Commit 80d2b5af authored by Liran Alon's avatar Liran Alon Committed by Greg Kroah-Hartman

KVM: x86: Don't re-execute instruction when not passing CR2 value


[ Upstream commit 9b8ae637 ]

In case of instruction-decode failure or emulation failure,
x86_emulate_instruction() will call reexecute_instruction() which will
attempt to use the cr2 value passed to x86_emulate_instruction().
However, when x86_emulate_instruction() is called from
emulate_instruction(), cr2 is not passed (passed as 0) and therefore
it doesn't make sense to execute reexecute_instruction() logic at all.

Fixes: 51d8b661 ("KVM: cleanup emulate_instruction")
Signed-off-by: default avatarLiran Alon <liran.alon@oracle.com>
Reviewed-by: default avatarNikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: default avatarWanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3d4df917
...@@ -998,7 +998,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2, ...@@ -998,7 +998,8 @@ int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
static inline int emulate_instruction(struct kvm_vcpu *vcpu, static inline int emulate_instruction(struct kvm_vcpu *vcpu,
int emulation_type) int emulation_type)
{ {
return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0); return x86_emulate_instruction(vcpu, 0,
emulation_type | EMULTYPE_NO_REEXECUTE, NULL, 0);
} }
void kvm_enable_efer_bits(u64); void kvm_enable_efer_bits(u64);
......
...@@ -6023,7 +6023,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu) ...@@ -6023,7 +6023,7 @@ static int handle_invalid_guest_state(struct kvm_vcpu *vcpu)
if (test_bit(KVM_REQ_EVENT, &vcpu->requests)) if (test_bit(KVM_REQ_EVENT, &vcpu->requests))
return 1; return 1;
err = emulate_instruction(vcpu, EMULTYPE_NO_REEXECUTE); err = emulate_instruction(vcpu, 0);
if (err == EMULATE_USER_EXIT) { if (err == EMULATE_USER_EXIT) {
++vcpu->stat.mmio_exits; ++vcpu->stat.mmio_exits;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment