Skip to content

Commit 3986f65

Browse files
author
Peter Zijlstra
committed
kvm/emulate: Fix SETcc emulation for ENDBR
Companion patch for commit fe83f5e ("kvm/emulate: Fix SETcc emulation function offsets with SLS"), now extending it to cover the additional ENDBR instruction. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/YjMVpfe%[email protected]
1 parent b9067cd commit 3986f65

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

arch/x86/kvm/emulate.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/stringify.h>
2525
#include <asm/debugreg.h>
2626
#include <asm/nospec-branch.h>
27+
#include <asm/ibt.h>
2728

2829
#include "x86.h"
2930
#include "tss.h"
@@ -434,15 +435,16 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
434435
/*
435436
* Depending on .config the SETcc functions look like:
436437
*
438+
* ENDBR [4 bytes; CONFIG_X86_KERNEL_IBT]
437439
* SETcc %al [3 bytes]
438440
* RET [1 byte]
439441
* INT3 [1 byte; CONFIG_SLS]
440442
*
441-
* Which gives possible sizes 4 or 5. When rounded up to the
442-
* next power-of-two alignment they become 4 or 8.
443+
* Which gives possible sizes 4, 5, 8 or 9. When rounded up to the
444+
* next power-of-two alignment they become 4, 8 or 16 resp.
443445
*/
444-
#define SETCC_LENGTH (4 + IS_ENABLED(CONFIG_SLS))
445-
#define SETCC_ALIGN (4 << IS_ENABLED(CONFIG_SLS))
446+
#define SETCC_LENGTH (ENDBR_INSN_SIZE + 4 + IS_ENABLED(CONFIG_SLS))
447+
#define SETCC_ALIGN (4 << IS_ENABLED(CONFIG_SLS) << HAS_KERNEL_IBT)
446448
static_assert(SETCC_LENGTH <= SETCC_ALIGN);
447449

448450
#define FOP_SETCC(op) \

0 commit comments

Comments
 (0)