public inbox for linux-coco@lists.linux.dev
 help / color / mirror / Atom feed
From: "Huang, Kai" <kai.huang@intel.com>
To: "nik.borisov@suse.com" <nik.borisov@suse.com>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"Edgecombe, Rick P" <rick.p.edgecombe@intel.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>
Subject: Re: [PATCH] x86/tdx: Make seamcall/tdcall CET-compliant
Date: Wed, 22 Oct 2025 10:14:00 +0000	[thread overview]
Message-ID: <7821da3d359f6df510bba3bc4323ede303dfde3d.camel@intel.com> (raw)
In-Reply-To: <20251022093644.320207-1-nik.borisov@suse.com>

On Wed, 2025-10-22 at 12:36 +0300, Nikolay Borisov wrote:
> _seamcall/_ret/_saved_ret can be the target of indirect calls via
> sc_retry_prerr/__seamcall_dirty_cache so on machines with CET enabled
> such call chains result in a  splat and a BUG():
> 

[...]

> 
> Fix it by adding an ENBDR in TDX_MODULE_CALL macro to cover all
> cases.
> 
> Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
> ---
> 
> The kernel this was observed is a SLE, however it contains the current upstream
> TDX patches. And looking at the usptream code the problem persists there as well.

Does your kernel contain commit 0b3bc018e86af ("x86/virt/tdx: Avoid
indirect calls to TDX assembly functions")?

Some history about this commit:

I firstly found __seamcall*() could be indirect calls in some randconfig
when building the kernel, and tried to resolve it by (effectively) adding
ENDBR:

https://lore.kernel.org/lkml/20250604003848.13154-1-kai.huang@intel.com/

Peter suggested that we could use __always_inline to keep compiler from
generating indirect calls (which resulted in the above commit):

https://lore.kernel.org/lkml/20250605145914.GW39944@noisy.programming.kicks-ass.net/

I never met __tdcall*() could be indirect calls, though.

> 
>  arch/x86/virt/vmx/tdx/tdxcall.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/x86/virt/vmx/tdx/tdxcall.S b/arch/x86/virt/vmx/tdx/tdxcall.S
> index 016a2a1ec1d6..a2137cd7a669 100644
> --- a/arch/x86/virt/vmx/tdx/tdxcall.S
> +++ b/arch/x86/virt/vmx/tdx/tdxcall.S
> @@ -43,6 +43,7 @@
>   * TDH.EXPORT.MEM.
>   */
>  .macro TDX_MODULE_CALL host:req ret=0 saved=0
> +	ENDBR
>  	FRAME_BEGIN
> 
>  	/* Move Leaf ID to RAX */
> --
> 2.51.1

  reply	other threads:[~2025-10-22 10:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  9:36 [PATCH] x86/tdx: Make seamcall/tdcall CET-compliant Nikolay Borisov
2025-10-22 10:14 ` Huang, Kai [this message]
2025-10-22 10:21   ` Nikolay Borisov
2025-10-22 10:30     ` Peter Zijlstra
2025-10-22 10:48       ` Nikolay Borisov
2025-10-22 10:51         ` Peter Zijlstra
2025-10-22 11:10           ` Nikolay Borisov
2025-10-22 11:19             ` Peter Zijlstra

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=7821da3d359f6df510bba3bc4323ede303dfde3d.camel@intel.com \
    --to=kai.huang@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-coco@lists.linux.dev \
    --cc=nik.borisov@suse.com \
    --cc=rick.p.edgecombe@intel.com \
    --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