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

* Re: [PATCH RFC] efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s
  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
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-05 19:08 UTC (permalink / raw)
  To: Christopher Obbard, Ard Biesheuvel, Ilias Apalodimas
  Cc: Bjorn Andersson, Johan Hovold, Marc Zyngier, linux-efi

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] efi/libstub: empty cmdline clobbers FDT bootargs and
  CONFIG_CMDLINE
- [Medium] efi/libstub: efi_quirk_cmdline ignored under
  CONFIG_CMDLINE_FORCE
- [Medium] efi/libstub: efi_add_quirk_cmdline() can exceed
  COMMAND_LINE_SIZE
- [Low] efi/libstub: unmeasured SMBIOS quirk disables PAuth via
  arm64.nopauth
--

commit 996c453c39b0a2907966f4e7ee2f19941e71289e
Author: Christopher Obbard <chris.obbard@oss.qualcomm.com>

efi/libstub: arm64: Disable pointer authentication on the ThinkPad X13s

This commit adds an efi_quirk_cmdline hook so check_platform_features() can
prepend kernel command line options in the EFI stub, and uses it on arm64
to prepend arm64.nopauth on the Lenovo ThinkPad X13s based on SMBIOS type 1
strings.

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

> 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";

[Severity: Low]
Can an untrusted host VMM in a confidential arm64 guest spoof these SMBIOS
type 1 strings to disable pointer authentication without affecting the
measured command line?

efi_convert_cmdline() measures the raw LoadOptions into
EFISTUB_EVT_LOAD_OPTIONS before efi_stub_common() runs, and
system_is_thinkpad_x13s() checks only SMBIOS strings without a hardware
identity check (such as MIDR_EL1) or measurement of efi_quirk_cmdline.

In an Arm CCA Realm booting via UEFI, a spoofed SMBIOS table would force
all six pointer authentication ID register fields to zero while leaving the
load-options measurement unchanged.

> 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

[ ... ]

> @@ -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;

[Severity: Medium]
Can prepending efi_quirk_cmdline push the command line past
COMMAND_LINE_SIZE?

efi_convert_cmdline() caps the converted command line at
COMMAND_LINE_SIZE - 1 bytes and truncates on a safe whitespace boundary
outside quotes.

Because efi_add_quirk_cmdline() adds quirk_len + 1 bytes without re-checking
that bound, early_init_dt_scan_chosen() will silently truncate the tail
mid-option or mid-quote, while idreg-override.c:get_bootargs_cmdline() still
parses the untruncated /chosen/bootargs property.

> +	memcpy(new, efi_quirk_cmdline, quirk_len);
> +	new[quirk_len] = ' ';
> +	memcpy(new + quirk_len + 1, cmdline, len + 1);
> +
> +	return new;
> +}

[Severity: High]
Does turning an empty UEFI command line into "arm64.nopauth " clobber
existing FDT /chosen/bootargs and disable the CONFIG_CMDLINE fallback?

When UEFI LoadOptions are empty, update_fdt() previously skipped writing
/chosen/bootargs, preserving DTB bootargs or allowing
early_init_dt_scan_chosen() and idreg-override.c:parse_cmdline() to fall
back to CONFIG_CMDLINE.

Because cmdline_ptr is now non-empty, update_fdt() overwrites
/chosen/bootargs, dropping all configured boot parameters (such as root= or
console=) on setups that boot with empty LoadOptions.  It also leaves a
trailing space when cmdline is empty.

[ ... ]

> @@ -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);
> +		}
> +	}

[Severity: Medium]
Should this skip adding efi_quirk_cmdline (or avoid claiming it was added)
when CONFIG_CMDLINE_FORCE is enabled?

Both early_init_dt_scan_chosen() and idreg-override.c:parse_cmdline()
ignore /chosen/bootargs under CONFIG_CMDLINE_FORCE, so arm64.nopauth has no
effect and pointer authentication remains enabled despite the info message.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-wip-obbardc-qcom-x13s-nopauth-v1-1-913a21a18286@oss.qualcomm.com?part=1

^ permalink raw reply	[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