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.Deegan@xen.org, Ian.Campbell@citrix.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v2 6/6] xen/arm: grant table
Date: Fri, 20 Jul 2012 16:05:58 +0100	[thread overview]
Message-ID: <1342796758-4958-6-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <1342796758-4958-1-git-send-email-stefano.stabellini@eu.citrix.com>

Implement XENMAPSPACE_grant_table and grant_table_op.

Introduce an HVM_PARAM to tell the guest where to map the grant table
(HVM_PARAM_GRANT_START_PFN), similarly to what we do with
HVM_PARAM_CONSOLE_PFN and HVM_PARAM_STORE_PFN.
However HVM_PARAM_GRANT_START_PFN is also going to be used by dom0, so
we set the parameter in Xen rather than libxc.
Using HVM_PARAM_GRANT_START_PFN removes the need for a platform pci
device.

Statically set HVM_PARAM_GRANT_START_PFN to 0xb0000000 for now.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Tim Deegan <tim@xen.org>
---
 xen/arch/arm/domain.c           |    3 +++
 xen/arch/arm/mm.c               |   29 ++++++++++++++++++++++++++++-
 xen/arch/arm/traps.c            |    1 +
 xen/include/public/hvm/params.h |    4 +++-
 4 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 6e1e08a..7c56cf3 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -345,6 +345,9 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)
 
         if ( (rc = p2m_alloc_table(d)) != 0 )
             goto fail;
+
+        /* XXX: select this dynamically */
+        d->arch.hvm_domain.params[HVM_PARAM_GRANT_START_PFN] = 0xb0000;
     }
 
     if ( (rc = domain_vgic_init(d)) != 0 )
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 7033023..2f28a18 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -25,6 +25,7 @@
 #include <xen/mm.h>
 #include <xen/preempt.h>
 #include <xen/errno.h>
+#include <xen/grant_table.h>
 #include <xen/guest_access.h>
 #include <asm/page.h>
 #include <asm/current.h>
@@ -477,7 +478,7 @@ static int xenmem_add_to_physmap_once(
     struct domain *d,
     const struct xen_add_to_physmap *xatp)
 {
-    unsigned long mfn = 0;
+    unsigned long mfn = 0, idx = 0;
     int rc;
 
     switch ( xatp->space )
@@ -506,6 +507,32 @@ static int xenmem_add_to_physmap_once(
         rcu_unlock_domain(od);
         break;
     }
+    case XENMAPSPACE_grant_table:
+        spin_lock(&d->grant_table->lock);
+
+        if ( d->grant_table->gt_version == 0 )
+            d->grant_table->gt_version = 1;
+
+        idx = xatp->idx;
+        if ( d->grant_table->gt_version == 2 &&
+                (xatp->idx & XENMAPIDX_grant_table_status) )
+        {
+            idx &= ~XENMAPIDX_grant_table_status;
+            if ( idx < nr_status_frames(d->grant_table) )
+                mfn = virt_to_mfn(d->grant_table->status[idx]);
+        }
+        else
+        {
+            if ( (idx >= nr_grant_frames(d->grant_table)) &&
+                    (idx < max_nr_grant_frames) )
+                gnttab_grow_table(d, idx + 1);
+
+            if ( idx < nr_grant_frames(d->grant_table) )
+                mfn = virt_to_mfn(d->grant_table->shared_raw[idx]);
+        }
+
+        spin_unlock(&d->grant_table->lock);
+        break;
     default:
         return -ENOSYS;
     }
diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 3900545..cdbd11f 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -431,6 +431,7 @@ static arm_hypercall_t *arm_hypercall_table[] = {
     HYPERCALL(physdev_op),
     HYPERCALL(sysctl),
     HYPERCALL(hvm_op),
+    HYPERCALL(grant_table_op),
 };
 
 static void do_debug_trap(struct cpu_user_regs *regs, unsigned int code)
diff --git a/xen/include/public/hvm/params.h b/xen/include/public/hvm/params.h
index 55c1b57..a2da05d 100644
--- a/xen/include/public/hvm/params.h
+++ b/xen/include/public/hvm/params.h
@@ -147,6 +147,8 @@
 #define HVM_PARAM_ACCESS_RING_PFN   28
 #define HVM_PARAM_SHARING_RING_PFN  29
 
-#define HVM_NR_PARAMS          30
+#define HVM_PARAM_GRANT_START_PFN 30
+
+#define HVM_NR_PARAMS          31
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */
-- 
1.7.2.5

  parent reply	other threads:[~2012-07-20 15:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 15:05 [PATCH v2 0/6] xen/arm: grant_table Stefano Stabellini
2012-07-20 15:05 ` [PATCH v2 1/6] Initialize lr_queue in vcpu_vgic_init for the first 32 irqs Stefano Stabellini
2012-07-20 15:05   ` [PATCH v2 2/6] xen/arm: set paging_mode_translate and paging_mode_external Stefano Stabellini
2012-07-20 15:05   ` [PATCH v2 3/6] xen/arm: implement page reference and grant table functions needed by grant_table.c Stefano Stabellini
2012-07-23 16:03     ` Ian Campbell
2012-07-24 10:25       ` Stefano Stabellini
2012-07-24 10:41         ` Ian Campbell
2012-07-26 17:56           ` Stefano Stabellini
2012-07-27  7:57             ` Ian Campbell
2012-07-20 15:05   ` [PATCH v2 4/6] xen/arm: implement get/put_page_type Stefano Stabellini
2012-07-23 16:08     ` Ian Campbell
2012-07-24 10:27       ` Stefano Stabellini
2012-07-24 10:42         ` Ian Campbell
2012-07-26 18:03           ` Stefano Stabellini
2012-07-23 20:01     ` Tim Deegan
2012-07-24 10:21       ` Stefano Stabellini
2012-07-20 15:05   ` [PATCH v2 5/6] xen/arm: create_p2m_entries should not call free_domheap_page Stefano Stabellini
2012-07-23 16:25     ` Ian Campbell
2012-07-24 10:28       ` Stefano Stabellini
2012-07-20 15:05   ` Stefano Stabellini [this message]
2012-07-23 16:13     ` [PATCH v2 6/6] xen/arm: grant table Ian Campbell
2012-07-24 10:30       ` Stefano Stabellini
2012-07-23 16:24   ` [PATCH v2 1/6] Initialize lr_queue in vcpu_vgic_init for the first 32 irqs Ian Campbell
2012-07-23 16:30 ` [PATCH v2 0/6] xen/arm: grant_table Ian Campbell

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=1342796758-4958-6-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=Tim.Deegan@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).