[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <58339ba1-d7ac-45dd-9d62-1a023d528f50@linux.intel.com>
Date: Tue, 27 May 2025 13:31:12 +0800
From: Binbin Wu <binbin.wu@...ux.intel.com>
To: Edward Adam Davis <eadavis@...com>, seanjc@...gle.com
Cc: pbonzini@...hat.com, tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH next] KVM: VMX: add noinstr for is_td_vcpu and is_td
On 5/27/2025 11:45 AM, Edward Adam Davis wrote:
> is_td() and is_td_vcpu() run in no instrumentation, so they are need
> noinstr.
>
> [1]
> vmlinux.o: error: objtool: vmx_handle_nmi+0x47:
> call to is_td_vcpu.isra.0() leaves .noinstr.text section
>
> Fixes: 7172c753c26a ("KVM: VMX: Move common fields of struct vcpu_{vmx,tdx} to a struct")
> Signed-off-by: Edward Adam Davis <eadavis@...com>
> ---
> arch/x86/kvm/vmx/common.h | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
> index 8f46a06e2c44..70e0879c58f6 100644
> --- a/arch/x86/kvm/vmx/common.h
> +++ b/arch/x86/kvm/vmx/common.h
> @@ -59,20 +59,20 @@ struct vcpu_vt {
>
> #ifdef CONFIG_KVM_INTEL_TDX
>
> -static __always_inline bool is_td(struct kvm *kvm)
> +static noinstr __always_inline bool is_td(struct kvm *kvm)
> {
> return kvm->arch.vm_type == KVM_X86_TDX_VM;
> }
>
> -static __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu)
> +static noinstr __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu)
> {
> return is_td(vcpu->kvm);
> }
noinstr is not needed when the functions are __always_inline.
>
> #else
>
> -static inline bool is_td(struct kvm *kvm) { return false; }
> -static inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
> +static noinstr bool is_td(struct kvm *kvm) { return false; }
> +static noinstr bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
Oops, overlooked the !CONFIG_KVM_INTEL_TDX case.
How about:
diff --git a/arch/x86/kvm/vmx/common.h b/arch/x86/kvm/vmx/common.h
index 8f46a06e2c44..a0c5e8781c33 100644
--- a/arch/x86/kvm/vmx/common.h
+++ b/arch/x86/kvm/vmx/common.h
@@ -71,8 +71,8 @@ static __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu)
#else
-static inline bool is_td(struct kvm *kvm) { return false; }
-static inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
+static __always_inline bool is_td(struct kvm *kvm) { return false; }
+static __always_inline bool is_td_vcpu(struct kvm_vcpu *vcpu) { return false; }
>
> #endif
>
Powered by blists - more mailing lists