From nobody Tue Jan 24 22:11:51 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 4P1h5h0r4Gz3bfYS; Tue, 24 Jan 2023 22:11:52 +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 4P1h5h0HBKz4Pkc; Tue, 24 Jan 2023 22:11:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598312; 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=qy9xb4Kxr5DZdR5Km5Fgv3aEAR3UoKNres8UePrcASE=; b=BL+iMi5k0yg14+p1HwOS/PSS1Pvy1FgdixL0iSAyjX6zrNLfV3IuSxJ4qp2m2ERBp9lu7C ay9tmyj7m4bARYVMSuxNsVGz+hKU2oQQ511Dl7XYf4XFqfgdKhbJ1uakOrW8IFAUNZ5vmr +HR16fRyPhONLDgSk3fSZkJDONL3dD6R+RNjcUcPlH+MXWqXuET+o0oxKa3AH6thm0QBgF 6W4yMPWdO+2SxgDhem48GA/FBWALjW984ZJwF4schjuKdwg0ihJ39REoCViXsCxHvuz6jl rDH1d6b8B29TPCLH/Q5ErgMJJVrKc5B9Ym24pGk3c/XXiNRgjch2voHTTIa+rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598312; 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=qy9xb4Kxr5DZdR5Km5Fgv3aEAR3UoKNres8UePrcASE=; b=enrj2xhb1hWLPu94V80TW6c9CZ15+JpdAcVoJ41SzwYrKucRA3MGtROEXWVcPtQ/QW+TGC zTbCrgfvTCrv/SxkAnTYmaeRb0o47dUhJTWF3Go9W01/tbwiJofLK4zIb54a7YF07BA2lS Xrsnn1G6sH7At4gtFXS0tVpkXqMy3wUZm3DlO7KVQZx3lpwZGUGaCZib2W9J+bEsN8SSuQ Ff4YZZdbFNlytSP1C+QIGXe6mYj6dxHVquEChzja4fyRfqkNQ27oIVoNsJVHUGUHMR93Pn FuOXVz2QjD5ikUmddEm7BUevjIvhPYFSvdAjALJMBujeBuiU5h2Qdrto2GASQg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598312; a=rsa-sha256; cv=none; b=SntXPR+zMDOppn4rwmhHCUTGH84llrf7cB1asT0hS6iAEWDMhALgqESoGcqVoU/fkqz36w IFg3hbwPCuJiiTQzWjdCku6dR1S0VCnwsMkdzZDZWZw/kEgSscp7jNqQgZvMzjAUGsyMUF FgSGhgEvT1avt+WEdK8UyBnQKIeJwccgF32LiPLr8DfwJYDBQ41o7Oys3dpdVHGG2nqDiN ug/IQEJ2ZExifW3n92wQIL0G6KbAgG0wLd0vBgjxO/TuyS5CLOIdrZwmsf4Tz6HuDvecQl uWsh0rVmNG15fZr9gur9PNhREgpDFfJ42fnGun+vPfdM+oTkmzYXrT1RQKWgbw== 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 4P1h5g6F08zQRq; Tue, 24 Jan 2023 22:11:51 +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 30OMBpv0085299; Tue, 24 Jan 2023 22:11:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMBpMf085298; Tue, 24 Jan 2023 22:11:51 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:11:51 GMT Message-Id: <202301242211.30OMBpMf085298@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: cffdb3f5e2da - stable/13 - stand: Move i386_devdesc to a union 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: cffdb3f5e2da60f21bf9ef52c4791ee1d46b7d44 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=cffdb3f5e2da60f21bf9ef52c4791ee1d46b7d44 commit cffdb3f5e2da60f21bf9ef52c4791ee1d46b7d44 Author: Warner Losh AuthorDate: 2022-08-11 15:04:08 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:30 +0000 stand: Move i386_devdesc to a union Rather than have the magic, hand-crafted fields that have to align with fields in other structures at the end of i386_devdesc, make it into anonymous union and adjust the code accordingly. This is safer and similar to what CAM does. Sponsored by: Netflix Reviewed by: kevans, tsoome (prior version) Differential Revision: https://reviews.freebsd.org/D35965 (cherry picked from commit f197c0bf3e075286ccea32cd12023f3317474c5a) --- stand/i386/libi386/libi386.h | 28 +++++++++++++--------------- stand/i386/loader/main.c | 22 ++++++++++------------ stand/i386/zfsboot/zfsboot.c | 19 +++++++++---------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/stand/i386/libi386/libi386.h b/stand/i386/libi386/libi386.h index a52a1190e7ec..9c7a452a03ad 100644 --- a/stand/i386/libi386/libi386.h +++ b/stand/i386/libi386/libi386.h @@ -27,25 +27,23 @@ */ +#include "disk.h" +#ifdef LOADER_ZFS_SUPPORT +#include "libzfs.h" +#endif /* * i386 fully-qualified device descriptor. */ -struct i386_devdesc { - struct devdesc dd; /* Must be first. */ - union - { - struct +struct i386_devdesc +{ + union { - int slice; - int partition; - off_t offset; - } biosdisk; - struct - { - uint64_t pool_guid; - uint64_t root_guid; - } zfs; - } d_kind; + struct devdesc dd; + struct disk_devdesc disk; +#ifdef LOADER_ZFS_SUPPORT + struct zfs_devdesc zfs; +#endif + }; }; /* diff --git a/stand/i386/loader/main.c b/stand/i386/loader/main.c index cb716d7a9f21..29c40921a85a 100644 --- a/stand/i386/loader/main.c +++ b/stand/i386/loader/main.c @@ -308,8 +308,8 @@ extract_currdev(void) new_currdev.dd.d_unit = 0; } else { /* we don't know what our boot device is */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } #ifdef LOADER_ZFS_SUPPORT @@ -322,8 +322,8 @@ extract_currdev(void) zargs->size >= offsetof(struct zfs_boot_args, primary_pool)) { /* sufficient data is provided */ - new_currdev.d_kind.zfs.pool_guid = zargs->pool; - new_currdev.d_kind.zfs.root_guid = zargs->root; + new_currdev.zfs.pool_guid = zargs->pool; + new_currdev.zfs.root_guid = zargs->root; if (zargs->size >= sizeof(*zargs) && zargs->primary_vdev != 0) { sprintf(buf, "%llu", zargs->primary_pool); @@ -333,8 +333,8 @@ extract_currdev(void) } } else { /* old style zfsboot block */ - new_currdev.d_kind.zfs.pool_guid = kargs->zfspool; - new_currdev.d_kind.zfs.root_guid = 0; + new_currdev.zfs.pool_guid = kargs->zfspool; + new_currdev.zfs.root_guid = 0; } new_currdev.dd.d_dev = &zfs_dev; @@ -350,14 +350,12 @@ extract_currdev(void) #endif } else if ((initial_bootdev & B_MAGICMASK) != B_DEVMAGIC) { /* The passed-in boot device is bad */ - new_currdev.d_kind.biosdisk.slice = -1; - new_currdev.d_kind.biosdisk.partition = 0; + new_currdev.disk.d_slice = -1; + new_currdev.disk.d_partition = 0; biosdev = -1; } else { - new_currdev.d_kind.biosdisk.slice = - B_SLICE(initial_bootdev) - 1; - new_currdev.d_kind.biosdisk.partition = - B_PARTITION(initial_bootdev); + new_currdev.disk.d_slice = B_SLICE(initial_bootdev) - 1; + new_currdev.disk.d_partition = B_PARTITION(initial_bootdev); biosdev = initial_bootinfo->bi_bios_dev; /* diff --git a/stand/i386/zfsboot/zfsboot.c b/stand/i386/zfsboot/zfsboot.c index 8dd3066f15e5..b68d80e802c2 100644 --- a/stand/i386/zfsboot/zfsboot.c +++ b/stand/i386/zfsboot/zfsboot.c @@ -467,8 +467,8 @@ load(void) if (bdev->dd.d_dev->dv_type == DEVT_ZFS) { zfsargs.size = sizeof(zfsargs); - zfsargs.pool = bdev->d_kind.zfs.pool_guid; - zfsargs.root = bdev->d_kind.zfs.root_guid; + zfsargs.pool = bdev->zfs.pool_guid; + zfsargs.root = bdev->zfs.root_guid; #ifdef LOADER_GELI_SUPPORT export_geli_boot_data(&zfsargs.gelidata); #endif @@ -481,8 +481,8 @@ load(void) __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), bootdev, KARGS_FLAGS_ZFS | KARGS_FLAGS_EXTARG, - (uint32_t)bdev->d_kind.zfs.pool_guid, - (uint32_t)(bdev->d_kind.zfs.pool_guid >> 32), + (uint32_t)bdev->zfs.pool_guid, + (uint32_t)(bdev->zfs.pool_guid >> 32), VTOP(&bootinfo), zfsargs); } else { @@ -528,13 +528,12 @@ mount_root(char *arg) free(bdev); bdev = ddesc; if (bdev->dd.d_dev->dv_type == DEVT_DISK) { - if (bdev->d_kind.biosdisk.partition == -1) + if (bdev->disk.d_partition == -1) part = 0xff; else - part = bdev->d_kind.biosdisk.partition; + part = bdev->disk.d_partition; bootdev = MAKEBOOTDEV(dev_maj[bdev->dd.d_dev->dv_type], - bdev->d_kind.biosdisk.slice + 1, - bdev->dd.d_unit, part); + bdev->disk.d_slice + 1, bdev->dd.d_unit, part); bootinfo.bi_bios_dev = bd_unit2bios(bdev); } strncpy(boot_devname, root, sizeof (boot_devname)); @@ -714,8 +713,8 @@ i386_zfs_probe(void) if (pool_guid != 0 && bdev == NULL) { bdev = malloc(sizeof (struct i386_devdesc)); bzero(bdev, sizeof (struct i386_devdesc)); - bdev->dd.d_dev = &zfs_dev; - bdev->d_kind.zfs.pool_guid = pool_guid; + bdev->zfs.dd.d_dev = &zfs_dev; + bdev->zfs.pool_guid = pool_guid; } } }