All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger@xenproject.org>
To: George Dunlap <gwd@xenproject.org>
Cc: xen-devel@lists.xenproject.org,
	"Roger Pau Monné" <roger.pau@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Teddy Astie" <teddy.astie@vates.tech>
Subject: Re: [PATCH v3 02/18] x86/mm: purge unneeded destroy_perdomain_mapping()
Date: Wed, 7 Oct 2026 16:06:07 +0200	[thread overview]
Message-ID: <asZRz9iFoTWXTVFx@Mac.lan> (raw)
In-Reply-To: <20261007104051.48841-3-gwd@xenproject.org>

On Wed, Oct 07, 2026 at 11:40:35AM +0100, George Dunlap wrote:
> From: Roger Pau Monné <roger.pau@citrix.com>
> 
> 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.  create_ allocates a per-domain L3,
>   but destroy_ tears down mappings without freeing it; 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 unneccessary callers, drop this one too.
> 
> Note that free_compat_arg_xlat() keeps its explicit teardown: in
> addition to vCPU teardown, it serves switch_compat()'s undo path,
> where the domain lives on as a 64-bit one and the argument-translation
> pages have to go.  Add a comment to make sure it isn't missed.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> Assisted-by: Claude Code:claude-fable-5
> Signed-off-by: George Dunlap <gwd@xenproject.org>
> ---
> Changes in v3:
> - Note that pv_domain_destroy()'s other call site, the error path of
>   pv_domain_initialise(), is covered the same way (Jan).
> - Also drop pv_destroy_gdt_ldt_l1tab(), the per-vCPU teardown call
>   (Jan), and comment on why free_compat_arg_xlat() keeps its own.  The
>   Reviewed-by tags given for the previous form are dropped.
> 
> Changes in v2:
> - Added to the series
> 
> Changes since the previously posted version:
> - Reworked the commit message to make it more clear how it fits in
>   with the larger series.  No functional change.
> ---
>  xen/arch/x86/hvm/hvm.c   |  1 -
>  xen/arch/x86/pv/domain.c | 10 ----------
>  xen/arch/x86/x86_64/mm.c |  5 +++++
>  3 files changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 192309c2fc..3924c1b204 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -730,7 +730,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);
>   fail:
>      hvm_domain_relinquish_resources(d);
>      XFREE(d->arch.hvm.io_handler);
> diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
> index 03262a4952..07ea4bb4d2 100644
> --- a/xen/arch/x86/pv/domain.c
> +++ b/xen/arch/x86/pv/domain.c
> @@ -332,12 +332,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) )
> @@ -346,7 +340,6 @@ void pv_vcpu_destroy(struct vcpu *v)
>          release_compat_l4(v);
>      }
>  
> -    pv_destroy_gdt_ldt_l1tab(v);
>      XFREE(v->arch.pv.trap_ctxt);
>  }
>  
> @@ -394,9 +387,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);
> diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c
> index 8eadab7933..2a1805964d 100644
> --- a/xen/arch/x86/x86_64/mm.c
> +++ b/xen/arch/x86/x86_64/mm.c
> @@ -737,6 +737,11 @@ int setup_compat_arg_xlat(struct vcpu *v)
>                                      NULL, NIL(struct page_info *));
>  }
>  
> +/*
> + * Besides vCPU teardown, which free_perdomain_mappings() would cover, this
> + * serves switch_compat()'s undo path: the domain lives on as a 64-bit one
> + * there, so the translation area has to go right away.

I'm unsure we want to be that verbose, but if so I would mention PV
explicitly, possible: "the PV domain lives ..."

Otherwise LGTM, but I don't think I can RB or Ack it being also the
author.

Thanks, Roger.


  reply	other threads:[~2026-10-07 14:06 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 10:40 [PATCH v3 00/18] ASI: HVM per-vCPU areas and sparse-view directmap George Dunlap
2026-10-07 10:40 ` [PATCH v3 01/18] x86/PoD: map one page at a time in p2m_pod_zero_check() George Dunlap
2026-10-07 10:51   ` Jan Beulich
2026-10-07 12:33   ` Andrew Cooper
2026-10-07 12:38   ` Andrew Cooper
2026-10-08 11:09     ` George Dunlap
2026-10-08 22:24       ` Andrew Cooper
2026-10-07 10:40 ` [PATCH v3 02/18] x86/mm: purge unneeded destroy_perdomain_mapping() George Dunlap
2026-10-07 14:06   ` Roger Pau Monné [this message]
2026-10-07 14:24     ` Jan Beulich
2026-10-08 12:19       ` George Dunlap
2026-10-08  7:55   ` Jan Beulich
2026-10-08  8:31     ` Roger Pau Monné
2026-10-08 12:27       ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 03/18] x86/mm: prepare destroy_perdomain_mapping() for per-vCPU perdomain areas George Dunlap
2026-10-07 15:58   ` Roger Pau Monné
2026-10-08 13:27     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 04/18] x86/domain_page: drop redundant create_perdomain_mapping() call George Dunlap
2026-10-07 16:14   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 05/18] x86/mm: prepare create_perdomain_mapping() for per-vCPU perdomain areas George Dunlap
2026-10-07 16:31   ` Roger Pau Monné
2026-10-12 12:44     ` George Dunlap
2026-10-08  8:05   ` Jan Beulich
2026-10-07 10:40 ` [PATCH v3 06/18] x86/spec-ctrl: introduce Address Space Isolation command line option George Dunlap
2026-10-07 16:52   ` Roger Pau Monné
2026-10-12 12:47     ` George Dunlap
2026-10-08  8:24   ` Jan Beulich
2026-10-12 12:48     ` George Dunlap
2026-10-07 10:40 ` [PATCH v3 07/18] x86/hvm: introduce per-vCPU L3 page-table George Dunlap
2026-10-07 19:21   ` Roger Pau Monné
2026-10-08 20:55     ` George Dunlap
2026-10-08  8:40   ` Jan Beulich
2026-10-08 21:00     ` George Dunlap
2026-10-09  7:06       ` Jan Beulich
2026-10-07 10:40 ` [PATCH v3 08/18] x86/domain_page: prepare the mapcache for per-vCPU accounting George Dunlap
2026-10-08  8:22   ` Roger Pau Monné
2026-10-12 14:19     ` George Dunlap
2026-10-13 10:50       ` Roger Pau Monné
2026-10-12 13:48   ` Jan Beulich
2026-10-12 16:07     ` George Dunlap
2026-10-13  6:25       ` Jan Beulich
2026-10-13  9:53         ` George Dunlap
2026-10-13 11:56           ` Jan Beulich
2026-10-07 10:40 ` [PATCH v3 09/18] x86/domain_page: move struct mapcache_vcpu to struct arch_vcpu George Dunlap
2026-10-08  8:28   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 10/18] x86/domain_page: don't unmap a mapcache entry that is not present George Dunlap
2026-10-08 11:03   ` Roger Pau Monné
2026-10-13 10:33     ` George Dunlap
2026-10-13 10:55       ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 11/18] x86/hvm: introduce per-vCPU mapcache for vCPU-PT domains George Dunlap
2026-10-08 13:56   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 12/18] x86/mm: let Xen's page-table walker operate on a given root George Dunlap
2026-10-08 14:58   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 13/18] x86/mm: build and maintain a sparse view of the directmap George Dunlap
2026-10-07 15:20   ` George Dunlap
2026-10-08 18:02   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 14/18] x86/domain_page: key the directmap fast paths on the loaded view George Dunlap
2026-10-08 18:51   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 15/18] x86/mm: flush owned pages before reuse with the sparse directmap view George Dunlap
2026-10-08 19:00   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 16/18] x86/domain_page: keep the maphash's slots, not their mappings George Dunlap
2026-10-08 19:08   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 17/18] x86/mm: run guest contexts on the sparse directmap view George Dunlap
2026-10-09  7:58   ` Roger Pau Monné
2026-10-07 10:40 ` [PATCH v3 18/18] x86/spec-ctrl: wire the sparse directmap view into the asi= option George Dunlap
2026-10-08 19:21   ` Roger Pau Monné

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=asZRz9iFoTWXTVFx@Mac.lan \
    --to=roger@xenproject.org \
    --cc=andrew.cooper3@citrix.com \
    --cc=gwd@xenproject.org \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.