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 v2 3/4] libxc: fixes for the ARM platform
Date: Wed, 16 Jan 2013 18:58:54 +0000	[thread overview]
Message-ID: <1358362736-2870-3-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1301161853130.4978@kaball.uk.xensource.com>

Make xc_dom_feature_translated an arch-dependent function.

alloc_magic_pages: save console and xenstore pfn's in xc_dom_image.
alloc_magic_pages: set HVM_PARAM_CONSOLE_EVTCHN and
HVM_PARAM_STORE_EVTCHN hvm_params using the event channels allocated by
the toolstack.

Call xc_dom_gnttab_hvm_seed instead of xc_dom_gnttab_seed in
xc_dom_gnttab_init for autotranslated guests.


Changes on v2:
- add xc_dom_gnttab_init changes.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 tools/libxc/xc_core_arm.h |    2 ++
 tools/libxc/xc_core_x86.h |    5 +++++
 tools/libxc/xc_dom.h      |    6 +-----
 tools/libxc/xc_dom_arm.c  |   19 ++++++++++++-------
 tools/libxc/xc_dom_boot.c |   23 ++++++++++-------------
 5 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/tools/libxc/xc_core_arm.h b/tools/libxc/xc_core_arm.h
index 3a6be2a..c046250 100644
--- a/tools/libxc/xc_core_arm.h
+++ b/tools/libxc/xc_core_arm.h
@@ -33,6 +33,8 @@ struct xc_core_arch_context {
                                                                 (0)
 #define xc_core_arch_context_dump(xch, arch_ctxt, args, dump_rtn)    (0)
 
+#define xc_dom_feature_translated(dom) (1)
+
 int
 xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
                               unsigned long pfn);
diff --git a/tools/libxc/xc_core_x86.h b/tools/libxc/xc_core_x86.h
index 7b209f6..ee7d8b1 100644
--- a/tools/libxc/xc_core_x86.h
+++ b/tools/libxc/xc_core_x86.h
@@ -34,6 +34,11 @@ struct xc_core_arch_context {
                                                                 (0)
 #define xc_core_arch_context_dump(xch, arch_ctxt, args, dump_rtn)    (0)
 
+static inline int xc_dom_feature_translated(struct xc_dom_image *dom)
+{
+    return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active);
+}
+
 int
 xc_core_arch_gpfn_may_present(struct xc_core_arch_context *arch_ctxt,
                               unsigned long pfn);
diff --git a/tools/libxc/xc_dom.h b/tools/libxc/xc_dom.h
index eccc516..b5e17be 100644
--- a/tools/libxc/xc_dom.h
+++ b/tools/libxc/xc_dom.h
@@ -15,6 +15,7 @@
  */
 
 #include <xen/libelf/libelf.h>
+#include <xc_core.h>
 
 #define INVALID_P2M_ENTRY   ((xen_pfn_t)-1)
 
@@ -312,11 +313,6 @@ static inline void *xc_dom_vaddr_to_ptr(struct xc_dom_image *dom,
     return (ptr ? (ptr + offset) : NULL);
 }
 
-static inline int xc_dom_feature_translated(struct xc_dom_image *dom)
-{
-    return elf_xen_feature_get(XENFEAT_auto_translated_physmap, dom->f_active);
-}
-
 static inline xen_pfn_t xc_dom_p2m_host(struct xc_dom_image *dom, xen_pfn_t pfn)
 {
     if (dom->shadow_enabled)
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index b743a6c..0cec774 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -51,7 +51,7 @@ static int setup_pgtables_arm(struct xc_dom_image *dom)
 static int alloc_magic_pages(struct xc_dom_image *dom)
 {
     int rc, i;
-    xen_pfn_t store_pfn, console_pfn, p2m[NR_MAGIC_PAGES];
+    xen_pfn_t p2m[NR_MAGIC_PAGES];
 
     DOMPRINTF_CALLED(dom->xch);
 
@@ -64,15 +64,20 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
     if ( rc < 0 )
         return rc;
 
-    console_pfn = dom->rambase_pfn + dom->total_pages + CONSOLE_PFN_OFFSET;
-    store_pfn = dom->rambase_pfn + dom->total_pages + XENSTORE_PFN_OFFSET;
+    dom->console_pfn = dom->rambase_pfn + dom->total_pages + CONSOLE_PFN_OFFSET;
+    dom->xenstore_pfn = dom->rambase_pfn + dom->total_pages + XENSTORE_PFN_OFFSET;
 
-    xc_clear_domain_page(dom->xch, dom->guest_domid, console_pfn);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, store_pfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn);
     xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN,
-            console_pfn);
+            dom->console_pfn);
     xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN,
-            store_pfn);
+            dom->xenstore_pfn);
+    /* allocated by toolstack */
+    xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_EVTCHN,
+            dom->console_evtchn);
+    xc_set_hvm_param(dom->xch, dom->guest_domid, HVM_PARAM_STORE_EVTCHN,
+            dom->xenstore_evtchn);
 
     return 0;
 }
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index f83aa12..c7f04a8 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -416,19 +416,16 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t domid,
 
 int xc_dom_gnttab_init(struct xc_dom_image *dom)
 {
-    xen_pfn_t console_gmfn;
-    xen_pfn_t xenstore_gmfn;
-    int autotranslated;
-
-    autotranslated = xc_dom_feature_translated(dom);
-    console_gmfn = autotranslated ?
-           dom->console_pfn : xc_dom_p2m_host(dom, dom->console_pfn);
-    xenstore_gmfn = autotranslated ?
-           dom->xenstore_pfn : xc_dom_p2m_host(dom, dom->xenstore_pfn);
-
-    return xc_dom_gnttab_seed(dom->xch, dom->guest_domid,
-                              console_gmfn, xenstore_gmfn,
-                              dom->console_domid, dom->xenstore_domid);
+    if ( xc_dom_feature_translated(dom) ) {
+        return xc_dom_gnttab_hvm_seed(dom->xch, dom->guest_domid,
+                                      dom->console_pfn, dom->xenstore_pfn,
+                                      dom->console_domid, dom->xenstore_domid);
+    } else {
+        return xc_dom_gnttab_seed(dom->xch, dom->guest_domid,
+                                  xc_dom_p2m_host(dom, dom->console_pfn),
+                                  xc_dom_p2m_host(dom, dom->xenstore_pfn),
+                                  dom->console_domid, dom->xenstore_domid);
+    }
 }
 
 /*
-- 
1.7.2.5

  parent reply	other threads:[~2013-01-16 18:58 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-16 18:57 [PATCH v2 0/4] xen/arm: compile and run xl Stefano Stabellini
2013-01-16 18:58 ` [PATCH v2 1/4] xen: move XEN_SYSCTL_physinfo, XEN_SYSCTL_numainfo and XEN_SYSCTL_topologyinfo to common code Stefano Stabellini
2013-01-24 17:37   ` Ian Campbell
2013-02-14 11:28     ` Stefano Stabellini
2013-01-16 18:58 ` [PATCH v2 2/4] xen/arm: implement gnttab_create_shared_page and gnttab_shared_gmfn Stefano Stabellini
2013-01-24 17:39   ` Ian Campbell
2013-01-16 18:58 ` Stefano Stabellini [this message]
2013-01-24 17:40   ` [PATCH v2 3/4] libxc: fixes for the ARM platform Ian Campbell
2013-02-14 11:44     ` Ian Campbell
2013-01-16 18:58 ` [PATCH v2 4/4] xen/arm: compile and run libxl/xl Stefano Stabellini
2013-01-24 17:43   ` 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=1358362736-2870-3-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).