From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796497531; b=DjuiMM+UqHqr3pA0M6qEtg7jZMCi0eOW8/wUidc6DMYMnyYvU6JbQHYnHbiGxOIW3e2o REU8D2SY2ZBqmJg/mmN1o94eFMV1myuxfZ4qwwWS0RiLSyFZAc4T1JqkIsEvXzOVdsLy6 t51ZfCCy5P+rSRd/XdNLr5yrNCTgK4TwYqHRQq22zpj4pqOaywjcPgrRRqXm7j1k16Byk jjQx/o3duTCEC6bJyEdncWUS7Ap0q1WJLxFfqUTrep/v57DhmTyaBHUTLT2vNs3s2194y aaFmm0xKosIn6Qd+AQgyi2looeiJK4x6SL/DpSyjt3fLGD/5G6V/l9qpiJkzx4DHD1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796497531; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=x39a2jtAZfgR18VE/LbK89OK4s7b5OTrHvlz+G7Xoaw=; b=Pfw1HPwznm1PEZGIFPW8gpvpt18MflEswDMxEauVmtJXYTJiVS+98BMypigTf6ZRIGmj okJ84J/elfGYzlr+4dkii52YbgQ7pMQfR7A6Cn/6bpfCXDheDDQpnJ+ZUAJmalYI7XVCn kZUZ4Y1u8bLzGnykzAkOc4MmY6U2JOWTEZ118Nd4n4MSn7ABx5p5PVaqzWeTTda1K4WMv C3Av/SDfHbEMbZu+ibI5KkpUrNBE8splPq018AQUKvUUhccvLpnpmrDwAgl2FVnWc3QbP t97saIT+38WEnnnTH9BZ522CtWWcKr1yq7Qf6r1Vu3hwRsOHo+Or5AKEL/Pnk1xnbPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HIVANlKM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 74BCB606A31F for ; Sat, 5 Dec 2026 19:05:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HIVANlKM Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF28E1F0092B; Sat, 5 Dec 2026 19:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796497531; bh=x39a2jtAZfgR18VE/LbK89OK4s7b5OTrHvlz+G7Xoaw=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=HIVANlKM5vV5HCoFASG1rfeA0zFVwUNapv/+tApi+XoMqixYrYQXjwzebVhsotnv9 woRdDsxymjKFvo0Yn1SccxWKsVOWx7hry1Ab1C56mD061yn++SMLbFIUhwtbzNfGy6 7OkT0Q8FZyWxRSCr0T0B9F9e4OVDuiMwzLgluGczJTbjbUezG/Ku2KeSncrsfSV8C7 zL/GD9b38li9SYq1UCPFNaSUsX2f1s/AkgHTU7neladfKHz+bBChsIhHoom1XWOClb mFJacJgQ2rrF9x4dQNCyIUAv/w63VdKH8NE3LnM3MCK8uSIOcrLYGvG0tFp/QjWcZ7 lGLER2oNtE7HQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] efi/libstub: arm64: Work around EBS failure on T14s Gen 6 Reply-To: sashiko-reviews@lists.linux.dev To: "Christopher Obbard" , "Ard Biesheuvel" , "Ilias Apalodimas" Cc: "Bjorn Andersson" , "Johan Hovold" , "Marc Zyngier" , linux-efi@vger.kernel.org In-Reply-To: <20261205-wip-obbardc-qcom-t14s-gen6-ebs-workaround-v1-1-546dd3885e38@oss.qualcomm.com> References: <20261205-wip-obbardc-qcom-t14s-gen6-ebs-workaround-v1-1-546dd3885e38@oss.qualcomm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 19:05:30 +0000 X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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@hovoldconsulti= ng.com/ [1] > diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/fir= mware/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; > } > =20 > +#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 =3D 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]) !=3D EFI_SUCCESS) > + break; > + } > + > + if (n !=3D EFI_EBS_POOL_RESERVE_BLOCKS) > + efi_warn("Failed to fully populate ExitBootServices() reserve pool\n"); > + > + for (i =3D 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 compil= er 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, voi= d *priv, > if (efi_disable_pci_dma) > efi_pci_disable_bridge_busmaster(); > =20 > + if (efi_ebs_pool_reserve) > + efi_reserve_ebs_pool(); > + > status =3D efi_get_memory_map(&map, true); > if (status !=3D 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 calli= ng exit_boot_services(), would free it on these error paths. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261205-wip-obbard= c-qcom-t14s-gen6-ebs-workaround-v1-1-546dd3885e38@oss.qualcomm.com?part=3D1