x86/xen: fix set_phys_range_identity() if pfn_e > MAX_P2M_PFN
authorDavid Vrabel <david.vrabel@citrix.com>
Mon, 6 Jan 2014 11:55:13 +0000 (11:55 +0000)
committerDavid Vrabel <david.vrabel@citrix.com>
Thu, 15 May 2014 15:13:23 +0000 (16:13 +0100)
Allow set_phys_range_identity() to work with a range that overlaps
MAX_P2M_PFN by clamping pfn_e to MAX_P2M_PFN.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
arch/x86/xen/p2m.c

index 4fc71cc1705ba4be902eabbfdeca64eb00a6b07a..82c8c9305510e92c8c76d2c869b1cc52d14ccc2b 100644 (file)
@@ -774,7 +774,7 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,
 {
        unsigned long pfn;
 
-       if (unlikely(pfn_s >= MAX_P2M_PFN || pfn_e >= MAX_P2M_PFN))
+       if (unlikely(pfn_s >= MAX_P2M_PFN))
                return 0;
 
        if (unlikely(xen_feature(XENFEAT_auto_translated_physmap)))
@@ -783,6 +783,9 @@ unsigned long __init set_phys_range_identity(unsigned long pfn_s,
        if (pfn_s > pfn_e)
                return 0;
 
+       if (pfn_e > MAX_P2M_PFN)
+               pfn_e = MAX_P2M_PFN;
+
        for (pfn = (pfn_s & ~(P2M_MID_PER_PAGE * P2M_PER_PAGE - 1));
                pfn < ALIGN(pfn_e, (P2M_MID_PER_PAGE * P2M_PER_PAGE));
                pfn += P2M_MID_PER_PAGE * P2M_PER_PAGE)