[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250605142124.GT39944@noisy.programming.kicks-ass.net>
Date: Thu, 5 Jun 2025 16:21:24 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Kai Huang <kai.huang@...el.com>
Cc: dave.hansen@...el.com, tglx@...utronix.de, bp@...en8.de,
mingo@...hat.com, hpa@...or.com, kirill.shutemov@...ux.intel.com,
rick.p.edgecombe@...el.com, x86@...nel.org, samitolvanen@...gle.com,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/virt/tdx: Add ENDBR for low level SEAMCALL assembly
functions
On Thu, Jun 05, 2025 at 04:07:39PM +0200, Peter Zijlstra wrote:
> On Wed, Jun 04, 2025 at 12:38:48PM +1200, Kai Huang wrote:
> > Build warnings about missing ENDBR around making SEAMCALLs[*] were
> > observed when using some randconfig[1] to build today's Linus's tree.
> >
> > In the C code, the low level SEAMCALL assembly functions (__seamcall(),
> > __seamcall_ret() and __seamcall_saved_ret()) are indirectly called via
> > the common sc_retry() function:
> >
> > static inline u64 sc_retry(sc_func_t func, u64 fn,
> > struct tdx_module_args *args)
> > { ... }
> >
> > #define seamcall(_fn, _args) sc_retry(__seamcall, (_fn), (_args))
> >
> > It turns out compilers may not always be smart enough to figure out how
> > to call those assembly functions directly.
>
> Did you try something like so?
This seems to cure things for me.
---
diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h
index 4a1922ec80cf..e8cd717f4f0f 100644
--- a/arch/x86/include/asm/tdx.h
+++ b/arch/x86/include/asm/tdx.h
@@ -100,8 +100,8 @@ void tdx_init(void);
typedef u64 (*sc_func_t)(u64 fn, struct tdx_module_args *args);
-static inline u64 sc_retry(sc_func_t func, u64 fn,
- struct tdx_module_args *args)
+static __always_inline u64 sc_retry(const sc_func_t func, u64 fn,
+ struct tdx_module_args *args)
{
int retry = RDRAND_RETRY_LOOPS;
u64 ret;
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 7fdb37387886..ed87eae7b414 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -69,7 +69,7 @@ static inline void seamcall_err_ret(u64 fn, u64 err,
args->r9, args->r10, args->r11);
}
-static inline int sc_retry_prerr(sc_func_t func, sc_err_func_t err_func,
+static __always_inline int sc_retry_prerr(const sc_func_t func, sc_err_func_t err_func,
u64 fn, struct tdx_module_args *args)
{
u64 sret = sc_retry(func, fn, args);
Powered by blists - more mailing lists