From nobody Thu Jul 28 21:37:45 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 4Lv3sP4TmSz4X0xG; Thu, 28 Jul 2022 21:37:45 +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 4Lv3sP41Ssz3rf9; Thu, 28 Jul 2022 21:37:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659044265; 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=kNl8B0r3bCxGYEA9sn1D0RCu+LEnD4+i7ODIuFtM3II=; b=rVwoWtlx/D86E2kx+5Yo9xdUtT6F13uBOkPMLfzqXIZsAajySOCaxXapM2WaZ+NfJqfyHC 10XRDGnz42MXBgdF4OhcgCipPz9GdRi+OmJiPrf/iAIuCA6N8yahTgmiJB3fpV6u5qB3Xx zbLjR5TBVftaM6/48PycmWTUOEMra+EuEwly3nmGS9Yd6Rfo34VkMNfp2lkMSQRkN8LAXK yPCLXQ9UXuA8Rxk27OdoXGO8sSoy1QE2ZUj2/RboM/XNxCfodjvsOwvhp61Z/3UPQHmIHW HbAhtPYI+Pd7gcDWVFZKiETtvP/K6dVdoVXf5U3/xVoDf2n6wMrhOvSG9jlwPA== 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 4Lv3sP2z6vz19Ph; Thu, 28 Jul 2022 21:37:45 +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 26SLbjJP001687; Thu, 28 Jul 2022 21:37:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26SLbjAZ001686; Thu, 28 Jul 2022 21:37:45 GMT (envelope-from git) Date: Thu, 28 Jul 2022 21:37:45 GMT Message-Id: <202207282137.26SLbjAZ001686@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: f56d7a73be66 - main - kboot: Add host_exit and use it to implement exit() 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: f56d7a73be6688299c7ec97fac6d505c657aa55c Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659044265; 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=kNl8B0r3bCxGYEA9sn1D0RCu+LEnD4+i7ODIuFtM3II=; b=bCnTyjCM7N5yF07uJY9rIrUKr3n8p7qMoF1NX9g0qFyCw5erFVODXxHAk5c3rvcsZOIPte S6WsveWJp/dRXTI0yr+RT+8XMasy4Y5RXE0XztT/oFuvI4HZZqjPh8U30cyfXa0DQcIPnH IoZua0Ln5X+WgM1Zj3h8MND+t+GCveBrimHGG+iD+kJeztm6bmhmGdH2N1f/7dzpd8K6r+ cyabNd5knjKPilFiDowVUQbK2hXMUMWYA4YEfisTAtVXhtlD3uOZsocXv+YLfRprWTSo+3 o0UNL76+CQB+Dg8xTwxNt9vtloVv+662Ly0TkPGe7s6or0uZbRiLCf901fhcWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659044265; a=rsa-sha256; cv=none; b=Et5/+65OaGlQLucf5XZVZCAR3Z5DGDMOhI7vI+Y9H7c35AvwSXRJVhff1dVfyfgzRICsp8 d644r5lLbEvwfnaq4STDBI7nuOcfDuJDdDFKlucsOYIpSJjgjzm4wA5D5dhhU42oh+kkoP BGKZxPkwa9lbUTBGsnRxHJza3+4U3gTwPxqsPVi96XmcdYPu67phdTP/W/55eIKcK1f4nN yB3zP2kY2597TiLWjzeMZzvdRZV39LcH4RqtbMT/KcEh2oTI2hDERk9ElUB+WMGzwpeL87 pKFOnX4lfI2heJWK/7fS7+MjyHZ/SkmBQDGNyP/oKtz88PfAWghg8rS05AT4AQ== 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=f56d7a73be6688299c7ec97fac6d505c657aa55c commit f56d7a73be6688299c7ec97fac6d505c657aa55c Author: Warner Losh AuthorDate: 2022-07-28 21:18:08 +0000 Commit: Warner Losh CommitDate: 2022-07-28 21:35:42 +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 --- 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(); }