From: Dave Hansen <dave.hansen@intel.com>
To: Kai Huang <kai.huang@intel.com>,
peterz@infradead.org, tglx@linutronix.de, bp@alien8.de,
mingo@redhat.com, hpa@zytor.com, kirill.shutemov@linux.intel.com
Cc: rick.p.edgecombe@intel.com, x86@kernel.org,
samitolvanen@google.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] x86/virt/tdx: Enforce no indirect calls of TDX assembly
Date: Fri, 6 Jun 2025 08:58:18 -0700 [thread overview]
Message-ID: <ade8a82a-23c6-4a7e-968c-e4b0d4bcbc46@intel.com> (raw)
In-Reply-To: <20250606130737.30713-1-kai.huang@intel.com>
It doesn't really "enforce" anything. But, oh well, I'll just fix it up
when I apply it early next week. Here's what I'll probably apply:
x86/virt/tdx: Avoid indirect calls to TDX assembly functions
Two 'static inline' TDX helper functions (sc_retry() and
sc_retry_prerr()) take function pointer arguments which refer to
assembly functions. Normally, the compiler inlines the TDX helper,
realizes that the function pointer targets are completely static -- thus
can be resolved at compile time -- and generates direct call instructions.
But, other times (like when CONFIG_CC_OPTIMIZE_FOR_SIZE=y), the compiler
declines to inline the helpers and will instead generate indirect call
instructions.
Indirect calls to assembly functions require special annotation (for
various Control Flow Integrity mechanisms). But TDX assembly functions
lack the special annotations and can only be called directly.
Annotate both the helpers as '__always_inline' to prod the compiler into
maintaining the direct calls. There is no guarantee here, but Peter has
volunteered to report the compiler bug if this assumption ever breaks[1].
...
> This was found through randconfig testing, presumably setting
> CONFIG_CC_OPTIMIZE_FOR_SIZE=1 when objtool spewed a bunch of these:
>
> vmlinux.o: warning: objtool: tdh_mem_range_block+0x7e: relocation to
> !ENDBR: __seamcall_ret+0x0
>
> Link: https://lore.kernel.org/lkml/20250605145914.GW39944@noisy.programming.kicks-ass.net/ [1]
next prev parent reply other threads:[~2025-06-06 15:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-06 13:07 [PATCH v3] x86/virt/tdx: Enforce no indirect calls of TDX assembly Kai Huang
2025-06-06 15:58 ` Dave Hansen [this message]
2025-06-09 10:36 ` Huang, Kai
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=ade8a82a-23c6-4a7e-968c-e4b0d4bcbc46@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=kai.huang@intel.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rick.p.edgecombe@intel.com \
--cc=samitolvanen@google.com \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.