From: "H. Peter Anvin" <hpa@zytor.com>
To: "Shao, Marshall" <Marshall.Shao@Dell.com>,
"ardb@kernel.org" <ardb@kernel.org>,
"linux-efi@vger.kernel.org" <linux-efi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"bp@alien8.de" <bp@alien8.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"tglx@linutronix.de" <tglx@linutronix.de>
Cc: "Mishra, Ashish" <Ashish.Mishra4@dell.com>,
"Dion, Christopher" <Christopher.Dion@dell.com>,
"Caisse, Joe" <Joe.Caisse@dell.com>,
"Chia, Jia Yuan" <JiaYuan.Chia@dell.com>,
"Mukundan, Govind" <Govind.Mukundan@dell.com>
Subject: Re: [Patch] Do not clear BSS region in x86 stub
Date: Wed, 17 Jul 2024 23:15:21 -0700 [thread overview]
Message-ID: <A2AEC38D-56FB-4687-BDC2-54F1600F14A1@zytor.com> (raw)
In-Reply-To: <DS7PR19MB570996A580C6F5D2C9CACCE48BA32@DS7PR19MB5709.namprd19.prod.outlook.com>
On July 17, 2024 12:33:08 AM PDT, "Shao, Marshall" <Marshall.Shao@Dell.com> wrote:
>From: Marshall Shao <marshall.shao@dell.com>
>
>Clearing the BSS region may cause the UEFI firmware to malfunction
>during boot.
>
>When booting the kernel from an older firmware version that has TPM
>enabled and the MemoryOverwriteRequestControl bit set to 1, the
>firmware's boot service might encounter an exception if it attempts
>to initialize the BSS region within the x86 stub.
>
>To circumvent the firmware exception, it is advisable to enlarge the
>BOOT_STACK_SIZE and to perform the initialization of static variables
>prior to the decompression of the bzImage.
>
>Signed-off-by: Marshall Shao <marshall.shao@dell.com>
>---
> arch/x86/boot/compressed/misc.c | 8 +++-----
> arch/x86/include/asm/boot.h | 2 +-
> drivers/firmware/efi/libstub/x86-stub.c | 5 -----
> 3 files changed, 4 insertions(+), 11 deletions(-)
>
>diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
>index b70e4a21c15f..bac5a3c55c2c 100644
>--- a/arch/x86/boot/compressed/misc.c
>+++ b/arch/x86/boot/compressed/misc.c
>@@ -356,11 +356,9 @@ unsigned long decompress_kernel(unsigned char *outbuf, unsigned long virt_addr,
> void (*error)(char *x))
> {
> unsigned long entry;
>-
>- if (!free_mem_ptr) {
>- free_mem_ptr = (unsigned long)boot_heap;
>- free_mem_end_ptr = (unsigned long)boot_heap + sizeof(boot_heap);
>- }
>+ free_mem_ptr = (unsigned long)boot_heap;
>+ free_mem_end_ptr = (unsigned long)boot_heap + sizeof(boot_heap);
>+ malloc_ptr = free_mem_ptr;
>
> if (__decompress(input_data, input_len, NULL, NULL, outbuf, output_len,
> NULL, error) < 0)
>diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
>index 3e5b111e619d..312bc87ab027 100644
>--- a/arch/x86/include/asm/boot.h
>+++ b/arch/x86/include/asm/boot.h
>@@ -33,7 +33,7 @@
> #endif
>
> #ifdef CONFIG_X86_64
>-# define BOOT_STACK_SIZE 0x4000
>+# define BOOT_STACK_SIZE 0x10000
>
> /*
> * Used by decompressor's startup_32() to allocate page tables for identity
>diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c
>index 1983fd3bf392..d92d2ccc709b 100644
>--- a/drivers/firmware/efi/libstub/x86-stub.c
>+++ b/drivers/firmware/efi/libstub/x86-stub.c
>@@ -21,7 +21,6 @@
> #include "efistub.h"
> #include "x86-stub.h"
>
>-extern char _bss[], _ebss[];
>
> const efi_system_table_t *efi_system_table;
> const efi_dxe_services_table_t *efi_dxe_table;
>@@ -476,9 +475,6 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
> efi_status_t status;
> char *cmdline_ptr;
>
>- if (efi_is_native())
>- memset(_bss, 0, _ebss - _bss);
>-
> efi_system_table = sys_table_arg;
>
> /* Check if we were booted by the EFI firmware */
>@@ -1000,7 +996,6 @@ void __noreturn efi_stub_entry(efi_handle_t handle,
> void efi_handover_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg,
> struct boot_params *boot_params)
> {
>- memset(_bss, 0, _ebss - _bss);
> efi_stub_entry(handle, sys_table_arg, boot_params);
> }
>
>--
>2.34.1
>
>
>Internal Use - Confidential
>
This is strange. Is the problem that the BSS is not properly reflected in the UEFI PECOFF header?
next prev parent reply other threads:[~2024-07-18 6:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-17 7:33 Shao, Marshall
2024-07-17 14:22 ` Ard Biesheuvel
2024-07-17 15:16 ` Shao, Marshall
2024-07-17 15:26 ` Ard Biesheuvel
2024-07-20 15:40 ` Shao, Marshall
2024-07-21 13:26 ` Ard Biesheuvel
2024-07-22 11:45 ` Shao, Marshall
2024-07-22 22:14 ` Ard Biesheuvel
2024-07-23 14:21 ` Shao, Marshall
2024-07-23 14:26 ` Ard Biesheuvel
2024-07-24 1:48 ` Shao, Marshall
2024-07-18 6:15 ` H. Peter Anvin [this message]
2024-07-20 15:47 ` Shao, Marshall
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=A2AEC38D-56FB-4687-BDC2-54F1600F14A1@zytor.com \
--to=hpa@zytor.com \
--cc=Ashish.Mishra4@dell.com \
--cc=Christopher.Dion@dell.com \
--cc=Govind.Mukundan@dell.com \
--cc=JiaYuan.Chia@dell.com \
--cc=Joe.Caisse@dell.com \
--cc=Marshall.Shao@Dell.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/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
all inboxes | Powered by JetHome®