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

[PATCH v7 13/50] x86/shadow: use map_domain_pages() for cross-page emulated writes



sh_emulate_map_dest() picks its mapping method purely on whether the
write straddles a page boundary: a single page goes through
map_domain_page(), two pages through vmap() -- mapping the destination
in every context for the duration, and flushing every CPU's TLB, once
per page, at vunmap().  map_domain_pages() maps it only in the page
tables of the guest's own domain, and flushes only this CPU's TLB; use
it for the two-page case.

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

This is one of the two in-tree consumers of the primitive.

Assisted-by: Claude Code:claude-fable-5, Claude Code:claude-opus-5-5
Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
---
Changes in v7:
- Message: without the sparse directmap view, the gain is the flush.

Changes in v5:
- New in this version.
---
 xen/arch/x86/mm/shadow/hvm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c
index e6fb97c4b6..6c554ef29d 100644
--- a/xen/arch/x86/mm/shadow/hvm.c
+++ b/xen/arch/x86/mm/shadow/hvm.c
@@ -506,7 +506,7 @@ static void *sh_emulate_map_dest(struct vcpu *v, unsigned 
long vaddr,
         /* Cross-page writes mean probably not a pagetable. */
         sh_remove_shadows(d, sh_ctxt->mfn[1], 0, 0 /* Slow, can fail. */ );
 
-        map = vmap(sh_ctxt->mfn, 2);
+        map = map_domain_pages(sh_ctxt->mfn, 2);
         if ( !map )
         {
             put_page(mfn_to_page(sh_ctxt->mfn[0]));
@@ -670,7 +670,7 @@ static void sh_emulate_unmap_dest(struct vcpu *v, void 
*addr,
     if ( unlikely(mfn_valid(sh_ctxt->mfn[1])) )
     {
         put_page(mfn_to_page(sh_ctxt->mfn[1]));
-        vunmap((void *)((unsigned long)addr & PAGE_MASK));
+        unmap_domain_pages(addr, 2);
     }
     else
         unmap_domain_page(addr);
-- 
2.56.0




 


Rackspace

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