From nobody Tue Jan 24 22:11:37 2023 X-Original-To: dev-commits-src-branches@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 4P1h5Q1nnNz3bfQh; Tue, 24 Jan 2023 22:11:38 +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 4P1h5Q0ts6z4P56; Tue, 24 Jan 2023 22:11:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598298; 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=tw1FbIrabUXuvSa4SNn7wCUsLd8SVddSHp0Uf8U18mg=; b=PQK/Rf4Utx0kbQp4Srso6x+q9WGoBxMR3if7NqPSSZ07EvBvKuUzB/H0junzkjk2jM8lD+ 3/nSGIS4Ote2gE5rBq6NlfnfUdkRAbKxHqb369GtTGgnMui82xkA+YnSdhifHDxxHRg13L D7vvdF53IfyaSUzUpS1rA3ngLrB1sAY30tKoFoxOuqeBRWaS0aBueheQS2RBKXHx4Vb59+ 94HPGWsw/79WI4lqaOmwScFIr6kGz4Xg/td4mCMPLg17QZC7nRK8rCUbou4tOn/amOc7dw 1wD2CT1rJO3lG5HlVuhko6Ho4aOkEWLEGe7GKCSAAndA59hGanDW0FFVE6nxug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598298; 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=tw1FbIrabUXuvSa4SNn7wCUsLd8SVddSHp0Uf8U18mg=; b=FiidJU1teKWEvRcqJLu6utNPNfvGQoMirUYJFAdYbBhSV6kPXLZnsMX6pgHfMvKURmwVLJ lp6TRfqMGzvxcEjQuhdnM+vht5CB6hye4EW12HJaRZWD1wArIvSw9u8cvn59UmLFTGMn4B ePadM0PDAk0lJp6C4djaqPe074tsmgRIbwwOiuKAi+a+AXk396gOHCpUhT6fpAKrjfnNS5 BN0blH5DTiCUBJFDiMdXhQTVuZXkJfDas7tFW926qHIz5C9mghjeTCom+dUYMrhLoqGLW+ 5eFnWF4xfRyUC5EjDOP/MQMECTFQk54qbKaRjbwWBixtAPDOkXcPqX7Ut8VfoA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598298; a=rsa-sha256; cv=none; b=qepI9aL4Ruosxg+X7MQZJjdYaz0JzKtTpVXNMeu4IL85YaAurUcra/UKCtAORQXWwAD+OP rzSS2FTFL8QsaDloulBp2m/h7ogu57Ag185w92MkGbeYXA1jwAyOTRGlFT4oS51LKhftGU GwiCE4E1pRA+uQ3cOqIl2HMJcn8tgQ2JUCNxhIzmhJnjH7jnXxPsd7DLzHixXR3I1mRU8N CC38vlkdww6A0HVBxEj1pvksUCtY2VIRsvK0zsZhY3l0NnQrXNY2+pvQ8i1zL9unJh56un C2ASPcL19S1HmdckBuG6Nqd/O0UVdc0/4LhzIKL05Urtq6E4oh2Gs9/N+PgmhQ== 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 4P1h5P757MzQRg; Tue, 24 Jan 2023 22:11:37 +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 30OMBb6r084989; Tue, 24 Jan 2023 22:11:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMBb4i084988; Tue, 24 Jan 2023 22:11:37 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:11:37 GMT Message-Id: <202301242211.30OMBb4i084988@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: fce2a0a930a7 - stable/13 - kboot: Add host_exit and use it to implement exit() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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: fce2a0a930a7680a4725746a274d61a7ff84ac9d Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=fce2a0a930a7680a4725746a274d61a7ff84ac9d commit fce2a0a930a7680a4725746a274d61a7ff84ac9d Author: Warner Losh AuthorDate: 2022-07-28 21:18:08 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:28 +0000 kboot: Add host_exit and use it to implement exit() Clients of libsa are expected to implement exit(). The current exit just loops forever. It is better to really exit: when running as init that will reboot the system. When not running as init, other programs can recover (not that we support running as init, but when we do in the future, this is still the rigtht thing). Sponsored by: Netflix (cherry picked from commit f56d7a73be6688299c7ec97fac6d505c657aa55c) --- stand/kboot/arch/aarch64/syscall_nr.h | 1 + stand/kboot/arch/amd64/syscall_nr.h | 1 + stand/kboot/arch/powerpc64/syscall_nr.h | 1 + stand/kboot/host_syscall.h | 1 + stand/kboot/host_syscalls.c | 6 ++++++ stand/kboot/main.c | 2 +- 6 files changed, 11 insertions(+), 1 deletion(-) diff --git a/stand/kboot/arch/aarch64/syscall_nr.h b/stand/kboot/arch/aarch64/syscall_nr.h index 511d1fa8b2a7..79bf22947e94 100644 --- a/stand/kboot/arch/aarch64/syscall_nr.h +++ b/stand/kboot/arch/aarch64/syscall_nr.h @@ -1,5 +1,6 @@ #define SYS_close 57 #define SYS_dup 23 +#define SYS_exit 93 #define SYS_fstat 80 #define SYS_getdents64 61 #define SYS_getpid 172 diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 71930001c1cf..71469109a55e 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,5 +1,6 @@ #define SYS_close 3 #define SYS_dup 32 +#define SYS_exit 60 #define SYS_getdents64 217 #define SYS_getpid 39 #define SYS_gettimeofday 96 diff --git a/stand/kboot/arch/powerpc64/syscall_nr.h b/stand/kboot/arch/powerpc64/syscall_nr.h index 0702673c7228..7b425e36c517 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,5 +1,6 @@ #define SYS_close 6 #define SYS_dup 41 +#define SYS_exit 1 #define SYS_fstat 108 #define SYS_getdents64 202 #define SYS_getpid 20 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index 9f876952641e..09f5355e520d 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -155,6 +155,7 @@ struct host_dirent64 { */ int host_close(int fd); int host_dup(int fd); +int host_exit(int code); int host_fstat(int fd, struct host_kstat *sb); int host_getdents64(int fd, void *dirp, int count); int host_getpid(void); diff --git a/stand/kboot/host_syscalls.c b/stand/kboot/host_syscalls.c index 52371021f282..8b364083b15c 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -19,6 +19,12 @@ host_dup(int fd) return host_syscall(SYS_dup, fd); } +int +host_exit(int code) +{ + return host_syscall(SYS_exit, code); +} + /* Same system call with different names on different Linux architectures due to history */ int host_fstat(int fd, struct host_kstat *sb) diff --git a/stand/kboot/main.c b/stand/kboot/main.c index 83ad0ceb8a18..5d40e2c3b582 100644 --- a/stand/kboot/main.c +++ b/stand/kboot/main.c @@ -303,7 +303,7 @@ main(int argc, const char **argv) void exit(int code) { - while (1); /* XXX: host_exit */ + host_exit(code); __unreachable(); }