Re: [PATCH] Move VMEnter and VMExit tracepoints closer to the actual event

From: Thomas Gleixner
Date: Thu May 20 2021 - 03:21:28 EST


On Wed, May 19 2021 at 20:23, Stefano De Venuto wrote:
> diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
> index 05eca131eaf2..c77d4866e239 100644
> --- a/arch/x86/kvm/svm/svm.c
> +++ b/arch/x86/kvm/svm/svm.c
> @@ -3275,8 +3275,6 @@ static int handle_exit(struct kvm_vcpu *vcpu, fastpath_t exit_fastpath)
> struct kvm_run *kvm_run = vcpu->run;
> u32 exit_code = svm->vmcb->control.exit_code;
>
> - trace_kvm_exit(exit_code, vcpu, KVM_ISA_SVM);
> -
> /* SEV-ES guests must use the CR write traps to track CR registers. */
> if (!sev_es_guest(vcpu->kvm)) {
> if (!svm_is_intercept(svm, INTERCEPT_CR0_WRITE))
> @@ -3707,6 +3705,8 @@ static noinstr void svm_vcpu_enter_exit(struct kvm_vcpu *vcpu)
>
> kvm_guest_enter_irqoff();
>
> + trace_kvm_entry(vcpu);

No. This violates the noinstr rules and will make objtool complain on a
full validation run.

So this wants to be:

+ instrumentation_begin();
+ trace_kvm_entry(vcpu);
+ instrumentation_end();

kvm_guest_enter_irqoff();

and on the exit side the trace wants to be post kvm_guest_exit_irqoff().

Thanks,

tglx