[PATCH 2/2] KVM: x86: Set EMULTYPE_NO_REEXECUTE for MMIO emulation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



reexecute_instruction(), added by commit a6f177efaa58 ("KVM: Reenter
guest after emulation failure if due to access to non-mmio address"),
is intended to return true if and only if emulation failed due to a
write to a shadowed page, i.e. MMIO emulation that happens to fail
should never be retried.  Set EMULTYPE_NO_REEXECUTE when we know we
are emulating a (alleged) MMIO access to document that we should not
re-execute the instruction.

This is purely a documentation update as reexecute_instruction() does
not re-execute instructions whose faulting GPA corresponds to an error
or no-slot PFN, e.g. EMULTYPE_NO_REEXECUTE was added by commit
991eebf9f8e5 ("KVM: VMX: do not try to reexecute failed instruction
while emulating invalid guest state") for reasons entirely unrelated
to MMIO.  Case in point, mmio_info_in_cache() always returns false for
nested VMs, e.g. EMULTYPE_NO_REEXECUTE won't be set if MMIO emulation
for a nested VM is triggered outside of the handle_mmio_page_fault()
path.

Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
 arch/x86/kvm/mmu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a282321329b5..1c152fd9fc7c 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -5231,7 +5231,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
 	if (unlikely(error_code & PFERR_RSVD_MASK)) {
 		r = handle_mmio_page_fault(vcpu, cr2, direct);
 		if (r == RET_PF_EMULATE) {
-			emulation_type = 0;
+			emulation_type = EMULTYPE_NO_REEXECUTE;
 			goto emulate;
 		}
 	}
@@ -5261,7 +5261,7 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
 	}
 
 	if (mmio_info_in_cache(vcpu, cr2, direct))
-		emulation_type = 0;
+		emulation_type = EMULTYPE_NO_REEXECUTE;
 emulate:
 	/*
 	 * On AMD platforms, under certain conditions insn_len may be zero on #NPF.
-- 
2.18.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux