vmmon: use standard ASM_ENDBR macro

Some cross page functions need an explicit endbr64 instruction as they are
indirect branch targets but are not recognized as such. VMware 17 uses home
cooked ENDBR macro rather than standard ASM_ENDBR defined in kernel.

Use ASM_ENDBR instead and define it as empty if not available (kernel
before 5.18-rc1) so that we do not generate useless endbr64 instructions
when building against kernel which does not support IBT or has it disabled.
This commit is contained in:
Michal Kubecek 2023-01-17 22:40:04 +01:00
parent 656c714398
commit ec77a99716
1 changed files with 8 additions and 6 deletions

View File

@ -75,7 +75,9 @@
#define EXPORTED_ASM_SYMBOL(fn) ".global " ASM_PREFIX #fn "\n" \
ASM_PREFIX #fn ":\n"
#define ENDBR ".byte 0xf3, 0x0f, 0x1e, 0xfa\n"
#ifndef ASM_ENDBR
#define ASM_ENDBR
#endif
/*
* Tag the crosspage code C wrapper with the crosspage section and page
@ -295,7 +297,7 @@ CrossPage_CodePage(void)
".p2align 4\n"
EXPORTED_ASM_SYMBOL(SwitchDBHandler)
ENDBR
ASM_ENDBR
"pushq %%rax\n"
"call SwitchExcGetCrossPageData\n"
"addq %[wsExceptionDB], %%rax\n"
@ -334,7 +336,7 @@ CrossPage_CodePage(void)
".p2align 4\n"
EXPORTED_ASM_SYMBOL(SwitchUDHandler)
ENDBR
ASM_ENDBR
"pushq %%rax\n"
"pushq %%rbx\n"
"pushq %%rcx\n"
@ -403,7 +405,7 @@ CrossPage_CodePage(void)
".p2align 4\n"
EXPORTED_ASM_SYMBOL(SwitchNMIHandler)
ENDBR
ASM_ENDBR
"pushq %%rax\n"
"call SwitchExcGetCrossPageData\n"
"addq %[wsExceptionNMI], %%rax\n"
@ -439,7 +441,7 @@ CrossPage_CodePage(void)
".p2align 4\n"
EXPORTED_ASM_SYMBOL(SwitchMCEHandler)
ENDBR
ASM_ENDBR
"pushq %%rax\n"
"call SwitchExcGetCrossPageData\n"
"addq %[wsExceptionMC], %%rax\n"
@ -560,7 +562,7 @@ CrossPage_CodePage(void)
".p2align 4\n"
EXPORTED_ASM_SYMBOL(VmmToHost)
ENDBR
ASM_ENDBR
"movq %c[VMMCROSSPAGE] + %c[crosspageDataLA], %%rcx\n"
/* Create an lret frame on the monitor stack. */
"pushq (%%rsp)\n"