From: "Jan Beulich" Subject: [PATCH 5/6] gnttab: fix/adjust gnttab_transfer() Date: Fri, 12 Jun 2015 11:38:07 +0100 Message-ID: <557AD2AF02000078000841EA@mail.emea.novell.com> References: <557AD03E02000078000841B4@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part6E5A4C9F.1__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Z3MLi-0004DJ-Nv for xen-devel@lists.xenproject.org; Fri, 12 Jun 2015 10:38:10 +0000 In-Reply-To: <557AD03E02000078000841B4@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. --=__Part6E5A4C9F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - don't update shared entry's frame number for translated domains (as MFNs shouldn't be exposed to such guests) - for v1 grant table format, force copying of the page also when the intended MFN doesn't fit in 32 bits (and the domain isn't translated) - fix an apparent off-by-one error (it's unclear to me why commit 5cc77f9098 ("32-on-64: Fix domain address-size clamping, implement") uses BITS_PER_LONG-1 here, while using BITS_PER_LONG in the two other invocations of domain_clamp_alloc_bitsize()) - adjust comments accompanying the shared entry's frame field Signed-off-by: Jan Beulich --- a/xen/common/grant_table.c +++ b/xen/common/grant_table.c @@ -1639,7 +1639,8 @@ gnttab_transfer( } =20 max_bitsize =3D domain_clamp_alloc_bitsize( - e, BITS_PER_LONG+PAGE_SHIFT-1); + e, e->grant_table->gt_version > 1 || paging_mode_translate(e) + ? BITS_PER_LONG + PAGE_SHIFT : 32 + PAGE_SHIFT); if ( (1UL << (max_bitsize - PAGE_SHIFT)) <=3D mfn ) { struct page_info *new_page; @@ -1736,14 +1737,18 @@ gnttab_transfer( if ( e->grant_table->gt_version =3D=3D 1 ) { grant_entry_v1_t *sha =3D &shared_entry_v1(e->grant_table, = gop.ref); + guest_physmap_add_page(e, sha->frame, mfn, 0); - sha->frame =3D mfn; + if ( !paging_mode_translate(e) ) + sha->frame =3D mfn; } else { grant_entry_v2_t *sha =3D &shared_entry_v2(e->grant_table, = gop.ref); + guest_physmap_add_page(e, sha->full_page.frame, mfn, 0); - sha->full_page.frame =3D mfn; + if ( !paging_mode_translate(e) ) + sha->full_page.frame =3D mfn; } smp_wmb(); shared_entry_header(e->grant_table, gop.ref)->flags |=3D --- a/xen/include/public/grant_table.h +++ b/xen/include/public/grant_table.h @@ -134,8 +134,10 @@ struct grant_entry_v1 { /* The domain being granted foreign privileges. [GST] */ domid_t domid; /* - * GTF_permit_access: Frame that @domid is allowed to map and access. = [GST] - * GTF_accept_transfer: Frame whose ownership transferred by @domid. = [XEN] + * GTF_permit_access: GFN that @domid is allowed to map and access. = [GST] + * GTF_accept_transfer: GFN that @domid is allowed to transfer into. = [GST] + * GTF_transfer_completed: MFN whose ownership transferred by @domid + * (non-translated guests only). [XEN] */ uint32_t frame; }; --=__Part6E5A4C9F.1__= Content-Type: text/plain; name="gnttab-transfer.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="gnttab-transfer.patch" gnttab: fix/adjust gnttab_transfer()=0A=0A- don't update shared entry's = frame number for translated domains (as=0A MFNs shouldn't be exposed to = such guests)=0A- for v1 grant table format, force copying of the page also = when the=0A intended MFN doesn't fit in 32 bits (and the domain isn't = translated)=0A- fix an apparent off-by-one error (it's unclear to me why = commit=0A 5cc77f9098 ("32-on-64: Fix domain address-size clamping, = implement")=0A uses BITS_PER_LONG-1 here, while using BITS_PER_LONG in = the two other=0A invocations of domain_clamp_alloc_bitsize())=0A- adjust = comments accompanying the shared entry's frame field=0A=0ASigned-off-by: = Jan Beulich =0A=0A--- a/xen/common/grant_table.c=0A+++ = b/xen/common/grant_table.c=0A@@ -1639,7 +1639,8 @@ gnttab_transfer(=0A = }=0A =0A max_bitsize =3D domain_clamp_alloc_bitsize(=0A- = e, BITS_PER_LONG+PAGE_SHIFT-1);=0A+ e, e->grant_table->gt_v= ersion > 1 || paging_mode_translate(e)=0A+ ? BITS_PER_LONG + = PAGE_SHIFT : 32 + PAGE_SHIFT);=0A if ( (1UL << (max_bitsize - = PAGE_SHIFT)) <=3D mfn )=0A {=0A struct page_info = *new_page;=0A@@ -1736,14 +1737,18 @@ gnttab_transfer(=0A if ( = e->grant_table->gt_version =3D=3D 1 )=0A {=0A = grant_entry_v1_t *sha =3D &shared_entry_v1(e->grant_table, gop.ref);=0A+=0A= guest_physmap_add_page(e, sha->frame, mfn, 0);=0A- = sha->frame =3D mfn;=0A+ if ( !paging_mode_translate(e) )=0A+ = sha->frame =3D mfn;=0A }=0A else=0A = {=0A grant_entry_v2_t *sha =3D &shared_entry_v2(e->grant_table,= gop.ref);=0A+=0A guest_physmap_add_page(e, sha->full_page.fram= e, mfn, 0);=0A- sha->full_page.frame =3D mfn;=0A+ if = ( !paging_mode_translate(e) )=0A+ sha->full_page.frame =3D = mfn;=0A }=0A smp_wmb();=0A shared_entry_header(e->g= rant_table, gop.ref)->flags |=3D=0A--- a/xen/include/public/grant_table.h= =0A+++ b/xen/include/public/grant_table.h=0A@@ -134,8 +134,10 @@ struct = grant_entry_v1 {=0A /* The domain being granted foreign privileges. = [GST] */=0A domid_t domid;=0A /*=0A- * GTF_permit_access: = Frame that @domid is allowed to map and access. [GST]=0A- * GTF_accept_= transfer: Frame whose ownership transferred by @domid. [XEN]=0A+ * = GTF_permit_access: GFN that @domid is allowed to map and access. [GST]=0A+ = * GTF_accept_transfer: GFN that @domid is allowed to transfer into. = [GST]=0A+ * GTF_transfer_completed: MFN whose ownership transferred by = @domid=0A+ * (non-translated guests only). = [XEN]=0A */=0A uint32_t frame;=0A };=0A --=__Part6E5A4C9F.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 --=__Part6E5A4C9F.1__=--