From: "Jan Beulich" Subject: [PATCH 3/4] x86/EPT: fix pinned cache attribute range checking Date: Wed, 23 Apr 2014 09:41:01 +0100 Message-ID: <535798BD020000780000B2EA@nat28.tlf.novell.com> References: <53579447020000780000B2A9@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part9DAF948D.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wcsjo-00048O-Uf for xen-devel@lists.xenproject.org; Wed, 23 Apr 2014 08:41:05 +0000 In-Reply-To: <53579447020000780000B2A9@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: xen-devel Cc: Keir Fraser , Kevin Tian , Eddie Dong , Jun Nakajima , Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part9DAF948D.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This wasn't done properly by 4d66f069 ("x86: fix pinned cache attribute handling"): The passed in GFN shouldn't be assumed to be order aligned. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/mtrr.c +++ b/xen/arch/x86/hvm/mtrr.c @@ -589,6 +589,7 @@ int hvm_get_mem_pinned_cacheattr( uint32_t *type) { struct hvm_mem_pinned_cacheattr_range *range; + uint64_t mask =3D ~(uint64_t)0 << order; int rc =3D 0; =20 *type =3D ~0; @@ -601,15 +602,15 @@ int hvm_get_mem_pinned_cacheattr( &d->arch.hvm_domain.pinned_cacheattr_ranges,= list ) { - if ( (guest_fn >=3D range->start) && - (guest_fn + (1UL << order) - 1 <=3D range->end) ) + if ( ((guest_fn & mask) >=3D range->start) && + ((guest_fn | ~mask) <=3D range->end) ) { *type =3D range->type; rc =3D 1; break; } - if ( (guest_fn <=3D range->end) && - (range->start <=3D guest_fn + (1UL << order) - 1) ) + if ( ((guest_fn & mask) <=3D range->end) && + (range->start <=3D (guest_fn | ~mask)) ) { rc =3D -1; break; --=__Part9DAF948D.1__= Content-Type: text/plain; name="x86-get-pinned-order.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-get-pinned-order.patch" x86/EPT: fix pinned cache attribute range checking=0A=0AThis wasn't done = properly by 4d66f069 ("x86: fix pinned cache attribute=0Ahandling"): The = passed in GFN shouldn't be assumed to be order aligned.=0A=0ASigned-off-by:= Jan Beulich =0A=0A--- a/xen/arch/x86/hvm/mtrr.c=0A+++ = b/xen/arch/x86/hvm/mtrr.c=0A@@ -589,6 +589,7 @@ int hvm_get_mem_pinned_cach= eattr(=0A uint32_t *type)=0A {=0A struct hvm_mem_pinned_cacheattr_r= ange *range;=0A+ uint64_t mask =3D ~(uint64_t)0 << order;=0A int rc = =3D 0;=0A =0A *type =3D ~0;=0A@@ -601,15 +602,15 @@ int hvm_get_mem_pin= ned_cacheattr(=0A &d->arch.hvm_domain.pinned_= cacheattr_ranges,=0A list )=0A {=0A- = if ( (guest_fn >=3D range->start) &&=0A- (guest_fn + (1UL = << order) - 1 <=3D range->end) )=0A+ if ( ((guest_fn & mask) >=3D = range->start) &&=0A+ ((guest_fn | ~mask) <=3D range->end) )=0A = {=0A *type =3D range->type;=0A rc =3D = 1;=0A break;=0A }=0A- if ( (guest_fn <=3D = range->end) &&=0A- (range->start <=3D guest_fn + (1UL << = order) - 1) )=0A+ if ( ((guest_fn & mask) <=3D range->end) &&=0A+ = (range->start <=3D (guest_fn | ~mask)) )=0A {=0A = rc =3D -1;=0A break;=0A --=__Part9DAF948D.1__= 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 --=__Part9DAF948D.1__=--