From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Vishal Annapurve <vannapurve@google.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
linux-coco@lists.linux.dev, virtualization@lists.linux.dev,
pbonzini@redhat.com, seanjc@google.com, erdemaktas@google.com,
ackerleytng@google.com, jxgao@google.com, sagis@google.com,
oupton@google.com, pgonda@google.com, kirill@shutemov.name,
dave.hansen@linux.intel.com, chao.p.peng@linux.intel.com,
isaku.yamahata@gmail.com,
sathyanarayanan.kuppuswamy@linux.intel.com, jgross@suse.com,
ajay.kaher@broadcom.com, alexey.amakhalov@broadcom.com,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
stable@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Tony Luck <tony.luck@intel.com>
Subject: Re: [PATCH V5 1/4] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT
Date: Fri, 28 Feb 2025 16:47:57 -0500 [thread overview]
Message-ID: <Z8IvDeIJH2EJuPo-@char.us.oracle.com> (raw)
In-Reply-To: <20250220211628.1832258-2-vannapurve@google.com>
On Thu, Feb 20, 2025 at 09:16:25PM +0000, Vishal Annapurve wrote:
> From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
>
> CONFIG_PARAVIRT_XXL is mainly defined/used by XEN PV guests. For
> other VM guest types, features supported under CONFIG_PARAVIRT
> are self sufficient. CONFIG_PARAVIRT mainly provides support for
> TLB flush operations and time related operations.
>
> For TDX guest as well, paravirt calls under CONFIG_PARVIRT meets
> most of its requirement except the need of HLT and SAFE_HLT
> paravirt calls, which is currently defined under
> CONFIG_PARAVIRT_XXL.
>
> Since enabling CONFIG_PARAVIRT_XXL is too bloated for TDX guest
> like platforms, move HLT and SAFE_HLT paravirt calls under
> CONFIG_PARAVIRT.
Could you use the bloat-o-meter to give an idea of the savings?
Also .. aren't most distros building with Xen support so they will
always have the full paravirt support?
>
> Moving HLT and SAFE_HLT paravirt calls are not fatal and should not
> break any functionality for current users of CONFIG_PARAVIRT.
>
> Cc: stable@vger.kernel.org
> Fixes: bfe6ed0c6727 ("x86/tdx: Add HLT support for TDX guests")
> Co-developed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Reviewed-by: Andi Kleen <ak@linux.intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> Signed-off-by: Vishal Annapurve <vannapurve@google.com>
> ---
> arch/x86/include/asm/irqflags.h | 40 +++++++++++++++------------
> arch/x86/include/asm/paravirt.h | 20 +++++++-------
> arch/x86/include/asm/paravirt_types.h | 3 +-
> arch/x86/kernel/paravirt.c | 14 ++++++----
> 4 files changed, 41 insertions(+), 36 deletions(-)
>
> diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
> index cf7fc2b8e3ce..1c2db11a2c3c 100644
> --- a/arch/x86/include/asm/irqflags.h
> +++ b/arch/x86/include/asm/irqflags.h
> @@ -76,6 +76,28 @@ static __always_inline void native_local_irq_restore(unsigned long flags)
>
> #endif
>
> +#ifndef CONFIG_PARAVIRT
> +#ifndef __ASSEMBLY__
> +/*
> + * Used in the idle loop; sti takes one instruction cycle
> + * to complete:
> + */
> +static __always_inline void arch_safe_halt(void)
> +{
> + native_safe_halt();
> +}
> +
> +/*
> + * Used when interrupts are already enabled or to
> + * shutdown the processor:
> + */
> +static __always_inline void halt(void)
> +{
> + native_halt();
> +}
> +#endif /* __ASSEMBLY__ */
> +#endif /* CONFIG_PARAVIRT */
> +
> #ifdef CONFIG_PARAVIRT_XXL
> #include <asm/paravirt.h>
> #else
> @@ -97,24 +119,6 @@ static __always_inline void arch_local_irq_enable(void)
> native_irq_enable();
> }
>
> -/*
> - * Used in the idle loop; sti takes one instruction cycle
> - * to complete:
> - */
> -static __always_inline void arch_safe_halt(void)
> -{
> - native_safe_halt();
> -}
> -
> -/*
> - * Used when interrupts are already enabled or to
> - * shutdown the processor:
> - */
> -static __always_inline void halt(void)
> -{
> - native_halt();
> -}
> -
> /*
> * For spinlocks, etc:
> */
> diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
> index 041aff51eb50..29e7331a0c98 100644
> --- a/arch/x86/include/asm/paravirt.h
> +++ b/arch/x86/include/asm/paravirt.h
> @@ -107,6 +107,16 @@ static inline void notify_page_enc_status_changed(unsigned long pfn,
> PVOP_VCALL3(mmu.notify_page_enc_status_changed, pfn, npages, enc);
> }
>
> +static __always_inline void arch_safe_halt(void)
> +{
> + PVOP_VCALL0(irq.safe_halt);
> +}
> +
> +static inline void halt(void)
> +{
> + PVOP_VCALL0(irq.halt);
> +}
> +
> #ifdef CONFIG_PARAVIRT_XXL
> static inline void load_sp0(unsigned long sp0)
> {
> @@ -170,16 +180,6 @@ static inline void __write_cr4(unsigned long x)
> PVOP_VCALL1(cpu.write_cr4, x);
> }
>
> -static __always_inline void arch_safe_halt(void)
> -{
> - PVOP_VCALL0(irq.safe_halt);
> -}
> -
> -static inline void halt(void)
> -{
> - PVOP_VCALL0(irq.halt);
> -}
> -
> static inline u64 paravirt_read_msr(unsigned msr)
> {
> return PVOP_CALL1(u64, cpu.read_msr, msr);
> diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
> index fea56b04f436..abccfccc2e3f 100644
> --- a/arch/x86/include/asm/paravirt_types.h
> +++ b/arch/x86/include/asm/paravirt_types.h
> @@ -120,10 +120,9 @@ struct pv_irq_ops {
> struct paravirt_callee_save save_fl;
> struct paravirt_callee_save irq_disable;
> struct paravirt_callee_save irq_enable;
> -
> +#endif
> void (*safe_halt)(void);
> void (*halt)(void);
> -#endif
> } __no_randomize_layout;
>
> struct pv_mmu_ops {
> diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
> index 1ccaa3397a67..c5bb980b8a67 100644
> --- a/arch/x86/kernel/paravirt.c
> +++ b/arch/x86/kernel/paravirt.c
> @@ -110,6 +110,11 @@ int paravirt_disable_iospace(void)
> return request_resource(&ioport_resource, &reserve_ioports);
> }
>
> +static noinstr void pv_native_safe_halt(void)
> +{
> + native_safe_halt();
> +}
> +
> #ifdef CONFIG_PARAVIRT_XXL
> static noinstr void pv_native_write_cr2(unsigned long val)
> {
> @@ -125,11 +130,6 @@ static noinstr void pv_native_set_debugreg(int regno, unsigned long val)
> {
> native_set_debugreg(regno, val);
> }
> -
> -static noinstr void pv_native_safe_halt(void)
> -{
> - native_safe_halt();
> -}
> #endif
>
> struct pv_info pv_info = {
> @@ -186,9 +186,11 @@ struct paravirt_patch_template pv_ops = {
> .irq.save_fl = __PV_IS_CALLEE_SAVE(pv_native_save_fl),
> .irq.irq_disable = __PV_IS_CALLEE_SAVE(pv_native_irq_disable),
> .irq.irq_enable = __PV_IS_CALLEE_SAVE(pv_native_irq_enable),
> +#endif /* CONFIG_PARAVIRT_XXL */
> +
> + /* Irq HLT ops. */
> .irq.safe_halt = pv_native_safe_halt,
> .irq.halt = native_halt,
> -#endif /* CONFIG_PARAVIRT_XXL */
>
> /* Mmu ops. */
> .mmu.flush_tlb_user = native_flush_tlb_local,
> --
> 2.48.1.601.g30ceb7b040-goog
>
>
next prev parent reply other threads:[~2025-02-28 21:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 21:16 [PATCH V5 0/4] x86/tdx: Fix HLT logic execution for TDX VMs Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 1/4] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT Vishal Annapurve
2025-02-20 21:47 ` Dave Hansen
2025-02-20 23:17 ` Vishal Annapurve
2025-02-28 21:47 ` Konrad Rzeszutek Wilk [this message]
2025-03-03 9:54 ` Jürgen Groß
2025-02-20 21:16 ` [PATCH V5 2/4] x86/tdx: Route safe halt execution via tdx_safe_halt() Vishal Annapurve
2025-02-20 23:00 ` Dave Hansen
2025-02-20 23:51 ` Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 3/4] x86/tdx: Emit warning if IRQs are enabled during HLT #VE handling Vishal Annapurve
2025-02-20 21:16 ` [PATCH V5 4/4] x86/tdx: Remove TDX specific idle routine Vishal Annapurve
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=Z8IvDeIJH2EJuPo-@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=ackerleytng@google.com \
--cc=ajay.kaher@broadcom.com \
--cc=ak@linux.intel.com \
--cc=alexey.amakhalov@broadcom.com \
--cc=chao.p.peng@linux.intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=erdemaktas@google.com \
--cc=isaku.yamahata@gmail.com \
--cc=jgross@suse.com \
--cc=jxgao@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=kirill@shutemov.name \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=oupton@google.com \
--cc=pbonzini@redhat.com \
--cc=pgonda@google.com \
--cc=sagis@google.com \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=seanjc@google.com \
--cc=stable@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=vannapurve@google.com \
--cc=virtualization@lists.linux.dev \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).