From: Paolo Bonzini <pbonzini@redhat.com>
To: Maxim Levitsky <mlevitsk@redhat.com>, kvm@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Sean Christopherson <seanjc@google.com>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Dave Hansen <dave.hansen@linux.intel.com>
Subject: Re: [PATCH v3 2/4] KVM: x86: add more information to the kvm_entry tracepoint
Date: Fri, 24 Nov 2023 17:08:27 +0100 [thread overview]
Message-ID: <da4b9e89-00c7-4067-b962-e86805a345c6@redhat.com> (raw)
In-Reply-To: <20230928103640.78453-3-mlevitsk@redhat.com>
On 9/28/23 12:36, Maxim Levitsky wrote:
> Add VMX/SVM specific interrupt injection info to vm entry tracepoint.
> Also add a flag showing that immediate vm exit is set to happen after
> the entry.
>
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
> arch/x86/include/asm/kvm-x86-ops.h | 1 +
> arch/x86/include/asm/kvm_host.h | 5 ++++-
> arch/x86/kvm/svm/svm.c | 17 +++++++++++++++++
> arch/x86/kvm/trace.h | 15 +++++++++++++--
> arch/x86/kvm/vmx/vmx.c | 12 ++++++++++++
> 5 files changed, 47 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm-x86-ops.h b/arch/x86/include/asm/kvm-x86-ops.h
> index f654a7f4cc8c0c..346fed6e3c33aa 100644
> --- a/arch/x86/include/asm/kvm-x86-ops.h
> +++ b/arch/x86/include/asm/kvm-x86-ops.h
> @@ -99,6 +99,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(sched_in)
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 383a1d0cc0743b..321721813474f7 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1679,13 +1679,16 @@ 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);
>
> + void (*get_entry_info)(struct kvm_vcpu *vcpu,
> + u32 *inj_info, u32 *inj_info_error_code);
> +
> int (*check_intercept)(struct kvm_vcpu *vcpu,
> struct x86_instruction_info *info,
> enum x86_intercept_stage stage,
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 60b130b7f9d510..cd65c04be3d0e2 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3504,6 +3504,22 @@ 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 *inj_info,
> + u32 *inj_info_error_code)
> +{
> + struct vmcb_control_area *control = &to_svm(vcpu)->vmcb->control;
> +
> + *inj_info = control->event_inj;
> +
> + if ((*inj_info & SVM_EXITINTINFO_VALID) &&
> + (*inj_info & SVM_EXITINTINFO_VALID_ERR))
> + *inj_info_error_code = control->event_inj_err;
> + else
> + *inj_info_error_code = 0;
> +
> +}
> +
> static int svm_handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
> @@ -4992,6 +5008,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,
>
> diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h
> index 83843379813ee3..28e8a63368cc02 100644
> --- a/arch/x86/kvm/trace.h
> +++ b/arch/x86/kvm/trace.h
> @@ -21,14 +21,25 @@ TRACE_EVENT(kvm_entry,
> TP_STRUCT__entry(
> __field( unsigned int, vcpu_id )
> __field( unsigned long, rip )
> - ),
> + __field( u32, inj_info )
> + __field( u32, inj_info_err )
> + __field( bool, req_imm_exit )
> + ),
>
> TP_fast_assign(
> __entry->vcpu_id = vcpu->vcpu_id;
> __entry->rip = kvm_rip_read(vcpu);
> + __entry->req_imm_exit = vcpu->arch.req_immediate_exit;
> +
> + static_call(kvm_x86_get_entry_info)(vcpu,
> + &__entry->inj_info,
> + &__entry->inj_info_err);
> ),
>
> - TP_printk("vcpu %u, rip 0x%lx", __entry->vcpu_id, __entry->rip)
> + TP_printk("vcpu %u, rip 0x%lx inj 0x%08x inj_error_code 0x%08x%s",
> + __entry->vcpu_id, __entry->rip,
> + __entry->inj_info, __entry->inj_info_err,
> + __entry->req_imm_exit ? " [req_imm_exit]" : "")
> );
>
> /*
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index eb7e42235e8811..9dd13f52d4999c 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -6156,6 +6156,17 @@ static void vmx_get_exit_info(struct kvm_vcpu *vcpu, u32 *reason,
> }
> }
>
> +static void vmx_get_entry_info(struct kvm_vcpu *vcpu,
> + u32 *inj_info,
> + u32 *inj_info_error_code)
> +{
> + *inj_info = vmcs_read32(VM_ENTRY_INTR_INFO_FIELD);
> + if (is_exception_with_error_code(*inj_info))
> + *inj_info_error_code = vmcs_read32(VM_ENTRY_EXCEPTION_ERROR_CODE);
> + else
> + *inj_info_error_code = 0;
> +}
> +
> static void vmx_destroy_pml_buffer(struct vcpu_vmx *vmx)
> {
> if (vmx->pml_pg) {
> @@ -8297,6 +8308,7 @@ static struct kvm_x86_ops vmx_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,
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2023-11-24 16:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 10:36 [PATCH v3 0/4] KVM: x86: tracepoint updates Maxim Levitsky
2023-09-28 10:36 ` [PATCH v3 1/4] KVM: x86: refactor req_immediate_exit logic Maxim Levitsky
2023-11-24 16:07 ` Paolo Bonzini
2023-11-28 6:41 ` Maxim Levitsky
2023-09-28 10:36 ` [PATCH v3 2/4] KVM: x86: add more information to the kvm_entry tracepoint Maxim Levitsky
2023-11-24 16:08 ` Paolo Bonzini [this message]
2023-09-28 10:36 ` [PATCH v3 3/4] KVM: x86: add information about pending requests to kvm_exit tracepoint Maxim Levitsky
2023-11-24 16:08 ` Paolo Bonzini
2023-09-28 10:36 ` [PATCH v3 4/4] KVM: x86: add new nested vmexit tracepoints Maxim Levitsky
2023-11-24 16:11 ` Paolo Bonzini
2023-11-28 6:42 ` Maxim Levitsky
2023-10-17 12:12 ` [PATCH v3 0/4] KVM: x86: tracepoint updates Maxim Levitsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da4b9e89-00c7-4067-b962-e86805a345c6@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox