xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: tim@xen.org, Ian.Campbell@citrix.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v3 1/6] xen: improve changes to xen_add_to_physmap
Date: Thu, 16 Aug 2012 15:50:07 +0100	[thread overview]
Message-ID: <1345128612-10323-1-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1208161523420.4850@kaball.uk.xensource.com>

This is an incremental patch on top of
c0bc926083b5987a3e9944eec2c12ad0580100e2: in order to retain binary
compatibility, it is better to introduce foreign_domid as part of a
union containing both size and foreign_domid.

Changes in v2:

- do not use an anonymous union.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 tools/firmware/hvmloader/pci.c  |    2 +-
 xen/arch/arm/mm.c               |    2 +-
 xen/arch/x86/mm.c               |   10 +++++-----
 xen/arch/x86/x86_64/compat/mm.c |    6 ++++++
 xen/include/public/memory.h     |   11 +++++++----
 5 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tools/firmware/hvmloader/pci.c b/tools/firmware/hvmloader/pci.c
index fd56e50..6375989 100644
--- a/tools/firmware/hvmloader/pci.c
+++ b/tools/firmware/hvmloader/pci.c
@@ -212,7 +212,7 @@ void pci_setup(void)
         xatp.space = XENMAPSPACE_gmfn_range;
         xatp.idx   = hvm_info->low_mem_pgend;
         xatp.gpfn  = hvm_info->high_mem_pgend;
-        xatp.size  = nr_pages;
+        xatp.u.size  = nr_pages;
         if ( hypercall_memory_op(XENMEM_add_to_physmap, &xatp) != 0 )
             BUG();
         hvm_info->high_mem_pgend += nr_pages;
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 08bc55b..2400e1c 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -506,7 +506,7 @@ static int xenmem_add_to_physmap_once(
         paddr_t maddr;
         struct domain *od;
 
-        rc = rcu_lock_target_domain_by_id(xatp->foreign_domid, &od);
+        rc = rcu_lock_target_domain_by_id(xatp->u.foreign_domid, &od);
         if ( rc < 0 )
             return rc;
         maddr = p2m_lookup(od, xatp->idx << PAGE_SHIFT);
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 9f63974..f5c704e 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4630,7 +4630,7 @@ static int xenmem_add_to_physmap(struct domain *d,
             this_cpu(iommu_dont_flush_iotlb) = 1;
 
         start_xatp = *xatp;
-        while ( xatp->size > 0 )
+        while ( xatp->u.size > 0 )
         {
             rc = xenmem_add_to_physmap_once(d, xatp);
             if ( rc < 0 )
@@ -4638,10 +4638,10 @@ static int xenmem_add_to_physmap(struct domain *d,
 
             xatp->idx++;
             xatp->gpfn++;
-            xatp->size--;
+            xatp->u.size--;
 
             /* Check for continuation if it's not the last interation */
-            if ( xatp->size > 0 && hypercall_preempt_check() )
+            if ( xatp->u.size > 0 && hypercall_preempt_check() )
             {
                 rc = -EAGAIN;
                 break;
@@ -4651,8 +4651,8 @@ static int xenmem_add_to_physmap(struct domain *d,
         if ( need_iommu(d) )
         {
             this_cpu(iommu_dont_flush_iotlb) = 0;
-            iommu_iotlb_flush(d, start_xatp.idx, start_xatp.size - xatp->size);
-            iommu_iotlb_flush(d, start_xatp.gpfn, start_xatp.size - xatp->size);
+            iommu_iotlb_flush(d, start_xatp.idx, start_xatp.u.size - xatp->u.size);
+            iommu_iotlb_flush(d, start_xatp.gpfn, start_xatp.u.size - xatp->u.size);
         }
 
         return rc;
diff --git a/xen/arch/x86/x86_64/compat/mm.c b/xen/arch/x86/x86_64/compat/mm.c
index f497503..5bcd2fd 100644
--- a/xen/arch/x86/x86_64/compat/mm.c
+++ b/xen/arch/x86/x86_64/compat/mm.c
@@ -59,10 +59,16 @@ int compat_arch_memory_op(int op, XEN_GUEST_HANDLE(void) arg)
     {
         struct compat_add_to_physmap cmp;
         struct xen_add_to_physmap *nat = COMPAT_ARG_XLAT_VIRT_BASE;
+        enum XLAT_add_to_physmap_u u;
 
         if ( copy_from_guest(&cmp, arg, 1) )
             return -EFAULT;
 
+        if ( cmp.space == XENMAPSPACE_gmfn_range )
+            u = XLAT_add_to_physmap_u_size;
+        if ( cmp.space == XENMAPSPACE_gmfn_foreign )
+            u = XLAT_add_to_physmap_u_foreign_domid;
+
         XLAT_add_to_physmap(nat, &cmp);
         rc = arch_memory_op(op, guest_handle_from_ptr(nat, void));
 
diff --git a/xen/include/public/memory.h b/xen/include/public/memory.h
index b2adfbe..7d4ee26 100644
--- a/xen/include/public/memory.h
+++ b/xen/include/public/memory.h
@@ -208,8 +208,12 @@ struct xen_add_to_physmap {
     /* Which domain to change the mapping for. */
     domid_t domid;
 
-    /* Number of pages to go through for gmfn_range */
-    uint16_t    size;
+    union {
+        /* Number of pages to go through for gmfn_range */
+        uint16_t    size;
+        /* IFF gmfn_foreign */
+        domid_t foreign_domid;
+    } u;
 
     /* Source mapping space. */
 #define XENMAPSPACE_shared_info  0 /* shared info page */
@@ -217,8 +221,7 @@ struct xen_add_to_physmap {
 #define XENMAPSPACE_gmfn         2 /* GMFN */
 #define XENMAPSPACE_gmfn_range   3 /* GMFN range */
 #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another guest */
-    uint16_t space;
-    domid_t foreign_domid; /* IFF gmfn_foreign */
+    unsigned int space;
 
 #define XENMAPIDX_grant_table_status 0x80000000
 
-- 
1.7.2.5

  reply	other threads:[~2012-08-16 14:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 14:48 [PATCH v3 0/6] ARM hypercall ABI: 64 bit ready Stefano Stabellini
2012-08-16 14:50 ` Stefano Stabellini [this message]
2012-08-16 14:50 ` [PATCH v3 2/6] xen: xen_ulong_t substitution Stefano Stabellini
2012-08-16 14:50 ` [PATCH v3 3/6] xen: change the limit of nr_extents to UINT_MAX >> MEMOP_EXTENT_SHIFT Stefano Stabellini
2012-08-16 14:50 ` [PATCH v3 4/6] xen: introduce XEN_GUEST_HANDLE_PARAM Stefano Stabellini
2012-08-16 15:54   ` Jan Beulich
2012-08-16 16:11     ` Jan Beulich
2012-08-16 17:10       ` Stefano Stabellini
2012-08-17  8:02         ` Ian Campbell
2012-08-17  9:46           ` Jan Beulich
2012-08-17 13:47             ` Stefano Stabellini
2012-08-17 13:51               ` Ian Campbell
2012-08-17 13:55                 ` Stefano Stabellini
2012-08-17 14:05                   ` Jan Beulich
2012-08-17 13:58               ` Jan Beulich
2012-08-17 14:45                 ` Stefano Stabellini
2012-08-17 14:59                   ` Jan Beulich
2012-08-17 14:50                 ` Ian Campbell
2012-08-17 14:53                   ` Stefano Stabellini
2012-08-17 14:57                   ` Jan Beulich
2012-08-17 15:06                     ` Ian Campbell
2012-08-16 17:08     ` Stefano Stabellini
2012-08-17  9:17       ` Jan Beulich
2012-08-17 13:51         ` Stefano Stabellini
2012-08-16 14:50 ` [PATCH v3 5/6] xen: replace XEN_GUEST_HANDLE with XEN_GUEST_HANDLE_PARAM when appropriate Stefano Stabellini
2012-08-16 14:50 ` [PATCH v3 6/6] xen: more substitutions Stefano Stabellini
2012-10-16 10:36 ` [PATCH v3 0/6] ARM hypercall ABI: 64 bit ready Ian Campbell
2012-10-17 16:51   ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1345128612-10323-1-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).