Skip to content

Commit 22cc5ca

Browse files
kirylIngo Molnar
authored andcommitted
x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT
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. Moving HLT and SAFE_HLT paravirt calls are not fatal and should not break any functionality for current users of CONFIG_PARAVIRT. Fixes: bfe6ed0 ("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> Signed-off-by: Vishal Annapurve <vannapurve@google.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Reviewed-by: Andi Kleen <ak@linux.intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Juergen Gross <jgross@suse.com> Tested-by: Ryan Afranji <afranji@google.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: stable@kernel.org Link: https://lore.kernel.org/r/20250228014416.3925664-2-vannapurve@google.com
1 parent 0d86c23 commit 22cc5ca

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

arch/x86/include/asm/irqflags.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ static __always_inline void native_local_irq_restore(unsigned long flags)
7676

7777
#endif
7878

79+
#ifndef CONFIG_PARAVIRT
80+
#ifndef __ASSEMBLY__
81+
/*
82+
* Used in the idle loop; sti takes one instruction cycle
83+
* to complete:
84+
*/
85+
static __always_inline void arch_safe_halt(void)
86+
{
87+
native_safe_halt();
88+
}
89+
90+
/*
91+
* Used when interrupts are already enabled or to
92+
* shutdown the processor:
93+
*/
94+
static __always_inline void halt(void)
95+
{
96+
native_halt();
97+
}
98+
#endif /* __ASSEMBLY__ */
99+
#endif /* CONFIG_PARAVIRT */
100+
79101
#ifdef CONFIG_PARAVIRT_XXL
80102
#include <asm/paravirt.h>
81103
#else
@@ -97,24 +119,6 @@ static __always_inline void arch_local_irq_enable(void)
97119
native_irq_enable();
98120
}
99121

100-
/*
101-
* Used in the idle loop; sti takes one instruction cycle
102-
* to complete:
103-
*/
104-
static __always_inline void arch_safe_halt(void)
105-
{
106-
native_safe_halt();
107-
}
108-
109-
/*
110-
* Used when interrupts are already enabled or to
111-
* shutdown the processor:
112-
*/
113-
static __always_inline void halt(void)
114-
{
115-
native_halt();
116-
}
117-
118122
/*
119123
* For spinlocks, etc:
120124
*/

arch/x86/include/asm/paravirt.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ static inline void notify_page_enc_status_changed(unsigned long pfn,
102102
PVOP_VCALL3(mmu.notify_page_enc_status_changed, pfn, npages, enc);
103103
}
104104

105+
static __always_inline void arch_safe_halt(void)
106+
{
107+
PVOP_VCALL0(irq.safe_halt);
108+
}
109+
110+
static inline void halt(void)
111+
{
112+
PVOP_VCALL0(irq.halt);
113+
}
114+
105115
#ifdef CONFIG_PARAVIRT_XXL
106116
static inline void load_sp0(unsigned long sp0)
107117
{
@@ -165,16 +175,6 @@ static inline void __write_cr4(unsigned long x)
165175
PVOP_VCALL1(cpu.write_cr4, x);
166176
}
167177

168-
static __always_inline void arch_safe_halt(void)
169-
{
170-
PVOP_VCALL0(irq.safe_halt);
171-
}
172-
173-
static inline void halt(void)
174-
{
175-
PVOP_VCALL0(irq.halt);
176-
}
177-
178178
static inline u64 paravirt_read_msr(unsigned msr)
179179
{
180180
return PVOP_CALL1(u64, cpu.read_msr, msr);

arch/x86/include/asm/paravirt_types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,9 @@ struct pv_irq_ops {
120120
struct paravirt_callee_save save_fl;
121121
struct paravirt_callee_save irq_disable;
122122
struct paravirt_callee_save irq_enable;
123-
123+
#endif
124124
void (*safe_halt)(void);
125125
void (*halt)(void);
126-
#endif
127126
} __no_randomize_layout;
128127

129128
struct pv_mmu_ops {

arch/x86/kernel/paravirt.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ void paravirt_set_sched_clock(u64 (*func)(void))
7575
static_call_update(pv_sched_clock, func);
7676
}
7777

78+
static noinstr void pv_native_safe_halt(void)
79+
{
80+
native_safe_halt();
81+
}
82+
7883
#ifdef CONFIG_PARAVIRT_XXL
7984
static noinstr void pv_native_write_cr2(unsigned long val)
8085
{
@@ -100,11 +105,6 @@ static noinstr void pv_native_set_debugreg(int regno, unsigned long val)
100105
{
101106
native_set_debugreg(regno, val);
102107
}
103-
104-
static noinstr void pv_native_safe_halt(void)
105-
{
106-
native_safe_halt();
107-
}
108108
#endif
109109

110110
struct pv_info pv_info = {
@@ -161,9 +161,11 @@ struct paravirt_patch_template pv_ops = {
161161
.irq.save_fl = __PV_IS_CALLEE_SAVE(pv_native_save_fl),
162162
.irq.irq_disable = __PV_IS_CALLEE_SAVE(pv_native_irq_disable),
163163
.irq.irq_enable = __PV_IS_CALLEE_SAVE(pv_native_irq_enable),
164+
#endif /* CONFIG_PARAVIRT_XXL */
165+
166+
/* Irq HLT ops. */
164167
.irq.safe_halt = pv_native_safe_halt,
165168
.irq.halt = native_halt,
166-
#endif /* CONFIG_PARAVIRT_XXL */
167169

168170
/* Mmu ops. */
169171
.mmu.flush_tlb_user = native_flush_tlb_local,

0 commit comments

Comments
 (0)