diff options
author | Peter Zijlstra | 2022-03-21 10:57:51 +0100 |
---|---|---|
committer | Peter Zijlstra | 2022-03-22 21:12:14 +0100 |
commit | b9067cd80fbc5b3ae061e5bde6efd19bbf02f9e2 (patch) | |
tree | fdaaed7ef09b95c42def87363f084a4f46b7369f /arch/x86/kvm | |
parent | f6a2c2b2de817078ac5a7e58c10e746165e7825d (diff) | |
parent | fe83f5eae432ccc8e90082d6ed506d5233547473 (diff) |
Merge branch 'kvm/kvm-sls-fix'
Sync with the last minute SLS fix to extend it for IBT.
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/emulate.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 08c4e9c1a382..d98fb36c68ed 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -430,8 +430,23 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); FOP_END /* Special case for SETcc - 1 instruction per cc */ + +/* + * Depending on .config the SETcc functions look like: + * + * SETcc %al [3 bytes] + * RET [1 byte] + * INT3 [1 byte; CONFIG_SLS] + * + * Which gives possible sizes 4 or 5. When rounded up to the + * next power-of-two alignment they become 4 or 8. + */ +#define SETCC_LENGTH (4 + IS_ENABLED(CONFIG_SLS)) +#define SETCC_ALIGN (4 << IS_ENABLED(CONFIG_SLS)) +static_assert(SETCC_LENGTH <= SETCC_ALIGN); + #define FOP_SETCC(op) \ - ".align 4 \n\t" \ + ".align " __stringify(SETCC_ALIGN) " \n\t" \ ".type " #op ", @function \n\t" \ #op ": \n\t" \ ASM_ENDBR \ @@ -1049,7 +1064,7 @@ static int em_bsr_c(struct x86_emulate_ctxt *ctxt) static __always_inline u8 test_cc(unsigned int condition, unsigned long flags) { u8 rc; - void (*fop)(void) = (void *)em_setcc + 4 * (condition & 0xf); + void (*fop)(void) = (void *)em_setcc + SETCC_ALIGN * (condition & 0xf); flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF; asm("push %[flags]; popf; " CALL_NOSPEC |