From nobody Fri Feb 03 15:50:51 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P7g9S4BG6z3kRxP; Fri, 3 Feb 2023 15:50:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P7g9R5yzZz3JFr; Fri, 3 Feb 2023 15:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675439451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YYGd6SgVvpHuslLQ6zL+gWOv83Tn7P3dbhyLs09KE7A=; b=HLu2chFp8HTiVBqAR/tbZ+OCUq1zGjRcTVXWLZjD3/COC724EiIZZ5hGumDeu0UYOohq4U JrXpw6+EkYZczhS+JZXh0hFSA1oKJO6FPw7HCz/RtEBZFcVj35ua/ehDPZBzRlCbp2uy3o R6++2dghmNVgKLZn7j0AG3rLHhDlxKawV3ZzKDz/5bMlCtpTFeKYkEmNMKamho/J/BMYfL Tz+6O85kGeZlyFCQtMLLlddMv91DRthjIb0cwm9K+HzldekWFAhTkwEI3X8T+mpQGETk/9 9UMy5dGz9H8hZ0b4seA4sjH+9ev5oXxnoLiA68JhFaztfDKEmf3RhMjLnPfA4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1675439451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=YYGd6SgVvpHuslLQ6zL+gWOv83Tn7P3dbhyLs09KE7A=; b=taU7LiGuQcTgID5vzb3/IgyVvLG0wd2FtX/DMrr4nznWLE64B8xaUExgQq3kVZjzy2Ap06 NnpL4a3rpzoEKSfPSPaM5owRvL1eZhwA+cx7OWy4m/C7h764XkNlElU6HLsNOfnBb4oPh8 5n0/7Djn5yoJeAysVQrpNSnLYrfuZyvyta2gvIxMKp7otowBMyjV9cZsvahKlYbbL1UG6U QIHHfUFxOUCPWKpiKUDKe4So+ZW5XQ7oSpsq18Kx60XdK76j+4jm6HuLK4oJcLrNWvndV7 ZjKF/V2kXdqs2Dcf4R9frjefIUo8n0f+UvUoP3MuU0+fG/vOX/TsEajUAk74sw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1675439451; a=rsa-sha256; cv=none; b=OMYKxovvPSU5x6/SaG6AAb7Gnjrze4fhckfKtaXyAWS8VOSfu35YSxgG+wfe10DiO3RW2s JmFBLsyNqoLNZTXpLo7dPtPgA7mhdzbKh8j96FofFiFU+HB+4krt7RpUVfbMGlbbQGWlGH a/qkZK9Evv+CcdcgPQJnORz7eE6TzYLaZQvpxLdrXzXETtpB6G1af/NmX57fYIjU1q8aoX PMEs+ijDfggqNwFnWD2qXIiN+UetvzngYeCbY2FgXawqya5uzTFdM4ABoCw0YYpRrYX1KI +pTLFKquT1G24yi9l9RqSEo08M3hqWATxmIBlQWlbCkb2P9R7qAc2VBA9LhN+Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P7g9R543rzgTB; Fri, 3 Feb 2023 15:50:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 313FopZT024082; Fri, 3 Feb 2023 15:50:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 313FopfI024081; Fri, 3 Feb 2023 15:50:51 GMT (envelope-from git) Date: Fri, 3 Feb 2023 15:50:51 GMT Message-Id: <202302031550.313FopfI024081@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 84eb9b2306fd - main - kboot: MI fixups to enable aarch64 booting List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 84eb9b2306fd4b8cf4d9328ff661f7684c596642 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=84eb9b2306fd4b8cf4d9328ff661f7684c596642 commit 84eb9b2306fd4b8cf4d9328ff661f7684c596642 Author: Warner Losh AuthorDate: 2023-02-03 15:40:22 +0000 Commit: Warner Losh CommitDate: 2023-02-03 15:41:40 +0000 kboot: MI fixups to enable aarch64 booting A number of bug fixes to loading kernels and modules on aarch64 and amd64. Fix offset calcuations. Add a number of debugs, commented out for now (will GC them in the future) With this, and the MD aarch64 commands, we can linux boot in qemu and on real hardware. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D38261 --- stand/kboot/main.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 7f548fe15b08..6631cb38ae22 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include #include "host_syscall.h" #include "kboot.h" +#include "stand.h" struct arch_switch archsw; extern void *_end; @@ -49,6 +50,11 @@ static void kboot_zfs_probe(void); extern int command_fdt_internal(int argc, char *argv[]); +#define PA_INVAL (vm_offset_t)-1 +static vm_offset_t pa_start = PA_INVAL; +static vm_offset_t padding; +static vm_offset_t offset; + static uint64_t commit_limit; static uint64_t committed_as; static uint64_t mem_avail; @@ -95,8 +101,8 @@ memory_limits(void) int kboot_getdev(void **vdev, const char *devspec, const char **path) { - int rv; struct devdesc **dev = (struct devdesc **)vdev; + int rv; /* * If it looks like this is just a path and no device, go with the @@ -311,11 +317,13 @@ time(time_t *tloc) struct host_kexec_segment loaded_segments[HOST_KEXEC_SEGMENT_MAX]; int nkexec_segments = 0; +#define SEGALIGN (1ul<<20) + static ssize_t get_phys_buffer(vm_offset_t dest, const size_t len, void **buf) { int i = 0; - const size_t segsize = 8*1024*1024; + const size_t segsize = 64*1024*1024; if (nkexec_segments == HOST_KEXEC_SEGMENT_MAX) panic("Tried to load too many kexec segments"); @@ -328,7 +336,7 @@ get_phys_buffer(vm_offset_t dest, const size_t len, void **buf) loaded_segments[nkexec_segments].buf = host_getmem(segsize); loaded_segments[nkexec_segments].bufsz = segsize; - loaded_segments[nkexec_segments].mem = (void *)rounddown2(dest,segsize); + loaded_segments[nkexec_segments].mem = (void *)rounddown2(dest,SEGALIGN); loaded_segments[nkexec_segments].memsz = segsize; i = nkexec_segments; @@ -347,9 +355,17 @@ kboot_copyin(const void *src, vm_offset_t dest, const size_t len) ssize_t segsize, remainder; void *destbuf; + if (pa_start == PA_INVAL) { + pa_start = kboot_get_phys_load_segment(); +// padding = 2 << 20; /* XXX amd64: revisit this when we make it work */ + padding = 0; + offset = dest; + get_phys_buffer(pa_start, len, &destbuf); + } + remainder = len; do { - segsize = get_phys_buffer(dest, remainder, &destbuf); + segsize = get_phys_buffer(dest + pa_start + padding - offset, remainder, &destbuf); bcopy(src, destbuf, segsize); remainder -= segsize; src += segsize; @@ -367,7 +383,7 @@ kboot_copyout(vm_offset_t src, void *dest, const size_t len) remainder = len; do { - segsize = get_phys_buffer(src, remainder, &srcbuf); + segsize = get_phys_buffer(src + pa_start + padding - offset, remainder, &srcbuf); bcopy(srcbuf, dest, segsize); remainder -= segsize; src += segsize; @@ -420,17 +436,18 @@ kboot_autoload(void) static void kboot_kseg_get(int *nseg, void **ptr) { -#if 0 int a; + printf("kseg_get: %d segments\n", nkexec_segments); + printf("VA SZ PA MEMSZ\n"); + printf("---------------- -------- ---------------- -----\n"); for (a = 0; a < nkexec_segments; a++) { - printf("kseg_get: %jx %jx %jx %jx\n", + printf("%016jx %08jx %016jx %08jx\n", (uintmax_t)loaded_segments[a].buf, (uintmax_t)loaded_segments[a].bufsz, (uintmax_t)loaded_segments[a].mem, (uintmax_t)loaded_segments[a].memsz); } -#endif *nseg = nkexec_segments; *ptr = &loaded_segments[0];