mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-26 00:12:56 -04:00
KVM: x86: Add interrupt injection information to the kvm_entry tracepoint
Add VMX/SVM specific interrupt injection info the kvm_entry tracepoint. As is done with kvm_exit, gather the information via a kvm_x86_ops hook to avoid the moderately costly VMREADs on VMX when the tracepoint isn't enabled. Opportunistically rename the parameters in the get_exit_info() declaration to match the names used by both SVM and VMX. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Link: https://lore.kernel.org/r/20240910200350.264245-2-mlevitsk@redhat.com [sean: drop is_guest_mode() change, use intr_info/error_code for names] Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
committed by
Sean Christopherson
parent
62e41f6b4f
commit
3e633e7e7d
@@ -100,6 +100,7 @@ KVM_X86_OP(get_l2_tsc_multiplier)
|
||||
KVM_X86_OP(write_tsc_offset)
|
||||
KVM_X86_OP(write_tsc_multiplier)
|
||||
KVM_X86_OP(get_exit_info)
|
||||
KVM_X86_OP(get_entry_info)
|
||||
KVM_X86_OP(check_intercept)
|
||||
KVM_X86_OP(handle_exit_irqoff)
|
||||
KVM_X86_OP_OPTIONAL(update_cpu_dirty_logging)
|
||||
|
||||
@@ -1770,12 +1770,15 @@ struct kvm_x86_ops {
|
||||
void (*write_tsc_multiplier)(struct kvm_vcpu *vcpu);
|
||||
|
||||
/*
|
||||
* Retrieve somewhat arbitrary exit information. Intended to
|
||||
* Retrieve somewhat arbitrary exit/entry information. Intended to
|
||||
* be used only from within tracepoints or error paths.
|
||||
*/
|
||||
void (*get_exit_info)(struct kvm_vcpu *vcpu, u32 *reason,
|
||||
u64 *info1, u64 *info2,
|
||||
u32 *exit_int_info, u32 *exit_int_info_err_code);
|
||||
u32 *intr_info, u32 *error_code);
|
||||
|
||||
void (*get_entry_info)(struct kvm_vcpu *vcpu,
|
||||
u32 *intr_info, u32 *error_code);
|
||||
|
||||
int (*check_intercept)(struct kvm_vcpu *vcpu,
|
||||
struct x86_instruction_info *info,
|
||||
|
||||
@@ -3542,6 +3542,21 @@ static void svm_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
|
||||
*error_code = 0;
|
||||
}
|
||||
|
||||
static void svm_get_entry_info(struct kvm_vcpu *vcpu, u32 *intr_info,
|
||||
u32 *error_code)
|
||||
{
|
||||
struct vmcb_control_area *control = &to_svm(vcpu)->vmcb->control;
|
||||
|
||||
*intr_info = control->event_inj;
|
||||
|
||||
if ((*intr_info & SVM_EXITINTINFO_VALID) &&
|
||||
(*intr_info & SVM_EXITINTINFO_VALID_ERR))
|
||||
*error_code = control->event_inj_err;
|
||||
else
|
||||
*error_code = 0;
|
||||
|
||||
}
|
||||
|
||||
static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
|
||||
{
|
||||
struct vcpu_svm *svm = to_svm(vcpu);
|
||||
@@ -5082,6 +5097,7 @@ static struct kvm_x86_ops svm_x86_ops __initdata = {
|
||||
.required_apicv_inhibits = AVIC_REQUIRED_APICV_INHIBITS,
|
||||
|
||||
.get_exit_info = svm_get_exit_info,
|
||||
.get_entry_info = svm_get_entry_info,
|
||||
|
||||
.vcpu_after_set_cpuid = svm_vcpu_after_set_cpuid,
|
||||
|
||||
|
||||
@@ -22,15 +22,22 @@ TRACE_EVENT(kvm_entry,
|
||||
__field( unsigned int, vcpu_id )
|
||||
__field( unsigned long, rip )
|
||||
__field( bool, immediate_exit )
|
||||
__field( u32, intr_info )
|
||||
__field( u32, error_code )
|
||||
),
|
||||
|
||||
TP_fast_assign(
|
||||
__entry->vcpu_id = vcpu->vcpu_id;
|
||||
__entry->rip = kvm_rip_read(vcpu);
|
||||
__entry->immediate_exit = force_immediate_exit;
|
||||
|
||||
kvm_x86_call(get_entry_info)(vcpu, &__entry->intr_info,
|
||||
&__entry->error_code);
|
||||
),
|
||||
|
||||
TP_printk("vcpu %u, rip 0x%lx%s", __entry->vcpu_id, __entry->rip,
|
||||
TP_printk("vcpu %u, rip 0x%lx intr_info 0x%08x error_code 0x%08x%s",
|
||||
__entry->vcpu_id, __entry->rip,
|
||||
__entry->intr_info, __entry->error_code,
|
||||
__entry->immediate_exit ? "[immediate exit]" : "")
|
||||
);
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ struct kvm_x86_ops vt_x86_ops __initdata = {
|
||||
.get_mt_mask = vmx_get_mt_mask,
|
||||
|
||||
.get_exit_info = vmx_get_exit_info,
|
||||
.get_entry_info = vmx_get_entry_info,
|
||||
|
||||
.vcpu_after_set_cpuid = vmx_vcpu_after_set_cpuid,
|
||||
|
||||
|
||||
@@ -6194,6 +6194,15 @@ void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
|
||||
}
|
||||
}
|
||||
|
||||
void vmx_get_entry_info(struct kvm_vcpu *vcpu, u32 *intr_info, u32 *error_code)
|
||||
{
|
||||
*intr_info = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD);
|
||||
if (is_exception_with_error_code(*intr_info))
|
||||
*error_code = vmcs_read32(VM_ENTRY_EXCEPTION_ERROR_CODE);
|
||||
else
|
||||
*error_code = 0;
|
||||
}
|
||||
|
||||
static void vmx_destroy_pml_buffer(struct vcpu_vmx *vmx)
|
||||
{
|
||||
if (vmx->pml_pg) {
|
||||
|
||||
@@ -104,8 +104,11 @@ void vmx_load_eoi_exitmap(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
|
||||
int vmx_set_tss_addr(struct kvm *kvm, unsigned int addr);
|
||||
int vmx_set_identity_map_addr(struct kvm *kvm, u64 ident_addr);
|
||||
u8 vmx_get_mt_mask(struct kvm_vcpu *vcpu, gfn_t gfn, bool is_mmio);
|
||||
|
||||
void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
|
||||
u64 *info1, u64 *info2, u32 *intr_info, u32 *error_code);
|
||||
void vmx_get_entry_info(struct kvm_vcpu *vcpu, u32 *intr_info, u32 *error_code);
|
||||
|
||||
u64 vmx_get_l2_tsc_offset(struct kvm_vcpu *vcpu);
|
||||
u64 vmx_get_l2_tsc_multiplier(struct kvm_vcpu *vcpu);
|
||||
void vmx_write_tsc_offset(struct kvm_vcpu *vcpu);
|
||||
|
||||
Reference in New Issue
Block a user