mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 20:14:06 +02:00
x86/paravirt: Move thunk macros to paravirt_types.h
The macros for generating PV-thunks are part of the generic paravirt infrastructure, so they should be in paravirt_types.h. Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260105110520.21356-5-jgross@suse.com
This commit is contained in:
parent
d73298f015
commit
b49c63eea5
|
|
@ -581,74 +581,6 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
|
|||
|
||||
#endif /* SMP && PARAVIRT_SPINLOCKS */
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
/* save and restore all caller-save registers, except return value */
|
||||
#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
|
||||
#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
|
||||
#else
|
||||
/* save and restore all caller-save registers, except return value */
|
||||
#define PV_SAVE_ALL_CALLER_REGS \
|
||||
"push %rcx;" \
|
||||
"push %rdx;" \
|
||||
"push %rsi;" \
|
||||
"push %rdi;" \
|
||||
"push %r8;" \
|
||||
"push %r9;" \
|
||||
"push %r10;" \
|
||||
"push %r11;"
|
||||
#define PV_RESTORE_ALL_CALLER_REGS \
|
||||
"pop %r11;" \
|
||||
"pop %r10;" \
|
||||
"pop %r9;" \
|
||||
"pop %r8;" \
|
||||
"pop %rdi;" \
|
||||
"pop %rsi;" \
|
||||
"pop %rdx;" \
|
||||
"pop %rcx;"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generate a thunk around a function which saves all caller-save
|
||||
* registers except for the return value. This allows C functions to
|
||||
* be called from assembler code where fewer than normal registers are
|
||||
* available. It may also help code generation around calls from C
|
||||
* code if the common case doesn't use many registers.
|
||||
*
|
||||
* When a callee is wrapped in a thunk, the caller can assume that all
|
||||
* arg regs and all scratch registers are preserved across the
|
||||
* call. The return value in rax/eax will not be saved, even for void
|
||||
* functions.
|
||||
*/
|
||||
#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
|
||||
#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
|
||||
extern typeof(func) __raw_callee_save_##func; \
|
||||
\
|
||||
asm(".pushsection " section ", \"ax\";" \
|
||||
".globl " PV_THUNK_NAME(func) ";" \
|
||||
".type " PV_THUNK_NAME(func) ", @function;" \
|
||||
ASM_FUNC_ALIGN \
|
||||
PV_THUNK_NAME(func) ":" \
|
||||
ASM_ENDBR \
|
||||
FRAME_BEGIN \
|
||||
PV_SAVE_ALL_CALLER_REGS \
|
||||
"call " #func ";" \
|
||||
PV_RESTORE_ALL_CALLER_REGS \
|
||||
FRAME_END \
|
||||
ASM_RET \
|
||||
".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
|
||||
".popsection")
|
||||
|
||||
#define PV_CALLEE_SAVE_REGS_THUNK(func) \
|
||||
__PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
|
||||
|
||||
/* Get a reference to a callee-save function */
|
||||
#define PV_CALLEE_SAVE(func) \
|
||||
((struct paravirt_callee_save) { __raw_callee_save_##func })
|
||||
|
||||
/* Promise that "func" already uses the right calling convention */
|
||||
#define __PV_IS_CALLEE_SAVE(func) \
|
||||
((struct paravirt_callee_save) { func })
|
||||
|
||||
#ifdef CONFIG_PARAVIRT_XXL
|
||||
static __always_inline unsigned long arch_local_save_flags(void)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -512,5 +512,73 @@ unsigned long pv_native_read_cr2(void);
|
|||
|
||||
#define ALT_NOT_XEN ALT_NOT(X86_FEATURE_XENPV)
|
||||
|
||||
#ifdef CONFIG_X86_32
|
||||
/* save and restore all caller-save registers, except return value */
|
||||
#define PV_SAVE_ALL_CALLER_REGS "pushl %ecx;"
|
||||
#define PV_RESTORE_ALL_CALLER_REGS "popl %ecx;"
|
||||
#else
|
||||
/* save and restore all caller-save registers, except return value */
|
||||
#define PV_SAVE_ALL_CALLER_REGS \
|
||||
"push %rcx;" \
|
||||
"push %rdx;" \
|
||||
"push %rsi;" \
|
||||
"push %rdi;" \
|
||||
"push %r8;" \
|
||||
"push %r9;" \
|
||||
"push %r10;" \
|
||||
"push %r11;"
|
||||
#define PV_RESTORE_ALL_CALLER_REGS \
|
||||
"pop %r11;" \
|
||||
"pop %r10;" \
|
||||
"pop %r9;" \
|
||||
"pop %r8;" \
|
||||
"pop %rdi;" \
|
||||
"pop %rsi;" \
|
||||
"pop %rdx;" \
|
||||
"pop %rcx;"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Generate a thunk around a function which saves all caller-save
|
||||
* registers except for the return value. This allows C functions to
|
||||
* be called from assembler code where fewer than normal registers are
|
||||
* available. It may also help code generation around calls from C
|
||||
* code if the common case doesn't use many registers.
|
||||
*
|
||||
* When a callee is wrapped in a thunk, the caller can assume that all
|
||||
* arg regs and all scratch registers are preserved across the
|
||||
* call. The return value in rax/eax will not be saved, even for void
|
||||
* functions.
|
||||
*/
|
||||
#define PV_THUNK_NAME(func) "__raw_callee_save_" #func
|
||||
#define __PV_CALLEE_SAVE_REGS_THUNK(func, section) \
|
||||
extern typeof(func) __raw_callee_save_##func; \
|
||||
\
|
||||
asm(".pushsection " section ", \"ax\";" \
|
||||
".globl " PV_THUNK_NAME(func) ";" \
|
||||
".type " PV_THUNK_NAME(func) ", @function;" \
|
||||
ASM_FUNC_ALIGN \
|
||||
PV_THUNK_NAME(func) ":" \
|
||||
ASM_ENDBR \
|
||||
FRAME_BEGIN \
|
||||
PV_SAVE_ALL_CALLER_REGS \
|
||||
"call " #func ";" \
|
||||
PV_RESTORE_ALL_CALLER_REGS \
|
||||
FRAME_END \
|
||||
ASM_RET \
|
||||
".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
|
||||
".popsection")
|
||||
|
||||
#define PV_CALLEE_SAVE_REGS_THUNK(func) \
|
||||
__PV_CALLEE_SAVE_REGS_THUNK(func, ".text")
|
||||
|
||||
/* Get a reference to a callee-save function */
|
||||
#define PV_CALLEE_SAVE(func) \
|
||||
((struct paravirt_callee_save) { __raw_callee_save_##func })
|
||||
|
||||
/* Promise that "func" already uses the right calling convention */
|
||||
#define __PV_IS_CALLEE_SAVE(func) \
|
||||
((struct paravirt_callee_save) { func })
|
||||
|
||||
#endif /* CONFIG_PARAVIRT */
|
||||
#endif /* _ASM_X86_PARAVIRT_TYPES_H */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user