From 2c41f1a77ab1de7e07bbd9e66e08f117156d38c4 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Sat, 21 Feb 2026 23:23:23 +0000 Subject: [PATCH] lib: launch: move page size from a global variable to elf_image --- lib/liblaunch/elf.c | 15 +++------------ lib/liblaunch/elf.h | 1 + 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/liblaunch/elf.c b/lib/liblaunch/elf.c index 4cd90c4..f8c0ff3 100644 --- a/lib/liblaunch/elf.c +++ b/lib/liblaunch/elf.c @@ -21,8 +21,8 @@ /* TODO in case we ever support ELF32 images */ #define elf_class_bits(x) (64) -#define PAGE_SIZE (page_size()) -#define PAGE_MASK (page_size() - 1) +#define PAGE_SIZE (image->e_page_size) +#define PAGE_MASK (image->e_page_size - 1) #define PAGE_OFFSET(v) ((v) & (PAGE_SIZE - 1)) #define PAGE_ALIGN_DOWN(v) (v) &= ~(PAGE_SIZE - 1) #define PAGE_ALIGN_UP(v) \ @@ -35,16 +35,6 @@ #undef DEBUG_LOG -static size_t page_size(void) -{ - static size_t pagesz = 0; - if (pagesz == 0) { - kern_config_get(KERN_CFG_PAGE_SIZE, &pagesz, sizeof pagesz); - } - - return pagesz; -} - static enum launch_status elf_validate_ehdr(elf_ehdr_t *hdr) { if (hdr->e_ident[EI_MAG0] != ELF_MAG0) { @@ -488,6 +478,7 @@ void elf_image_init(struct elf_image *out) { memset(out, 0x0, sizeof(*out)); + kern_config_get(KERN_CFG_PAGE_SIZE, &out->e_page_size, sizeof out->e_page_size); out->e_image = KERN_HANDLE_INVALID; out->e_data = KERN_HANDLE_INVALID; out->e_local_space = KERN_HANDLE_INVALID; diff --git a/lib/liblaunch/elf.h b/lib/liblaunch/elf.h index 5f961a0..8432c8a 100644 --- a/lib/liblaunch/elf.h +++ b/lib/liblaunch/elf.h @@ -289,6 +289,7 @@ struct bootdata; struct bootfs_file; struct elf_image { + size_t e_page_size; kern_handle_t e_image, e_data; kern_handle_t e_local_space, e_remote_space; kern_handle_t e_local_exec, e_remote_exec;