The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] x86: Fix bloated SafeRET fixup alternatives
@ 2026-12-02 12:28 Ard Biesheuvel
  2026-12-02 12:28 ` [PATCH 1/2] x86/entry: Move __FIXUP_INTR_SAFERET fixup out of line Ard Biesheuvel
  2026-12-02 12:28 ` [PATCH 2/2] x86/entry: Implement the SafeRET fixup check more compactly Ard Biesheuvel
  0 siblings, 2 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2026-12-02 12:28 UTC (permalink / raw)
  To: x86
  Cc: linux-kernel, Ard Biesheuvel, Borislav Petkov, Tom Lendacky,
	Thomas Gleixner, Peter Zijlstra, Josh Poimboeuf, Pawan Gupta,
	Atish Patra

From: Ard Biesheuvel <ardb@kernel.org>

The SafeRET fixup helpers are expanded into the entry code using
alternatives patching, even though most of the code can happily be
placed out of line. The remaining logic can be expressed more
succinctly, resulting in less code bloat in the entry code itself.

This reduces the size of the alternative from 67 to 25 bytes (or 49 to
22 bytes for the NMI variety)

I spotted this while working on RIP-relative codegen for vmlinux.

Cc: Borislav Petkov <bp@alien8.de>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Thomas Gleixner <tglx@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
Cc: Atish Patra <atishp@meta.com>

Ard Biesheuvel (2):
  x86/entry: Move __FIXUP_INTR_SAFERET fixup out of line
  x86/entry: Implement the SafeRET fixup check more compactly

 arch/x86/entry/entry_64.S            |  6 +--
 arch/x86/include/asm/nospec-branch.h | 53 +++++++++++---------
 2 files changed, 33 insertions(+), 26 deletions(-)

-- 
2.56.1.915.g69d5ec7298-goog


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

end of thread, other threads:[~2026-12-02 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 12:28 [PATCH 0/2] x86: Fix bloated SafeRET fixup alternatives Ard Biesheuvel
2026-12-02 12:28 ` [PATCH 1/2] x86/entry: Move __FIXUP_INTR_SAFERET fixup out of line Ard Biesheuvel
2026-12-02 12:28 ` [PATCH 2/2] x86/entry: Implement the SafeRET fixup check more compactly Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox