The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb+git@google.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel <ardb@kernel.org>,
	 Borislav Petkov <bp@alien8.de>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	 Thomas Gleixner <tglx@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Josh Poimboeuf <jpoimboe@kernel.org>,
	Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
	 Atish Patra <atishp@meta.com>
Subject: [PATCH 0/2] x86: Fix bloated SafeRET fixup alternatives
Date: Wed,  2 Dec 2026 13:28:00 +0100	[thread overview]
Message-ID: <20261202122759.1436053-4-ardb+git@google.com> (raw)

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


             reply	other threads:[~2026-12-02 12:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:28 Ard Biesheuvel [this message]
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

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=20261202122759.1436053-4-ardb+git@google.com \
    --to=ardb+git@google.com \
    --cc=ardb@kernel.org \
    --cc=atishp@meta.com \
    --cc=bp@alien8.de \
    --cc=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pawan.kumar.gupta@linux.intel.com \
    --cc=peterz@infradead.org \
    --cc=tglx@kernel.org \
    --cc=thomas.lendacky@amd.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