From nobody Fri Jul 15 18:04:06 2022 X-Original-To: dev-commits-src-main@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 4Lkzkt3vMRz4TGkH; Fri, 15 Jul 2022 18:04:06 +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 4Lkzkt379vz3Rt4; Fri, 15 Jul 2022 18:04:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657908246; 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=irw/gm0Sss/xu+Gf77Gvdeg5wNXEizOzHq3zgpOrPIM=; b=kcQYgW4AFTbABjExTpsVAO2wX1l5C/yV1AXrJ8tKsAoTEK/XJYxMNSxHL3Jz6iSYYsLJ/g 6zDIXgUmK5qOZbWhGrYiQGYaxv1WAUTpyevV2+D4HJGmzOuBYcHc0jCiBafMVVT9ED0CA1 H5u23bdE4tZMMHKdOKO0EkGThStn2qM8LxkV34a+9Cj6ygiaZ/j9fGlupdkqzvy5gOjF2M ooKoDSHImAT7DPMBs7yh06NMfEiCm9ADhDcJxOyvYwF2BpaOJnKvY6FAmAe7hToSA5u0H5 Ib2wb3A2HA16D3yU582GXkkafgq4v7TuqvAbFAc2j0YLzW/VYLwQRjpNeWMRiQ== 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 4Lkzkt26XnzrZZ; Fri, 15 Jul 2022 18:04:06 +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 26FI46Bf060384; Fri, 15 Jul 2022 18:04:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26FI46lK060383; Fri, 15 Jul 2022 18:04:06 GMT (envelope-from git) Date: Fri, 15 Jul 2022 18:04:06 GMT Message-Id: <202207151804.26FI46lK060383@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: ffb0d016df7e - main - kboot: Refinements to host_kexec_load List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: ffb0d016df7e5526e4b8fd74a1f0617c81478328 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657908246; 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=irw/gm0Sss/xu+Gf77Gvdeg5wNXEizOzHq3zgpOrPIM=; b=EkxU5N7WCrVE0FRUtnYS76mcDUaZg6FEAdmKuCwc2ZovpDTLbYslSs03YoB9pOKMY7ngxZ CJ3lXb/OVYvDe+ohInY26W3zlvHFFcaoVbd3t+f3ukwDDaVDLFTdcUh2mvI+txM7mDsY44 jLLDCoEHt9DB2QlUQJl4i+CtbXHr2D9U/yTHlwmEOmDmxNSOGwLUq3TY+81sDGm3CEJ8kw tOuYuWlmMfBF0O23JAZ2I6vJr2AKndYWydMNs+B2kI6x5CmV8kDJ4BqNCZZhrS39qMPH5l PTOXDLutPL30KOudPHc+FaNPwiCFEsmlLdKdmKBiAc0V1glb+JeWfFsndd3vWA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657908246; a=rsa-sha256; cv=none; b=ci5E/JwdMQjNwMqg2Zo0t174mHNhyoPo24XSlRLj/7JIDs4QiUaP9rpQUbC56RMWjwF6wK mAigAJv6i6HTsxszrRLfaBzE19GHzOj5BYn8d8S9GZxG0BJfcaalTU3QOdbslIuEMaRYYV /XOF0ygl/9DnaUdqF2BVjE1Y6PfR2KKWriD6O2oecZySlUzh6Dd5nJYvmsTaUZaOU8XBqZ GFTegGT9oJ/Hitp/1HHN2wiQfk1/4GCIMQmJNaDJMHdeu6mmver3A2LOQqlx/hGrQrNHhF OyIl8nJLcUSzlQBK6DULOqs9i4/plUaAhH9Lu24nUnpXgd7H8eCQ3Cn2c0k09Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=ffb0d016df7e5526e4b8fd74a1f0617c81478328 commit ffb0d016df7e5526e4b8fd74a1f0617c81478328 Author: Warner Losh AuthorDate: 2022-06-28 16:40:04 +0000 Commit: Warner Losh CommitDate: 2022-07-15 18:00:51 +0000 kboot: Refinements to host_kexec_load Move kexec_segments to host_syscall.h and pre-pend host_ to it. Correct args to host_exec_load. Sponsored by: Netflix --- stand/kboot/arch/amd64/syscall_nr.h | 3 --- stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c | 2 +- stand/kboot/arch/powerpc64/syscall_nr.h | 3 --- stand/kboot/host_syscall.h | 25 ++++++++++++++++++++++++- stand/kboot/host_syscalls.c | 4 ++-- stand/kboot/main.c | 9 +-------- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 4e2f686e7ae5..4d8db2083ebc 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -18,6 +18,3 @@ #define SYS_symlinkat 266 #define SYS_uname 63 #define SYS_write 1 - -#define KEXEC_ARCH_X86_64 62 -#define KEXEC_ARCH KEXEC_ARCH_X86_64 diff --git a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c index 94f27d13f1b9..93dcb2ea9c3b 100644 --- a/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c +++ b/stand/kboot/arch/powerpc64/ppc64_elf_freebsd.c @@ -153,7 +153,7 @@ ppc64_elf_exec(struct preloaded_file *fp) panic("architecture did not provide kexec segment mapping"); archsw.arch_kexec_kseg_get(&nseg, &kseg); - error = host_kexec_load(trampolinebase, nseg, (uintptr_t)kseg, KEXEC_ARCH << 16); + error = host_kexec_load(trampolinebase, nseg, kseg, HOST_KEXEC_ARCH_PPC64); if (error != 0) panic("kexec_load returned error: %d", error); diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index 404a6f15fafc..a467259e8b60 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -19,6 +19,3 @@ #define SYS_symlinkat 295 #define SYS_uname 120 #define SYS_write 4 - -#define KEXEC_ARCH_PPC64 21 -#define KEXEC_ARCH KEXEC_ARCH_PPC64 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index 1b12ffc3d4e6..061f82b062b0 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -95,6 +95,29 @@ struct host_timeval { #define HOST_REBOOT_MAGIC2 672274793 #define HOST_REBOOT_CMD_KEXEC 0x45584543 +/* + * Values from linux/tools/include/uapi/linux/kexec.h + */ + +/* + * Values match ELF architecture types. + */ +#define HOST_KEXEC_ARCH_X86_64 (62 << 16) +#define HOST_KEXEC_ARCH_PPC64 (21 << 16) +#define HOST_KEXEC_ARCH_ARM (40 << 16) +#define HOST_KEXEC_ARCH_AARCH64 (183 << 16) +#define HOST_KEXEC_ARCH_RISCV (243 << 16) + +/* Arbitrary cap on segments */ +#define HOST_KEXEC_SEGMENT_MAX 16 + +struct host_kexec_segment { + void *buf; + int bufsz; + void *mem; + int memsz; +}; + /* * System Calls */ @@ -104,7 +127,7 @@ int host_fstat(int fd, struct host_kstat *sb); int host_getdents(int fd, void *dirp, int count); int host_getpid(void); int host_gettimeofday(struct host_timeval *a, void *b); -int host_kexec_load(uint32_t start, int nsegs, uint32_t segs, uint32_t flags); +int host_kexec_load(unsigned long entry, unsigned long nsegs, struct host_kexec_segment *segs, unsigned long flags); ssize_t host_llseek(int fd, int32_t offset_high, int32_t offset_lo, uint64_t *result, int whence); int host_mkdir(const char *, host_mode_t); void *host_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off); diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c index 1dd7aeb1963b..865107263d7b 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -44,9 +44,9 @@ host_gettimeofday(struct host_timeval *a, void *b) } int -host_kexec_load(uint32_t start, int nsegs, uint32_t segs, uint32_t flags) +host_kexec_load(unsigned long entry, unsigned long nsegs, struct host_kexec_segment *segs, unsigned long flags) { - return host_syscall(SYS_kexec_load, start, nsegs, segs, flags); + return host_syscall(SYS_kexec_load, entry, nsegs, segs, flags); } ssize_t diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 3fab25132f15..79c03398ba6d 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -340,14 +340,7 @@ time(time_t *tloc) return (rv); } -struct kexec_segment { - void *buf; - int bufsz; - void *mem; - int memsz; -}; - -struct kexec_segment loaded_segments[128]; +struct host_kexec_segment loaded_segments[128]; int nkexec_segments = 0; static ssize_t