[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210412130938.68178-5-david.edmondson@oracle.com>
Date: Mon, 12 Apr 2021 14:09:35 +0100
From: David Edmondson <david.edmondson@...cle.com>
To: linux-kernel@...r.kernel.org
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
Sean Christopherson <seanjc@...gle.com>,
Thomas Gleixner <tglx@...utronix.de>,
Joerg Roedel <joro@...tes.org>,
Wanpeng Li <wanpengli@...cent.com>,
Borislav Petkov <bp@...en8.de>,
Jim Mattson <jmattson@...gle.com>,
Ingo Molnar <mingo@...hat.com>,
Joao Martins <joao.m.martins@...cle.com>,
David Edmondson <david.edmondson@...cle.com>
Subject: [PATCH 4/6] KVM: x86: pass a proper reason to kvm_emulate_instruction()
From: Joao Martins <joao.m.martins@...cle.com>
Declare various causes of emulation and use them as appropriate.
Signed-off-by: Joao Martins <joao.m.martins@...cle.com>
Signed-off-by: David Edmondson <david.edmondson@...cle.com>
---
arch/x86/include/asm/kvm_host.h | 6 ++++++
arch/x86/kvm/mmu/mmu.c | 4 ++--
arch/x86/kvm/x86.c | 5 +++--
3 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
index 556dc51e322a..79e9ca756742 100644
--- a/arch/x86/include/asm/kvm_host.h
+++ b/arch/x86/include/asm/kvm_host.h
@@ -1529,6 +1529,12 @@ extern u64 kvm_mce_cap_supported;
enum {
EMULREASON_UNKNOWN = 0,
+ EMULREASON_SKIP,
+ EMULREASON_GP,
+ EMULREASON_IO,
+ EMULREASON_IO_COMPLETE,
+ EMULREASON_UD,
+ EMULREASON_PF,
};
int kvm_emulate_instruction(struct kvm_vcpu *vcpu, int emulation_type,
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
index 515ff790b7c5..14ddf1a5ac12 100644
--- a/arch/x86/kvm/mmu/mmu.c
+++ b/arch/x86/kvm/mmu/mmu.c
@@ -5056,8 +5056,8 @@ int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gpa_t cr2_or_gpa, u64 error_code,
if (!mmio_info_in_cache(vcpu, cr2_or_gpa, direct) && !is_guest_mode(vcpu))
emulation_type |= EMULTYPE_ALLOW_RETRY_PF;
emulate:
- return x86_emulate_instruction(vcpu, cr2_or_gpa, emulation_type, 0,
- insn, insn_len);
+ return x86_emulate_instruction(vcpu, cr2_or_gpa, emulation_type,
+ EMULREASON_PF, insn, insn_len);
}
EXPORT_SYMBOL_GPL(kvm_mmu_page_fault);
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 88519bf6bd00..41020eba8e21 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -6197,7 +6197,7 @@ int handle_ud(struct kvm_vcpu *vcpu)
emul_type = EMULTYPE_TRAP_UD_FORCED;
}
- return kvm_emulate_instruction(vcpu, emul_type, 0);
+ return kvm_emulate_instruction(vcpu, emul_type, EMULREASON_UD);
}
EXPORT_SYMBOL_GPL(handle_ud);
@@ -9343,7 +9343,8 @@ static inline int complete_emulated_io(struct kvm_vcpu *vcpu)
int r;
vcpu->srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
- r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE, 0);
+ r = kvm_emulate_instruction(vcpu, EMULTYPE_NO_DECODE,
+ EMULREASON_IO_COMPLETE);
srcu_read_unlock(&vcpu->kvm->srcu, vcpu->srcu_idx);
return r;
}
--
2.30.2
Powered by blists - more mailing lists