Skip to content

Commit c9a34c3

Browse files
author
Peter Zijlstra
committed
x86/kvm: Remove .fixup usage
KVM instruction emulation has a gnarly hack where the .fixup does a return, however there's already a ret right after the 10b label, so mark that as 11 and have the exception clear %esi to remove the .fixup. Suggested-by: Paolo Bonzini <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5fc77b9 commit c9a34c3

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

arch/x86/include/asm/extable_fixup_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,6 @@
4646
#define EX_TYPE_IMM_REG 17 /* reg := (long)imm */
4747
#define EX_TYPE_EFAULT_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(-EFAULT))
4848
#define EX_TYPE_ZERO_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(0))
49+
#define EX_TYPE_ONE_REG (EX_TYPE_IMM_REG | EX_DATA_IMM(1))
4950

5051
#endif

arch/x86/kvm/emulate.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
315315
__FOP_FUNC(#name)
316316

317317
#define __FOP_RET(name) \
318-
ASM_RET \
318+
"11: " ASM_RET \
319319
".size " name ", .-" name "\n\t"
320320

321321
#define FOP_RET(name) \
@@ -344,7 +344,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
344344
__FOP_RET(#op "_" #dst)
345345

346346
#define FOP1EEX(op, dst) \
347-
FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception)
347+
FOP1E(op, dst) _ASM_EXTABLE_TYPE_REG(10b, 11b, EX_TYPE_ZERO_REG, %%esi)
348348

349349
#define FASTOP1(op) \
350350
FOP_START(op) \
@@ -434,10 +434,6 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
434434
#op " %al \n\t" \
435435
__FOP_RET(#op)
436436

437-
asm(".pushsection .fixup, \"ax\"\n"
438-
"kvm_fastop_exception: xor %esi, %esi; " ASM_RET
439-
".popsection");
440-
441437
FOP_START(setcc)
442438
FOP_SETCC(seto)
443439
FOP_SETCC(setno)
@@ -473,12 +469,8 @@ FOP_END;
473469
\
474470
asm volatile("1:" insn "\n" \
475471
"2:\n" \
476-
".pushsection .fixup, \"ax\"\n" \
477-
"3: movl $1, %[_fault]\n" \
478-
" jmp 2b\n" \
479-
".popsection\n" \
480-
_ASM_EXTABLE(1b, 3b) \
481-
: [_fault] "+qm"(_fault) inoutclob ); \
472+
_ASM_EXTABLE_TYPE_REG(1b, 2b, EX_TYPE_ONE_REG, %[_fault]) \
473+
: [_fault] "+r"(_fault) inoutclob ); \
482474
\
483475
_fault ? X86EMUL_UNHANDLEABLE : X86EMUL_CONTINUE; \
484476
})

0 commit comments

Comments
 (0)