From nobody Mon May 1 21:04:16 2023 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 4Q9G0x10m2z491DY; Mon, 1 May 2023 21:04:17 +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 4Q9G0x0CpVz3J19; Mon, 1 May 2023 21:04:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682975057; 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=hEFvj8dhCHBlT0WZp0so12oDUQ1eebyCso8Rg1bYrsU=; b=HuQi4ZF95srmis6QnW72FfDEXc5iUJH6F26c1pQo57LTHP29uwGoBzIoYzchkDn4zytbOx 7CBVBMqaiA1B//dBWS8B1YUjduCrgT60pIUG9gqFU0TlVNq5PVYzOil77WaH3QuHPtDztS CYw76A27/sMo0Buvpl0BN7M+tfyUBKHAeVXwM1+1Cr2LKndXNbvZBfRR2Rz+T9jPd4i0/b A8rM3mIjD3ssk8daEHG2E0vKmfgsN/rrFKTowt++pnqgWlhebkaetRRf+TmEe/O2BMvL16 K6yPrpQXqjE+OvIpGJtYa26LL/P523BSa7dVBKCd0Nc1cp6W8jBx2gNuNouhUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1682975057; 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=hEFvj8dhCHBlT0WZp0so12oDUQ1eebyCso8Rg1bYrsU=; b=hicmxU3Wte0R/XNyfiUjLJ5QRzfnW2RoclRGx/kUdzxxKSZLbPHINxSWcOpvE3d/T1aiwn Q53v9+V/W7EXKEfFadrnoihRLm6JpzmcI5heEU+/Y5wNY8yypG7Yl3TTQqJMoomydVogaf g6ozBk3YsxOhkGGvcg04zxW+0niJ6zq2fJe+iHw0tLVOJF50xOC0v+xGJmMvgLq+HzgOEZ I1SneaNTR2lyjOxfe3cggltWsM6hT8BYmMuS5+dDVAEFQBqRCn6WnZomP29B9Ml9adBlR7 QrpZKFIfC+uoWBDfSnLYtJGydjiAdiB0sZhevwhnyQzyhaM/9MSFAqx+EOpxgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1682975057; a=rsa-sha256; cv=none; b=jNrmrEQGimbXpvjgpG0oZx+57EX33FabDZS3FXpvkuVFcJsbgJ09oUZ/1zZStAA1KTaCSY PvRNTgD6a59BzaN/1bvWD/k4UrPKBME/PodqATnIcCpuwbEJBN19+LewPHykbTwYeo0Q5c B7eWIISjAsQeE843/xD5eSZAn/NVbEQQh3kQ9ZtrjUyK16HOLUwv6P14pAauEJg/5bC46t 30eQMg22qD0/b9dfOJGQgGfFNzqPS4Szp9BH5VvDOrmXHOX3gRhxM68JZcb5RKWvaPyb3F Sd/Tgso+6NiOupTTs53V/92qUuYdR8x+2s5vaCXcYlZZ7YT1V8BBa5SULi3TGA== 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 4Q9G0w6DTVzKky; Mon, 1 May 2023 21:04:16 +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 341L4GZG051830; Mon, 1 May 2023 21:04:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 341L4GLq051829; Mon, 1 May 2023 21:04:16 GMT (envelope-from git) Date: Mon, 1 May 2023 21:04:16 GMT Message-Id: <202305012104.341L4GLq051829@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: 43f7eeff0d45 - main - stand/boot1.efi: Implement bootonce for ZFS 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: 43f7eeff0d45769e1deaf0a6879bc807fdafaf4c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=43f7eeff0d45769e1deaf0a6879bc807fdafaf4c commit 43f7eeff0d45769e1deaf0a6879bc807fdafaf4c Author: Warner Losh AuthorDate: 2023-05-01 15:27:14 +0000 Commit: Warner Losh CommitDate: 2023-05-01 21:02:53 +0000 stand/boot1.efi: Implement bootonce for ZFS Implement ZFS bootonce protocol. We pass zfs-bootonce=t to the next boot stage as a command line argument. Unlike zfsboot -> loader handoff in the BIOS case, we don't use the OS_BOOTONCE_USED. This would require modifications to loader.efi which would only server to make it more complicated. Instead, use the command line parsing interface for the boot1.efi -> loader.efi to pass in the zfs-bootonce kenv that will be needed by rc.d/zfsbe to activate the BE if boot progresses that far. Sponsored by: Netflix Reviewed by: tsoome, kevans Differential Revision: https://reviews.freebsd.org/D39412 --- stand/efi/boot1/zfs_module.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/stand/efi/boot1/zfs_module.c b/stand/efi/boot1/zfs_module.c index 7aaca72e30f1..234b50084839 100644 --- a/stand/efi/boot1/zfs_module.c +++ b/stand/efi/boot1/zfs_module.c @@ -40,6 +40,8 @@ static dev_info_t *devices; +static char zfs_bootonce[VDEV_PAD_SIZE]; + uint64_t ldi_get_size(void *priv) { @@ -165,6 +167,16 @@ load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) return (EFI_NOT_FOUND); } + /* + * OK. We've found a filesystem. Any attempt to use it should clear the + * 'once' flag. Prior to now, we'd not be able to clear it anyway. We + * don't care if we can't find the files to boot, or if there's a + * problem with it: we've tried to use it once we're able to mount the + * ZFS dataset. + */ + *zfs_bootonce = '\0'; + zfs_get_bootonce_spa(spa, OS_BOOTONCE, zfs_bootonce, sizeof(zfs_bootonce)); + if ((err = zfs_lookup(&zmount, filepath, &dn)) != 0) { if (err == ENOENT) { DPRINTF("Failed to find '%s' on pool '%s' (%d)\n", @@ -220,6 +232,18 @@ status(void) printf("\n"); } +static const char * +extra_env(void) +{ + char *rv = NULL; /* So we return NULL if asprintf fails */ + + if (*zfs_bootonce == '\0') + return NULL; + asprintf(&rv, "zfs-bootonce=%s", zfs_bootonce); + return (rv); +} + + static void init(void) { @@ -241,5 +265,6 @@ const boot_module_t zfs_module = .probe = probe, .load = load, .status = status, - .devices = _devices + .devices = _devices, + .extra_env = extra_env, };