For the 32-bit boot GDT, we only need 4 descriptors. Allocate the
required 32 bytes using allocate_pool, rather than always allocating a
full page. The UEFI spec guarantees that allocate_pool returns an 8-byte
aligned buffer, so we don't need to do additional alignment.
The "size" stored in the GDT pointer should be one less than the true
size of the GDT.
Signed-off-by: Arvind Sankar <redacted>
---
arch/x86/boot/compressed/eboot.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index a72cfda91d7e..2447e4508aa4 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -350,14 +350,23 @@ static efi_status_t setup_gdt(struct desc_ptr *gdt)
efi_status_t status;
struct desc_struct *desc;
- gdt->size = 0x800;
- status = efi_low_alloc(gdt->size, 8, (unsigned long *)&gdt->address);
+ gdt->size = 0x20;
+ status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, gdt->size,
+ (void **)&gdt->address);
if (status != EFI_SUCCESS) {
efi_printk("Failed to allocate memory for 'gdt'\n");
return status;
}
memset((char *)gdt->address, 0x0, gdt->size);
+
+ /*
+ * The "size" stored in the GDT pointer is actually a limit value,
+ * which when added to the base address gives the address of the last
+ * byte of the GDT. Hence it should be one less than the true size.
+ */
+ gdt->size--;
+
desc = (struct desc_struct *)gdt->address;
/* The first GDT is a dummy. */--
2.24.1