From: "Jan Beulich" Subject: [PATCH v2 2/3] gnttab: don't silently truncate frame numbers in gnttab_set_version() Date: Mon, 22 Jun 2015 12:45:40 +0100 Message-ID: <55881184020000780008775D@mail.emea.novell.com> References: <558810070200007800087749@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part3B0FE474.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z70Ab-0001JM-Mk for xen-devel@lists.xenproject.org; Mon, 22 Jun 2015 11:45:45 +0000 In-Reply-To: <558810070200007800087749@mail.emea.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: Ian Campbell , Keir Fraser , Ian Jackson , 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. --=__Part3B0FE474.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On a v2 -> v1 transition frame numbers previously stored in a 64-bit field have to fit into a 32-bit one. Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -2597,14 +2597,32 @@ gnttab_set_version(XEN_GUEST_HANDLE_PARA } } =20 - /* XXX: If we're going to version 2, we could maybe shrink the - active grant table here. */ - - if ( op.version =3D=3D 2 && gt->gt_version < 2 ) + switch ( gt->gt_version ) { - res =3D gnttab_populate_status_frames(d, gt, nr_grant_frames(gt));= - if ( res < 0) - goto out_unlock; + case 0: + if ( op.version =3D=3D 2 ) + { + case 1: + /* XXX: We could maybe shrink the active grant table here. */ + res =3D gnttab_populate_status_frames(d, gt, nr_grant_frames(g= t)); + if ( res < 0) + goto out_unlock; + } + break; + case 2: + for ( i =3D 0; i < GNTTAB_NR_RESERVED_ENTRIES; i++ ) + { + if ( ((shared_entry_v2(gt, i).hdr.flags & GTF_type_mask) = =3D=3D + GTF_permit_access) && + (shared_entry_v2(gt, i).full_page.frame >> 32) ) + { + gdprintk(XENLOG_WARNING, + "tried to change grant table version to 1 with = non-representable entries\n"); + res =3D -ERANGE; + goto out_unlock; + } + } + break; } =20 /* Preserve the first 8 entries (toolstack reserved grants) */ --=__Part3B0FE474.1__= Content-Type: text/plain; name="gnttab-set-version-no-truncate.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="gnttab-set-version-no-truncate.patch" gnttab: don't silently truncate frame numbers in gnttab_set_version()=0A=0A= On a v2 -> v1 transition frame numbers previously stored in a 64-bit=0Afiel= d have to fit into a 32-bit one.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/common/grant_table.c=0A+++ b/xen/common/grant_tabl= e.c=0A@@ -2597,14 +2597,32 @@ gnttab_set_version(XEN_GUEST_HANDLE_PARA=0A = }=0A }=0A =0A- /* XXX: If we're going to version 2, we could = maybe shrink the=0A- active grant table here. */=0A-=0A- if ( = op.version =3D=3D 2 && gt->gt_version < 2 )=0A+ switch ( gt->gt_version = )=0A {=0A- res =3D gnttab_populate_status_frames(d, gt, = nr_grant_frames(gt));=0A- if ( res < 0)=0A- goto = out_unlock;=0A+ case 0:=0A+ if ( op.version =3D=3D 2 )=0A+ = {=0A+ case 1:=0A+ /* XXX: We could maybe shrink the active = grant table here. */=0A+ res =3D gnttab_populate_status_frames(d= , gt, nr_grant_frames(gt));=0A+ if ( res < 0)=0A+ = goto out_unlock;=0A+ }=0A+ break;=0A+ case 2:=0A+ = for ( i =3D 0; i < GNTTAB_NR_RESERVED_ENTRIES; i++ )=0A+ {=0A+ = if ( ((shared_entry_v2(gt, i).hdr.flags & GTF_type_mask) =3D=3D=0A+ = GTF_permit_access) &&=0A+ (shared_entry_v2(= gt, i).full_page.frame >> 32) )=0A+ {=0A+ = gdprintk(XENLOG_WARNING,=0A+ "tried to change = grant table version to 1 with non-representable entries\n");=0A+ = res =3D -ERANGE;=0A+ goto out_unlock;=0A+ = }=0A+ }=0A+ break;=0A }=0A =0A /* Preserve the first = 8 entries (toolstack reserved grants) */=0A --=__Part3B0FE474.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 --=__Part3B0FE474.1__=--