tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: [PATCH 2/3] bootloader: Handle 64-bit bootinfo
On Sun, Mar 02, 2025 at 03:18:08PM +0300, Vladimir Serbinenko wrote:
> On my darp10-b the bootloader is loaded around 32GiB mark and so all
> BI_ADD with a static address end up way over 4GiB and are truncated
> when passed to the kernel. Instead keep the whole pointer until we move
> all bootinfos to the heap
> ---
> sys/arch/i386/stand/lib/bootinfo.h | 9 +++++++--
> sys/arch/i386/stand/lib/exec.c | 8 +++++++-
> 2 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/sys/arch/i386/stand/lib/bootinfo.h b/sys/arch/i386/stand/lib/bootinfo.h
> index 8def5f4d273..3173c06e6a1 100644
> --- a/sys/arch/i386/stand/lib/bootinfo.h
> +++ b/sys/arch/i386/stand/lib/bootinfo.h
> @@ -28,17 +28,22 @@
>
> #include <machine/bootinfo.h>
>
> -struct bootinfo {
> +struct bootinfo32 {
> uint32_t nentries;
> uint32_t entry[1];
> };
>
> +struct bootinfo {
> + uint32_t nentries;
> + uintptr_t entry[1];
> +};
> +
> extern struct bootinfo *bootinfo;
>
> #define BTINFO_MAX 64
>
> #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
> - + ((max) - 1) * sizeof(uint32_t))) \
> + + ((max) - 1) * sizeof(uintptr_t))) \
> ->nentries = 0
>
> #define BI_FREE() dealloc(bootinfo, 0)
> diff --git a/sys/arch/i386/stand/lib/exec.c b/sys/arch/i386/stand/lib/exec.c
> index adddaab6aac..9b0e1e54425 100644
> --- a/sys/arch/i386/stand/lib/exec.c
> +++ b/sys/arch/i386/stand/lib/exec.c
> @@ -564,13 +564,19 @@ exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy,
>
> entry = marks[MARK_ENTRY];
> #ifdef EFIBOOT
> + struct bootinfo32 *bootinfo32 = alloc(sizeof(struct bootinfo32)
> + + (bootinfo->nentries - 1)
> + * sizeof(uint32_t));
> + bootinfo32->nentries = bootinfo->nentries;
> +
> /* Copy bootinfo to safe arena. */
> for (i = 0; i < bootinfo->nentries; i++) {
> struct btinfo_common *bi = (void *)(u_long)bootinfo->entry[i];
> char *p = alloc(bi->len);
> memcpy(p, bi, bi->len);
> - bootinfo->entry[i] = vtophys(p);
> + bootinfo32->entry[i] = vtophys(p);
> }
> + boot_argv[2] = vtophys(bootinfo32);
>
> efi_kernel_start = marks[MARK_START];
> efi_kernel_size = image_end - (efi_loadaddr + efi_kernel_start);
> --
> 2.48.1
>
This needs to consider the boot -> kernel ABI carefully; currently it
looks like this breaks non-EFI boot with argv[2].
Home |
Main Index |
Thread Index |
Old Index