@@ -8470,11 +8470,6 @@ static bool emulator_is_smm(struct x86_emulate_ctxt *ctxt)
84708470 return is_smm (emul_to_vcpu (ctxt ));
84718471}
84728472
8473- static bool emulator_is_guest_mode (struct x86_emulate_ctxt * ctxt )
8474- {
8475- return is_guest_mode (emul_to_vcpu (ctxt ));
8476- }
8477-
84788473#ifndef CONFIG_KVM_SMM
84798474static int emulator_leave_smm (struct x86_emulate_ctxt * ctxt )
84808475{
@@ -8558,7 +8553,6 @@ static const struct x86_emulate_ops emulate_ops = {
85588553 .guest_cpuid_is_intel_compatible = emulator_guest_cpuid_is_intel_compatible ,
85598554 .set_nmi_mask = emulator_set_nmi_mask ,
85608555 .is_smm = emulator_is_smm ,
8561- .is_guest_mode = emulator_is_guest_mode ,
85628556 .leave_smm = emulator_leave_smm ,
85638557 .triple_fault = emulator_triple_fault ,
85648558 .set_xcr = emulator_set_xcr ,
@@ -9143,7 +9137,14 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa,
91439137 ctxt -> exception .address = 0 ;
91449138 }
91459139
9146- r = x86_emulate_insn (ctxt );
9140+ /*
9141+ * Check L1's instruction intercepts when emulating instructions for
9142+ * L2, unless KVM is re-emulating a previously decoded instruction,
9143+ * e.g. to complete userspace I/O, in which case KVM has already
9144+ * checked the intercepts.
9145+ */
9146+ r = x86_emulate_insn (ctxt , is_guest_mode (vcpu ) &&
9147+ !(emulation_type & EMULTYPE_NO_DECODE ));
91479148
91489149 if (r == EMULATION_INTERCEPTED )
91499150 return 1 ;
0 commit comments