git: 849f8fea5ca9 - main - kboot: Use roundup2 instead of expanding the (old) definiution of it inline

From: Warner Losh <imp_at_FreeBSD.org>
Date: Wed, 09 Apr 2025 21:17:55 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=849f8fea5ca96d8bff36b8a30d009ba4d0fcbab2

commit 849f8fea5ca96d8bff36b8a30d009ba4d0fcbab2
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-04-09 21:16:56 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-04-09 21:16:56 +0000

    kboot: Use roundup2 instead of expanding the (old) definiution of it inline
    
    The boot loader pads efi_map_header to start the array of
    efi_memory_descriptor entries on the 16-byte-aligned boundary after the
    header. Since the header isn't naturally 16-byte aligned, we need to do
    this.
    
    We should have used the actual UEFI EFI_MEMORY_ATTRIBUTES_TABLE which
    used uint32_t's to pass all this data to the kernel (they never needed
    to be 64-bit quantities or size_t's even) since these entries and the
    total size of the table is small. However, this ship long since sailed
    since we've used these structures for a decade and there's little to be
    gained by changing them. The table header we pass to the kernel from the
    loader has similar names, but the seamntics of the fields are different.
    
    Sponsored by:           Netflix
---
 stand/kboot/kboot/arch/aarch64/load_addr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/stand/kboot/kboot/arch/aarch64/load_addr.c b/stand/kboot/kboot/arch/aarch64/load_addr.c
index 8ea3516a5cff..9d6f23a9d344 100644
--- a/stand/kboot/kboot/arch/aarch64/load_addr.c
+++ b/stand/kboot/kboot/arch/aarch64/load_addr.c
@@ -36,7 +36,7 @@ foreach_efi_map_entry(struct efi_map_header *efihdr, efi_map_entry_cb cb, void *
 	 * Memory map data provided by UEFI via the GetMemoryMap
 	 * Boot Services API.
 	 */
-	efisz = (sizeof(struct efi_map_header) + 0xf) & ~0xf;
+	efisz = roundup2(sizeof(struct efi_map_header), 16);
 	map = (struct efi_md *)((uint8_t *)efihdr + efisz);
 
 	if (efihdr->descriptor_size == 0)
@@ -169,7 +169,7 @@ do_memory_from_fdt(int fd)
 	 * so early boot can copy the memory map into this space and have the
 	 * rest of the code cope.
 	 */
-	efisz = (sizeof(*efihdr) + 0xf) & ~0xf;
+	efisz = roundup2(sizeof(*efihdr), 16);
 	buf = malloc(sz + efisz);
 	if (buf == NULL)
 		return false;