Linux EFI development
 help / color / mirror / Atom feed
* [PATCH RFC] efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s
@ 2026-12-05 18:50 Christopher Obbard
  2026-12-05 19:08 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Christopher Obbard @ 2026-12-05 18:50 UTC (permalink / raw)
  To: Ard Biesheuvel, Ilias Apalodimas
  Cc: Bjorn Andersson, Johan Hovold, Marc Zyngier, linux-efi,
	linux-arm-msm, linux-kernel, Christopher Obbard

The Lenovo ThinkPad X13s (sc8280xp) firmware appears not to let the
kernel use pointer authentication, and the kernel is not known to boot
if it tries. Today every user has to know to add arm64.nopauth to the
command line, and the X13s wiki, the Ubuntu X13s GRUB settings and the
Debian installation guide all tell them to. This is still the case with
BIOS 1.67 (N3HET95W) and 1.68 (update N3HUJ26W), the latest at the time
of writing.

  ARM Pointer authentication is not working (needs firmware fixes,
  disabled via kernel commandline).

The stub can already identify the machine from SMBIOS in
check_platform_features(), but has no way to pass an option on to the
kernel. Add efi_quirk_cmdline, which check_platform_features() can set,
and put it in front of the command line before the kernel is booted.
On arm64 the command line goes into /chosen/bootargs, which the early
idreg override code reads, so this works for options such as
arm64.nopauth that have to take effect before the kernel proper
starts. The options go first, because anything after "--" is passed
to init. If the new command line cannot be allocated, warn and boot
with the original one.

Set it to arm64.nopauth on the X13s, identified by a manufacturer of
"LENOVO" and a family of "ThinkPad X13s Gen 1" in the SMBIOS type 1
record, as reported by the 21BX, 21BY and 4810 machine types. Check
the record length before reading the family field, which older SMBIOS
versions do not have. Only do it when the kernel is built with pointer
authentication support, since the option does nothing otherwise.

Tested on an X13s (21BY, BIOS N3HET95W 1.67) booted from GRUB, without
arm64.nopauth in the GRUB entry. The stub added it, the kernel booted
with pointer authentication disabled ("forced to 0" for all six
ID_AA64ISAR1_EL1 and ID_AA64ISAR2_EL1 fields), and /proc/cmdline
started with "arm64.nopauth".

Link: https://github.com/jhovold/linux/wiki/X13s#kernel-command-line
Link: https://git.launchpad.net/~ubuntu-concept/ubuntu/+source/ubuntu-x13s-settings/tree/grub.d/ubuntu-x13s-settings.cfg?h=main
Link: https://wiki.debian.org/InstallingDebianOn/Thinkpad/X13s#Boot_Debian_Installer
Signed-off-by: Christopher Obbard <chris.obbard@oss.qualcomm.com>
---
The ThinkPad X13s does not boot unless arm64.nopauth is on the kernel
command line, because its firmware does not let the kernel use pointer
authentication. The latest BIOS version 1.68 still has the problem
every distribution and user guide for the machine tells users to add
the option by hand.

This RFC makes the EFI stub add the option itself on the X13s, found
from SMBIOS. It adds a small generic hook, efi_quirk_cmdline, that
check_platform_features() can set to put options in front of the
command line and uses it on arm64.

Johan carried an unconditional "hack: arm64: disable pointer
authentication" in his sc8280xp branches until v6.7 [1] and his X13s
wiki [2] still documents the command line option. This tries to do the
same thing in a form that only affects the X13s and that could go
upstream.

The issue has been reported to Lenovo. If a firmware update fixes it,
the workaround can be limited to older firmware versions.

Questions
---------

Is the stub the right place? Pointer authentication is decided by
the early idreg override code before the kernel proper runs, so a
normal arm64 erratum is too late. The early code could match the DT
root compatible instead, but the stub is the only place where SMBIOS
is available and SMBIOS also identifies the machine when it is
booted with a DT that is not the upstream one.

Is a generic efi_quirk_cmdline acceptable, or should this be arm64
only? The options go first, so that anything the user passes
overrides them and nothing ends up after "--".

I squashed the generic hook and the arm64 user into one patch, since
there is only one user. I can split them if that is preferred.

[1] https://github.com/jhovold/linux/commit/62f35e2f0a24af48216bb4853fe6ccbf0e8b51be
[2] https://github.com/jhovold/linux/wiki/X13s#kernel-command-line
---
 drivers/firmware/efi/libstub/arm64.c    | 25 +++++++++++++++++++++
 drivers/firmware/efi/libstub/efi-stub.c | 40 +++++++++++++++++++++++++++++++++
 drivers/firmware/efi/libstub/efistub.h  |  1 +
 3 files changed, 66 insertions(+)

diff --git a/drivers/firmware/efi/libstub/arm64.c b/drivers/firmware/efi/libstub/arm64.c
index c190a3ac97001..838df75a46587 100644
--- a/drivers/firmware/efi/libstub/arm64.c
+++ b/drivers/firmware/efi/libstub/arm64.c
@@ -55,6 +55,24 @@ static bool system_needs_vamap(void)
 	return false;
 }
 
+static bool system_is_thinkpad_x13s(void)
+{
+	const struct efi_smbios_type1_record *record;
+	const u8 *str;
+
+	record = (struct efi_smbios_type1_record *)efi_get_smbios_record(1);
+	if (!record || record->header.length <
+		       offsetofend(struct efi_smbios_type1_record, family))
+		return false;
+
+	str = efi_get_smbios_string(record, manufacturer);
+	if (!str || strcmp(str, "LENOVO"))
+		return false;
+
+	str = efi_get_smbios_string(record, family);
+	return str && !strcmp(str, "ThinkPad X13s Gen 1");
+}
+
 efi_status_t check_platform_features(void)
 {
 	u64 tg;
@@ -67,6 +85,13 @@ efi_status_t check_platform_features(void)
 	if (VA_BITS_MIN >= 48 && !system_needs_vamap())
 		efi_novamap = true;
 
+	/*
+	 * The Lenovo ThinkPad X13s firmware does not let the kernel use
+	 * pointer authentication, and the kernel does not boot if it tries.
+	 */
+	if (IS_ENABLED(CONFIG_ARM64_PTR_AUTH) && system_is_thinkpad_x13s())
+		efi_quirk_cmdline = "arm64.nopauth";
+
 	/* UEFI mandates support for 4 KB granularity, no need to check */
 	if (IS_ENABLED(CONFIG_ARM64_4K_PAGES))
 		return EFI_SUCCESS;
diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c
index a824b2ba3026b..7747da185399f 100644
--- a/drivers/firmware/efi/libstub/efi-stub.c
+++ b/drivers/firmware/efi/libstub/efi-stub.c
@@ -62,6 +62,12 @@ alloc_primary_display(const struct efi_image_info *image_info)
 	return efistub_sysfb_display_info(image_info);
 }
 
+/*
+ * Options that check_platform_features() wants passed to the kernel, for
+ * machines that need them to boot.
+ */
+const char *efi_quirk_cmdline;
+
 void __weak free_primary_display(struct sysfb_display_info *dpy)
 { }
 
@@ -173,12 +179,34 @@ efi_status_t efi_handle_cmdline(efi_loaded_image_t *image, char **cmdline_ptr)
 	return EFI_SUCCESS;
 }
 
+/*
+ * Put efi_quirk_cmdline in front of the command line. It has to go first,
+ * because anything after "--" is passed to init.
+ */
+static char *efi_add_quirk_cmdline(char *cmdline)
+{
+	size_t quirk_len = strlen(efi_quirk_cmdline);
+	size_t len = strlen(cmdline);
+	char *new;
+
+	if (efi_bs_call(allocate_pool, EFI_LOADER_DATA, quirk_len + len + 2,
+			(void **)&new) != EFI_SUCCESS)
+		return NULL;
+
+	memcpy(new, efi_quirk_cmdline, quirk_len);
+	new[quirk_len] = ' ';
+	memcpy(new + quirk_len + 1, cmdline, len + 1);
+
+	return new;
+}
+
 efi_status_t efi_stub_common(efi_handle_t handle,
 			     efi_loaded_image_t *image,
 			     const struct efi_image_info *image_info,
 			     char *cmdline_ptr)
 {
 	unsigned long image_addr = efistub_kernel_base(image_info);
+	char *quirk_cmdline __free(efi_pool) = NULL;
 	struct sysfb_display_info *dpy;
 	efi_status_t status;
 
@@ -186,6 +214,18 @@ efi_status_t efi_stub_common(efi_handle_t handle,
 	if (status != EFI_SUCCESS)
 		return status;
 
+	if (efi_quirk_cmdline) {
+		quirk_cmdline = efi_add_quirk_cmdline(cmdline_ptr);
+		if (quirk_cmdline) {
+			efi_info("Adding \"%s\" to the command line\n",
+				 efi_quirk_cmdline);
+			cmdline_ptr = quirk_cmdline;
+		} else {
+			efi_warn("Failed to add \"%s\" to the command line\n",
+				 efi_quirk_cmdline);
+		}
+	}
+
 	dpy = setup_primary_display(image_info);
 
 	efi_retrieve_eventlog();
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index df3f88f4786b8..acc85ce8b94b5 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -44,6 +44,7 @@ extern bool efi_nokaslr;
 extern int efi_loglevel;
 extern int efi_mem_encrypt;
 extern bool efi_novamap;
+extern const char *efi_quirk_cmdline;
 extern const efi_system_table_t *efi_system_table;
 
 typedef union efi_dxe_services_table efi_dxe_services_table_t;

---
base-commit: 697ced232513751c6924629ef8765911e613fd1c
change-id: 20261205-wip-obbardc-qcom-x13s-nopauth-74777fd2759f

Best regards,
--  
Christopher Obbard


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

end of thread, other threads:[~2026-12-05 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 18:50 [PATCH RFC] efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s Christopher Obbard
2026-12-05 19:08 ` sashiko-bot

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