From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] x86/MTRR: fix range check in mtrr_add_page() Date: Tue, 13 Aug 2013 17:55:55 +0100 Message-ID: <520A651B.2030105@citrix.com> References: <520A709D02000078000EB977@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4228790871918168897==" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1V9Ht1-0000qf-5k for xen-devel@lists.xenproject.org; Tue, 13 Aug 2013 16:55:59 +0000 In-Reply-To: <520A709D02000078000EB977@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Keir Fraser List-Id: xen-devel@lists.xenproject.org --===============4228790871918168897== Content-Type: multipart/alternative; boundary="------------090701020700040603060904" --------------090701020700040603060904 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit 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 Reviewed-by: Andrew Cooper > > --- 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 --------------090701020700040603060904 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
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

--------------090701020700040603060904-- --===============4228790871918168897== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============4228790871918168897==--