From nobody Fri Jul 15 18:04:01 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 4Lkzkp04V3z4TGrd; Fri, 15 Jul 2022 18:04:02 +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 4Lkzkn6FrSz3RjQ; Fri, 15 Jul 2022 18:04:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657908241; 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=1DnkWTzHfaOPJUuIuclgdwMxow9faUwQ4GXr+oxe6Qo=; b=olLPIAPSLM+Wsj7A2cqwb9zsed4bbjtoocRxjnh8suI4BczybYuPq03wE67O/07PXO+v6X pJtFwimjOZco4la8wnW2jRqr3TXMAO/y2gGuPPOtOJMw+IiAgNB7igyYtd7+miuY/0WKvL fi8d7nlgKu5w0XHjPBkpvKBprORk7K4XQPdGksm45U1OVIsG8VhL0nDUxgV0agjCTp1YcM eHKqog2qyrNptyB9lJpqs3kxaPHSrumoFfQe2+1vfpmgjUYdBeNWIgpgzRLwOxqp+xoA8T E4obL4FmLKINutY8Dxk9uK7WRUbrC0rYgh0PHz6czuDF04Fcs8gfmFbDPhhEvw== 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 4Lkzkn53GgzrLJ; Fri, 15 Jul 2022 18:04:01 +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 26FI41lG060287; Fri, 15 Jul 2022 18:04:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26FI414D060286; Fri, 15 Jul 2022 18:04:01 GMT (envelope-from git) Date: Fri, 15 Jul 2022 18:04:01 GMT Message-Id: <202207151804.26FI414D060286@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: bc84de741dfd - main - kboot: Implement dup(2) 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: bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657908241; 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=1DnkWTzHfaOPJUuIuclgdwMxow9faUwQ4GXr+oxe6Qo=; b=UWS4D5BT+cJjg+Wnm1sYgdsYy98malukyv75UySO4Z2Pl54ZWXbtKKswhNVI8YVP/FtxeN aPkkgA0obJGzz5laUAUis/7iB8Y4wMpGYBIBLUGaN3UNHcR36FjMXa/KRI0GM34MZclMec R6+4rXVETMMJhv78tssZWXHYNCNY9UL8Eip5h1PE3XKHy7xwpoB7d6NRCKxKHtMfoSOe5K R7DO1RMFjUWzanJmUQJvmy0nE87VlpEbr3BOo4npFLg4wN0NxOzcY5M90tV8DrS62sbvIh BR7YX8gdxJ7lKViQdDoM6tI9VxONMfbuHTXEjmsOoWeIpT9fwdaclmFFza/iiw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657908241; a=rsa-sha256; cv=none; b=mwfiSbvQNaoDyNMYzWF3PE1dDuTUlQxSPGi/bsaoa66kICoAL2HWfzoxRBOui0E/vcwFJM mmU8djFEBcLTNBjsnoFXwN8xas7NcRUvBiNMzrm1rhHfMRGt2/V/IQvDf5kMEXuQLqv55a MGt9G26d2NuYFj3dX2VSXygr4W3N4cSzjKyzSBtb+M7XeN4hwaewnOT46icuVZNgZOrLQv DkUF3wHMs5zMnInoZIgCXTAgljjtIDCAMFC9878C2V3+eCYP/eGGzJEP3QfnXbXsBFyq8/ naXxxrsvrxtmQ2617PYyObIB37PKmC1tm6wumob6uYyFbCeSo29LvkzQbeEYvA== 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=bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1 commit bc84de741dfd3b81cc7d332f8e6f0d84afe4eee1 Author: Warner Losh AuthorDate: 2022-06-30 18:25:49 +0000 Commit: Warner Losh CommitDate: 2022-07-15 18:00:50 +0000 kboot: Implement dup(2) Early in boot, we need to create the normal stdin/out/err env for the boot loader to run in. To do that, we need to open the console and duplicate the file descriptors which requires dup(2). Implement a wrapper as host_dup. Sponsored by: Netflix --- 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 ++++++ 4 files changed, 9 insertions(+) diff --git a/stand/kboot/arch/amd64/syscall_nr.h b/stand/kboot/arch/amd64/syscall_nr.h index 756b3e93af9a..62deefe73539 100644 --- a/stand/kboot/arch/amd64/syscall_nr.h +++ b/stand/kboot/arch/amd64/syscall_nr.h @@ -1,4 +1,5 @@ #define SYS_close 3 +#define SYS_dup 32 #define SYS_getdents 78 #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 13f26d80f6a3..d6678d9044d9 100644 --- a/stand/kboot/arch/powerpc64/syscall_nr.h +++ b/stand/kboot/arch/powerpc64/syscall_nr.h @@ -1,4 +1,5 @@ #define SYS_close 6 +#define SYS_dup 41 #define SYS_fstat 108 #define SYS_getdents 141 #define SYS_getpid 20 diff --git a/stand/kboot/host_syscall.h b/stand/kboot/host_syscall.h index 3b02f2e78304..10d4166514b9 100644 --- a/stand/kboot/host_syscall.h +++ b/stand/kboot/host_syscall.h @@ -92,6 +92,7 @@ struct host_timeval { * System Calls */ int host_close(int fd); +int host_dup(int fd); int host_fstat(int fd, struct host_kstat *sb); int host_getdents(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 a69937a5a0e1..2fe4c599df82 100644 --- a/stand/kboot/host_syscalls.c +++ b/stand/kboot/host_syscalls.c @@ -13,6 +13,12 @@ host_close(int fd) return host_syscall(SYS_close, fd); } +int +host_dup(int fd) +{ + return host_syscall(SYS_dup, fd); +} + int host_fstat(int fd, struct host_kstat *sb) {