git: 50bc81e7001c - main - kboot/amd64: Use segs framework to find kernel location
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 17 Apr 2025 21:59:20 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=50bc81e7001c3843339e5ea75edf8e908fb8ad8d commit 50bc81e7001c3843339e5ea75edf8e908fb8ad8d Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2025-04-17 04:04:58 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2025-04-17 21:56:46 +0000 kboot/amd64: Use segs framework to find kernel location Use the segs framework to find a place to land the kernel, with the same super ugly defaults as aarch64. Sponsored by: Netflix Reviewed by: kevans, jhibbits Differential Revision: https://reviews.freebsd.org/D49866 --- stand/kboot/kboot/arch/amd64/load_addr.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/stand/kboot/kboot/arch/amd64/load_addr.c b/stand/kboot/kboot/arch/amd64/load_addr.c index ae53aa75da19..e0815cd0790f 100644 --- a/stand/kboot/kboot/arch/amd64/load_addr.c +++ b/stand/kboot/kboot/arch/amd64/load_addr.c @@ -43,23 +43,26 @@ enumerate_memory_arch(void) return (true); } +/* XXX refactor with aarch64 */ uint64_t kboot_get_phys_load_segment(void) { - static uint64_t base_seg = BAD_SEG; +#define HOLE_SIZE (64ul << 20) +#define KERN_ALIGN (2ul << 20) + static uint64_t s = 0; - if (base_seg != BAD_SEG) - return (base_seg); + if (s != 0) + return (s); - if (nr_seg > 0) - base_seg = find_ram(segs, nr_seg, 2ULL << 20, 2ULL << 20, - 64ULL << 20, 4ULL << 30); - if (base_seg == BAD_SEG) { - /* XXX Should fall back to using /proc/iomem maybe? */ - /* XXX PUNT UNTIL I NEED SOMETHING BETTER */ - base_seg = 300ULL * (1 << 20); - } - return (base_seg); + print_avail(); + s = first_avail(KERN_ALIGN, HOLE_SIZE, SYSTEM_RAM); + printf("KBOOT GET PHYS Using %#llx\n", (long long)s); + if (s != 0) + return (s); + s = 0x40000000 | 0x4200000; /* should never get here */ + /* XXX PANIC? XXX */ + printf("Falling back to the crazy address %#lx which works in qemu\n", s); + return (s); } void