summaryrefslogtreecommitdiffstats
path: root/include/xen
diff options
context:
space:
mode:
authorPaul Durrant <paul.durrant@citrix.com>2018-05-09 09:16:12 -0400
committerJuergen Gross <jgross@suse.com>2018-05-14 09:25:37 -0400
commit3ad0876554cafa368f574d4d408468510543e9ff (patch)
tree7fade80924630151265270e68355d3f68b029bad /include/xen
parent4bf2cc9645599382e34b7d0cbe5a13d0de98194e (diff)
xen/privcmd: add IOCTL_PRIVCMD_MMAP_RESOURCE
My recent Xen patch series introduces a new HYPERVISOR_memory_op to support direct priv-mapping of certain guest resources (such as ioreq pages, used by emulators) by a tools domain, rather than having to access such resources via the guest P2M. This patch adds the necessary infrastructure to the privcmd driver and Xen MMU code to support direct resource mapping. NOTE: The adjustment in the MMU code is partially cosmetic. Xen will now allow a PV tools domain to map guest pages either by GFN or MFN, thus the term 'mfn' has been swapped for 'pfn' in the lower layers of the remap code. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Signed-off-by: Juergen Gross <jgross@suse.com>
Diffstat (limited to 'include/xen')
-rw-r--r--include/xen/interface/memory.h66
-rw-r--r--include/xen/interface/xen.h7
-rw-r--r--include/xen/xen-ops.h24
3 files changed, 93 insertions, 4 deletions
diff --git a/include/xen/interface/memory.h b/include/xen/interface/memory.h
index 583dd93b3016..4c5751c26f87 100644
--- a/include/xen/interface/memory.h
+++ b/include/xen/interface/memory.h
@@ -265,4 +265,70 @@ struct xen_remove_from_physmap {
265}; 265};
266DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap); 266DEFINE_GUEST_HANDLE_STRUCT(xen_remove_from_physmap);
267 267
268/*
269 * Get the pages for a particular guest resource, so that they can be
270 * mapped directly by a tools domain.
271 */
272#define XENMEM_acquire_resource 28
273struct xen_mem_acquire_resource {
274 /* IN - The domain whose resource is to be mapped */
275 domid_t domid;
276 /* IN - the type of resource */
277 uint16_t type;
278
279#define XENMEM_resource_ioreq_server 0
280#define XENMEM_resource_grant_table 1
281
282 /*
283 * IN - a type-specific resource identifier, which must be zero
284 * unless stated otherwise.
285 *
286 * type == XENMEM_resource_ioreq_server -> id == ioreq server id
287 * type == XENMEM_resource_grant_table -> id defined below
288 */
289 uint32_t id;
290
291#define XENMEM_resource_grant_table_id_shared 0
292#define XENMEM_resource_grant_table_id_status 1
293
294 /* IN/OUT - As an IN parameter number of frames of the resource
295 * to be mapped. However, if the specified value is 0 and
296 * frame_list is NULL then this field will be set to the
297 * maximum value supported by the implementation on return.
298 */
299 uint32_t nr_frames;
300 /*
301 * OUT - Must be zero on entry. On return this may contain a bitwise
302 * OR of the following values.
303 */
304 uint32_t flags;
305
306 /* The resource pages have been assigned to the calling domain */
307#define _XENMEM_rsrc_acq_caller_owned 0
308#define XENMEM_rsrc_acq_caller_owned (1u << _XENMEM_rsrc_acq_caller_owned)
309
310 /*
311 * IN - the index of the initial frame to be mapped. This parameter
312 * is ignored if nr_frames is 0.
313 */
314 uint64_t frame;
315
316#define XENMEM_resource_ioreq_server_frame_bufioreq 0
317#define XENMEM_resource_ioreq_server_frame_ioreq(n) (1 + (n))
318
319 /*
320 * IN/OUT - If the tools domain is PV then, upon return, frame_list
321 * will be populated with the MFNs of the resource.
322 * If the tools domain is HVM then it is expected that, on
323 * entry, frame_list will be populated with a list of GFNs
324 * that will be mapped to the MFNs of the resource.
325 * If -EIO is returned then the frame_list has only been
326 * partially mapped and it is up to the caller to unmap all
327 * the GFNs.
328 * This parameter may be NULL if nr_frames is 0.
329 */
330 GUEST_HANDLE(xen_pfn_t) frame_list;
331};
332DEFINE_GUEST_HANDLE_STRUCT(xen_mem_acquire_resource);
333
268#endif /* __XEN_PUBLIC_MEMORY_H__ */ 334#endif /* __XEN_PUBLIC_MEMORY_H__ */
diff --git a/include/xen/interface/xen.h b/include/xen/interface/xen.h
index 4f4830ef8f93..8bfb242f433e 100644
--- a/include/xen/interface/xen.h
+++ b/include/xen/interface/xen.h
@@ -265,9 +265,10 @@
265 * 265 *
266 * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7. 266 * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7.
267 */ 267 */
268#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */ 268#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */
269#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */ 269#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */
270#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */ 270#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */
271#define MMU_PT_UPDATE_NO_TRANSLATE 3 /* checked '*ptr = val'. ptr is MA. */
271 272
272/* 273/*
273 * MMU EXTENDED OPERATIONS 274 * MMU EXTENDED OPERATIONS
diff --git a/include/xen/xen-ops.h b/include/xen/xen-ops.h
index fd23e42c6024..fd18c974a619 100644
--- a/include/xen/xen-ops.h
+++ b/include/xen/xen-ops.h
@@ -63,7 +63,7 @@ static inline void xen_destroy_contiguous_region(phys_addr_t pstart,
63struct vm_area_struct; 63struct vm_area_struct;
64 64
65/* 65/*
66 * xen_remap_domain_gfn_array() - map an array of foreign frames 66 * xen_remap_domain_gfn_array() - map an array of foreign frames by gfn
67 * @vma: VMA to map the pages into 67 * @vma: VMA to map the pages into
68 * @addr: Address at which to map the pages 68 * @addr: Address at which to map the pages
69 * @gfn: Array of GFNs to map 69 * @gfn: Array of GFNs to map
@@ -86,6 +86,28 @@ int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
86 unsigned domid, 86 unsigned domid,
87 struct page **pages); 87 struct page **pages);
88 88
89/*
90 * xen_remap_domain_mfn_array() - map an array of foreign frames by mfn
91 * @vma: VMA to map the pages into
92 * @addr: Address at which to map the pages
93 * @mfn: Array of MFNs to map
94 * @nr: Number entries in the MFN array
95 * @err_ptr: Returns per-MFN error status.
96 * @prot: page protection mask
97 * @domid: Domain owning the pages
98 * @pages: Array of pages if this domain has an auto-translated physmap
99 *
100 * @mfn and @err_ptr may point to the same buffer, the MFNs will be
101 * overwritten by the error codes after they are mapped.
102 *
103 * Returns the number of successfully mapped frames, or a -ve error
104 * code.
105 */
106int xen_remap_domain_mfn_array(struct vm_area_struct *vma,
107 unsigned long addr, xen_pfn_t *mfn, int nr,
108 int *err_ptr, pgprot_t prot,
109 unsigned int domid, struct page **pages);
110
89/* xen_remap_domain_gfn_range() - map a range of foreign frames 111/* xen_remap_domain_gfn_range() - map a range of foreign frames
90 * @vma: VMA to map the pages into 112 * @vma: VMA to map the pages into
91 * @addr: Address at which to map the pages 113 * @addr: Address at which to map the pages