summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-07-31 15:49:31 +0200
committersalmonik <salmonik@tuta.io>2026-07-31 15:49:31 +0200
commitee1c85bfcba17a120bbc95fb2399485295affb76 (patch)
tree85cae4ab45652f6427046a5eb8173819eef0d5a7
parentfeat(rsboot): initial commit — UEFI bootloader extracted from RNG (diff)
downloadrsboot-ee1c85bfcba17a120bbc95fb2399485295affb76.tar.gz
rsboot-ee1c85bfcba17a120bbc95fb2399485295affb76.zip
fix(memory): allocate file buffers as LoaderData (2), not RuntimeData (6)
The bzImage and initramfs read buffers were allocated with EfiRuntimeServicesData (6), marking them as runtime-services memory that the OS must preserve forever. As OS-loader scratch they should be EfiLoaderData (2): reclaimable once the OS takes control.
-rw-r--r--main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/main.c b/main.c
index d28a337..92e4a99 100644
--- a/main.c
+++ b/main.c
@@ -31,7 +31,10 @@ static u64 allocate_pages(efi_boot_services *b, u64 mt, u64 np, u64 *a) {
31} 31}
32static u8 *rf(efi_boot_services *b, efi_file_protocol *f, u64 *sz, u64 mx) { 32static u8 *rf(efi_boot_services *b, efi_file_protocol *f, u64 *sz, u64 mx) {
33 u64 np = (mx + 4095) / 4096, a; 33 u64 np = (mx + 4095) / 4096, a;
34 if (allocate_pages(b, 6, np, &a)) return 0; 34 /* LoaderData (2): scratch buffers for the OS loader, reclaimable by the
35 * OS once it takes control. Type 6 (RuntimeData) would mark them as
36 * runtime-services memory that must survive forever. */
37 if (allocate_pages(b, 2, np, &a)) return 0;
35 u8 *d = (u8 *)a; 38 u8 *d = (u8 *)a;
36 u64 r = mx; 39 u64 r = mx;
37 if (f->read(f, &r, d) && r != mx) return 0; 40 if (f->read(f, &r, d) && r != mx) return 0;