Skip to content

Commit ae5db45

Browse files
committed
x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT
jira LE-2729 build-fix Fix build when XEN_PV is not set commit-author Kirill A. Shutemov <[email protected]> commit 22cc5ca upstream-diff Had to fix a couple of trivial merge conflicts because this kernel hasn't removed paravirt_disable_iospace and pv_native_wbindvd yet 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 <[email protected]> Signed-off-by: Kuppuswamy Sathyanarayanan <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Vishal Annapurve <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Reviewed-by: Tony Luck <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Tested-by: Ryan Afranji <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Brian Gerst <[email protected]> Cc: H. Peter Anvin <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Josh Poimboeuf <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] (cherry picked from commit 22cc5ca) Signed-off-by: Brett Mastbergen <[email protected]>
1 parent 513904d commit ae5db45

File tree

4 files changed

+41
-36
lines changed

4 files changed

+41
-36
lines changed

arch/x86/include/asm/irqflags.h

+22-18
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

+10-10
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ static inline void notify_page_enc_status_changed(unsigned long pfn,
107107
PVOP_VCALL3(mmu.notify_page_enc_status_changed, pfn, npages, enc);
108108
}
109109

110+
static __always_inline void arch_safe_halt(void)
111+
{
112+
PVOP_VCALL0(irq.safe_halt);
113+
}
114+
115+
static inline void halt(void)
116+
{
117+
PVOP_VCALL0(irq.halt);
118+
}
119+
110120
#ifdef CONFIG_PARAVIRT_XXL
111121
static inline void load_sp0(unsigned long sp0)
112122
{
@@ -170,16 +180,6 @@ static inline void __write_cr4(unsigned long x)
170180
PVOP_VCALL1(cpu.write_cr4, x);
171181
}
172182

173-
static __always_inline void arch_safe_halt(void)
174-
{
175-
PVOP_VCALL0(irq.safe_halt);
176-
}
177-
178-
static inline void halt(void)
179-
{
180-
PVOP_VCALL0(irq.halt);
181-
}
182-
183183
extern noinstr void pv_native_wbinvd(void);
184184

185185
static __always_inline void wbinvd(void)

arch/x86/include/asm/paravirt_types.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ struct pv_irq_ops {
122122
struct paravirt_callee_save save_fl;
123123
struct paravirt_callee_save irq_disable;
124124
struct paravirt_callee_save irq_enable;
125-
125+
#endif
126126
void (*safe_halt)(void);
127127
void (*halt)(void);
128-
#endif
129128
} __no_randomize_layout;
130129

131130
struct pv_mmu_ops {

arch/x86/kernel/paravirt.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ int paravirt_disable_iospace(void)
100100
return request_resource(&ioport_resource, &reserve_ioports);
101101
}
102102

103+
static noinstr void pv_native_safe_halt(void)
104+
{
105+
native_safe_halt();
106+
}
107+
103108
#ifdef CONFIG_PARAVIRT_XXL
104109
static noinstr void pv_native_write_cr2(unsigned long val)
105110
{
@@ -120,11 +125,6 @@ noinstr void pv_native_wbinvd(void)
120125
{
121126
native_wbinvd();
122127
}
123-
124-
static noinstr void pv_native_safe_halt(void)
125-
{
126-
native_safe_halt();
127-
}
128128
#endif
129129

130130
struct pv_info pv_info = {
@@ -182,9 +182,11 @@ struct paravirt_patch_template pv_ops = {
182182
.irq.save_fl = __PV_IS_CALLEE_SAVE(pv_native_save_fl),
183183
.irq.irq_disable = __PV_IS_CALLEE_SAVE(pv_native_irq_disable),
184184
.irq.irq_enable = __PV_IS_CALLEE_SAVE(pv_native_irq_enable),
185+
#endif /* CONFIG_PARAVIRT_XXL */
186+
187+
/* Irq HLT ops. */
185188
.irq.safe_halt = pv_native_safe_halt,
186189
.irq.halt = native_halt,
187-
#endif /* CONFIG_PARAVIRT_XXL */
188190

189191
/* Mmu ops. */
190192
.mmu.flush_tlb_user = native_flush_tlb_local,

0 commit comments

Comments
 (0)