Module Name: src
Committed By: skrll
Date: Tue May 11 07:15:10 UTC 2021
Modified Files:
src/sys/stand/efiboot: exec.c
Log Message:
Consistently have ALIGN sizes as the power of two size, i.e. change
FDT_ALIGN, and use the same math(s) to round.
In the process fix the load_offset for the kernel to use the EFIBOOT_ALIGN
aligned address if that's what we get from AllocatePages.
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/exec.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.19 src/sys/stand/efiboot/exec.c:1.20
--- src/sys/stand/efiboot/exec.c:1.19 Sat Oct 10 19:17:39 2020
+++ src/sys/stand/efiboot/exec.c Tue May 11 07:15:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.19 2020/10/10 19:17:39 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.20 2021/05/11 07:15:10 skrll Exp $ */
/*-
* Copyright (c) 2019 Jason R. Thorpe
@@ -42,7 +42,7 @@ extern char twiddle_toggle;
u_long load_offset = 0;
#define FDT_SPACE (4 * 1024 * 1024)
-#define FDT_ALIGN ((2 * 1024 * 1024) - 1)
+#define FDT_ALIGN (2 * 1024 * 1024)
static EFI_PHYSICAL_ADDRESS initrd_addr, dtb_addr, rndseed_addr, efirng_addr;
static u_long initrd_size = 0, dtb_size = 0, rndseed_size = 0, efirng_size = 0;
@@ -260,7 +260,7 @@ exec_netbsd(const char *fname, const cha
return EIO;
}
close(fd);
- marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & (-sizeof(int));
+ marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & -sizeof(int);
alloc_size = marks[MARK_END] - marks[MARK_START] + FDT_SPACE + EFIBOOT_ALIGN;
#ifdef EFIBOOT_ALLOCATE_MAX_ADDRESS
@@ -279,7 +279,7 @@ exec_netbsd(const char *fname, const cha
}
memset(marks, 0, sizeof(marks));
- load_offset = (addr + EFIBOOT_ALIGN) & ~(EFIBOOT_ALIGN - 1);
+ load_offset = (addr + EFIBOOT_ALIGN - 1) & -EFIBOOT_ALIGN;
fd = loadfile(fname, marks, LOAD_KERNEL);
if (fd < 0) {
printf("boot: %s: %s\n", fname, strerror(errno));
@@ -308,7 +308,7 @@ exec_netbsd(const char *fname, const cha
load_file(get_rndseed_path(), 0, false,
&rndseed_addr, &rndseed_size);
- efi_fdt_init((marks[MARK_END] + FDT_ALIGN) & ~FDT_ALIGN, FDT_ALIGN + 1);
+ efi_fdt_init((marks[MARK_END] + FDT_ALIGN - 1) & -FDT_ALIGN, FDT_ALIGN);
load_modules(fname);
load_fdt_overlays();
efi_fdt_initrd(initrd_addr, initrd_size);