Commit 9824b00c authored by Juergen Gross's avatar Juergen Gross Committed by Borislav Petkov (AMD)
Browse files

x86/paravirt: Move some functions and defines to alternative.c



As a preparation for replacing paravirt patching completely by
alternative patching, move some backend functions and #defines to
the alternatives code and header.

Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231129133332.31043-3-jgross@suse.com
parent 772ca413
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -330,6 +330,22 @@ static inline int alternatives_text_reserved(void *start, void *end)
 */
#define ASM_NO_INPUT_CLOBBER(clbr...) "i" (0) : clbr

/* Macro for creating assembler functions avoiding any C magic. */
#define DEFINE_ASM_FUNC(func, instr, sec)		\
	asm (".pushsection " #sec ", \"ax\"\n"		\
	     ".global " #func "\n\t"			\
	     ".type " #func ", @function\n\t"		\
	     ASM_FUNC_ALIGN "\n"			\
	     #func ":\n\t"				\
	     ASM_ENDBR					\
	     instr "\n\t"				\
	     ASM_RET					\
	     ".size " #func ", . - " #func "\n\t"	\
	     ".popsection")

void BUG_func(void);
void nop_func(void);

#else /* __ASSEMBLY__ */

#ifdef CONFIG_SMP
+0 −12
Original line number Diff line number Diff line
@@ -720,18 +720,6 @@ static __always_inline unsigned long arch_local_irq_save(void)
#undef PVOP_VCALL4
#undef PVOP_CALL4

#define DEFINE_PARAVIRT_ASM(func, instr, sec)		\
	asm (".pushsection " #sec ", \"ax\"\n"		\
	     ".global " #func "\n\t"			\
	     ".type " #func ", @function\n\t"		\
	     ASM_FUNC_ALIGN "\n"			\
	     #func ":\n\t"				\
	     ASM_ENDBR					\
	     instr "\n\t"				\
	     ASM_RET					\
	     ".size " #func ", . - " #func "\n\t"	\
	     ".popsection")

extern void default_banner(void);
void native_pv_lock_init(void) __init;

+1 −3
Original line number Diff line number Diff line
@@ -540,8 +540,6 @@ int paravirt_disable_iospace(void);
	__PVOP_VCALL(op, PVOP_CALL_ARG1(arg1), PVOP_CALL_ARG2(arg2),	\
		     PVOP_CALL_ARG3(arg3), PVOP_CALL_ARG4(arg4))

void _paravirt_nop(void);
void paravirt_BUG(void);
unsigned long paravirt_ret0(void);
#ifdef CONFIG_PARAVIRT_XXL
u64 _paravirt_ident_64(u64);
@@ -551,7 +549,7 @@ void pv_native_irq_enable(void);
unsigned long pv_native_read_cr2(void);
#endif

#define paravirt_nop	((void *)_paravirt_nop)
#define paravirt_nop	((void *)nop_func)

extern struct paravirt_patch_site __parainstructions[],
	__parainstructions_end[];
+2 −2
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ __PV_CALLEE_SAVE_REGS_THUNK(__pv_queued_spin_unlock_slowpath, ".spinlock.text");
	"pop    %rdx\n\t"						\
	FRAME_END

DEFINE_PARAVIRT_ASM(__raw_callee_save___pv_queued_spin_unlock,
DEFINE_ASM_FUNC(__raw_callee_save___pv_queued_spin_unlock,
		PV_UNLOCK_ASM, .spinlock.text);

#else /* CONFIG_64BIT */
+10 −0
Original line number Diff line number Diff line
@@ -385,6 +385,16 @@ apply_relocation(u8 *buf, size_t len, u8 *dest, u8 *src, size_t src_len)
	}
}

/* Low-level backend functions usable from alternative code replacements. */
DEFINE_ASM_FUNC(nop_func, "", .entry.text);
EXPORT_SYMBOL_GPL(nop_func);

noinstr void BUG_func(void)
{
	BUG();
}
EXPORT_SYMBOL_GPL(BUG_func);

/*
 * Replace instructions with better alternatives for this CPU type. This runs
 * before SMP is initialized to avoid SMP problems with self modifying code.
Loading