Skip to content

Commit b35491e

Browse files
Wanpeng Libonzini
authored andcommitted
KVM: X86: Kill off ctxt->ud
ctxt->ud is consumed only by x86_decode_insn(), we can kill it off by passing emulation_type to x86_decode_insn() and dropping ctxt->ud altogether. Tracking that info in ctxt for literally one call is silly. Suggested-by: Sean Christopherson <[email protected]> Signed-off-by: Wanpeng Li <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Message-Id: <[email protected]>
1 parent da6393c commit b35491e

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

arch/x86/kvm/emulate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5111,7 +5111,7 @@ static int decode_operand(struct x86_emulate_ctxt *ctxt, struct operand *op,
51115111
return rc;
51125112
}
51135113

5114-
int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
5114+
int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type)
51155115
{
51165116
int rc = X86EMUL_CONTINUE;
51175117
int mode = ctxt->mode;
@@ -5322,7 +5322,8 @@ int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len)
53225322

53235323
ctxt->execute = opcode.u.execute;
53245324

5325-
if (unlikely(ctxt->ud) && likely(!(ctxt->d & EmulateOnUD)))
5325+
if (unlikely(emulation_type & EMULTYPE_TRAP_UD) &&
5326+
likely(!(ctxt->d & EmulateOnUD)))
53265327
return EMULATION_FAILED;
53275328

53285329
if (unlikely(ctxt->d &

arch/x86/kvm/kvm_emulate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ struct x86_emulate_ctxt {
314314
int interruptibility;
315315

316316
bool perm_ok; /* do not check permissions if true */
317-
bool ud; /* inject an #UD if host doesn't support insn */
318317
bool tf; /* TF value before instruction (after for syscall/sysret) */
319318

320319
bool have_exception;
@@ -491,7 +490,7 @@ enum x86_intercept {
491490
#define X86EMUL_MODE_HOST X86EMUL_MODE_PROT64
492491
#endif
493492

494-
int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len);
493+
int x86_decode_insn(struct x86_emulate_ctxt *ctxt, void *insn, int insn_len, int emulation_type);
495494
bool x86_page_table_writing_insn(struct x86_emulate_ctxt *ctxt);
496495
#define EMULATION_FAILED -1
497496
#define EMULATION_OK 0

arch/x86/kvm/x86.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7568,9 +7568,7 @@ int x86_decode_emulated_instruction(struct kvm_vcpu *vcpu, int emulation_type,
75687568
kvm_vcpu_check_breakpoint(vcpu, &r))
75697569
return r;
75707570

7571-
ctxt->ud = emulation_type & EMULTYPE_TRAP_UD;
7572-
7573-
r = x86_decode_insn(ctxt, insn, insn_len);
7571+
r = x86_decode_insn(ctxt, insn, insn_len, emulation_type);
75747572

75757573
trace_kvm_emulate_insn_start(vcpu);
75767574
++vcpu->stat.insn_emulation;

0 commit comments

Comments
 (0)