Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932540AbbFHMJm (ORCPT ); Mon, 8 Jun 2015 08:09:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43104 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbbFHMHF (ORCPT ); Mon, 8 Jun 2015 08:07:05 -0400 From: Juergen Gross To: xen-devel@lists.xensource.com, konrad.wilk@oracle.com, david.vrabel@citrix.com, boris.ostrovsky@oracle.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Juergen Gross Subject: [Patch V4 07/16] xen: check memory area against e820 map Date: Mon, 8 Jun 2015 14:06:48 +0200 Message-Id: <1433765217-16333-8-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433765217-16333-1-git-send-email-jgross@suse.com> References: <1433765217-16333-1-git-send-email-jgross@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1920 Lines: 65 Provide a service routine to check a physical memory area against the E820 map. The routine will return false if the complete area is RAM according to the E820 map and true otherwise. Signed-off-by: Juergen Gross Reviewed-by: David Vrabel --- arch/x86/xen/setup.c | 23 +++++++++++++++++++++++ arch/x86/xen/xen-ops.h | 1 + 2 files changed, 24 insertions(+) diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 87251b4..99ef82c 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c @@ -573,6 +573,29 @@ static unsigned long __init xen_count_remap_pages(unsigned long max_pfn) return extra; } +bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size) +{ + struct e820entry *entry; + unsigned mapcnt; + phys_addr_t end; + + if (!size) + return false; + + end = start + size; + entry = xen_e820_map; + + for (mapcnt = 0; mapcnt < xen_e820_map_entries; mapcnt++) { + if (entry->type == E820_RAM && entry->addr <= start && + (entry->addr + entry->size) >= end) + return false; + + entry++; + } + + return true; +} + /* * Reserve Xen mfn_list. * See comment above "struct start_info" in diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h index 9e195c6..c1385b8 100644 --- a/arch/x86/xen/xen-ops.h +++ b/arch/x86/xen/xen-ops.h @@ -39,6 +39,7 @@ void xen_reserve_top(void); void xen_mm_pin_all(void); void xen_mm_unpin_all(void); +bool __init xen_is_e820_reserved(phys_addr_t start, phys_addr_t size); unsigned long __ref xen_chk_extra_mem(unsigned long pfn); void __init xen_inv_extra_mem(void); void __init xen_remap_memory(void); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/