All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christopher Obbard" <chris.obbard@oss.qualcomm.com>,
	"Ard Biesheuvel" <ardb@kernel.org>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>
Cc: "Bjorn Andersson" <andersson@kernel.org>,
	"Johan Hovold" <johan@kernel.org>,
	"Marc Zyngier" <maz@kernel.org>,
	linux-efi@vger.kernel.org
Subject: Re: [PATCH] efi/libstub: arm64: Work around EBS failure on T14s Gen 6
Date: Sat, 05 Dec 2026 19:05:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-251846@kernel.org> (raw)
In-Reply-To: <20261205-wip-obbardc-qcom-t14s-gen6-ebs-workaround-v1-1-546dd3885e38@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] efi/libstub: arm64 efi_reserve_ebs_pool() compiled into
  non-arm64 stubs
- [Low] efi/libstub: leak of retained pool block in
  efi_exit_boot_services() on error
--

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

efi/libstub: arm64: Work around EBS failure on T14s Gen 6

This commit works around intermittent ExitBootServices() failures on the
Lenovo ThinkPad T14s Gen 6 by pre-allocating and partially freeing 200-byte
boot services pool blocks before fetching the memory map.

Link: https://lore.kernel.org/linux-arm-msm/Z0gn1N3IsP8r3gTA@hovoldconsulting.com/ [1]

> diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
> index e50deec996865..9eb60ee0c8391 100644
> --- a/drivers/firmware/efi/libstub/efi-stub-helper.c
> +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c

[ ... ]

> @@ -387,6 +388,46 @@ char *efi_convert_cmdline(efi_loaded_image_t *image)
>  	return cmdline_addr;
>  }
>  
> +#define EFI_EBS_POOL_RESERVE_BLOCKS	16
> +#define EFI_EBS_POOL_RESERVE_SIZE	200
> +

[ ... ]

> +static void efi_reserve_ebs_pool(void)
> +{
> +	void *blocks[EFI_EBS_POOL_RESERVE_BLOCKS];
> +	int i, n;
> +
> +	efi_warn("Working around broken ExitBootServices()\n");
> +
> +	for (n = 0; n < EFI_EBS_POOL_RESERVE_BLOCKS; n++) {
> +		if (efi_bs_call(allocate_pool, EFI_BOOT_SERVICES_DATA,
> +				EFI_EBS_POOL_RESERVE_SIZE,
> +				&blocks[n]) != EFI_SUCCESS)
> +			break;
> +	}
> +
> +	if (n != EFI_EBS_POOL_RESERVE_BLOCKS)
> +		efi_warn("Failed to fully populate ExitBootServices() reserve pool\n");
> +
> +	for (i = 0; i < n - 1; i++)
> +		efi_bs_call(free_pool, blocks[i]);
> +}

[Severity: Low]
Should efi_reserve_ebs_pool() and its call site be guarded with
IS_ENABLED(CONFIG_ARM64)?

efi_ebs_pool_reserve is only ever set in arm64.c's check_platform_features().
Because it has external linkage and LTO is disabled for libstub, the compiler
cannot eliminate efi_reserve_ebs_pool() or its warning strings on x86, ARM,
RISC-V, and LoongArch builds.

Guarding the call with IS_ENABLED(CONFIG_ARM64) or keeping the workaround in
arm64.c would avoid compiling dead code into other architectures.

[ ... ]

> @@ -411,6 +452,9 @@ efi_status_t efi_exit_boot_services(void *handle, void *priv,
>  	if (efi_disable_pci_dma)
>  		efi_pci_disable_bridge_busmaster();
>  
> +	if (efi_ebs_pool_reserve)
> +		efi_reserve_ebs_pool();
> +
>  	status = efi_get_memory_map(&map, true);
>  	if (status != EFI_SUCCESS)
>  		return status;

[Severity: Low]
Does this leak the retained pool block if efi_get_memory_map() or priv_func()
fails?

efi_reserve_ebs_pool() leaves blocks[n - 1] allocated and discards its
pointer.  If efi_get_memory_map() or priv_func() fails,
efi_exit_boot_services() returns before exit_boot_services() is called,
leaking the block and its pinned pool page to the bootloader or UEFI shell.

Returning the retained pointer from efi_reserve_ebs_pool() and storing it in
a __free(efi_pool) local variable, disarmed with no_free_ptr() before calling
exit_boot_services(), would free it on these error paths.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205-wip-obbardc-qcom-t14s-gen6-ebs-workaround-v1-1-546dd3885e38@oss.qualcomm.com?part=1

      reply	other threads:[~2026-12-05 19:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 18:49 [PATCH] efi/libstub: arm64: Work around EBS failure on T14s Gen 6 Christopher Obbard
2026-12-05 19:05 ` sashiko-bot [this message]

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=sashiko-outbox-251846@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=andersson@kernel.org \
    --cc=ardb@kernel.org \
    --cc=chris.obbard@oss.qualcomm.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=johan@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.