History

Merge tag 'for-linus-5.17' of git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fix from Paolo Bonzini: "Fix for the SLS mitigation, which makes a 'SETcc/RET' pair grow to 'SETcc/RET/INT3'. This doesn't fit in 4 bytes any more, so the alignment has to change to 8 for this case" * tag 'for-linus-5.17' of git://git.kernel.org/pub/scm/virt/kvm/kvm: kvm/emulate: Fix SETcc emulation function offsets with SLS

Linus Torvalds committed 4 years ago

Commit 7445b2d2 parents 1e0e7a6 fe83f5e1 file · +17 −2Browse files

Unified · Split

arch/x86/kvm/emulate.c+17−2
@@ -429,8 +429,23 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop); · 428 unmodified lines
429 FOP_END429 FOP_END
430 430
431/* Special case for SETcc - 1 instruction per cc */431/* Special case for SETcc - 1 instruction per cc */
432
433/*
434 * Depending on .config the SETcc functions look like:
435 *
436 * SETcc %al [3 bytes]
437 * RET [1 byte]
438 * INT3 [1 byte; CONFIG_SLS]
439 *
440 * Which gives possible sizes 4 or 5. When rounded up to the
441 * next power-of-two alignment they become 4 or 8.
442 */
443#define SETCC_LENGTH (4 + IS_ENABLED(CONFIG_SLS))
444#define SETCC_ALIGN (4 << IS_ENABLED(CONFIG_SLS))
445static_assert(SETCC_LENGTH <= SETCC_ALIGN);
446
432#define FOP_SETCC(op) \447#define FOP_SETCC(op) \
433 ".align 4 \n\t" \448 ".align " __stringify(SETCC_ALIGN) " \n\t" \
434 ".type " #op ", @function \n\t" \449 ".type " #op ", @function \n\t" \
435 #op ": \n\t" \450 #op ": \n\t" \
436 #op " %al \n\t" \451 #op " %al \n\t" \
@@ -1047,7 +1062,7 @@ static int em_bsr_c(struct x86_emulate_ctxt *ctxt) · 610 unmodified lines
1047static __always_inline u8 test_cc(unsigned int condition, unsigned long flags)1062static __always_inline u8 test_cc(unsigned int condition, unsigned long flags)
1048{1063{
1049 u8 rc;1064 u8 rc;
1050 void (*fop)(void) = (void *)em_setcc + 4 * (condition & 0xf);1065 void (*fop)(void) = (void *)em_setcc + SETCC_ALIGN * (condition & 0xf);
1051 1066
1052 flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF;1067 flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF;
1053 asm("push %[flags]; popf; " CALL_NOSPEC1068 asm("push %[flags]; popf; " CALL_NOSPEC

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t