diff mbox series

[2/8] efi/x86: Allocate the GDT pointer on the stack

Message ID 20200130200440.1796058-3-nivedita@alum.mit.edu
State New
Headers show
Series x86/efi,boot: GDT handling cleanup/fixes | expand

Commit Message

Arvind Sankar Jan. 30, 2020, 8:04 p.m. UTC
The GDT pointer isn't needed after loading it into GDTR, so there is no
need to dynamically allocate it.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/x86/boot/compressed/eboot.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index f89caae60057..a0a2fd0528af 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -713,7 +713,7 @@  struct boot_params *efi_main(efi_handle_t handle,
 			     efi_system_table_t *sys_table_arg,
 			     struct boot_params *boot_params)
 {
-	struct desc_ptr *gdt = NULL;
+	struct desc_ptr gdt;
 	struct setup_header *hdr = &boot_params->hdr;
 	efi_status_t status;
 	struct desc_struct *desc;
@@ -754,15 +754,8 @@  struct boot_params *efi_main(efi_handle_t handle,
 
 	setup_quirks(boot_params);
 
-	status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*gdt),
-			     (void **)&gdt);
-	if (status != EFI_SUCCESS) {
-		efi_printk("Failed to allocate memory for 'gdt' structure\n");
-		goto fail;
-	}
-
-	gdt->size = 0x800;
-	status = efi_low_alloc(gdt->size, 8, (unsigned long *)&gdt->address);
+	gdt.size = 0x800;
+	status = efi_low_alloc(gdt.size, 8, (unsigned long *)&gdt.address);
 	if (status != EFI_SUCCESS) {
 		efi_printk("Failed to allocate memory for 'gdt'\n");
 		goto fail;
@@ -794,8 +787,8 @@  struct boot_params *efi_main(efi_handle_t handle,
 		goto fail;
 	}
 
-	memset((char *)gdt->address, 0x0, gdt->size);
-	desc = (struct desc_struct *)gdt->address;
+	memset((char *)gdt.address, 0x0, gdt.size);
+	desc = (struct desc_struct *)gdt.address;
 
 	/* The first GDT is a dummy. */
 	desc++;
@@ -879,7 +872,7 @@  struct boot_params *efi_main(efi_handle_t handle,
 	}
 
 	raw_local_irq_disable();
-	native_load_gdt(gdt);
+	native_load_gdt(&gdt);
 
 	return boot_params;
 fail: