Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8065dbd1 authored by Sean Christopherson's avatar Sean Christopherson Committed by Radim Krčmář
Browse files

KVM: x86: Invert emulation re-execute behavior to make it opt-in



Re-execution of an instruction after emulation decode failure is
intended to be used only when emulating shadow page accesses.  Invert
the flag to make allowing re-execution opt-in since that behavior is
by far in the minority.

Signed-off-by: default avatarSean Christopherson <sean.j.christopherson@intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 35be0ade
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -1238,7 +1238,7 @@ enum emulation_result {
#define EMULTYPE_TRAP_UD	    (1 << 1)
#define EMULTYPE_TRAP_UD	    (1 << 1)
#define EMULTYPE_SKIP		    (1 << 2)
#define EMULTYPE_SKIP		    (1 << 2)
#define EMULTYPE_RETRY		    (1 << 3)
#define EMULTYPE_RETRY		    (1 << 3)
#define EMULTYPE_NO_REEXECUTE	    (1 << 4)
#define EMULTYPE_ALLOW_REEXECUTE    (1 << 4)
#define EMULTYPE_NO_UD_ON_FAIL	    (1 << 5)
#define EMULTYPE_NO_UD_ON_FAIL	    (1 << 5)
#define EMULTYPE_VMWARE		    (1 << 6)
#define EMULTYPE_VMWARE		    (1 << 6)
int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
int x86_emulate_instruction(struct kvm_vcpu *vcpu, unsigned long cr2,
@@ -1247,15 +1247,13 @@ 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,
	return x86_emulate_instruction(vcpu, 0, emulation_type, NULL, 0);
			emulation_type | EMULTYPE_NO_REEXECUTE, NULL, 0);
}
}


static inline int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
static inline int kvm_emulate_instruction_from_buffer(struct kvm_vcpu *vcpu,
						      void *insn, int insn_len)
						      void *insn, int insn_len)
{
{
	return x86_emulate_instruction(vcpu, 0, EMULTYPE_NO_REEXECUTE,
	return x86_emulate_instruction(vcpu, 0, 0, insn, insn_len);
				       insn, insn_len);
}
}


void kvm_enable_efer_bits(u64);
void kvm_enable_efer_bits(u64);
+1 −1
Original line number Original line Diff line number Diff line
@@ -5217,7 +5217,7 @@ static int make_mmu_pages_available(struct kvm_vcpu *vcpu)
int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t cr2, u64 error_code,
		       void *insn, int insn_len)
		       void *insn, int insn_len)
{
{
	int r, emulation_type = EMULTYPE_RETRY;
	int r, emulation_type = EMULTYPE_RETRY | EMULTYPE_ALLOW_REEXECUTE;
	enum emulation_result er;
	enum emulation_result er;
	bool direct = vcpu->arch.mmu.direct_map;
	bool direct = vcpu->arch.mmu.direct_map;


+1 −1
Original line number Original line Diff line number Diff line
@@ -5870,7 +5870,7 @@ static bool reexecute_instruction(struct kvm_vcpu *vcpu, gva_t cr2,
	gpa_t gpa = cr2;
	gpa_t gpa = cr2;
	kvm_pfn_t pfn;
	kvm_pfn_t pfn;


	if (emulation_type & EMULTYPE_NO_REEXECUTE)
	if (!(emulation_type & EMULTYPE_ALLOW_REEXECUTE))
		return false;
		return false;


	if (!vcpu->arch.mmu.direct_map) {
	if (!vcpu->arch.mmu.direct_map) {