From nobody Thu Aug 11 16:27:36 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 4M3XK44pHVz4Yrtp; Thu, 11 Aug 2022 16:27:36 +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 4M3XK444D8z3pZ5; Thu, 11 Aug 2022 16:27:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660235256; 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=deg3k/2dEZHNE8iprOOm1zBFsOVRYe9zAw8Fqr0OW9A=; b=uRT0fw1CgZndTQR6nwY+kqFT9Ymp6WQpQzJjcYx1xlKlT1qYhwu4ogDTnAkL1VXdWD3MdA /QATj74l9LPtHLbNzyEFwbAPw5vOnlbc2AjLq2UZxdhrwUXR8u/XTAGvhzynS4DEytxm61 w79B0z6nx33jaLVmEaW15SNPA6ZlrxpCp7lU58dLnBpvM9w+CQRtIjiNQpyjKQfnTTIMVj r4mal2FIISZeT8oyYemu2LXuSAnkvgZN905wLzTnoO/3jzKad5f1NEKGn2UHhQY7pC/SQX po6ZR3pRgBsc6Di/Tyk/YKERr1NHrBGOD2Wr/uUOqTHK/3MkESqOqu4Tryhfiw== 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 4M3XK4379czy4f; Thu, 11 Aug 2022 16:27:36 +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 27BGRa5j055251; Thu, 11 Aug 2022 16:27:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27BGRa1G055250; Thu, 11 Aug 2022 16:27:36 GMT (envelope-from git) Date: Thu, 11 Aug 2022 16:27:36 GMT Message-Id: <202208111627.27BGRa1G055250@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: f197c0bf3e07 - main - stand: Move i386_devdesc to a union 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: f197c0bf3e075286ccea32cd12023f3317474c5a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660235256; 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=deg3k/2dEZHNE8iprOOm1zBFsOVRYe9zAw8Fqr0OW9A=; b=jwzm9I1z0zdqoca8Ia4IwklgvVtDaYm065ILkNNirWBjXU+AmCKIdese+G/3dtmPS5JVXJ pGk0vK6M9nrNjQhTGiwJ4CKZeS7dyuKg5diYZ32+C7oaI9z0xf5edlW4ql2NrgwvanhpbW lwq/VjkAolMvSU94jIqeUofce55Bc90RYtYPqibuYn/8S1H0quKOyJzyfrF3LnOU5KqkTa D8Fwzzig4A8JfYyWzYpfDWufOiDA7vngq94Agv16LP4tZ7S6ijqnqJ7ol+Bzc2W3t6Yipt CN8JFyigHBo5Nk2J082DINa2aCM4KDtWlP15qgcHgTjLtL5/SBH3/AVug9yu/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660235256; a=rsa-sha256; cv=none; b=uGpJTLs+gFyw20kUFUSwZPO6rthQSNVBJWQlmDf8XsyNW4BNZ1+0dY6pFJKSEm9K4IOFRq Vk5kQONAmGC5GXAYXqKMmAxQQAK9rCaWUhpOrt6qWF9xeBydSzbH3mcTJc5RHpoWy5EruD BmIACAxRsGMfN8L+X9fc0h5Y4Pvf5lNF+Q1EB2fxJyMWCpwtvWW5i03KyLWP4kHbI0Dch1 9llKEERBOpdsj7J8nB17layR1aWEsEPKAc5WT+5GEy28aboqlkkT0FFhP6pcGMAMUVcCu0 ptpcnV/6vbC+K3bq6RSxyvQRcaKl/z1pAN4wdB/X9FnZt5cAor8P2B+LLlShbQ== 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=f197c0bf3e075286ccea32cd12023f3317474c5a commit f197c0bf3e075286ccea32cd12023f3317474c5a Author: Warner Losh AuthorDate: 2022-08-11 15:04:08 +0000 Commit: Warner Losh CommitDate: 2022-08-11 16:27:15 +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 --- 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; } } }