From a50658f644f72b42da86c9fd98bafc29fe00c039 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 17 Oct 2012 09:51:25 +0100 Subject: [PATCH] xen: x86 pvh: use XENMEM_add_to_physmap_range for foreign gmfn mappings Squeezing the necessary fields into the existing XENMEM_add_to_physmap interface was proving to be a bit tricky so we have decided to go with a new interface upstream (the XENMAPSPACE_gmfn_foreign interface using XENMEM_add_to_physmap was never committed anywhere). This interface also allows for batching which was impossible to support at the same time as foreign mfns in the old interface. This reverts the relevant parts of "PVH: basic and header changes, elfnote changes, ..." and followups and trivially converts pvh_add_to_xen_p2m over. Acked-by: Mukesh Rathor Acked-by: Stefano Stabellini Signed-off-by: Ian Campbell Signed-off-by: Konrad Rzeszutek Wilk --- arch/x86/xen/mmu.c | 18 ++++++++++++------ include/xen/interface/memory.h | 18 +++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 58f2084c2f81..fee34fea494d 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c @@ -2500,13 +2500,19 @@ static int pvh_add_to_xen_p2m(unsigned long lpfn, unsigned long fgmfn, unsigned int domid) { int rc; - struct xen_add_to_physmap xatp = { .foreign_domid = domid }; + struct xen_add_to_physmap_range xatp = { + .domid = DOMID_SELF, + .foreign_domid = domid, + .size = 1, + .space = XENMAPSPACE_gmfn_foreign, + }; + xen_ulong_t idx = fgmfn; + xen_pfn_t gpfn = lpfn; + + set_xen_guest_handle(xatp.idxs, &idx); + set_xen_guest_handle(xatp.gpfns, &gpfn); - xatp.gpfn = lpfn; - xatp.idx = fgmfn; - xatp.domid = DOMID_SELF; - xatp.space = XENMAPSPACE_gmfn_foreign; - rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap, &xatp); + rc = HYPERVISOR_memory_op(XENMEM_add_to_physmap_range, &xatp); if (rc) pr_warn("d0: Failed to map pfn (0x%lx) to mfn (0x%lx) rc:%d\n", lpfn, fgmfn, rc); diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h index e4d2d5f4b69d..b40a4315cb8b 100644 --- a/include/xen/interface/memory.h +++ b/include/xen/interface/memory.h @@ -153,6 +153,14 @@ struct xen_machphys_mapping { }; DEFINE_GUEST_HANDLE_STRUCT(xen_machphys_mapping_t); +#define XENMAPSPACE_shared_info 0 /* shared info page */ +#define XENMAPSPACE_grant_table 1 /* grant table page */ +#define XENMAPSPACE_gmfn 2 /* GMFN */ +#define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. */ +#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom, + * XENMEM_add_to_physmap_range only. + */ + /* * Sets the GPFN at which a particular page appears in the specified guest's * pseudophysical address space. @@ -167,15 +175,7 @@ struct xen_add_to_physmap { uint16_t size; /* Source mapping space. */ -#define XENMAPSPACE_shared_info 0 /* shared info page */ -#define XENMAPSPACE_grant_table 1 /* grant table page */ -#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 XENMAPSPACE_gmfn_foreign */ - -#define XENMAPIDX_grant_table_status 0x80000000 + unsigned int space; /* Index into source mapping space. */ xen_ulong_t idx; -- 2.39.5