From nobody Tue Jan 24 22:11:05 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 4P1h4n42Z2z3bfG3; Tue, 24 Jan 2023 22:11:05 +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 4P1h4n3Tv1z4MDZ; Tue, 24 Jan 2023 22:11:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598265; 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=C88TgtYblkXZ1S1QZX5s/LRQFXfDucWMx9IHyKSqQxg=; b=D4NAUJi+16RhsATM97S21NwTXDkbxQ2mtaBWxJyDvAqkujHPULuDPAC7/Al7q4gGCXggEE GJ5DEPuoTJsgs0cR2Uq1IOars6PdOa+Qmx/FIqdoi5UyHWfroGa8cSxEQLVi4p9nGLjJKf hxQzLjLVgvKyQMKvbmMULf+nN/z68aISWqFeUP2Isjxs6H+Bk8ZUdXxfPNGJDnZ8LRlivx MpivpdpE/CfHww9Xe2ZmXmn1ceIf5aUwIkQ+FdJYiQ+Z5hX9mu+SCqzPODEl6MtDyTlfRx fnxAXtkvfVfu60rgE9LDGioXmYuXJ33cbzwoILjF5/ByTttz42Hi31qhqtJYjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598265; 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=C88TgtYblkXZ1S1QZX5s/LRQFXfDucWMx9IHyKSqQxg=; b=iDpapKc6yUO1IWl748+K5NNRfmmhRaVgokLqLlLBNQLCz+K9izfAHnTKCgtidhT6a6XXa0 yWI/qZou+IQ5jWqEGmNUIGfpieI2zchdkTU/TmVNdyU8Aw9ibLE+FVGO58PZ3GeDtedNjr SbI7Odpr0IFLZPxQynJMZpB4Bn4dT2acnjgdEm6ERhV0iWQwYGbjeYiESog8r3TfvzHQCU qb/ALQxS1tHno1HVr0+dgY15FunLSeDqDtaqGI2ibYCH9fBXLbtcHVNGCYkNqUg737+nXY 4u19f80D1LfeiwTPtzzEjf2AKxaKm7ioW2cx0L6T/IJtDHcrnR/JPkW1+oj1ag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598265; a=rsa-sha256; cv=none; b=Bz4Goe6ENbxWRs4rG+SYJRRmWTlHbxLWUcqLUM7ojnqDeEoHv7IyN2+a6neydv2o0pcreu iZSo3ABKceLYTYbI24lxZLUNwSRYjHMhHpsWrTFOxpSdXwzim343vsh8XkWrHYOhNKx7Kl /9VflwNh1GAHUqTepM2DLbD6YN/1zomc7oWaFojXP3pmDuyC1hsoxz/Qwydx155yO4hnc9 baCmzvXwugTNiIszamrop9j/05pDwfM8I3iGvFiur5lqtbnGyq6YlMp4RJXfITSha0VfGh YvSMgHsyxj7LkTDTp/eu6bxN3WfJSOlw8bNhoaz0+99JWczBXLGTP/deLNzEjg== 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 4P1h4n2ZkDzQZ2; Tue, 24 Jan 2023 22:11:05 +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 30OMB5KT083441; Tue, 24 Jan 2023 22:11:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMB5Fn083440; Tue, 24 Jan 2023 22:11:05 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:11:05 GMT Message-Id: <202301242211.30OMB5Fn083440@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: 27a094a2e66c - stable/13 - kboot: Refinements to host_kexec_load 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 27a094a2e66c2641f18b05558cb6b28582e413dc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=27a094a2e66c2641f18b05558cb6b28582e413dc commit 27a094a2e66c2641f18b05558cb6b28582e413dc Author: Warner Losh AuthorDate: 2022-06-28 16:40:04 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:25 +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 (cherry picked from commit ffb0d016df7e5526e4b8fd74a1f0617c81478328) --- 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