[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 38/45] x86/hvm: use map_domain_pages() for multi-frame emulated accesses



hvmemul_map_linear_addr() picks its mapping method purely on the frame
count: one frame goes through map_domain_page(), more through vmap() --
mapping the guest data in every context for the duration, those of
domains on the sparse directmap view included, whatever the guest's own
configuration.  map_domain_pages() maps them only in the page tables of
the guest's own domain; use it for the multi-frame case.

The NULL return handling is unchanged: the primitive can fail only for
want of a free slot, and the access then bails out as unhandleable
exactly as before.

This is one of the two in-tree consumers of the primitive.  Other
long-lived global mappings of guest pages (the ioreq server pages among
them) remain in the vmap area.

Assisted-by: Claude Code:claude-fable-5, Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v5:
- New in this version.
---
 xen/arch/x86/hvm/emulate.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index da7c08b5d9..7e7beccb93 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -735,7 +735,8 @@ static void *hvmemul_map_linear_addr(
 
     /*
      * The maximum access size depends on the number of adjacent mfns[] which
-     * can be vmap()'d, accouting for possible misalignment within the region.
+     * can be mapped together, accounting for possible misalignment within
+     * the region.
      * The higher level emulation callers are responsible for ensuring that
      * mfns[] is large enough for the requested access size.
      */
@@ -824,9 +825,9 @@ static void *hvmemul_map_linear_addr(
     /* Entire access within a single frame? */
     if ( nr_frames == 1 )
         mapping = map_domain_page(hvmemul_ctxt->mfn[0]);
-    /* Multiple frames? Need to vmap(). */
-    else if ( (mapping = vmap(hvmemul_ctxt->mfn,
-                              nr_frames)) == NULL )
+    /* Multiple frames? Need a multi-page mapping. */
+    else if ( (mapping = map_domain_pages(hvmemul_ctxt->mfn,
+                                          nr_frames)) == NULL )
         goto unhandleable;
 
 #ifndef NDEBUG /* Poision unused mfn[]s with INVALID_MFN. */
@@ -867,7 +868,7 @@ static void hvmemul_unmap_linear_addr(
     if ( nr_frames == 1 )
         unmap_domain_page(mapping);
     else
-        vunmap(mapping);
+        unmap_domain_pages(mapping, nr_frames);
 
     for ( i = 0; i < nr_frames; i++ )
     {
-- 
2.56.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.