Re: [PATCHv12 4/9] x86/boot/compressed: Handle unaccepted memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 19, 2023 at 01:16:41PM +0300, Kirill A. Shutemov wrote:
> On Fri, May 19, 2023 at 02:14:29AM +0300, Kirill A. Shutemov wrote:
> > diff --git a/arch/x86/boot/compressed/mem.c b/arch/x86/boot/compressed/mem.c
> > index 67594fcb11d9..87372b96d613 100644
> > --- a/arch/x86/boot/compressed/mem.c
> > +++ b/arch/x86/boot/compressed/mem.c
> > @@ -1,9 +1,32 @@
> >  // SPDX-License-Identifier: GPL-2.0-only
> >  
> >  #include "error.h"
> > +#include "misc.h"
> >  
> >  void arch_accept_memory(phys_addr_t start, phys_addr_t end)
> >  {
> >  	/* Platform-specific memory-acceptance call goes here */
> >  	error("Cannot accept memory");
> >  }
> > +
> > +void init_unaccepted_memory(void)
> > +{
> > +	guid_t guid =  LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID;
> > +	struct efi_unaccepted_memory *unaccepted_table;
> > +	unsigned long cfg_table_pa;
> > +	unsigned int cfg_table_len;
> > +	int ret;
> > +
> > +	ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len);
> > +	if (ret)
> > +		error("EFI config table not found.");
> > +
> > +	unaccepted_table = (void *)efi_find_vendor_table(boot_params,
> > +							 cfg_table_pa,
> > +							 cfg_table_len,
> > +							 guid);
> > +	if (unaccepted_table->version != 1)
> > +		error("Unknown version of unaccepted memory table\n");
> > +
> > +	set_unaccepted_table(unaccepted_table);
> > +}
> 
> 0-day reported boot failure outdise TDX guest with CONFIG_INTEL_TDX_GUEST=y.

0-day folks reported one more issue: booting on non-EFI system fail.

Updated fixup:

diff --git a/arch/x86/boot/compressed/mem.c b/arch/x86/boot/compressed/mem.c
index 0108c97399a5..e7f7ef31e581 100644
--- a/arch/x86/boot/compressed/mem.c
+++ b/arch/x86/boot/compressed/mem.c
@@ -46,8 +46,13 @@ void init_unaccepted_memory(void)
 	struct efi_unaccepted_memory *unaccepted_table;
 	unsigned long cfg_table_pa;
 	unsigned int cfg_table_len;
+	enum efi_type et;
 	int ret;
 
+	et = efi_get_type(boot_params);
+	if (et == EFI_TYPE_NONE)
+		return;
+
 	ret = efi_get_conf_table(boot_params, &cfg_table_pa, &cfg_table_len);
 	if (ret)
 		error("EFI config table not found.");
@@ -56,6 +61,9 @@ void init_unaccepted_memory(void)
 							 cfg_table_pa,
 							 cfg_table_len,
 							 guid);
+	if (!unaccepted_table)
+		return;
+
 	if (unaccepted_table->version != 1)
 		error("Unknown version of unaccepted memory table\n");
 
-- 
  Kiryl Shutsemau / Kirill A. Shutemov



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux