linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/tdx: Always inline tdx_tdvpr_pa()
@ 2025-05-27 22:04 Rick Edgecombe
  2025-05-28  3:49 ` Xiaoyao Li
  0 siblings, 1 reply; 2+ messages in thread
From: Rick Edgecombe @ 2025-05-27 22:04 UTC (permalink / raw)
  To: pbonzini
  Cc: kvm, linux-kernel, lkp, xiaoyao.li, kai.huang, seanjc, x86,
	dave.hansen, Rick Edgecombe

In some cases tdx_tdvpr_pa() is not fully inlined into tdh_vp_enter(),
which causes the following warning:

  vmlinux.o: warning: objtool: tdh_vp_enter+0x8: call to tdx_tdvpr_pa() leaves .noinstr.text section

tdh_vp_enter() is marked noinstr and so can't accommodate the function
being outlined. Previously this didn't cause issues because the compiler
inlined the function. However, newer Clang compilers are deciding to
outline it.

So mark the function __always_inline to force it to be inlined. This
would leave the similar function tdx_tdr_pa() looking a bit asymmetric
and odd, as it is marked inline but actually doesn't need to be inlined.
So somewhat opportunistically remove the inline from tdx_tdr_pa() so that
it is clear that it does not need to be inlined, unlike tdx_tdvpr_pa().

tdx_tdvpr_pa() uses page_to_phys() which can make further calls to
outlines functions, but not on x86 following commit cba5d9b3e99d
("x86/mm/64: Make SPARSEMEM_VMEMMAP the only memory model").

Fixes: 69e23faf82b4 ("x86/virt/tdx: Add SEAMCALL wrapper to enter/exit TDX guest")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202505240530.5KktQ5mX-lkp@intel.com/
Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: Kai Huang <kai.huang@intel.com>
---
Previous discussion here:
https://lore.kernel.org/kvm/20250526204523.562665-1-pbonzini@redhat.com/

FWIW, I'm ok with the flatten version of the fix too, but posting this
just to speed things along in case.

And note, for full correctness, this and the flatten fix will depend on
the queued tip commit:
https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=cba5d9b3e99d6268d7909a65c2bd78f4d195aead

---
 arch/x86/virt/vmx/tdx/tdx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index f5e2a937c1e7..626cc2f37dec 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -1496,12 +1496,12 @@ void tdx_guest_keyid_free(unsigned int keyid)
 }
 EXPORT_SYMBOL_GPL(tdx_guest_keyid_free);
 
-static inline u64 tdx_tdr_pa(struct tdx_td *td)
+static u64 tdx_tdr_pa(struct tdx_td *td)
 {
 	return page_to_phys(td->tdr_page);
 }
 
-static inline u64 tdx_tdvpr_pa(struct tdx_vp *td)
+static __always_inline u64 tdx_tdvpr_pa(struct tdx_vp *td)
 {
 	return page_to_phys(td->tdvpr_page);
 }
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/tdx: Always inline tdx_tdvpr_pa()
  2025-05-27 22:04 [PATCH] x86/tdx: Always inline tdx_tdvpr_pa() Rick Edgecombe
@ 2025-05-28  3:49 ` Xiaoyao Li
  0 siblings, 0 replies; 2+ messages in thread
From: Xiaoyao Li @ 2025-05-28  3:49 UTC (permalink / raw)
  To: Rick Edgecombe, pbonzini
  Cc: kvm, linux-kernel, lkp, kai.huang, seanjc, x86, dave.hansen

On 5/28/2025 6:04 AM, Rick Edgecombe wrote:
> In some cases tdx_tdvpr_pa() is not fully inlined into tdh_vp_enter(),
> which causes the following warning:
> 
>    vmlinux.o: warning: objtool: tdh_vp_enter+0x8: call to tdx_tdvpr_pa() leaves .noinstr.text section
> 
> tdh_vp_enter() is marked noinstr and so can't accommodate the function
> being outlined. Previously this didn't cause issues because the compiler
> inlined the function. However, newer Clang compilers are deciding to
> outline it.
> 
> So mark the function __always_inline to force it to be inlined. This
> would leave the similar function tdx_tdr_pa() looking a bit asymmetric
> and odd, as it is marked inline but actually doesn't need to be inlined.
> So somewhat opportunistically remove the inline from tdx_tdr_pa() so that
> it is clear that it does not need to be inlined, unlike tdx_tdvpr_pa().
> 
> tdx_tdvpr_pa() uses page_to_phys() which can make further calls to
> outlines functions, but not on x86 following commit cba5d9b3e99d
> ("x86/mm/64: Make SPARSEMEM_VMEMMAP the only memory model").
> 
> Fixes: 69e23faf82b4 ("x86/virt/tdx: Add SEAMCALL wrapper to enter/exit TDX guest")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202505240530.5KktQ5mX-lkp@intel.com/
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
> Reviewed-by: Kai Huang <kai.huang@intel.com>

Reviewed-by: Xiaoyao Li <Xiaoyao.li@intel.com>

> ---
> Previous discussion here:
> https://lore.kernel.org/kvm/20250526204523.562665-1-pbonzini@redhat.com/
> 
> FWIW, I'm ok with the flatten version of the fix too, but posting this
> just to speed things along in case.
> 
> And note, for full correctness, this and the flatten fix will depend on
> the queued tip commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=cba5d9b3e99d6268d7909a65c2bd78f4d195aead
> 
> ---
>   arch/x86/virt/vmx/tdx/tdx.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
> index f5e2a937c1e7..626cc2f37dec 100644
> --- a/arch/x86/virt/vmx/tdx/tdx.c
> +++ b/arch/x86/virt/vmx/tdx/tdx.c
> @@ -1496,12 +1496,12 @@ void tdx_guest_keyid_free(unsigned int keyid)
>   }
>   EXPORT_SYMBOL_GPL(tdx_guest_keyid_free);
>   
> -static inline u64 tdx_tdr_pa(struct tdx_td *td)
> +static u64 tdx_tdr_pa(struct tdx_td *td)
>   {
>   	return page_to_phys(td->tdr_page);
>   }
>   
> -static inline u64 tdx_tdvpr_pa(struct tdx_vp *td)
> +static __always_inline u64 tdx_tdvpr_pa(struct tdx_vp *td)
>   {
>   	return page_to_phys(td->tdvpr_page);
>   }


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-28  3:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27 22:04 [PATCH] x86/tdx: Always inline tdx_tdvpr_pa() Rick Edgecombe
2025-05-28  3:49 ` Xiaoyao Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).