]> xenbits.xensource.com Git - xen.git/commitdiff
x86/MTRR: fix range check in mtrr_add_page()
authorJan Beulich <jbeulich@suse.com>
Tue, 20 Aug 2013 13:01:10 +0000 (15:01 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 20 Aug 2013 13:01:10 +0000 (15:01 +0200)
Extracted from Yinghai Lu's Linux commit d5c78673 ("x86: Fix /proc/mtrr
with base/size more than 44bits").

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
master commit: f67af6d5803b6a015e30cb490a94f9547cb0437c
master date: 2013-08-14 11:20:26 +0200

xen/arch/x86/cpu/mtrr/main.c

index a201d72b6da43048431615b7023c48fbc62a02d6..f7fc0a6e4b07f2fa3fb59dfeaf60cc0fee3fe624 100644 (file)
@@ -340,7 +340,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
                return -EINVAL;
        }
 
-       if (base & size_or_mask || size & size_or_mask) {
+       if ((base | (base + size - 1)) >> (paddr_bits - PAGE_SHIFT)) {
                printk(KERN_WARNING "mtrr: base or size exceeds the MTRR width\n");
                return -EINVAL;
        }