From 700a2c08dceab4dc41859e5c1501ec3b186f6cbd Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 30 May 2025 08:14:15 -0600 Subject: [PATCH] stand/efi: Use EFI_PAGE_SIZE here, it's more appropriate No functional change: We're allocating a page from EFI, which is always 4k on amd64. So, this should always be 4k. PAGE_SIZE usually is this, but might not be in some cases. For the end of the stack pointer in the ist1, it should point the architecture's physical page past where we've allocated. EFI_PAGE_SIZE more faithfully reflects that here since PAGE_SIZE might not be exactly that in the future (if we had a larger logical page than physical page). Since the AllocPage interface is in EFI_PAGE_SIZE pages always, this seems safer. No functional change since they are both 2096 today. Sponsored by: Netflix Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D50584 --- stand/efi/loader/arch/amd64/trap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stand/efi/loader/arch/amd64/trap.c b/stand/efi/loader/arch/amd64/trap.c index 95a42a18f71..61feb76e2dc 100644 --- a/stand/efi/loader/arch/amd64/trap.c +++ b/stand/efi/loader/arch/amd64/trap.c @@ -356,7 +356,7 @@ efi_redirect_exceptions(void) PREPARE_EXCEPTION(19); PREPARE_EXCEPTION(20); - exc_rsp = exc_stack_pa + PAGE_SIZE - + exc_rsp = exc_stack_pa + EFI_PAGE_SIZE - (6 /* hw exception frame */ + 3 /* scratch regs */) * 8; /* Find free IST and use it */ @@ -376,7 +376,7 @@ efi_redirect_exceptions(void) if (intercepted[i]) loader_idt_e->gd_ist = ist; } - (&(tss->tss_ist1))[ist - 1] = exc_stack_pa + PAGE_SIZE; + (&(tss->tss_ist1))[ist - 1] = exc_stack_pa + EFI_PAGE_SIZE; /* Switch to new IDT */ rfl = intr_disable();