aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/memory.c
diff options
context:
space:
mode:
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>2012-01-28 13:47:24 +0000
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>2012-01-28 13:47:24 +0000
commit14eb3b41d03f75b89928fad8f720f7d49598b0be (patch)
tree9ee446aae1f6ade9547d28a66f3b98bdea22993e /xen/common/memory.c
parent0057a949dea2d22b1d9be884a7bd9912aa7f03cc (diff)
downloadxen-14eb3b41d03f75b89928fad8f720f7d49598b0be.tar.gz
xen-14eb3b41d03f75b89928fad8f720f7d49598b0be.tar.bz2
xen-14eb3b41d03f75b89928fad8f720f7d49598b0be.zip
xen: reinstate previously unused XENMEM_remove_from_physmap hypercall
This patch reinstates the XENMEM_remove_from_physmap hypercall which was removed in 19041:ee62aaafff46 because it was not used. However, is now needed in order to support xenstored stub domains. The xenstored stub domain is not priviliged like dom0 and so cannot unilaterally map the xenbus page of other guests into it's address space. Therefore, before creating a domU the domain builder needs to seed its grant table with a grant ref allowing the xenstored stub domain to access the new domU's xenbus page. At present domU's do not start with their grant table mapped. Instead it gets mapped when the guest requests a grant table from the hypervisor. In order to seed the grant table, the domain builder first needs to map it into dom0 address space. But the hypercall to do this requires a gpfn (guest pfn), which is an mfn for PV guest, but a pfn for HVM guests. Therfore, in order to seed the grant table of an HVM guest, dom0 needs to *temporarily* map it into the guest's "physical" address space. Hence the need to reinstate the XENMEM_remove_from_physmap hypercall. Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com> Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/common/memory.c')
-rw-r--r--xen/common/memory.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/xen/common/memory.c b/xen/common/memory.c
index 8d45439745..53886cea3b 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -659,6 +659,43 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE(void) arg)
break;
+ case XENMEM_remove_from_physmap:
+ {
+ struct xen_remove_from_physmap xrfp;
+ unsigned long mfn;
+ struct domain *d;
+
+ if ( copy_from_guest(&xrfp, arg, 1) )
+ return -EFAULT;
+
+ rc = rcu_lock_target_domain_by_id(xrfp.domid, &d);
+ if ( rc != 0 )
+ return rc;
+
+ if ( xsm_remove_from_physmap(current->domain, d) )
+ {
+ rcu_unlock_domain(d);
+ return -EPERM;
+ }
+
+ domain_lock(d);
+
+ mfn = get_gfn_untyped(d, xrfp.gpfn);
+
+ if ( mfn_valid(mfn) )
+ guest_physmap_remove_page(d, xrfp.gpfn, mfn, PAGE_ORDER_4K);
+ else
+ rc = -ENOENT;
+
+ put_gfn(d, xrfp.gpfn);
+
+ domain_unlock(d);
+
+ rcu_unlock_domain(d);
+
+ break;
+ }
+
default:
rc = arch_memory_op(op, arg);
break;