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

[xen master] x86/mm: purge unneeded destroy_perdomain_mapping()



commit af8ab775f391f7e2170c8a9913d70c983add53cd
Author:     Roger Pau Monné <roger.pau@xxxxxxxxxx>
AuthorDate: Tue Nov 3 17:13:24 2026 -0500
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 12 09:21:20 2026 +0100

    x86/mm: purge unneeded destroy_perdomain_mapping()
    
    We want to change per-domain mappings to be per-vCPU mappings.  In
    preparation for that, we want to arrange that
    destroy_perdomain_mapping() work either with a single perdomain area,
    or with a per-vCPU perdomain area.
    
    There are two calls made from domain-scoped contexts; both calls turn
    out to be unnecessary:
    
    - destroy_perdomain_mapping() is not logically the undo of
      create_perdomain_mapping(), as the name and its use in
      hvm_domain_initialise() suggest.  destroy_ tears down mappings
      without freeing the per-domain L3; and since the call here passes
      nr == 0, it tears down nothing at all.  The per-domain L3 page is
      actually freed by free_perdomain_mappings(), which
      hvm_domain_initialise()'s caller, arch_domain_create(), already
      invokes on its failure path.
    
    - The call in pv_domain_destroy() is redundant at both of its call
      sites.  arch_domain_destroy() unconditionally calls
      free_perdomain_mappings(), which tears down the same entries and
      additionally frees the page-table structures; and the other caller,
      the error path of pv_domain_initialise(), returns into
      arch_domain_create()'s failure path, which invokes
      free_perdomain_mappings() as well.
    
    One vCPU-scoped caller, pv_destroy_gdt_ldt_l1tab(), is covered the
    same way: a vCPU is only ever destroyed together with its domain, or
    on the failure path of creating it, and both routes end in
    free_perdomain_mappings(); the GDT/LDT slots hold no area-owned pages,
    so there is nothing else for the call to do.  While we're getting rid
    of unnecessary callers, drop this one too.
    
    Note that free_compat_arg_xlat() keeps its explicit teardown:
    switch_compat() calls it on the failure path.  While in practice most
    toolstacks will immediately destroy the domain, in theory a toolstack
    could let it live on as a 64-bit guest.  Release the resources
    immediately rather than waiting for domain destruction.
    
    Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Assisted-by: Claude Code:claude-fable-5
    Signed-off-by: George Dunlap <gwd@xxxxxxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c   |  1 -
 xen/arch/x86/pv/domain.c | 10 ----------
 2 files changed, 11 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 46d3a520d5..71da15c0a4 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -726,7 +726,6 @@ int hvm_domain_initialise(struct domain *d,
     XFREE(d->arch.hvm.irq);
  fail0:
     hvm_destroy_cacheattr_region_list(d);
-    destroy_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0);
     hvm_domain_relinquish_resources(d);
     XFREE(d->arch.hvm.io_handler);
     XFREE(d->arch.hvm.pl_time);
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index 0c42ae58aa..28ea0742ab 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -319,12 +319,6 @@ static int pv_create_gdt_ldt_l1tab(struct vcpu *v)
                                     NULL);
 }
 
-static void pv_destroy_gdt_ldt_l1tab(struct vcpu *v)
-{
-    destroy_perdomain_mapping(v->domain, GDT_VIRT_START(v),
-                              1U << GDT_LDT_VCPU_SHIFT);
-}
-
 void pv_vcpu_destroy(struct vcpu *v)
 {
     if ( is_pv_32bit_vcpu(v) )
@@ -333,7 +327,6 @@ void pv_vcpu_destroy(struct vcpu *v)
         release_compat_l4(v);
     }
 
-    pv_destroy_gdt_ldt_l1tab(v);
     XFREE(v->arch.pv.trap_ctxt);
 }
 
@@ -381,9 +374,6 @@ void pv_domain_destroy(struct domain *d)
 {
     pv_l1tf_domain_destroy(d);
 
-    destroy_perdomain_mapping(d, GDT_LDT_VIRT_START,
-                              GDT_LDT_MBYTES << (20 - PAGE_SHIFT));
-
     XFREE(d->arch.pv.cpuidmasks);
 
     FREE_XENHEAP_PAGE(d->arch.pv.gdt_ldt_l1tab);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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