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> --- a/xen/arch/x86/cpu/mtrr/main.c +++ b/xen/arch/x86/cpu/mtrr/main.c @@ -340,7 +340,7 @@ int mtrr_add_page(unsigned long base, un 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; } _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Andrew Cooper
2013-Aug-13 16:55 UTC
Re: [PATCH] x86/MTRR: fix range check in mtrr_add_page()
On 13/08/13 16:45, Jan Beulich wrote:> 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>> > --- a/xen/arch/x86/cpu/mtrr/main.c > +++ b/xen/arch/x86/cpu/mtrr/main.c > @@ -340,7 +340,7 @@ int mtrr_add_page(unsigned long base, un > 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; > } > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel_______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel
Keir Fraser
2013-Aug-13 17:34 UTC
Re: [PATCH] x86/MTRR: fix range check in mtrr_add_page()
On 13/08/2013 16:45, "Jan Beulich" <JBeulich@suse.com> wrote:> 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>Acked-by: Keir Fraser <keir@xen.org>> --- a/xen/arch/x86/cpu/mtrr/main.c > +++ b/xen/arch/x86/cpu/mtrr/main.c > @@ -340,7 +340,7 @@ int mtrr_add_page(unsigned long base, un > 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; > } > > >