From owner-svn-src-stable-12@freebsd.org Sun Oct 20 14:45:19 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ECE7F160DFE; Sun, 20 Oct 2019 14:45:19 +0000 (UTC) (envelope-from dim@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46x2cb5p04z3K5r; Sun, 20 Oct 2019 14:45:19 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AB4BDD5B9; Sun, 20 Oct 2019 14:45:19 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9KEjJqu077112; Sun, 20 Oct 2019 14:45:19 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9KEjJSf077111; Sun, 20 Oct 2019 14:45:19 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201910201445.x9KEjJSf077111@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 20 Oct 2019 14:45:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353776 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 353776 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Oct 2019 14:45:20 -0000 Author: dim Date: Sun Oct 20 14:45:19 2019 New Revision: 353776 URL: https://svnweb.freebsd.org/changeset/base/353776 Log: Follow up on r351916 by also bumping the version suffix to 12.1 in Makefile.libcompat. Reported by: Jeremy Cox Modified: stable/12/Makefile.libcompat Modified: stable/12/Makefile.libcompat ============================================================================== --- stable/12/Makefile.libcompat Sun Oct 20 14:15:45 2019 (r353775) +++ stable/12/Makefile.libcompat Sun Oct 20 14:45:19 2019 (r353776) @@ -17,7 +17,7 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} .if ${WANT_COMPILER_TYPE} == gcc || \ (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) .else -LIB32CPUFLAGS+= -target x86_64-unknown-freebsd12.0 +LIB32CPUFLAGS+= -target x86_64-unknown-freebsd12.1 .endif LIB32CPUFLAGS+= -m32 LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ @@ -49,9 +49,9 @@ LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} .endif .else .if ${TARGET_ARCH:Mmips64el*} != "" -LIB32CPUFLAGS= -target mipsel-unknown-freebsd12.0 +LIB32CPUFLAGS= -target mipsel-unknown-freebsd12.1 .else -LIB32CPUFLAGS= -target mips-unknown-freebsd12.0 +LIB32CPUFLAGS= -target mips-unknown-freebsd12.1 .endif .endif LIB32CPUFLAGS+= -mabi=32 From owner-svn-src-stable-12@freebsd.org Sun Oct 20 22:01:36 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7D26316C321; Sun, 20 Oct 2019 22:01:36 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xDJ02qHnz4QKX; Sun, 20 Oct 2019 22:01:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 43C4C1A59A; Sun, 20 Oct 2019 22:01:36 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9KM1a3d057334; Sun, 20 Oct 2019 22:01:36 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9KM1Zwr057332; Sun, 20 Oct 2019 22:01:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910202201.x9KM1Zwr057332@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 20 Oct 2019 22:01:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353783 - in stable: 11/sys/kern 11/sys/sys 12/sys/kern 12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/sys/kern 11/sys/sys 12/sys/kern 12/sys/sys X-SVN-Commit-Revision: 353783 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Oct 2019 22:01:36 -0000 Author: kevans Date: Sun Oct 20 22:01:35 2019 New Revision: 353783 URL: https://svnweb.freebsd.org/changeset/base/353783 Log: MFC r353128-r353129: fully initialize cloned devices w/ make_dev_args r353128: kern_conf: fully initialize cloned devices with make_dev_args, too Attempting to initialize si_drv{1,2} with mda_si_drv{1,2} does not work if you are operating on cloned devices. clone_create must be called prior to the make_dev* family to create/return the device on the clonelist as needed. This device is later returned early in newdev(), prior to si_drv{0,1,2} initialization. This patch simply breaks out of the loop if we've found a device and finishes init. r353129: Remove the remnants of SI_CHEAPCLONE SI_CHEAPCLONE was introduced in r66067 for use with cloned bpfs. It was later also used in tty, tun, tap at points. The rough timeline for being removed in each of these is as follows: - r181690: bpf switched to use cdevpriv API by ed@ - r181905: ed@ rewrote the TTY later to be mpsafe - r204464: kib@ removes it from tun/tap, declaring it unused I've not yet been able to dig up any other consumers in the intervening 9 years. It is no longer set on any devices in the tree and leaves an interesting situation in make_dev_sv where we're ok with the device already being set SI_NAMED. Modified: stable/12/sys/kern/kern_conf.c stable/12/sys/sys/conf.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/kern_conf.c stable/11/sys/sys/conf.h Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/kern/kern_conf.c ============================================================================== --- stable/12/sys/kern/kern_conf.c Sun Oct 20 21:06:25 2019 (r353782) +++ stable/12/sys/kern/kern_conf.c Sun Oct 20 22:01:35 2019 (r353783) @@ -166,12 +166,6 @@ dev_rel(struct cdev *dev) dev->si_refcount--; KASSERT(dev->si_refcount >= 0, ("dev_rel(%s) gave negative count", devtoname(dev))); -#if 0 - if (dev->si_usecount == 0 && - (dev->si_flags & SI_CHEAPCLONE) && (dev->si_flags & SI_NAMED)) - ; - else -#endif if (dev->si_devsw == NULL && dev->si_refcount == 0) { LIST_REMOVE(dev, si_list); flag = 1; @@ -575,20 +569,41 @@ newdev(struct make_dev_args *args, struct cdev *si) mtx_assert(&devmtx, MA_OWNED); csw = args->mda_devsw; + si2 = NULL; if (csw->d_flags & D_NEEDMINOR) { /* We may want to return an existing device */ LIST_FOREACH(si2, &csw->d_devs, si_list) { if (dev2unit(si2) == args->mda_unit) { dev_free_devlocked(si); - return (si2); + si = si2; + break; } } + + /* + * If we're returning an existing device, we should make sure + * it isn't already initialized. This would have been caught + * in consumers anyways, but it's good to catch such a case + * early. We still need to complete initialization of the + * device, and we'll use whatever make_dev_args were passed in + * to do so. + */ + KASSERT(si2 == NULL || (si2->si_flags & SI_NAMED) == 0, + ("make_dev() by driver %s on pre-existing device (min=%x, name=%s)", + args->mda_devsw->d_name, dev2unit(si2), devtoname(si2))); } si->si_drv0 = args->mda_unit; - si->si_devsw = csw; si->si_drv1 = args->mda_si_drv1; si->si_drv2 = args->mda_si_drv2; - LIST_INSERT_HEAD(&csw->d_devs, si, si_list); + /* Only push to csw->d_devs if it's not a cloned device. */ + if (si2 == NULL) { + si->si_devsw = csw; + LIST_INSERT_HEAD(&csw->d_devs, si, si_list); + } else { + KASSERT(si->si_devsw == csw, + ("%s: inconsistent devsw between clone_create() and make_dev()", + __func__)); + } return (si); } @@ -798,17 +813,6 @@ make_dev_sv(struct make_dev_args *args1, struct cdev * dev_refl(dev); if ((args.mda_flags & MAKEDEV_ETERNAL) != 0) dev->si_flags |= SI_ETERNAL; - if (dev->si_flags & SI_CHEAPCLONE && - dev->si_flags & SI_NAMED) { - /* - * This is allowed as it removes races and generally - * simplifies cloning devices. - * XXX: still ?? - */ - dev_unlock_and_free(); - *dres = dev; - return (0); - } KASSERT(!(dev->si_flags & SI_NAMED), ("make_dev() by driver %s on pre-existing device (min=%x, name=%s)", args.mda_devsw->d_name, dev2unit(dev), devtoname(dev))); @@ -1543,7 +1547,6 @@ DB_SHOW_COMMAND(cdev, db_show_cdev) SI_FLAG(SI_ETERNAL); SI_FLAG(SI_ALIAS); SI_FLAG(SI_NAMED); - SI_FLAG(SI_CHEAPCLONE); SI_FLAG(SI_CHILD); SI_FLAG(SI_DUMPDEV); SI_FLAG(SI_CLONELIST); Modified: stable/12/sys/sys/conf.h ============================================================================== --- stable/12/sys/sys/conf.h Sun Oct 20 21:06:25 2019 (r353782) +++ stable/12/sys/sys/conf.h Sun Oct 20 22:01:35 2019 (r353783) @@ -59,7 +59,7 @@ struct cdev { #define SI_ETERNAL 0x0001 /* never destroyed */ #define SI_ALIAS 0x0002 /* carrier of alias name */ #define SI_NAMED 0x0004 /* make_dev{_alias} has been called */ -#define SI_CHEAPCLONE 0x0008 /* can be removed_dev'ed when vnode reclaims */ +#define SI_UNUSED1 0x0008 /* unused */ #define SI_CHILD 0x0010 /* child of another struct cdev **/ #define SI_DUMPDEV 0x0080 /* is kernel dumpdev */ #define SI_CLONELIST 0x0200 /* on a clone list */ From owner-svn-src-stable-12@freebsd.org Sun Oct 20 22:05:59 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CF40516C55A; Sun, 20 Oct 2019 22:05:59 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xDP3586gz4Qpl; Sun, 20 Oct 2019 22:05:59 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 94D471A5EE; Sun, 20 Oct 2019 22:05:59 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9KM5xZ8057866; Sun, 20 Oct 2019 22:05:59 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9KM5w26057863; Sun, 20 Oct 2019 22:05:58 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910202205.x9KM5w26057863@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 20 Oct 2019 22:05:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353784 - in stable: 11/lib/libbe 11/sbin/bectl 12/lib/libbe 12/sbin/bectl X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/lib/libbe 11/sbin/bectl 12/lib/libbe 12/sbin/bectl X-SVN-Commit-Revision: 353784 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Oct 2019 22:05:59 -0000 Author: kevans Date: Sun Oct 20 22:05:57 2019 New Revision: 353784 URL: https://svnweb.freebsd.org/changeset/base/353784 Log: MFC r353644, r353646, r353663: bectl(8) origin auto-destroy r353644: libbe(3): add needed bits for be_destroy to auto-destroy some origins New BEs can be created from either an existing snapshot or an existing BE. If an existing BE is chosen (either implicitly via 'bectl create' or explicitly via 'bectl create -e foo bar', for instance), then bectl will create a snapshot of the current BE or "foo" with be_snapshot, with a name formatted like: strftime("%F-%T") and a serial added to it. This commit adds the needed bits for libbe or consumers to determine if a snapshot names matches one of these auto-created snapshots (with some light validation of the date/time/serial), and also a be_destroy flag to specify that the origin should be automatically destroyed if possible. A future commit to bectl will specify BE_DESTROY_AUTOORIGIN by default so we clean up the origin in the most common case, non-user-managed snapshots. r353646: bectl(8): destroy: use BE_DESTROY_AUTOORIGIN if -o is not specified -o will force the origin to be destroyed unconditionally. BE_DESTROY_AUTOORIGIN, on the other hand, will only destroy the origin if it matches the format used by be_snapshot. This lets us clean up the snapshots that are clearly not user-managed (because we're creating them) while leaving user-created snapshots in place and warning that they're still around when the BE created goes away. r353663: libbe(3): Fix destroy of imported BE w/ AUTOORIGIN Imported BE, much like the activated BE, will not have an origin that we can fetch/examine for destruction. be_destroy should not return BE_ERR_NOORIGIN for failure to get the origin property for BE_DESTROY_AUTOORIGIN, because we don't really know going into it that there's even an origin to be destroyed. BE_DESTROY_NEEDORIGIN has been renamed to BE_DESTROY_WANTORIGIN because only a subset of it *needs* the origin, so 'need' is too strong of verbiage. This was caught by jenkins and the bectl tests, but kevans failed to run the bectl tests prior to commit. Modified: stable/12/lib/libbe/be.c stable/12/lib/libbe/be.h stable/12/lib/libbe/libbe.3 stable/12/sbin/bectl/bectl.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/libbe/be.c stable/11/lib/libbe/be.h stable/11/lib/libbe/libbe.3 stable/11/sbin/bectl/bectl.c Directory Properties: stable/11/ (props changed) Modified: stable/12/lib/libbe/be.c ============================================================================== --- stable/12/lib/libbe/be.c Sun Oct 20 22:01:35 2019 (r353783) +++ stable/12/lib/libbe/be.c Sun Oct 20 22:05:57 2019 (r353784) @@ -229,6 +229,7 @@ be_destroy_cb(zfs_handle_t *zfs_hdl, void *data) return (0); } +#define BE_DESTROY_WANTORIGIN (BE_DESTROY_ORIGIN | BE_DESTROY_AUTOORIGIN) /* * Destroy the boot environment or snapshot specified by the name * parameter. Options are or'd together with the possible values: @@ -264,11 +265,25 @@ be_destroy(libbe_handle_t *lbh, const char *name, int if (fs == NULL) return (set_error(lbh, BE_ERR_ZFSOPEN)); - if ((options & BE_DESTROY_ORIGIN) != 0 && + if ((options & BE_DESTROY_WANTORIGIN) != 0 && zfs_prop_get(fs, ZFS_PROP_ORIGIN, origin, sizeof(origin), - NULL, NULL, 0, 1) != 0) + NULL, NULL, 0, 1) != 0 && + (options & BE_DESTROY_ORIGIN) != 0) return (set_error(lbh, BE_ERR_NOORIGIN)); + /* + * If the caller wants auto-origin destruction and the origin + * name matches one of our automatically created snapshot names + * (i.e. strftime("%F-%T") with a serial at the end), then + * we'll set the DESTROY_ORIGIN flag and nuke it + * be_is_auto_snapshot_name is exported from libbe(3) so that + * the caller can determine if it needs to warn about the origin + * not being destroyed or not. + */ + if ((options & BE_DESTROY_AUTOORIGIN) != 0 && *origin != '\0' && + be_is_auto_snapshot_name(lbh, origin)) + options |= BE_DESTROY_ORIGIN; + /* Don't destroy a mounted dataset unless force is specified */ if ((mounted = zfs_is_mounted(fs, NULL)) != 0) { if (force) { @@ -341,6 +356,25 @@ be_setup_snapshot_name(libbe_handle_t *lbh, char *buf, if (!zfs_dataset_exists(lbh->lzh, buf, ZFS_TYPE_SNAPSHOT)) return; } +} + +bool +be_is_auto_snapshot_name(libbe_handle_t *lbh, const char *name) +{ + const char *snap; + int day, hour, minute, month, second, serial, year; + + if ((snap = strchr(name, '@')) == NULL) + return (false); + ++snap; + /* We'll grab the individual components and do some light validation. */ + if (sscanf(snap, "%d-%d-%d-%d:%d:%d-%d", &year, &month, &day, &hour, + &minute, &second, &serial) != 7) + return (false); + return (year >= 1970) && (month >= 1 && month <= 12) && + (day >= 1 && day <= 31) && (hour >= 0 && hour <= 23) && + (minute >= 0 && minute <= 59) && (second >= 0 && second <= 60) && + serial >= 0; } int Modified: stable/12/lib/libbe/be.h ============================================================================== --- stable/12/lib/libbe/be.h Sun Oct 20 22:01:35 2019 (r353783) +++ stable/12/lib/libbe/be.h Sun Oct 20 22:05:57 2019 (r353784) @@ -82,6 +82,8 @@ void be_prop_list_free(nvlist_t *be_list); int be_activate(libbe_handle_t *, const char *, bool); +bool be_is_auto_snapshot_name(libbe_handle_t *, const char *); + /* Bootenv creation functions */ int be_create(libbe_handle_t *, const char *); int be_create_depth(libbe_handle_t *, const char *, const char *, int); @@ -97,6 +99,7 @@ int be_rename(libbe_handle_t *, const char *, const ch typedef enum { BE_DESTROY_FORCE = 1 << 0, BE_DESTROY_ORIGIN = 1 << 1, + BE_DESTROY_AUTOORIGIN = 1 << 2, } be_destroy_opt_t; int be_destroy(libbe_handle_t *, const char *, int); Modified: stable/12/lib/libbe/libbe.3 ============================================================================== --- stable/12/lib/libbe/libbe.3 Sun Oct 20 22:01:35 2019 (r353783) +++ stable/12/lib/libbe/libbe.3 Sun Oct 20 22:05:57 2019 (r353784) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 22, 2019 +.Dd October 16, 2019 .Dt LIBBE 3 .Os .Sh NAME @@ -59,6 +59,9 @@ .Ft const char * Ns .Fn be_root_path "libbe_handle_t *hdl" .Pp +.Ft bool Ns +.Fn be_is_auto_snapshot_name "libbe_handle_t *hdl" "const char *snap" +.Pp .Ft int .Fn be_create "libbe_handle_t *hdl" "const char *be_name" .Pp @@ -212,6 +215,18 @@ active on reboot. The .Fn be_root_path function returns the boot environment root path. +.Pp +The +.Fn be_is_auto_snapshot_name +function is used to determine if the given snapshot name matches the format that +the +.Fn be_snapshot +function will use by default if it is not given a snapshot name to use. +It returns +.Dv true +if the name matches the format, and +.Dv false +if it does not. .Pp The .Fn be_create Modified: stable/12/sbin/bectl/bectl.c ============================================================================== --- stable/12/sbin/bectl/bectl.c Sun Oct 20 22:01:35 2019 (r353783) +++ stable/12/sbin/bectl/bectl.c Sun Oct 20 22:05:57 2019 (r353784) @@ -376,6 +376,7 @@ bectl_cmd_destroy(int argc, char *argv[]) /* We'll emit a notice if there's an origin to be cleaned up */ if ((flags & BE_DESTROY_ORIGIN) == 0 && strchr(target, '@') == NULL) { + flags |= BE_DESTROY_AUTOORIGIN; if (be_root_concat(be, target, targetds) != 0) goto destroy; if (be_prop_list_alloc(&props) != 0) @@ -384,7 +385,8 @@ bectl_cmd_destroy(int argc, char *argv[]) be_prop_list_free(props); goto destroy; } - if (nvlist_lookup_string(props, "origin", &origin) == 0) + if (nvlist_lookup_string(props, "origin", &origin) == 0 && + !be_is_auto_snapshot_name(be, origin)) fprintf(stderr, "bectl destroy: leaving origin '%s' intact\n", origin); be_prop_list_free(props); From owner-svn-src-stable-12@freebsd.org Mon Oct 21 00:08:37 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 64C6D16E88A; Mon, 21 Oct 2019 00:08:37 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xH6Y1r5sz4WG3; Mon, 21 Oct 2019 00:08:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 21DAC1BB19; Mon, 21 Oct 2019 00:08:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9L08bAa027875; Mon, 21 Oct 2019 00:08:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9L08ZQt027865; Mon, 21 Oct 2019 00:08:35 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910210008.x9L08ZQt027865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 21 Oct 2019 00:08:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353787 - in stable/12/sys: kern vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/sys: kern vm X-SVN-Commit-Revision: 353787 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 00:08:37 -0000 Author: kevans Date: Mon Oct 21 00:08:34 2019 New Revision: 353787 URL: https://svnweb.freebsd.org/changeset/base/353787 Log: MFC r351650, r351795-r351796: writemapping accounting for posixshm r351650: posixshm: switch to OBJT_SWAP in advance of other changes Future changes to posixshm will start tracking writeable mappings in order to support file sealing. Tracking writeable mappings for an OBJT_DEFAULT object is complicated as it may be swapped out and converted to an OBJT_SWAP. One may generically add this tracking for vm_object, but this is difficult to do without increasing memory footprint of vm_object and blowing up memory usage by a significant amount. On the other hand, the swap pager can be expanded to track writeable mappings without increasing vm_object size. This change is currently in D21456. Switch over to OBJT_SWAP in advance of the other changes to the swap pager and posixshm. r351795: vm pager: writemapping accounting for OBJT_SWAP Currently writemapping accounting is only done for vnode_pager which does some accounting on the underlying vnode. Extend this to allow accounting to be possible for any of the pager types. New pageops are added to update/release writecount that need to be implemented for any pager wishing to do said accounting, and we implement these methods now for both vnode_pager (unchanged) and swap_pager. The primary motivation for this is to allow other systems with OBJT_SWAP objects to check if their objects have any write mappings and reject operations with EBUSY if so. posixshm will be the first to do so in order to reject adding write seals to the shmfd if any writable mappings exist. r351796: posixshm: start counting writeable mappings r351650 switched posixshm to using OBJT_SWAP for shm_object r351795 added support to the swap_pager for tracking writeable mappings Take advantage of this and start tracking writeable mappings; fd sealing will use this to reject a seal on writing with EBUSY if any such mapping exist. Modified: stable/12/sys/kern/uipc_shm.c stable/12/sys/kern/vfs_vnops.c stable/12/sys/vm/swap_pager.c stable/12/sys/vm/vm_map.c stable/12/sys/vm/vm_map.h stable/12/sys/vm/vm_mmap.c stable/12/sys/vm/vm_object.h stable/12/sys/vm/vm_pager.h stable/12/sys/vm/vnode_pager.c stable/12/sys/vm/vnode_pager.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/uipc_shm.c ============================================================================== --- stable/12/sys/kern/uipc_shm.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/kern/uipc_shm.c Mon Oct 21 00:08:34 2019 (r353787) @@ -554,7 +554,7 @@ shm_alloc(struct ucred *ucred, mode_t mode) shmfd->shm_uid = ucred->cr_uid; shmfd->shm_gid = ucred->cr_gid; shmfd->shm_mode = mode; - shmfd->shm_object = vm_pager_allocate(OBJT_DEFAULT, NULL, + shmfd->shm_object = vm_pager_allocate(OBJT_SWAP, NULL, shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate")); shmfd->shm_object->pg_color = 0; @@ -900,6 +900,7 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *a struct shmfd *shmfd; vm_prot_t maxprot; int error; + bool writecnt; shmfd = fp->f_data; maxprot = VM_PROT_NONE; @@ -910,10 +911,10 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *a if ((fp->f_flag & FWRITE) != 0) maxprot |= VM_PROT_WRITE; + writecnt = (flags & MAP_SHARED) != 0 && (prot & VM_PROT_WRITE) != 0; + /* Don't permit shared writable mappings on read-only descriptors. */ - if ((flags & MAP_SHARED) != 0 && - (maxprot & VM_PROT_WRITE) == 0 && - (prot & VM_PROT_WRITE) != 0) + if (writecnt && (maxprot & VM_PROT_WRITE) == 0) return (EACCES); maxprot &= cap_maxprot; @@ -936,10 +937,16 @@ shm_mmap(struct file *fp, vm_map_t map, vm_offset_t *a mtx_unlock(&shm_timestamp_lock); vm_object_reference(shmfd->shm_object); + if (writecnt) + vm_pager_update_writecount(shmfd->shm_object, 0, objsize); error = vm_mmap_object(map, addr, objsize, prot, maxprot, flags, - shmfd->shm_object, foff, FALSE, td); - if (error != 0) + shmfd->shm_object, foff, writecnt, td); + if (error != 0) { + if (writecnt) + vm_pager_release_writecount(shmfd->shm_object, 0, + objsize); vm_object_deallocate(shmfd->shm_object); + } return (error); } Modified: stable/12/sys/kern/vfs_vnops.c ============================================================================== --- stable/12/sys/kern/vfs_vnops.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/kern/vfs_vnops.c Mon Oct 21 00:08:34 2019 (r353787) @@ -86,7 +86,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include +#include #ifdef HWPMC_HOOKS #include @@ -2483,7 +2483,7 @@ vn_mmap(struct file *fp, vm_map_t map, vm_offset_t *ad * writecount, then undo that now. */ if (writecounted) - vnode_pager_release_writecount(object, 0, size); + vm_pager_release_writecount(object, 0, size); vm_object_deallocate(object); } #ifdef HWPMC_HOOKS Modified: stable/12/sys/vm/swap_pager.c ============================================================================== --- stable/12/sys/vm/swap_pager.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/swap_pager.c Mon Oct 21 00:08:34 2019 (r353787) @@ -375,6 +375,10 @@ static boolean_t static void swap_pager_init(void); static void swap_pager_unswapped(vm_page_t); static void swap_pager_swapoff(struct swdevt *sp); +static void swap_pager_update_writecount(vm_object_t object, + vm_offset_t start, vm_offset_t end); +static void swap_pager_release_writecount(vm_object_t object, + vm_offset_t start, vm_offset_t end); struct pagerops swappagerops = { .pgo_init = swap_pager_init, /* early system initialization of pager */ @@ -385,6 +389,8 @@ struct pagerops swappagerops = { .pgo_putpages = swap_pager_putpages, /* pageout */ .pgo_haspage = swap_pager_haspage, /* get backing store status for page */ .pgo_pageunswapped = swap_pager_unswapped, /* remove swap related to page */ + .pgo_update_writecount = swap_pager_update_writecount, + .pgo_release_writecount = swap_pager_release_writecount, }; /* @@ -610,6 +616,7 @@ swap_pager_alloc_init(void *handle, struct ucred *cred object = vm_object_allocate(OBJT_SWAP, OFF_TO_IDX(offset + PAGE_MASK + size)); + object->un_pager.swp.writemappings = 0; object->handle = handle; if (cred != NULL) { object->cred = cred; @@ -1920,6 +1927,7 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t p atomic_thread_fence_rel(); object->type = OBJT_SWAP; + object->un_pager.swp.writemappings = 0; KASSERT(object->handle == NULL, ("default pager with handle")); } @@ -3004,4 +3012,28 @@ sysctl_swap_async_max(SYSCTL_HANDLER_ARGS) mtx_unlock(&pbuf_mtx); return (0); +} + +static void +swap_pager_update_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + + VM_OBJECT_WLOCK(object); + KASSERT((object->flags & OBJ_NOSPLIT) != 0, + ("Splittable object with writecount")); + object->un_pager.swp.writemappings += (vm_ooffset_t)end - start; + VM_OBJECT_WUNLOCK(object); +} + +static void +swap_pager_release_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + + VM_OBJECT_WLOCK(object); + KASSERT((object->flags & OBJ_NOSPLIT) != 0, + ("Splittable object with writecount")); + object->un_pager.swp.writemappings -= (vm_ooffset_t)end - start; + VM_OBJECT_WUNLOCK(object); } Modified: stable/12/sys/vm/vm_map.c ============================================================================== --- stable/12/sys/vm/vm_map.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vm_map.c Mon Oct 21 00:08:34 2019 (r353787) @@ -574,10 +574,10 @@ vm_map_process_deferred(void) td->td_map_def_user = NULL; while (entry != NULL) { next = entry->next; - MPASS((entry->eflags & (MAP_ENTRY_VN_WRITECNT | - MAP_ENTRY_VN_EXEC)) != (MAP_ENTRY_VN_WRITECNT | + MPASS((entry->eflags & (MAP_ENTRY_WRITECNT | + MAP_ENTRY_VN_EXEC)) != (MAP_ENTRY_WRITECNT | MAP_ENTRY_VN_EXEC)); - if ((entry->eflags & MAP_ENTRY_VN_WRITECNT) != 0) { + if ((entry->eflags & MAP_ENTRY_WRITECNT) != 0) { /* * Decrement the object's writemappings and * possibly the vnode's v_writecount. @@ -586,7 +586,7 @@ vm_map_process_deferred(void) ("Submap with writecount")); object = entry->object.vm_object; KASSERT(object != NULL, ("No object for writecount")); - vnode_pager_release_writecount(object, entry->start, + vm_pager_release_writecount(object, entry->start, entry->end); } vm_map_entry_set_vnode_text(entry, false); @@ -1484,8 +1484,8 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_oof protoeflags |= MAP_ENTRY_GROWS_DOWN; if (cow & MAP_STACK_GROWS_UP) protoeflags |= MAP_ENTRY_GROWS_UP; - if (cow & MAP_VN_WRITECOUNT) - protoeflags |= MAP_ENTRY_VN_WRITECNT; + if (cow & MAP_WRITECOUNT) + protoeflags |= MAP_ENTRY_WRITECNT; if (cow & MAP_VN_EXEC) protoeflags |= MAP_ENTRY_VN_EXEC; if ((cow & MAP_CREATE_GUARD) != 0) @@ -2196,7 +2196,7 @@ _vm_map_clip_start(vm_map_t map, vm_map_entry_t entry, vm_map_entry_set_vnode_text(new_entry, true); /* * The object->un_pager.vnp.writemappings for the - * object of MAP_ENTRY_VN_WRITECNT type entry shall be + * object of MAP_ENTRY_WRITECNT type entry shall be * kept as is here. The virtual pages are * re-distributed among the clipped entries, so the sum is * left the same. @@ -3758,20 +3758,20 @@ vm_map_copy_entry( dst_entry->eflags |= MAP_ENTRY_COW | MAP_ENTRY_NEEDS_COPY; dst_entry->offset = src_entry->offset; - if (src_entry->eflags & MAP_ENTRY_VN_WRITECNT) { + if (src_entry->eflags & MAP_ENTRY_WRITECNT) { /* - * MAP_ENTRY_VN_WRITECNT cannot + * MAP_ENTRY_WRITECNT cannot * indicate write reference from * src_entry, since the entry is * marked as needs copy. Allocate a * fake entry that is used to - * decrement object->un_pager.vnp.writecount + * decrement object->un_pager writecount * at the appropriate time. Attach * fake_entry to the deferred list. */ fake_entry = vm_map_entry_create(dst_map); - fake_entry->eflags = MAP_ENTRY_VN_WRITECNT; - src_entry->eflags &= ~MAP_ENTRY_VN_WRITECNT; + fake_entry->eflags = MAP_ENTRY_WRITECNT; + src_entry->eflags &= ~MAP_ENTRY_WRITECNT; vm_object_reference(src_object); fake_entry->object.vm_object = src_object; fake_entry->start = src_entry->start; @@ -3954,7 +3954,7 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c * not relock it later for the assertion * correctness. */ - if (old_entry->eflags & MAP_ENTRY_VN_WRITECNT && + if (old_entry->eflags & MAP_ENTRY_WRITECNT && object->type == OBJT_VNODE) { KASSERT(((struct vnode *)object->handle)-> v_writecount > 0, @@ -3974,8 +3974,8 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c MAP_ENTRY_IN_TRANSITION); new_entry->wiring_thread = NULL; new_entry->wired_count = 0; - if (new_entry->eflags & MAP_ENTRY_VN_WRITECNT) { - vnode_pager_update_writecount(object, + if (new_entry->eflags & MAP_ENTRY_WRITECNT) { + vm_pager_update_writecount(object, new_entry->start, new_entry->end); } vm_map_entry_set_vnode_text(new_entry, true); @@ -4006,7 +4006,7 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c * Copied entry is COW over the old object. */ new_entry->eflags &= ~(MAP_ENTRY_USER_WIRED | - MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_VN_WRITECNT); + MAP_ENTRY_IN_TRANSITION | MAP_ENTRY_WRITECNT); new_entry->wiring_thread = NULL; new_entry->wired_count = 0; new_entry->object.vm_object = NULL; @@ -4030,7 +4030,7 @@ vmspace_fork(struct vmspace *vm1, vm_ooffset_t *fork_c new_entry->end = old_entry->end; new_entry->eflags = old_entry->eflags & ~(MAP_ENTRY_USER_WIRED | MAP_ENTRY_IN_TRANSITION | - MAP_ENTRY_VN_WRITECNT | MAP_ENTRY_VN_EXEC); + MAP_ENTRY_WRITECNT | MAP_ENTRY_VN_EXEC); new_entry->protection = old_entry->protection; new_entry->max_protection = old_entry->max_protection; new_entry->inheritance = VM_INHERIT_ZERO; Modified: stable/12/sys/vm/vm_map.h ============================================================================== --- stable/12/sys/vm/vm_map.h Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vm_map.h Mon Oct 21 00:08:34 2019 (r353787) @@ -145,7 +145,7 @@ struct vm_map_entry { #define MAP_ENTRY_GROWS_UP 0x00002000 /* bottom-up stacks */ #define MAP_ENTRY_WIRE_SKIPPED 0x00004000 -#define MAP_ENTRY_VN_WRITECNT 0x00008000 /* writeable vnode +#define MAP_ENTRY_WRITECNT 0x00008000 /* tracked writeable mapping */ #define MAP_ENTRY_GUARD 0x00010000 #define MAP_ENTRY_STACK_GAP_DN 0x00020000 @@ -349,7 +349,7 @@ long vmspace_resident_count(struct vmspace *vmspace); #define MAP_CREATE_GUARD 0x00000080 #define MAP_DISABLE_COREDUMP 0x00000100 #define MAP_PREFAULT_MADVISE 0x00000200 /* from (user) madvise request */ -#define MAP_VN_WRITECOUNT 0x00000400 +#define MAP_WRITECOUNT 0x00000400 #define MAP_REMAP 0x00000800 #define MAP_STACK_GROWS_DOWN 0x00001000 #define MAP_STACK_GROWS_UP 0x00002000 Modified: stable/12/sys/vm/vm_mmap.c ============================================================================== --- stable/12/sys/vm/vm_mmap.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vm_mmap.c Mon Oct 21 00:08:34 2019 (r353787) @@ -1242,7 +1242,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize, } if (writex) { *writecounted = TRUE; - vnode_pager_update_writecount(obj, 0, objsize); + vm_pager_update_writecount(obj, 0, objsize); } } else { error = EINVAL; @@ -1298,7 +1298,7 @@ vm_mmap_vnode(struct thread *td, vm_size_t objsize, done: if (error != 0 && *writecounted) { *writecounted = FALSE; - vnode_pager_update_writecount(obj, objsize, 0); + vm_pager_update_writecount(obj, objsize, 0); } vput(vp); return (error); @@ -1433,7 +1433,7 @@ vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t siz * writecount, then undo that now. */ if (writecounted) - vnode_pager_release_writecount(object, 0, size); + vm_pager_release_writecount(object, 0, size); vm_object_deallocate(object); } return (error); @@ -1522,7 +1522,7 @@ vm_mmap_object(vm_map_t map, vm_offset_t *addr, vm_siz if (flags & MAP_SHARED) docow |= MAP_INHERIT_SHARE; if (writecounted) - docow |= MAP_VN_WRITECOUNT; + docow |= MAP_WRITECOUNT; if (flags & MAP_STACK) { if (object != NULL) return (EINVAL); Modified: stable/12/sys/vm/vm_object.h ============================================================================== --- stable/12/sys/vm/vm_object.h Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vm_object.h Mon Oct 21 00:08:34 2019 (r353787) @@ -167,6 +167,7 @@ struct vm_object { struct { void *swp_tmpfs; struct pctrie swp_blks; + vm_ooffset_t writemappings; } swp; } un_pager; struct ucred *cred; Modified: stable/12/sys/vm/vm_pager.h ============================================================================== --- stable/12/sys/vm/vm_pager.h Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vm_pager.h Mon Oct 21 00:08:34 2019 (r353787) @@ -61,6 +61,7 @@ typedef boolean_t pgo_haspage_t(vm_object_t, vm_pindex typedef int pgo_populate_t(vm_object_t, vm_pindex_t, int, vm_prot_t, vm_pindex_t *, vm_pindex_t *); typedef void pgo_pageunswapped_t(vm_page_t); +typedef void pgo_writecount_t(vm_object_t, vm_offset_t, vm_offset_t); struct pagerops { pgo_init_t *pgo_init; /* Initialize pager. */ @@ -72,6 +73,9 @@ struct pagerops { pgo_haspage_t *pgo_haspage; /* Query page. */ pgo_populate_t *pgo_populate; /* Bulk spec pagein. */ pgo_pageunswapped_t *pgo_pageunswapped; + /* Operations for specialized writecount handling */ + pgo_writecount_t *pgo_update_writecount; + pgo_writecount_t *pgo_release_writecount; }; extern struct pagerops defaultpagerops; @@ -190,6 +194,26 @@ vm_pager_page_unswapped(vm_page_t m) VM_OBJECT_ASSERT_LOCKED(m->object); if (pagertab[m->object->type]->pgo_pageunswapped) (*pagertab[m->object->type]->pgo_pageunswapped)(m); +} + +static __inline void +vm_pager_update_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + + if (pagertab[object->type]->pgo_update_writecount) + pagertab[object->type]->pgo_update_writecount(object, start, + end); +} + +static __inline void +vm_pager_release_writecount(vm_object_t object, vm_offset_t start, + vm_offset_t end) +{ + + if (pagertab[object->type]->pgo_release_writecount) + pagertab[object->type]->pgo_release_writecount(object, start, + end); } struct cdev_pager_ops { Modified: stable/12/sys/vm/vnode_pager.c ============================================================================== --- stable/12/sys/vm/vnode_pager.c Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vnode_pager.c Mon Oct 21 00:08:34 2019 (r353787) @@ -97,6 +97,10 @@ static vm_object_t vnode_pager_alloc(void *, vm_ooffse vm_ooffset_t, struct ucred *cred); static int vnode_pager_generic_getpages_done(struct buf *); static void vnode_pager_generic_getpages_done_async(struct buf *); +static void vnode_pager_update_writecount(vm_object_t, vm_offset_t, + vm_offset_t); +static void vnode_pager_release_writecount(vm_object_t, vm_offset_t, + vm_offset_t); struct pagerops vnodepagerops = { .pgo_alloc = vnode_pager_alloc, @@ -105,6 +109,8 @@ struct pagerops vnodepagerops = { .pgo_getpages_async = vnode_pager_getpages_async, .pgo_putpages = vnode_pager_putpages, .pgo_haspage = vnode_pager_haspage, + .pgo_update_writecount = vnode_pager_update_writecount, + .pgo_release_writecount = vnode_pager_release_writecount, }; int vnode_pbuf_freecnt; @@ -1499,7 +1505,7 @@ done: VM_OBJECT_WUNLOCK(obj); } -void +static void vnode_pager_update_writecount(vm_object_t object, vm_offset_t start, vm_offset_t end) { @@ -1528,7 +1534,7 @@ vnode_pager_update_writecount(vm_object_t object, vm_o VM_OBJECT_WUNLOCK(object); } -void +static void vnode_pager_release_writecount(vm_object_t object, vm_offset_t start, vm_offset_t end) { Modified: stable/12/sys/vm/vnode_pager.h ============================================================================== --- stable/12/sys/vm/vnode_pager.h Sun Oct 20 22:55:47 2019 (r353786) +++ stable/12/sys/vm/vnode_pager.h Mon Oct 21 00:08:34 2019 (r353787) @@ -50,12 +50,8 @@ int vnode_pager_generic_putpages(struct vnode *vp, vm_ int vnode_pager_local_getpages(struct vop_getpages_args *ap); int vnode_pager_local_getpages_async(struct vop_getpages_async_args *ap); int vnode_pager_putpages_ioflags(int pager_flags); -void vnode_pager_release_writecount(vm_object_t object, vm_offset_t start, - vm_offset_t end); void vnode_pager_undirty_pages(vm_page_t *ma, int *rtvals, int written, off_t eof, int lpos); -void vnode_pager_update_writecount(vm_object_t object, vm_offset_t start, - vm_offset_t end); #endif /* _KERNEL */ #endif /* _VNODE_PAGER_ */ From owner-svn-src-stable-12@freebsd.org Mon Oct 21 01:24:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 73A9516FF2E; Mon, 21 Oct 2019 01:24:25 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xJp12Q0Rz4ZWr; Mon, 21 Oct 2019 01:24:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3762D1C911; Mon, 21 Oct 2019 01:24:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9L1OPVC075300; Mon, 21 Oct 2019 01:24:25 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9L1ONpm075292; Mon, 21 Oct 2019 01:24:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910210124.x9L1ONpm075292@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 21 Oct 2019 01:24:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353789 - in stable: 11/lib/libc/gen 11/lib/libc/sys 11/sys/kern 11/sys/sys 12/lib/libc/gen 12/lib/libc/sys 12/sys/kern 12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/lib/libc/gen 11/lib/libc/sys 11/sys/kern 11/sys/sys 12/lib/libc/gen 12/lib/libc/sys 12/sys/kern 12/sys/sys X-SVN-Commit-Revision: 353789 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 01:24:25 -0000 Author: kevans Date: Mon Oct 21 01:24:21 2019 New Revision: 353789 URL: https://svnweb.freebsd.org/changeset/base/353789 Log: MFC r352711-r352712: Address posix_spawn(3) signal issues r352711: rfork(2): add RFSPAWN flag When RFSPAWN is passed, rfork exhibits vfork(2) semantics but also resets signal handlers in the child during creation to avoid a point of corruption of parent state from the child. This flag will be used by posix_spawn(3) to handle potential signal issues. Reviewed by: jilles, kib Differential Revision: https://reviews.freebsd.org/D19058 r352712: posix_spawn(3): handle potential signal issues with vfork Described in [1], signal handlers running in a vfork child have opportunities to corrupt the parent's state. Address this by adding a new rfork(2) flag, RFSPAWN, that has vfork(2) semantics but also resets signal handlers in the child during creation. x86 uses rfork_thread(3) instead of a direct rfork(2) because rfork with RFMEM/RFSPAWN cannot work when the return address is stored on the stack -- further information about this problem is described under RFMEM in the rfork(2) man page. Addressing this has been identified as a prerequisite to using posix_spawn in subprocess on FreeBSD [2]. [1] https://ewontfix.com/7/ [2] https://bugs.python.org/issue35823 Modified: stable/12/lib/libc/gen/posix_spawn.c stable/12/lib/libc/sys/rfork.2 stable/12/sys/kern/kern_fork.c stable/12/sys/kern/kern_sig.c stable/12/sys/sys/proc.h stable/12/sys/sys/signalvar.h stable/12/sys/sys/unistd.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/libc/gen/posix_spawn.c stable/11/lib/libc/sys/rfork.2 stable/11/sys/kern/kern_fork.c stable/11/sys/kern/kern_sig.c stable/11/sys/sys/proc.h stable/11/sys/sys/signalvar.h stable/11/sys/sys/unistd.h Directory Properties: stable/11/ (props changed) Modified: stable/12/lib/libc/gen/posix_spawn.c ============================================================================== --- stable/12/lib/libc/gen/posix_spawn.c Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/lib/libc/gen/posix_spawn.c Mon Oct 21 01:24:21 2019 (r353789) @@ -194,43 +194,115 @@ process_file_actions(const posix_spawn_file_actions_t return (0); } +struct posix_spawn_args { + const char *path; + const posix_spawn_file_actions_t *fa; + const posix_spawnattr_t *sa; + char * const * argv; + char * const * envp; + int use_env_path; + int error; +}; + +#if defined(__i386__) || defined(__amd64__) +#define _RFORK_THREAD_STACK_SIZE 4096 +#endif + static int +_posix_spawn_thr(void *data) +{ + struct posix_spawn_args *psa; + char * const *envp; + + psa = data; + if (psa->sa != NULL) { + psa->error = process_spawnattr(*psa->sa); + if (psa->error) + _exit(127); + } + if (psa->fa != NULL) { + psa->error = process_file_actions(*psa->fa); + if (psa->error) + _exit(127); + } + envp = psa->envp != NULL ? psa->envp : environ; + if (psa->use_env_path) + _execvpe(psa->path, psa->argv, envp); + else + _execve(psa->path, psa->argv, envp); + psa->error = errno; + + /* This is called in such a way that it must not exit. */ + _exit(127); +} + +static int do_posix_spawn(pid_t *pid, const char *path, const posix_spawn_file_actions_t *fa, const posix_spawnattr_t *sa, char * const argv[], char * const envp[], int use_env_path) { + struct posix_spawn_args psa; pid_t p; - volatile int error = 0; +#ifdef _RFORK_THREAD_STACK_SIZE + char *stack; - p = vfork(); - switch (p) { - case -1: - return (errno); - case 0: - if (sa != NULL) { - error = process_spawnattr(*sa); - if (error) - _exit(127); - } - if (fa != NULL) { - error = process_file_actions(*fa); - if (error) - _exit(127); - } - if (use_env_path) - _execvpe(path, argv, envp != NULL ? envp : environ); - else - _execve(path, argv, envp != NULL ? envp : environ); - error = errno; - _exit(127); - default: - if (error != 0) - _waitpid(p, NULL, WNOHANG); - else if (pid != NULL) - *pid = p; - return (error); + stack = malloc(_RFORK_THREAD_STACK_SIZE); + if (stack == NULL) + return (ENOMEM); +#endif + psa.path = path; + psa.fa = fa; + psa.sa = sa; + psa.argv = argv; + psa.envp = envp; + psa.use_env_path = use_env_path; + psa.error = 0; + + /* + * Passing RFSPAWN to rfork(2) gives us effectively a vfork that drops + * non-ignored signal handlers. We'll fall back to the slightly less + * ideal vfork(2) if we get an EINVAL from rfork -- this should only + * happen with newer libc on older kernel that doesn't accept + * RFSPAWN. + */ +#ifdef _RFORK_THREAD_STACK_SIZE + /* + * x86 stores the return address on the stack, so rfork(2) cannot work + * as-is because the child would clobber the return address om the + * parent. Because of this, we must use rfork_thread instead while + * almost every other arch stores the return address in a register. + */ + p = rfork_thread(RFSPAWN, stack + _RFORK_THREAD_STACK_SIZE, + _posix_spawn_thr, &psa); + free(stack); +#else + p = rfork(RFSPAWN); + if (p == 0) + /* _posix_spawn_thr does not return */ + _posix_spawn_thr(&psa); +#endif + /* + * The above block should leave us in a state where we've either + * succeeded and we're ready to process the results, or we need to + * fallback to vfork() if the kernel didn't like RFSPAWN. + */ + + if (p == -1 && errno == EINVAL) { + p = vfork(); + if (p == 0) + /* _posix_spawn_thr does not return */ + _posix_spawn_thr(&psa); } + if (p == -1) + return (errno); + if (psa.error != 0) + /* Failed; ready to reap */ + _waitpid(p, NULL, WNOHANG); + else if (pid != NULL) + /* exec succeeded */ + *pid = p; + return (psa.error); } int Modified: stable/12/lib/libc/sys/rfork.2 ============================================================================== --- stable/12/lib/libc/sys/rfork.2 Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/lib/libc/sys/rfork.2 Mon Oct 21 01:24:21 2019 (r353789) @@ -5,7 +5,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 12, 2011 +.Dd September 25, 2019 .Dt RFORK 2 .Os .Sh NAME @@ -34,7 +34,9 @@ and open files. The .Fa flags argument -is the logical OR of some subset of: +is either +.Dv RFSPAWN +or the logical OR of some subset of: .Bl -tag -width ".Dv RFLINUXTHPN" .It Dv RFPROC If set a new process is created; otherwise changes affect the @@ -103,6 +105,17 @@ This is intended to mimic certain Linux clone behaviou File descriptors in a shared file descriptor table are kept open until either they are explicitly closed or all processes sharing the table exit. +.Pp +If +.Dv RFSPAWN +is passed, +.Nm +will use +.Xr vfork 2 +semantics but reset all signal actions in the child to default. +This flag is used by the +.Xr posix_spawn 3 +implementation in libc. .Pp If .Dv RFPROC Modified: stable/12/sys/kern/kern_fork.c ============================================================================== --- stable/12/sys/kern/kern_fork.c Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/sys/kern/kern_fork.c Mon Oct 21 01:24:21 2019 (r353789) @@ -171,10 +171,18 @@ sys_rfork(struct thread *td, struct rfork_args *uap) /* Don't allow kernel-only flags. */ if ((uap->flags & RFKERNELONLY) != 0) return (EINVAL); + /* RFSPAWN must not appear with others */ + if ((uap->flags & RFSPAWN) != 0 && uap->flags != RFSPAWN) + return (EINVAL); AUDIT_ARG_FFLAGS(uap->flags); bzero(&fr, sizeof(fr)); - fr.fr_flags = uap->flags; + if ((uap->flags & RFSPAWN) != 0) { + fr.fr_flags = RFFDG | RFPROC | RFPPWAIT | RFMEM; + fr.fr_flags2 = FR2_DROPSIG_CAUGHT; + } else { + fr.fr_flags = uap->flags; + } fr.fr_pidp = &pid; error = fork1(td, &fr); if (error == 0) { @@ -520,6 +528,11 @@ do_fork(struct thread *td, struct fork_req *fr, struct } else { sigacts_copy(newsigacts, p1->p_sigacts); p2->p_sigacts = newsigacts; + if ((fr->fr_flags2 & FR2_DROPSIG_CAUGHT) != 0) { + mtx_lock(&p2->p_sigacts->ps_mtx); + sig_drop_caught(p2); + mtx_unlock(&p2->p_sigacts->ps_mtx); + } } if (fr->fr_flags & RFTSIGZMB) Modified: stable/12/sys/kern/kern_sig.c ============================================================================== --- stable/12/sys/kern/kern_sig.c Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/sys/kern/kern_sig.c Mon Oct 21 01:24:21 2019 (r353789) @@ -986,12 +986,7 @@ execsigs(struct proc *p) PROC_LOCK_ASSERT(p, MA_OWNED); ps = p->p_sigacts; mtx_lock(&ps->ps_mtx); - while (SIGNOTEMPTY(ps->ps_sigcatch)) { - sig = sig_ffs(&ps->ps_sigcatch); - sigdflt(ps, sig); - if ((sigprop(sig) & SIGPROP_IGNORE) != 0) - sigqueue_delete_proc(p, sig); - } + sig_drop_caught(p); /* * As CloudABI processes cannot modify signal handlers, fully @@ -3855,4 +3850,21 @@ sigacts_shared(struct sigacts *ps) { return (ps->ps_refcnt > 1); +} + +void +sig_drop_caught(struct proc *p) +{ + int sig; + struct sigacts *ps; + + ps = p->p_sigacts; + PROC_LOCK_ASSERT(p, MA_OWNED); + mtx_assert(&ps->ps_mtx, MA_OWNED); + while (SIGNOTEMPTY(ps->ps_sigcatch)) { + sig = sig_ffs(&ps->ps_sigcatch); + sigdflt(ps, sig); + if ((sigprop(sig) & SIGPROP_IGNORE) != 0) + sigqueue_delete_proc(p, sig); + } } Modified: stable/12/sys/sys/proc.h ============================================================================== --- stable/12/sys/sys/proc.h Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/sys/sys/proc.h Mon Oct 21 01:24:21 2019 (r353789) @@ -1002,6 +1002,8 @@ struct fork_req { int *fr_pd_fd; int fr_pd_flags; struct filecaps *fr_pd_fcaps; + int fr_flags2; +#define FR2_DROPSIG_CAUGHT 0x00001 /* Drop caught non-DFL signals */ }; /* Modified: stable/12/sys/sys/signalvar.h ============================================================================== --- stable/12/sys/sys/signalvar.h Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/sys/sys/signalvar.h Mon Oct 21 01:24:21 2019 (r353789) @@ -381,6 +381,7 @@ void sigacts_copy(struct sigacts *dest, struct sigacts void sigacts_free(struct sigacts *ps); struct sigacts *sigacts_hold(struct sigacts *ps); int sigacts_shared(struct sigacts *ps); +void sig_drop_caught(struct proc *p); void sigexit(struct thread *td, int sig) __dead2; int sigev_findtd(struct proc *p, struct sigevent *sigev, struct thread **); int sig_ffs(sigset_t *set); Modified: stable/12/sys/sys/unistd.h ============================================================================== --- stable/12/sys/sys/unistd.h Mon Oct 21 00:52:21 2019 (r353788) +++ stable/12/sys/sys/unistd.h Mon Oct 21 01:24:21 2019 (r353789) @@ -188,11 +188,14 @@ #define RFTSIGNUM(flags) (((flags) >> RFTSIGSHIFT) & RFTSIGMASK) #define RFTSIGFLAGS(signum) ((signum) << RFTSIGSHIFT) #define RFPROCDESC (1<<28) /* return a process descriptor */ -#define RFPPWAIT (1<<31) /* parent sleeps until child exits (vfork) */ +/* kernel: parent sleeps until child exits (vfork) */ +#define RFPPWAIT (1<<31) +/* user: vfork(2) semantics, clear signals */ +#define RFSPAWN (1U<<31) #define RFFLAGS (RFFDG | RFPROC | RFMEM | RFNOWAIT | RFCFDG | \ RFTHREAD | RFSIGSHARE | RFLINUXTHPN | RFSTOPPED | RFHIGHPID | RFTSIGZMB | \ - RFPROCDESC | RFPPWAIT) -#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPPWAIT | RFPROCDESC) + RFPROCDESC | RFSPAWN | RFPPWAIT) +#define RFKERNELONLY (RFSTOPPED | RFHIGHPID | RFPROCDESC) #endif /* __BSD_VISIBLE */ From owner-svn-src-stable-12@freebsd.org Mon Oct 21 01:27:03 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EAF817003C; Mon, 21 Oct 2019 01:27:03 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xJs32McFz4ZmH; Mon, 21 Oct 2019 01:27:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 344451C913; Mon, 21 Oct 2019 01:27:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9L1R2TR075493; Mon, 21 Oct 2019 01:27:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9L1R2UR075491; Mon, 21 Oct 2019 01:27:02 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910210127.x9L1R2UR075491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 21 Oct 2019 01:27:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353790 - in stable: 11 12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11 12 X-SVN-Commit-Revision: 353790 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 01:27:03 -0000 Author: kevans Date: Mon Oct 21 01:27:01 2019 New Revision: 353790 URL: https://svnweb.freebsd.org/changeset/base/353790 Log: MFC r352929: Add a top-level makeman target Abstracting away the details of how src.conf(5) is generated is arguably a good thing; do so with a top-level makeman target. Modified: stable/12/Makefile stable/12/Makefile.inc1 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/Makefile stable/11/Makefile.inc1 Directory Properties: stable/11/ (props changed) Modified: stable/12/Makefile ============================================================================== --- stable/12/Makefile Mon Oct 21 01:24:21 2019 (r353789) +++ stable/12/Makefile Mon Oct 21 01:27:01 2019 (r353790) @@ -34,6 +34,7 @@ # targets - Print a list of supported TARGET/TARGET_ARCH pairs # for world and kernel targets. # toolchains - Build a toolchain for all world and kernel targets. +# makeman - Regenerate src.conf(5) # sysent - (Re)build syscall entries from syscalls.master. # xdev - xdev-build + xdev-install for the architecture # specified with TARGET and TARGET_ARCH. @@ -132,7 +133,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel bu reinstallkernel reinstallkernel.debug \ installworld kernel-toolchain libraries maninstall \ obj objlink showconfig tags toolchain update \ - sysent \ + makeman sysent \ _worldtmp _legacy _bootstrap-tools _cleanobj _obj \ _build-tools _build-metadata _cross-tools _includes _libraries \ build32 distribute32 install32 buildsoft distributesoft installsoft \ Modified: stable/12/Makefile.inc1 ============================================================================== --- stable/12/Makefile.inc1 Mon Oct 21 01:24:21 2019 (r353789) +++ stable/12/Makefile.inc1 Mon Oct 21 01:27:01 2019 (r353790) @@ -1423,6 +1423,10 @@ packageworld: .PHONY . endif .endfor +makeman: .PHONY + ${_+_}cd ${.CURDIR}/tools/build/options; sh makeman > \ + ${.CURDIR}/share/man/man5/src.conf.5 + _sysent_dirs= sys/kern _sysent_dirs+= sys/compat/freebsd32 _sysent_dirs+= sys/compat/cloudabi32 \ From owner-svn-src-stable-12@freebsd.org Mon Oct 21 17:45:03 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0BB0215C8F2; Mon, 21 Oct 2019 17:45:03 +0000 (UTC) (envelope-from dim@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xkYV6NrFz4VMK; Mon, 21 Oct 2019 17:45:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEA6527799; Mon, 21 Oct 2019 17:45:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9LHj264051663; Mon, 21 Oct 2019 17:45:02 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LHj031051652; Mon, 21 Oct 2019 17:45:00 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201910211745.x9LHj031051652@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 21 Oct 2019 17:45:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353800 - in stable/12: share/man/man5 tools/build/options X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable/12: share/man/man5 tools/build/options X-SVN-Commit-Revision: 353800 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 17:45:03 -0000 Author: dim Date: Mon Oct 21 17:45:00 2019 New Revision: 353800 URL: https://svnweb.freebsd.org/changeset/base/353800 Log: MFC r339524 (by imp): Add missing options. WITHOUT_LOADER_LUA is only needed since we turned it off by default on powerpc and sparc64 in r338203. Same with WITHOUT_LOADER_GEIL. WITH_NVME, WITHOUT_NVME, WITH_LOADER_FORCE_LE have been needed since they were added. MFC r353737: Provide a src.conf(5) description for the new WITHOUT_CAROOT option, and rename the WITH_LOADER_VERIEXEC_PASS_MANFIEST description to its correct name. Also correct a bunch of spelling errors in that description. Added: stable/12/tools/build/options/WITHOUT_LOADER_LUA - copied unchanged from r339524, head/tools/build/options/WITHOUT_LOADER_LUA stable/12/tools/build/options/WITHOUT_NVME - copied unchanged from r339524, head/tools/build/options/WITHOUT_NVME stable/12/tools/build/options/WITH_LOADER_FORCE_LE - copied unchanged from r339524, head/tools/build/options/WITH_LOADER_FORCE_LE stable/12/tools/build/options/WITH_LOADER_GELI - copied unchanged from r339524, head/tools/build/options/WITH_LOADER_GELI stable/12/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST - copied unchanged from r353737, head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST stable/12/tools/build/options/WITH_NVME - copied unchanged from r339524, head/tools/build/options/WITH_NVME Deleted: stable/12/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANFIEST Modified: stable/12/share/man/man5/src.conf.5 stable/12/tools/build/options/WITH_LOADER_VERIEXEC stable/12/tools/build/options/WITH_VERIEXEC Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man5/src.conf.5 ============================================================================== --- stable/12/share/man/man5/src.conf.5 Mon Oct 21 17:17:21 2019 (r353799) +++ stable/12/share/man/man5/src.conf.5 Mon Oct 21 17:45:00 2019 (r353800) @@ -1,6 +1,6 @@ .\" DO NOT EDIT-- this file is @generated by tools/build/options/makeman. .\" $FreeBSD$ -.Dd September 26, 2019 +.Dd October 21, 2019 .Dt SRC.CONF 5 .Os .Sh NAME @@ -1252,11 +1252,24 @@ with support for verification based on certificates ob .It Va WITH_LOADER_FIREWIRE Enable firewire support in /boot/loader on x86. This option is a nop on all other platforms. +.It Va WITH_LOADER_FORCE_LE +Set to force the powerpc boot loader to launch the kernel in little +endian mode. .It Va WITHOUT_LOADER_GELI Disable inclusion of GELI crypto support in the boot chain binaries. .Pp This is a default setting on powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe and sparc64/sparc64. +.It Va WITH_LOADER_GELI +Set to build GELI bootloader support. +.Pp +This is a default setting on +amd64/amd64, arm/arm, arm/armv6, arm/armv7, arm64/aarch64, i386/i386, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf and riscv/riscv64. +.It Va WITHOUT_LOADER_LUA +Set to not build LUA bindings for the boot loader. +.Pp +This is a default setting on +powerpc/powerpc, powerpc/powerpc64, powerpc/powerpcspe and sparc64/sparc64. .It Va WITH_LOADER_LUA Set to build LUA bindings for the boot loader. .Pp @@ -1285,10 +1298,10 @@ arm/arm, arm/armv6, arm/armv7, mips/mipsel, mips/mips, .It Va WITH_LOADER_VERIEXEC Enable building .Xr loader 8 -with support for verifcation similar to Verified Exec. +with support for verification similar to Verified Exec. .Pp -It depends on -.Va WITH_BEARSSL +Depends on +.Va WITH_BEARSSL . When set, these options are also in effect: .Pp .Bl -inset -compact @@ -1297,6 +1310,14 @@ When set, these options are also in effect: .Va WITHOUT_LOADER_EFI_SECUREBOOT is set explicitly) .El +.It Va WITH_LOADER_VERIEXEC_PASS_MANIFEST +Enable building +.Xr loader 8 +with support to pass a verified manifest to the kernel. +The kernel has to be built with a module to parse the manifest. +.Pp +Depends on +.Va WITH_LOADER_VERIEXEC . .It Va WITHOUT_LOADER_ZFS Set to not build ZFS file system boot loader support. .It Va WITHOUT_LOCALES @@ -1502,6 +1523,17 @@ will not be built either if this option is set. Set to not build .Xr ntpd 8 and related programs. +.It Va WITHOUT_NVME +Set to not build nvme related tools and kernel modules. +.Pp +This is a default setting on +arm/arm, arm/armv6, arm/armv7, arm64/aarch64, mips/mipsel, mips/mips, mips/mips64el, mips/mips64, mips/mipsn32, mips/mipselhf, mips/mipshf, mips/mips64elhf, mips/mips64hf, powerpc/powerpc, powerpc/powerpcspe, riscv/riscv64 and sparc64/sparc64. +.It Va WITH_NVME +Set to build nvme related tools and kernel modules. + +.Pp +This is a default setting on +amd64/amd64, i386/i386 and powerpc/powerpc64. .It Va WITH_OFED Set to build the .Dq "OpenFabrics Enterprise Distribution" @@ -1919,8 +1951,8 @@ which loads the contents of verified manifests into th for use by .Xr mac_veriexec 4 .Pp -It depends on -.Va WITH_BEARSSL +Depends on +.Va WITH_BEARSSL . .It Va WITHOUT_VI Set to not build and install vi, view, ex and related programs. .It Va WITHOUT_VT Copied: stable/12/tools/build/options/WITHOUT_LOADER_LUA (from r339524, head/tools/build/options/WITHOUT_LOADER_LUA) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITHOUT_LOADER_LUA Mon Oct 21 17:45:00 2019 (r353800, copy of r339524, head/tools/build/options/WITHOUT_LOADER_LUA) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to not build LUA bindings for the boot loader. Copied: stable/12/tools/build/options/WITHOUT_NVME (from r339524, head/tools/build/options/WITHOUT_NVME) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITHOUT_NVME Mon Oct 21 17:45:00 2019 (r353800, copy of r339524, head/tools/build/options/WITHOUT_NVME) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to not build nvme related tools and kernel modules. Copied: stable/12/tools/build/options/WITH_LOADER_FORCE_LE (from r339524, head/tools/build/options/WITH_LOADER_FORCE_LE) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITH_LOADER_FORCE_LE Mon Oct 21 17:45:00 2019 (r353800, copy of r339524, head/tools/build/options/WITH_LOADER_FORCE_LE) @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to force the powerpc boot loader to launch the kernel in little +endian mode. Copied: stable/12/tools/build/options/WITH_LOADER_GELI (from r339524, head/tools/build/options/WITH_LOADER_GELI) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITH_LOADER_GELI Mon Oct 21 17:45:00 2019 (r353800, copy of r339524, head/tools/build/options/WITH_LOADER_GELI) @@ -0,0 +1,2 @@ +.\" $FreeBSD$ +Set to build GELI bootloader support. Modified: stable/12/tools/build/options/WITH_LOADER_VERIEXEC ============================================================================== --- stable/12/tools/build/options/WITH_LOADER_VERIEXEC Mon Oct 21 17:17:21 2019 (r353799) +++ stable/12/tools/build/options/WITH_LOADER_VERIEXEC Mon Oct 21 17:45:00 2019 (r353800) @@ -1,7 +1,7 @@ .\" $FreeBSD$ Enable building .Xr loader 8 -with support for verifcation similar to Verified Exec. +with support for verification similar to Verified Exec. .Pp -It depends on -.Va WITH_BEARSSL +Depends on +.Va WITH_BEARSSL . Copied: stable/12/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST (from r353737, head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST Mon Oct 21 17:45:00 2019 (r353800, copy of r353737, head/tools/build/options/WITH_LOADER_VERIEXEC_PASS_MANIFEST) @@ -0,0 +1,8 @@ +.\" $FreeBSD$ +Enable building +.Xr loader 8 +with support to pass a verified manifest to the kernel. +The kernel has to be built with a module to parse the manifest. +.Pp +Depends on +.Va WITH_LOADER_VERIEXEC . Copied: stable/12/tools/build/options/WITH_NVME (from r339524, head/tools/build/options/WITH_NVME) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/tools/build/options/WITH_NVME Mon Oct 21 17:45:00 2019 (r353800, copy of r339524, head/tools/build/options/WITH_NVME) @@ -0,0 +1,3 @@ +.\" $FreeBSD$ +Set to build nvme related tools and kernel modules. + Modified: stable/12/tools/build/options/WITH_VERIEXEC ============================================================================== --- stable/12/tools/build/options/WITH_VERIEXEC Mon Oct 21 17:17:21 2019 (r353799) +++ stable/12/tools/build/options/WITH_VERIEXEC Mon Oct 21 17:45:00 2019 (r353800) @@ -5,5 +5,5 @@ which loads the contents of verified manifests into th for use by .Xr mac_veriexec 4 .Pp -It depends on -.Va WITH_BEARSSL +Depends on +.Va WITH_BEARSSL . From owner-svn-src-stable-12@freebsd.org Tue Oct 22 08:52:22 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0F01C154920; Tue, 22 Oct 2019 08:52:22 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46y6hP6Z5gz4VkW; Tue, 22 Oct 2019 08:52:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C4CAF9E48; Tue, 22 Oct 2019 08:52:21 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9M8qLj0098647; Tue, 22 Oct 2019 08:52:21 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9M8qL68098646; Tue, 22 Oct 2019 08:52:21 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910220852.x9M8qL68098646@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 22 Oct 2019 08:52:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353878 - stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Commit-Revision: 353878 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 08:52:22 -0000 Author: avg Date: Tue Oct 22 08:52:21 2019 New Revision: 353878 URL: https://svnweb.freebsd.org/changeset/base/353878 Log: MFC r353624: MFV r353623: 10473 zfs(1M) missing cross-reference to zfs-program(1M) Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Oct 22 00:18:16 2019 (r353877) +++ stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Tue Oct 22 08:52:21 2019 (r353878) @@ -23,17 +23,16 @@ .\" Copyright (c) 2012, Glen Barber .\" Copyright (c) 2012, Bryan Drewery .\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved. -.\" Copyright (c) 2014, Joyent, Inc. All rights reserved. .\" Copyright (c) 2013, Steven Hartland .\" Copyright (c) 2016 Nexenta Systems, Inc. All Rights Reserved. .\" Copyright (c) 2014, Xin LI .\" Copyright (c) 2014-2015, The FreeBSD Foundation, All Rights Reserved. -.\" Copyright 2018 Joyent, Inc. +.\" Copyright 2019 Joyent, Inc. .\" Copyright (c) 2018 Datto Inc. .\" .\" $FreeBSD$ .\" -.Dd February 15, 2018 +.Dd Octover 16, 2019 .Dt ZFS 8 .Os .Sh NAME @@ -3928,6 +3927,7 @@ M F /tank/test/modified .Xr jail 8 , .Xr mount 8 , .Xr umount 8 , +.Xr zfs-program 8 , .Xr zpool 8 .Sh AUTHORS This manual page is a From owner-svn-src-stable-12@freebsd.org Tue Oct 22 08:56:46 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AD827154ADD; Tue, 22 Oct 2019 08:56:46 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46y6nV3y9cz4W2R; Tue, 22 Oct 2019 08:56:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 67A889E62; Tue, 22 Oct 2019 08:56:46 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9M8uk0b099022; Tue, 22 Oct 2019 08:56:46 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9M8ukMN099021; Tue, 22 Oct 2019 08:56:46 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910220856.x9M8ukMN099021@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 22 Oct 2019 08:56:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353880 - stable/12/sys/i386/include X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/i386/include X-SVN-Commit-Revision: 353880 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 08:56:46 -0000 Author: avg Date: Tue Oct 22 08:56:45 2019 New Revision: 353880 URL: https://svnweb.freebsd.org/changeset/base/353880 Log: MFC r353301: i386: hide more of atomic 64-bit definitions under _KERNEL Modified: stable/12/sys/i386/include/atomic.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/i386/include/atomic.h ============================================================================== --- stable/12/sys/i386/include/atomic.h Tue Oct 22 08:53:06 2019 (r353879) +++ stable/12/sys/i386/include/atomic.h Tue Oct 22 08:56:45 2019 (r353880) @@ -880,6 +880,7 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_testandset_32 atomic_testandset_int #define atomic_testandclear_32 atomic_testandclear_int +#ifdef _KERNEL /* Operations on 64-bit quad words. */ #define atomic_cmpset_acq_64 atomic_cmpset_64 #define atomic_cmpset_rel_64 atomic_cmpset_64 @@ -893,6 +894,7 @@ u_long atomic_swap_long(volatile u_long *p, u_long v); #define atomic_subtract_rel_64 atomic_subtract_64 #define atomic_load_64 atomic_load_acq_64 #define atomic_store_64 atomic_store_rel_64 +#endif /* Operations on pointers. */ #define atomic_set_ptr(p, v) \ From owner-svn-src-stable-12@freebsd.org Tue Oct 22 09:07:00 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C5E39155456; Tue, 22 Oct 2019 09:07:00 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46y71J4pB5z4X1P; Tue, 22 Oct 2019 09:07:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 83A22A01E; Tue, 22 Oct 2019 09:07:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9M970wr005163; Tue, 22 Oct 2019 09:07:00 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9M96xma005148; Tue, 22 Oct 2019 09:06:59 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910220906.x9M96xma005148@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 22 Oct 2019 09:06:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353881 - in stable/12/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/common/atomic/i386 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys/cddl: compat/opensolaris/kern compat/opensolaris/sys contrib/opensolaris/common/atomic/i386 X-SVN-Commit-Revision: 353881 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 09:07:00 -0000 Author: avg Date: Tue Oct 22 09:06:59 2019 New Revision: 353881 URL: https://svnweb.freebsd.org/changeset/base/353881 Log: MFC r353167,r353270: ZFS: add emulation of atomic_swap_64 and atomic_load_64 Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c stable/12/sys/cddl/compat/opensolaris/sys/atomic.h stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue Oct 22 09:06:59 2019 (r353881) @@ -71,6 +71,29 @@ atomic_dec_64(volatile uint64_t *target) *target -= 1; mtx_unlock(&atomic_mtx); } + +uint64_t +atomic_swap_64(volatile uint64_t *a, uint64_t value) +{ + uint64_t ret; + + mtx_lock(&atomic_mtx); + ret = *a; + *a = value; + mtx_unlock(&atomic_mtx); + return (ret); +} + +uint64_t +atomic_load_64(volatile uint64_t *a) +{ + uint64_t ret; + + mtx_lock(&atomic_mtx); + ret = *a; + mtx_unlock(&atomic_mtx); + return (ret); +} #endif uint64_t Modified: stable/12/sys/cddl/compat/opensolaris/sys/atomic.h ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Oct 22 09:06:59 2019 (r353881) @@ -44,6 +44,8 @@ !defined(ARM_HAVE_ATOMIC64) && !defined(I386_HAVE_ATOMIC64) extern void atomic_add_64(volatile uint64_t *target, int64_t delta); extern void atomic_dec_64(volatile uint64_t *target); +extern uint64_t atomic_swap_64(volatile uint64_t *a, uint64_t value); +extern uint64_t atomic_load_64(volatile uint64_t *a); #endif #ifndef __sparc64__ extern uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, Modified: stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Tue Oct 22 08:56:45 2019 (r353880) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Tue Oct 22 09:06:59 2019 (r353881) @@ -126,6 +126,34 @@ ret SET_SIZE(atomic_cas_64) + ENTRY(atomic_swap_64) + pushl %esi + pushl %ebx + movl 12(%esp), %esi + movl 16(%esp), %ebx + movl 20(%esp), %ecx + movl (%esi), %eax + movl 4(%esi), %edx // %edx:%eax = old value +1: + lock + cmpxchg8b (%esi) + jne 1b + popl %ebx + popl %esi + ret + SET_SIZE(atomic_swap_64) + + ENTRY(atomic_load_64) + pushl %esi + movl 8(%esp), %esi + movl %ebx, %eax // make old and new values equal, so that + movl %ecx, %edx // destination is never changed + lock + cmpxchg8b (%esi) + popl %esi + ret + SET_SIZE(atomic_load_64) + ENTRY(membar_producer) lock xorl $0, (%esp) From owner-svn-src-stable-12@freebsd.org Tue Oct 22 14:06:13 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D78C115BA77; Tue, 22 Oct 2019 14:06:13 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yFfY5MC6z3K3g; Tue, 22 Oct 2019 14:06:13 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9710FD6DB; Tue, 22 Oct 2019 14:06:13 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9ME6Dfb082097; Tue, 22 Oct 2019 14:06:13 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9ME6Dd5082094; Tue, 22 Oct 2019 14:06:13 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910221406.x9ME6Dd5082094@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 22 Oct 2019 14:06:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353882 - in stable/12/sys: conf netinet X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: conf netinet X-SVN-Commit-Revision: 353882 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 14:06:13 -0000 Author: markj Date: Tue Oct 22 14:06:12 2019 New Revision: 353882 URL: https://svnweb.freebsd.org/changeset/base/353882 Log: MFC r353477: Move SCTP DTrace probe definitions into a .c file. Added: stable/12/sys/netinet/sctp_kdtrace.c - copied unchanged from r353477, head/sys/netinet/sctp_kdtrace.c Deleted: stable/12/sys/netinet/sctp_dtrace_define.h Modified: stable/12/sys/conf/files stable/12/sys/netinet/sctp_pcb.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/files ============================================================================== --- stable/12/sys/conf/files Tue Oct 22 09:06:59 2019 (r353881) +++ stable/12/sys/conf/files Tue Oct 22 14:06:12 2019 (r353882) @@ -4343,6 +4343,7 @@ netinet/sctp_cc_functions.c optional inet sctp | inet6 netinet/sctp_crc32.c optional inet | inet6 netinet/sctp_indata.c optional inet sctp | inet6 sctp netinet/sctp_input.c optional inet sctp | inet6 sctp +netinet/sctp_kdtrace.c optional inet sctp | inet6 sctp netinet/sctp_output.c optional inet sctp | inet6 sctp netinet/sctp_pcb.c optional inet sctp | inet6 sctp netinet/sctp_peeloff.c optional inet sctp | inet6 sctp Copied: stable/12/sys/netinet/sctp_kdtrace.c (from r353477, head/sys/netinet/sctp_kdtrace.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/netinet/sctp_kdtrace.c Tue Oct 22 14:06:12 2019 (r353882, copy of r353477, head/sys/netinet/sctp_kdtrace.c) @@ -0,0 +1,173 @@ +/*- + * SPDX-License-Identifier: BSD-3-Clause + * + * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. + * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * a) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * b) Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the distribution. + * + * c) Neither the name of Cisco Systems, Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include + +SDT_PROVIDER_DECLARE(sctp); + +/********************************************************/ +/* Cwnd probe - tracks changes in the congestion window on a netp */ +/********************************************************/ +/* Initial */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, init, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* ACK-INCREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, ack, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* ACK-INCREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, rttvar, + "uint64_t", /* The Vtag << 32 | localport << 16 | + * remoteport */ + "uint64_t", /* obw | nbw */ + "uint64_t", /* bwrtt | newrtt */ + "uint64_t", /* flight */ + "uint64_t"); /* (cwnd << 32) | point << 16 | retval(0/1) */ + +SDT_PROBE_DEFINE5(sctp, cwnd, net, rttstep, + "uint64_t", /* The Vtag << 32 | localport << 16 | + * remoteport */ + "uint64_t", /* obw | nbw */ + "uint64_t", /* bwrtt | newrtt */ + "uint64_t", /* flight */ + "uint64_t"); /* (cwnd << 32) | point << 16 | retval(0/1) */ + +/* FastRetransmit-DECREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, fr, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* TimeOut-DECREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, to, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* BurstLimit-DECREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, bl, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* ECN-DECREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, ecn, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/* PacketDrop-DECREASE */ +SDT_PROBE_DEFINE5(sctp, cwnd, net, pd, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The old value of the cwnd */ + "int"); /* The new value of the cwnd */ + +/********************************************************/ +/* Rwnd probe - tracks changes in the receiver window for an assoc */ +/********************************************************/ +SDT_PROBE_DEFINE4(sctp, rwnd, assoc, val, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "int", /* The up/down amount */ + "int"); /* The new value of the cwnd */ + +/********************************************************/ +/* flight probe - tracks changes in the flight size on a net or assoc */ +/********************************************************/ +SDT_PROBE_DEFINE5(sctp, flightsize, net, val, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "uintptr_t", /* The pointer to the struct sctp_nets * + * changing */ + "int", /* The up/down amount */ + "int"); /* The new value of the cwnd */ + +/********************************************************/ +/* The total flight version */ +/********************************************************/ +SDT_PROBE_DEFINE4(sctp, flightsize, assoc, val, + "uint32_t", /* The Vtag for this end */ + "uint32_t", /* The port number of the local side << 16 | + * port number of remote in network byte + * order. */ + "int", /* The up/down amount */ + "int"); /* The new value of the cwnd */ Modified: stable/12/sys/netinet/sctp_pcb.c ============================================================================== --- stable/12/sys/netinet/sctp_pcb.c Tue Oct 22 09:06:59 2019 (r353881) +++ stable/12/sys/netinet/sctp_pcb.c Tue Oct 22 14:06:12 2019 (r353882) @@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #if defined(INET) || defined(INET6) #include #endif From owner-svn-src-stable-12@freebsd.org Tue Oct 22 14:06:43 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2FB0415BAE4; Tue, 22 Oct 2019 14:06:43 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yFg70TVmz3KBB; Tue, 22 Oct 2019 14:06:43 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E7366D6DC; Tue, 22 Oct 2019 14:06:42 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9ME6g0g082166; Tue, 22 Oct 2019 14:06:42 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9ME6gKk082165; Tue, 22 Oct 2019 14:06:42 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910221406.x9ME6gKk082165@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 22 Oct 2019 14:06:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353883 - stable/12/sys/netinet6 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/netinet6 X-SVN-Commit-Revision: 353883 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 14:06:43 -0000 Author: markj Date: Tue Oct 22 14:06:42 2019 New Revision: 353883 URL: https://svnweb.freebsd.org/changeset/base/353883 Log: MFC r353457: Add a missing include of opt_sctp.h. Modified: stable/12/sys/netinet6/ip6_forward.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet6/ip6_forward.c ============================================================================== --- stable/12/sys/netinet6/ip6_forward.c Tue Oct 22 14:06:12 2019 (r353882) +++ stable/12/sys/netinet6/ip6_forward.c Tue Oct 22 14:06:42 2019 (r353883) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include "opt_ipsec.h" #include "opt_ipstealth.h" +#include "opt_sctp.h" #include #include From owner-svn-src-stable-12@freebsd.org Tue Oct 22 14:10:32 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 058F215BB92; Tue, 22 Oct 2019 14:10:32 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yFlW6Nb6z3KLp; Tue, 22 Oct 2019 14:10:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BEE06D6E1; Tue, 22 Oct 2019 14:10:31 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9MEAVGD082418; Tue, 22 Oct 2019 14:10:31 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9MEAV6B082417; Tue, 22 Oct 2019 14:10:31 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910221410.x9MEAV6B082417@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 22 Oct 2019 14:10:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353884 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 353884 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 14:10:32 -0000 Author: markj Date: Tue Oct 22 14:10:31 2019 New Revision: 353884 URL: https://svnweb.freebsd.org/changeset/base/353884 Log: MFC r353734: Further constrain the use of per-CPU caches for free pages. PR: 241048 Modified: stable/12/sys/vm/vm_page.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/vm_page.c ============================================================================== --- stable/12/sys/vm/vm_page.c Tue Oct 22 14:06:42 2019 (r353883) +++ stable/12/sys/vm/vm_page.c Tue Oct 22 14:10:31 2019 (r353884) @@ -199,10 +199,12 @@ vm_page_init_cache_zones(void *dummy __unused) vmd = VM_DOMAIN(domain); /* - * Don't allow the page caches to take up more than .25% of - * memory. + * Don't allow the page caches to take up more than .1875% of + * memory. A UMA bucket contains at most 256 free pages, and we + * have two buckets per CPU per free pool. */ - if (vmd->vmd_page_count / 400 < 256 * mp_ncpus * VM_NFREEPOOL) + if (vmd->vmd_page_count / 600 < 2 * 256 * mp_ncpus * + VM_NFREEPOOL) continue; for (pool = 0; pool < VM_NFREEPOOL; pool++) { pgcache = &vmd->vmd_pgcache[pool]; From owner-svn-src-stable-12@freebsd.org Tue Oct 22 14:11:23 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8DB9915BD2C; Tue, 22 Oct 2019 14:11:23 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yFmW3FvSz3KWZ; Tue, 22 Oct 2019 14:11:23 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 53332D736; Tue, 22 Oct 2019 14:11:23 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9MEBNR2084928; Tue, 22 Oct 2019 14:11:23 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9MEBNlA084542; Tue, 22 Oct 2019 14:11:23 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910221411.x9MEBNlA084542@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 22 Oct 2019 14:11:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353885 - in stable/12/sys: modules/pf netpfil/pf X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: modules/pf netpfil/pf X-SVN-Commit-Revision: 353885 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 14:11:23 -0000 Author: markj Date: Tue Oct 22 14:11:22 2019 New Revision: 353885 URL: https://svnweb.freebsd.org/changeset/base/353885 Log: MFC r353458, r353460: Add a missing include of opt_sctp.h. Modified: stable/12/sys/modules/pf/Makefile stable/12/sys/netpfil/pf/pf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/modules/pf/Makefile ============================================================================== --- stable/12/sys/modules/pf/Makefile Tue Oct 22 14:10:31 2019 (r353884) +++ stable/12/sys/modules/pf/Makefile Tue Oct 22 14:11:22 2019 (r353885) @@ -6,7 +6,7 @@ KMOD= pf SRCS= pf.c pf_if.c pf_lb.c pf_osfp.c pf_ioctl.c pf_norm.c pf_table.c \ pf_ruleset.c in4_cksum.c \ bus_if.h device_if.h \ - opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h opt_global.h + opt_pf.h opt_inet.h opt_inet6.h opt_bpf.h opt_sctp.h opt_global.h .if !defined(KERNBUILDDIR) # pflog can be loaded as a module, have the additional checks turned on Modified: stable/12/sys/netpfil/pf/pf.c ============================================================================== --- stable/12/sys/netpfil/pf/pf.c Tue Oct 22 14:10:31 2019 (r353884) +++ stable/12/sys/netpfil/pf/pf.c Tue Oct 22 14:11:22 2019 (r353885) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "opt_inet6.h" #include "opt_bpf.h" #include "opt_pf.h" +#include "opt_sctp.h" #include #include @@ -103,6 +104,10 @@ __FBSDID("$FreeBSD$"); #include #endif /* INET6 */ +#ifdef SCTP +#include +#endif + #include #include @@ -5589,7 +5594,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, } #ifdef SCTP if (m0->m_pkthdr.csum_flags & CSUM_SCTP & ~ifp->if_hwassist) { - sctp_delayed_cksum(m, (uint32_t)(ip->ip_hl << 2)); + sctp_delayed_cksum(m0, (uint32_t)(ip->ip_hl << 2)); m0->m_pkthdr.csum_flags &= ~CSUM_SCTP; } #endif From owner-svn-src-stable-12@freebsd.org Tue Oct 22 21:24:49 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 90291165B22; Tue, 22 Oct 2019 21:24:49 +0000 (UTC) (envelope-from brooks@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yRNd3G7sz4Hvy; Tue, 22 Oct 2019 21:24:49 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 535C01A5B9; Tue, 22 Oct 2019 21:24:49 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9MLOn2f043205; Tue, 22 Oct 2019 21:24:49 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9MLOnMs043204; Tue, 22 Oct 2019 21:24:49 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201910222124.x9MLOnMs043204@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Tue, 22 Oct 2019 21:24:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353901 - stable/12/usr.bin/rpcgen X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/usr.bin/rpcgen X-SVN-Commit-Revision: 353901 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Oct 2019 21:24:49 -0000 Author: brooks Date: Tue Oct 22 21:24:48 2019 New Revision: 353901 URL: https://svnweb.freebsd.org/changeset/base/353901 Log: MFC r353569: rpcgen: make compiler arglist allocation dynamic Limit argmax to an absurdly large value prevent overflow (no overflow possible on FreeBSD due to ARG_MAX). In CheriBSD we exceed the 19 non-NULL arguments in the static array. Add a simple size doubling allocator and increase the default to 32. GC remnants of support for fixed arguments. Reviewed by: archardson (prior version), James Clarke (prior version) Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21971 Modified: stable/12/usr.bin/rpcgen/rpc_main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.bin/rpcgen/rpc_main.c ============================================================================== --- stable/12/usr.bin/rpcgen/rpc_main.c Tue Oct 22 20:41:54 2019 (r353900) +++ stable/12/usr.bin/rpcgen/rpc_main.c Tue Oct 22 21:24:48 2019 (r353901) @@ -93,19 +93,13 @@ static int allnc = nitems(allnv); */ static void addarg(const char *); /* add another argument to the list */ static void insarg(int, const char *); /* insert arg at specified location */ -static void clear_args(void); /* clear argument list */ static void checkfiles(const char *, const char *); /* check if out file already exists */ +static char **arglist; +static int argcount = 0; +static int argmax = 0; - -#define ARGLISTLEN 20 -#define FIXEDARGS 0 - -static char *arglist[ARGLISTLEN]; -static int argcount = FIXEDARGS; - - int nonfatalerrors; /* errors */ int inetdflag = 0; /* Support for inetd is disabled by default, use -I */ int pmflag = 0; /* Support for port monitors is disabled by default */ @@ -141,7 +135,6 @@ main(int argc, const char *argv[]) struct commandline cmd; (void) memset((char *)&cmd, 0, sizeof (struct commandline)); - clear_args(); if (!parseargs(argc, argv, &cmd)) usage(); /* @@ -273,16 +266,6 @@ add_warning(void) f_print(fout, " */\n\n"); } -/* clear list of arguments */ -static void -clear_args(void) -{ - int i; - for (i = FIXEDARGS; i < ARGLISTLEN; i++) - arglist[i] = NULL; - argcount = FIXEDARGS; -} - /* prepend C-preprocessor and flags before arguments */ static void prepend_cpp(void) @@ -925,21 +908,40 @@ do_registers(int argc, const char *argv[]) } /* - * Add another argument to the arg list + * Extend the argument list */ static void -addarg(const char *cp) +moreargs(void) { - if (argcount >= ARGLISTLEN) { - warnx("too many defines"); + char **newarglist; + + argmax = argmax == 0 ? 32 : argmax << 1; + if (argmax > INT_MAX / 4) { + warnx("refusing to allocate too many arguments"); crash(); - /*NOTREACHED*/ } + newarglist = realloc(arglist, argmax * sizeof(*arglist)); + if (newarglist == NULL) { + warnx("unable to allocate arglist"); + crash(); + } + free(arglist); + arglist = newarglist; +} + +/* + * Add another argument to the arg list + */ +static void +addarg(const char *cp) +{ + if (argcount >= argmax) + moreargs(); + if (cp != NULL) arglist[argcount++] = xstrdup(cp); else arglist[argcount++] = NULL; - } /* @@ -950,11 +952,8 @@ insarg(int place, const char *cp) { int i; - if (argcount >= ARGLISTLEN) { - warnx("too many defines"); - crash(); - /*NOTREACHED*/ - } + if (argcount >= argmax) + moreargs(); /* Move up existing arguments */ for (i = argcount - 1; i >= place; i--) From owner-svn-src-stable-12@freebsd.org Wed Oct 23 13:40:39 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BD31A152C20; Wed, 23 Oct 2019 13:40:39 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46ys2b4h8Vz47yq; Wed, 23 Oct 2019 13:40:39 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 84F922544C; Wed, 23 Oct 2019 13:40:39 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NDedDN020186; Wed, 23 Oct 2019 13:40:39 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NDednB020185; Wed, 23 Oct 2019 13:40:39 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910231340.x9NDednB020185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 23 Oct 2019 13:40:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353921 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 353921 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2019 13:40:39 -0000 Author: markj Date: Wed Oct 23 13:40:39 2019 New Revision: 353921 URL: https://svnweb.freebsd.org/changeset/base/353921 Log: MFC r352622: Set NX in mappings created by pmap_kenter() and pmap_kenter_attr(). Modified: stable/12/sys/amd64/amd64/pmap.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Wed Oct 23 13:21:15 2019 (r353920) +++ stable/12/sys/amd64/amd64/pmap.c Wed Oct 23 13:40:39 2019 (r353921) @@ -3135,7 +3135,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa) pt_entry_t *pte; pte = vtopte(va); - pte_store(pte, pa | X86_PG_RW | X86_PG_V | pg_g); + pte_store(pte, pa | X86_PG_RW | X86_PG_V | pg_g | pg_nx); } static __inline void @@ -3146,7 +3146,7 @@ pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, int mo pte = vtopte(va); cache_bits = pmap_cache_bits(kernel_pmap, mode, 0); - pte_store(pte, pa | X86_PG_RW | X86_PG_V | pg_g | cache_bits); + pte_store(pte, pa | X86_PG_RW | X86_PG_V | pg_g | pg_nx | cache_bits); } /* From owner-svn-src-stable-12@freebsd.org Wed Oct 23 13:41:27 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 804D6152DF2; Wed, 23 Oct 2019 13:41:27 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46ys3W2sBQz489G; Wed, 23 Oct 2019 13:41:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4548F254AA; Wed, 23 Oct 2019 13:41:27 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NDfR2q022508; Wed, 23 Oct 2019 13:41:27 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NDfRvt022507; Wed, 23 Oct 2019 13:41:27 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910231341.x9NDfRvt022507@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 23 Oct 2019 13:41:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353922 - stable/12/sys/powerpc/aim X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/powerpc/aim X-SVN-Commit-Revision: 353922 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2019 13:41:27 -0000 Author: markj Date: Wed Oct 23 13:41:26 2019 New Revision: 353922 URL: https://svnweb.freebsd.org/changeset/base/353922 Log: MFC r353650: Clear PGA_WRITEABLE in moea_pvo_remove(). Modified: stable/12/sys/powerpc/aim/mmu_oea.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/powerpc/aim/mmu_oea.c ============================================================================== --- stable/12/sys/powerpc/aim/mmu_oea.c Wed Oct 23 13:40:39 2019 (r353921) +++ stable/12/sys/powerpc/aim/mmu_oea.c Wed Oct 23 13:41:26 2019 (r353922) @@ -2120,23 +2120,26 @@ moea_pvo_remove(struct pvo_entry *pvo, int pteidx) pvo->pvo_pmap->pm_stats.wired_count--; /* + * Remove this PVO from the PV and pmap lists. + */ + LIST_REMOVE(pvo, pvo_vlink); + RB_REMOVE(pvo_tree, &pvo->pvo_pmap->pmap_pvo, pvo); + + /* * Save the REF/CHG bits into their cache if the page is managed. + * Clear PGA_WRITEABLE if all mappings of the page have been removed. */ if ((pvo->pvo_vaddr & PVO_MANAGED) == PVO_MANAGED) { - struct vm_page *pg; + struct vm_page *pg; pg = PHYS_TO_VM_PAGE(pvo->pvo_pte.pte.pte_lo & PTE_RPGN); if (pg != NULL) { moea_attr_save(pg, pvo->pvo_pte.pte.pte_lo & (PTE_REF | PTE_CHG)); + if (LIST_EMPTY(&pg->md.mdpg_pvoh)) + vm_page_aflag_clear(pg, PGA_WRITEABLE); } } - - /* - * Remove this PVO from the PV and pmap lists. - */ - LIST_REMOVE(pvo, pvo_vlink); - RB_REMOVE(pvo_tree, &pvo->pvo_pmap->pmap_pvo, pvo); /* * Remove this from the overflow list and return it to the pool From owner-svn-src-stable-12@freebsd.org Wed Oct 23 13:41:45 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 926B3152E86; Wed, 23 Oct 2019 13:41:45 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46ys3s3HNKz48KB; Wed, 23 Oct 2019 13:41:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 54486254C2; Wed, 23 Oct 2019 13:41:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NDfjGR023200; Wed, 23 Oct 2019 13:41:45 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NDfieY023198; Wed, 23 Oct 2019 13:41:44 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910231341.x9NDfieY023198@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 23 Oct 2019 13:41:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353923 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 353923 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2019 13:41:45 -0000 Author: markj Date: Wed Oct 23 13:41:44 2019 New Revision: 353923 URL: https://svnweb.freebsd.org/changeset/base/353923 Log: MFC r353671: Use KOBJMETHOD_END in the kernel linker. Modified: stable/12/sys/kern/link_elf.c stable/12/sys/kern/link_elf_obj.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/link_elf.c ============================================================================== --- stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:26 2019 (r353922) +++ stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:44 2019 (r353923) @@ -179,7 +179,7 @@ static kobj_method_t link_elf_methods[] = { KOBJMETHOD(linker_ctf_get, link_elf_ctf_get), KOBJMETHOD(linker_symtab_get, link_elf_symtab_get), KOBJMETHOD(linker_strtab_get, link_elf_strtab_get), - { 0, 0 } + KOBJMETHOD_END }; static struct linker_class link_elf_class = { Modified: stable/12/sys/kern/link_elf_obj.c ============================================================================== --- stable/12/sys/kern/link_elf_obj.c Wed Oct 23 13:41:26 2019 (r353922) +++ stable/12/sys/kern/link_elf_obj.c Wed Oct 23 13:41:44 2019 (r353923) @@ -163,7 +163,7 @@ static kobj_method_t link_elf_methods[] = { KOBJMETHOD(linker_ctf_get, link_elf_ctf_get), KOBJMETHOD(linker_symtab_get, link_elf_symtab_get), KOBJMETHOD(linker_strtab_get, link_elf_strtab_get), - { 0, 0 } + KOBJMETHOD_END }; static struct linker_class link_elf_class = { From owner-svn-src-stable-12@freebsd.org Wed Oct 23 13:41:59 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CDCC7152F4B; Wed, 23 Oct 2019 13:41:59 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46ys4751D6z48SF; Wed, 23 Oct 2019 13:41:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8FDF4254D2; Wed, 23 Oct 2019 13:41:59 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NDfxR1023257; Wed, 23 Oct 2019 13:41:59 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NDfxOM023255; Wed, 23 Oct 2019 13:41:59 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910231341.x9NDfxOM023255@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 23 Oct 2019 13:41:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353924 - in stable/12/sys: amd64/amd64 kern X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 kern X-SVN-Commit-Revision: 353924 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2019 13:41:59 -0000 Author: markj Date: Wed Oct 23 13:41:58 2019 New Revision: 353924 URL: https://svnweb.freebsd.org/changeset/base/353924 Log: MFC r352623: Use elf_relocaddr() when handling R_X86_64_RELATIVE relocations. Modified: stable/12/sys/amd64/amd64/elf_machdep.c stable/12/sys/kern/link_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/elf_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/elf_machdep.c Wed Oct 23 13:41:44 2019 (r353923) +++ stable/12/sys/amd64/amd64/elf_machdep.c Wed Oct 23 13:41:58 2019 (r353924) @@ -268,7 +268,6 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas */ printf("kldload: unexpected R_COPY relocation\n"); return (-1); - break; case R_X86_64_GLOB_DAT: /* S */ case R_X86_64_JMP_SLOT: /* XXX need addend + offset */ @@ -280,7 +279,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbas break; case R_X86_64_RELATIVE: /* B + A */ - addr = relocbase + addend; + addr = elf_relocaddr(lf, relocbase + addend); val = addr; if (*where != val) *where = val; Modified: stable/12/sys/kern/link_elf.c ============================================================================== --- stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:44 2019 (r353923) +++ stable/12/sys/kern/link_elf.c Wed Oct 23 13:41:58 2019 (r353924) @@ -1163,6 +1163,9 @@ elf_relocaddr(linker_file_t lf, Elf_Addr x) { elf_file_t ef; + KASSERT(lf->ops->cls == (kobj_class_t)&link_elf_class, + ("elf_relocaddr: unexpected linker file %p", lf)); + ef = (elf_file_t)lf; if (x >= ef->pcpu_start && x < ef->pcpu_stop) return ((x - ef->pcpu_start) + ef->pcpu_base); From owner-svn-src-stable-12@freebsd.org Wed Oct 23 14:15:17 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B126B153D5C; Wed, 23 Oct 2019 14:15:17 +0000 (UTC) (envelope-from emaste@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46yspY4Dg6z4BH4; Wed, 23 Oct 2019 14:15:17 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 74EB825B4D; Wed, 23 Oct 2019 14:15:17 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9NEFHNX043456; Wed, 23 Oct 2019 14:15:17 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9NEFHI6043455; Wed, 23 Oct 2019 14:15:17 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201910231415.x9NEFHI6043455@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Wed, 23 Oct 2019 14:15:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353925 - stable/12/sys/dev/vt X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/sys/dev/vt X-SVN-Commit-Revision: 353925 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2019 14:15:17 -0000 Author: emaste Date: Wed Oct 23 14:15:16 2019 New Revision: 353925 URL: https://svnweb.freebsd.org/changeset/base/353925 Log: MFC r353680: vt: remove comment that is not true since r259680 r259680 added support to vt(4) for printing double-width characters. Remove the comment that claims no support. Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/dev/vt/vt_font.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/vt/vt_font.c ============================================================================== --- stable/12/sys/dev/vt/vt_font.c Wed Oct 23 13:41:58 2019 (r353924) +++ stable/12/sys/dev/vt/vt_font.c Wed Oct 23 14:15:16 2019 (r353925) @@ -92,11 +92,6 @@ vtfont_lookup(const struct vt_font *vf, term_char_t c) unsigned int normal_map; unsigned int bold_map; - /* - * No support for printing right hand sides for CJK fullwidth - * characters. Simply print a space and assume that the left - * hand side describes the entire character. - */ src = TCHAR_CHARACTER(c); if (TCHAR_FORMAT(c) & TF_CJK_RIGHT) { normal_map = VFNT_MAP_NORMAL_RIGHT; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:33:13 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 457EF1730AF; Thu, 24 Oct 2019 02:33:13 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBB1133bz48cm; Thu, 24 Oct 2019 02:33:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 069E1758D; Thu, 24 Oct 2019 02:33:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2XC7G087400; Thu, 24 Oct 2019 02:33:12 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2XCwu087399; Thu, 24 Oct 2019 02:33:12 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240233.x9O2XCwu087399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:33:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353975 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 353975 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:33:13 -0000 Author: kevans Date: Thu Oct 24 02:33:12 2019 New Revision: 353975 URL: https://svnweb.freebsd.org/changeset/base/353975 Log: MFC r344268: loader: ptable_close() should check its argument Modified: stable/12/stand/common/part.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/part.c ============================================================================== --- stable/12/stand/common/part.c Thu Oct 24 02:32:22 2019 (r353974) +++ stable/12/stand/common/part.c Thu Oct 24 02:33:12 2019 (r353975) @@ -788,6 +788,9 @@ ptable_close(struct ptable *table) { struct pentry *entry; + if (table == NULL) + return; + while (!STAILQ_EMPTY(&table->entries)) { entry = STAILQ_FIRST(&table->entries); STAILQ_REMOVE_HEAD(&table->entries, entry); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:27:17 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BCB39171EB2; Thu, 24 Oct 2019 02:27:17 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zB394sD2z47fc; Thu, 24 Oct 2019 02:27:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 79E6573D0; Thu, 24 Oct 2019 02:27:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2RHoU081498; Thu, 24 Oct 2019 02:27:17 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2RGGi081491; Thu, 24 Oct 2019 02:27:16 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240227.x9O2RGGi081491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:27:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353971 - in stable/12/stand/efi: include include/Guid include/Protocol libefi loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand/efi: include include/Guid include/Protocol libefi loader X-SVN-Commit-Revision: 353971 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:27:17 -0000 Author: kevans Date: Thu Oct 24 02:27:16 2019 New Revision: 353971 URL: https://svnweb.freebsd.org/changeset/base/353971 Log: MFC r342054-r342055, r342742: loader diagnostics r342054: Print an error message in efi_main.c if we can't allocate memory for the heap With the default Qemu parameters, only 128MB RAM gets given to a VM. This causes the loader to be unable to allocate the 64MB it needs for the heap. This change makes the cause of the error more obvious. r342055: Cast error message in efi_main.c to CHAR16* to avoid build error r342742: loader.efi: efi variable rework and lsefi command added This update does add diag and debug capabilities to interpret the efi variables, configuration and protocols (lsefi). The side effect is that we add/update bunch of related headers. Added: stable/12/stand/efi/include/Guid/ - copied from r342742, head/stand/efi/include/Guid/ stable/12/stand/efi/include/Protocol/ - copied from r342742, head/stand/efi/include/Protocol/ stable/12/stand/efi/include/efigpt.h - copied unchanged from r342742, head/stand/efi/include/efigpt.h stable/12/stand/efi/include/efiip.h - copied unchanged from r342742, head/stand/efi/include/efiip.h stable/12/stand/efi/include/efipoint.h - copied unchanged from r342742, head/stand/efi/include/efipoint.h stable/12/stand/efi/include/efitcp.h - copied unchanged from r342742, head/stand/efi/include/efitcp.h stable/12/stand/efi/include/efiudp.h - copied unchanged from r342742, head/stand/efi/include/efiudp.h Modified: stable/12/stand/efi/include/efi.h stable/12/stand/efi/include/efiapi.h stable/12/stand/efi/include/eficon.h stable/12/stand/efi/include/efidef.h stable/12/stand/efi/include/efilib.h stable/12/stand/efi/include/efipciio.h stable/12/stand/efi/libefi/env.c stable/12/stand/efi/loader/efi_main.c stable/12/stand/efi/loader/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/include/efi.h ============================================================================== --- stable/12/stand/efi/include/efi.h Thu Oct 24 02:25:33 2019 (r353970) +++ stable/12/stand/efi/include/efi.h Thu Oct 24 02:27:16 2019 (r353971) @@ -43,8 +43,10 @@ Revision History #include "efibind.h" #include "efidef.h" #include "efidevp.h" +#include "efipciio.h" #include "efiprot.h" #include "eficon.h" +#include "eficonsctl.h" #include "efiser.h" #include "efi_nii.h" #include "efipxebc.h" @@ -53,6 +55,11 @@ Revision History #include "efifs.h" #include "efierr.h" #include "efigop.h" +#include "efiip.h" +#include "efiudp.h" +#include "efitcp.h" +#include "efipoint.h" +#include "efiuga.h" /* * FreeBSD UUID Modified: stable/12/stand/efi/include/efiapi.h ============================================================================== --- stable/12/stand/efi/include/efiapi.h Thu Oct 24 02:25:33 2019 (r353970) +++ stable/12/stand/efi/include/efiapi.h Thu Oct 24 02:27:16 2019 (r353971) @@ -218,9 +218,13 @@ VOID { 0x8BE4DF61, 0x93CA, 0x11d2, {0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C} } // Variable attributes -#define EFI_VARIABLE_NON_VOLATILE 0x00000001 -#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 -#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_NON_VOLATILE 0x00000001 +#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002 +#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004 +#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008 +#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010 +#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020 +#define EFI_VARIABLE_APPEND_WRITE 0x00000040 // Variable size limitation #define EFI_MAXIMUM_VARIABLE_SIZE 1024 @@ -911,4 +915,282 @@ typedef struct _EFI_SYSTEM_TABLE { } EFI_SYSTEM_TABLE; +/* + * unlisted GUID's.. + */ +#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \ +{ 0x13AC6DD1, 0x73D0, 0x11D4, {0xB0, 0x6B, 0x00, 0xAA, 0x00, 0xBD, 0x6D, 0xE7} } + +#define EFI_DRIVER_CONFIGURATION2_PROTOCOL_GUID \ +{ 0xbfd7dc1d, 0x24f1, 0x40d9, {0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe} } + +#define EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID \ +{ 0x107a772b, 0xd5e1, 0x11d4, {0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_DRIVER_BINDING_PROTOCOL_GUID \ + { 0x18A031AB, 0xB443, 0x4D1A, \ + { 0xA5, 0xC0, 0x0C, 0x09, 0x26, 0x1E, 0x9F, 0x71 } \ + } + +#define EFI_TAPE_IO_PROTOCOL_GUID \ + { 0x1e93e633, 0xd65a, 0x459e, \ + { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \ + } + +#define EFI_SCSI_IO_PROTOCOL_GUID \ + { 0x932f47e6, 0x2362, 0x4002, \ + { 0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \ + } + +#define EFI_USB2_HC_PROTOCOL_GUID \ + { 0x3e745226, 0x9818, 0x45b6, \ + { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } \ + } + +#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \ + { 0x2755590C, 0x6F3C, 0x42FA, \ + { 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \ + } + +#define EFI_DEBUGPORT_PROTOCOL_GUID \ + { 0xEBA4E8D2, 0x3858, 0x41EC, \ + { 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 } \ + } + +#define EFI_DECOMPRESS_PROTOCOL_GUID \ + { 0xd8117cfe, 0x94a6, 0x11d4, \ + { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define EFI_ACPI_TABLE_PROTOCOL_GUID \ + { 0xffe06bdd, 0x6107, 0x46a6, \ + { 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c} \ + } + +#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \ + { 0x587e72d7, 0xcc50, 0x4f79, \ + { 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f } \ + } + +#define EFI_HII_DATABASE_PROTOCOL_GUID \ + { 0xef9fc172, 0xa1b2, 0x4693, \ + { 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 } \ + } + +#define EFI_HII_STRING_PROTOCOL_GUID \ + { 0xfd96974, 0x23aa, 0x4cdc, \ + { 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a } \ + } + +#define EFI_HII_IMAGE_PROTOCOL_GUID \ + { 0x31a6406a, 0x6bdf, 0x4e46, \ + { 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 } \ + } + +#define EFI_HII_FONT_PROTOCOL_GUID \ + { 0xe9ca4775, 0x8657, 0x47fc, \ + { 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 } \ + } +#define EFI_HII_CONFIGURATION_ACCESS_PROTOCOL_GUID \ + { 0x330d4706, 0xf2a0, 0x4e4f, \ + { 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 } \ + } + +#define EFI_COMPONENT_NAME_PROTOCOL_GUID \ +{ 0x107a772c, 0xd5e1, 0x11d4, {0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \ + { 0x6a7a5cff, 0xe8d9, 0x4f70, \ + { 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14} \ + } + +#define EFI_USB_IO_PROTOCOL_GUID \ + { 0x2B2F68D6, 0x0CD2, 0x44cf, \ + { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \ + } +#define EFI_HCDP_TABLE_GUID \ + { 0xf951938d, 0x620b, 0x42ef, \ + { 0x82, 0x79, 0xa8, 0x4b, 0x79, 0x61, 0x78, 0x98 } \ + } + +#define EFI_DEVICE_TREE_GUID \ + { 0xb1b621d5, 0xf19c, 0x41a5, \ + { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } \ + } + +#define EFI_VENDOR_APPLE_GUID \ + { 0x2B0585EB, 0xD8B8, 0x49A9, \ + { 0x8B, 0x8C, 0xE2, 0x1B, 0x01, 0xAE, 0xF2, 0xB7 } \ + } + +#define EFI_CONSOLE_IN_DEVICE_GUID \ +{ 0xd3b36f2b, 0xd551, 0x11d4, {0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_CONSOLE_OUT_DEVICE_GUID \ +{ 0xd3b36f2c, 0xd551, 0x11d4, {0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_STANDARD_ERROR_DEVICE_GUID \ +{ 0xd3b36f2d, 0xd551, 0x11d4, {0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_UNICODE_COLLATION2_PROTOCOL_GUID \ +{ 0xa4c751fc, 0x23ae, 0x4c3e, {0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49} } + +#define EFI_FORM_BROWSER2_PROTOCOL_GUID \ +{ 0xb9d4c360, 0xbcfb, 0x4f9b, {0x92, 0x98, 0x53, 0xc1, 0x36, 0x98, 0x22, 0x58} } + +#define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0xf44c00ee, 0x1f2c, 0x4a00, {0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3} } + +#define EFI_ARP_PROTOCOL_GUID \ +{ 0xf4b427bb, 0xba21, 0x4f16, {0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c} } + +#define EFI_IP4_CONFIG_PROTOCOL_GUID \ +{ 0x3b95aa31, 0x3793, 0x434b, {0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e} } + +#define EFI_IP6_CONFIG_PROTOCOL_GUID \ +{ 0x937fe521, 0x95ae, 0x4d1a, {0x89, 0x29, 0x48, 0xbc, 0xd9, 0x0a, 0xd3, 0x1a} } + +#define EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0xf36ff770, 0xa7e1, 0x42cf, {0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c} } + +#define EFI_MANAGED_NETWORK_PROTOCOL_GUID \ +{ 0x7ab33a91, 0xace5, 0x4326, {0xb5, 0x72, 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16} } + +#define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0x2FE800BE, 0x8F01, 0x4aa6, {0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F} } + +#define EFI_MTFTP4_PROTOCOL_GUID \ +{ 0x78247c57, 0x63db, 0x4708, {0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b} } + +#define EFI_MTFTP6_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0xd9760ff3, 0x3cca, 0x4267, {0x80, 0xf9, 0x75, 0x27, 0xfa, 0xfa, 0x42, 0x23} } + +#define EFI_MTFTP6_PROTOCOL_GUID \ +{ 0xbf0a78ba, 0xec29, 0x49cf, {0xa1, 0xc9, 0x7a, 0xe5, 0x4e, 0xab, 0x6a, 0x51} } + +#define EFI_DHCP4_PROTOCOL_GUID \ +{ 0x8a219718, 0x4ef5, 0x4761, {0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56} } + +#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0x9d9a39d8, 0xbd42, 0x4a73, {0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80} } + +#define EFI_DHCP6_SERVICE_BINDING_PROTOCOL_GUID \ +{ 0x9fb9a8a1, 0x2f4a, 0x43a6, {0x88, 0x9c, 0xd0, 0xf7, 0xb6, 0xc4, 0x7a, 0xd5} } + +#define EFI_DHCP6_PROTOCOL_GUID \ +{ 0x87c8bad7, 0x595, 0x4053, {0x82, 0x97, 0xde, 0xde, 0x39, 0x5f, 0x5d, 0x5b} } + +#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \ +{ 0xa59e8fcf, 0xbda0, 0x43bb, {0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77} } + +#define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \ +{ 0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe} } + +#define EFI_DISK_INFO_PROTOCOL_GUID \ +{ 0xd432a67f, 0x14dc, 0x484b, {0xb3, 0xbb, 0x3f, 0x2, 0x91, 0x84, 0x93, 0x27} } + +#define EFI_ISA_IO_PROTOCOL_GUID \ +{ 0x7ee2bd44, 0x3da0, 0x11d4, { 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_VLAN_CONFIG_PROTOCOL_GUID \ +{ 0x9e23d768, 0xd2f3, 0x4366, {0x9f, 0xc3, 0x3a, 0x7a, 0xba, 0x86, 0x43, 0x74} } + +#define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \ +{ 0xa1e37052, 0x80d9, 0x4e65, {0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9} } + +#define EFI_ISA_ACPI_PROTOCOL_GUID \ +{ 0x64a892dc, 0x5561, 0x4536, {0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55} } + +#define EFI_PCI_ENUMERATION_COMPLETE_GUID \ +{ 0x30cfe3e7, 0x3de1, 0x4586, {0xbe, 0x20, 0xde, 0xab, 0xa1, 0xb3, 0xb7, 0x93} } + +#define EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID \ +{ 0x0784924f, 0xe296, 0x11d4, {0x9a, 0x49, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d } } + +#define EFI_DRIVER_DIAGNOSTICS2_PROTOCOL_GUID \ +{ 0x4d330321, 0x025f, 0x4aac, {0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63} } + +#define EFI_CAPSULE_ARCH_PROTOCOL_GUID \ +{ 0x5053697e, 0x2cbc, 0x4819, {0x90, 0xd9, 0x05, 0x80, 0xde, 0xee, 0x57, 0x54} } + +#define EFI_MONOTONIC_COUNTER_ARCH_PROTOCOL_GUID \ +{0x1da97072, 0xbddc, 0x4b30, {0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a} } + +#define EFI_REALTIME_CLOCK_ARCH_PROTOCOL_GUID \ +{0x27cfac87, 0x46cc, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_MP_SERVICES_PROTOCOL_GUID \ +{ 0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08} } + +#define EFI_VARIABLE_ARCH_PROTOCOL_GUID \ +{ 0x1e5668e2, 0x8481, 0x11d4, {0xbc, 0xf1, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } + +#define EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID \ +{ 0x6441f818, 0x6362, 0x4e44, {0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53} } + +#define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \ +{ 0x6441f818, 0x6362, 0x4e44, {0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53} } + +#define EFI_ACPI_SUPPORT_PROTOCOL_GUID \ +{ 0x6441f818, 0x6362, 0x4e44, {0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53} } + +#define EFI_BDS_ARCH_PROTOCOL_GUID \ +{ 0x665e3ff6, 0x46cc, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_METRONOME_ARCH_PROTOCOL_GUID \ +{ 0x26baccb2, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } + +#define EFI_TIMER_ARCH_PROTOCOL_GUID \ +{ 0x26baccb3, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } + +#define EFI_DPC_PROTOCOL_GUID \ +{ 0x480f8ae9, 0xc46, 0x4aa9, { 0xbc, 0x89, 0xdb, 0x9f, 0xba, 0x61, 0x98, 0x6} } + +#define EFI_PRINT2_PROTOCOL_GUID \ +{ 0xf05976ef, 0x83f1, 0x4f3d, {0x86, 0x19, 0xf7, 0x59, 0x5d, 0x41, 0xe5, 0x38} } + +#define EFI_RESET_ARCH_PROTOCOL_GUID \ +{ 0x27cfac88, 0x46cc, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } + +#define EFI_CPU_ARCH_PROTOCOL_GUID \ +{ 0x26baccb1, 0x6f42, 0x11d4, {0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 } } + +#define EFI_CPU_IO2_PROTOCOL_GUID \ +{ 0xad61f191, 0xae5f, 0x4c0e, {0xb9, 0xfa, 0xe8, 0x69, 0xd2, 0x88, 0xc6, 0x4f} } + +#define EFI_LEGACY_8259_PROTOCOL_GUID \ +{ 0x38321dba, 0x4fe0, 0x4e17, {0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1} } + +#define EFI_SECURITY_ARCH_PROTOCOL_GUID \ +{ 0xa46423e3, 0x4617, 0x49f1, {0xb9, 0xff, 0xd1, 0xbf, 0xa9, 0x11, 0x58, 0x39} } + +#define EFI_SECURITY2_ARCH_PROTOCOL_GUID \ +{ 0x94ab2f58, 0x1438, 0x4ef1, {0x91, 0x52, 0x18, 0x94, 0x1a, 0x3a, 0x0e, 0x68} } + +#define EFI_RUNTIME_ARCH_PROTOCOL_GUID \ +{ 0xb7dfb4e1, 0x52f, 0x449f, {0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33} } + +#define EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID \ +{ 0xd2b2b828, 0x826, 0x48a7, {0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0} } + +#define EFI_DATA_HUB_PROTOCOL_GUID \ +{ 0xae80d021, 0x618e, 0x11d4, {0xbc, 0xd7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81} } + +#define PCD_PROTOCOL_GUID \ +{ 0x11b34006, 0xd85b, 0x4d0a, { 0xa2, 0x90, 0xd5, 0xa5, 0x71, 0x31, 0xe, 0xf7} } + +#define EFI_PCD_PROTOCOL_GUID \ +{ 0x13a3f0f6, 0x264a, 0x3ef0, {0xf2, 0xe0, 0xde, 0xc5, 0x12, 0x34, 0x2f, 0x34} } + +#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \ +{ 0x8f644fa9, 0xe850, 0x4db1, {0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 } } + +#define EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID \ +{ 0x220e73b6, 0x6bdb, 0x4413, { 0x84, 0x5, 0xb9, 0x74, 0xb1, 0x8, 0x61, 0x9a } } + +#define EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID \ +{ 0x7aa35a69, 0x506c, 0x444f, {0xa7, 0xaf, 0x69, 0x4b, 0xf5, 0x6f, 0x71, 0xc8} } + +#define LZMA_COMPRESS_GUID \ +{ 0xee4e5898, 0x3914, 0x4259, {0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf} } #endif Modified: stable/12/stand/efi/include/eficon.h ============================================================================== --- stable/12/stand/efi/include/eficon.h Thu Oct 24 02:25:33 2019 (r353970) +++ stable/12/stand/efi/include/eficon.h Thu Oct 24 02:27:16 2019 (r353971) @@ -263,29 +263,57 @@ typedef struct { // Scan codes for base line keys // -#define SCAN_NULL 0x0000 -#define SCAN_UP 0x0001 -#define SCAN_DOWN 0x0002 -#define SCAN_RIGHT 0x0003 -#define SCAN_LEFT 0x0004 -#define SCAN_HOME 0x0005 -#define SCAN_END 0x0006 -#define SCAN_INSERT 0x0007 -#define SCAN_DELETE 0x0008 -#define SCAN_PAGE_UP 0x0009 -#define SCAN_PAGE_DOWN 0x000A -#define SCAN_F1 0x000B -#define SCAN_F2 0x000C -#define SCAN_F3 0x000D -#define SCAN_F4 0x000E -#define SCAN_F5 0x000F -#define SCAN_F6 0x0010 -#define SCAN_F7 0x0011 -#define SCAN_F8 0x0012 -#define SCAN_F9 0x0013 -#define SCAN_F10 0x0014 -#define SCAN_ESC 0x0017 +#define SCAN_NULL 0x0000 +#define SCAN_UP 0x0001 +#define SCAN_DOWN 0x0002 +#define SCAN_RIGHT 0x0003 +#define SCAN_LEFT 0x0004 +#define SCAN_HOME 0x0005 +#define SCAN_END 0x0006 +#define SCAN_INSERT 0x0007 +#define SCAN_DELETE 0x0008 +#define SCAN_PAGE_UP 0x0009 +#define SCAN_PAGE_DOWN 0x000A +#define SCAN_F1 0x000B +#define SCAN_F2 0x000C +#define SCAN_F3 0x000D +#define SCAN_F4 0x000E +#define SCAN_F5 0x000F +#define SCAN_F6 0x0010 +#define SCAN_F7 0x0011 +#define SCAN_F8 0x0012 +#define SCAN_F9 0x0013 +#define SCAN_F10 0x0014 +#define SCAN_ESC 0x0017 +// +// EFI Scan code Ex +// +#define SCAN_F11 0x0015 +#define SCAN_F12 0x0016 +#define SCAN_F13 0x0068 +#define SCAN_F14 0x0069 +#define SCAN_F15 0x006A +#define SCAN_F16 0x006B +#define SCAN_F17 0x006C +#define SCAN_F18 0x006D +#define SCAN_F19 0x006E +#define SCAN_F20 0x006F +#define SCAN_F21 0x0070 +#define SCAN_F22 0x0071 +#define SCAN_F23 0x0072 +#define SCAN_F24 0x0073 +#define SCAN_MUTE 0x007F +#define SCAN_VOLUME_UP 0x0080 +#define SCAN_VOLUME_DOWN 0x0081 +#define SCAN_BRIGHTNESS_UP 0x0100 +#define SCAN_BRIGHTNESS_DOWN 0x0101 +#define SCAN_SUSPEND 0x0102 +#define SCAN_HIBERNATE 0x0103 +#define SCAN_TOGGLE_DISPLAY 0x0104 +#define SCAN_RECOVERY 0x0105 +#define SCAN_EJECT 0x0106 + typedef EFI_STATUS (EFIAPI *EFI_INPUT_RESET) ( @@ -305,5 +333,195 @@ typedef struct _SIMPLE_INPUT_INTERFACE { EFI_INPUT_READ_KEY ReadKeyStroke; EFI_EVENT WaitForKey; } SIMPLE_INPUT_INTERFACE; + +#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ + {0xdd9e7534, 0x7762, 0x4698, {0x8c, 0x14, 0xf5, 0x85, \ + 0x17, 0xa6, 0x25, 0xaa} } + +INTERFACE_DECL(_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL); + +typedef UINT8 EFI_KEY_TOGGLE_STATE; +// +// Any Shift or Toggle State that is valid should have +// high order bit set. +// +typedef struct EFI_KEY_STATE { + UINT32 KeyShiftState; + EFI_KEY_TOGGLE_STATE KeyToggleState; +} EFI_KEY_STATE; + +typedef struct { + EFI_INPUT_KEY Key; + EFI_KEY_STATE KeyState; +} EFI_KEY_DATA; + +// +// Shift state +// +#define EFI_SHIFT_STATE_VALID 0x80000000 +#define EFI_RIGHT_SHIFT_PRESSED 0x00000001 +#define EFI_LEFT_SHIFT_PRESSED 0x00000002 +#define EFI_RIGHT_CONTROL_PRESSED 0x00000004 +#define EFI_LEFT_CONTROL_PRESSED 0x00000008 +#define EFI_RIGHT_ALT_PRESSED 0x00000010 +#define EFI_LEFT_ALT_PRESSED 0x00000020 +#define EFI_RIGHT_LOGO_PRESSED 0x00000040 +#define EFI_LEFT_LOGO_PRESSED 0x00000080 +#define EFI_MENU_KEY_PRESSED 0x00000100 +#define EFI_SYS_REQ_PRESSED 0x00000200 + +// +// Toggle state +// +#define EFI_TOGGLE_STATE_VALID 0x80 +#define EFI_KEY_STATE_EXPOSED 0x40 +#define EFI_SCROLL_LOCK_ACTIVE 0x01 +#define EFI_NUM_LOCK_ACTIVE 0x02 +#define EFI_CAPS_LOCK_ACTIVE 0x04 + +// +// EFI Key Notfication Function +// +typedef +EFI_STATUS +(EFIAPI *EFI_KEY_NOTIFY_FUNCTION) ( + IN EFI_KEY_DATA *KeyData + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_RESET_EX) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN BOOLEAN ExtendedVerification + ) +/*++ + + Routine Description: + Reset the input device and optionaly run diagnostics + + Arguments: + This - Protocol instance pointer. + ExtendedVerification - Driver may perform diagnostics on reset. + + Returns: + EFI_SUCCESS - The device was reset. + EFI_DEVICE_ERROR - The device is not functioning properly and could + not be reset. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_INPUT_READ_KEY_EX) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + OUT EFI_KEY_DATA *KeyData + ) +/*++ + + Routine Description: + Reads the next keystroke from the input device. The WaitForKey Event can + be used to test for existance of a keystroke via WaitForEvent () call. + + Arguments: + This - Protocol instance pointer. + KeyData - A pointer to a buffer that is filled in with the keystroke + state data for the key that was pressed. + + Returns: + EFI_SUCCESS - The keystroke information was returned. + EFI_NOT_READY - There was no keystroke data availiable. + EFI_DEVICE_ERROR - The keystroke information was not returned due to + hardware errors. + EFI_INVALID_PARAMETER - KeyData is NULL. +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_SET_STATE) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN EFI_KEY_TOGGLE_STATE *KeyToggleState + ) +/*++ + + Routine Description: + Set certain state for the input device. + + Arguments: + This - Protocol instance pointer. + KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the + state for the input device. + + Returns: + EFI_SUCCESS - The device state was set successfully. + EFI_DEVICE_ERROR - The device is not functioning correctly and could + not have the setting adjusted. + EFI_UNSUPPORTED - The device does not have the ability to set its state. + EFI_INVALID_PARAMETER - KeyToggleState is NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN EFI_KEY_DATA *KeyData, + IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction, + OUT EFI_HANDLE *NotifyHandle + ) +/*++ + + Routine Description: + Register a notification function for a particular keystroke for the input device. + + Arguments: + This - Protocol instance pointer. + KeyData - A pointer to a buffer that is filled in with the keystroke + information data for the key that was pressed. + KeyNotificationFunction - Points to the function to be called when the key + sequence is typed specified by KeyData. + NotifyHandle - Points to the unique handle assigned to the registered notification. + + Returns: + EFI_SUCCESS - The notification function was registered successfully. + EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures. + EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL. + +--*/ +; + +typedef +EFI_STATUS +(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) ( + IN struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This, + IN EFI_HANDLE NotificationHandle + ) +/*++ + + Routine Description: + Remove a registered notification function from a particular keystroke. + + Arguments: + This - Protocol instance pointer. + NotificationHandle - The handle of the notification function being unregistered. + + Returns: + EFI_SUCCESS - The notification function was unregistered successfully. + EFI_INVALID_PARAMETER - The NotificationHandle is invalid. + EFI_NOT_FOUND - Can not find the matching entry in database. + +--*/ +; + +typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL { + EFI_INPUT_RESET_EX Reset; + EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx; + EFI_EVENT WaitForKeyEx; + EFI_SET_STATE SetState; + EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify; + EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify; +} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL; #endif Modified: stable/12/stand/efi/include/efidef.h ============================================================================== --- stable/12/stand/efi/include/efidef.h Thu Oct 24 02:25:33 2019 (r353970) +++ stable/12/stand/efi/include/efidef.h Thu Oct 24 02:27:16 2019 (r353971) @@ -121,6 +121,19 @@ typedef struct { UINT8 Addr[32]; } EFI_MAC_ADDRESS; +typedef struct { + UINT32 ReceivedQueueTimeoutValue; + UINT32 TransmitQueueTimeoutValue; + UINT16 ProtocolTypeFilter; + BOOLEAN EnableUnicastReceive; + BOOLEAN EnableMulticastReceive; + BOOLEAN EnableBroadcastReceive; + BOOLEAN EnablePromiscuousReceive; + BOOLEAN FlushQueuesOnReset; + BOOLEAN EnableReceiveTimestamps; + BOOLEAN DisableBackgroundPolling; +} EFI_MANAGED_NETWORK_CONFIG_DATA; + // // Memory // Copied: stable/12/stand/efi/include/efigpt.h (from r342742, head/stand/efi/include/efigpt.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/include/efigpt.h Thu Oct 24 02:27:16 2019 (r353971, copy of r342742, head/stand/efi/include/efigpt.h) @@ -0,0 +1,69 @@ +/* $FreeBSD$ */ +#ifndef _EFI_GPT_H +#define _EFI_GPT_H +/*++ + +Copyright (c) 1998 Intel Corporation + +Module Name: + + EfiGpt.h + +Abstract: + Include file for EFI partitioning scheme + + + +Revision History + +--*/ + +#define PRIMARY_PART_HEADER_LBA 1 + +typedef struct { + EFI_TABLE_HEADER Header; + EFI_LBA MyLBA; + EFI_LBA AlternateLBA; + EFI_LBA FirstUsableLBA; + EFI_LBA LastUsableLBA; + EFI_GUID DiskGUID; + EFI_LBA PartitionEntryLBA; + UINT32 NumberOfPartitionEntries; + UINT32 SizeOfPartitionEntry; + UINT32 PartitionEntryArrayCRC32; +} EFI_PARTITION_TABLE_HEADER; + +#define EFI_PTAB_HEADER_ID "EFI PART" + +typedef struct { + EFI_GUID PartitionTypeGUID; + EFI_GUID UniquePartitionGUID; + EFI_LBA StartingLBA; + EFI_LBA EndingLBA; + UINT64 Attributes; + CHAR16 PartitionName[36]; +} EFI_PARTITION_ENTRY; + +// +// EFI Partition Attributes +// +#define EFI_PART_USED_BY_EFI 0x0000000000000001 +#define EFI_PART_REQUIRED_TO_FUNCTION 0x0000000000000002 +#define EFI_PART_USED_BY_OS 0x0000000000000004 +#define EFI_PART_REQUIRED_BY_OS 0x0000000000000008 +#define EFI_PART_BACKUP_REQUIRED 0x0000000000000010 +#define EFI_PART_USER_DATA 0x0000000000000020 +#define EFI_PART_CRITICAL_USER_DATA 0x0000000000000040 +#define EFI_PART_REDUNDANT_PARTITION 0x0000000000000080 + +#define EFI_PART_TYPE_UNUSED_GUID \ + { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} } + +#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \ + { 0xc12a7328, 0xf81f, 0x11d2, {0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b} } + +#define EFI_PART_TYPE_LEGACY_MBR_GUID \ + { 0x024dee41, 0x33e7, 0x11d3, {0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f} } + +#endif + Copied: stable/12/stand/efi/include/efiip.h (from r342742, head/stand/efi/include/efiip.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/include/efiip.h Thu Oct 24 02:27:16 2019 (r353971, copy of r342742, head/stand/efi/include/efiip.h) @@ -0,0 +1,460 @@ +/* $FreeBSD$ */ +#ifndef _EFI_IP_H +#define _EFI_IP_H + +/*++ +Copyright (c) 2013 Intel Corporation + +--*/ + +#define EFI_IP4_SERVICE_BINDING_PROTOCOL \ + {0xc51711e7,0xb4bf,0x404a,{0xbf,0xb8,0x0a,0x04, 0x8e,0xf1,0xff,0xe4}} + +#define EFI_IP4_PROTOCOL \ + {0x41d94cd2,0x35b6,0x455a,{0x82,0x58,0xd4,0xe5,0x13,0x34,0xaa,0xdd}} + +#define EFI_IP6_SERVICE_BINDING_PROTOCOL \ + {0xec835dd3,0xfe0f,0x617b,{0xa6,0x21,0xb3,0x50,0xc3,0xe1,0x33,0x88}} + +#define EFI_IP6_PROTOCOL \ + {0x2c8759d5,0x5c2d,0x66ef,{0x92,0x5f,0xb6,0x6c,0x10,0x19,0x57,0xe2}} + +INTERFACE_DECL(_EFI_IP4); +INTERFACE_DECL(_EFI_IP6); + +typedef struct { + EFI_HANDLE InstanceHandle; + EFI_IPv4_ADDRESS Ip4Address; + EFI_IPv4_ADDRESS SubnetMask; +} EFI_IP4_ADDRESS_PAIR; + +typedef struct { + EFI_HANDLE DriverHandle; + UINT32 AddressCount; + EFI_IP4_ADDRESS_PAIR AddressPairs[1]; +} EFI_IP4_VARIABLE_DATA; + +typedef struct { + UINT8 DefaultProtocol; + BOOLEAN AcceptAnyProtocol; + BOOLEAN AcceptIcmpErrors; + BOOLEAN AcceptBroadcast; + BOOLEAN AcceptPromiscuous; + BOOLEAN UseDefaultAddress; + EFI_IPv4_ADDRESS StationAddress; + EFI_IPv4_ADDRESS SubnetMask; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; + BOOLEAN RawData; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; +} EFI_IP4_CONFIG_DATA; + +typedef struct { + EFI_IPv4_ADDRESS SubnetAddress; + EFI_IPv4_ADDRESS SubnetMask; + EFI_IPv4_ADDRESS GatewayAddress; +} EFI_IP4_ROUTE_TABLE; + +typedef struct { + UINT8 Type; + UINT8 Code; +} EFI_IP4_ICMP_TYPE; + +typedef struct { + BOOLEAN IsStarted; + UINT32 MaxPacketSize; + EFI_IP4_CONFIG_DATA ConfigData; + BOOLEAN IsConfigured; + UINT32 GroupCount; + EFI_IPv4_ADDRESS *GroupTable; + UINT32 RouteCount; + EFI_IP4_ROUTE_TABLE *RouteTable; + UINT32 IcmpTypeCount; + EFI_IP4_ICMP_TYPE *IcmpTypeList; +} EFI_IP4_MODE_DATA; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GET_MODE_DATA) ( + IN struct _EFI_IP4 *This, + OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL, + OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL, + OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIGURE) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_GROUPS) ( + IN struct _EFI_IP4 *This, + IN BOOLEAN JoinFlag, + IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_ROUTES) ( + IN struct _EFI_IP4 *This, + IN BOOLEAN DeleteRoute, + IN EFI_IPv4_ADDRESS *SubnetAddress, + IN EFI_IPv4_ADDRESS *SubnetMask, + IN EFI_IPv4_ADDRESS *GatewayAddress + ); + +#pragma pack(1) +typedef struct { + UINT8 HeaderLength:4; + UINT8 Version:4; + UINT8 TypeOfService; + UINT16 TotalLength; + UINT16 Identification; + UINT16 Fragmentation; + UINT8 TimeToLive; + UINT8 Protocol; + UINT16 Checksum; + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS DestinationAddress; +} EFI_IP4_HEADER; +#pragma pack() + +typedef struct { + UINT32 FragmentLength; + VOID *FragmentBuffer; +} EFI_IP4_FRAGMENT_DATA; + +typedef struct { + EFI_TIME TimeStamp; + EFI_EVENT RecycleSignal; + UINT32 HeaderLength; + EFI_IP4_HEADER *Header; + UINT32 OptionsLength; + VOID *Options; + UINT32 DataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_RECEIVE_DATA; + +typedef struct { + EFI_IPv4_ADDRESS SourceAddress; + EFI_IPv4_ADDRESS GatewayAddress; + UINT8 Protocol; + UINT8 TypeOfService; + UINT8 TimeToLive; + BOOLEAN DoNotFragment; +} EFI_IP4_OVERRIDE_DATA; + +typedef struct { + EFI_IPv4_ADDRESS DestinationAddress; + EFI_IP4_OVERRIDE_DATA *OverrideData; + UINT32 OptionsLength; + VOID *OptionsBuffer; + UINT32 TotalDataLength; + UINT32 FragmentCount; + EFI_IP4_FRAGMENT_DATA FragmentTable[1]; +} EFI_IP4_TRANSMIT_DATA; + +typedef struct { + EFI_EVENT Event; + EFI_STATUS Status; + union { + EFI_IP4_RECEIVE_DATA *RxData; + EFI_IP4_TRANSMIT_DATA *TxData; + } Packet; +} EFI_IP4_COMPLETION_TOKEN; + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_TRANSMIT) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_RECEIVE) ( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CANCEL)( + IN struct _EFI_IP4 *This, + IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL + ); + +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_POLL) ( + IN struct _EFI_IP4 *This + ); + +typedef struct _EFI_IP4 { + EFI_IP4_GET_MODE_DATA GetModeData; + EFI_IP4_CONFIGURE Configure; + EFI_IP4_GROUPS Groups; + EFI_IP4_ROUTES Routes; + EFI_IP4_TRANSMIT Transmit; + EFI_IP4_RECEIVE Receive; + EFI_IP4_CANCEL Cancel; + EFI_IP4_POLL Poll; +} EFI_IP4; + +typedef struct { + UINT8 DefaultProtocol; + BOOLEAN AcceptAnyProtocol; + BOOLEAN AcceptIcmpErrors; + BOOLEAN AcceptPromiscuous; + EFI_IPv6_ADDRESS DestinationAddress; + EFI_IPv6_ADDRESS StationAddress; + UINT8 TrafficClass; + UINT8 HopLimit; + UINT32 FlowLabel; + UINT32 ReceiveTimeout; + UINT32 TransmitTimeout; +} EFI_IP6_CONFIG_DATA; + +typedef struct { + EFI_IPv6_ADDRESS Address; + UINT8 PrefixLength; +} EFI_IP6_ADDRESS_INFO; + +typedef struct { + EFI_IPv6_ADDRESS Gateway; + EFI_IPv6_ADDRESS Destination; + UINT8 PrefixLength; +} EFI_IP6_ROUTE_TABLE; + +typedef enum { + EfiNeighborInComplete, + EfiNeighborReachable, + EfiNeighborStale, + EfiNeighborDelay, + EfiNeighborProbe +} EFI_IP6_NEIGHBOR_STATE; + +typedef struct { + EFI_IPv6_ADDRESS Neighbor; + EFI_MAC_ADDRESS LinkAddress; + EFI_IP6_NEIGHBOR_STATE State; +} EFI_IP6_NEIGHBOR_CACHE; + +typedef struct { + UINT8 Type; + UINT8 Code; +} EFI_IP6_ICMP_TYPE; + +//*********************************************************** +// ICMPv6 type definitions for error messages +//*********************************************************** +#define ICMP_V6_DEST_UNREACHABLE 0x1 +#define ICMP_V6_PACKET_TOO_BIG 0x2 +#define ICMP_V6_TIME_EXCEEDED 0x3 +#define ICMP_V6_PARAMETER_PROBLEM 0x4 + +//*********************************************************** +// ICMPv6 type definition for informational messages +//*********************************************************** +#define ICMP_V6_ECHO_REQUEST 0x80 +#define ICMP_V6_ECHO_REPLY 0x81 +#define ICMP_V6_LISTENER_QUERY 0x82 +#define ICMP_V6_LISTENER_REPORT 0x83 +#define ICMP_V6_LISTENER_DONE 0x84 +#define ICMP_V6_ROUTER_SOLICIT 0x85 +#define ICMP_V6_ROUTER_ADVERTISE 0x86 +#define ICMP_V6_NEIGHBOR_SOLICIT 0x87 +#define ICMP_V6_NEIGHBOR_ADVERTISE 0x88 +#define ICMP_V6_REDIRECT 0x89 +#define ICMP_V6_LISTENER_REPORT_2 0x8F + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_DEST_UNREACHABLE +//*********************************************************** +#define ICMP_V6_NO_ROUTE_TO_DEST 0x0 +#define ICMP_V6_COMM_PROHIBITED 0x1 +#define ICMP_V6_BEYOND_SCOPE 0x2 +#define ICMP_V6_ADDR_UNREACHABLE 0x3 +#define ICMP_V6_PORT_UNREACHABLE 0x4 +#define ICMP_V6_SOURCE_ADDR_FAILED 0x5 +#define ICMP_V6_ROUTE_REJECTED 0x6 + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_TIME_EXCEEDED +//*********************************************************** +#define ICMP_V6_TIMEOUT_HOP_LIMIT 0x0 +#define ICMP_V6_TIMEOUT_REASSEMBLE 0x1 + +//*********************************************************** +// ICMPv6 code definitions for ICMP_V6_PARAMETER_PROBLEM +//*********************************************************** +#define ICMP_V6_ERRONEOUS_HEADER 0x0 *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:43:41 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4716D174DDA; Thu, 24 Oct 2019 02:43:41 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBQ51tDdz4BNn; Thu, 24 Oct 2019 02:43:41 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 225F57745; Thu, 24 Oct 2019 02:43:41 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2hfB8093434; Thu, 24 Oct 2019 02:43:41 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2hcbK093423; Thu, 24 Oct 2019 02:43:38 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240243.x9O2hcbK093423@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:43:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353979 - in stable/12/stand/efi: boot1 include libefi loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand/efi: boot1 include libefi loader X-SVN-Commit-Revision: 353979 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:43:41 -0000 Author: kevans Date: Thu Oct 24 02:43:38 2019 New Revision: 353979 URL: https://svnweb.freebsd.org/changeset/base/353979 Log: MFC r346345-r346346, r346353, r346407-r346409, r346430, r346573, r346575 r346345: Add a more generic efi_setenv function. efi_setenv allows any UEFI variable to be set. r346346: Add efi_delenv Add an interface to remove / delete UEFI variables. r346353: Minor tweak to the debug Make it clear we're loading from UFS. r346407: Add define for CONST. Newer interfaces take CONST parameters, so define CONST to minimize differences between our headers and the standards docs. r346408: Add UEFI definitions related to converting string to DEVICE_PATH Add definitions from UEFI 2.7 Errata B standards doc for converting a text string to a device path. Added clearly missing 'e' at the end of Device to resolve mismatch in that document in EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL element names. r346409: Add wrapper functions to convert strings to EFI_DEVICE_PATH In anticipation of new functionality, create routines to convert char * and a CHAR16 * to a EFI_DEVICE_PATH EFI_DEVICE_PATH *efi_name_to_devpath(const char *path); EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path); void efi_devpath_free(EFI_DEVICE_PATH *dp); The first two return an EFI_DEVICE_PATH for the passed in paths. The third frees up the storage the first two return when the caller is done with it. r346430: Start to reduce the number of #ifdef EFI_ZFS_BOOT There's a number of EFI_ZFS_BOOT #ifdefs that aren't needed, or can be eliminated with some trivial #defines. Remove the EFI_ZFS_BOOT ifdefs that aren't needed. Replace libzfs.h include which is not safe to include without EFI_ZFS_BOOT with efizfs.h which is and now conditionally included libzfs.h. Define efizfs_set_preferred away and define efi_zfs_probe to NULL when ZFS is compiled out. r346573: Move setting of console earlier in boot. There's no reason we can't setup the console first thing after the arch flags are setup. We set it undconditionally to efi. This is a good default, and will get us error messages to at least the efi console no matter what. This will also prime the pump so that as other variables are set, they will take effect and the console will be correct as soon as those env vars are set. Also remove the redundant setting of the console to efi when we know the console is efi. r346575: Create boot_img as a global variable Get the information from the image that we're booting and store it in a global variable. Prefer using this to passing it around. Remove the special case for zfs that set the preferred boot handle by having it uses this global variable diretly. Modified: stable/12/stand/efi/boot1/ufs_module.c stable/12/stand/efi/include/efi.h stable/12/stand/efi/include/efidef.h stable/12/stand/efi/include/efidevp.h stable/12/stand/efi/include/efilib.h stable/12/stand/efi/include/efizfs.h stable/12/stand/efi/libefi/devicename.c stable/12/stand/efi/libefi/devpath.c stable/12/stand/efi/libefi/efienv.c stable/12/stand/efi/libefi/efizfs.c stable/12/stand/efi/loader/conf.c stable/12/stand/efi/loader/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/boot1/ufs_module.c ============================================================================== --- stable/12/stand/efi/boot1/ufs_module.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/boot1/ufs_module.c Thu Oct 24 02:43:38 2019 (r353979) @@ -148,7 +148,7 @@ load(const char *filepath, dev_info_t *dev, void **buf #ifdef EFI_DEBUG { CHAR16 *text = efi_devpath_name(dev->devpath); - DPRINTF("Loading '%s' from %S\n", filepath, text); + DPRINTF("UFS Loading '%s' from %S\n", filepath, text); efi_free_devpath_name(text); } #endif Modified: stable/12/stand/efi/include/efi.h ============================================================================== --- stable/12/stand/efi/include/efi.h Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/include/efi.h Thu Oct 24 02:43:38 2019 (r353979) @@ -62,6 +62,11 @@ Revision History #include "efiuga.h" /* + * Global variables + */ +extern EFI_LOADED_IMAGE *boot_img; + +/* * FreeBSD UUID */ #define FREEBSD_BOOT_VAR_GUID \ Modified: stable/12/stand/efi/include/efidef.h ============================================================================== --- stable/12/stand/efi/include/efidef.h Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/include/efidef.h Thu Oct 24 02:43:38 2019 (r353979) @@ -63,6 +63,7 @@ typedef VOID *EFI_EVENT; #define IN #define OUT #define OPTIONAL + #define CONST const #endif Modified: stable/12/stand/efi/include/efidevp.h ============================================================================== --- stable/12/stand/efi/include/efidevp.h Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/include/efidevp.h Thu Oct 24 02:43:38 2019 (r353979) @@ -433,6 +433,9 @@ typedef union { #define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \ { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } } +#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \ + { 0x05c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } } + INTERFACE_DECL(_EFI_DEVICE_PATH_PROTOCOL); typedef @@ -455,6 +458,23 @@ typedef struct _EFI_DEVICE_PATH_TO_TEXT_PROTOCOL { EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText; EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText; } EFI_DEVICE_PATH_TO_TEXT_PROTOCOL; + +typedef +struct _EFI_DEVICE_PATH* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) ( + IN CONST CHAR16* TextDeviceNode + ); +typedef +struct _EFI_DEVICE_PATH* +(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) ( + IN CONST CHAR16* TextDevicePath + ); + + +typedef struct _EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL { + EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode; + EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath; +} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL; #pragma pack() Modified: stable/12/stand/efi/include/efilib.h ============================================================================== --- stable/12/stand/efi/include/efilib.h Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/include/efilib.h Thu Oct 24 02:43:38 2019 (r353979) @@ -94,6 +94,9 @@ void efi_free_devpath_name(CHAR16 *); EFI_DEVICE_PATH *efi_devpath_to_media_path(EFI_DEVICE_PATH *); UINTN efi_devpath_length(EFI_DEVICE_PATH *); EFI_HANDLE efi_devpath_to_handle(EFI_DEVICE_PATH *path, EFI_HANDLE *handles, unsigned nhandles); +EFI_DEVICE_PATH *efi_name_to_devpath(const char *path); +EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path); +void efi_devpath_free(EFI_DEVICE_PATH *dp); int efi_status_to_errno(EFI_STATUS); EFI_STATUS errno_to_efi_status(int errno); @@ -124,9 +127,11 @@ void cpy16to8(const CHAR16 *, char *, size_t); * the loader setting / getting FreeBSD specific variables. */ +EFI_STATUS efi_delenv(EFI_GUID *guid, const char *varname); EFI_STATUS efi_freebsd_getenv(const char *v, void *data, __size_t *len); EFI_STATUS efi_getenv(EFI_GUID *g, const char *v, void *data, __size_t *len); EFI_STATUS efi_global_getenv(const char *v, void *data, __size_t *len); +EFI_STATUS efi_setenv(EFI_GUID *guid, const char *varname, UINT32 attr, void *data, __size_t len); EFI_STATUS efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr); /* guids and names */ Modified: stable/12/stand/efi/include/efizfs.h ============================================================================== --- stable/12/stand/efi/include/efizfs.h Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/include/efizfs.h Thu Oct 24 02:43:38 2019 (r353979) @@ -33,6 +33,8 @@ #define _EFIZFS_H_ #ifdef EFI_ZFS_BOOT +#include + typedef STAILQ_HEAD(zfsinfo_list, zfsinfo) zfsinfo_list_t; typedef struct zfsinfo @@ -48,8 +50,9 @@ void efi_zfs_probe(void); EFI_HANDLE efizfs_get_handle_by_guid(uint64_t); bool efizfs_get_guid_by_handle(EFI_HANDLE, uint64_t *); zfsinfo_list_t *efizfs_get_zfsinfo_list(void); -void efizfs_set_preferred(EFI_HANDLE); +#else +#define efi_zfs_probe NULL #endif #endif Modified: stable/12/stand/efi/libefi/devicename.c ============================================================================== --- stable/12/stand/efi/libefi/devicename.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/libefi/devicename.c Thu Oct 24 02:43:38 2019 (r353979) @@ -34,12 +34,10 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef EFI_ZFS_BOOT -#include -#endif #include #include +#include static int efi_parsedev(struct devdesc **, const char *, const char **); Modified: stable/12/stand/efi/libefi/devpath.c ============================================================================== --- stable/12/stand/efi/libefi/devpath.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/libefi/devpath.c Thu Oct 24 02:43:38 2019 (r353979) @@ -29,12 +29,15 @@ __FBSDID("$FreeBSD$"); #include #include +#include static EFI_GUID ImageDevicePathGUID = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID DevicePathToTextGUID = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID; -static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *textProtocol; +static EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *toTextProtocol; +static EFI_GUID DevicePathFromTextGUID = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; +static EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *fromTextProtocol; EFI_DEVICE_PATH * efi_lookup_image_devpath(EFI_HANDLE handle) @@ -65,22 +68,20 @@ efi_lookup_devpath(EFI_HANDLE handle) CHAR16 * efi_devpath_name(EFI_DEVICE_PATH *devpath) { - static int once = 1; EFI_STATUS status; if (devpath == NULL) return (NULL); - if (once) { + if (toTextProtocol == NULL) { status = BS->LocateProtocol(&DevicePathToTextGUID, NULL, - (VOID **)&textProtocol); + (VOID **)&toTextProtocol); if (EFI_ERROR(status)) - textProtocol = NULL; - once = 0; + toTextProtocol = NULL; } - if (textProtocol == NULL) + if (toTextProtocol == NULL) return (NULL); - return (textProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE)); + return (toTextProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE)); } void @@ -88,6 +89,46 @@ efi_free_devpath_name(CHAR16 *text) { BS->FreePool(text); +} + +EFI_DEVICE_PATH * +efi_name_to_devpath(const char *path) +{ + EFI_DEVICE_PATH *devpath; + CHAR16 *uv; + size_t ul; + + uv = NULL; + if (utf8_to_ucs2(path, &uv, &ul) != 0) + return (NULL); + devpath = efi_name_to_devpath16(uv); + free(uv); + return (devpath); +} + +EFI_DEVICE_PATH * +efi_name_to_devpath16(CHAR16 *path) +{ + EFI_STATUS status; + + if (path == NULL) + return (NULL); + if (fromTextProtocol == NULL) { + status = BS->LocateProtocol(&DevicePathFromTextGUID, NULL, + (VOID **)&fromTextProtocol); + if (EFI_ERROR(status)) + fromTextProtocol = NULL; + } + if (fromTextProtocol == NULL) + return (NULL); + + return (fromTextProtocol->ConvertTextToDevicePath(path)); +} + +void efi_devpath_free(EFI_DEVICE_PATH *devpath) +{ + + BS->FreePool(devpath); } EFI_DEVICE_PATH * Modified: stable/12/stand/efi/libefi/efienv.c ============================================================================== --- stable/12/stand/efi/libefi/efienv.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/libefi/efienv.c Thu Oct 24 02:43:38 2019 (r353979) @@ -68,7 +68,26 @@ efi_freebsd_getenv(const char *v, void *data, size_t * return (efi_getenv(&FreeBSDBootVarGUID, v, data, len)); } +/* + * efi_setenv -- Sets an env variable. + */ EFI_STATUS +efi_setenv(EFI_GUID *guid, const char *varname, UINT32 attr, void *data, __size_t len) +{ + EFI_STATUS rv; + CHAR16 *uv; + size_t ul; + + uv = NULL; + if (utf8_to_ucs2(varname, &uv, &ul) != 0) + return (EFI_OUT_OF_RESOURCES); + + rv = RS->SetVariable(uv, guid, attr, len, data); + free(uv); + return (rv); +} + +EFI_STATUS efi_setenv_freebsd_wcs(const char *varname, CHAR16 *valstr) { CHAR16 *var = NULL; @@ -84,3 +103,21 @@ efi_setenv_freebsd_wcs(const char *varname, CHAR16 *va return (rv); } +/* + * efi_delenv -- deletes the specified env variable + */ +EFI_STATUS +efi_delenv(EFI_GUID *guid, const char *name) +{ + CHAR16 *var; + size_t len; + EFI_STATUS rv; + + var = NULL; + if (utf8_to_ucs2(name, &var, &len) != 0) + return (EFI_OUT_OF_RESOURCES); + + rv = RS->SetVariable(var, guid, 0, 0, NULL); + free(var); + return rv; +} Modified: stable/12/stand/efi/libefi/efizfs.c ============================================================================== --- stable/12/stand/efi/libefi/efizfs.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/libefi/efizfs.c Thu Oct 24 02:43:38 2019 (r353979) @@ -45,14 +45,6 @@ static zfsinfo_list_t zfsinfo; uint64_t pool_guid; -static EFI_HANDLE preferred; - -void -efizfs_set_preferred(EFI_HANDLE h) -{ - preferred = h; -} - zfsinfo_list_t * efizfs_get_zfsinfo_list(void) { @@ -122,7 +114,7 @@ efi_zfs_probe(void) efipart_hddev.dv_name, hd->pd_unit, pd->pd_unit); if (zfs_probe_dev(devname, &guid) == 0) { insert_zfs(pd->pd_handle, guid); - if (pd->pd_handle == preferred) + if (pd->pd_handle == boot_img->DeviceHandle) pool_guid = guid; } Modified: stable/12/stand/efi/loader/conf.c ============================================================================== --- stable/12/stand/efi/loader/conf.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/loader/conf.c Thu Oct 24 02:43:38 2019 (r353979) @@ -31,9 +31,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#ifdef EFI_ZFS_BOOT -#include -#endif +#include struct devsw *devsw[] = { &efipart_fddev, Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 02:36:42 2019 (r353978) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 02:43:38 2019 (r353979) @@ -50,10 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include -#ifdef EFI_ZFS_BOOT -#include #include "efizfs.h" -#endif #include "loader_efi.h" @@ -91,6 +88,11 @@ static int fail_timeout = 5; */ UINT16 boot_current; +/* + * Image that we booted from. + */ +EFI_LOADED_IMAGE *boot_img; + static bool has_keyboard(void) { @@ -303,7 +305,7 @@ fix_dosisms(char *p) enum { BOOT_INFO_OK = 0, BAD_CHOICE = 1, NOT_SPECIFIC = 2 }; static int -match_boot_info(EFI_LOADED_IMAGE *img __unused, char *boot_info, size_t bisz) +match_boot_info(char *boot_info, size_t bisz) { uint32_t attr; uint16_t fplen; @@ -451,7 +453,7 @@ match_boot_info(EFI_LOADED_IMAGE *img __unused, char * * a drop to the OK boot loader prompt is possible. */ static int -find_currdev(EFI_LOADED_IMAGE *img, bool do_bootmgr, bool is_last, +find_currdev(bool do_bootmgr, bool is_last, char *boot_info, size_t boot_info_sz) { pdinfo_t *dp, *pp; @@ -484,7 +486,7 @@ find_currdev(EFI_LOADED_IMAGE *img, bool do_bootmgr, b * loader.conf. */ if (do_bootmgr) { - rv = match_boot_info(img, boot_info, boot_info_sz); + rv = match_boot_info(boot_info, boot_info_sz); switch (rv) { case BOOT_INFO_OK: /* We found it */ return (0); @@ -517,7 +519,7 @@ find_currdev(EFI_LOADED_IMAGE *img, bool do_bootmgr, b * boot protocol to do so. We fail and let UEFI go on to * the next candidate. */ - dp = efiblk_get_pdinfo_by_handle(img->DeviceHandle); + dp = efiblk_get_pdinfo_by_handle(boot_img->DeviceHandle); if (dp != NULL) { text = efi_devpath_name(dp->pd_devpath); if (text != NULL) { @@ -556,7 +558,7 @@ find_currdev(EFI_LOADED_IMAGE *img, bool do_bootmgr, b * any of the nodes in that path match one of the enumerated * handles. Currently, this handle list is only for netboot. */ - if (efi_handle_lookup(img->DeviceHandle, &dev, &unit, &extra) == 0) { + if (efi_handle_lookup(boot_img->DeviceHandle, &dev, &unit, &extra) == 0) { set_currdev_devsw(dev, unit); if (sanity_check_currdev()) return (0); @@ -754,7 +756,6 @@ main(int argc, CHAR16 *argv[]) size_t sz, bosz = 0, bisz = 0; UINT16 boot_order[100]; char boot_info[4096]; - EFI_LOADED_IMAGE *img; char buf[32]; bool uefi_boot_mgr; @@ -763,33 +764,28 @@ main(int argc, CHAR16 *argv[]) archsw.arch_copyin = efi_copyin; archsw.arch_copyout = efi_copyout; archsw.arch_readin = efi_readin; -#ifdef EFI_ZFS_BOOT - /* Note this needs to be set before ZFS init. */ archsw.arch_zfs_probe = efi_zfs_probe; -#endif /* Get our loaded image protocol interface structure. */ - (void) OpenProtocolByHandle(IH, &imgid, (void **)&img); + (void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img); -#ifdef EFI_ZFS_BOOT - /* Tell ZFS probe code where we booted from */ - efizfs_set_preferred(img->DeviceHandle); -#endif + /* + * Chicken-and-egg problem; we want to have console output early, but + * some console attributes may depend on reading from eg. the boot + * device, which we can't do yet. We can use printf() etc. once this is + * done. So, we set it to the efi console, then call console init. This + * gets us printf early, but also primes the pump for all future console + * changes to take effect, regardless of where they come from. + */ + setenv("console", "efi", 1); + cons_probe(); + /* Init the time source */ efi_time_init(); has_kbd = has_keyboard(); /* - * XXX Chicken-and-egg problem; we want to have console output - * early, but some console attributes may depend on reading from - * eg. the boot device, which we can't do yet. We can use - * printf() etc. once this is done. - */ - setenv("console", "efi", 1); - cons_probe(); - - /* * Initialise the block cache. Set the upper limit. */ bcache_init(32768, 512); @@ -813,17 +809,15 @@ main(int argc, CHAR16 *argv[]) if ((howto & CON_MASK) == 0) { /* No override, uhowto is controlling and efi cons is perfect */ howto = howto | (uhowto & CON_MASK); - setenv("console", "efi", 1); } else if ((howto & CON_MASK) == (uhowto & CON_MASK)) { /* override matches what UEFI told us, efi console is perfect */ - setenv("console", "efi", 1); } else if ((uhowto & (CON_MASK)) != 0) { /* * We detected a serial console on ConOut. All possible * overrides include serial. We can't really override what efi * gives us, so we use it knowing it's the best choice. */ - setenv("console", "efi", 1); + /* Do nothing */ } else { /* * We detected some kind of serial in the override, but ConOut @@ -887,14 +881,14 @@ main(int argc, CHAR16 *argv[]) /* Determine the devpath of our image so we can prefer it. */ - text = efi_devpath_name(img->FilePath); + text = efi_devpath_name(boot_img->FilePath); if (text != NULL) { printf(" Load Path: %S\n", text); efi_setenv_freebsd_wcs("LoaderPath", text); efi_free_devpath_name(text); } - rv = OpenProtocolByHandle(img->DeviceHandle, &devid, (void **)&imgpath); + rv = OpenProtocolByHandle(boot_img->DeviceHandle, &devid, (void **)&imgpath); if (rv == EFI_SUCCESS) { text = efi_devpath_name(imgpath); if (text != NULL) { @@ -981,7 +975,7 @@ main(int argc, CHAR16 *argv[]) * the boot protocol and also allow an escape hatch for users wishing * to try something different. */ - if (find_currdev(img, uefi_boot_mgr, is_last, boot_info, bisz) != 0) + if (find_currdev(uefi_boot_mgr, is_last, boot_info, bisz) != 0) if (!interactive_interrupt("Failed to find bootable partition")) return (EFI_NOT_FOUND); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:53:08 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6C85176707; Thu, 24 Oct 2019 02:53:08 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBd06Xbsz4CkV; Thu, 24 Oct 2019 02:53:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AA66B7905; Thu, 24 Oct 2019 02:53:08 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2r8VC099498; Thu, 24 Oct 2019 02:53:08 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2r7nR099492; Thu, 24 Oct 2019 02:53:07 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240253.x9O2r7nR099492@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:53:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353982 - in stable/12/stand/efi: boot1 include libefi loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand/efi: boot1 include libefi loader X-SVN-Commit-Revision: 353982 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:53:09 -0000 Author: kevans Date: Thu Oct 24 02:53:07 2019 New Revision: 353982 URL: https://svnweb.freebsd.org/changeset/base/353982 Log: MFC r346702-r346704, r346879-r346881, r347023, r347059-r347062, r347193-r347194, r347201 r346702: Add efi_freebsd_delenv Add a wrapper around efi_delenv akin to efi_freebsd_getenv and efi_getenv. r346703: Move initialization of the block device handles earlier (we're just snagging them from UEFI BIOS). Call the device type init routines earlier as well, as they don't depend on how the console is setup. This will allow us to read files earlier in boot, so any rare error messages that this might move only to the EFI console will be an acceptable price to pay. Also tweak the order of has_kbd so it resides next to the rest of the console code. It needs to be after we initialize the buffer cache. r346704: Add the proper range of years for Netflix's copyright on this file. Note that I wrote it. r346879: Read in and parse /efi/freebsd/loader.env from the boot device's partition as if it were on the command line. Fetch FreeBSD-LoaderEnv UEFI enviornment variable. If set, read in loader environment variables from it. Otherwise read in /efi/freebsd/loader.env. Both are read relative to the device loader.efi loaded from (they aren't full UEFI device paths) Next fetch FreeBSD-NextLoaderEnv UEFI environment variable. If present, read the file it points to in as above and delete the UEFI environment variable so it only happens once. This lets one set environment variables in the bootloader. Unfortunately, we don't have all the mechanisms in place to parse the file, nor do we have the magic pattern matching in place that loader.conf has. Variables are of the form foo=bar. No quotes are supported, so spaces aren't allowed, for example. Also, variables like foo_load=yes are intercepted when we parse the loader.conf file and things are done based on that. Since those aren't done here, variables that cause an action to happen won't work. r346880: Implement uefi_rootdev If uefi_rootdev is set in the environment, then treat it like a device path. Convert the string to a device path and see if we can find a device that matches. If so, use that device at our root dev no matter what. If it's bad in any way, the boot will fail. r346881: Implement uefi_ignore_boot_mgr env variable. When set, we ignore all the hints that the UEFI boot manager has set for us. We also always fail back to the OK prompt when we can't find the right thing to boot rather than failing back to the UEFI boot manager. This has the side effect of also expanding the cases where we fail back to the OK prompt to include when we're booted under UEFI, but UEFI::BootCurrent isn't set in the environment and we can't find a proper place to boot from. r347023: stand: correct mis-merge from r346879 Small mis-merge from multiple WIP resulted in block io media handles getting double-initialized. This resulted in some installations oddly landing at the mountroot prompt. r347059: Remove stray '*' We're storing an EFI_HANDLE, not an pointer to a handle. Since EFI_HANDLE is a void * anyway, this has little practical effect since the conversion to / from void * and void ** is silent. r347060: When we can't get memory, trying again right away is going to fail. Rather than print N failure messages, bail on the first one. r347061: Substitute boot1 with ${BOOT1} Allow for other names to be built, so parameterize this makefile to avoid hard coding boot1. r347062: Use SRC+= rather than SRC= To allow boot1/Makefile to be included, use SRC+= rathern than SRC= so the including Makefile can add additional sources to the build. r347193: Reach over and pull in devpath.c from libefi This allows us to remove three nearly identical functions because the differences don't matter, and the size difference is trivial. r347194: We only ever need one devinfo per handle. So allocate it outside of looping over the filesystem modules rather than doing a malloc + free each time through the loop. In addition, nothing changes from loop to loop, so setup the new devinfo outside the loop as well. r347201: Simplify boot1 allocation of handles. There's no need to pre-malloc the number of handles. Instead call LocateHandles twice, once to get the size, and once to get the data. Modified: stable/12/stand/efi/boot1/Makefile stable/12/stand/efi/boot1/boot1.c stable/12/stand/efi/boot1/boot_module.h stable/12/stand/efi/include/efilib.h stable/12/stand/efi/libefi/efienv.c stable/12/stand/efi/loader/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/boot1/Makefile ============================================================================== --- stable/12/stand/efi/boot1/Makefile Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/boot1/Makefile Thu Oct 24 02:53:07 2019 (r353982) @@ -2,7 +2,8 @@ .include -PROG= boot1.sym +BOOT1?= boot1 +PROG= ${BOOT1}.sym INTERNALPROG= WARNS?= 6 @@ -24,7 +25,7 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-parameter CWARNFLAGS.zfs_module.c += -Wno-unused-function # architecture-specific loader code -SRCS= boot1.c self_reloc.c start.S ufs_module.c +SRCS+= boot1.c self_reloc.c start.S ufs_module.c devpath.c .if ${MK_LOADER_ZFS} != "no" SRCS+= zfs_module.c CFLAGS.zfs_module.c+= -I${ZFSSRC} @@ -51,10 +52,11 @@ CFLAGS+= -DEFI_DEBUG .PATH: ${EFISRC}/loader/arch/${MACHINE} .PATH: ${EFISRC}/loader .PATH: ${LDRSRC} +.PATH: ${EFISRC}/libefi CFLAGS+= -I${LDRSRC} -FILES= boot1.efi boot1.efifat -FILESMODE_boot1.efi= ${BINMODE} +FILES= ${BOOT1}.efi ${BOOT1}.efifat +FILESMODE_${BOOT1}.efi= ${BINMODE} LDSCRIPT= ${EFISRC}/loader/arch/${MACHINE}/ldscript.${MACHINE} LDFLAGS+= -Wl,-T${LDSCRIPT},-Bsymbolic,-znotext -shared @@ -79,7 +81,7 @@ LDADD+= ${LIBEFI} ${LIBSA} DPADD+= ${LDSCRIPT} -boot1.efi: ${PROG} +${BOOT1}.efi: ${PROG} if ${NM} ${.ALLSRC} | grep ' U '; then \ echo "Undefined symbols in ${.ALLSRC}"; \ exit 1; \ @@ -95,7 +97,7 @@ boot1.efi: ${PROG} .include "Makefile.fat" -boot1.efifat: boot1.efi +${BOOT1}.efifat: ${BOOT1}.efi @set -- `ls -l ${.ALLSRC}`; \ x=$$(($$5-${BOOT1_MAXSIZE})); \ if [ $$x -ge 0 ]; then \ @@ -106,6 +108,6 @@ boot1.efifat: boot1.efi xz -d -c ${BOOTSRC}/efi/boot1/fat-${MACHINE}.tmpl.xz > ${.TARGET} ${DD} if=${.ALLSRC} of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc -CLEANFILES+= boot1.efi boot1.efifat +CLEANFILES+= ${BOOT1}.efi ${BOOT1}.efifat .include Modified: stable/12/stand/efi/boot1/boot1.c ============================================================================== --- stable/12/stand/efi/boot1/boot1.c Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/boot1/boot1.c Thu Oct 24 02:53:07 2019 (r353982) @@ -47,8 +47,6 @@ static const boot_module_t *boot_modules[] = }; #define NUM_BOOT_MODULES nitems(boot_modules) -/* The initial number of handles used to query EFI for partitions. */ -#define NUM_HANDLES_INIT 24 static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; @@ -93,66 +91,6 @@ Calloc(size_t n1, size_t n2, const char *file, int lin } /* - * nodes_match returns TRUE if the imgpath isn't NULL and the nodes match, - * FALSE otherwise. - */ -static BOOLEAN -nodes_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) -{ - size_t len; - - if (imgpath == NULL || imgpath->Type != devpath->Type || - imgpath->SubType != devpath->SubType) - return (FALSE); - - len = DevicePathNodeLength(imgpath); - if (len != DevicePathNodeLength(devpath)) - return (FALSE); - - return (memcmp(imgpath, devpath, (size_t)len) == 0); -} - -/* - * device_paths_match returns TRUE if the imgpath isn't NULL and all nodes - * in imgpath and devpath match up to their respective occurrences of a - * media node, FALSE otherwise. - */ -static BOOLEAN -device_paths_match(EFI_DEVICE_PATH *imgpath, EFI_DEVICE_PATH *devpath) -{ - - if (imgpath == NULL) - return (FALSE); - - while (!IsDevicePathEnd(imgpath) && !IsDevicePathEnd(devpath)) { - if (IsDevicePathType(imgpath, MEDIA_DEVICE_PATH) && - IsDevicePathType(devpath, MEDIA_DEVICE_PATH)) - return (TRUE); - - if (!nodes_match(imgpath, devpath)) - return (FALSE); - - imgpath = NextDevicePathNode(imgpath); - devpath = NextDevicePathNode(devpath); - } - - return (FALSE); -} - -/* - * devpath_last returns the last non-path end node in devpath. - */ -static EFI_DEVICE_PATH * -devpath_last(EFI_DEVICE_PATH *devpath) -{ - - while (!IsDevicePathEnd(NextDevicePathNode(devpath))) - devpath = NextDevicePathNode(devpath); - - return (devpath); -} - -/* * load_loader attempts to load the loader image data. * * It tries each module and its respective devices, identified by mod->probe, @@ -239,7 +177,7 @@ try_boot(void) buf = NULL; } - if ((status = BS->LoadImage(TRUE, IH, devpath_last(dev->devpath), + if ((status = BS->LoadImage(TRUE, IH, efi_devpath_last_node(dev->devpath), loaderbuf, loadersize, &loaderhandle)) != EFI_SUCCESS) { printf("Failed to load image provided by %s, size: %zu, (%lu)\n", mod->name, loadersize, EFI_ERROR_CODE(status)); @@ -336,27 +274,27 @@ probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, B if (!blkio->Media->LogicalPartition) return (EFI_UNSUPPORTED); - *preferred = device_paths_match(imgpath, devpath); + *preferred = efi_devpath_match(imgpath, devpath); /* Run through each module, see if it can load this partition */ + devinfo = malloc(sizeof(*devinfo)); + if (devinfo == NULL) { + DPRINTF("\nFailed to allocate devinfo\n"); + return (EFI_UNSUPPORTED); + } + devinfo->dev = blkio; + devinfo->devpath = devpath; + devinfo->devhandle = h; + devinfo->preferred = *preferred; + devinfo->next = NULL; + for (i = 0; i < NUM_BOOT_MODULES; i++) { - devinfo = malloc(sizeof(*devinfo)); - if (devinfo == NULL) { - DPRINTF("\nFailed to allocate devinfo\n"); - continue; - } - devinfo->dev = blkio; - devinfo->devpath = devpath; - devinfo->devhandle = h; devinfo->devdata = NULL; - devinfo->preferred = *preferred; - devinfo->next = NULL; - status = boot_modules[i]->probe(devinfo); if (status == EFI_SUCCESS) return (EFI_SUCCESS); - free(devinfo); } + free(devinfo); return (EFI_UNSUPPORTED); } @@ -495,32 +433,17 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) BS->Exit(IH, EFI_OUT_OF_RESOURCES, 0, NULL); #endif - /* Get all the device handles */ - hsize = (UINTN)NUM_HANDLES_INIT * sizeof(EFI_HANDLE); + hsize = 0; + BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, + &hsize, NULL); handles = malloc(hsize); if (handles == NULL) - printf("Failed to allocate %d handles\n", NUM_HANDLES_INIT); - - status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, - &hsize, handles); - switch (status) { - case EFI_SUCCESS: - break; - case EFI_BUFFER_TOO_SMALL: - free(handles); - handles = malloc(hsize); - if (handles == NULL) - efi_panic(EFI_OUT_OF_RESOURCES, "Failed to allocate %d handles\n", - NUM_HANDLES_INIT); - status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, - NULL, &hsize, handles); - if (status != EFI_SUCCESS) - efi_panic(status, "Failed to get device handles\n"); - break; - default: + efi_panic(EFI_OUT_OF_RESOURCES, "Failed to allocate %d handles\n", + hsize); + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, + NULL, &hsize, handles); + if (status != EFI_SUCCESS) efi_panic(status, "Failed to get device handles\n"); - break; - } /* Scan all partitions, probing with all modules. */ nhandles = hsize / sizeof(*handles); Modified: stable/12/stand/efi/boot1/boot_module.h ============================================================================== --- stable/12/stand/efi/boot1/boot_module.h Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/boot1/boot_module.h Thu Oct 24 02:53:07 2019 (r353982) @@ -48,7 +48,7 @@ typedef struct dev_info { EFI_BLOCK_IO *dev; EFI_DEVICE_PATH *devpath; - EFI_HANDLE *devhandle; + EFI_HANDLE devhandle; void *devdata; uint64_t partoff; int preferred; Modified: stable/12/stand/efi/include/efilib.h ============================================================================== --- stable/12/stand/efi/include/efilib.h Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/include/efilib.h Thu Oct 24 02:53:07 2019 (r353982) @@ -128,6 +128,7 @@ void cpy16to8(const CHAR16 *, char *, size_t); */ EFI_STATUS efi_delenv(EFI_GUID *guid, const char *varname); +EFI_STATUS efi_freebsd_delenv(const char *varname); EFI_STATUS efi_freebsd_getenv(const char *v, void *data, __size_t *len); EFI_STATUS efi_getenv(EFI_GUID *g, const char *v, void *data, __size_t *len); EFI_STATUS efi_global_getenv(const char *v, void *data, __size_t *len); Modified: stable/12/stand/efi/libefi/efienv.c ============================================================================== --- stable/12/stand/efi/libefi/efienv.c Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/libefi/efienv.c Thu Oct 24 02:53:07 2019 (r353982) @@ -119,5 +119,11 @@ efi_delenv(EFI_GUID *guid, const char *name) rv = RS->SetVariable(var, guid, 0, 0, NULL); free(var); - return rv; + return (rv); +} + +EFI_STATUS +efi_freebsd_delenv(const char *name) +{ + return (efi_delenv(&FreeBSDBootVarGUID, name)); } Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 02:49:13 2019 (r353981) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 02:53:07 2019 (r353982) @@ -3,7 +3,7 @@ * Copyright (c) 2006 Marcel Moolenaar * All rights reserved. * - * Copyright (c) 2018 Netflix, Inc. + * Copyright (c) 2016-2019 Netflix, Inc. written by M. Warner Losh * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -472,13 +472,35 @@ find_currdev(bool do_bootmgr, bool is_last, */ rootdev = getenv("rootdev"); if (rootdev != NULL) { - printf("Setting currdev to configured rootdev %s\n", rootdev); + printf(" Setting currdev to configured rootdev %s\n", + rootdev); set_currdev(rootdev); return (0); } /* - * Second choice: If we can find out image boot_info, and there's + * Second choice: If uefi_rootdev is set, translate that UEFI device + * path to the loader's internal name and use that. + */ + do { + rootdev = getenv("uefi_rootdev"); + if (rootdev == NULL) + break; + devpath = efi_name_to_devpath(rootdev); + if (devpath == NULL) + break; + dp = efiblk_get_pdinfo_by_device_path(devpath); + efi_devpath_free(devpath); + if (dp == NULL) + break; + printf(" Setting currdev to UEFI path %s\n", + rootdev); + set_currdev_pdinfo(dp); + return (0); + } while (0); + + /* + * Third choice: If we can find out image boot_info, and there's * a follow-on boot image in that boot_info, use that. In this * case root will be the partition specified in that image and * we'll load the kernel specified by the file path. Should there @@ -742,6 +764,80 @@ out: return (how); } +void +parse_loader_efi_config(EFI_HANDLE h, const char *env_fn) +{ + pdinfo_t *dp; + struct stat st; + int fd = -1; + char *env = NULL; + + dp = efiblk_get_pdinfo_by_handle(h); + if (dp == NULL) + return; + set_currdev_pdinfo(dp); + if (stat(env_fn, &st) != 0) + return; + fd = open(env_fn, O_RDONLY); + if (fd == -1) + return; + env = malloc(st.st_size + 1); + if (env == NULL) + goto out; + if (read(fd, env, st.st_size) != st.st_size) + goto out; + env[st.st_size] = '\0'; + boot_parse_cmdline(env); +out: + free(env); + close(fd); +} + +static void +read_loader_env(const char *name, char *def_fn, bool once) +{ + UINTN len; + char *fn, *freeme = NULL; + + len = 0; + fn = def_fn; + if (efi_freebsd_getenv(name, NULL, &len) == EFI_BUFFER_TOO_SMALL) { + freeme = fn = malloc(len + 1); + if (fn != NULL) { + if (efi_freebsd_getenv(name, fn, &len) != EFI_SUCCESS) { + free(fn); + fn = NULL; + printf( + "Can't fetch FreeBSD::%s we know is there\n", name); + } else { + /* + * if tagged as 'once' delete the env variable so we + * only use it once. + */ + if (once) + efi_freebsd_delenv(name); + /* + * We malloced 1 more than len above, then redid the call. + * so now we have room at the end of the string to NUL terminate + * it here, even if the typical idium would have '- 1' here to + * not overflow. len should be the same on return both times. + */ + fn[len] = '\0'; + } + } else { + printf( + "Can't allocate %d bytes to fetch FreeBSD::%s env var\n", + len, name); + } + } + if (fn) { + printf(" Reading loader env vars from %s\n", fn); + parse_loader_efi_config(boot_img->DeviceHandle, fn); + } +} + + + EFI_STATUS main(int argc, CHAR16 *argv[]) { @@ -783,13 +879,30 @@ main(int argc, CHAR16 *argv[]) /* Init the time source */ efi_time_init(); - has_kbd = has_keyboard(); - /* * Initialise the block cache. Set the upper limit. */ bcache_init(32768, 512); + /* + * Scan the BLOCK IO MEDIA handles then + * march through the device switch probing for things. + */ + i = efipart_inithandles(); + if (i != 0 && i != ENOENT) { + printf("efipart_inithandles failed with ERRNO %d, expect " + "failures\n", i); + } + + for (i = 0; devsw[i] != NULL; i++) + if (devsw[i]->dv_init != NULL) + (devsw[i]->dv_init)(); + + /* + * Detect console settings two different ways: one via the command + * args (eg -h) or via the UEFI ConOut variable. + */ + has_kbd = has_keyboard(); howto = parse_args(argc, argv); if (!has_kbd && (howto & RB_PROBE)) howto |= RB_SERIAL | RB_MULTIPLE; @@ -797,6 +910,24 @@ main(int argc, CHAR16 *argv[]) uhowto = parse_uefi_con_out(); /* + * Read additional environment variables from the boot device's + * "LoaderEnv" file. Any boot loader environment variable may be set + * there, which are subtly different than loader.conf variables. Only + * the 'simple' ones may be set so things like foo_load="YES" won't work + * for two reasons. First, the parser is simplistic and doesn't grok + * quotes. Second, because the variables that cause an action to happen + * are parsed by the lua, 4th or whatever code that's not yet + * loaded. This is relative to the root directory when loader.efi is + * loaded off the UFS root drive (when chain booted), or from the ESP + * when directly loaded by the BIOS. + * + * We also read in NextLoaderEnv if it was specified. This allows next boot + * functionality to be implemented and to override anything in LoaderEnv. + */ + read_loader_env("LoaderEnv", "/efi/freebsd/loader.env", false); + read_loader_env("NextLoaderEnv", NULL, true); + + /* * We now have two notions of console. howto should be viewed as * overrides. If console is already set, don't set it again. */ @@ -852,20 +983,6 @@ main(int argc, CHAR16 *argv[]) if ((s = getenv("fail_timeout")) != NULL) fail_timeout = strtol(s, NULL, 10); - /* - * Scan the BLOCK IO MEDIA handles then - * march through the device switch probing for things. - */ - i = efipart_inithandles(); - if (i != 0 && i != ENOENT) { - printf("efipart_inithandles failed with ERRNO %d, expect " - "failures\n", i); - } - - for (i = 0; devsw[i] != NULL; i++) - if (devsw[i]->dv_init != NULL) - (devsw[i]->dv_init)(); - printf("%s\n", bootprog_info); printf(" Command line arguments:"); for (i = 0; i < argc; i++) @@ -878,8 +995,6 @@ main(int argc, CHAR16 *argv[]) ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff); printf(" Console: %s (%#x)\n", getenv("console"), howto); - - /* Determine the devpath of our image so we can prefer it. */ text = efi_devpath_name(boot_img->FilePath); if (text != NULL) { @@ -898,36 +1013,41 @@ main(int argc, CHAR16 *argv[]) } } - uefi_boot_mgr = true; - boot_current = 0; - sz = sizeof(boot_current); - rv = efi_global_getenv("BootCurrent", &boot_current, &sz); - if (rv == EFI_SUCCESS) - printf(" BootCurrent: %04x\n", boot_current); - else { - boot_current = 0xffff; + if (getenv("uefi_ignore_boot_mgr") != NULL) { + printf(" Ignoring UEFI boot manager\n"); uefi_boot_mgr = false; - } + } else { + uefi_boot_mgr = true; + boot_current = 0; + sz = sizeof(boot_current); + rv = efi_global_getenv("BootCurrent", &boot_current, &sz); + if (rv == EFI_SUCCESS) + printf(" BootCurrent: %04x\n", boot_current); + else { + boot_current = 0xffff; + uefi_boot_mgr = false; + } - sz = sizeof(boot_order); - rv = efi_global_getenv("BootOrder", &boot_order, &sz); - if (rv == EFI_SUCCESS) { - printf(" BootOrder:"); - for (i = 0; i < sz / sizeof(boot_order[0]); i++) - printf(" %04x%s", boot_order[i], - boot_order[i] == boot_current ? "[*]" : ""); - printf("\n"); - is_last = boot_order[(sz / sizeof(boot_order[0])) - 1] == boot_current; - bosz = sz; - } else if (uefi_boot_mgr) { - /* - * u-boot doesn't set BootOrder, but otherwise participates in the - * boot manager protocol. So we fake it here and don't consider it - * a failure. - */ - bosz = sizeof(boot_order[0]); - boot_order[0] = boot_current; - is_last = true; + sz = sizeof(boot_order); + rv = efi_global_getenv("BootOrder", &boot_order, &sz); + if (rv == EFI_SUCCESS) { + printf(" BootOrder:"); + for (i = 0; i < sz / sizeof(boot_order[0]); i++) + printf(" %04x%s", boot_order[i], + boot_order[i] == boot_current ? "[*]" : ""); + printf("\n"); + is_last = boot_order[(sz / sizeof(boot_order[0])) - 1] == boot_current; + bosz = sz; + } else if (uefi_boot_mgr) { + /* + * u-boot doesn't set BootOrder, but otherwise participates in the + * boot manager protocol. So we fake it here and don't consider it + * a failure. + */ + bosz = sizeof(boot_order[0]); + boot_order[0] = boot_current; + is_last = true; + } } /* @@ -976,7 +1096,8 @@ main(int argc, CHAR16 *argv[]) * to try something different. */ if (find_currdev(uefi_boot_mgr, is_last, boot_info, bisz) != 0) - if (!interactive_interrupt("Failed to find bootable partition")) + if (uefi_boot_mgr && + !interactive_interrupt("Failed to find bootable partition")) return (EFI_NOT_FOUND); efi_init_environment(); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:46:37 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E1A2F175603; Thu, 24 Oct 2019 02:46:37 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBTT5h31z4Bn1; Thu, 24 Oct 2019 02:46:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A4355774B; Thu, 24 Oct 2019 02:46:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2kbMD093655; Thu, 24 Oct 2019 02:46:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2kbMB093653; Thu, 24 Oct 2019 02:46:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240246.x9O2kbMB093653@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:46:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353980 - in stable/12/stand: efi/loader fdt X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: efi/loader fdt X-SVN-Commit-Revision: 353980 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:46:38 -0000 Author: kevans Date: Thu Oct 24 02:46:36 2019 New Revision: 353980 URL: https://svnweb.freebsd.org/changeset/base/353980 Log: MFC r346701: loader: fdt: Add fdt_is_setup function When efi_autoload is called it will call fdt_setup_fdtp which setup the dtb and overlays. If a user already loaded at dtb or overlays or just printed the efi provided dtb, this will re-setup everything and also re-applying the overlays. Test that everything is setup before doing it again. Modified: stable/12/stand/efi/loader/autoload.c stable/12/stand/fdt/fdt_loader_cmd.c stable/12/stand/fdt/fdt_platform.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/loader/autoload.c ============================================================================== --- stable/12/stand/efi/loader/autoload.c Thu Oct 24 02:43:38 2019 (r353979) +++ stable/12/stand/efi/loader/autoload.c Thu Oct 24 02:46:36 2019 (r353980) @@ -50,7 +50,8 @@ efi_autoload(void) * imply that we're on a platform where FDT is a requirement. If we * fix this, then the error handling here should be fixed accordingly. */ - fdt_setup_fdtp(); + if (fdt_is_setup() == 0) + fdt_setup_fdtp(); #endif return (0); } Modified: stable/12/stand/fdt/fdt_loader_cmd.c ============================================================================== --- stable/12/stand/fdt/fdt_loader_cmd.c Thu Oct 24 02:43:38 2019 (r353979) +++ stable/12/stand/fdt/fdt_loader_cmd.c Thu Oct 24 02:46:36 2019 (r353980) @@ -510,6 +510,16 @@ fdt_apply_overlays() } int +fdt_is_setup(void) +{ + + if (fdtp != NULL) + return (1); + + return (0); +} + +int fdt_setup_fdtp() { struct preloaded_file *bfp; Modified: stable/12/stand/fdt/fdt_platform.h ============================================================================== --- stable/12/stand/fdt/fdt_platform.h Thu Oct 24 02:43:38 2019 (r353979) +++ stable/12/stand/fdt/fdt_platform.h Thu Oct 24 02:46:36 2019 (r353980) @@ -48,6 +48,7 @@ int fdt_load_dtb_addr(struct fdt_header *); int fdt_load_dtb_file(const char *); void fdt_load_dtb_overlays(const char *); int fdt_setup_fdtp(void); +int fdt_is_setup(void); /* The platform library needs to implement these functions */ int fdt_platform_load_dtb(void); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:06:38 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2F0F9150E83; Thu, 24 Oct 2019 03:06:38 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBwZ0VPZz4FQv; Thu, 24 Oct 2019 03:06:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E9C057AF3; Thu, 24 Oct 2019 03:06:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O36bFW006923; Thu, 24 Oct 2019 03:06:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O36bUs006922; Thu, 24 Oct 2019 03:06:37 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240306.x9O36bUs006922@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:06:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353985 - stable/12/stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 353985 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:06:38 -0000 Author: kevans Date: Thu Oct 24 03:06:37 2019 New Revision: 353985 URL: https://svnweb.freebsd.org/changeset/base/353985 Log: MFC r348352, r348354 r348352: loader: zfs_alloc and zfs_free should use panic The zfs alloc and free code print out the error and get stuck in infinite loop; use panic() instead. r348354: loader: malloc+memset is calloc in spa_create Replace malloc + memset pair with calloc. Modified: stable/12/stand/libsa/zfs/zfsimpl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:04:36 2019 (r353984) +++ stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:06:37 2019 (r353985) @@ -174,8 +174,7 @@ zfs_alloc(size_t size) char *ptr; if (zfs_temp_ptr + size > zfs_temp_end) { - printf("ZFS: out of temporary buffer space\n"); - for (;;) ; + panic("ZFS: out of temporary buffer space"); } ptr = zfs_temp_ptr; zfs_temp_ptr += size; @@ -189,8 +188,7 @@ zfs_free(void *ptr, size_t size) zfs_temp_ptr -= size; if (zfs_temp_ptr != ptr) { - printf("ZFS: zfs_alloc()/zfs_free() mismatch\n"); - for (;;) ; + panic("ZFS: zfs_alloc()/zfs_free() mismatch"); } } @@ -1341,9 +1339,8 @@ spa_create(uint64_t guid, const char *name) { spa_t *spa; - if ((spa = malloc(sizeof(spa_t))) == NULL) + if ((spa = calloc(1, sizeof(spa_t))) == NULL) return (NULL); - memset(spa, 0, sizeof(spa_t)); if ((spa->spa_name = strdup(name)) == NULL) { free(spa); return (NULL); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:22:52 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CE7C6170FC7; Thu, 24 Oct 2019 02:22:52 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46z9y455lpz46dR; Thu, 24 Oct 2019 02:22:52 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 93C8E73CC; Thu, 24 Oct 2019 02:22:52 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2MqaS081130; Thu, 24 Oct 2019 02:22:52 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2MqZf081129; Thu, 24 Oct 2019 02:22:52 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240222.x9O2MqZf081129@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:22:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353968 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 353968 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:22:52 -0000 Author: kevans Date: Thu Oct 24 02:22:52 2019 New Revision: 353968 URL: https://svnweb.freebsd.org/changeset/base/353968 Log: MFC r339796: Simplify the EFI delay() function by calling BS->Stall() Modified: stable/12/stand/efi/libefi/delay.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/delay.c ============================================================================== --- stable/12/stand/efi/libefi/delay.c Wed Oct 23 23:20:49 2019 (r353967) +++ stable/12/stand/efi/libefi/delay.c Thu Oct 24 02:22:52 2019 (r353968) @@ -33,15 +33,5 @@ __FBSDID("$FreeBSD$"); void delay(int usecs) { - static EFI_EVENT ev = 0; - UINTN junk; - - if (!ev) { - if (BS->CreateEvent(EVT_TIMER, TPL_APPLICATION, 0, 0, &ev) - != EFI_SUCCESS) - return; - } - - BS->SetTimer(ev, TimerRelative, usecs * 10); - BS->WaitForEvent(1, &ev, &junk); + BS->Stall(usecs); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:34:49 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6014C1734CB; Thu, 24 Oct 2019 02:34:49 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBCs1rclz48tK; Thu, 24 Oct 2019 02:34:49 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 228AC758F; Thu, 24 Oct 2019 02:34:49 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2YmDx087580; Thu, 24 Oct 2019 02:34:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2Ymbk087579; Thu, 24 Oct 2019 02:34:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240234.x9O2Ymbk087579@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:34:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353977 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 353977 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:34:49 -0000 Author: kevans Date: Thu Oct 24 02:34:48 2019 New Revision: 353977 URL: https://svnweb.freebsd.org/changeset/base/353977 Log: MFC r345330: loader: fix loading of kernels with . in path The loader indended to search the kernel file name (only) for . but instead searched the entire path, so paths like "boot/test.elfv2/kernel" would not work. Modified: stable/12/stand/common/load_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/load_elf.c ============================================================================== --- stable/12/stand/common/load_elf.c Thu Oct 24 02:33:57 2019 (r353976) +++ stable/12/stand/common/load_elf.c Thu Oct 24 02:34:48 2019 (r353977) @@ -868,14 +868,16 @@ fake_modname(const char *name) sp++; else sp = name; - ep = strrchr(name, '.'); - if (ep) { - if (ep == name) { - sp = invalid_name; - ep = invalid_name + sizeof(invalid_name) - 1; - } - } else - ep = name + strlen(name); + + ep = strrchr(sp, '.'); + if (ep == NULL) { + ep = sp + strlen(sp); + } + if (ep == sp) { + sp = invalid_name; + ep = invalid_name + sizeof(invalid_name) - 1; + } + len = ep - sp; fp = malloc(len + 1); if (fp == NULL) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:08:12 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2DE07151402; Thu, 24 Oct 2019 03:08:12 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zByN0T2Kz4Fgy; Thu, 24 Oct 2019 03:08:12 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E912C7AF9; Thu, 24 Oct 2019 03:08:11 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O38BCf007056; Thu, 24 Oct 2019 03:08:11 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O38BXP007055; Thu, 24 Oct 2019 03:08:11 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240308.x9O38BXP007055@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:08:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353986 - stable/12/stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 353986 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:08:12 -0000 Author: kevans Date: Thu Oct 24 03:08:11 2019 New Revision: 353986 URL: https://svnweb.freebsd.org/changeset/base/353986 Log: MFC r348381: Unexpand be32dec(). Modified: stable/12/stand/libsa/zfs/zfsimpl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:06:37 2019 (r353985) +++ stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:08:11 2019 (r353986) @@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$"); * Stand-alone ZFS file reader. */ +#include #include #include #include @@ -195,10 +196,7 @@ zfs_free(void *ptr, size_t size) static int xdr_int(const unsigned char **xdr, int *ip) { - *ip = ((*xdr)[0] << 24) - | ((*xdr)[1] << 16) - | ((*xdr)[2] << 8) - | ((*xdr)[3] << 0); + *ip = be32dec(*xdr); (*xdr) += 4; return (0); } @@ -206,10 +204,7 @@ xdr_int(const unsigned char **xdr, int *ip) static int xdr_u_int(const unsigned char **xdr, u_int *ip) { - *ip = ((*xdr)[0] << 24) - | ((*xdr)[1] << 16) - | ((*xdr)[2] << 8) - | ((*xdr)[3] << 0); + *ip = be32dec(*xdr); (*xdr) += 4; return (0); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:41:55 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A0BE5157025; Thu, 24 Oct 2019 03:41:55 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCjH20M8z4MFV; Thu, 24 Oct 2019 03:41:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 286A68249; Thu, 24 Oct 2019 03:41:55 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3ftT6030445; Thu, 24 Oct 2019 03:41:55 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3ftDN030444; Thu, 24 Oct 2019 03:41:55 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240341.x9O3ftDN030444@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:41:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354002 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 354002 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:41:55 -0000 Author: kevans Date: Thu Oct 24 03:41:54 2019 New Revision: 354002 URL: https://svnweb.freebsd.org/changeset/base/354002 Log: MFC r341276: When handling CMD_CRIT error set command_errmsg to NULL after we dump it out, so that it does not result in error message printed twice. OK load doodoo can't find 'doodoo' can't find 'doodoo' OK Modified: stable/12/stand/common/interp_forth.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/interp_forth.c ============================================================================== --- stable/12/stand/common/interp_forth.c Thu Oct 24 03:40:20 2019 (r354001) +++ stable/12/stand/common/interp_forth.c Thu Oct 24 03:41:54 2019 (r354002) @@ -142,6 +142,7 @@ bf_command(FICL_VM *vm) switch (result) { case CMD_CRIT: printf("%s\n", command_errmsg); + command_errmsg = NULL; break; case CMD_FATAL: panic("%s", command_errmsg); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:48:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6ABD157FA9; Thu, 24 Oct 2019 03:48:29 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCrs5ZzTz4N1Z; Thu, 24 Oct 2019 03:48:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A29098297; Thu, 24 Oct 2019 03:48:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3mT8X031864; Thu, 24 Oct 2019 03:48:29 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3mTR3031859; Thu, 24 Oct 2019 03:48:29 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240348.x9O3mTR3031859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:48:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354004 - in stable/12/stand/efi/loader/arch: arm i386 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand/efi/loader/arch: arm i386 X-SVN-Commit-Revision: 354004 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:48:30 -0000 Author: kevans Date: Thu Oct 24 03:48:28 2019 New Revision: 354004 URL: https://svnweb.freebsd.org/changeset/base/354004 Log: MFC r344560, r344718 r344560: stand: Remove unused i386 EFI MD bits r328169 removed the copy of bootinfo that would've made this somewhat functional. However, this is irrelevant- earlier work in r292338 was done to exit boot services in the MI bi_load() rather than having N copies of the GetMemoryMap/ExitBootServices dance. i386 never quite caught up to that; ldr_enter was still being called but the prereq for that, ldr_bootinfo, was no longer. As a consequence, this ExitBootServices() was being called with a mapkey=0, clearly bogus, and reportedly breaking the boot in some instances. r344718: EFI: don't call printf after ExitBootServices, since it uses Boot Services ExitBootServices terminates all boot services including console access. Attempting to call printf afterwards can result in a crash, depending on the implementation. Move any printf statements to before we call bi_load, and remove any that depend on calling bi_load first. Deleted: stable/12/stand/efi/loader/arch/i386/efimd.c Modified: stable/12/stand/efi/loader/arch/arm/exec.c stable/12/stand/efi/loader/arch/i386/Makefile.inc stable/12/stand/efi/loader/arch/i386/elf32_freebsd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/loader/arch/arm/exec.c ============================================================================== --- stable/12/stand/efi/loader/arch/arm/exec.c Thu Oct 24 03:44:32 2019 (r354003) +++ stable/12/stand/efi/loader/arch/arm/exec.c Thu Oct 24 03:48:28 2019 (r354004) @@ -74,16 +74,19 @@ __elfN(arm_exec)(struct preloaded_file *fp) e = (Elf_Ehdr *)&fmp->md_data; efi_time_fini(); + + entry = efi_translate(e->e_entry); + + printf("Kernel entry at 0x%x...\n", (unsigned)entry); + printf("Kernel args: %s\n", fp->f_args); + if ((error = bi_load(fp->f_args, &modulep, &kernend)) != 0) { efi_time_init(); return (error); } - entry = efi_translate(e->e_entry); - printf("Kernel entry at 0x%x...\n", (unsigned)entry); - printf("Kernel args: %s\n", fp->f_args); - printf("modulep: %#x\n", modulep); - printf("relocation_offset %llx\n", __elfN(relocation_offset)); + /* At this point we've called ExitBootServices, so we can't call + * printf or any other function that uses Boot Services */ dev_cleanup(); Modified: stable/12/stand/efi/loader/arch/i386/Makefile.inc ============================================================================== --- stable/12/stand/efi/loader/arch/i386/Makefile.inc Thu Oct 24 03:44:32 2019 (r354003) +++ stable/12/stand/efi/loader/arch/i386/Makefile.inc Thu Oct 24 03:48:28 2019 (r354004) @@ -1,7 +1,6 @@ # $FreeBSD$ SRCS+= start.S \ - efimd.c \ elf32_freebsd.c \ exec.c Modified: stable/12/stand/efi/loader/arch/i386/elf32_freebsd.c ============================================================================== --- stable/12/stand/efi/loader/arch/i386/elf32_freebsd.c Thu Oct 24 03:44:32 2019 (r354003) +++ stable/12/stand/efi/loader/arch/i386/elf32_freebsd.c Thu Oct 24 03:48:28 2019 (r354004) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); extern void __exec(caddr_t addr, ...); extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp); -extern int ldr_enter(const char *kernel); static int elf32_exec(struct preloaded_file *amp); static int elf32_obj_exec(struct preloaded_file *amp); @@ -76,16 +75,19 @@ elf32_exec(struct preloaded_file *fp) ehdr = (Elf_Ehdr *)&(md->md_data); efi_time_fini(); + + entry = ehdr->e_entry & 0xffffff; + + printf("Start @ 0x%x ...\n", entry); + err = bi_load(fp->f_args, &modulep, &kernend); if (err != 0) { efi_time_init(); return(err); } - entry = ehdr->e_entry & 0xffffff; - printf("Start @ 0x%x ...\n", entry); - - ldr_enter(fp->f_name); + /* At this point we've called ExitBootServices, so we can't call + * printf or any other function that uses Boot Services */ dev_cleanup(); __exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, kernend); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:49:14 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A942175D13; Thu, 24 Oct 2019 02:49:14 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBXV25p4z4C9G; Thu, 24 Oct 2019 02:49:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2723F774C; Thu, 24 Oct 2019 02:49:14 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2nEtR093829; Thu, 24 Oct 2019 02:49:14 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2nDEi093828; Thu, 24 Oct 2019 02:49:13 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240249.x9O2nDEi093828@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:49:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353981 - stable/12/stand/i386/zfsboot X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/i386/zfsboot X-SVN-Commit-Revision: 353981 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:49:14 -0000 Author: kevans Date: Thu Oct 24 02:49:13 2019 New Revision: 353981 URL: https://svnweb.freebsd.org/changeset/base/353981 Log: MFC r346969: zfsboot: to detect disk size, use GPT information first If we do have GPT on disk, read the disk size from it and do not call int13. Since int13 does report bogus informatiopn too often, rather trust the partition table. We are using the same strategy with loader. Modified: stable/12/stand/i386/zfsboot/zfsboot.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/i386/zfsboot/zfsboot.c ============================================================================== --- stable/12/stand/i386/zfsboot/zfsboot.c Thu Oct 24 02:46:36 2019 (r353980) +++ stable/12/stand/i386/zfsboot/zfsboot.c Thu Oct 24 02:49:13 2019 (r353981) @@ -478,6 +478,33 @@ copy_dsk(struct zfsdsk *zdsk) } /* + * Get disk size from GPT. + */ +static uint64_t +drvsize_gpt(struct dsk *dskp) +{ +#ifdef GPT + struct gpt_hdr hdr; + char *sec; + + sec = dmadat->secbuf; + if (drvread(dskp, sec, 1, 1)) + return (0); + + memcpy(&hdr, sec, sizeof(hdr)); + if (memcmp(hdr.hdr_sig, GPT_HDR_SIG, sizeof(hdr.hdr_sig)) != 0 || + hdr.hdr_lba_self != 1 || hdr.hdr_revision < 0x00010000 || + hdr.hdr_entsz < sizeof(struct gpt_ent) || + DEV_BSIZE % hdr.hdr_entsz != 0) { + return (0); + } + return (hdr.hdr_lba_alt + 1); +#else + return (0); +#endif +} + +/* * Get disk size from eax=0x800 and 0x4800. We need to probe both * because 0x4800 may not be available and we would like to get more * or less correct disk size - if it is possible at all. @@ -492,6 +519,11 @@ drvsize_ext(struct zfsdsk *zdsk) int cyl, hds, sec; dskp = &zdsk->dsk; + + /* Try to read disk size from GPT */ + size = drvsize_gpt(dskp); + if (size != 0) + return (size); v86.ctl = V86_FLAGS; v86.addr = 0x13; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:24:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1FFB61543A5; Thu, 24 Oct 2019 03:24:29 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCK86tgYz4JHr; Thu, 24 Oct 2019 03:24:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CF7267EB2; Thu, 24 Oct 2019 03:24:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3OSe8018879; Thu, 24 Oct 2019 03:24:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3OSLv018878; Thu, 24 Oct 2019 03:24:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240324.x9O3OSLv018878@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:24:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353992 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 353992 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:24:29 -0000 Author: kevans Date: Thu Oct 24 03:24:28 2019 New Revision: 353992 URL: https://svnweb.freebsd.org/changeset/base/353992 Log: MFC r351695-r351696 r351695: loader.efi: some systems do not translate scan code 0x8 to backspace Add scancode translation for backspace. r351696: loader.efi: use and prefer coninex interface Add support for EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL. Modified: stable/12/stand/efi/libefi/efi_console.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/efi_console.c ============================================================================== --- stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 03:21:30 2019 (r353991) +++ stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 03:24:28 2019 (r353992) @@ -32,8 +32,10 @@ __FBSDID("$FreeBSD$"); #include "bootstrap.h" +static EFI_GUID simple_input_ex_guid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; static SIMPLE_TEXT_OUTPUT_INTERFACE *conout; static SIMPLE_INPUT_INTERFACE *conin; +static EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *coninex; #ifdef TERM_EMU #define DEFAULT_FGCOLOR EFI_LIGHTGRAY @@ -115,6 +117,8 @@ efi_cons_probe(struct console *cp) static int efi_cons_init(int arg) { + EFI_STATUS status; + #ifdef TERM_EMU conout->SetAttribute(conout, EFI_TEXT_ATTR(DEFAULT_FGCOLOR, DEFAULT_BGCOLOR)); @@ -125,7 +129,11 @@ efi_cons_init(int arg) bg_c = DEFAULT_BGCOLOR; #endif conout->EnableCursor(conout, TRUE); - return 0; + status = BS->OpenProtocol(ST->ConsoleInHandle, &simple_input_ex_guid, + (void **)&coninex, IH, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL); + if (status != EFI_SUCCESS) + coninex = NULL; + return (0); } static void @@ -478,27 +486,30 @@ keybuf_inschar(EFI_INPUT_KEY *key) { switch (key->ScanCode) { - case 0x1: /* UP */ + case SCAN_UP: /* UP */ keybuf[0] = 0x1b; /* esc */ keybuf[1] = '['; keybuf[2] = 'A'; break; - case 0x2: /* DOWN */ + case SCAN_DOWN: /* DOWN */ keybuf[0] = 0x1b; /* esc */ keybuf[1] = '['; keybuf[2] = 'B'; break; - case 0x3: /* RIGHT */ + case SCAN_RIGHT: /* RIGHT */ keybuf[0] = 0x1b; /* esc */ keybuf[1] = '['; keybuf[2] = 'C'; break; - case 0x4: /* LEFT */ + case SCAN_LEFT: /* LEFT */ keybuf[0] = 0x1b; /* esc */ keybuf[1] = '['; keybuf[2] = 'D'; break; - case 0x17: + case SCAN_DELETE: + keybuf[0] = CHAR_BACKSPACE; + break; + case SCAN_ESC: keybuf[0] = 0x1b; /* esc */ break; default: @@ -521,6 +532,40 @@ efi_readkey(void) return (false); } +static bool +efi_readkey_ex(void) +{ + EFI_STATUS status; + EFI_INPUT_KEY *kp; + EFI_KEY_DATA key_data; + uint32_t kss; + + status = coninex->ReadKeyStrokeEx(coninex, &key_data); + if (status == EFI_SUCCESS) { + kss = key_data.KeyState.KeyShiftState; + kp = &key_data.Key; + if (kss & EFI_SHIFT_STATE_VALID) { + + /* + * quick mapping to control chars, replace with + * map lookup later. + */ + if (kss & EFI_RIGHT_CONTROL_PRESSED || + kss & EFI_LEFT_CONTROL_PRESSED) { + if (kp->UnicodeChar >= 'a' && + kp->UnicodeChar <= 'z') { + kp->UnicodeChar -= 'a'; + kp->UnicodeChar++; + } + } + } + + keybuf_inschar(kp); + return (true); + } + return (false); +} + int efi_cons_getchar(void) { @@ -531,8 +576,13 @@ efi_cons_getchar(void) key_pending = 0; - if (efi_readkey()) - return (keybuf_getchar()); + if (coninex == NULL) { + if (efi_readkey()) + return (keybuf_getchar()); + } else { + if (efi_readkey_ex()) + return (keybuf_getchar()); + } return (-1); } @@ -540,6 +590,7 @@ efi_cons_getchar(void) int efi_cons_poll(void) { + EFI_STATUS status; if (keybuf_ischar() || key_pending) return (1); @@ -549,10 +600,21 @@ efi_cons_poll(void) * WaitForKey(). * CheckEvent() can clear the signaled state. */ - if (conin->WaitForKey == NULL) - key_pending = efi_readkey(); - else - key_pending = BS->CheckEvent(conin->WaitForKey) == EFI_SUCCESS; + if (coninex != NULL) { + if (coninex->WaitForKeyEx == NULL) { + key_pending = efi_readkey_ex(); + } else { + status = BS->CheckEvent(coninex->WaitForKeyEx); + key_pending = status == EFI_SUCCESS; + } + } else { + if (conin->WaitForKey == NULL) { + key_pending = efi_readkey(); + } else { + status = BS->CheckEvent(conin->WaitForKey); + key_pending = status == EFI_SUCCESS; + } + } return (key_pending); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:44:33 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5D89D157733; Thu, 24 Oct 2019 03:44:33 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCmK1p1Qz4MXf; Thu, 24 Oct 2019 03:44:33 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 21AAE8286; Thu, 24 Oct 2019 03:44:33 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3iWML031576; Thu, 24 Oct 2019 03:44:32 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3iWjb031575; Thu, 24 Oct 2019 03:44:32 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240344.x9O3iWjb031575@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:44:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354003 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354003 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:44:33 -0000 Author: kevans Date: Thu Oct 24 03:44:32 2019 New Revision: 354003 URL: https://svnweb.freebsd.org/changeset/base/354003 Log: MFC r349344: Add missing include of sys/boot.h This change was dropped out in a rebase and I didn't catch that before I committed. Modified: stable/12/sys/kern/kern_mib.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/kern_mib.c ============================================================================== --- stable/12/sys/kern/kern_mib.c Thu Oct 24 03:41:54 2019 (r354002) +++ stable/12/sys/kern/kern_mib.c Thu Oct 24 03:44:32 2019 (r354003) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include "opt_config.h" #include +#include #include #include #include From owner-svn-src-stable-12@freebsd.org Thu Oct 24 04:04:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE65615A63A; Thu, 24 Oct 2019 04:04:54 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zDCp48LZz4QQb; Thu, 24 Oct 2019 04:04:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6D0748646; Thu, 24 Oct 2019 04:04:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O44sSG043266; Thu, 24 Oct 2019 04:04:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O44sNd043265; Thu, 24 Oct 2019 04:04:54 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240404.x9O44sNd043265@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 04:04:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354009 - stable/12/stand/efi/loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/loader X-SVN-Commit-Revision: 354009 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 04:04:54 -0000 Author: kevans Date: Thu Oct 24 04:04:53 2019 New Revision: 354009 URL: https://svnweb.freebsd.org/changeset/base/354009 Log: MFC r349471, r351166: Tweak EFI_STAGING_SIZE r349471: Increase EFI_STAGING_SIZE to 100MB on x64 To avoid failures when the large 18MB nvidia.ko module is being loaded, increase EFI_STAGING_SIZE from 64MB to 100MB on x64 systems. Leave the other platforms at 64MB. r351166: Reduce size of EFI_STAGING_SIZE to 32 on arm Reduce the size of the EFI_STAGING area we allocate on arm to 32. On arm SBC such as the NanoPi-NEOLTS the staging area allocation will fail on the 256MB model with a staging size of 64. Modified: stable/12/stand/efi/loader/copy.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/loader/copy.c ============================================================================== --- stable/12/stand/efi/loader/copy.c Thu Oct 24 04:00:49 2019 (r354008) +++ stable/12/stand/efi/loader/copy.c Thu Oct 24 04:04:53 2019 (r354009) @@ -176,7 +176,13 @@ out: #endif /* __i386__ || __amd64__ */ #ifndef EFI_STAGING_SIZE +#if defined(__amd64__) +#define EFI_STAGING_SIZE 100 +#elif defined(__arm__) +#define EFI_STAGING_SIZE 32 +#else #define EFI_STAGING_SIZE 64 +#endif #endif EFI_PHYSICAL_ADDRESS staging, staging_end; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:25:31 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8BDE71718FE; Thu, 24 Oct 2019 02:25:31 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zB1737stz476y; Thu, 24 Oct 2019 02:25:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ACE773CE; Thu, 24 Oct 2019 02:25:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2PVFc081312; Thu, 24 Oct 2019 02:25:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2PVXM081311; Thu, 24 Oct 2019 02:25:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240225.x9O2PVXM081311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:25:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353969 - stable/12/stand X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand X-SVN-Commit-Revision: 353969 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:25:31 -0000 Author: kevans Date: Thu Oct 24 02:25:30 2019 New Revision: 353969 URL: https://svnweb.freebsd.org/changeset/base/353969 Log: MFC r341433: Move inclusion of src.opts.mk later. src.opts.mk includes bsd.own.mk. This in turn defines CTFCONVERT_CMD depending on the MK_CTF value. We then set MK_CTF to no, which has no real effect. The solution is to set all the MK_foo values before including src.opts.mk. This should stop the cdboot binary from exploding in size for releases built WITH_CTF=yes in src.conf. Modified: stable/12/stand/defs.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/defs.mk ============================================================================== --- stable/12/stand/defs.mk Thu Oct 24 02:22:52 2019 (r353968) +++ stable/12/stand/defs.mk Thu Oct 24 02:25:30 2019 (r353969) @@ -1,12 +1,12 @@ # $FreeBSD$ -.include - -WARNS?=1 - .if !defined(__BOOT_DEFS_MK__) __BOOT_DEFS_MK__=${MFILE} +# We need to define all the MK_ options before including src.opts.mk +# because it includes bsd.own.mk which needs the right MK_ values, +# espeically MK_CTF. + MK_CTF= no MK_SSP= no MK_PROFILE= no @@ -15,6 +15,10 @@ MAN= NO_PIC= INTERNALLIB= .endif + +.include + +WARNS?= 1 BOOTSRC= ${SRCTOP}/stand EFISRC= ${BOOTSRC}/efi From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:04:37 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 61BA2150728; Thu, 24 Oct 2019 03:04:37 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBtF2drGz4F8X; Thu, 24 Oct 2019 03:04:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2693A7AED; Thu, 24 Oct 2019 03:04:37 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O34bVl006747; Thu, 24 Oct 2019 03:04:37 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O34au0006744; Thu, 24 Oct 2019 03:04:36 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240304.x9O34au0006744@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:04:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353984 - in stable/12/stand: common fdt X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: common fdt X-SVN-Commit-Revision: 353984 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:04:37 -0000 Author: kevans Date: Thu Oct 24 03:04:36 2019 New Revision: 353984 URL: https://svnweb.freebsd.org/changeset/base/353984 Log: MFC r348194, r348196, r348204, r348207: loader/fdt pnpmatch r348194: loader: Add pnp functions for autoloading modules based on linker.hints This adds some new commands to loader : - pnpmatch This takes a pnpinfo string as argument and tries to find a kernel module associated with it. -v and -d option are available and are the same as in devmatch (v is verbose, d dumps the hints). - pnpload This takes a pnpinfo string as argument and tries to load a kernel module associated with it. - pnpautoload This will attempt to load every kernel module for each buses. Each buses are probed, the probe function will generate pnpinfo string and load kernel module associated with it if it exists. Only simplebus for FDT system is implemented for now. Since we need the dtb and overlays to be applied before searching the tree fdt_devmatch_next will load and apply the dtb + overlays. All the pnp parsing code comes from devmatch and is the same at 99%. r348196: loader: Remove unused variable r348204: Remove yet another unused variable. r348207: Initialize a variable to fix build with GCC. Modified: stable/12/stand/common/module.c stable/12/stand/fdt/fdt_loader_cmd.c stable/12/stand/fdt/fdt_platform.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/module.c ============================================================================== --- stable/12/stand/common/module.c Thu Oct 24 03:01:40 2019 (r353983) +++ stable/12/stand/common/module.c Thu Oct 24 03:04:36 2019 (r353984) @@ -39,6 +39,10 @@ __FBSDID("$FreeBSD$"); #include #include +#if defined(LOADER_FDT_SUPPORT) +#include +#endif + #include "bootstrap.h" #define MDIR_REMOVED 0x0001 @@ -52,18 +56,18 @@ struct moduledir { STAILQ_ENTRY(moduledir) d_link; }; -static int file_load(char *, vm_offset_t, struct preloaded_file **); -static int file_load_dependencies(struct preloaded_file *); -static char * file_search(const char *, char **); -static struct kernel_module *file_findmodule(struct preloaded_file *, char *, - struct mod_depend *); -static int file_havepath(const char *); -static char *mod_searchmodule(char *, struct mod_depend *); -static void file_insert_tail(struct preloaded_file *); -static void file_remove(struct preloaded_file *); -struct file_metadata *metadata_next(struct file_metadata *, int); -static void moduledir_readhints(struct moduledir *); -static void moduledir_rebuild(void); +static int file_load(char *filename, vm_offset_t dest, struct preloaded_file **result); +static int file_load_dependencies(struct preloaded_file *base_mod); +static char * file_search(const char *name, char **extlist); +static struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo); +static int file_havepath(const char *name); +static char *mod_searchmodule(char *name, struct mod_depend *verinfo); +static char * mod_searchmodule_pnpinfo(const char *bus, const char *pnpinfo); +static void file_insert_tail(struct preloaded_file *mp); +static void file_remove(struct preloaded_file *fp); +struct file_metadata* metadata_next(struct file_metadata *base_mp, int type); +static void moduledir_readhints(struct moduledir *mdp); +static void moduledir_rebuild(void); /* load address should be tweaked by first module loaded (kernel) */ static vm_offset_t loadaddr = 0; @@ -344,6 +348,186 @@ command_lsmod(int argc, char *argv[]) return(CMD_OK); } +COMMAND_SET(pnpmatch, "pnpmatch", "list matched modules based on pnpinfo", command_pnpmatch); + +static int pnp_dump_flag = 0; +static int pnp_unbound_flag = 0; +static int pnp_verbose_flag = 0; + +static int +command_pnpmatch(int argc, char *argv[]) +{ + char *module; + int ch; + + pnp_verbose_flag = 0; + pnp_dump_flag = 0; + optind = 1; + optreset = 1; + while ((ch = getopt(argc, argv, "vd")) != -1) { + switch(ch) { + case 'v': + pnp_verbose_flag = 1; + break; + case 'd': + pnp_dump_flag = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } + } + argv += (optind - 1); + argc -= (optind - 1); + + module = mod_searchmodule_pnpinfo(argv[1], argv[2]); + if (module) + printf("Matched module: %s\n", module); + else if(argv[1]) + printf("No module matches %s\n", argv[1]); + + return (CMD_OK); +} + +COMMAND_SET(pnpload, "pnpload", "load matched modules based on pnpinfo", command_pnpload); + +static int +command_pnpload(int argc, char *argv[]) +{ + char *module; + int ch, error; + + pnp_verbose_flag = 0; + pnp_dump_flag = 0; + optind = 1; + optreset = 1; + while ((ch = getopt(argc, argv, "vd")) != -1) { + switch(ch) { + case 'v': + pnp_verbose_flag = 1; + break; + case 'd': + pnp_dump_flag = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } + } + argv += (optind - 1); + argc -= (optind - 1); + + if (argc != 2) + return (CMD_ERROR); + + module = mod_searchmodule_pnpinfo(argv[1], argv[2]); + + error = mod_load(module, NULL, 0, NULL); + if (error == EEXIST) { + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: module '%s' already loaded", argv[1]); + return (CMD_WARN); + } + + return (error == 0 ? CMD_OK : CMD_CRIT); +} + +#if defined(LOADER_FDT_SUPPORT) +static void +pnpautoload_simplebus(void) { + const char *pnpstring; + const char *compatstr; + char *pnpinfo = NULL; + char *module = NULL; + int tag = 0, len, pnplen; + int error; + + while (1) { + pnpstring = fdt_devmatch_next(&tag, &len); + if (pnpstring == NULL) + return; + + compatstr = pnpstring; + for (pnplen = 0; pnplen != len; compatstr = pnpstring + pnplen) { + pnplen += strlen(compatstr) + 1; + asprintf(&pnpinfo, "compat=%s", compatstr); + + module = mod_searchmodule_pnpinfo("simplebus", pnpinfo); + if (module) { + error = mod_loadkld(module, 0, NULL); + if (error) + printf("Cannot load module %s\n", module); + break; + } + } + free(pnpinfo); + free(module); + } +} +#endif + +struct pnp_bus { + const char *name; + void (*load)(void); +}; + +struct pnp_bus pnp_buses[] = { +#if defined(LOADER_FDT_SUPPORT) + {"simplebus", pnpautoload_simplebus}, +#endif +}; + +COMMAND_SET(pnpautoload, "pnpautoload", "auto load modules based on pnpinfo", command_pnpautoload); + +static int +command_pnpautoload(int argc, char *argv[]) +{ + int i; + int verbose; + int ch, match; + + pnp_verbose_flag = 0; + pnp_dump_flag = 0; + verbose = 0; + optind = 1; + optreset = 1; + match = 0; + while ((ch = getopt(argc, argv, "v")) != -1) { + switch(ch) { + case 'v': + verbose = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } + } + argv += (optind - 1); + argc -= (optind - 1); + + if (argc > 2) + return (CMD_ERROR); + + for (i = 0; i < nitems(pnp_buses); i++) { + if (argc == 2 && strcmp(argv[1], pnp_buses[i].name) != 0) { + if (verbose) + printf("Skipping bus %s\n", pnp_buses[i].name); + continue; + } + if (verbose) + printf("Autoloading modules for simplebus\n"); + pnp_buses[i].load(); + match = 1; + } + if (match == 0) + printf("Unsupported bus %s\n", argv[1]); + + return (CMD_OK); +} + /* * File level interface, functions file_* */ @@ -908,6 +1092,284 @@ bad: return result; } +static int +getint(void **ptr) +{ + int *p = *ptr; + int rv; + + p = (int *)roundup2((intptr_t)p, sizeof(int)); + rv = *p++; + *ptr = p; + return rv; +} + +static void +getstr(void **ptr, char *val) +{ + int *p = *ptr; + char *c = (char *)p; + int len = *(uint8_t *)c; + + memcpy(val, c + 1, len); + val[len] = 0; + c += len + 1; + *ptr = (void *)c; +} + +static int +pnpval_as_int(const char *val, const char *pnpinfo) +{ + int rv; + char key[256]; + char *cp; + + if (pnpinfo == NULL) + return -1; + + cp = strchr(val, ';'); + key[0] = ' '; + if (cp == NULL) + strlcpy(key + 1, val, sizeof(key) - 1); + else { + memcpy(key + 1, val, cp - val); + key[cp - val + 1] = '\0'; + } + strlcat(key, "=", sizeof(key)); + if (strncmp(key + 1, pnpinfo, strlen(key + 1)) == 0) + rv = strtol(pnpinfo + strlen(key + 1), NULL, 0); + else { + cp = strstr(pnpinfo, key); + if (cp == NULL) + rv = -1; + else + rv = strtol(cp + strlen(key), NULL, 0); + } + return rv; +} + +static void +quoted_strcpy(char *dst, const char *src) +{ + char q = ' '; + + if (*src == '\'' || *src == '"') + q = *src++; + while (*src && *src != q) + *dst++ = *src++; // XXX backtick quoting + *dst++ = '\0'; + // XXX overflow +} + +static char * +pnpval_as_str(const char *val, const char *pnpinfo) +{ + static char retval[256]; + char key[256]; + char *cp; + + if (pnpinfo == NULL) { + *retval = '\0'; + return retval; + } + + cp = strchr(val, ';'); + key[0] = ' '; + if (cp == NULL) + strlcpy(key + 1, val, sizeof(key) - 1); + else { + memcpy(key + 1, val, cp - val); + key[cp - val + 1] = '\0'; + } + strlcat(key, "=", sizeof(key)); + if (strncmp(key + 1, pnpinfo, strlen(key + 1)) == 0) + quoted_strcpy(retval, pnpinfo + strlen(key + 1)); + else { + cp = strstr(pnpinfo, key); + if (cp == NULL) + strcpy(retval, "MISSING"); + else + quoted_strcpy(retval, cp + strlen(key)); + } + return retval; +} + +static char * +devmatch_search_hints(struct moduledir *mdp, const char *bus, const char *dev, const char *pnpinfo) +{ + char val1[256], val2[256]; + int ival, len, ents, i, notme, mask, bit, v, found; + void *ptr, *walker, *hints_end; + char *lastmod = NULL, *cp, *s; + + moduledir_readhints(mdp); + found = 0; + if (mdp->d_hints == NULL) + goto bad; + walker = mdp->d_hints; + hints_end = walker + mdp->d_hintsz; + while (walker < hints_end && !found) { + len = getint(&walker); + ival = getint(&walker); + ptr = walker; + switch (ival) { + case MDT_VERSION: + getstr(&ptr, val1); + ival = getint(&ptr); + getstr(&ptr, val2); + if (pnp_dump_flag || pnp_verbose_flag) + printf("Version: if %s.%d kmod %s\n", val1, ival, val2); + break; + case MDT_MODULE: + getstr(&ptr, val1); + getstr(&ptr, val2); + if (lastmod) + free(lastmod); + lastmod = strdup(val2); + if (pnp_dump_flag || pnp_verbose_flag) + printf("module %s in %s\n", val1, val1); + break; + case MDT_PNP_INFO: + if (!pnp_dump_flag && !pnp_unbound_flag && lastmod && strcmp(lastmod, "kernel") == 0) + break; + getstr(&ptr, val1); + getstr(&ptr, val2); + ents = getint(&ptr); + if (pnp_dump_flag || pnp_verbose_flag) + printf("PNP info for bus %s format %s %d entries (%s)\n", + val1, val2, ents, lastmod); + if (strcmp(val1, "usb") == 0) { + if (pnp_verbose_flag) + printf("Treating usb as uhub -- bug in source table still?\n"); + strcpy(val1, "uhub"); + } + if (bus && strcmp(val1, bus) != 0) { + if (pnp_verbose_flag) + printf("Skipped because table for bus %s, looking for %s\n", + val1, bus); + break; + } + for (i = 0; i < ents; i++) { + if (pnp_verbose_flag) + printf("---------- Entry %d ----------\n", i); + if (pnp_dump_flag) + printf(" "); + cp = val2; + notme = 0; + mask = -1; + bit = -1; + do { + switch (*cp) { + /* All integer fields */ + case 'I': + case 'J': + case 'G': + case 'L': + case 'M': + ival = getint(&ptr); + if (pnp_dump_flag) { + printf("%#x:", ival); + break; + } + if (bit >= 0 && ((1 << bit) & mask) == 0) + break; + v = pnpval_as_int(cp + 2, pnpinfo); + if (pnp_verbose_flag) + printf("Matching %s (%c) table=%#x tomatch=%#x\n", + cp + 2, *cp, v, ival); + switch (*cp) { + case 'J': + if (ival == -1) + break; + /*FALLTHROUGH*/ + case 'I': + if (v != ival) + notme++; + break; + case 'G': + if (v < ival) + notme++; + break; + case 'L': + if (v > ival) + notme++; + break; + case 'M': + mask = ival; + break; + } + break; + /* String fields */ + case 'D': + case 'Z': + getstr(&ptr, val1); + if (pnp_dump_flag) { + printf("'%s':", val1); + break; + } + if (*cp == 'D') + break; + s = pnpval_as_str(cp + 2, pnpinfo); + if (strcmp(s, val1) != 0) + notme++; + break; + /* Key override fields, required to be last in the string */ + case 'T': + /* + * This is imperfect and only does one key and will be redone + * to be more general for multiple keys. Currently, nothing + * does that. + */ + if (pnp_dump_flag) /* No per-row data stored */ + break; + if (cp[strlen(cp) - 1] == ';') /* Skip required ; at end */ + cp[strlen(cp) - 1] = '\0'; /* in case it's not there */ + if ((s = strstr(pnpinfo, cp + 2)) == NULL) + notme++; + else if (s > pnpinfo && s[-1] != ' ') + notme++; + break; + default: + printf("Unknown field type %c\n:", *cp); + break; + } + bit++; + cp = strchr(cp, ';'); + if (cp) + cp++; + } while (cp && *cp); + if (pnp_dump_flag) + printf("\n"); + else if (!notme) { + if (!pnp_unbound_flag) { + if (pnp_verbose_flag) + printf("Matches --- %s ---\n", lastmod); + } + found++; + } + } + break; + default: + break; + } + walker = (void *)(len - sizeof(int) + (intptr_t)walker); + } + if (pnp_unbound_flag && found == 0 && *pnpinfo) { + if (pnp_verbose_flag) + printf("------------------------- "); + printf("%s on %s pnpinfo %s", *dev ? dev : "unattached", bus, pnpinfo); + if (pnp_verbose_flag) + printf(" -------------------------"); + printf("\n"); + } + if (found != 0) + return (lastmod); + free(lastmod); + +bad: + return (NULL); +} + /* * Attempt to locate the file containing the module (name) */ @@ -924,6 +1386,26 @@ mod_searchmodule(char *name, struct mod_depend *verinf result = NULL; STAILQ_FOREACH(mdp, &moduledir_list, d_link) { result = mod_search_hints(mdp, name, verinfo); + if (result) + break; + } + + return(result); +} + +static char * +mod_searchmodule_pnpinfo(const char *bus, const char *pnpinfo) +{ + struct moduledir *mdp; + char *result; + + moduledir_rebuild(); + /* + * Now we ready to lookup module in the given directories + */ + result = NULL; + STAILQ_FOREACH(mdp, &moduledir_list, d_link) { + result = devmatch_search_hints(mdp, bus, NULL, pnpinfo); if (result) break; } Modified: stable/12/stand/fdt/fdt_loader_cmd.c ============================================================================== --- stable/12/stand/fdt/fdt_loader_cmd.c Thu Oct 24 03:01:40 2019 (r353983) +++ stable/12/stand/fdt/fdt_loader_cmd.c Thu Oct 24 03:04:36 2019 (r353984) @@ -67,6 +67,8 @@ static struct fdt_header *fdt_to_load = NULL; static struct fdt_header *fdtp = NULL; /* Size of FDT blob */ static size_t fdtp_size = 0; +/* Have we loaded all the needed overlays */ +static int fdt_overlays_applied = 0; static int fdt_load_dtb(vm_offset_t va); static void fdt_print_overlay_load_error(int err, const char *filename); @@ -439,6 +441,9 @@ fdt_apply_overlays() if ((fdtp == NULL) || (fdtp_size == 0)) return; + if (fdt_overlays_applied) + return; + max_overlay_size = 0; for (fp = file_findfile(NULL, "dtbo"); fp != NULL; fp = fp->f_next) { if (max_overlay_size < fp->f_size) @@ -507,6 +512,7 @@ fdt_apply_overlays() fdtp_size = current_fdtp_size; } free(overlay); + fdt_overlays_applied = 1; } int @@ -1858,4 +1864,66 @@ fdt_cmd_nyi(int argc, char *argv[]) printf("command not yet implemented\n"); return (CMD_ERROR); +} + +const char * +fdt_devmatch_next(int *tag, int *compatlen) +{ + const struct fdt_property *p; + const struct fdt_property *status; + int o, len = -1; + static int depth = 0; + + if (fdtp == NULL) { + fdt_setup_fdtp(); + fdt_apply_overlays(); + } + + if (*tag != 0) { + o = *tag; + /* We are at the end of the DTB */ + if (o < 0) + return (NULL); + } else { + o = fdt_path_offset(fdtp, "/"); + if (o < 0) { + printf("Can't find dtb\n"); + return (NULL); + } + depth = 0; + } + + /* Find the next node with a compatible property */ + while (1) { + p = NULL; + if (o >= 0 && depth >= 0) { + /* skip disabled nodes */ + status = fdt_get_property(fdtp, o, "status", &len); + if (len > 0) { + if (strcmp(status->data, "disabled") == 0) { + o = fdt_next_node(fdtp, o, &depth); + if (o < 0) /* End of tree */ + return (NULL); + continue; + } + } + + p = fdt_get_property(fdtp, o, "compatible", &len); + } + if (p) + break; + o = fdt_next_node(fdtp, o, &depth); + if (o < 0) /* End of tree */ + return (NULL); + } + + /* Prepare next node for next call */ + o = fdt_next_node(fdtp, o, &depth); + *tag = o; + + if (len >= 0) { + *compatlen = len; + return (p->data); + } + return (NULL); } Modified: stable/12/stand/fdt/fdt_platform.h ============================================================================== --- stable/12/stand/fdt/fdt_platform.h Thu Oct 24 03:01:40 2019 (r353983) +++ stable/12/stand/fdt/fdt_platform.h Thu Oct 24 03:04:36 2019 (r353984) @@ -55,4 +55,7 @@ int fdt_platform_load_dtb(void); void fdt_platform_load_overlays(void); void fdt_platform_fixups(void); +/* Devmatch/pnp function */ +const char *fdt_devmatch_next(int *tag, int *compatlen); + #endif /* FDT_PLATFORM_H */ From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:09:31 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id CA339151882; Thu, 24 Oct 2019 03:09:31 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBzv4yJsz4Fxn; Thu, 24 Oct 2019 03:09:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8E9347B02; Thu, 24 Oct 2019 03:09:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O39VVK007170; Thu, 24 Oct 2019 03:09:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O39Vr8007169; Thu, 24 Oct 2019 03:09:31 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240309.x9O39Vr8007169@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:09:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353987 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 353987 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:09:31 -0000 Author: kevans Date: Thu Oct 24 03:09:31 2019 New Revision: 353987 URL: https://svnweb.freebsd.org/changeset/base/353987 Log: MFC r348499: Fix comment parsing in interp_simple.c loader.rc has comment lines without a trailing space, which get interpreted as commands. Avoid this by only matching against the backslash character. Modified: stable/12/stand/common/interp_simple.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/interp_simple.c ============================================================================== --- stable/12/stand/common/interp_simple.c Thu Oct 24 03:08:11 2019 (r353986) +++ stable/12/stand/common/interp_simple.c Thu Oct 24 03:09:31 2019 (r353987) @@ -114,7 +114,7 @@ interp_include(const char *filename) line++; flags = 0; /* Discard comments */ - if (strncmp(input+strspn(input, " "), "\\ ", 2) == 0) + if (strncmp(input+strspn(input, " "), "\\", 1) == 0) continue; cp = input; /* Echo? */ From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:28:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 047F11721A2; Thu, 24 Oct 2019 02:28:29 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zB4X5GCsz47nZ; Thu, 24 Oct 2019 02:28:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9880273D1; Thu, 24 Oct 2019 02:28:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2SS7p081604; Thu, 24 Oct 2019 02:28:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2SSCN081603; Thu, 24 Oct 2019 02:28:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240228.x9O2SSCN081603@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:28:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353972 - stable/12/stand/i386/libfirewire X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/i386/libfirewire X-SVN-Commit-Revision: 353972 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:28:29 -0000 Author: kevans Date: Thu Oct 24 02:28:28 2019 New Revision: 353972 URL: https://svnweb.freebsd.org/changeset/base/353972 Log: MFC r342865: biospci_write_config args were backwards biospci_write_config args swapped length and value to write. Some hardware coped just fine, while other hardware had issues. PR: 155441 Modified: stable/12/stand/i386/libfirewire/firewire.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/i386/libfirewire/firewire.c ============================================================================== --- stable/12/stand/i386/libfirewire/firewire.c Thu Oct 24 02:27:16 2019 (r353971) +++ stable/12/stand/i386/libfirewire/firewire.c Thu Oct 24 02:28:28 2019 (r353972) @@ -107,9 +107,9 @@ fw_probe(int index, struct fwohci_softc *sc) } biospci_write_config(sc->locator, - 0x4 /* command */, - 0x6 /* enable bus master and memory mapped I/O */, - BIOSPCI_16BITS); + 0x4 /* command */, + BIOSPCI_16BITS, + 0x6 /* enable bus master and memory mapped I/O */); biospci_read_config(sc->locator, 0x00 /*devid*/, BIOSPCI_32BITS, &sc->devid); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:19:45 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E32DF15354B; Thu, 24 Oct 2019 03:19:45 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCCj5fNrz4HJ7; Thu, 24 Oct 2019 03:19:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A6AD87CE6; Thu, 24 Oct 2019 03:19:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3Jjrn013357; Thu, 24 Oct 2019 03:19:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3Jjkc013356; Thu, 24 Oct 2019 03:19:45 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240319.x9O3Jjkc013356@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:19:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353989 - stable/12/stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 353989 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:19:46 -0000 Author: kevans Date: Thu Oct 24 03:19:45 2019 New Revision: 353989 URL: https://svnweb.freebsd.org/changeset/base/353989 Log: MFC r349217: Tell loader to ignore newer features enabled on the root pool. There are many new features in ZoF. Most, if not all, do not effect read only usage. Encryption in particular is enabled at the pool level but used at the dataset level. The loader obviously will not be able to boot if the boot dataset is encrypted, but should not care if some other dataset in the root pool is encrypted. Modified: stable/12/stand/libsa/zfs/zfsimpl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:16:23 2019 (r353988) +++ stable/12/stand/libsa/zfs/zfsimpl.c Thu Oct 24 03:19:45 2019 (r353989) @@ -117,6 +117,12 @@ static const char *features_for_read[] = { "org.illumos:skein", "org.zfsonlinux:large_dnode", "com.joyent:multi_vdev_crash_dump", + "com.delphix:spacemap_histogram", + "com.delphix:zpool_checkpoint", + "com.delphix:spacemap_v2", + "com.datto:encryption", + "org.zfsonlinux:allocation_classes", + "com.datto:resilver_defer", "com.delphix:device_removal", "com.delphix:obsolete_counts", NULL From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:30:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6B2161729F8; Thu, 24 Oct 2019 02:30:54 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zB7L2923z48BS; Thu, 24 Oct 2019 02:30:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 168B973F6; Thu, 24 Oct 2019 02:30:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2UrKM081815; Thu, 24 Oct 2019 02:30:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2UrRi081814; Thu, 24 Oct 2019 02:30:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240230.x9O2UrRi081814@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:30:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353973 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 353973 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:30:54 -0000 Author: kevans Date: Thu Oct 24 02:30:53 2019 New Revision: 353973 URL: https://svnweb.freebsd.org/changeset/base/353973 Log: Record MFC of r343911, MFC'd in r346718 Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:32:23 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B6D0B172E99; Thu, 24 Oct 2019 02:32:23 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zB934Pqmz48Vn; Thu, 24 Oct 2019 02:32:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 61DD9757C; Thu, 24 Oct 2019 02:32:23 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2WNMp086579; Thu, 24 Oct 2019 02:32:23 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2WNeh086578; Thu, 24 Oct 2019 02:32:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240232.x9O2WNeh086578@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:32:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353974 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 353974 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:32:23 -0000 Author: kevans Date: Thu Oct 24 02:32:22 2019 New Revision: 353974 URL: https://svnweb.freebsd.org/changeset/base/353974 Log: Record MFC or r344839, MFC'd in r352788 Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:33:58 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D09017322F; Thu, 24 Oct 2019 02:33:58 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBBt0YTLz48j4; Thu, 24 Oct 2019 02:33:58 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EB77D758E; Thu, 24 Oct 2019 02:33:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2Xv3K087486; Thu, 24 Oct 2019 02:33:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2XvF8087485; Thu, 24 Oct 2019 02:33:57 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240233.x9O2XvF8087485@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:33:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353976 - stable/12/stand/common X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/common X-SVN-Commit-Revision: 353976 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:33:58 -0000 Author: kevans Date: Thu Oct 24 02:33:57 2019 New Revision: 353976 URL: https://svnweb.freebsd.org/changeset/base/353976 Log: MFC r344892: stand/common/module: Apply style(9) Modified: stable/12/stand/common/module.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/module.c ============================================================================== --- stable/12/stand/common/module.c Thu Oct 24 02:33:12 2019 (r353975) +++ stable/12/stand/common/module.c Thu Oct 24 02:33:57 2019 (r353976) @@ -102,63 +102,63 @@ COMMAND_SET(load, "load", "load a kernel or module", c static int command_load(int argc, char *argv[]) { - struct preloaded_file *fp; - char *typestr; - char *prefix; - char *skip; - int dflag, dofile, dokld, ch, error; + struct preloaded_file *fp; + char *typestr; + char *prefix; + char *skip; + int dflag, dofile, dokld, ch, error; - dflag = dokld = dofile = 0; - optind = 1; - optreset = 1; - typestr = NULL; - if (argc == 1) { - command_errmsg = "no filename specified"; - return (CMD_CRIT); - } - prefix = skip = NULL; - while ((ch = getopt(argc, argv, "dkp:s:t:")) != -1) { - switch(ch) { - case 'd': - dflag++; - break; - case 'k': - dokld = 1; - break; - case 'p': - prefix = optarg; - break; - case 's': - skip = optarg; - break; - case 't': - typestr = optarg; - dofile = 1; - break; - case '?': - default: - /* getopt has already reported an error */ - return (CMD_OK); + dflag = dokld = dofile = 0; + optind = 1; + optreset = 1; + typestr = NULL; + if (argc == 1) { + command_errmsg = "no filename specified"; + return (CMD_CRIT); } - } - argv += (optind - 1); - argc -= (optind - 1); - - /* - * Request to load a raw file? - */ - if (dofile) { - if ((argc != 2) || (typestr == NULL) || (*typestr == 0)) { - command_errmsg = "invalid load type"; - return (CMD_CRIT); + prefix = skip = NULL; + while ((ch = getopt(argc, argv, "dkp:s:t:")) != -1) { + switch(ch) { + case 'd': + dflag++; + break; + case 'k': + dokld = 1; + break; + case 'p': + prefix = optarg; + break; + case 's': + skip = optarg; + break; + case 't': + typestr = optarg; + dofile = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return (CMD_OK); + } } + argv += (optind - 1); + argc -= (optind - 1); + /* + * Request to load a raw file? + */ + if (dofile) { + if ((argc != 2) || (typestr == NULL) || (*typestr == 0)) { + command_errmsg = "invalid load type"; + return (CMD_CRIT); + } + #ifdef LOADER_VERIEXEC - if (strncmp(typestr, "manifest", 8) == 0) { - if (dflag > 0) - ve_debug_set(dflag); - return (load_manifest(argv[1], prefix, skip, NULL)); - } + if (strncmp(typestr, "manifest", 8) == 0) { + if (dflag > 0) + ve_debug_set(dflag); + return (load_manifest(argv[1], prefix, skip, NULL)); + } #ifdef LOADER_VERIEXEC_PASS_MANIFEST if (strncmp(typestr, "pass_manifest", 13) == 0) { if (dflag > 0) @@ -168,46 +168,46 @@ command_load(int argc, char *argv[]) #endif #endif - fp = file_findfile(argv[1], typestr); - if (fp) { - snprintf(command_errbuf, sizeof(command_errbuf), - "warning: file '%s' already loaded", argv[1]); - return (CMD_WARN); - } + fp = file_findfile(argv[1], typestr); + if (fp) { + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: file '%s' already loaded", argv[1]); + return (CMD_WARN); + } - if (file_loadraw(argv[1], typestr, 1) != NULL) - return (CMD_OK); + if (file_loadraw(argv[1], typestr, 1) != NULL) + return (CMD_OK); - /* Failing to load mfs_root is never going to end well! */ - if (strcmp("mfs_root", typestr) == 0) - return (CMD_FATAL); + /* Failing to load mfs_root is never going to end well! */ + if (strcmp("mfs_root", typestr) == 0) + return (CMD_FATAL); - return (CMD_ERROR); - } - /* - * Do we have explicit KLD load ? - */ - if (dokld || file_havepath(argv[1])) { - error = mod_loadkld(argv[1], argc - 2, argv + 2); - if (error == EEXIST) { - snprintf(command_errbuf, sizeof(command_errbuf), - "warning: KLD '%s' already loaded", argv[1]); - return (CMD_WARN); + return (CMD_ERROR); } + /* + * Do we have explicit KLD load ? + */ + if (dokld || file_havepath(argv[1])) { + error = mod_loadkld(argv[1], argc - 2, argv + 2); + if (error == EEXIST) { + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: KLD '%s' already loaded", argv[1]); + return (CMD_WARN); + } - return (error == 0 ? CMD_OK : CMD_CRIT); - } - /* - * Looks like a request for a module. - */ - error = mod_load(argv[1], NULL, argc - 2, argv + 2); - if (error == EEXIST) { - snprintf(command_errbuf, sizeof(command_errbuf), - "warning: module '%s' already loaded", argv[1]); - return (CMD_WARN); - } + return (error == 0 ? CMD_OK : CMD_CRIT); + } + /* + * Looks like a request for a module. + */ + error = mod_load(argv[1], NULL, argc - 2, argv + 2); + if (error == EEXIST) { + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: module '%s' already loaded", argv[1]); + return (CMD_WARN); + } - return (error == 0 ? CMD_OK : CMD_CRIT); + return (error == 0 ? CMD_OK : CMD_CRIT); } #ifdef LOADER_GELI_SUPPORT @@ -216,53 +216,53 @@ COMMAND_SET(load_geli, "load_geli", "load a geli key", static int command_load_geli(int argc, char *argv[]) { - char typestr[80]; - char *cp; - int ch, num; + char typestr[80]; + char *cp; + int ch, num; - if (argc < 3) { - command_errmsg = "usage is [-n key#] "; - return(CMD_ERROR); - } + if (argc < 3) { + command_errmsg = "usage is [-n key#] "; + return(CMD_ERROR); + } - num = 0; - optind = 1; - optreset = 1; - while ((ch = getopt(argc, argv, "n:")) != -1) { - switch(ch) { - case 'n': - num = strtol(optarg, &cp, 0); - if (cp == optarg) { - snprintf(command_errbuf, sizeof(command_errbuf), - "bad key index '%s'", optarg); - return(CMD_ERROR); - } - break; - case '?': - default: - /* getopt has already reported an error */ - return(CMD_OK); + num = 0; + optind = 1; + optreset = 1; + while ((ch = getopt(argc, argv, "n:")) != -1) { + switch(ch) { + case 'n': + num = strtol(optarg, &cp, 0); + if (cp == optarg) { + snprintf(command_errbuf, sizeof(command_errbuf), + "bad key index '%s'", optarg); + return(CMD_ERROR); + } + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } } - } - argv += (optind - 1); - argc -= (optind - 1); - sprintf(typestr, "%s:geli_keyfile%d", argv[1], num); - return (file_loadraw(argv[2], typestr, 1) ? CMD_OK : CMD_ERROR); + argv += (optind - 1); + argc -= (optind - 1); + sprintf(typestr, "%s:geli_keyfile%d", argv[1], num); + return (file_loadraw(argv[2], typestr, 1) ? CMD_OK : CMD_ERROR); } #endif void unload(void) { - struct preloaded_file *fp; + struct preloaded_file *fp; - while (preloaded_files != NULL) { - fp = preloaded_files; - preloaded_files = preloaded_files->f_next; - file_discard(fp); - } - loadaddr = 0; - unsetenv("kernelname"); + while (preloaded_files != NULL) { + fp = preloaded_files; + preloaded_files = preloaded_files->f_next; + file_discard(fp); + } + loadaddr = 0; + unsetenv("kernelname"); } COMMAND_SET(unload, "unload", "unload all modules", command_unload); @@ -270,8 +270,8 @@ COMMAND_SET(unload, "unload", "unload all modules", co static int command_unload(int argc, char *argv[]) { - unload(); - return(CMD_OK); + unload(); + return(CMD_OK); } COMMAND_SET(lsmod, "lsmod", "list loaded modules", command_lsmod); @@ -279,66 +279,66 @@ COMMAND_SET(lsmod, "lsmod", "list loaded modules", com static int command_lsmod(int argc, char *argv[]) { - struct preloaded_file *fp; - struct kernel_module *mp; - struct file_metadata *md; - char lbuf[80]; - int ch, verbose, ret = 0; + struct preloaded_file *fp; + struct kernel_module *mp; + struct file_metadata *md; + char lbuf[80]; + int ch, verbose, ret = 0; - verbose = 0; - optind = 1; - optreset = 1; - while ((ch = getopt(argc, argv, "v")) != -1) { - switch(ch) { - case 'v': - verbose = 1; - break; - case '?': - default: - /* getopt has already reported an error */ - return(CMD_OK); + verbose = 0; + optind = 1; + optreset = 1; + while ((ch = getopt(argc, argv, "v")) != -1) { + switch(ch) { + case 'v': + verbose = 1; + break; + case '?': + default: + /* getopt has already reported an error */ + return(CMD_OK); + } } - } - pager_open(); - for (fp = preloaded_files; fp; fp = fp->f_next) { - snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr); - pager_output(lbuf); - pager_output(fp->f_name); - snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type, - (long)fp->f_size); - if (pager_output(lbuf)) - break; - if (fp->f_args != NULL) { - pager_output(" args: "); - pager_output(fp->f_args); - if (pager_output("\n")) - break; - } - if (fp->f_modules) { - pager_output(" modules: "); - for (mp = fp->f_modules; mp; mp = mp->m_next) { - snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name, - mp->m_version); + pager_open(); + for (fp = preloaded_files; fp; fp = fp->f_next) { + snprintf(lbuf, sizeof(lbuf), " %p: ", (void *) fp->f_addr); pager_output(lbuf); - } - if (pager_output("\n")) - break; - } - if (verbose) { - /* XXX could add some formatting smarts here to display some better */ - for (md = fp->f_metadata; md != NULL; md = md->md_next) { - snprintf(lbuf, sizeof(lbuf), " 0x%04x, 0x%lx\n", - md->md_type, (long) md->md_size); + pager_output(fp->f_name); + snprintf(lbuf, sizeof(lbuf), " (%s, 0x%lx)\n", fp->f_type, + (long)fp->f_size); if (pager_output(lbuf)) break; - } + if (fp->f_args != NULL) { + pager_output(" args: "); + pager_output(fp->f_args); + if (pager_output("\n")) + break; + } + if (fp->f_modules) { + pager_output(" modules: "); + for (mp = fp->f_modules; mp; mp = mp->m_next) { + snprintf(lbuf, sizeof(lbuf), "%s.%d ", mp->m_name, + mp->m_version); + pager_output(lbuf); + } + if (pager_output("\n")) + break; + } + if (verbose) { + /* XXX could add some formatting smarts here to display some better */ + for (md = fp->f_metadata; md != NULL; md = md->md_next) { + snprintf(lbuf, sizeof(lbuf), " 0x%04x, 0x%lx\n", + md->md_type, (long) md->md_size); + if (pager_output(lbuf)) + break; + } + } + if (ret) + break; } - if (ret) - break; - } - pager_close(); - return(CMD_OK); + pager_close(); + return(CMD_OK); } /* @@ -347,86 +347,86 @@ command_lsmod(int argc, char *argv[]) int file_load(char *filename, vm_offset_t dest, struct preloaded_file **result) { - static int last_file_format = 0; - struct preloaded_file *fp; - int error; - int i; + static int last_file_format = 0; + struct preloaded_file *fp; + int error; + int i; - if (archsw.arch_loadaddr != NULL) - dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest); + if (archsw.arch_loadaddr != NULL) + dest = archsw.arch_loadaddr(LOAD_RAW, filename, dest); - error = EFTYPE; - for (i = last_file_format, fp = NULL; - file_formats[i] && fp == NULL; i++) { - error = (file_formats[i]->l_load)(filename, dest, &fp); - if (error == 0) { - fp->f_loader = last_file_format = i; /* remember the loader */ - *result = fp; - break; - } else if (last_file_format == i && i != 0) { - /* Restart from the beginning */ - i = -1; - last_file_format = 0; - fp = NULL; - continue; + error = EFTYPE; + for (i = last_file_format, fp = NULL; + file_formats[i] && fp == NULL; i++) { + error = (file_formats[i]->l_load)(filename, dest, &fp); + if (error == 0) { + fp->f_loader = last_file_format = i; /* remember the loader */ + *result = fp; + break; + } else if (last_file_format == i && i != 0) { + /* Restart from the beginning */ + i = -1; + last_file_format = 0; + fp = NULL; + continue; + } + if (error == EFTYPE) + continue; /* Unknown to this handler? */ + if (error) { + snprintf(command_errbuf, sizeof(command_errbuf), + "can't load file '%s': %s", filename, strerror(error)); + break; + } } - if (error == EFTYPE) - continue; /* Unknown to this handler? */ - if (error) { - snprintf(command_errbuf, sizeof(command_errbuf), - "can't load file '%s': %s", filename, strerror(error)); - break; - } - } - return (error); + return (error); } static int file_load_dependencies(struct preloaded_file *base_file) { - struct file_metadata *md; - struct preloaded_file *fp; - struct mod_depend *verinfo; - struct kernel_module *mp; - char *dmodname; - int error; + struct file_metadata *md; + struct preloaded_file *fp; + struct mod_depend *verinfo; + struct kernel_module *mp; + char *dmodname; + int error; - md = file_findmetadata(base_file, MODINFOMD_DEPLIST); - if (md == NULL) - return (0); - error = 0; - do { - verinfo = (struct mod_depend*)md->md_data; - dmodname = (char *)(verinfo + 1); - if (file_findmodule(NULL, dmodname, verinfo) == NULL) { - printf("loading required module '%s'\n", dmodname); - error = mod_load(dmodname, verinfo, 0, NULL); - if (error) - break; - /* - * If module loaded via kld name which isn't listed - * in the linker.hints file, we should check if it have - * required version. - */ - mp = file_findmodule(NULL, dmodname, verinfo); - if (mp == NULL) { - snprintf(command_errbuf, sizeof(command_errbuf), - "module '%s' exists but with wrong version", dmodname); - error = ENOENT; - break; - } + md = file_findmetadata(base_file, MODINFOMD_DEPLIST); + if (md == NULL) + return (0); + error = 0; + do { + verinfo = (struct mod_depend*)md->md_data; + dmodname = (char *)(verinfo + 1); + if (file_findmodule(NULL, dmodname, verinfo) == NULL) { + printf("loading required module '%s'\n", dmodname); + error = mod_load(dmodname, verinfo, 0, NULL); + if (error) + break; + /* + * If module loaded via kld name which isn't listed + * in the linker.hints file, we should check if it have + * required version. + */ + mp = file_findmodule(NULL, dmodname, verinfo); + if (mp == NULL) { + snprintf(command_errbuf, sizeof(command_errbuf), + "module '%s' exists but with wrong version", dmodname); + error = ENOENT; + break; + } + } + md = metadata_next(md, MODINFOMD_DEPLIST); + } while (md); + if (!error) + return (0); + /* Load failed; discard everything */ + while (base_file != NULL) { + fp = base_file; + base_file = base_file->f_next; + file_discard(fp); } - md = metadata_next(md, MODINFOMD_DEPLIST); - } while (md); - if (!error) - return (0); - /* Load failed; discard everything */ - while (base_file != NULL) { - fp = base_file; - base_file = base_file->f_next; - file_discard(fp); - } - return (error); + return (error); } /* @@ -436,82 +436,82 @@ file_load_dependencies(struct preloaded_file *base_fil struct preloaded_file * file_loadraw(const char *fname, char *type, int insert) { - struct preloaded_file *fp; - char *name; - int fd, got; - vm_offset_t laddr; + struct preloaded_file *fp; + char *name; + int fd, got; + vm_offset_t laddr; - /* We can't load first */ - if ((file_findfile(NULL, NULL)) == NULL) { - command_errmsg = "can't load file before kernel"; - return(NULL); - } + /* We can't load first */ + if ((file_findfile(NULL, NULL)) == NULL) { + command_errmsg = "can't load file before kernel"; + return(NULL); + } - /* locate the file on the load path */ - name = file_search(fname, NULL); - if (name == NULL) { - snprintf(command_errbuf, sizeof(command_errbuf), - "can't find '%s'", fname); - return(NULL); - } + /* locate the file on the load path */ + name = file_search(fname, NULL); + if (name == NULL) { + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", fname); + return(NULL); + } - if ((fd = open(name, O_RDONLY)) < 0) { - snprintf(command_errbuf, sizeof(command_errbuf), - "can't open '%s': %s", name, strerror(errno)); - free(name); - return(NULL); - } + if ((fd = open(name, O_RDONLY)) < 0) { + snprintf(command_errbuf, sizeof(command_errbuf), + "can't open '%s': %s", name, strerror(errno)); + free(name); + return(NULL); + } #ifdef LOADER_VERIEXEC - if (verify_file(fd, name, 0, VE_MUST) < 0) { - sprintf(command_errbuf, "can't verify '%s'", name); - free(name); - close(fd); - return(NULL); - } + if (verify_file(fd, name, 0, VE_MUST) < 0) { + sprintf(command_errbuf, "can't verify '%s'", name); + free(name); + close(fd); + return(NULL); + } #endif - if (archsw.arch_loadaddr != NULL) - loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr); + if (archsw.arch_loadaddr != NULL) + loadaddr = archsw.arch_loadaddr(LOAD_RAW, name, loadaddr); - printf("%s ", name); + printf("%s ", name); - laddr = loadaddr; - for (;;) { - /* read in 4k chunks; size is not really important */ - got = archsw.arch_readin(fd, laddr, 4096); - if (got == 0) /* end of file */ - break; - if (got < 0) { /* error */ - snprintf(command_errbuf, sizeof(command_errbuf), - "error reading '%s': %s", name, strerror(errno)); - free(name); - close(fd); - return(NULL); + laddr = loadaddr; + for (;;) { + /* read in 4k chunks; size is not really important */ + got = archsw.arch_readin(fd, laddr, 4096); + if (got == 0) /* end of file */ + break; + if (got < 0) { /* error */ + snprintf(command_errbuf, sizeof(command_errbuf), + "error reading '%s': %s", name, strerror(errno)); + free(name); + close(fd); + return(NULL); + } + laddr += got; } - laddr += got; - } - printf("size=%#jx\n", (uintmax_t)(laddr - loadaddr)); + printf("size=%#jx\n", (uintmax_t)(laddr - loadaddr)); - /* Looks OK so far; create & populate control structure */ - fp = file_alloc(); - fp->f_name = strdup(name); - fp->f_type = strdup(type); - fp->f_args = NULL; - fp->f_metadata = NULL; - fp->f_loader = -1; - fp->f_addr = loadaddr; - fp->f_size = laddr - loadaddr; + /* Looks OK so far; create & populate control structure */ + fp = file_alloc(); + fp->f_name = strdup(name); + fp->f_type = strdup(type); + fp->f_args = NULL; + fp->f_metadata = NULL; + fp->f_loader = -1; + fp->f_addr = loadaddr; + fp->f_size = laddr - loadaddr; - /* recognise space consumption */ - loadaddr = laddr; + /* recognise space consumption */ + loadaddr = laddr; - /* Add to the list of loaded files */ - if (insert != 0) - file_insert_tail(fp); - close(fd); - return(fp); + /* Add to the list of loaded files */ + if (insert != 0) + file_insert_tail(fp); + close(fd); + return(fp); } /* @@ -522,35 +522,35 @@ file_loadraw(const char *fname, char *type, int insert int mod_load(char *modname, struct mod_depend *verinfo, int argc, char *argv[]) { - struct kernel_module *mp; - int err; - char *filename; + struct kernel_module *mp; + int err; + char *filename; - if (file_havepath(modname)) { - printf("Warning: mod_load() called instead of mod_loadkld() for module '%s'\n", modname); - return (mod_loadkld(modname, argc, argv)); - } - /* see if module is already loaded */ - mp = file_findmodule(NULL, modname, verinfo); - if (mp) { + if (file_havepath(modname)) { + printf("Warning: mod_load() called instead of mod_loadkld() for module '%s'\n", modname); + return (mod_loadkld(modname, argc, argv)); + } + /* see if module is already loaded */ + mp = file_findmodule(NULL, modname, verinfo); + if (mp) { #ifdef moduleargs - if (mp->m_args) - free(mp->m_args); - mp->m_args = unargv(argc, argv); + if (mp->m_args) + free(mp->m_args); + mp->m_args = unargv(argc, argv); #endif - snprintf(command_errbuf, sizeof(command_errbuf), - "warning: module '%s' already loaded", mp->m_name); - return (0); - } - /* locate file with the module on the search path */ - filename = mod_searchmodule(modname, verinfo); - if (filename == NULL) { - snprintf(command_errbuf, sizeof(command_errbuf), - "can't find '%s'", modname); - return (ENOENT); - } - err = mod_loadkld(filename, argc, argv); - return (err); + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: module '%s' already loaded", mp->m_name); + return (0); + } + /* locate file with the module on the search path */ + filename = mod_searchmodule(modname, verinfo); + if (filename == NULL) { + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", modname); + return (ENOENT); + } + err = mod_loadkld(filename, argc, argv); + return (err); } /* @@ -560,57 +560,57 @@ mod_load(char *modname, struct mod_depend *verinfo, in int mod_loadkld(const char *kldname, int argc, char *argv[]) { - struct preloaded_file *fp, *last_file; - int err; - char *filename; + struct preloaded_file *fp, *last_file; + int err; + char *filename; - /* - * Get fully qualified KLD name - */ - filename = file_search(kldname, kld_ext_list); - if (filename == NULL) { - snprintf(command_errbuf, sizeof(command_errbuf), - "can't find '%s'", kldname); - return (ENOENT); - } - /* - * Check if KLD already loaded - */ - fp = file_findfile(filename, NULL); - if (fp) { - snprintf(command_errbuf, sizeof(command_errbuf), - "warning: KLD '%s' already loaded", filename); - free(filename); - return (0); - } - for (last_file = preloaded_files; - last_file != NULL && last_file->f_next != NULL; - last_file = last_file->f_next) - ; + /* + * Get fully qualified KLD name + */ + filename = file_search(kldname, kld_ext_list); + if (filename == NULL) { + snprintf(command_errbuf, sizeof(command_errbuf), + "can't find '%s'", kldname); + return (ENOENT); + } + /* + * Check if KLD already loaded + */ + fp = file_findfile(filename, NULL); + if (fp) { + snprintf(command_errbuf, sizeof(command_errbuf), + "warning: KLD '%s' already loaded", filename); + free(filename); + return (0); + } + for (last_file = preloaded_files; + last_file != NULL && last_file->f_next != NULL; + last_file = last_file->f_next) + ; - do { - err = file_load(filename, loadaddr, &fp); - if (err) - break; - fp->f_args = unargv(argc, argv); - loadaddr = fp->f_addr + fp->f_size; - file_insert_tail(fp); /* Add to the list of loaded files */ - if (file_load_dependencies(fp) != 0) { - err = ENOENT; - last_file->f_next = NULL; - loadaddr = last_file->f_addr + last_file->f_size; - fp = NULL; - break; + do { + err = file_load(filename, loadaddr, &fp); + if (err) + break; + fp->f_args = unargv(argc, argv); + loadaddr = fp->f_addr + fp->f_size; + file_insert_tail(fp); /* Add to the list of loaded files */ + if (file_load_dependencies(fp) != 0) { + err = ENOENT; + last_file->f_next = NULL; + loadaddr = last_file->f_addr + last_file->f_size; + fp = NULL; + break; + } + } while(0); + if (err == EFTYPE) { + snprintf(command_errbuf, sizeof(command_errbuf), + "don't know how to load module '%s'", filename); } - } while(0); - if (err == EFTYPE) { - snprintf(command_errbuf, sizeof(command_errbuf), - "don't know how to load module '%s'", filename); - } - if (err && fp) - file_discard(fp); - free(filename); - return (err); + if (err && fp) + file_discard(fp); + free(filename); + return (err); } /* @@ -620,14 +620,14 @@ mod_loadkld(const char *kldname, int argc, char *argv[ struct preloaded_file * file_findfile(const char *name, const char *type) { - struct preloaded_file *fp; + struct preloaded_file *fp; - for (fp = preloaded_files; fp != NULL; fp = fp->f_next) { - if (((name == NULL) || !strcmp(name, fp->f_name)) && - ((type == NULL) || !strcmp(type, fp->f_type))) - break; - } - return (fp); + for (fp = preloaded_files; fp != NULL; fp = fp->f_next) { + if (((name == NULL) || !strcmp(name, fp->f_name)) && + ((type == NULL) || !strcmp(type, fp->f_type))) + break; + } + return (fp); } /* @@ -638,35 +638,35 @@ struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo) { - struct kernel_module *mp, *best; - int bestver, mver; + struct kernel_module *mp, *best; + int bestver, mver; - if (fp == NULL) { - for (fp = preloaded_files; fp; fp = fp->f_next) { - mp = file_findmodule(fp, modname, verinfo); - if (mp) - return (mp); + if (fp == NULL) { + for (fp = preloaded_files; fp; fp = fp->f_next) { + mp = file_findmodule(fp, modname, verinfo); + if (mp) + return (mp); + } + return (NULL); } - return (NULL); - } - best = NULL; - bestver = 0; - for (mp = fp->f_modules; mp; mp = mp->m_next) { - if (strcmp(modname, mp->m_name) == 0) { - if (verinfo == NULL) - return (mp); - mver = mp->m_version; - if (mver == verinfo->md_ver_preferred) - return (mp); - if (mver >= verinfo->md_ver_minimum && - mver <= verinfo->md_ver_maximum && - mver > bestver) { - best = mp; - bestver = mver; - } + best = NULL; + bestver = 0; + for (mp = fp->f_modules; mp; mp = mp->m_next) { + if (strcmp(modname, mp->m_name) == 0) { + if (verinfo == NULL) + return (mp); + mver = mp->m_version; + if (mver == verinfo->md_ver_preferred) + return (mp); + if (mver >= verinfo->md_ver_minimum && + mver <= verinfo->md_ver_maximum && + mver > bestver) { + best = mp; + bestver = mver; + } + } } - } - return (best); + return (best); } /* * Make a copy of (size) bytes of data from (p), and associate them as @@ -675,14 +675,14 @@ file_findmodule(struct preloaded_file *fp, char *modna void file_addmetadata(struct preloaded_file *fp, int type, size_t size, void *p) { - struct file_metadata *md; + struct file_metadata *md; - md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size); - md->md_size = size; - md->md_type = type; - bcopy(p, md->md_data, size); - md->md_next = fp->f_metadata; - fp->f_metadata = md; + md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size); + md->md_size = size; + md->md_type = type; + bcopy(p, md->md_data, size); + md->md_next = fp->f_metadata; + fp->f_metadata = md; } /* @@ -691,12 +691,12 @@ file_addmetadata(struct preloaded_file *fp, int type, struct file_metadata * file_findmetadata(struct preloaded_file *fp, int type) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Thu Oct 24 02:36:43 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 036F8173961; Thu, 24 Oct 2019 02:36:43 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBG267TVz498f; Thu, 24 Oct 2019 02:36:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B2BC37590; Thu, 24 Oct 2019 02:36:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O2agQA087739; Thu, 24 Oct 2019 02:36:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O2agZH087738; Thu, 24 Oct 2019 02:36:42 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240236.x9O2agZH087738@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 02:36:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353978 - in stable/12/stand: common efi/loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: common efi/loader X-SVN-Commit-Revision: 353978 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 02:36:43 -0000 Author: kevans Date: Thu Oct 24 02:36:42 2019 New Revision: 353978 URL: https://svnweb.freebsd.org/changeset/base/353978 Log: MFC r345998-r346002, r346007-r346008: various loader improvements r345998: loader: malloc+bzero is calloc Replace malloc+bzero in module.c with calloc. r345999: loader: file_addmodule should check for memory allocation strdup() can return NULL. r346000: loader: remove pointer checks before free() in module.c free() does check for NULL argument, remove duplicate checks. r346001: loader: file_addmetadata() should check for memory allocation malloc() can return NULL. r346002: loader: mod_loadkld() error: we previously assumed 'last_file' could be null The last_file variable is used to reset the loadaddr variable back to original value; however, it is possible the last_file is NULL, so we can not blindly trust it. But then again, we can just save the original loadaddr and use the saved value for recovery. r346007: loader: add file_remove() function to undo file_insert_tail(). 346002 did miss the fact that we do not only undo the loadaddr, but also we need to remove the inserted module. Implement file_remove() to do the job. r346008: loader: command_lsefi: ret can be used uninitialized Modified: stable/12/stand/common/module.c stable/12/stand/efi/loader/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/module.c ============================================================================== --- stable/12/stand/common/module.c Thu Oct 24 02:34:48 2019 (r353977) +++ stable/12/stand/common/module.c Thu Oct 24 02:36:42 2019 (r353978) @@ -52,16 +52,18 @@ struct moduledir { STAILQ_ENTRY(moduledir) d_link; }; -static int file_load(char *filename, vm_offset_t dest, struct preloaded_file **result); -static int file_load_dependencies(struct preloaded_file *base_mod); -static char * file_search(const char *name, char **extlist); -static struct kernel_module * file_findmodule(struct preloaded_file *fp, char *modname, struct mod_depend *verinfo); -static int file_havepath(const char *name); -static char *mod_searchmodule(char *name, struct mod_depend *verinfo); -static void file_insert_tail(struct preloaded_file *mp); -struct file_metadata* metadata_next(struct file_metadata *base_mp, int type); -static void moduledir_readhints(struct moduledir *mdp); -static void moduledir_rebuild(void); +static int file_load(char *, vm_offset_t, struct preloaded_file **); +static int file_load_dependencies(struct preloaded_file *); +static char * file_search(const char *, char **); +static struct kernel_module *file_findmodule(struct preloaded_file *, char *, + struct mod_depend *); +static int file_havepath(const char *); +static char *mod_searchmodule(char *, struct mod_depend *); +static void file_insert_tail(struct preloaded_file *); +static void file_remove(struct preloaded_file *); +struct file_metadata *metadata_next(struct file_metadata *, int); +static void moduledir_readhints(struct moduledir *); +static void moduledir_rebuild(void); /* load address should be tweaked by first module loaded (kernel) */ static vm_offset_t loadaddr = 0; @@ -70,10 +72,11 @@ static vm_offset_t loadaddr = 0; static const char *default_searchpath = "/boot/kernel;/boot/modules;/boot/dtb"; #else -static const char *default_searchpath ="/boot/kernel;/boot/modules"; +static const char *default_searchpath = "/boot/kernel;/boot/modules"; #endif -static STAILQ_HEAD(, moduledir) moduledir_list = STAILQ_HEAD_INITIALIZER(moduledir_list); +static STAILQ_HEAD(, moduledir) moduledir_list = + STAILQ_HEAD_INITIALIZER(moduledir_list); struct preloaded_file *preloaded_files = NULL; @@ -534,8 +537,7 @@ mod_load(char *modname, struct mod_depend *verinfo, in mp = file_findmodule(NULL, modname, verinfo); if (mp) { #ifdef moduleargs - if (mp->m_args) - free(mp->m_args); + free(mp->m_args); mp->m_args = unargv(argc, argv); #endif snprintf(command_errbuf, sizeof(command_errbuf), @@ -560,9 +562,10 @@ mod_load(char *modname, struct mod_depend *verinfo, in int mod_loadkld(const char *kldname, int argc, char *argv[]) { - struct preloaded_file *fp, *last_file; - int err; + struct preloaded_file *fp; + int err; char *filename; + vm_offset_t loadaddr_saved; /* * Get fully qualified KLD name @@ -583,22 +586,19 @@ mod_loadkld(const char *kldname, int argc, char *argv[ free(filename); return (0); } - for (last_file = preloaded_files; - last_file != NULL && last_file->f_next != NULL; - last_file = last_file->f_next) - ; do { err = file_load(filename, loadaddr, &fp); if (err) break; fp->f_args = unargv(argc, argv); + loadaddr_saved = loadaddr; loadaddr = fp->f_addr + fp->f_size; - file_insert_tail(fp); /* Add to the list of loaded files */ + file_insert_tail(fp); /* Add to the list of loaded files */ if (file_load_dependencies(fp) != 0) { err = ENOENT; - last_file->f_next = NULL; - loadaddr = last_file->f_addr + last_file->f_size; + file_remove(fp); + loadaddr = loadaddr_saved; fp = NULL; break; } @@ -678,10 +678,12 @@ file_addmetadata(struct preloaded_file *fp, int type, struct file_metadata *md; md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size); - md->md_size = size; - md->md_type = type; - bcopy(p, md->md_data, size); - md->md_next = fp->f_metadata; + if (md != NULL) { + md->md_size = size; + md->md_type = type; + bcopy(p, md->md_data, size); + md->md_next = fp->f_metadata; + } fp->f_metadata = md; } @@ -926,11 +928,14 @@ file_addmodule(struct preloaded_file *fp, char *modnam mp = file_findmodule(fp, modname, &mdepend); if (mp) return (EEXIST); - mp = malloc(sizeof(struct kernel_module)); + mp = calloc(1, sizeof(struct kernel_module)); if (mp == NULL) return (ENOMEM); - bzero(mp, sizeof(struct kernel_module)); mp->m_name = strdup(modname); + if (mp->m_name == NULL) { + free(mp); + return (ENOMEM); + } mp->m_version = version; mp->m_fp = fp; mp->m_next = fp->f_modules; @@ -958,18 +963,14 @@ file_discard(struct preloaded_file *fp) } mp = fp->f_modules; while (mp) { - if (mp->m_name) - free(mp->m_name); + free(mp->m_name); mp1 = mp; mp = mp->m_next; free(mp1); } - if (fp->f_name != NULL) - free(fp->f_name); - if (fp->f_type != NULL) - free(fp->f_type); - if (fp->f_args != NULL) - free(fp->f_args); + free(fp->f_name); + free(fp->f_type); + free(fp->f_args); free(fp); } @@ -980,12 +981,8 @@ file_discard(struct preloaded_file *fp) struct preloaded_file * file_alloc(void) { - struct preloaded_file *fp; - if ((fp = malloc(sizeof(struct preloaded_file))) != NULL) { - bzero(fp, sizeof(struct preloaded_file)); - } - return (fp); + return (calloc(1, sizeof(struct preloaded_file))); } /* @@ -1007,6 +1004,29 @@ file_insert_tail(struct preloaded_file *fp) } } +/* + * Remove module from the chain + */ +static void +file_remove(struct preloaded_file *fp) +{ + struct preloaded_file *cm; + + if (preloaded_files == NULL) + return; + + if (preloaded_files == fp) { + preloaded_files = fp->f_next; + return; + } + for (cm = preloaded_files; cm->f_next != NULL; cm = cm->f_next) { + if (cm->f_next == fp) { + cm->f_next = fp->f_next; + return; + } + } +} + static char * moduledir_fullpath(struct moduledir *mdp, const char *fname) { @@ -1056,10 +1076,8 @@ moduledir_readhints(struct moduledir *mdp) return; bad: close(fd); - if (mdp->d_hints) { - free(mdp->d_hints); - mdp->d_hints = NULL; - } + free(mdp->d_hints); + mdp->d_hints = NULL; mdp->d_flags |= MDIR_NOHINTS; return; } @@ -1120,8 +1138,7 @@ moduledir_rebuild(void) if ((mdp->d_flags & MDIR_REMOVED) == 0) { mdp = STAILQ_NEXT(mdp, d_link); } else { - if (mdp->d_hints) - free(mdp->d_hints); + free(mdp->d_hints); mtmp = mdp; mdp = STAILQ_NEXT(mdp, d_link); STAILQ_REMOVE(&moduledir_list, mtmp, moduledir, d_link); Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 02:34:48 2019 (r353977) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 02:36:42 2019 (r353978) @@ -1217,7 +1217,7 @@ command_lsefi(int argc __unused, char *argv[] __unused EFI_HANDLE handle; UINTN bufsz = 0, i, j; EFI_STATUS status; - int ret; + int ret = 0; status = BS->LocateHandle(AllHandles, NULL, NULL, &bufsz, buffer); if (status != EFI_BUFFER_TOO_SMALL) { From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:29:01 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E6933154F29; Thu, 24 Oct 2019 03:29:01 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCQP5mXPz4K1t; Thu, 24 Oct 2019 03:29:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A94DA7EC8; Thu, 24 Oct 2019 03:29:01 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3T1m0019264; Thu, 24 Oct 2019 03:29:01 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3T11w019263; Thu, 24 Oct 2019 03:29:01 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240329.x9O3T11w019263@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:29:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353995 - stable/12/stand/libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa X-SVN-Commit-Revision: 353995 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:29:02 -0000 Author: kevans Date: Thu Oct 24 03:29:01 2019 New Revision: 353995 URL: https://svnweb.freebsd.org/changeset/base/353995 Log: MFC r352548: loader: fix typo in zalloc. Modified: stable/12/stand/libsa/zalloc.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zalloc.c ============================================================================== --- stable/12/stand/libsa/zalloc.c Thu Oct 24 03:27:52 2019 (r353994) +++ stable/12/stand/libsa/zalloc.c Thu Oct 24 03:29:01 2019 (r353995) @@ -125,7 +125,8 @@ znalloc(MemPool *mp, uintptr_t bytes, size_t align) continue; /* - * Cut extra from head and create new memory node from reminder. + * Cut extra from head and create new memory node from + * remainder. */ if (extra != 0) { From owner-svn-src-stable-12@freebsd.org Thu Oct 24 04:00:51 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A765E159A53; Thu, 24 Oct 2019 04:00:51 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zD771nByz4PmT; Thu, 24 Oct 2019 04:00:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0618984A6; Thu, 24 Oct 2019 04:00:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O40peD037869; Thu, 24 Oct 2019 04:00:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O40n4a037862; Thu, 24 Oct 2019 04:00:49 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240400.x9O40n4a037862@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 04:00:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354008 - in stable/12/stand: efi/include efi/include/Protocol efi/libefi efi/loader libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: efi/include efi/include/Protocol efi/libefi efi/loader libsa X-SVN-Commit-Revision: 354008 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 04:00:51 -0000 Author: kevans Date: Thu Oct 24 04:00:49 2019 New Revision: 354008 URL: https://svnweb.freebsd.org/changeset/base/354008 Log: MFC EFI HTTP Support: r349349, r349395, r349404, r349564-r349566, r349613, r350444 r349349: loader: add HTTP support using UEFI Add support for an HTTP "network filesystem" using the UEFI's HTTP stack. This also supports HTTPS, but TianoCore EDK2 implementations currently crash while fetching loader files. Only IPv4 is supported at the moment. IPv6 support is planned for a follow-up changeset. Note that we include some headers from the TianoCore EDK II project in stand/efi/include/Protocol verbatim, including links to the license instead of including the full text because that's their preferred way of communicating it, despite not being normal FreeBSD project practice. r349395: Disconnect EFI HTTP support The EFI HTTP code has been causing boot failures for people, so disable it while a fix is being worked on. r349404: Re-enable loader efi http boot and fix dv_open bug if dv_init failed The code in efihttp.c was assuming that dv_open wouldn't be called if dv_init failed. But the dv_init return value is currently ignored. Add a new variable, `efihttp_init_done` and only proceed in dv_open if it's true. This fixes the loader on systems without efi http support. r349564: Clean efihttp pointer-sign warnings The Http protocol structure is using unsigned char strings, Use type casts where needed. r349565: efihttp: comparison of integers of different signs message.HeaderCount is UINTN (unsigned int), so should be i. r349566: efihttp: mark unused arguments with __unused we do have __unused, lets use it. r349613: efihttp: mac and err can be used uninitialized While there, also check if mac != NULL, and use pointer compare for ipv4 and dns. r350444: Fix EFI loader build when LOADER_NET_SUPPORT=no. Added: stable/12/stand/efi/include/Protocol/Http.h - copied unchanged from r349349, head/stand/efi/include/Protocol/Http.h stable/12/stand/efi/include/Protocol/Ip4Config2.h - copied unchanged from r349349, head/stand/efi/include/Protocol/Ip4Config2.h stable/12/stand/efi/include/Protocol/ServiceBinding.h - copied unchanged from r349349, head/stand/efi/include/Protocol/ServiceBinding.h stable/12/stand/efi/libefi/efihttp.c - copied, changed from r349349, head/stand/efi/libefi/efihttp.c Modified: stable/12/stand/efi/include/efidevp.h stable/12/stand/efi/include/efilib.h stable/12/stand/efi/libefi/Makefile stable/12/stand/efi/loader/conf.c stable/12/stand/libsa/stand.h Directory Properties: stable/12/ (props changed) Copied: stable/12/stand/efi/include/Protocol/Http.h (from r349349, head/stand/efi/include/Protocol/Http.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/include/Protocol/Http.h Thu Oct 24 04:00:49 2019 (r354008, copy of r349349, head/stand/efi/include/Protocol/Http.h) @@ -0,0 +1,523 @@ +/* $FreeBSD$ */ +/** @file + This file defines the EFI HTTP Protocol interface. It is split into + the following two main sections: + HTTP Service Binding Protocol (HTTPSB) + HTTP Protocol (HTTP) + + Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+ (C) Copyright 2015-2017 Hewlett Packard Enterprise Development LP
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + @par Revision Reference: + This Protocol is introduced in UEFI Specification 2.5 + +**/ + +#ifndef __EFI_HTTP_PROTOCOL_H__ +#define __EFI_HTTP_PROTOCOL_H__ + +#define EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID \ + { \ + 0xbdc8e6af, 0xd9bc, 0x4379, {0xa7, 0x2a, 0xe0, 0xc4, 0xe7, 0x5d, 0xae, 0x1c } \ + } + +#define EFI_HTTP_PROTOCOL_GUID \ + { \ + 0x7a59b29b, 0x910b, 0x4171, {0x82, 0x42, 0xa8, 0x5a, 0x0d, 0xf2, 0x5b, 0x5b } \ + } + +typedef struct _EFI_HTTP_PROTOCOL EFI_HTTP_PROTOCOL; + +/// +/// EFI_HTTP_VERSION +/// +typedef enum { + HttpVersion10, + HttpVersion11, + HttpVersionUnsupported +} EFI_HTTP_VERSION; + +/// +/// EFI_HTTP_METHOD +/// +typedef enum { + HttpMethodGet, + HttpMethodPost, + HttpMethodPatch, + HttpMethodOptions, + HttpMethodConnect, + HttpMethodHead, + HttpMethodPut, + HttpMethodDelete, + HttpMethodTrace, + HttpMethodMax +} EFI_HTTP_METHOD; + +/// +/// EFI_HTTP_STATUS_CODE +/// +typedef enum { + HTTP_STATUS_UNSUPPORTED_STATUS = 0, + HTTP_STATUS_100_CONTINUE, + HTTP_STATUS_101_SWITCHING_PROTOCOLS, + HTTP_STATUS_200_OK, + HTTP_STATUS_201_CREATED, + HTTP_STATUS_202_ACCEPTED, + HTTP_STATUS_203_NON_AUTHORITATIVE_INFORMATION, + HTTP_STATUS_204_NO_CONTENT, + HTTP_STATUS_205_RESET_CONTENT, + HTTP_STATUS_206_PARTIAL_CONTENT, + HTTP_STATUS_300_MULTIPLE_CHOICES, + HTTP_STATUS_301_MOVED_PERMANENTLY, + HTTP_STATUS_302_FOUND, + HTTP_STATUS_303_SEE_OTHER, + HTTP_STATUS_304_NOT_MODIFIED, + HTTP_STATUS_305_USE_PROXY, + HTTP_STATUS_307_TEMPORARY_REDIRECT, + HTTP_STATUS_400_BAD_REQUEST, + HTTP_STATUS_401_UNAUTHORIZED, + HTTP_STATUS_402_PAYMENT_REQUIRED, + HTTP_STATUS_403_FORBIDDEN, + HTTP_STATUS_404_NOT_FOUND, + HTTP_STATUS_405_METHOD_NOT_ALLOWED, + HTTP_STATUS_406_NOT_ACCEPTABLE, + HTTP_STATUS_407_PROXY_AUTHENTICATION_REQUIRED, + HTTP_STATUS_408_REQUEST_TIME_OUT, + HTTP_STATUS_409_CONFLICT, + HTTP_STATUS_410_GONE, + HTTP_STATUS_411_LENGTH_REQUIRED, + HTTP_STATUS_412_PRECONDITION_FAILED, + HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE, + HTTP_STATUS_414_REQUEST_URI_TOO_LARGE, + HTTP_STATUS_415_UNSUPPORTED_MEDIA_TYPE, + HTTP_STATUS_416_REQUESTED_RANGE_NOT_SATISFIED, + HTTP_STATUS_417_EXPECTATION_FAILED, + HTTP_STATUS_500_INTERNAL_SERVER_ERROR, + HTTP_STATUS_501_NOT_IMPLEMENTED, + HTTP_STATUS_502_BAD_GATEWAY, + HTTP_STATUS_503_SERVICE_UNAVAILABLE, + HTTP_STATUS_504_GATEWAY_TIME_OUT, + HTTP_STATUS_505_HTTP_VERSION_NOT_SUPPORTED, + HTTP_STATUS_308_PERMANENT_REDIRECT +} EFI_HTTP_STATUS_CODE; + +/// +/// EFI_HTTPv4_ACCESS_POINT +/// +typedef struct { + /// + /// Set to TRUE to instruct the EFI HTTP instance to use the default address + /// information in every TCP connection made by this instance. In addition, when set + /// to TRUE, LocalAddress and LocalSubnet are ignored. + /// + BOOLEAN UseDefaultAddress; + /// + /// If UseDefaultAddress is set to FALSE, this defines the local IP address to be + /// used in every TCP connection opened by this instance. + /// + EFI_IPv4_ADDRESS LocalAddress; + /// + /// If UseDefaultAddress is set to FALSE, this defines the local subnet to be used + /// in every TCP connection opened by this instance. + /// + EFI_IPv4_ADDRESS LocalSubnet; + /// + /// This defines the local port to be used in + /// every TCP connection opened by this instance. + /// + UINT16 LocalPort; +} EFI_HTTPv4_ACCESS_POINT; + +/// +/// EFI_HTTPv6_ACCESS_POINT +/// +typedef struct { + /// + /// Local IP address to be used in every TCP connection opened by this instance. + /// + EFI_IPv6_ADDRESS LocalAddress; + /// + /// Local port to be used in every TCP connection opened by this instance. + /// + UINT16 LocalPort; +} EFI_HTTPv6_ACCESS_POINT; + +/// +/// EFI_HTTP_CONFIG_DATA_ACCESS_POINT +/// + + +typedef struct { + /// + /// HTTP version that this instance will support. + /// + EFI_HTTP_VERSION HttpVersion; + /// + /// Time out (in milliseconds) when blocking for requests. + /// + UINT32 TimeOutMillisec; + /// + /// Defines behavior of EFI DNS and TCP protocols consumed by this instance. If + /// FALSE, this instance will use EFI_DNS4_PROTOCOL and EFI_TCP4_PROTOCOL. If TRUE, + /// this instance will use EFI_DNS6_PROTOCOL and EFI_TCP6_PROTOCOL. + /// + BOOLEAN LocalAddressIsIPv6; + + union { + /// + /// When LocalAddressIsIPv6 is FALSE, this points to the local address, subnet, and + /// port used by the underlying TCP protocol. + /// + EFI_HTTPv4_ACCESS_POINT *IPv4Node; + /// + /// When LocalAddressIsIPv6 is TRUE, this points to the local IPv6 address and port + /// used by the underlying TCP protocol. + /// + EFI_HTTPv6_ACCESS_POINT *IPv6Node; + } AccessPoint; +} EFI_HTTP_CONFIG_DATA; + +/// +/// EFI_HTTP_REQUEST_DATA +/// +typedef struct { + /// + /// The HTTP method (e.g. GET, POST) for this HTTP Request. + /// + EFI_HTTP_METHOD Method; + /// + /// The URI of a remote host. From the information in this field, the HTTP instance + /// will be able to determine whether to use HTTP or HTTPS and will also be able to + /// determine the port number to use. If no port number is specified, port 80 (HTTP) + /// is assumed. See RFC 3986 for more details on URI syntax. + /// + CHAR16 *Url; +} EFI_HTTP_REQUEST_DATA; + +/// +/// EFI_HTTP_RESPONSE_DATA +/// +typedef struct { + /// + /// Response status code returned by the remote host. + /// + EFI_HTTP_STATUS_CODE StatusCode; +} EFI_HTTP_RESPONSE_DATA; + +/// +/// EFI_HTTP_HEADER +/// +typedef struct { + /// + /// Null terminated string which describes a field name. See RFC 2616 Section 14 for + /// detailed information about field names. + /// + CHAR8 *FieldName; + /// + /// Null terminated string which describes the corresponding field value. See RFC 2616 + /// Section 14 for detailed information about field values. + /// + CHAR8 *FieldValue; +} EFI_HTTP_HEADER; + +/// +/// EFI_HTTP_MESSAGE +/// +typedef struct { + /// + /// HTTP message data. + /// + union { + /// + /// When the token is used to send a HTTP request, Request is a pointer to storage that + /// contains such data as URL and HTTP method. + /// + EFI_HTTP_REQUEST_DATA *Request; + /// + /// When used to await a response, Response points to storage containing HTTP response + /// status code. + /// + EFI_HTTP_RESPONSE_DATA *Response; + } Data; + /// + /// Number of HTTP header structures in Headers list. On request, this count is + /// provided by the caller. On response, this count is provided by the HTTP driver. + /// + UINTN HeaderCount; + /// + /// Array containing list of HTTP headers. On request, this array is populated by the + /// caller. On response, this array is allocated and populated by the HTTP driver. It + /// is the responsibility of the caller to free this memory on both request and + /// response. + /// + EFI_HTTP_HEADER *Headers; + /// + /// Length in bytes of the HTTP body. This can be zero depending on the HttpMethod type. + /// + UINTN BodyLength; + /// + /// Body associated with the HTTP request or response. This can be NULL depending on + /// the HttpMethod type. + /// + VOID *Body; +} EFI_HTTP_MESSAGE; + + +/// +/// EFI_HTTP_TOKEN +/// +typedef struct { + /// + /// This Event will be signaled after the Status field is updated by the EFI HTTP + /// Protocol driver. The type of Event must be EFI_NOTIFY_SIGNAL. The Task Priority + /// Level (TPL) of Event must be lower than or equal to TPL_CALLBACK. + /// + EFI_EVENT Event; + /// + /// Status will be set to one of the following value if the HTTP request is + /// successfully sent or if an unexpected error occurs: + /// EFI_SUCCESS: The HTTP request was successfully sent to the remote host. + /// EFI_HTTP_ERROR: The response message was successfully received but contains a + /// HTTP error. The response status code is returned in token. + /// EFI_ABORTED: The HTTP request was cancelled by the caller and removed from + /// the transmit queue. + /// EFI_TIMEOUT: The HTTP request timed out before reaching the remote host. + /// EFI_DEVICE_ERROR: An unexpected system or network error occurred. + /// + EFI_STATUS Status; + /// + /// Pointer to storage containing HTTP message data. + /// + EFI_HTTP_MESSAGE *Message; +} EFI_HTTP_TOKEN; + +/** + Returns the operational parameters for the current HTTP child instance. + + The GetModeData() function is used to read the current mode data (operational + parameters) for this HTTP protocol instance. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[out] HttpConfigData Point to buffer for operational parameters of this + HTTP instance. It is the responsibility of the caller + to allocate the memory for HttpConfigData and + HttpConfigData->AccessPoint.IPv6Node/IPv4Node. In fact, + it is recommended to allocate sufficient memory to record + IPv6Node since it is big enough for all possibilities. + + @retval EFI_SUCCESS Operation succeeded. + @retval EFI_INVALID_PARAMETER This is NULL. + HttpConfigData is NULL. + HttpConfigData->AccessPoint.IPv4Node or + HttpConfigData->AccessPoint.IPv6Node is NULL. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_GET_MODE_DATA)( + IN EFI_HTTP_PROTOCOL *This, + OUT EFI_HTTP_CONFIG_DATA *HttpConfigData + ); + +/** + Initialize or brutally reset the operational parameters for this EFI HTTP instance. + + The Configure() function does the following: + When HttpConfigData is not NULL Initialize this EFI HTTP instance by configuring + timeout, local address, port, etc. + When HttpConfigData is NULL, reset this EFI HTTP instance by closing all active + connections with remote hosts, canceling all asynchronous tokens, and flush request + and response buffers without informing the appropriate hosts. + + No other EFI HTTP function can be executed by this instance until the Configure() + function is executed and returns successfully. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] HttpConfigData Pointer to the configure data to configure the instance. + + @retval EFI_SUCCESS Operation succeeded. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + HttpConfigData->LocalAddressIsIPv6 is FALSE and + HttpConfigData->AccessPoint.IPv4Node is NULL. + HttpConfigData->LocalAddressIsIPv6 is TRUE and + HttpConfigData->AccessPoint.IPv6Node is NULL. + @retval EFI_ALREADY_STARTED Reinitialize this HTTP instance without calling + Configure() with NULL to reset it. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources when + executing Configure(). + @retval EFI_UNSUPPORTED One or more options in ConfigData are not supported + in the implementation. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_CONFIGURE)( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_CONFIG_DATA *HttpConfigData OPTIONAL + ); + +/** + The Request() function queues an HTTP request to this HTTP instance, + similar to Transmit() function in the EFI TCP driver. When the HTTP request is sent + successfully, or if there is an error, Status in token will be updated and Event will + be signaled. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Pointer to storage containing HTTP request token. + + @retval EFI_SUCCESS Outgoing data was processed. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. + @retval EFI_TIMEOUT Data was dropped out of the transmit or receive queue. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + Token is NULL. + Token->Message is NULL. + Token->Message->Body is not NULL, + Token->Message->BodyLength is non-zero, and + Token->Message->Data is NULL, but a previous call to + Request()has not been completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. + @retval EFI_UNSUPPORTED The HTTP method is not supported in current implementation. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_REQUEST) ( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + Abort an asynchronous HTTP request or response token. + + The Cancel() function aborts a pending HTTP request or response transaction. If + Token is not NULL and the token is in transmit or receive queues when it is being + cancelled, its Token->Status will be set to EFI_ABORTED and then Token->Event will + be signaled. If the token is not in one of the queues, which usually means that the + asynchronous operation has completed, EFI_NOT_FOUND is returned. If Token is NULL, + all asynchronous tokens issued by Request() or Response() will be aborted. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Point to storage containing HTTP request or response + token. + + @retval EFI_SUCCESS Request and Response queues are successfully flushed. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_STARTED This instance hasn't been configured. + @retval EFI_NOT_FOUND The asynchronous request or response token is not + found. + @retval EFI_UNSUPPORTED The implementation does not support this function. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_CANCEL)( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + The Response() function queues an HTTP response to this HTTP instance, similar to + Receive() function in the EFI TCP driver. When the HTTP Response is received successfully, + or if there is an error, Status in token will be updated and Event will be signaled. + + The HTTP driver will queue a receive token to the underlying TCP instance. When data + is received in the underlying TCP instance, the data will be parsed and Token will + be populated with the response data. If the data received from the remote host + contains an incomplete or invalid HTTP header, the HTTP driver will continue waiting + (asynchronously) for more data to be sent from the remote host before signaling + Event in Token. + + It is the responsibility of the caller to allocate a buffer for Body and specify the + size in BodyLength. If the remote host provides a response that contains a content + body, up to BodyLength bytes will be copied from the receive buffer into Body and + BodyLength will be updated with the amount of bytes received and copied to Body. This + allows the client to download a large file in chunks instead of into one contiguous + block of memory. Similar to HTTP request, if Body is not NULL and BodyLength is + non-zero and all other fields are NULL or 0, the HTTP driver will queue a receive + token to underlying TCP instance. If data arrives in the receive buffer, up to + BodyLength bytes of data will be copied to Body. The HTTP driver will then update + BodyLength with the amount of bytes received and copied to Body. + + If the HTTP driver does not have an open underlying TCP connection with the host + specified in the response URL, Request() will return EFI_ACCESS_DENIED. This is + consistent with RFC 2616 recommendation that HTTP clients should attempt to maintain + an open TCP connection between client and host. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + @param[in] Token Pointer to storage containing HTTP response token. + + @retval EFI_SUCCESS Allocation succeeded. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been + initialized. + @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE: + This is NULL. + Token is NULL. + Token->Message->Headers is NULL. + Token->Message is NULL. + Token->Message->Body is not NULL, + Token->Message->BodyLength is non-zero, and + Token->Message->Data is NULL, but a previous call to + Response() has not been completed successfully. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough system resources. + @retval EFI_ACCESS_DENIED An open TCP connection is not present with the host + specified by response URL. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_RESPONSE) ( + IN EFI_HTTP_PROTOCOL *This, + IN EFI_HTTP_TOKEN *Token + ); + +/** + The Poll() function can be used by network drivers and applications to increase the + rate that data packets are moved between the communication devices and the transmit + and receive queues. + + In some systems, the periodic timer event in the managed network driver may not poll + the underlying communications device fast enough to transmit and/or receive all data + packets without missing incoming packets or dropping outgoing packets. Drivers and + applications that are experiencing packet loss should try calling the Poll() function + more often. + + @param[in] This Pointer to EFI_HTTP_PROTOCOL instance. + + @retval EFI_SUCCESS Incoming or outgoing data was processed.. + @retval EFI_DEVICE_ERROR An unexpected system or network error occurred + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_NOT_READY No incoming or outgoing data is processed. + @retval EFI_NOT_STARTED This EFI HTTP Protocol instance has not been started. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_HTTP_POLL) ( + IN EFI_HTTP_PROTOCOL *This + ); + +/// +/// The EFI HTTP protocol is designed to be used by EFI drivers and applications to +/// create and transmit HTTP Requests, as well as handle HTTP responses that are +/// returned by a remote host. This EFI protocol uses and relies on an underlying EFI +/// TCP protocol. +/// +struct _EFI_HTTP_PROTOCOL { + EFI_HTTP_GET_MODE_DATA GetModeData; + EFI_HTTP_CONFIGURE Configure; + EFI_HTTP_REQUEST Request; + EFI_HTTP_CANCEL Cancel; + EFI_HTTP_RESPONSE Response; + EFI_HTTP_POLL Poll; +}; + +extern EFI_GUID gEfiHttpServiceBindingProtocolGuid; +extern EFI_GUID gEfiHttpProtocolGuid; + +#endif Copied: stable/12/stand/efi/include/Protocol/Ip4Config2.h (from r349349, head/stand/efi/include/Protocol/Ip4Config2.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/include/Protocol/Ip4Config2.h Thu Oct 24 04:00:49 2019 (r354008, copy of r349349, head/stand/efi/include/Protocol/Ip4Config2.h) @@ -0,0 +1,324 @@ +/* $FreeBSD$ */ +/** @file + This file provides a definition of the EFI IPv4 Configuration II + Protocol. + +Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +@par Revision Reference: +This Protocol is introduced in UEFI Specification 2.5 + +**/ +#ifndef __EFI_IP4CONFIG2_PROTOCOL_H__ +#define __EFI_IP4CONFIG2_PROTOCOL_H__ + +/* #include */ + +#define EFI_IP4_CONFIG2_PROTOCOL_GUID \ + { \ + 0x5b446ed1, 0xe30b, 0x4faa, {0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \ + } + +typedef struct _EFI_IP4_CONFIG2_PROTOCOL EFI_IP4_CONFIG2_PROTOCOL; + + +/// +/// EFI_IP4_CONFIG2_DATA_TYPE +/// +typedef enum { + /// + /// The interface information of the communication device this EFI + /// IPv4 Configuration II Protocol instance manages. This type of + /// data is read only. The corresponding Data is of type + /// EFI_IP4_CONFIG2_INTERFACE_INFO. + /// + Ip4Config2DataTypeInterfaceInfo, + /// + /// The general configuration policy for the EFI IPv4 network stack + /// running on the communication device this EFI IPv4 + /// Configuration II Protocol instance manages. The policy will + /// affect other configuration settings. The corresponding Data is of + /// type EFI_IP4_CONFIG2_POLICY. + /// + Ip4Config2DataTypePolicy, + /// + /// The station addresses set manually for the EFI IPv4 network + /// stack. It is only configurable when the policy is + /// Ip4Config2PolicyStatic. The corresponding Data is of + /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. When DataSize + /// is 0 and Data is NULL, the existing configuration is cleared + /// from the EFI IPv4 Configuration II Protocol instance. + /// + Ip4Config2DataTypeManualAddress, + /// + /// The gateway addresses set manually for the EFI IPv4 network + /// stack running on the communication device this EFI IPv4 + /// Configuration II Protocol manages. It is not configurable when + /// the policy is Ip4Config2PolicyDhcp. The gateway + /// addresses must be unicast IPv4 addresses. The corresponding + /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances. + /// When DataSize is 0 and Data is NULL, the existing configuration + /// is cleared from the EFI IPv4 Configuration II Protocol instance. + /// + Ip4Config2DataTypeGateway, + /// + /// The DNS server list for the EFI IPv4 network stack running on + /// the communication device this EFI IPv4 Configuration II + /// Protocol manages. It is not configurable when the policy is + /// Ip4Config2PolicyDhcp. The DNS server addresses must be + /// unicast IPv4 addresses. The corresponding Data is a pointer to + /// an array of EFI_IPv4_ADDRESS instances. When DataSize + /// is 0 and Data is NULL, the existing configuration is cleared + /// from the EFI IPv4 Configuration II Protocol instance. + /// + Ip4Config2DataTypeDnsServer, + Ip4Config2DataTypeMaximum +} EFI_IP4_CONFIG2_DATA_TYPE; + +/// +/// EFI_IP4_CONFIG2_INTERFACE_INFO related definitions +/// +#define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32 + +/// +/// EFI_IP4_CONFIG2_INTERFACE_INFO +/// +typedef struct { + /// + /// The name of the interface. It is a NULL-terminated Unicode string. + /// + CHAR16 Name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE]; + /// + /// The interface type of the network interface. See RFC 1700, + /// section "Number Hardware Type". + /// + UINT8 IfType; + /// + /// The size, in bytes, of the network interface's hardware address. + /// + UINT32 HwAddressSize; + /// + /// The hardware address for the network interface. + /// + EFI_MAC_ADDRESS HwAddress; + /// + /// The station IPv4 address of this EFI IPv4 network stack. + /// + EFI_IPv4_ADDRESS StationAddress; + /// + /// The subnet address mask that is associated with the station address. + /// + EFI_IPv4_ADDRESS SubnetMask; + /// + /// Size of the following RouteTable, in bytes. May be zero. + /// + UINT32 RouteTableSize; + /// + /// The route table of the IPv4 network stack runs on this interface. + /// Set to NULL if RouteTableSize is zero. Type EFI_IP4_ROUTE_TABLE is defined in + /// EFI_IP4_PROTOCOL.GetModeData(). + /// + EFI_IP4_ROUTE_TABLE *RouteTable OPTIONAL; +} EFI_IP4_CONFIG2_INTERFACE_INFO; + +/// +/// EFI_IP4_CONFIG2_POLICY +/// +typedef enum { + /// + /// Under this policy, the Ip4Config2DataTypeManualAddress, + /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration + /// data are required to be set manually. The EFI IPv4 Protocol will get all + /// required configuration such as IPv4 address, subnet mask and + /// gateway settings from the EFI IPv4 Configuration II protocol. + /// + Ip4Config2PolicyStatic, + /// + /// Under this policy, the Ip4Config2DataTypeManualAddress, + /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration data are + /// not allowed to set via SetData(). All of these configurations are retrieved from DHCP + /// server or other auto-configuration mechanism. + /// + Ip4Config2PolicyDhcp, + Ip4Config2PolicyMax +} EFI_IP4_CONFIG2_POLICY; + +/// +/// EFI_IP4_CONFIG2_MANUAL_ADDRESS +/// +typedef struct { + /// + /// The IPv4 unicast address. + /// + EFI_IPv4_ADDRESS Address; + /// + /// The subnet mask. + /// + EFI_IPv4_ADDRESS SubnetMask; +} EFI_IP4_CONFIG2_MANUAL_ADDRESS; + +/** + Set the configuration for the EFI IPv4 network stack running on the communication device this EFI + IPv4 Configuration II Protocol instance manages. + + This function is used to set the configuration data of type DataType for the EFI IPv4 network stack + running on the communication device this EFI IPv4 Configuration II Protocol instance manages. + The successfully configured data is valid after system reset or power-off. + The DataSize is used to calculate the count of structure instances in the Data for some + DataType that multiple structure instances are allowed. + This function is always non-blocking. When setting some typeof configuration data, an + asynchronous process is invoked to check the correctness of the data, such as doing address conflict + detection on the manually set local IPv4 address. EFI_NOT_READY is returned immediately to + indicate that such an asynchronous process is invoked and the process is not finished yet. The caller + willing to get the result of the asynchronous process is required to call RegisterDataNotify() + to register an event on the specified configuration data. Once the event is signaled, the caller can call + GetData()to get back the configuration data in order to know the result. For other types of + configuration data that do not require an asynchronous configuration process, the result of the + operation is immediately returned. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to set. + @param[in] DataSize Size of the buffer pointed to by Data in bytes. + @param[in] Data The data buffer to set. The type ofthe data buffer is associated + with the DataType. + + @retval EFI_SUCCESS The specified configuration data for the EFI IPv4 network stack is set + successfully. + @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: + This is NULL. + One or more fields in Data and DataSize do not match the + requirement of the data type indicated by DataType. + @retval EFI_WRITE_PROTECTED The specified configuration data is read-only or the specified configuration + data can not be set under the current policy. + @retval EFI_ACCESS_DENIED Another set operation on the specified configuration data is already in process. + @retval EFI_NOT_READY An asynchronous process is invoked to set the specified configuration data and + the process is not finished yet. + @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type indicated by DataType. + @retval EFI_UNSUPPORTED This DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_DEVICE_ERROR An unexpected system error or network error occurred. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_SET_DATA) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN UINTN DataSize, + IN VOID *Data + ); + +/** + Get the configuration data for the EFI IPv4 network stack running on the communication device this + EFI IPv4 Configuration II Protocol instance manages. + + This function returns the configuration data of type DataType for the EFI IPv4 network stack + running on the communication device this EFI IPv4 Configuration II Protocol instance manages. + The caller is responsible for allocating the buffer usedto return the specified configuration data and + the required size will be returned to the caller if the size of the buffer is too small. + EFI_NOT_READY is returned if the specified configuration data is not ready due to an already in + progress asynchronous configuration process. The caller can call RegisterDataNotify() to + register an event on the specified configuration data. Once the asynchronous configuration process is + finished, the event will be signaled and a subsequent GetData() call will return the specified + configuration data. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to get. + @param[out] DataSize On input, in bytes, the size of Data. On output, in bytes, the size + of buffer required to store the specified configuration data. + @param[in] Data The data buffer in which the configuration data is returned. The + type of the data buffer is associated with the DataType. Ignored + if DataSize is 0. + + @retval EFI_SUCCESS The specified configuration data is got successfully. + @retval EFI_INVALID_PARAMETER One or more of the followings are TRUE: + This is NULL. + DataSize is NULL. + Data is NULL if *DataSizeis not zero. + @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified configuration data + and the required size is returned in DataSize. + @retval EFI_NOT_READY The specified configuration data is not ready due to an already in + progress asynchronous configuration process. + @retval EFI_NOT_FOUND The specified configuration data is not found. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_GET_DATA) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN OUT UINTN *DataSize, + IN VOID *Data OPTIONAL + ); + +/** + Register an event that is to be signaled whenever a configuration process on the specified + configuration data is done. + + This function registers an event that is to be signaled whenever a configuration process on the + specified configuration data is done. An event can be registered for different DataType + simultaneously and the caller is responsible for determining which type of configuration data causes + the signaling of the event in such case. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to unregister the event for. + @param[in] Event The event to register. + + @retval EFI_SUCCESS The notification event for the specified configuration data is + registered. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_UNSUPPORTED The configuration data type specified by DataType is not supported. + @retval EFI_OUT_OF_RESOURCES Required system resources could not be allocated. + @retval EFI_ACCESS_DENIED The Event is already registered for the DataType. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_REGISTER_NOTIFY) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/** + Remove a previously registered event for the specified configuration data. + + This function removes a previously registeredevent for the specified configuration data. + + @param[in] This Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance. + @param[in] DataType The type of data to remove the previously registered event for. + @param[in] Event The event to unregister. + + @retval EFI_SUCCESS The event registered for the specified configuration data is removed. + @retval EFI_INVALID_PARAMETER This is NULL or Event is NULL. + @retval EFI_NOT_FOUND The Eventhas not been registered for the specified DataType. +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_IP4_CONFIG2_UNREGISTER_NOTIFY) ( + IN EFI_IP4_CONFIG2_PROTOCOL *This, + IN EFI_IP4_CONFIG2_DATA_TYPE DataType, + IN EFI_EVENT Event + ); + +/// +/// The EFI_IP4_CONFIG2_PROTOCOL is designed to be the central repository for the common +/// configurations and the administrator configurable settings for the EFI IPv4 network stack. +/// An EFI IPv4 Configuration II Protocol instance will be installed on each communication device that +/// the EFI IPv4 network stack runs on. +/// +struct _EFI_IP4_CONFIG2_PROTOCOL { + EFI_IP4_CONFIG2_SET_DATA SetData; + EFI_IP4_CONFIG2_GET_DATA GetData; + EFI_IP4_CONFIG2_REGISTER_NOTIFY RegisterDataNotify; + EFI_IP4_CONFIG2_UNREGISTER_NOTIFY UnregisterDataNotify; +}; + +extern EFI_GUID gEfiIp4Config2ProtocolGuid; + +#endif + Copied: stable/12/stand/efi/include/Protocol/ServiceBinding.h (from r349349, head/stand/efi/include/Protocol/ServiceBinding.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/include/Protocol/ServiceBinding.h Thu Oct 24 04:00:49 2019 (r354008, copy of r349349, head/stand/efi/include/Protocol/ServiceBinding.h) @@ -0,0 +1,95 @@ +/* $FreeBSD$ */ +/** @file + UEFI Service Binding Protocol is defined in UEFI specification. + + The file defines the generic Service Binding Protocol functions. + It provides services that are required to create and destroy child + handles that support a given set of protocols. + + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __EFI_SERVICE_BINDING_H__ +#define __EFI_SERVICE_BINDING_H__ + +/// +/// Forward reference for pure ANSI compatibility +/// +typedef struct _EFI_SERVICE_BINDING_PROTOCOL EFI_SERVICE_BINDING_PROTOCOL; + +/** + Creates a child handle and installs a protocol. + + The CreateChild() function installs a protocol on ChildHandle. + If ChildHandle is a pointer to NULL, then a new handle is created and returned in ChildHandle. + If ChildHandle is not a pointer to NULL, then the protocol installs on the existing ChildHandle. + + @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance. + @param ChildHandle Pointer to the handle of the child to create. If it is NULL, + then a new handle is created. If it is a pointer to an existing UEFI handle, + then the protocol is added to the existing UEFI handle. + + @retval EFI_SUCCES The protocol was added to ChildHandle. + @retval EFI_INVALID_PARAMETER ChildHandle is NULL. + @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create + the child + @retval other The child handle was not created + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD)( + IN EFI_SERVICE_BINDING_PROTOCOL *This, + IN OUT EFI_HANDLE *ChildHandle + ); + +/** + Destroys a child handle with a protocol installed on it. + + The DestroyChild() function does the opposite of CreateChild(). It removes a protocol + that was installed by CreateChild() from ChildHandle. If the removed protocol is the + last protocol on ChildHandle, then ChildHandle is destroyed. + + @param This Pointer to the EFI_SERVICE_BINDING_PROTOCOL instance. + @param ChildHandle Handle of the child to destroy + + @retval EFI_SUCCES The protocol was removed from ChildHandle. + @retval EFI_UNSUPPORTED ChildHandle does not support the protocol that is being removed. + @retval EFI_INVALID_PARAMETER Child handle is NULL. + @retval EFI_ACCESS_DENIED The protocol could not be removed from the ChildHandle + because its services are being used. + @retval other The child handle was not destroyed + +**/ +typedef +EFI_STATUS +(EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD)( + IN EFI_SERVICE_BINDING_PROTOCOL *This, + IN EFI_HANDLE ChildHandle + ); + +/// +/// The EFI_SERVICE_BINDING_PROTOCOL provides member functions to create and destroy +/// child handles. A driver is responsible for adding protocols to the child handle +/// in CreateChild() and removing protocols in DestroyChild(). It is also required +/// that the CreateChild() function opens the parent protocol BY_CHILD_CONTROLLER +/// to establish the parent-child relationship, and closes the protocol in DestroyChild(). +/// The pseudo code for CreateChild() and DestroyChild() is provided to specify the +/// required behavior, not to specify the required implementation. Each consumer of +/// a software protocol is responsible for calling CreateChild() when it requires the +/// protocol and calling DestroyChild() when it is finished with that protocol. +/// +struct _EFI_SERVICE_BINDING_PROTOCOL { + EFI_SERVICE_BINDING_CREATE_CHILD CreateChild; + EFI_SERVICE_BINDING_DESTROY_CHILD DestroyChild; +}; + +#endif Modified: stable/12/stand/efi/include/efidevp.h ============================================================================== --- stable/12/stand/efi/include/efidevp.h Thu Oct 24 03:57:56 2019 (r354007) +++ stable/12/stand/efi/include/efidevp.h Thu Oct 24 04:00:49 2019 (r354008) @@ -232,6 +232,8 @@ typedef struct _IPv4_DEVICE_PATH { UINT16 RemotePort; UINT16 Protocol; BOOLEAN StaticIpAddress; + EFI_IPv4_ADDRESS GatewayIpAddress; + EFI_IPv4_ADDRESS SubnetMask; } IPv4_DEVICE_PATH; #define MSG_IPv6_DP 0x0d @@ -293,6 +295,26 @@ typedef struct _SATA_DEVICE_PATH { UINT16 PortMultiplierPortNumber; UINT16 Lun; } SATA_DEVICE_PATH; + + +/* DNS Device Path SubType */ +#define MSG_DNS_DP 0x1F +typedef struct { + EFI_DEVICE_PATH Header; + /* Indicates the DNS server address is IPv4 or IPv6 address. */ + UINT8 IsIPv6; + /* Instance of the DNS server address. */ + /* XXX: actually EFI_IP_ADDRESS */ + EFI_IPv4_ADDRESS DnsServerIp[]; +} DNS_DEVICE_PATH; + +/* Uniform Resource Identifiers (URI) Device Path SubType */ +#define MSG_URI_DP 0x18 +typedef struct { + EFI_DEVICE_PATH Header; + /* Instance of the URI pursuant to RFC 3986. */ + CHAR8 Uri[]; +} URI_DEVICE_PATH; #define MEDIA_DEVICE_PATH 0x04 Modified: stable/12/stand/efi/include/efilib.h ============================================================================== --- stable/12/stand/efi/include/efilib.h Thu Oct 24 03:57:56 2019 (r354007) +++ stable/12/stand/efi/include/efilib.h Thu Oct 24 04:00:49 2019 (r354008) @@ -42,6 +42,7 @@ extern EFI_RUNTIME_SERVICES *RS; extern struct devsw efipart_fddev; extern struct devsw efipart_cddev; extern struct devsw efipart_hddev; +extern struct devsw efihttp_dev; extern struct devsw efinet_dev; extern struct netif_driver efinetif; Modified: stable/12/stand/efi/libefi/Makefile ============================================================================== --- stable/12/stand/efi/libefi/Makefile Thu Oct 24 03:57:56 2019 (r354007) *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Thu Oct 24 04:08:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C915915B1B7; Thu, 24 Oct 2019 04:08:25 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zDHs4prxz4RLR; Thu, 24 Oct 2019 04:08:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 895598653; Thu, 24 Oct 2019 04:08:25 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O48PWa043568; Thu, 24 Oct 2019 04:08:25 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O48Px8043567; Thu, 24 Oct 2019 04:08:25 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240408.x9O48Px8043567@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 04:08:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354011 - in stable/12/stand: efi/libefi libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: efi/libefi libsa X-SVN-Commit-Revision: 354011 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 04:08:25 -0000 Author: kevans Date: Thu Oct 24 04:08:24 2019 New Revision: 354011 URL: https://svnweb.freebsd.org/changeset/base/354011 Log: MFC r349928: Allow efi loader to get network params from uboot Summary: efi loader does not work with static network parameters. It always uses BOOTP/DHCP and also uses RARP as a fallback. Problems with DHCP servers can cause the loader to fail to populate network parameters. Modified: stable/12/stand/efi/libefi/efinet.c stable/12/stand/libsa/net.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/efinet.c ============================================================================== --- stable/12/stand/efi/libefi/efinet.c Thu Oct 24 04:05:53 2019 (r354010) +++ stable/12/stand/efi/libefi/efinet.c Thu Oct 24 04:08:24 2019 (r354011) @@ -40,6 +40,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include "dev_net.h" + static EFI_GUID sn_guid = EFI_SIMPLE_NETWORK_PROTOCOL; static void efinet_end(struct netif *); @@ -198,7 +200,75 @@ efinet_get(struct iodesc *desc, void **pkt, time_t tim return (ret); } +/* + * Loader uses BOOTP/DHCP and also uses RARP as a fallback to populate + * network parameters and problems with DHCP servers can cause the loader + * to fail to populate them. Allow the device to ask about the basic + * network parameters and if present use them. + */ static void +efi_env_net_params(struct iodesc *desc) +{ + char *envstr; + in_addr_t ipaddr, mask, gwaddr, serveraddr; + n_long rootaddr; + + if ((envstr = getenv("rootpath")) != NULL) + strlcpy(rootpath, envstr, sizeof(rootpath)); + + /* + * Get network parameters. + */ + envstr = getenv("ipaddr"); + ipaddr = (envstr != NULL) ? inet_addr(envstr) : 0; + + envstr = getenv("netmask"); + mask = (envstr != NULL) ? inet_addr(envstr) : 0; + + envstr = getenv("gatewayip"); + gwaddr = (envstr != NULL) ? inet_addr(envstr) : 0; + + envstr = getenv("serverip"); + serveraddr = (envstr != NULL) ? inet_addr(envstr) : 0; + + /* No network params. */ + if (ipaddr == 0 && mask == 0 && gwaddr == 0 && serveraddr == 0) + return; + + /* Partial network params. */ + if (ipaddr == 0 || mask == 0 || gwaddr == 0 || serveraddr == 0) { + printf("Incomplete network settings from U-Boot\n"); + return; + } + + /* + * Set network parameters. + */ + myip.s_addr = ipaddr; + netmask = mask; + gateip.s_addr = gwaddr; + servip.s_addr = serveraddr; + + /* + * There must be a rootpath. It may be ip:/path or it may be just the + * path in which case the ip needs to be serverip. + */ + rootaddr = net_parse_rootpath(); + if (rootaddr == INADDR_NONE) + rootaddr = serveraddr; + rootip.s_addr = rootaddr; + +#ifdef EFINET_DEBUG + printf("%s: ip=%s\n", __func__, inet_ntoa(myip)); + printf("%s: mask=%s\n", __func__, intoa(netmask)); + printf("%s: gateway=%s\n", __func__, inet_ntoa(gateip)); + printf("%s: server=%s\n", __func__, inet_ntoa(servip)); +#endif + + desc->myip = myip; +} + +static void efinet_init(struct iodesc *desc, void *machdep_hint) { struct netif *nif = desc->io_netif; @@ -206,6 +276,9 @@ efinet_init(struct iodesc *desc, void *machdep_hint) EFI_HANDLE h; EFI_STATUS status; UINT32 mask; + + /* Attempt to get netboot params from env */ + efi_env_net_params(desc); if (nif->nif_driver->netif_ifs[nif->nif_unit].dif_unit < 0) { printf("Invalid network interface %d\n", nif->nif_unit); Modified: stable/12/stand/libsa/net.h ============================================================================== --- stable/12/stand/libsa/net.h Thu Oct 24 04:05:53 2019 (r354010) +++ stable/12/stand/libsa/net.h Thu Oct 24 04:08:24 2019 (r354011) @@ -91,6 +91,7 @@ extern struct in_addr rootip; extern struct in_addr swapip; extern struct in_addr gateip; extern struct in_addr nameip; +extern struct in_addr servip; extern n_long netmask; extern u_int intf_mtu; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:37:18 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3D4201563A4; Thu, 24 Oct 2019 03:37:18 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCby0gd2z4LHG; Thu, 24 Oct 2019 03:37:18 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id F00D780BA; Thu, 24 Oct 2019 03:37:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3bHYI025331; Thu, 24 Oct 2019 03:37:17 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3bH9P025330; Thu, 24 Oct 2019 03:37:17 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240337.x9O3bH9P025330@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:37:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353999 - stable/12/stand/i386 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/i386 X-SVN-Commit-Revision: 353999 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:37:18 -0000 Author: kevans Date: Thu Oct 24 03:37:17 2019 New Revision: 353999 URL: https://svnweb.freebsd.org/changeset/base/353999 Log: MFC r340834: Disable build-id in i386 binary boot components A user may enable build-id for all builds by adding LDFLAGS=-Wl,--build-id=sha1 to /etc/make.conf. In this case the build-id note ends added up to mbr and pmbr's .text, which makes it too large (it ends up being 532 bytes). To avoid this explicitly turn off build-id for these components. Modified: stable/12/stand/i386/Makefile.inc Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/i386/Makefile.inc ============================================================================== --- stable/12/stand/i386/Makefile.inc Thu Oct 24 03:32:47 2019 (r353998) +++ stable/12/stand/i386/Makefile.inc Thu Oct 24 03:37:17 2019 (r353999) @@ -2,6 +2,8 @@ # # $FreeBSD$ +.include "bsd.linker.mk" + LOADER_ADDRESS?=0x200000 LDFLAGS+= -nostdlib LDFLAGS.lld+= -Wl,--no-rosegment @@ -23,6 +25,9 @@ LDSCRIPT= ${BOOTSRC}/i386/boot.ldscript # LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary # LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary +.if ${LINKER_FEATURES:Mbuild-id} != "" +LDFLAGS_BIN+=-Wl,--build-id=none +.endif LD_FLAGS_BIN=-static -N --gc-sections .if ${MACHINE_CPUARCH} == "amd64" From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:40:21 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D9326156C10; Thu, 24 Oct 2019 03:40:21 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCgT5PDfz4Lm5; Thu, 24 Oct 2019 03:40:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9D60B80C5; Thu, 24 Oct 2019 03:40:21 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3eLPK025621; Thu, 24 Oct 2019 03:40:21 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3eLuO025619; Thu, 24 Oct 2019 03:40:21 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240340.x9O3eLuO025619@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:40:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354001 - stable/12/stand/libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa X-SVN-Commit-Revision: 354001 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:40:21 -0000 Author: kevans Date: Thu Oct 24 03:40:20 2019 New Revision: 354001 URL: https://svnweb.freebsd.org/changeset/base/354001 Log: MFC (proactively; not required yet) r339673: Fix stand/ build after r339671. ffs_subr.c requires calculate_crc32c() from libkern. Unfortunately we cannot just add libkern/crc32.c to libstand because crc32.o is already compiled from contrib/zlib/crc32.c. Use the include trick to rename the source. Note that libstand also provides crc32.c which seems to be unused. Added: stable/12/stand/libsa/crc32_libkern.c - copied unchanged from r339673, head/stand/libsa/crc32_libkern.c Modified: stable/12/stand/libsa/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/Makefile ============================================================================== --- stable/12/stand/libsa/Makefile Thu Oct 24 03:38:16 2019 (r354000) +++ stable/12/stand/libsa/Makefile Thu Oct 24 03:40:20 2019 (r354001) @@ -148,9 +148,9 @@ SRCS+=ffs_subr.c ffs_tables.c CFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2 -# explicit_bzero +# explicit_bzero and calculate_crc32c .PATH: ${SYSDIR}/libkern -SRCS+= explicit_bzero.c +SRCS+= explicit_bzero.c crc32_libkern.c # Maybe GELI .if ${MK_LOADER_GELI} == "yes" Copied: stable/12/stand/libsa/crc32_libkern.c (from r339673, head/stand/libsa/crc32_libkern.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/libsa/crc32_libkern.c Thu Oct 24 03:40:20 2019 (r354001, copy of r339673, head/stand/libsa/crc32_libkern.c) @@ -0,0 +1,3 @@ +/* $FreeBSD$ */ + +#include "../../sys/libkern/crc32.c" From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:01:42 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E682F177D14; Thu, 24 Oct 2019 03:01:42 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zBpt6bgqz4DhQ; Thu, 24 Oct 2019 03:01:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C61967A9C; Thu, 24 Oct 2019 03:01:42 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O31g6o002772; Thu, 24 Oct 2019 03:01:42 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O31eCL002762; Thu, 24 Oct 2019 03:01:40 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240301.x9O31eCL002762@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:01:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353983 - in stable/12/stand: common efi/libefi i386/libi386 powerpc userboot/userboot X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: common efi/libefi i386/libi386 powerpc userboot/userboot X-SVN-Commit-Revision: 353983 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:01:43 -0000 Author: kevans Date: Thu Oct 24 03:01:40 2019 New Revision: 353983 URL: https://svnweb.freebsd.org/changeset/base/353983 Log: MFC r345066, r347219-r347220, r347223, r347388-r347389, r347391, r347393, r347553, r348040 r345066: stand: Improve some debugging experience Some of these files using _DEBUG defined a DEBUG() macro to serve as a debug-printf. -DDEBUG is useful to enable some debugging output across multiple ELF/common parts, so switch the DEBUG-as-printf macros over to something more like DPRINTF that is more commonly used for this kind of thing and less likely to conflict. userboot/elf64_freebsd debugging also assumed %llx for uint64; use PRIx64 instead. r347219: loader: use safer DPRINTF body for non-debug case r347220: loader: bcache code does not need to check argument for free() r347223: command_bcache() does not use argv Therefore mark argv __unused. r347388: loader: implement proper 8 char tab stops The current console code is printing out 8 spaces for tab, calculate the amount of spaces based on tab stops. r347389: loader: ptable_print() needs two tabs sometimes Since the partition/slice names do vary in length, check the length of the fixed part of the line against 3 * 8, if the lenth is less than 3 tab stops, print out extra tab. use snprintf() instead of sprintf. r347391: loader: no-TERM_EMU is broken now If TERM_EMU is not defined, we do not have curx variable. Use conout mode for efi and expose get_pos() for i386. r347393: loader: use DPRINTF in biosdisk.c and define safe DPRINTF r345066 did miss biosdisk.c. Also define DPRINTF as ((void)0) for case we do not want debug printouts. r347553: loader: fix memory handling errors in module.c file_loadraw(): check for file_alloc() and strdup() results. we leak 'name'. mod_load() does leak 'filename'. mod_loadkld() does not need to check fp, file_discard() does check. r348040: stand: TARGET_ARCH is spelled MACHINE_ARCH in Makefiles Modified: stable/12/stand/common/bcache.c stable/12/stand/common/disk.c stable/12/stand/common/interp_forth.c stable/12/stand/common/module.c stable/12/stand/common/part.c stable/12/stand/efi/libefi/efi_console.c stable/12/stand/i386/libi386/biosdisk.c stable/12/stand/i386/libi386/vidconsole.c stable/12/stand/powerpc/Makefile stable/12/stand/userboot/userboot/elf64_freebsd.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/bcache.c ============================================================================== --- stable/12/stand/common/bcache.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/common/bcache.c Thu Oct 24 03:01:40 2019 (r353983) @@ -44,9 +44,9 @@ __FBSDID("$FreeBSD$"); /* #define BCACHE_DEBUG */ #ifdef BCACHE_DEBUG -# define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) +# define DPRINTF(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) #else -# define DEBUG(fmt, args...) +# define DPRINTF(fmt, args...) ((void)0) #endif struct bcachectl @@ -384,7 +384,7 @@ bcache_strategy(void *devdata, int rw, daddr_t blk, si /* bypass large requests, or when the cache is inactive */ if (bc == NULL || ((size * 2 / bcache_blksize) > bcache_nblks)) { - DEBUG("bypass %zu from %qu", size / bcache_blksize, blk); + DPRINTF("bypass %zu from %qu", size / bcache_blksize, blk); bcache_bypasses++; rw &= F_MASK; return (dd->dv_strategy(dd->dv_devdata, rw, blk, size, buf, rsize)); @@ -441,10 +441,8 @@ static void bcache_free_instance(struct bcache *bc) { if (bc != NULL) { - if (bc->bcache_ctl) - free(bc->bcache_ctl); - if (bc->bcache_data) - free(bc->bcache_data); + free(bc->bcache_ctl); + free(bc->bcache_data); free(bc); } } @@ -459,7 +457,7 @@ bcache_insert(struct bcache *bc, daddr_t blkno) cand = BHASH(bc, blkno); - DEBUG("insert blk %llu -> %u # %d", blkno, cand, bcache_bcount); + DPRINTF("insert blk %llu -> %u # %d", blkno, cand, bcache_bcount); bc->bcache_ctl[cand].bc_blkno = blkno; bc->bcache_ctl[cand].bc_count = bcache_bcount++; } @@ -476,7 +474,7 @@ bcache_invalidate(struct bcache *bc, daddr_t blkno) if (bc->bcache_ctl[i].bc_blkno == blkno) { bc->bcache_ctl[i].bc_count = -1; bc->bcache_ctl[i].bc_blkno = -1; - DEBUG("invalidate blk %llu", blkno); + DPRINTF("invalidate blk %llu", blkno); } } @@ -484,7 +482,7 @@ bcache_invalidate(struct bcache *bc, daddr_t blkno) COMMAND_SET(bcachestat, "bcachestat", "get disk block cache stats", command_bcache); static int -command_bcache(int argc, char *argv[]) +command_bcache(int argc, char *argv[] __unused) { if (argc != 1) { command_errmsg = "wrong number of arguments"; Modified: stable/12/stand/common/disk.c ============================================================================== --- stable/12/stand/common/disk.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/common/disk.c Thu Oct 24 03:01:40 2019 (r353983) @@ -38,9 +38,9 @@ __FBSDID("$FreeBSD$"); #include "disk.h" #ifdef DISK_DEBUG -# define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) +# define DPRINTF(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) #else -# define DEBUG(fmt, args...) +# define DPRINTF(fmt, args...) ((void)0) #endif struct open_disk { @@ -75,7 +75,7 @@ display_size(uint64_t size, u_int sectorsize) size /= 1024; unit = 'M'; } - sprintf(buf, "%4ld%cB", (long)size, unit); + snprintf(buf, sizeof(buf), "%4ld%cB", (long)size, unit); return (buf); } @@ -118,11 +118,24 @@ ptable_print(void *arg, const char *pname, const struc od = (struct open_disk *)pa->dev->dd.d_opendata; sectsize = od->sectorsize; partsize = part->end - part->start + 1; - sprintf(line, " %s%s: %s\t%s\n", pa->prefix, pname, - parttype2str(part->type), - pa->verbose ? display_size(partsize, sectsize) : ""); + snprintf(line, sizeof(line), " %s%s: %s", pa->prefix, pname, + parttype2str(part->type)); if (pager_output(line)) - return 1; + return (1); + + if (pa->verbose) { + /* Emit extra tab when the line is shorter than 3 tab stops */ + if (strlen(line) < 24) + (void) pager_output("\t"); + + snprintf(line, sizeof(line), "\t%s", + display_size(partsize, sectsize)); + if (pager_output(line)) + return (1); + } + if (pager_output("\n")) + return (1); + res = 0; if (part->type == PART_FREEBSD) { /* Open slice with BSD label */ @@ -140,7 +153,8 @@ ptable_print(void *arg, const char *pname, const struc dev.d_offset = part->start; table = ptable_open(&dev, partsize, sectsize, ptblread); if (table != NULL) { - sprintf(line, " %s%s", pa->prefix, pname); + snprintf(line, sizeof(line), " %s%s", + pa->prefix, pname); bsd.dev = pa->dev; bsd.prefix = line; bsd.verbose = pa->verbose; @@ -229,13 +243,13 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize int rc, slice, partition; if (sectorsize == 0) { - DEBUG("unknown sector size"); + DPRINTF("unknown sector size"); return (ENXIO); } rc = 0; od = (struct open_disk *)malloc(sizeof(struct open_disk)); if (od == NULL) { - DEBUG("no memory"); + DPRINTF("no memory"); return (ENOMEM); } dev->dd.d_opendata = od; @@ -256,14 +270,14 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize slice = dev->d_slice; partition = dev->d_partition; - DEBUG("%s unit %d, slice %d, partition %d => %p", + DPRINTF("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev), dev->dd.d_unit, dev->d_slice, dev->d_partition, od); /* Determine disk layout. */ od->table = ptable_open(&partdev, mediasize / sectorsize, sectorsize, ptblread); if (od->table == NULL) { - DEBUG("Can't read partition table"); + DPRINTF("Can't read partition table"); rc = ENXIO; goto out; } @@ -319,7 +333,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize table = ptable_open(dev, part.end - part.start + 1, od->sectorsize, ptblread); if (table == NULL) { - DEBUG("Can't read BSD label"); + DPRINTF("Can't read BSD label"); rc = ENXIO; goto out; } @@ -347,12 +361,12 @@ out: if (od->table != NULL) ptable_close(od->table); free(od); - DEBUG("%s could not open", disk_fmtdev(dev)); + DPRINTF("%s could not open", disk_fmtdev(dev)); } else { /* Save the slice and partition number to the dev */ dev->d_slice = slice; dev->d_partition = partition; - DEBUG("%s offset %lld => %p", disk_fmtdev(dev), + DPRINTF("%s offset %lld => %p", disk_fmtdev(dev), (long long)dev->d_offset, od); } return (rc); @@ -364,7 +378,7 @@ disk_close(struct disk_devdesc *dev) struct open_disk *od; od = (struct open_disk *)dev->dd.d_opendata; - DEBUG("%s closed => %p", disk_fmtdev(dev), od); + DPRINTF("%s closed => %p", disk_fmtdev(dev), od); ptable_close(od->table); free(od); return (0); Modified: stable/12/stand/common/interp_forth.c ============================================================================== --- stable/12/stand/common/interp_forth.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/common/interp_forth.c Thu Oct 24 03:01:40 2019 (r353983) @@ -39,9 +39,9 @@ INTERP_DEFINE("4th"); /* #define BFORTH_DEBUG */ #ifdef BFORTH_DEBUG -#define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) +#define DPRINTF(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) #else -#define DEBUG(fmt, args...) +#define DPRINTF(fmt, args...) ((void)0) #endif /* @@ -128,7 +128,7 @@ bf_command(FICL_VM *vm) vmUpdateTib(vm, tail + len); } } - DEBUG("cmd '%s'", line); + DPRINTF("cmd '%s'", line); command_errmsg = command_errbuf; command_errbuf[0] = 0; @@ -310,7 +310,7 @@ bf_run(const char *line) */ result = ficlExec(bf_vm, __DECONST(char *, line)); - DEBUG("ficlExec '%s' = %d", line, result); + DPRINTF("ficlExec '%s' = %d", line, result); switch (result) { case VM_OUTOFTEXT: case VM_ABORTQ: Modified: stable/12/stand/common/module.c ============================================================================== --- stable/12/stand/common/module.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/common/module.c Thu Oct 24 03:01:40 2019 (r353983) @@ -499,7 +499,14 @@ file_loadraw(const char *fname, char *type, int insert /* Looks OK so far; create & populate control structure */ fp = file_alloc(); - fp->f_name = strdup(name); + if (fp == NULL) { + snprintf(command_errbuf, sizeof (command_errbuf), + "no memory to load %s", name); + free(name); + close(fd); + return (NULL); + } + fp->f_name = name; fp->f_type = strdup(type); fp->f_args = NULL; fp->f_metadata = NULL; @@ -507,6 +514,13 @@ file_loadraw(const char *fname, char *type, int insert fp->f_addr = loadaddr; fp->f_size = laddr - loadaddr; + if (fp->f_type == NULL) { + snprintf(command_errbuf, sizeof (command_errbuf), + "no memory to load %s", name); + free(name); + close(fd); + return (NULL); + } /* recognise space consumption */ loadaddr = laddr; @@ -552,6 +566,7 @@ mod_load(char *modname, struct mod_depend *verinfo, in return (ENOENT); } err = mod_loadkld(filename, argc, argv); + free(filename); return (err); } @@ -607,7 +622,7 @@ mod_loadkld(const char *kldname, int argc, char *argv[ snprintf(command_errbuf, sizeof(command_errbuf), "don't know how to load module '%s'", filename); } - if (err && fp) + if (err) file_discard(fp); free(filename); return (err); Modified: stable/12/stand/common/part.c ============================================================================== --- stable/12/stand/common/part.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/common/part.c Thu Oct 24 03:01:40 2019 (r353983) @@ -44,9 +44,9 @@ __FBSDID("$FreeBSD$"); #include #ifdef PART_DEBUG -#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) +#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) #else -#define DEBUG(fmt, args...) +#define DPRINTF(fmt, args...) ((void)0) #endif #ifdef LOADER_GPT_SUPPORT @@ -155,34 +155,34 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, u uint32_t sz, crc; if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0) { - DEBUG("no GPT signature"); + DPRINTF("no GPT signature"); return (NULL); } sz = le32toh(hdr->hdr_size); if (sz < 92 || sz > sectorsize) { - DEBUG("invalid GPT header size: %d", sz); + DPRINTF("invalid GPT header size: %d", sz); return (NULL); } crc = le32toh(hdr->hdr_crc_self); hdr->hdr_crc_self = 0; if (crc32(hdr, sz) != crc) { - DEBUG("GPT header's CRC doesn't match"); + DPRINTF("GPT header's CRC doesn't match"); return (NULL); } hdr->hdr_crc_self = crc; hdr->hdr_revision = le32toh(hdr->hdr_revision); if (hdr->hdr_revision < GPT_HDR_REVISION) { - DEBUG("unsupported GPT revision %d", hdr->hdr_revision); + DPRINTF("unsupported GPT revision %d", hdr->hdr_revision); return (NULL); } hdr->hdr_lba_self = le64toh(hdr->hdr_lba_self); if (hdr->hdr_lba_self != lba_self) { - DEBUG("self LBA doesn't match"); + DPRINTF("self LBA doesn't match"); return (NULL); } hdr->hdr_lba_alt = le64toh(hdr->hdr_lba_alt); if (hdr->hdr_lba_alt == hdr->hdr_lba_self) { - DEBUG("invalid alternate LBA"); + DPRINTF("invalid alternate LBA"); return (NULL); } hdr->hdr_entries = le32toh(hdr->hdr_entries); @@ -190,7 +190,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, u if (hdr->hdr_entries == 0 || hdr->hdr_entsz < sizeof(struct gpt_ent) || sectorsize % hdr->hdr_entsz != 0) { - DEBUG("invalid entry size or number of entries"); + DPRINTF("invalid entry size or number of entries"); return (NULL); } hdr->hdr_lba_start = le64toh(hdr->hdr_lba_start); @@ -214,7 +214,7 @@ gpt_checktbl(const struct gpt_hdr *hdr, uint8_t *tbl, /* Check CRC only when buffer size is enough for table. */ if (hdr->hdr_crc_table != crc32(tbl, hdr->hdr_entries * hdr->hdr_entsz)) { - DEBUG("GPT table's CRC doesn't match"); + DPRINTF("GPT table's CRC doesn't match"); return (-1); } } @@ -310,7 +310,7 @@ ptable_gptread(struct ptable *table, void *dev, diskre table->type = PTABLE_NONE; goto out; } - DEBUG("GPT detected"); + DPRINTF("GPT detected"); size = MIN(hdr.hdr_entries * hdr.hdr_entsz, MAXTBLSZ * table->sectorsize); @@ -346,7 +346,7 @@ ptable_gptread(struct ptable *table, void *dev, diskre entry->flags = le64toh(ent->ent_attr); memcpy(&entry->type.gpt, &ent->ent_type, sizeof(uuid_t)); STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DEBUG("new GPT partition added"); + DPRINTF("new GPT partition added"); } out: free(buf); @@ -402,7 +402,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskre buf = malloc(table->sectorsize); if (buf == NULL) return (table); - DEBUG("EBR detected"); + DPRINTF("EBR detected"); for (i = 0; i < MAXEBRENTRIES; i++) { #if 0 /* Some BIOSes return an incorrect number of sectors */ if (offset >= table->sectors) @@ -430,7 +430,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskre entry->flags = dp[0].dp_flag; entry->type.mbr = dp[0].dp_typ; STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DEBUG("new EBR partition added"); + DPRINTF("new EBR partition added"); if (dp[1].dp_typ == 0) break; offset = e1->part.start + le32toh(dp[1].dp_start); @@ -470,14 +470,14 @@ ptable_bsdread(struct ptable *table, void *dev, diskre int i; if (table->sectorsize < sizeof(struct disklabel)) { - DEBUG("Too small sectorsize"); + DPRINTF("Too small sectorsize"); return (table); } buf = malloc(table->sectorsize); if (buf == NULL) return (table); if (dread(dev, buf, 1, 1) != 0) { - DEBUG("read failed"); + DPRINTF("read failed"); ptable_close(table); table = NULL; goto out; @@ -487,15 +487,15 @@ ptable_bsdread(struct ptable *table, void *dev, diskre le32toh(dl->d_magic2) != DISKMAGIC) goto out; if (le32toh(dl->d_secsize) != table->sectorsize) { - DEBUG("unsupported sector size"); + DPRINTF("unsupported sector size"); goto out; } dl->d_npartitions = le16toh(dl->d_npartitions); if (dl->d_npartitions > 20 || dl->d_npartitions < 8) { - DEBUG("invalid number of partitions"); + DPRINTF("invalid number of partitions"); goto out; } - DEBUG("BSD detected"); + DPRINTF("BSD detected"); part = &dl->d_partitions[0]; raw_offset = le32toh(part[RAW_PART].p_offset); for (i = 0; i < dl->d_npartitions; i++, part++) { @@ -513,7 +513,7 @@ ptable_bsdread(struct ptable *table, void *dev, diskre entry->part.index = i; /* starts from zero */ entry->type.bsd = part->p_fstype; STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DEBUG("new BSD partition added"); + DPRINTF("new BSD partition added"); } table->type = PTABLE_BSD; out: @@ -556,7 +556,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk if (buf == NULL) return (table); if (dread(dev, buf, 1, 0) != 0) { - DEBUG("read failed"); + DPRINTF("read failed"); ptable_close(table); table = NULL; goto out; @@ -566,20 +566,20 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk for (i = sum = 0; i < sizeof(struct vtoc8); i += sizeof(sum)) sum ^= be16dec(buf + i); if (sum != 0) { - DEBUG("incorrect checksum"); + DPRINTF("incorrect checksum"); goto out; } if (be16toh(dl->nparts) != VTOC8_NPARTS) { - DEBUG("invalid number of entries"); + DPRINTF("invalid number of entries"); goto out; } sectors = be16toh(dl->nsecs); heads = be16toh(dl->nheads); if (sectors * heads == 0) { - DEBUG("invalid geometry"); + DPRINTF("invalid geometry"); goto out; } - DEBUG("VTOC8 detected"); + DPRINTF("VTOC8 detected"); for (i = 0; i < VTOC8_NPARTS; i++) { dl->part[i].tag = be16toh(dl->part[i].tag); if (i == VTOC_RAW_PART || @@ -595,7 +595,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, disk entry->part.index = i; /* starts from zero */ entry->type.vtoc8 = dl->part[i].tag; STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DEBUG("new VTOC8 partition added"); + DPRINTF("new VTOC8 partition added"); } table->type = PTABLE_VTOC8; out: @@ -619,7 +619,7 @@ ptable_iso9660read(struct ptable *table, void *dev, di return (table); if (dread(dev, buf, 1, cdb2devb(16)) != 0) { - DEBUG("read failed"); + DPRINTF("read failed"); ptable_close(table); table = NULL; goto out; @@ -663,7 +663,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect return (NULL); /* First, read the MBR. */ if (dread(dev, buf, 1, DOSBBSECTOR) != 0) { - DEBUG("read failed"); + DPRINTF("read failed"); goto out; } @@ -703,7 +703,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect /* Check the MBR magic. */ if (buf[DOSMAGICOFFSET] != 0x55 || buf[DOSMAGICOFFSET + 1] != 0xaa) { - DEBUG("magic sequence not found"); + DPRINTF("magic sequence not found"); #if defined(LOADER_GPT_SUPPORT) /* There is no PMBR, check that we have backup GPT */ table->type = PTABLE_GPT; @@ -715,13 +715,13 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect dp = (struct dos_partition *)(buf + DOSPARTOFF); for (i = 0, count = 0; i < NDOSPART; i++) { if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80) { - DEBUG("invalid partition flag %x", dp[i].dp_flag); + DPRINTF("invalid partition flag %x", dp[i].dp_flag); goto out; } #ifdef LOADER_GPT_SUPPORT if (dp[i].dp_typ == DOSPTYP_PMBR) { table->type = PTABLE_GPT; - DEBUG("PMBR detected"); + DPRINTF("PMBR detected"); } #endif if (dp[i].dp_typ != 0) @@ -731,9 +731,9 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect if (table->type == PTABLE_GPT && count > 1) { if (dp[1].dp_typ != DOSPTYP_HFS) { table->type = PTABLE_NONE; - DEBUG("Incorrect PMBR, ignore it"); + DPRINTF("Incorrect PMBR, ignore it"); } else { - DEBUG("Bootcamp detected"); + DPRINTF("Bootcamp detected"); } } #ifdef LOADER_GPT_SUPPORT @@ -744,7 +744,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect #endif #ifdef LOADER_MBR_SUPPORT /* Read MBR. */ - DEBUG("MBR detected"); + DPRINTF("MBR detected"); table->type = PTABLE_MBR; for (i = has_ext = 0; i < NDOSPART; i++) { if (dp[i].dp_typ == 0) @@ -770,7 +770,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sect entry->flags = dp[i].dp_flag; entry->type.mbr = dp[i].dp_typ; STAILQ_INSERT_TAIL(&table->entries, entry, entry); - DEBUG("new MBR partition added"); + DPRINTF("new MBR partition added"); } if (has_ext) { table = ptable_ebrread(table, dev, dread); Modified: stable/12/stand/efi/libefi/efi_console.c ============================================================================== --- stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/efi/libefi/efi_console.c Thu Oct 24 03:01:40 2019 (r353983) @@ -135,11 +135,13 @@ efi_cons_rawputchar(int c) UINTN x, y; conout->QueryMode(conout, conout->Mode->Mode, &x, &y); - if (c == '\t') - /* XXX lame tab expansion */ - for (i = 0; i < 8; i++) + if (c == '\t') { + int n; + + n = 8 - ((conout->Mode->CursorColumn + 8) % 8); + for (i = 0; i < n; i++) efi_cons_rawputchar(' '); - else { + } else { #ifndef TERM_EMU if (c == '\n') efi_cons_efiputchar('\r'); Modified: stable/12/stand/i386/libi386/biosdisk.c ============================================================================== --- stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 03:01:40 2019 (r353983) @@ -65,9 +65,9 @@ __FBSDID("$FreeBSD$"); #define CDMAJOR 15 #ifdef DISK_DEBUG -#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) +#define DPRINTF(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) #else -#define DEBUG(fmt, args...) +#define DPRINTF(fmt, args...) ((void)0) #endif struct specification_packet { @@ -218,12 +218,12 @@ bd_bios2unit(int biosdev) bdinfo_t *bd; int i, unit; - DEBUG("looking for bios device 0x%x", biosdev); + DPRINTF("looking for bios device 0x%x", biosdev); for (i = 0; bdi[i] != NULL; i++) { unit = 0; STAILQ_FOREACH(bd, bdi[i], bd_link) { if (bd->bd_unit == biosdev) { - DEBUG("bd unit %d is BIOS device 0x%x", unit, + DPRINTF("bd unit %d is BIOS device 0x%x", unit, bd->bd_unit); return (unit); } @@ -620,7 +620,7 @@ bd_int13probe(bdinfo_t *bd) if (bd->bd_sectors == 0) bd->bd_sectors = (uint64_t)bd->bd_cyl * bd->bd_hds * bd->bd_sec; - DEBUG("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl, + DPRINTF("unit 0x%x geometry %d/%d/%d\n", bd->bd_unit, bd->bd_cyl, bd->bd_hds, bd->bd_sec); return (true); @@ -919,7 +919,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s return (EIO); } - DEBUG("open_disk %p", dev); + DPRINTF("open_disk %p", dev); offset = dblk * BIOSDISK_SECSIZE; dblk = offset / bd->bd_sectorsize; @@ -932,7 +932,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s * while translating block count to bytes. */ if (size > INT_MAX) { - DEBUG("too large I/O: %zu bytes", size); + DPRINTF("too large I/O: %zu bytes", size); return (EIO); } @@ -972,7 +972,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s if (dblk + blks >= d_offset + disk_blocks) { blks = d_offset + disk_blocks - dblk; size = blks * bd->bd_sectorsize; - DEBUG("short I/O %d", blks); + DPRINTF("short I/O %d", blks); } bio_size = min(BIO_BUFFER_SIZE, size); @@ -997,7 +997,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s switch (rw & F_MASK) { case F_READ: - DEBUG("read %d from %lld to %p", x, dblk, buf); + DPRINTF("read %d from %lld to %p", x, dblk, buf); bsize = bd->bd_sectorsize * x - blkoff; if (rest < bsize) bsize = rest; @@ -1010,7 +1010,7 @@ bd_realstrategy(void *devdata, int rw, daddr_t dblk, s bcopy(bbuf + blkoff, buf, bsize); break; case F_WRITE : - DEBUG("write %d from %lld to %p", x, dblk, buf); + DPRINTF("write %d from %lld to %p", x, dblk, buf); if (blkoff != 0) { /* * We got offset to sector, read 1 sector to @@ -1259,7 +1259,7 @@ bd_getdev(struct i386_devdesc *d) return (-1); biosdev = bd_unit2bios(d); - DEBUG("unit %d BIOS device %d", dev->dd.d_unit, biosdev); + DPRINTF("unit %d BIOS device %d", dev->dd.d_unit, biosdev); if (biosdev == -1) /* not a BIOS device */ return (-1); @@ -1312,6 +1312,6 @@ bd_getdev(struct i386_devdesc *d) } rootdev = MAKEBOOTDEV(major, slice, unit, partition); - DEBUG("dev is 0x%x\n", rootdev); + DPRINTF("dev is 0x%x\n", rootdev); return (rootdev); } Modified: stable/12/stand/i386/libi386/vidconsole.c ============================================================================== --- stable/12/stand/i386/libi386/vidconsole.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/i386/libi386/vidconsole.c Thu Oct 24 03:01:40 2019 (r353983) @@ -49,6 +49,8 @@ static int vidc_ischar(void); static int vidc_started; +void get_pos(int *x, int *y); + #ifdef TERM_EMU #define MAXARGS 8 #define DEFAULT_FGCOLOR 7 @@ -57,7 +59,6 @@ static int vidc_started; void end_term(void); void bail_out(int c); void vidc_term_emu(int c); -void get_pos(int *x, int *y); void curs_move(int *_x, int *_y, int x, int y); void write_char(int c, int fg, int bg); void scroll_up(int rows, int fg, int bg); @@ -136,11 +137,18 @@ vidc_rawputchar(int c) { int i; - if (c == '\t') - /* lame tab expansion */ - for (i = 0; i < 8; i++) + if (c == '\t') { + int n; +#ifndef TERM_EMU + int curx, cury; + + get_pos(&curx, %cury); +#endif + + n = 8 - ((curx + 8) % 8); + for (i = 0; i < n; i++) vidc_rawputchar(' '); - else { + } else { #ifndef TERM_EMU vidc_biosputchar(c); #else @@ -188,8 +196,6 @@ vidc_rawputchar(int c) } } -#ifdef TERM_EMU - /* Get cursor position on the screen. Result is in edx. Sets * curx and cury appropriately. */ @@ -205,6 +211,8 @@ get_pos(int *x, int *y) *x = v86.edx & 0x00ff; *y = (v86.edx & 0xff00) >> 8; } + +#ifdef TERM_EMU /* Move cursor to x rows and y cols (0-based). */ void Modified: stable/12/stand/powerpc/Makefile ============================================================================== --- stable/12/stand/powerpc/Makefile Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/powerpc/Makefile Thu Oct 24 03:01:40 2019 (r353983) @@ -6,7 +6,7 @@ NO_OBJ=t SUBDIR.yes= boot1.chrp ofw uboot -.if "${TARGET_ARCH}" == "powerpc64" +.if "${MACHINE_ARCH}" == "powerpc64" SUBDIR.${MK_FDT}+= kboot .endif Modified: stable/12/stand/userboot/userboot/elf64_freebsd.c ============================================================================== --- stable/12/stand/userboot/userboot/elf64_freebsd.c Thu Oct 24 02:53:07 2019 (r353982) +++ stable/12/stand/userboot/userboot/elf64_freebsd.c Thu Oct 24 03:01:40 2019 (r353983) @@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef DEBUG +#include +#endif #include #include #include @@ -136,7 +139,7 @@ elf64_exec(struct preloaded_file *fp) } #ifdef DEBUG - printf("Start @ %#llx ...\n", ehdr->e_entry); + printf("Start @ %#"PRIx64" ...\n", ehdr->e_entry); #endif dev_cleanup(); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 04:05:55 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 0415915AA69; Thu, 24 Oct 2019 04:05:55 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zDDy5vcgz4QqT; Thu, 24 Oct 2019 04:05:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A9ECA864A; Thu, 24 Oct 2019 04:05:54 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O45sck043384; Thu, 24 Oct 2019 04:05:54 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O45rdB043379; Thu, 24 Oct 2019 04:05:53 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240405.x9O45rdB043379@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 04:05:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354010 - in stable/12/stand: forth lua X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: forth lua X-SVN-Commit-Revision: 354010 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 04:05:55 -0000 Author: kevans Date: Thu Oct 24 04:05:53 2019 New Revision: 354010 URL: https://svnweb.freebsd.org/changeset/base/354010 Log: MFC r352599, r352601: loader interp color reset fixes r352599: loader_4th: menu items need to reset color attribute, not switch to white Forth menu kernel and BE entries, instead of resetting the color attribute, are switching to white color. r352601: loader_lua: lua color changes should end with reset The color change should have reset sequence, not switch to white. Modified: stable/12/stand/forth/menu.4th stable/12/stand/forth/menu.rc stable/12/stand/lua/color.lua stable/12/stand/lua/logo-beastie.lua stable/12/stand/lua/logo-orb.lua stable/12/stand/lua/menu.lua Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/forth/menu.4th ============================================================================== --- stable/12/stand/forth/menu.4th Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/forth/menu.4th Thu Oct 24 04:05:53 2019 (r354010) @@ -397,7 +397,7 @@ also menu-infrastructure definitions setenv \ Assign third to ansi_caption[x][y] - kerncapbuf 0 s" @[1mK@[37mernel: " [char] @ escc! strcat + kerncapbuf 0 s" @[1mK@[mernel: " [char] @ escc! strcat kernmenuidx @ [char] 0 = if s" default/@[32m" else @@ -405,7 +405,7 @@ also menu-infrastructure definitions then [char] @ escc! strcat 2over strcat - s" @[37m" [char] @ escc! strcat + s" @[m" [char] @ escc! strcat kernidx @ kernmenuidx @ ansi_caption[x][y] setenv Modified: stable/12/stand/forth/menu.rc ============================================================================== --- stable/12/stand/forth/menu.rc Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/forth/menu.rc Thu Oct 24 04:05:53 2019 (r354010) @@ -72,7 +72,7 @@ s" currdev" getenv dup 0> [if] drop 4 s" zfs:" compare set mainmenu_caption[7]="Select Boot [E]nvironment..." set mainmenu_command[7]="3 goto_menu" set mainmenu_keycode[7]=101 - set mainansi_caption[7]="Select Boot ^[1mE^[37mnvironment..." + set mainansi_caption[7]="Select Boot ^[1mE^[mnvironment..." s" chain_disk" getenv? [if] set mainmenu_caption[8]="Chain[L]oad ${chain_disk}" Modified: stable/12/stand/lua/color.lua ============================================================================== --- stable/12/stand/lua/color.lua Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/lua/color.lua Thu Oct 24 04:05:53 2019 (r354010) @@ -42,7 +42,7 @@ color.MAGENTA = 5 color.CYAN = 6 color.WHITE = 7 -color.DEFAULT = 0 +color.DEFAULT = 9 color.BRIGHT = 1 color.DIM = 2 @@ -67,7 +67,7 @@ function color.resetfg() if color.disabled then return '' end - return color.escapefg(color.WHITE) + return color.escapefg(color.DEFAULT) end function color.escapebg(color_value) @@ -81,7 +81,7 @@ function color.resetbg() if color.disabled then return '' end - return color.escapebg(color.BLACK) + return color.escapebg(color.DEFAULT) end function color.escape(fg_color, bg_color, attribute) @@ -101,7 +101,7 @@ function color.default() if color.disabled then return "" end - return color.escape(color.WHITE, color.BLACK, color.DEFAULT) + return color.escape(color.DEFAULT, color.DEFAULT) end function color.highlight(str) Modified: stable/12/stand/lua/logo-beastie.lua ============================================================================== --- stable/12/stand/lua/logo-beastie.lua Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/lua/logo-beastie.lua Thu Oct 24 04:05:53 2019 (r354010) @@ -48,7 +48,7 @@ local beastie_color = { " \\ / /\\", " \027[36m______\027[31m( (_ / \\______/", " \027[36m,' ,-----' |", -" `--{__________)\027[37m" +" `--{__________)\027[m" } drawer.addLogo("beastie", { Modified: stable/12/stand/lua/logo-orb.lua ============================================================================== --- stable/12/stand/lua/logo-orb.lua Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/lua/logo-orb.lua Thu Oct 24 04:05:53 2019 (r354010) @@ -44,7 +44,7 @@ local orb_color = { " -- \027[31;1m-.\027[31m", " `:` \027[31;1m`:`", " \027[31;1m.-- `--.", -" .---.....----.\027[37m" +" .---.....----.\027[m" } drawer.addLogo("orb", { Modified: stable/12/stand/lua/menu.lua ============================================================================== --- stable/12/stand/lua/menu.lua Thu Oct 24 04:04:53 2019 (r354009) +++ stable/12/stand/lua/menu.lua Thu Oct 24 04:05:53 2019 (r354010) @@ -47,10 +47,10 @@ local return_menu_entry = { local function OnOff(str, value) if value then return str .. color.escapefg(color.GREEN) .. "On" .. - color.escapefg(color.WHITE) + color.resetfg() else return str .. color.escapefg(color.RED) .. "off" .. - color.escapefg(color.WHITE) + color.resetfg() end end From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:20:28 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5A3F91536D5; Thu, 24 Oct 2019 03:20:28 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCDX1kGHz4HRH; Thu, 24 Oct 2019 03:20:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E6147CED; Thu, 24 Oct 2019 03:20:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3KSOU013490; Thu, 24 Oct 2019 03:20:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3KSNK013489; Thu, 24 Oct 2019 03:20:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240320.x9O3KSNK013489@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:20:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353990 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 353990 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:20:28 -0000 Author: kevans Date: Thu Oct 24 03:20:27 2019 New Revision: 353990 URL: https://svnweb.freebsd.org/changeset/base/353990 Log: MFC r349201: efinet: Defer exclusively opening the network handles Don't commit to exclusive access to the network device handle by efinet until the loader has decided to load something through the network. This allows for the possibility of other users of the network device. Modified: stable/12/stand/efi/libefi/efinet.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/efinet.c ============================================================================== --- stable/12/stand/efi/libefi/efinet.c Thu Oct 24 03:19:45 2019 (r353989) +++ stable/12/stand/efi/libefi/efinet.c Thu Oct 24 03:20:27 2019 (r353990) @@ -108,7 +108,25 @@ efinet_match(struct netif *nif, void *machdep_hint) static int efinet_probe(struct netif *nif, void *machdep_hint) { + EFI_SIMPLE_NETWORK *net; + EFI_HANDLE h; + EFI_STATUS status; + h = nif->nif_driver->netif_ifs[nif->nif_unit].dif_private; + /* + * Open the network device in exclusive mode. Without this + * we will be racing with the UEFI network stack. It will + * pull packets off the network leading to lost packets. + */ + status = BS->OpenProtocol(h, &sn_guid, (void **)&net, + IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); + if (status != EFI_SUCCESS) { + printf("Unable to open network interface %d for " + "exclusive access: %lu\n", nif->nif_unit, + EFI_ERROR_CODE(status)); + return (efi_status_to_errno(status)); + } + return (0); } @@ -269,7 +287,6 @@ efinet_dev_init() struct netif_dif *dif; struct netif_stats *stats; EFI_DEVICE_PATH *devpath, *node; - EFI_SIMPLE_NETWORK *net; EFI_HANDLE *handles, *handles2; EFI_STATUS status; UINTN sz; @@ -304,19 +321,6 @@ efinet_dev_init() if (DevicePathType(node) != MESSAGING_DEVICE_PATH || DevicePathSubType(node) != MSG_MAC_ADDR_DP) continue; - - /* - * Open the network device in exclusive mode. Without this - * we will be racing with the UEFI network stack. It will - * pull packets off the network leading to lost packets. - */ - status = BS->OpenProtocol(handles[i], &sn_guid, (void **)&net, - IH, NULL, EFI_OPEN_PROTOCOL_EXCLUSIVE); - if (status != EFI_SUCCESS) { - printf("Unable to open network interface %d for " - "exclusive access: %lu\n", i, - EFI_ERROR_CODE(status)); - } handles2[nifs] = handles[i]; nifs++; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 04:12:38 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id D1B3A15C01E; Thu, 24 Oct 2019 04:12:38 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zDNk4R21z4SYm; Thu, 24 Oct 2019 04:12:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7C71F8822; Thu, 24 Oct 2019 04:12:38 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O4CcCH049417; Thu, 24 Oct 2019 04:12:38 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O4CcPx049416; Thu, 24 Oct 2019 04:12:38 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240412.x9O4CcPx049416@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 04:12:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354012 - stable/12/stand/forth X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/forth X-SVN-Commit-Revision: 354012 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 04:12:38 -0000 Author: kevans Date: Thu Oct 24 04:12:38 2019 New Revision: 354012 URL: https://svnweb.freebsd.org/changeset/base/354012 Log: MFC r352420: loader_4th: scan_buffer can leave empty string on stack When the file processing is done, we will have string with lenght 0 in stack and we will attempt to allocate 0 bytes. Modified: stable/12/stand/forth/support.4th Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/forth/support.4th ============================================================================== --- stable/12/stand/forth/support.4th Thu Oct 24 04:08:24 2019 (r354011) +++ stable/12/stand/forth/support.4th Thu Oct 24 04:12:38 2019 (r354012) @@ -363,6 +363,7 @@ variable fd ; : line_buffer_resize ( len -- len ) + dup 0= if exit then >r line_buffer .len @ if line_buffer .addr @ @@ -376,6 +377,7 @@ variable fd ; : append_to_line_buffer ( addr len -- ) + dup 0= if 2drop exit then line_buffer strget 2swap strcat line_buffer .len ! From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:16:26 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 52012152D83; Thu, 24 Oct 2019 03:16:26 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zC7t22vvz4Gy2; Thu, 24 Oct 2019 03:16:26 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2A5B37CDC; Thu, 24 Oct 2019 03:16:26 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3GQFS013156; Thu, 24 Oct 2019 03:16:26 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3GNMT013142; Thu, 24 Oct 2019 03:16:23 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240316.x9O3GNMT013142@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:16:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353988 - in stable/12/stand: efi efi/boot1 efi/gptboot efi/include efi/libefi i386/gptboot libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: efi efi/boot1 efi/gptboot efi/include efi/libefi i386/gptboot libsa X-SVN-Commit-Revision: 353988 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:16:26 -0000 Author: kevans Date: Thu Oct 24 03:16:23 2019 New Revision: 353988 URL: https://svnweb.freebsd.org/changeset/base/353988 Log: MFC r348658-r348659, r348674-r348675, r348678, r348760, r348766, r348768, r348811-r348812, r348814, r349008 r348658: Introduce efi_devpath_same_disk This is like efi_devpath_match, but allows differing device media paths. Those just specify the partition information. r348659: Use newly minted efi_devpath_same_disk() instead of efi_devpath_match(). This fixes a regression in r347193. r348674: Don't shadow a global zfsmount variable. r348675: ufs_module.c can't currently be compiled with -Wcast-align, but the code is safe enough. Turn off the warning for now until I can find the right construct to silence it in the code. r348678: Eliminate unused uuid parameters from gptread and gptread_table. We only need it for the gptfind() function, where it's used. r348760: Use simple malloc/free instead of dropping down to the UEFI BootServices AllocatePool/FreePool calls. They are simpler to use and result in the same thing happening. r348766: Remove left-over status variables r348768: Rework the reporting of the priority. Simplify the code a bit and rework how we report the results of the probing. r348811: Break out the disk selection protocol from the rest of boot1. Segregate the disk probing and selection protocol from the rest of the boot loader. r348812: Create gptboot.efi This is a primary boot loader that is intended to implement the gptboot partition selection algorithm just like we did for BIOS booting. While the preferred method for UEFI is to use the UEFI Boot Manager protocol, there are situations where that can't be done: some BIOS makers interfere with the protocol in unhelpful ways, there's a new standard for a zero variable write from the client OS, and finally for USB drives that might be mobile between systems with multiple partitions there needs to be a media stable way to select. r348814: Add stuff to disable warning for %S Add the customary warnings to disable format checking on armv7. Code move to new files, and the unconditional setting of WARNS to 6 provoked it on tinerbox... r349008: Fix gcc build by removing redeclaration Added: stable/12/stand/efi/boot1/proto.c - copied unchanged from r348812, head/stand/efi/boot1/proto.c stable/12/stand/efi/boot1/proto.h - copied unchanged from r348812, head/stand/efi/boot1/proto.h stable/12/stand/efi/gptboot/ - copied from r348812, head/stand/efi/gptboot/ Modified: stable/12/stand/efi/Makefile stable/12/stand/efi/boot1/Makefile stable/12/stand/efi/boot1/boot1.c stable/12/stand/efi/boot1/boot_module.h stable/12/stand/efi/boot1/ufs_module.c stable/12/stand/efi/boot1/zfs_module.c stable/12/stand/efi/include/efilib.h stable/12/stand/efi/libefi/devpath.c stable/12/stand/i386/gptboot/gptboot.c stable/12/stand/libsa/gpt.c stable/12/stand/libsa/gpt.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/Makefile ============================================================================== --- stable/12/stand/efi/Makefile Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/Makefile Thu Oct 24 03:16:23 2019 (r353988) @@ -9,7 +9,7 @@ NO_OBJ=t .if ${COMPILER_TYPE} != "gcc" || ${COMPILER_VERSION} >= 40500 SUBDIR.${MK_FDT}+= fdt -SUBDIR.yes+= libefi boot1 +SUBDIR.yes+= libefi boot1 gptboot SUBDIR.${MK_FORTH}+= loader_4th SUBDIR.${MK_LOADER_LUA}+= loader_lua SUBDIR.yes+= loader_simp Modified: stable/12/stand/efi/boot1/Makefile ============================================================================== --- stable/12/stand/efi/boot1/Makefile Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/boot1/Makefile Thu Oct 24 03:16:23 2019 (r353988) @@ -5,7 +5,7 @@ BOOT1?= boot1 PROG= ${BOOT1}.sym INTERNALPROG= -WARNS?= 6 +WARNS= 6 CFLAGS+= -DEFI_BOOT1 # We implement a slightly non-standard %S in that it always takes a @@ -13,8 +13,13 @@ CFLAGS+= -DEFI_BOOT1 # seems to matter on arm64 where wchar_t defaults to an int instead # of a short. There's no good cast to use here so just ignore the # warnings for now. +CWARNFLAGS.proto.c+= -Wno-format CWARNFLAGS.boot1.c+= -Wno-format +# Disable bogus alignment issues +CWARNFLAGS.ufs_module.c += -Wno-format +CWARNFLAGS.ufs_module.c += -Wno-cast-align + # Disable warnings that are currently incompatible with the zfs boot code CWARNFLAGS.zfs_module.c += -Wno-array-bounds CWARNFLAGS.zfs_module.c += -Wno-cast-align @@ -25,7 +30,7 @@ CWARNFLAGS.zfs_module.c += -Wno-unused-parameter CWARNFLAGS.zfs_module.c += -Wno-unused-function # architecture-specific loader code -SRCS+= boot1.c self_reloc.c start.S ufs_module.c devpath.c +SRCS+= boot1.c proto.c self_reloc.c start.S ufs_module.c devpath.c .if ${MK_LOADER_ZFS} != "no" SRCS+= zfs_module.c CFLAGS.zfs_module.c+= -I${ZFSSRC} Modified: stable/12/stand/efi/boot1/boot1.c ============================================================================== --- stable/12/stand/efi/boot1/boot1.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/boot1/boot1.c Thu Oct 24 03:16:23 2019 (r353988) @@ -33,10 +33,11 @@ __FBSDID("$FreeBSD$"); #include "boot_module.h" #include "paths.h" +#include "proto.h" static void efi_panic(EFI_STATUS s, const char *fmt, ...) __dead2 __printflike(2, 3); -static const boot_module_t *boot_modules[] = +const boot_module_t *boot_modules[] = { #ifdef EFI_ZFS_BOOT &zfs_module, @@ -45,9 +46,8 @@ static const boot_module_t *boot_modules[] = &ufs_module #endif }; +const UINTN num_boot_modules = nitems(boot_modules); -#define NUM_BOOT_MODULES nitems(boot_modules) - static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; static EFI_GUID LoadedImageGUID = LOADED_IMAGE_PROTOCOL; @@ -91,66 +91,19 @@ Calloc(size_t n1, size_t n2, const char *file, int lin } /* - * load_loader attempts to load the loader image data. - * - * It tries each module and its respective devices, identified by mod->probe, - * in order until a successful load occurs at which point it returns EFI_SUCCESS - * and EFI_NOT_FOUND otherwise. - * - * Only devices which have preferred matching the preferred parameter are tried. - */ -static EFI_STATUS -load_loader(const boot_module_t **modp, dev_info_t **devinfop, void **bufp, - size_t *bufsize, BOOLEAN preferred) -{ - UINTN i; - dev_info_t *dev; - const boot_module_t *mod; - - for (i = 0; i < NUM_BOOT_MODULES; i++) { - mod = boot_modules[i]; - for (dev = mod->devices(); dev != NULL; dev = dev->next) { - if (dev->preferred != preferred) - continue; - - if (mod->load(PATH_LOADER_EFI, dev, bufp, bufsize) == - EFI_SUCCESS) { - *devinfop = dev; - *modp = mod; - return (EFI_SUCCESS); - } - } - } - - return (EFI_NOT_FOUND); -} - -/* * try_boot only returns if it fails to load the loader. If it succeeds * it simply boots, otherwise it returns the status of last EFI call. */ -static EFI_STATUS -try_boot(void) +EFI_STATUS +try_boot(const boot_module_t *mod, dev_info_t *dev, void *loaderbuf, size_t loadersize) { - size_t bufsize, loadersize, cmdsize; - void *buf, *loaderbuf; + size_t bufsize, cmdsize; + void *buf; char *cmd; - dev_info_t *dev; - const boot_module_t *mod; EFI_HANDLE loaderhandle; EFI_LOADED_IMAGE *loaded_image; EFI_STATUS status; - status = load_loader(&mod, &dev, &loaderbuf, &loadersize, TRUE); - if (status != EFI_SUCCESS) { - status = load_loader(&mod, &dev, &loaderbuf, &loadersize, - FALSE); - if (status != EFI_SUCCESS) { - printf("Failed to load '%s'\n", PATH_LOADER_EFI); - return (status); - } - } - /* * Read in and parse the command line from /boot.config or /boot/config, * if present. We'll pass it the next stage via a simple ASCII @@ -230,111 +183,6 @@ errout: return (status); } -/* - * probe_handle determines if the passed handle represents a logical partition - * if it does it uses each module in order to probe it and if successful it - * returns EFI_SUCCESS. - */ -static EFI_STATUS -probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath, BOOLEAN *preferred) -{ - dev_info_t *devinfo; - EFI_BLOCK_IO *blkio; - EFI_DEVICE_PATH *devpath; - EFI_STATUS status; - UINTN i; - - /* Figure out if we're dealing with an actual partition. */ - status = OpenProtocolByHandle(h, &DevicePathGUID, (void **)&devpath); - if (status == EFI_UNSUPPORTED) - return (status); - - if (status != EFI_SUCCESS) { - DPRINTF("\nFailed to query DevicePath (%lu)\n", - EFI_ERROR_CODE(status)); - return (status); - } -#ifdef EFI_DEBUG - { - CHAR16 *text = efi_devpath_name(devpath); - DPRINTF("probing: %S\n", text); - efi_free_devpath_name(text); - } -#endif - status = OpenProtocolByHandle(h, &BlockIoProtocolGUID, (void **)&blkio); - if (status == EFI_UNSUPPORTED) - return (status); - - if (status != EFI_SUCCESS) { - DPRINTF("\nFailed to query BlockIoProtocol (%lu)\n", - EFI_ERROR_CODE(status)); - return (status); - } - - if (!blkio->Media->LogicalPartition) - return (EFI_UNSUPPORTED); - - *preferred = efi_devpath_match(imgpath, devpath); - - /* Run through each module, see if it can load this partition */ - devinfo = malloc(sizeof(*devinfo)); - if (devinfo == NULL) { - DPRINTF("\nFailed to allocate devinfo\n"); - return (EFI_UNSUPPORTED); - } - devinfo->dev = blkio; - devinfo->devpath = devpath; - devinfo->devhandle = h; - devinfo->preferred = *preferred; - devinfo->next = NULL; - - for (i = 0; i < NUM_BOOT_MODULES; i++) { - devinfo->devdata = NULL; - status = boot_modules[i]->probe(devinfo); - if (status == EFI_SUCCESS) - return (EFI_SUCCESS); - } - free(devinfo); - - return (EFI_UNSUPPORTED); -} - -/* - * probe_handle_status calls probe_handle and outputs the returned status - * of the call. - */ -static void -probe_handle_status(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) -{ - EFI_STATUS status; - BOOLEAN preferred; - - preferred = FALSE; - status = probe_handle(h, imgpath, &preferred); - - DPRINTF("probe: "); - switch (status) { - case EFI_UNSUPPORTED: - printf("."); - DPRINTF(" not supported\n"); - break; - case EFI_SUCCESS: - if (preferred) { - printf("%c", '*'); - DPRINTF(" supported (preferred)\n"); - } else { - printf("%c", '+'); - DPRINTF(" supported\n"); - } - break; - default: - printf("x"); - DPRINTF(" error (%lu)\n", EFI_ERROR_CODE(status)); - break; - } - DSTALL(500000); -} - EFI_STATUS efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) { @@ -346,9 +194,6 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) SIMPLE_TEXT_OUTPUT_INTERFACE *conout = NULL; UINTN i, hsize, nhandles; CHAR16 *text; - UINT16 boot_current; - size_t sz; - UINT16 boot_order[100]; /* Basic initialization*/ ST = Xsystab; @@ -376,13 +221,27 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) printf("\n>> FreeBSD EFI boot block\n"); printf(" Loader path: %s\n\n", PATH_LOADER_EFI); printf(" Initializing modules:"); - for (i = 0; i < NUM_BOOT_MODULES; i++) { + for (i = 0; i < num_boot_modules; i++) { printf(" %s", boot_modules[i]->name); if (boot_modules[i]->init != NULL) boot_modules[i]->init(); } putchar('\n'); + /* Fetch all the block I/O handles, we have to search through them later */ + hsize = 0; + BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, + &hsize, NULL); + handles = malloc(hsize); + if (handles == NULL) + efi_panic(EFI_OUT_OF_RESOURCES, "Failed to allocate %d handles\n", + hsize); + status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, + NULL, &hsize, handles); + if (status != EFI_SUCCESS) + efi_panic(status, "Failed to get device handles\n"); + nhandles = hsize / sizeof(*handles); + /* Determine the devpath of our image so we can prefer it. */ status = OpenProtocolByHandle(IH, &LoadedImageGUID, (void **)&img); imgpath = NULL; @@ -409,58 +268,7 @@ efi_main(EFI_HANDLE Ximage, EFI_SYSTEM_TABLE *Xsystab) } } - boot_current = 0; - sz = sizeof(boot_current); - if (efi_global_getenv("BootCurrent", &boot_current, &sz) == EFI_SUCCESS) { - printf(" BootCurrent: %04x\n", boot_current); - - sz = sizeof(boot_order); - if (efi_global_getenv("BootOrder", &boot_order, &sz) == EFI_SUCCESS) { - printf(" BootOrder:"); - for (i = 0; i < sz / sizeof(boot_order[0]); i++) - printf(" %04x%s", boot_order[i], - boot_order[i] == boot_current ? "[*]" : ""); - printf("\n"); - } - } - -#ifdef TEST_FAILURE - /* - * For testing failover scenarios, it's nice to be able to fail fast. - * Define TEST_FAILURE to create a boot1.efi that always fails after - * reporting the boot manager protocol details. - */ - BS->Exit(IH, EFI_OUT_OF_RESOURCES, 0, NULL); -#endif - - hsize = 0; - BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, NULL, - &hsize, NULL); - handles = malloc(hsize); - if (handles == NULL) - efi_panic(EFI_OUT_OF_RESOURCES, "Failed to allocate %d handles\n", - hsize); - status = BS->LocateHandle(ByProtocol, &BlockIoProtocolGUID, - NULL, &hsize, handles); - if (status != EFI_SUCCESS) - efi_panic(status, "Failed to get device handles\n"); - - /* Scan all partitions, probing with all modules. */ - nhandles = hsize / sizeof(*handles); - printf(" Probing %zu block devices...", nhandles); - DPRINTF("\n"); - - for (i = 0; i < nhandles; i++) - probe_handle_status(handles[i], imgpath); - printf(" done\n"); - - /* Status summary. */ - for (i = 0; i < NUM_BOOT_MODULES; i++) { - printf(" "); - boot_modules[i]->status(); - } - - try_boot(); + choice_protocol(handles, nhandles, imgpath); /* If we get here, we're out of luck... */ efi_panic(EFI_LOAD_ERROR, "No bootable partitions found!"); Modified: stable/12/stand/efi/boot1/boot_module.h ============================================================================== --- stable/12/stand/efi/boot1/boot_module.h Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/boot1/boot_module.h Thu Oct 24 03:16:23 2019 (r353988) @@ -96,6 +96,9 @@ typedef struct boot_module_t dev_info_t *(*devices)(void); } boot_module_t; +extern const boot_module_t *boot_modules[]; +extern const UINTN num_boot_modules; + /* Standard boot modules. */ #ifdef EFI_UFS_BOOT extern const boot_module_t ufs_module; @@ -106,5 +109,4 @@ extern const boot_module_t zfs_module; /* Functions available to modules. */ extern void add_device(dev_info_t **devinfop, dev_info_t *devinfo); -extern int vsnprintf(char *str, size_t sz, const char *fmt, va_list ap); #endif Copied: stable/12/stand/efi/boot1/proto.c (from r348812, head/stand/efi/boot1/proto.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/boot1/proto.c Thu Oct 24 03:16:23 2019 (r353988, copy of r348812, head/stand/efi/boot1/proto.c) @@ -0,0 +1,223 @@ +/*- + * Copyright (c) 1998 Robert Nordier + * All rights reserved. + * Copyright (c) 2001 Robert Drehmel + * All rights reserved. + * Copyright (c) 2014 Nathan Whitehorn + * All rights reserved. + * Copyright (c) 2015 Eric McCorkle + * All rights reserved. + * + * Redistribution and use in source and binary forms are freely + * permitted provided that the above copyright notice and this + * paragraph and the following disclaimer are duplicated in all + * such forms. + * + * This software is provided "AS IS" and without any express or + * implied warranties, including, without limitation, the implied + * warranties of merchantability and fitness for a particular + * purpose. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include + +#include "boot_module.h" +#include "paths.h" +#include "proto.h" + +static EFI_GUID BlockIoProtocolGUID = BLOCK_IO_PROTOCOL; +static EFI_GUID DevicePathGUID = DEVICE_PATH_PROTOCOL; + +static const char *prio_str[] = { + "error", + "not supported", + "good", + "better" +}; + +/* + * probe_handle determines if the passed handle represents a logical partition + * if it does it uses each module in order to probe it and if successful it + * returns EFI_SUCCESS. + */ +static int +probe_handle(EFI_HANDLE h, EFI_DEVICE_PATH *imgpath) +{ + dev_info_t *devinfo; + EFI_BLOCK_IO *blkio; + EFI_DEVICE_PATH *devpath; + EFI_STATUS status; + UINTN i; + int preferred; + + /* Figure out if we're dealing with an actual partition. */ + status = BS->HandleProtocol(h, &DevicePathGUID, (void **)&devpath); + if (status == EFI_UNSUPPORTED) + return (0); + + if (status != EFI_SUCCESS) { + DPRINTF("\nFailed to query DevicePath (%lu)\n", + EFI_ERROR_CODE(status)); + return (-1); + } +#ifdef EFI_DEBUG + { + CHAR16 *text = efi_devpath_name(devpath); + DPRINTF("probing: %S ", text); + efi_free_devpath_name(text); + } +#endif + status = BS->HandleProtocol(h, &BlockIoProtocolGUID, (void **)&blkio); + if (status == EFI_UNSUPPORTED) + return (0); + + if (status != EFI_SUCCESS) { + DPRINTF("\nFailed to query BlockIoProtocol (%lu)\n", + EFI_ERROR_CODE(status)); + return (-1); + } + + if (!blkio->Media->LogicalPartition) + return (0); + + preferred = efi_devpath_same_disk(imgpath, devpath); + + /* Run through each module, see if it can load this partition */ + devinfo = malloc(sizeof(*devinfo)); + if (devinfo == NULL) { + DPRINTF("\nFailed to allocate devinfo\n"); + return (-1); + } + devinfo->dev = blkio; + devinfo->devpath = devpath; + devinfo->devhandle = h; + devinfo->preferred = preferred; + devinfo->next = NULL; + + for (i = 0; i < num_boot_modules; i++) { + devinfo->devdata = NULL; + + status = boot_modules[i]->probe(devinfo); + if (status == EFI_SUCCESS) + return (preferred + 1); + } + free(devinfo); + + return (0); +} + +/* + * load_loader attempts to load the loader image data. + * + * It tries each module and its respective devices, identified by mod->probe, + * in order until a successful load occurs at which point it returns EFI_SUCCESS + * and EFI_NOT_FOUND otherwise. + * + * Only devices which have preferred matching the preferred parameter are tried. + */ +static EFI_STATUS +load_loader(const boot_module_t **modp, dev_info_t **devinfop, void **bufp, + size_t *bufsize, int preferred) +{ + UINTN i; + dev_info_t *dev; + const boot_module_t *mod; + + for (i = 0; i < num_boot_modules; i++) { + mod = boot_modules[i]; + for (dev = mod->devices(); dev != NULL; dev = dev->next) { + if (dev->preferred != preferred) + continue; + + if (mod->load(PATH_LOADER_EFI, dev, bufp, bufsize) == + EFI_SUCCESS) { + *devinfop = dev; + *modp = mod; + return (EFI_SUCCESS); + } + } + } + + return (EFI_NOT_FOUND); +} + +void +choice_protocol(EFI_HANDLE *handles, UINTN nhandles, EFI_DEVICE_PATH *imgpath) +{ + UINT16 boot_current; + size_t sz; + UINT16 boot_order[100]; + unsigned i; + int rv; + EFI_STATUS status; + const boot_module_t *mod; + dev_info_t *dev; + void *loaderbuf; + size_t loadersize; + + /* Report UEFI Boot Manager Protocol details */ + boot_current = 0; + sz = sizeof(boot_current); + if (efi_global_getenv("BootCurrent", &boot_current, &sz) == EFI_SUCCESS) { + printf(" BootCurrent: %04x\n", boot_current); + + sz = sizeof(boot_order); + if (efi_global_getenv("BootOrder", &boot_order, &sz) == EFI_SUCCESS) { + printf(" BootOrder:"); + for (i = 0; i < sz / sizeof(boot_order[0]); i++) + printf(" %04x%s", boot_order[i], + boot_order[i] == boot_current ? "[*]" : ""); + printf("\n"); + } + } + +#ifdef TEST_FAILURE + /* + * For testing failover scenarios, it's nice to be able to fail fast. + * Define TEST_FAILURE to create a boot1.efi that always fails after + * reporting the boot manager protocol details. + */ + BS->Exit(IH, EFI_OUT_OF_RESOURCES, 0, NULL); +#endif + + /* Scan all partitions, probing with all modules. */ + printf(" Probing %zu block devices...", nhandles); + DPRINTF("\n"); + for (i = 0; i < nhandles; i++) { + rv = probe_handle(handles[i], imgpath); +#ifdef EFI_DEBUG + printf("%c", "x.+*"[rv + 1]); +#else + printf("%s\n", prio_str[rv + 1]); +#endif + } + printf(" done\n"); + + + /* Status summary. */ + for (i = 0; i < num_boot_modules; i++) { + printf(" "); + boot_modules[i]->status(); + } + + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, 1); + if (status != EFI_SUCCESS) { + status = load_loader(&mod, &dev, &loaderbuf, &loadersize, 0); + if (status != EFI_SUCCESS) { + printf("Failed to load '%s'\n", PATH_LOADER_EFI); + return; + } + } + + try_boot(mod, dev, loaderbuf, loadersize); +} Copied: stable/12/stand/efi/boot1/proto.h (from r348812, head/stand/efi/boot1/proto.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/efi/boot1/proto.h Thu Oct 24 03:16:23 2019 (r353988, copy of r348812, head/stand/efi/boot1/proto.h) @@ -0,0 +1,29 @@ +/*- + * Copyright (c) 2019 Netflix, Inc + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +void choice_protocol(EFI_HANDLE *handles, UINTN nhandles, EFI_DEVICE_PATH *imgpath); +EFI_STATUS try_boot(const boot_module_t *mod, dev_info_t *dev, void *loaderbuf, size_t loadersize); Modified: stable/12/stand/efi/boot1/ufs_module.c ============================================================================== --- stable/12/stand/efi/boot1/ufs_module.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/boot1/ufs_module.c Thu Oct 24 03:16:23 2019 (r353988) @@ -140,7 +140,6 @@ static EFI_STATUS load(const char *filepath, dev_info_t *dev, void **bufp, size_t *bufsize) { ufs_ino_t ino; - EFI_STATUS status; size_t size; ssize_t read; void *buf; @@ -167,18 +166,18 @@ load(const char *filepath, dev_info_t *dev, void **buf return (EFI_INVALID_PARAMETER); } - if ((status = BS->AllocatePool(EfiLoaderData, size, &buf)) != - EFI_SUCCESS) { - printf("Failed to allocate read buffer %zu for '%s' (%lu)\n", - size, filepath, EFI_ERROR_CODE(status)); - return (status); + buf = malloc(size); + if (buf == NULL) { + printf("Failed to allocate read buffer %zu for '%s'\n", + size, filepath); + return (EFI_OUT_OF_RESOURCES); } read = fsread(ino, buf, size); if ((size_t)read != size) { printf("Failed to read '%s' (%zd != %zu)\n", filepath, read, size); - (void)BS->FreePool(buf); + free(buf); return (EFI_INVALID_PARAMETER); } Modified: stable/12/stand/efi/boot1/zfs_module.c ============================================================================== --- stable/12/stand/efi/boot1/zfs_module.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/boot1/zfs_module.c Thu Oct 24 03:16:23 2019 (r353988) @@ -115,19 +115,17 @@ probe(dev_info_t *dev) { spa_t *spa; dev_info_t *tdev; - EFI_STATUS status; /* ZFS consumes the dev on success so we need a copy. */ - if ((status = BS->AllocatePool(EfiLoaderData, sizeof(*dev), - (void**)&tdev)) != EFI_SUCCESS) { - DPRINTF("Failed to allocate tdev (%lu)\n", - EFI_ERROR_CODE(status)); - return (status); + tdev = malloc(sizeof(*dev)); + if (tdev == NULL) { + DPRINTF("Failed to allocate tdev\n"); + return (EFI_OUT_OF_RESOURCES); } memcpy(tdev, dev, sizeof(*dev)); if (vdev_probe(vdev_read, tdev, &spa) != 0) { - (void)BS->FreePool(tdev); + free(tdev); return (EFI_UNSUPPORTED); } @@ -141,12 +139,11 @@ static EFI_STATUS load(const char *filepath, dev_info_t *devinfo, void **bufp, size_t *bufsize) { spa_t *spa; - struct zfsmount zfsmount; + struct zfsmount zmount; dnode_phys_t dn; struct stat st; int err; void *buf; - EFI_STATUS status; spa = devinfo->devdata; @@ -163,12 +160,12 @@ load(const char *filepath, dev_info_t *devinfo, void * return (EFI_NOT_FOUND); } - if ((err = zfs_mount(spa, 0, &zfsmount)) != 0) { + if ((err = zfs_mount(spa, 0, &zmount)) != 0) { DPRINTF("Failed to mount pool '%s' (%d)\n", spa->spa_name, err); return (EFI_NOT_FOUND); } - if ((err = zfs_lookup(&zfsmount, filepath, &dn)) != 0) { + if ((err = zfs_lookup(&zmount, filepath, &dn)) != 0) { if (err == ENOENT) { DPRINTF("Failed to find '%s' on pool '%s' (%d)\n", filepath, spa->spa_name, err); @@ -185,17 +182,17 @@ load(const char *filepath, dev_info_t *devinfo, void * return (EFI_INVALID_PARAMETER); } - if ((status = BS->AllocatePool(EfiLoaderData, (UINTN)st.st_size, &buf)) - != EFI_SUCCESS) { - printf("Failed to allocate load buffer %jd for pool '%s' for '%s' " - "(%lu)\n", (intmax_t)st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status)); + buf = malloc(st.st_size); + if (buf == NULL) { + printf("Failed to allocate load buffer %jd for pool '%s' for '%s' ", + (intmax_t)st.st_size, spa->spa_name, filepath); return (EFI_INVALID_PARAMETER); } if ((err = dnode_read(spa, &dn, 0, buf, st.st_size)) != 0) { printf("Failed to read node from %s (%d)\n", spa->spa_name, err); - (void)BS->FreePool(buf); + free(buf); return (EFI_INVALID_PARAMETER); } Modified: stable/12/stand/efi/include/efilib.h ============================================================================== --- stable/12/stand/efi/include/efilib.h Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/include/efilib.h Thu Oct 24 03:16:23 2019 (r353988) @@ -91,6 +91,7 @@ bool efi_devpath_match_node(EFI_DEVICE_PATH *, EFI_DEV bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *); void efi_free_devpath_name(CHAR16 *); +bool efi_devpath_same_disk(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *); EFI_DEVICE_PATH *efi_devpath_to_media_path(EFI_DEVICE_PATH *); UINTN efi_devpath_length(EFI_DEVICE_PATH *); EFI_HANDLE efi_devpath_to_handle(EFI_DEVICE_PATH *path, EFI_HANDLE *handles, unsigned nhandles); Modified: stable/12/stand/efi/libefi/devpath.c ============================================================================== --- stable/12/stand/efi/libefi/devpath.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/efi/libefi/devpath.c Thu Oct 24 03:16:23 2019 (r353988) @@ -199,14 +199,19 @@ efi_devpath_match_node(EFI_DEVICE_PATH *devpath1, EFI_ return (true); } -bool -efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) +static bool +_efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2, + bool ignore_media) { if (devpath1 == NULL || devpath2 == NULL) return (false); while (true) { + if (ignore_media && + IsDevicePathType(devpath1, MEDIA_DEVICE_PATH) && + IsDevicePathType(devpath2, MEDIA_DEVICE_PATH)) + return (true); if (!efi_devpath_match_node(devpath1, devpath2)) return false; if (IsDevicePathEnd(devpath1)) @@ -215,6 +220,25 @@ efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVIC devpath2 = NextDevicePathNode(devpath2); } return (true); +} +/* + * Are two devpaths identical? + */ +bool +efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) +{ + return _efi_devpath_match(devpath1, devpath2, false); +} + +/* + * Like efi_devpath_match, but stops at when we hit the media device + * path node that specifies the partition information. If we match + * up to that point, then we're on the same disk. + */ +bool +efi_devpath_same_disk(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2) +{ + return _efi_devpath_match(devpath1, devpath2, true); } bool Modified: stable/12/stand/i386/gptboot/gptboot.c ============================================================================== --- stable/12/stand/i386/gptboot/gptboot.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/i386/gptboot/gptboot.c Thu Oct 24 03:16:23 2019 (r353988) @@ -232,7 +232,7 @@ static int gptinit(void) { - if (gptread(&freebsd_ufs_uuid, &gdsk.dsk, dmadat->secbuf) == -1) { + if (gptread(&gdsk.dsk, dmadat->secbuf) == -1) { printf("%s: unable to load GPT\n", BOOTPROG); return (-1); } Modified: stable/12/stand/libsa/gpt.c ============================================================================== --- stable/12/stand/libsa/gpt.c Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/libsa/gpt.c Thu Oct 24 03:16:23 2019 (r353988) @@ -275,8 +275,8 @@ gptbootconv(const char *which, struct dsk *dskp, struc } static int -gptread_table(const char *which, const uuid_t *uuid, struct dsk *dskp, - struct gpt_hdr *hdr, struct gpt_ent *table) +gptread_table(const char *which, struct dsk *dskp, struct gpt_hdr *hdr, + struct gpt_ent *table) { struct gpt_ent *ent; int entries_per_sec; @@ -313,7 +313,7 @@ gptread_table(const char *which, const uuid_t *uuid, s } int -gptread(const uuid_t *uuid, struct dsk *dskp, char *buf) +gptread(struct dsk *dskp, char *buf) { uint64_t altlba; @@ -328,8 +328,7 @@ gptread(const uuid_t *uuid, struct dsk *dskp, char *bu dskp->start = 0; if (gptread_hdr("primary", dskp, &hdr_primary, 1) == 0 && - gptread_table("primary", uuid, dskp, &hdr_primary, - table_primary) == 0) { + gptread_table("primary", dskp, &hdr_primary, table_primary) == 0) { hdr_primary_lba = hdr_primary.hdr_lba_self; gpthdr = &hdr_primary; gpttable = table_primary; @@ -349,8 +348,7 @@ gptread(const uuid_t *uuid, struct dsk *dskp, char *bu if (altlba == 0) printf("%s: unable to locate backup GPT header\n", BOOTPROG); else if (gptread_hdr("backup", dskp, &hdr_backup, altlba) == 0 && - gptread_table("backup", uuid, dskp, &hdr_backup, - table_backup) == 0) { + gptread_table("backup", dskp, &hdr_backup, table_backup) == 0) { hdr_backup_lba = hdr_backup.hdr_lba_self; if (hdr_primary_lba == 0) { gpthdr = &hdr_backup; Modified: stable/12/stand/libsa/gpt.h ============================================================================== --- stable/12/stand/libsa/gpt.h Thu Oct 24 03:09:31 2019 (r353987) +++ stable/12/stand/libsa/gpt.h Thu Oct 24 03:16:23 2019 (r353988) @@ -34,7 +34,7 @@ #define MAXTBLENTS 128 -int gptread(const uuid_t *uuid, struct dsk *dskp, char *buf); +int gptread(struct dsk *dskp, char *buf); int gptfind(const uuid_t *uuid, struct dsk *dskp, int part); void gptbootfailed(struct dsk *dskp); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:21:31 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9A53D153AE1; Thu, 24 Oct 2019 03:21:31 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCFl3YzXz4HnS; Thu, 24 Oct 2019 03:21:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5E7F67D4B; Thu, 24 Oct 2019 03:21:31 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3LVQv015736; Thu, 24 Oct 2019 03:21:31 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3LUTP015733; Thu, 24 Oct 2019 03:21:30 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240321.x9O3LUTP015733@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:21:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353991 - in stable/12: stand/common stand/efi/loader sys/kern sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12: stand/common stand/efi/loader sys/kern sys/sys X-SVN-Commit-Revision: 353991 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:21:31 -0000 Author: kevans Date: Thu Oct 24 03:21:30 2019 New Revision: 353991 URL: https://svnweb.freebsd.org/changeset/base/353991 Log: MFC r349343: Use a common kernel path between loader and kernel Modified: stable/12/stand/common/paths.h stable/12/stand/efi/loader/main.c stable/12/sys/kern/kern_mib.c stable/12/sys/sys/boot.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/paths.h ============================================================================== --- stable/12/stand/common/paths.h Thu Oct 24 03:20:27 2019 (r353990) +++ stable/12/stand/common/paths.h Thu Oct 24 03:21:30 2019 (r353991) @@ -29,11 +29,14 @@ #ifndef _PATHS_H_ #define _PATHS_H_ +#include /* To get kernel path */ + #define PATH_DOTCONFIG "/boot.config" #define PATH_CONFIG "/boot/config" #define PATH_LOADER "/boot/loader" #define PATH_LOADER_EFI "/boot/loader.efi" #define PATH_LOADER_ZFS "/boot/zfsloader" -#define PATH_KERNEL "/boot/kernel/kernel" +#define PATH_LOADER_CONF "/boot/loader.conf" +#define PATH_DEFAULTS_LOADER_CONF "/boot/defaults/loader.conf" #endif /* _PATHS_H_ */ Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 03:20:27 2019 (r353990) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 03:21:30 2019 (r353991) @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -237,8 +238,8 @@ sanity_check_currdev(void) { struct stat st; - return (stat("/boot/defaults/loader.conf", &st) == 0 || - stat("/boot/kernel/kernel", &st) == 0); + return (stat(PATH_DEFAULTS_LOADER_CONF, &st) == 0 || + stat(PATH_KERNEL, &st) == 0); } #ifdef EFI_ZFS_BOOT Modified: stable/12/sys/kern/kern_mib.c ============================================================================== --- stable/12/sys/kern/kern_mib.c Thu Oct 24 03:20:27 2019 (r353990) +++ stable/12/sys/kern/kern_mib.c Thu Oct 24 03:21:30 2019 (r353991) @@ -136,7 +136,7 @@ SYSCTL_INT(_kern, KERN_SAVED_IDS, saved_ids, CTLFLAG_R SYSCTL_NULL_INT_PTR, 0, "Whether saved set-group/user ID is available"); #endif -char kernelname[MAXPATHLEN] = "/boot/kernel/kernel"; /* XXX bloat */ +char kernelname[MAXPATHLEN] = PATH_KERNEL; /* XXX bloat */ SYSCTL_STRING(_kern, KERN_BOOTFILE, bootfile, CTLFLAG_RW | CTLFLAG_MPSAFE, kernelname, sizeof kernelname, "Name of kernel file booted"); Modified: stable/12/sys/sys/boot.h ============================================================================== --- stable/12/sys/sys/boot.h Thu Oct 24 03:20:27 2019 (r353990) +++ stable/12/sys/sys/boot.h Thu Oct 24 03:21:30 2019 (r353991) @@ -32,6 +32,8 @@ #ifndef _SYS_BOOT_H_ #define _SYS_BOOT_H_ +#define PATH_KERNEL "/boot/kernel/kernel" + int boot_env_to_howto(void); void boot_howto_to_env(int howto); int boot_parse_arg(char *v); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:26:46 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 02A6F154944; Thu, 24 Oct 2019 03:26:46 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCMn6G9lz4Jc0; Thu, 24 Oct 2019 03:26:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BAB017EBF; Thu, 24 Oct 2019 03:26:45 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3QjiI019052; Thu, 24 Oct 2019 03:26:45 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3QjrH019051; Thu, 24 Oct 2019 03:26:45 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240326.x9O3QjrH019051@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:26:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353993 - in stable/12/stand: i386/zfsloader sparc64/zfsloader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: i386/zfsloader sparc64/zfsloader X-SVN-Commit-Revision: 353993 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:26:46 -0000 Author: kevans Date: Thu Oct 24 03:26:45 2019 New Revision: 353993 URL: https://svnweb.freebsd.org/changeset/base/353993 Log: MFC r352037, r352145: Remove empty zfsloader directories Deleted: stable/12/stand/i386/zfsloader/ stable/12/stand/sparc64/zfsloader/ Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:27:53 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 886BE154B52; Thu, 24 Oct 2019 03:27:53 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCP52rwHz4Jjh; Thu, 24 Oct 2019 03:27:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 438D97EC2; Thu, 24 Oct 2019 03:27:53 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3RrKm019156; Thu, 24 Oct 2019 03:27:53 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3RqQk019155; Thu, 24 Oct 2019 03:27:52 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240327.x9O3RqQk019155@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:27:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353994 - in stable/12/stand: . i386/loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: . i386/loader X-SVN-Commit-Revision: 353994 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:27:53 -0000 Author: kevans Date: Thu Oct 24 03:27:52 2019 New Revision: 353994 URL: https://svnweb.freebsd.org/changeset/base/353994 Log: MFC r352032: loader: --gc-sections needs sections to work with --gc-sections is not really useful unless we generate sections with -ffunction-sections -fdata-sections While there, i386/loader would win from --gc-sections too. Modified: stable/12/stand/defs.mk stable/12/stand/i386/loader/Makefile Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/defs.mk ============================================================================== --- stable/12/stand/defs.mk Thu Oct 24 03:26:45 2019 (r353993) +++ stable/12/stand/defs.mk Thu Oct 24 03:27:52 2019 (r353994) @@ -65,6 +65,7 @@ CFLAGS+= -Ddouble=jagged-little-pill -Dfloat=floaty-mc # Experience has shown that problems arise between ~520k to ~530k. CFLAGS.clang+= -Oz CFLAGS.gcc+= -Os +CFLAGS+= -ffunction-sections -fdata-sections .endif # GELI Support, with backward compat hooks (mostly) Modified: stable/12/stand/i386/loader/Makefile ============================================================================== --- stable/12/stand/i386/loader/Makefile Thu Oct 24 03:26:45 2019 (r353993) +++ stable/12/stand/i386/loader/Makefile Thu Oct 24 03:27:52 2019 (r353994) @@ -47,7 +47,7 @@ HELP_FILES= ${.CURDIR}/help.i386 CLEANFILES+= ${LOADER} ${LOADER}.bin CFLAGS+= -Wall -LDFLAGS+= -static -Ttext 0x0 +LDFLAGS+= -static -Ttext 0x0 -Wl,--gc-sections # i386 standalone support library LIBI386= ${BOOTOBJ}/i386/libi386/libi386.a From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:30:49 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1B3CE155290; Thu, 24 Oct 2019 03:30:49 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCSS6lZBz4KKh; Thu, 24 Oct 2019 03:30:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B36197EE9; Thu, 24 Oct 2019 03:30:48 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3Um2b020951; Thu, 24 Oct 2019 03:30:48 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3UmWb020950; Thu, 24 Oct 2019 03:30:48 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240330.x9O3UmWb020950@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:30:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353996 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 353996 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:30:49 -0000 Author: kevans Date: Thu Oct 24 03:30:48 2019 New Revision: 353996 URL: https://svnweb.freebsd.org/changeset/base/353996 Log: MFC r352557, r353161: powerpc/loader stripping (and revert) Modified: Directory Properties: stable/12/ (props changed) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:32:48 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 03CEA15590C; Thu, 24 Oct 2019 03:32:48 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCVl6N3Nz4Klf; Thu, 24 Oct 2019 03:32:47 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE17180A3; Thu, 24 Oct 2019 03:32:47 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3WlBL025036; Thu, 24 Oct 2019 03:32:47 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3WlwF025035; Thu, 24 Oct 2019 03:32:47 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240332.x9O3WlwF025035@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:32:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353998 - stable/12/stand/efi/loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/loader X-SVN-Commit-Revision: 353998 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:32:48 -0000 Author: kevans Date: Thu Oct 24 03:32:47 2019 New Revision: 353998 URL: https://svnweb.freebsd.org/changeset/base/353998 Log: MFC r353697: Allow loader.efi to identify non-standard boot setup PATH_BOOTABLE_TOKEN can be set to a non-standard path that identifies a device as bootable. Modified: stable/12/stand/efi/loader/main.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 03:32:02 2019 (r353997) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 03:32:47 2019 (r353998) @@ -239,6 +239,9 @@ sanity_check_currdev(void) struct stat st; return (stat(PATH_DEFAULTS_LOADER_CONF, &st) == 0 || +#ifdef PATH_BOOTABLE_TOKEN + stat(PATH_BOOTABLE_TOKEN, &st) == 0 || /* non-standard layout */ +#endif stat(PATH_KERNEL, &st) == 0); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:32:03 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2BD10155778; Thu, 24 Oct 2019 03:32:03 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCTv0MGmz4Kbd; Thu, 24 Oct 2019 03:32:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E371D7F5C; Thu, 24 Oct 2019 03:32:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3W26e024949; Thu, 24 Oct 2019 03:32:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3W22N024948; Thu, 24 Oct 2019 03:32:02 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240332.x9O3W22N024948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:32:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r353997 - stable/12/stand/efi/boot1 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/efi/boot1 X-SVN-Commit-Revision: 353997 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:32:03 -0000 Author: kevans Date: Thu Oct 24 03:32:02 2019 New Revision: 353997 URL: https://svnweb.freebsd.org/changeset/base/353997 Log: MFC r353544: boot1.efi: provide generic exit() and stub getchar() Modified: stable/12/stand/efi/boot1/boot1.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/boot1/boot1.c ============================================================================== --- stable/12/stand/efi/boot1/boot1.c Thu Oct 24 03:30:48 2019 (r353996) +++ stable/12/stand/efi/boot1/boot1.c Thu Oct 24 03:32:02 2019 (r353997) @@ -293,6 +293,18 @@ add_device(dev_info_t **devinfop, dev_info_t *devinfo) dev->next = devinfo; } +void +efi_exit(EFI_STATUS s) +{ + BS->Exit(IH, s, 0, NULL); +} + +void +exit(int error __unused) +{ + efi_exit(EFI_LOAD_ERROR); +} + /* * OK. We totally give up. Exit back to EFI with a sensible status so * it can try the next option on the list. @@ -308,7 +320,12 @@ efi_panic(EFI_STATUS s, const char *fmt, ...) va_end(ap); printf("\n"); - BS->Exit(IH, s, 0, NULL); + efi_exit(s); +} + +int getchar(void) +{ + return (-1); } void From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:38:17 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A4DC71565AC; Thu, 24 Oct 2019 03:38:17 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCd53Y5Qz4LQm; Thu, 24 Oct 2019 03:38:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5DD5F80BF; Thu, 24 Oct 2019 03:38:17 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3cHtq025435; Thu, 24 Oct 2019 03:38:17 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3cG9F025432; Thu, 24 Oct 2019 03:38:16 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240338.x9O3cG9F025432@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:38:16 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354000 - stable/12/stand/libsa X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12/stand/libsa X-SVN-Commit-Revision: 354000 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:38:17 -0000 Author: kevans Date: Thu Oct 24 03:38:16 2019 New Revision: 354000 URL: https://svnweb.freebsd.org/changeset/base/354000 Log: MFC r339970: Remove unnecessary include from libstand. Modified: stable/12/stand/libsa/ip.c stable/12/stand/libsa/net.c stable/12/stand/libsa/udp.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/ip.c ============================================================================== --- stable/12/stand/libsa/ip.c Thu Oct 24 03:37:17 2019 (r353999) +++ stable/12/stand/libsa/ip.c Thu Oct 24 03:38:16 2019 (r354000) @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: stable/12/stand/libsa/net.c ============================================================================== --- stable/12/stand/libsa/net.c Thu Oct 24 03:37:17 2019 (r353999) +++ stable/12/stand/libsa/net.c Thu Oct 24 03:38:16 2019 (r354000) @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include Modified: stable/12/stand/libsa/udp.c ============================================================================== --- stable/12/stand/libsa/udp.c Thu Oct 24 03:37:17 2019 (r353999) +++ stable/12/stand/libsa/udp.c Thu Oct 24 03:38:16 2019 (r354000) @@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:52:35 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3151715894C; Thu, 24 Oct 2019 03:52:35 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zCxb1JFRz4Njr; Thu, 24 Oct 2019 03:52:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C6478462; Thu, 24 Oct 2019 03:52:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3qZPb037272; Thu, 24 Oct 2019 03:52:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3qWfB037260; Thu, 24 Oct 2019 03:52:32 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240352.x9O3qWfB037260@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:52:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354006 - in stable/12/stand: common efi/libefi efi/loader i386/libi386 libsa/zfs mips/beri/loader uboot/common uboot/lib usb/storage userboot/userboot X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: common efi/libefi efi/loader i386/libi386 libsa/zfs mips/beri/loader uboot/common uboot/lib usb/storage userboot/userboot X-SVN-Commit-Revision: 354006 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:52:35 -0000 Author: kevans Date: Thu Oct 24 03:52:32 2019 New Revision: 354006 URL: https://svnweb.freebsd.org/changeset/base/354006 Log: MFC r345477, r346675, r346984, r348748 r345477: Distinguish between "no partition" and "choose best partition" with a constant. The values of the d_slice and d_partition fields of a disk_devdesc have a few values with special meanings in the disk_open() routine. Through various evolutions of the loader code over time, a d_partition value of -1 has meant both "use the first ufs partition found in the bsd label" and "don't open a bsd partition at all, open the raw slice." This defines a new special value of -2 to mean open the raw slice, and it gives symbolic names to all the special values used in d_slice and d_partition, and adjusts all existing uses of those fields to use the new constants. The phab review for this timed out without being accepted, but I'm still citing it below because there is useful commentary there. r346675: Restore the ability to open a raw disk or partition in loader(8). The disk_open() function searches for "the best partition" when slice and partition information is not provided as part of the device name. As of r345477 the slice and partition fields of a disk_devdesc are initialized to D_SLICEWILD and D_PARTWILD; in the past they were initialized to -1, which was sometimes interpreted as meaning 'wildcard' and sometimes as 'open the raw partition' depending on the context. So as an unintended side effect of r345477 it became basically impossible to ever open a disk or partition without doing the 'best partition' search. One visible effect of that was the inability to open the raw disk to read the partition table correctly in zfs_probe_dev(), leading to failures to find the zfs pool unless it was on the first partition. Now instead of always initializing slice and partition to wildcards, the disk_parsedev() function initializes them based on the presence of a path/file name following the device. If there is any path or filename following the ':' that ends the device name, then slice and partition are initialized to D_SLICEWILD and D_PARTWILD. If there is nothing after the ':' then it is considered to be a request to open the raw device or partition itself (not a file stored within it), and the fields are initialized to D_SLICENONE and D_PARTNONE. With this change in place, all the tests in src/tools/boot are succesful again, including the recently-added cases of booting from a zfs pool on a partition other than slice 1 of the device. r346984: Use D_PARTISGPT rather than bare 255 These three cases dovetail with other places in the code where we use or set D_PARTISGPT when we mean that the partitioning scheme is GPT. Use this #define to make the code easier to undertand. r348748: loader: disk_open() should honor D_PARTNONE The D_PARTNONE is documented to make it possible to open raw MBR partition, but the current disk_open() does not really implement this statement. The current code is checking partition against -1 (D_PARTNONE) but does attempt to open partition table in case we do have FreeBSD MBR partition type. Instead, we should check -2 (D_PARTWILD). In case we do have MBR + BSD label, this code is only working because by default, the first BSD partiton is created starting with relative sector 0, and we can still access the BSD table from that MBR slice. PR: 236981 Modified: stable/12/stand/common/disk.c stable/12/stand/common/disk.h stable/12/stand/efi/libefi/efipart.c stable/12/stand/efi/loader/main.c stable/12/stand/i386/libi386/biosdisk.c stable/12/stand/libsa/zfs/zfs.c stable/12/stand/mips/beri/loader/beri_disk_cfi.c stable/12/stand/mips/beri/loader/beri_disk_sdcard.c stable/12/stand/uboot/common/main.c stable/12/stand/uboot/lib/disk.c stable/12/stand/usb/storage/umass_loader.c stable/12/stand/userboot/userboot/main.c stable/12/stand/userboot/userboot/userboot_disk.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/disk.c ============================================================================== --- stable/12/stand/common/disk.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/common/disk.c Thu Oct 24 03:52:32 2019 (r354006) @@ -142,15 +142,8 @@ ptable_print(void *arg, const char *pname, const struc dev.dd.d_dev = pa->dev->dd.d_dev; dev.dd.d_unit = pa->dev->dd.d_unit; dev.d_slice = part->index; - dev.d_partition = -1; + dev.d_partition = D_PARTNONE; if (disk_open(&dev, partsize, sectsize) == 0) { - /* - * disk_open() for partition -1 on a bsd slice assumes - * you want the first bsd partition. Reset things so - * that we're looking at the start of the raw slice. - */ - dev.d_partition = -1; - dev.d_offset = part->start; table = ptable_open(&dev, partsize, sectsize, ptblread); if (table != NULL) { snprintf(line, sizeof(line), " %s%s", @@ -262,16 +255,16 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize */ memcpy(&partdev, dev, sizeof(partdev)); partdev.d_offset = 0; - partdev.d_slice = -1; - partdev.d_partition = -1; + partdev.d_slice = D_SLICENONE; + partdev.d_partition = D_PARTNONE; dev->d_offset = 0; table = NULL; slice = dev->d_slice; partition = dev->d_partition; - DPRINTF("%s unit %d, slice %d, partition %d => %p", - disk_fmtdev(dev), dev->dd.d_unit, dev->d_slice, dev->d_partition, od); + DPRINTF("%s unit %d, slice %d, partition %d => %p", disk_fmtdev(dev), + dev->dd.d_unit, dev->d_slice, dev->d_partition, od); /* Determine disk layout. */ od->table = ptable_open(&partdev, mediasize / sectorsize, sectorsize, @@ -311,22 +304,30 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize od->entrysize = part.end - part.start + 1; slice = part.index; if (ptable_gettype(od->table) == PTABLE_GPT) { - partition = 255; + partition = D_PARTISGPT; goto out; /* Nothing more to do */ - } else if (partition == 255) { + } else if (partition == D_PARTISGPT) { /* * When we try to open GPT partition, but partition - * table isn't GPT, reset d_partition value to -1 - * and try to autodetect appropriate value. + * table isn't GPT, reset partition value to + * D_PARTWILD and try to autodetect appropriate value. */ - partition = -1; + partition = D_PARTWILD; } + /* - * If d_partition < 0 and we are looking at a BSD slice, + * If partition is D_PARTNONE, then disk_open() was called + * to open raw MBR slice. + */ + if (partition == D_PARTNONE) + goto out; + + /* + * If partition is D_PARTWILD and we are looking at a BSD slice, * then try to read BSD label, otherwise return the * whole MBR slice. */ - if (partition == -1 && + if (partition == D_PARTWILD && part.type != PART_FREEBSD) goto out; /* Try to read BSD label */ @@ -338,7 +339,7 @@ disk_open(struct disk_devdesc *dev, uint64_t mediasize goto out; } /* - * If slice contains BSD label and d_partition < 0, then + * If slice contains BSD label and partition < 0, then * assume the 'a' partition. Otherwise just return the * whole MBR slice, because it can contain ZFS. */ @@ -391,9 +392,9 @@ disk_fmtdev(struct disk_devdesc *dev) char *cp; cp = buf + sprintf(buf, "%s%d", dev->dd.d_dev->dv_name, dev->dd.d_unit); - if (dev->d_slice >= 0) { + if (dev->d_slice > D_SLICENONE) { #ifdef LOADER_GPT_SUPPORT - if (dev->d_partition == 255) { + if (dev->d_partition == D_PARTISGPT) { sprintf(cp, "p%d:", dev->d_slice); return (buf); } else @@ -402,7 +403,7 @@ disk_fmtdev(struct disk_devdesc *dev) cp += sprintf(cp, "s%d", dev->d_slice); #endif } - if (dev->d_partition >= 0) + if (dev->d_partition > D_PARTNONE) cp += sprintf(cp, "%c", dev->d_partition + 'a'); strcat(cp, ":"); return (buf); @@ -416,7 +417,21 @@ disk_parsedev(struct disk_devdesc *dev, const char *de char *cp; np = devspec; - unit = slice = partition = -1; + unit = -1; + /* + * If there is path/file info after the device info, then any missing + * slice or partition info should be considered a request to search for + * an appropriate partition. Otherwise we want to open the raw device + * itself and not try to fill in missing info by searching. + */ + if ((cp = strchr(np, ':')) != NULL && cp[1] != '\0') { + slice = D_SLICEWILD; + partition = D_PARTWILD; + } else { + slice = D_SLICENONE; + partition = D_PARTNONE; + } + if (*np != '\0' && *np != ':') { unit = strtol(np, &cp, 10); if (cp == np) @@ -430,7 +445,7 @@ disk_parsedev(struct disk_devdesc *dev, const char *de /* we don't support nested partitions on GPT */ if (*cp != '\0' && *cp != ':') return (EINVAL); - partition = 255; + partition = D_PARTISGPT; } else #endif #ifdef LOADER_MBR_SUPPORT Modified: stable/12/stand/common/disk.h ============================================================================== --- stable/12/stand/common/disk.h Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/common/disk.h Thu Oct 24 03:52:32 2019 (r354006) @@ -32,33 +32,36 @@ * * Whole disk access: * - * d_slice = -1 - * d_partition = -1 + * d_slice = D_SLICENONE + * d_partition = * * Whole MBR slice: * * d_slice = MBR slice number (typically 1..4) - * d_partition = -1 + * d_partition = D_PARTNONE * * BSD disklabel partition within an MBR slice: * * d_slice = MBR slice number (typically 1..4) - * d_partition = disklabel partition (typically 0..19) + * d_partition = disklabel partition (typically 0..19 or D_PARTWILD) * * BSD disklabel partition on the true dedicated disk: * - * d_slice = -1 - * d_partition = disklabel partition (typically 0..19) + * d_slice = D_SLICENONE + * d_partition = disklabel partition (typically 0..19 or D_PARTWILD) * * GPT partition: * * d_slice = GPT partition number (typically 1..N) - * d_partition = 255 + * d_partition = D_PARTISGPT * - * For both MBR and GPT, to automatically find the 'best' slice or partition, - * set d_slice to zero. This uses the partition type to decide which partition - * to use according to the following list of preferences: + * For MBR, setting d_partition to D_PARTWILD will automatically use the first + * partition within the slice. * + * For both MBR and GPT, to automatically find the 'best' slice and partition, + * set d_slice to D_SLICEWILD. This uses the partition type to decide which + * partition to use according to the following list of preferences: + * * FreeBSD (active) * FreeBSD (inactive) * Linux (active) @@ -80,6 +83,12 @@ #ifndef _DISK_H #define _DISK_H + +#define D_SLICENONE -1 +#define D_SLICEWILD 0 +#define D_PARTNONE -1 +#define D_PARTWILD -2 +#define D_PARTISGPT 255 struct disk_devdesc { struct devdesc dd; /* Must be first. */ Modified: stable/12/stand/efi/libefi/efipart.c ============================================================================== --- stable/12/stand/efi/libefi/efipart.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/efi/libefi/efipart.c Thu Oct 24 03:52:32 2019 (r354006) @@ -748,8 +748,8 @@ efipart_print_common(struct devsw *dev, pdinfo_list_t pd->pd_blkio = blkio; pd_dev.dd.d_dev = dev; pd_dev.dd.d_unit = pd->pd_unit; - pd_dev.d_slice = -1; - pd_dev.d_partition = -1; + pd_dev.d_slice = D_SLICENONE; + pd_dev.d_partition = D_PARTNONE; ret = disk_open(&pd_dev, blkio->Media->BlockSize * (blkio->Media->LastBlock + 1), blkio->Media->BlockSize); Modified: stable/12/stand/efi/loader/main.c ============================================================================== --- stable/12/stand/efi/loader/main.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/efi/loader/main.c Thu Oct 24 03:52:32 2019 (r354006) @@ -220,12 +220,12 @@ set_currdev_pdinfo(pdinfo_t *dp) currdev.dd.d_dev = dp->pd_devsw; if (dp->pd_parent == NULL) { currdev.dd.d_unit = dp->pd_unit; - currdev.d_slice = -1; - currdev.d_partition = -1; + currdev.d_slice = D_SLICENONE; + currdev.d_partition = D_PARTNONE; } else { currdev.dd.d_unit = dp->pd_parent->pd_unit; currdev.d_slice = dp->pd_unit; - currdev.d_partition = 255; /* Assumes GPT */ + currdev.d_partition = D_PARTISGPT; /* XXX Assumes GPT */ } set_currdev_devdesc((struct devdesc *)&currdev); } else { Modified: stable/12/stand/i386/libi386/biosdisk.c ============================================================================== --- stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/i386/libi386/biosdisk.c Thu Oct 24 03:52:32 2019 (r354006) @@ -691,8 +691,8 @@ bd_print_common(struct devsw *dev, bdinfo_list_t *bdi, devd.dd.d_dev = dev; devd.dd.d_unit = i; - devd.d_slice = -1; - devd.d_partition = -1; + devd.d_slice = D_SLICENONE; + devd.d_partition = D_PARTNONE; if (disk_open(&devd, bd->bd_sectorsize * bd->bd_sectors, bd->bd_sectorsize) == 0) { @@ -745,8 +745,8 @@ bd_disk_get_sectors(struct disk_devdesc *dev) disk.dd.d_dev = dev->dd.d_dev; disk.dd.d_unit = dev->dd.d_unit; - disk.d_slice = -1; - disk.d_partition = -1; + disk.d_slice = D_SLICENONE; + disk.d_partition = D_PARTNONE; disk.d_offset = 0; size = bd->bd_sectors * bd->bd_sectorsize; Modified: stable/12/stand/libsa/zfs/zfs.c ============================================================================== --- stable/12/stand/libsa/zfs/zfs.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/libsa/zfs/zfs.c Thu Oct 24 03:52:32 2019 (r354006) @@ -590,7 +590,7 @@ zfs_probe_dev(const char *devname, uint64_t *pool_guid int slice = dev->d_slice; free(dev); - if (partition != -1 && slice != -1) { + if (partition != D_PARTNONE && slice != D_SLICENONE) { ret = zfs_probe(pa.fd, pool_guid); if (ret == 0) return (0); Modified: stable/12/stand/mips/beri/loader/beri_disk_cfi.c ============================================================================== --- stable/12/stand/mips/beri/loader/beri_disk_cfi.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/mips/beri/loader/beri_disk_cfi.c Thu Oct 24 03:52:32 2019 (r354006) @@ -129,8 +129,8 @@ beri_cfi_disk_print(int verbose) return (ret); dev.dd.d_dev = &beri_cfi_disk; dev.dd.d_unit = 0; - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; if (disk_open(&dev, cfi_get_mediasize(), cfi_get_sectorsize()) == 0) { snprintf(line, sizeof(line), " cfi%d", 0); ret = disk_print(&dev, line, verbose); Modified: stable/12/stand/mips/beri/loader/beri_disk_sdcard.c ============================================================================== --- stable/12/stand/mips/beri/loader/beri_disk_sdcard.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/mips/beri/loader/beri_disk_sdcard.c Thu Oct 24 03:52:32 2019 (r354006) @@ -135,8 +135,8 @@ beri_sdcard_disk_print(int verbose) return (ret); dev.dd.d_dev = &beri_sdcard_disk; dev.dd.d_unit = 0; - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; if (disk_open(&dev, altera_sdcard_get_mediasize(), altera_sdcard_get_sectorsize()) == 0) { snprintf(line, sizeof(line), " sdcard%d", 0); Modified: stable/12/stand/uboot/common/main.c ============================================================================== --- stable/12/stand/uboot/common/main.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/uboot/common/main.c Thu Oct 24 03:52:32 2019 (r354006) @@ -213,8 +213,8 @@ get_load_device(int *type, int *unit, int *slice, int *type = DEV_TYP_NONE; *unit = -1; - *slice = 0; - *partition = -1; + *slice = D_SLICEWILD; + *partition = D_PARTWILD; devstr = ub_env_get("loaderdev"); if (devstr == NULL) { @@ -295,7 +295,7 @@ get_load_device(int *type, int *unit, int *slice, int if (p == endp) { *type = DEV_TYP_NONE; *unit = -1; - *slice = 0; + *slice = D_SLICEWILD; return; } @@ -309,7 +309,7 @@ get_load_device(int *type, int *unit, int *slice, int if (*p != '.') { *type = DEV_TYP_NONE; *unit = -1; - *slice = 0; + *slice = D_SLICEWILD; return; } @@ -329,8 +329,8 @@ get_load_device(int *type, int *unit, int *slice, int /* Junk beyond partition number. */ *type = DEV_TYP_NONE; *unit = -1; - *slice = 0; - *partition = -1; + *slice = D_SLICEWILD; + *partition = D_PARTWILD; } static void @@ -339,15 +339,20 @@ print_disk_probe_info() char slice[32]; char partition[32]; - if (currdev.d_disk.d_slice > 0) - sprintf(slice, "%d", currdev.d_disk.d_slice); + if (currdev.d_disk.d_slice == D_SLICENONE) + strlcpy(slice, "", sizeof(slice)); + else if (currdev.d_disk.d_slice == D_SLICEWILD) + strlcpy(slice, "", sizeof(slice)); else - strcpy(slice, ""); + snprintf(slice, sizeof(slice), "%d", currdev.d_disk.d_slice); - if (currdev.d_disk.d_partition >= 0) - sprintf(partition, "%d", currdev.d_disk.d_partition); + if (currdev.d_disk.d_partition == D_PARTNONE) + strlcpy(partition, "", sizeof(partition)); + else if (currdev.d_disk.d_partition == D_PARTWILD) + strlcpy(partition, "", sizeof(partition)); else - strcpy(partition, ""); + snprintf(partition, sizeof(partition), "%d", + currdev.d_disk.d_partition); printf(" Checking unit=%d slice=%s partition=%s...", currdev.dd.d_unit, slice, partition); Modified: stable/12/stand/uboot/lib/disk.c ============================================================================== --- stable/12/stand/uboot/lib/disk.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/uboot/lib/disk.c Thu Oct 24 03:52:32 2019 (r354006) @@ -254,8 +254,8 @@ stor_print(int verbose) for (i = 0; i < stor_info_no; i++) { dev.dd.d_dev = &uboot_storage; dev.dd.d_unit = i; - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; snprintf(line, sizeof(line), "\tdisk%d (%s)\n", i, ub_stor_type(SI(&dev).type)); if ((ret = pager_output(line)) != 0) Modified: stable/12/stand/usb/storage/umass_loader.c ============================================================================== --- stable/12/stand/usb/storage/umass_loader.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/usb/storage/umass_loader.c Thu Oct 24 03:52:32 2019 (r354006) @@ -196,8 +196,8 @@ umass_disk_print(int verbose) return (ret); dev.d_dev = &umass_disk; dev.d_unit = 0; - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; if (umass_disk_open_sub(&dev) == 0) { ret = disk_print(&dev, " umass0", verbose); Modified: stable/12/stand/userboot/userboot/main.c ============================================================================== --- stable/12/stand/userboot/userboot/main.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/userboot/userboot/main.c Thu Oct 24 03:52:32 2019 (r354006) @@ -240,15 +240,15 @@ extract_currdev(void) if (userboot_disk_maxunit > 0) { dev.dd.d_dev = &userboot_disk; dev.dd.d_unit = 0; - dev.d_slice = 0; - dev.d_partition = 0; + dev.d_slice = D_SLICEWILD; + dev.d_partition = D_PARTWILD; /* * If we cannot auto-detect the partition type then * access the disk as a raw device. */ if (dev.dd.d_dev->dv_open(NULL, &dev)) { - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; } dd = &dev.dd; } else { Modified: stable/12/stand/userboot/userboot/userboot_disk.c ============================================================================== --- stable/12/stand/userboot/userboot/userboot_disk.c Thu Oct 24 03:51:33 2019 (r354005) +++ stable/12/stand/userboot/userboot/userboot_disk.c Thu Oct 24 03:52:32 2019 (r354006) @@ -137,8 +137,8 @@ userdisk_print(int verbose) break; dev.dd.d_dev = &userboot_disk; dev.dd.d_unit = i; - dev.d_slice = -1; - dev.d_partition = -1; + dev.d_slice = D_SLICENONE; + dev.d_partition = D_PARTNONE; if (disk_open(&dev, ud_info[i].mediasize, ud_info[i].sectorsize) == 0) { snprintf(line, sizeof(line), " disk%d", i); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 03:57:58 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 072381594B8; Thu, 24 Oct 2019 03:57:58 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zD3n70nhz4PJ7; Thu, 24 Oct 2019 03:57:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D474C8477; Thu, 24 Oct 2019 03:57:57 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O3vvCi037614; Thu, 24 Oct 2019 03:57:57 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O3vuIv037608; Thu, 24 Oct 2019 03:57:56 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910240357.x9O3vuIv037608@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 03:57:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354007 - in stable/12/stand: . common efi/loader i386/loader X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/stand: . common efi/loader i386/loader X-SVN-Commit-Revision: 354007 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 03:57:58 -0000 Author: kevans Date: Thu Oct 24 03:57:56 2019 New Revision: 354007 URL: https://svnweb.freebsd.org/changeset/base/354007 Log: MFC r346759: loader: implement map-vdisk and unmap-vdisk commands illumos update: https://www.illumos.org/issues/10598 Add map-vdisk and unmap-vdisk commands to create virtual disk interface on top of file. This will allow to use disk image from file system to load and start the kernel. By mapping file, we create vdiskX device, the device will be listed by lsdev [-v] and can be accessed directly as ls vdisk0p1:/path or can be used as value for currdev variable. vdisk strategy function does not use bcache as we have bcache used with backing file. vdisk can be unmapped when all consumers have closed the open files. In first iteration we do not support the zfs images because zfs pools do keep the device open (there is no "zpool export" mechanism). Adding zfs support is relatively simple, we just need to run zfs disk probe after mapping is done. Added: stable/12/stand/common/vdisk.c - copied unchanged from r346759, head/stand/common/vdisk.c Modified: stable/12/stand/common/help.common stable/12/stand/efi/loader/conf.c stable/12/stand/i386/loader/conf.c stable/12/stand/loader.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/common/help.common ============================================================================== --- stable/12/stand/common/help.common Thu Oct 24 03:52:32 2019 (r354006) +++ stable/12/stand/common/help.common Thu Oct 24 03:57:56 2019 (r354007) @@ -99,6 +99,13 @@ List loaded modules. If [-v] is specified, print more details. ################################################################################ +# Tmap-vdisk DMap virtual disk + + map-vdisk filename + + Map file as virtual disk. + +################################################################################ # Tmore DPage files more [ ...] @@ -395,6 +402,13 @@ unload This command removes any kernel and all loaded modules from memory. + +################################################################################ +# Tunmap-vdisk DUnmap virtual disk + + unmap-vdisk diskname + + Delete virtual disk mapping. ################################################################################ # Tunset DUnset a variable Copied: stable/12/stand/common/vdisk.c (from r346759, head/stand/common/vdisk.c) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/stand/common/vdisk.c Thu Oct 24 03:57:56 2019 (r354007, copy of r346759, head/stand/common/vdisk.c) @@ -0,0 +1,417 @@ +/*- + * Copyright 2019 Toomas Soome + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int vdisk_init(void); +static int vdisk_strategy(void *, int, daddr_t, size_t, char *, size_t *); +static int vdisk_open(struct open_file *, ...); +static int vdisk_close(struct open_file *); +static int vdisk_ioctl(struct open_file *, u_long, void *); +static int vdisk_print(int); + +struct devsw vdisk_dev = { + .dv_name = "vdisk", + .dv_type = DEVT_DISK, + .dv_init = vdisk_init, + .dv_strategy = vdisk_strategy, + .dv_open = vdisk_open, + .dv_close = vdisk_close, + .dv_ioctl = vdisk_ioctl, + .dv_print = vdisk_print, + .dv_cleanup = NULL +}; + +typedef STAILQ_HEAD(vdisk_info_list, vdisk_info) vdisk_info_list_t; + +typedef struct vdisk_info +{ + STAILQ_ENTRY(vdisk_info) vdisk_link; /* link in device list */ + char *vdisk_path; + int vdisk_unit; + int vdisk_fd; + uint64_t vdisk_size; /* size in bytes */ + uint32_t vdisk_sectorsz; + uint32_t vdisk_open; /* reference counter */ +} vdisk_info_t; + +static vdisk_info_list_t vdisk_list; /* list of mapped vdisks. */ + +static vdisk_info_t * +vdisk_get_info(struct devdesc *dev) +{ + vdisk_info_t *vd; + + STAILQ_FOREACH(vd, &vdisk_list, vdisk_link) { + if (vd->vdisk_unit == dev->d_unit) + return (vd); + } + return (vd); +} + +COMMAND_SET(map_vdisk, "map-vdisk", "map file as virtual disk", command_mapvd); + +static int +command_mapvd(int argc, char *argv[]) +{ + vdisk_info_t *vd, *p; + struct stat sb; + + if (argc != 2) { + printf("usage: %s filename\n", argv[0]); + return (CMD_ERROR); + } + + STAILQ_FOREACH(vd, &vdisk_list, vdisk_link) { + if (strcmp(vd->vdisk_path, argv[1]) == 0) { + printf("%s: file %s is already mapped as %s%d\n", + argv[0], argv[1], vdisk_dev.dv_name, + vd->vdisk_unit); + return (CMD_ERROR); + } + } + + if (stat(argv[1], &sb) < 0) { + /* + * ENOSYS is really ENOENT because we did try to walk + * through devsw list to try to open this file. + */ + if (errno == ENOSYS) + errno = ENOENT; + + printf("%s: stat failed: %s\n", argv[0], strerror(errno)); + return (CMD_ERROR); + } + + /* + * Avoid mapping small files. + */ + if (sb.st_size < 1024 * 1024) { + printf("%s: file %s is too small.\n", argv[0], argv[1]); + return (CMD_ERROR); + } + + vd = calloc(1, sizeof (*vd)); + if (vd == NULL) { + printf("%s: out of memory\n", argv[0]); + return (CMD_ERROR); + } + vd->vdisk_path = strdup(argv[1]); + if (vd->vdisk_path == NULL) { + free (vd); + printf("%s: out of memory\n", argv[0]); + return (CMD_ERROR); + } + vd->vdisk_fd = open(vd->vdisk_path, O_RDONLY); + if (vd->vdisk_fd < 0) { + printf("%s: open failed: %s\n", argv[0], strerror(errno)); + free(vd->vdisk_path); + free(vd); + return (CMD_ERROR); + } + + vd->vdisk_size = sb.st_size; + vd->vdisk_sectorsz = DEV_BSIZE; + STAILQ_FOREACH(p, &vdisk_list, vdisk_link) { + vdisk_info_t *n; + if (p->vdisk_unit == vd->vdisk_unit) { + vd->vdisk_unit++; + continue; + } + n = STAILQ_NEXT(p, vdisk_link); + if (p->vdisk_unit < vd->vdisk_unit) { + if (n == NULL) { + /* p is last elem */ + STAILQ_INSERT_TAIL(&vdisk_list, vd, vdisk_link); + break; + } + if (n->vdisk_unit > vd->vdisk_unit) { + /* p < vd < n */ + STAILQ_INSERT_AFTER(&vdisk_list, p, vd, + vdisk_link); + break; + } + /* else n < vd or n == vd */ + vd->vdisk_unit++; + continue; + } + /* p > vd only if p is the first element */ + STAILQ_INSERT_HEAD(&vdisk_list, vd, vdisk_link); + break; + } + + /* if the list was empty or contiguous */ + if (p == NULL) + STAILQ_INSERT_TAIL(&vdisk_list, vd, vdisk_link); + + printf("%s: file %s is mapped as %s%d\n", argv[0], vd->vdisk_path, + vdisk_dev.dv_name, vd->vdisk_unit); + return (CMD_OK); +} + +COMMAND_SET(unmap_vdisk, "unmap-vdisk", "unmap virtual disk", command_unmapvd); + +/* + * unmap-vdisk vdiskX + */ +static int +command_unmapvd(int argc, char *argv[]) +{ + size_t len; + vdisk_info_t *vd; + long unit; + char *end; + + if (argc != 2) { + printf("usage: %s %sN\n", argv[0], vdisk_dev.dv_name); + return (CMD_ERROR); + } + + len = strlen(vdisk_dev.dv_name); + if (strncmp(vdisk_dev.dv_name, argv[1], len) != 0) { + printf("%s: unknown device %s\n", argv[0], argv[1]); + return (CMD_ERROR); + } + errno = 0; + unit = strtol(argv[1] + len, &end, 10); + if (errno != 0 || (*end != '\0' && strcmp(end, ":") != 0)) { + printf("%s: unknown device %s\n", argv[0], argv[1]); + return (CMD_ERROR); + } + + STAILQ_FOREACH(vd, &vdisk_list, vdisk_link) { + if (vd->vdisk_unit == unit) + break; + } + + if (vd == NULL) { + printf("%s: unknown device %s\n", argv[0], argv[1]); + return (CMD_ERROR); + } + + if (vd->vdisk_open != 0) { + printf("%s: %s is in use, unable to unmap.\n", + argv[0], argv[1]); + return (CMD_ERROR); + } + + STAILQ_REMOVE(&vdisk_list, vd, vdisk_info, vdisk_link); + close(vd->vdisk_fd); + free(vd->vdisk_path); + free(vd); + printf("%s (%s) unmapped\n", argv[1], vd->vdisk_path); + + return (CMD_OK); +} + +static int +vdisk_init(void) +{ + STAILQ_INIT(&vdisk_list); + return (0); +} + +static int +vdisk_strategy(void *devdata, int rw, daddr_t blk, size_t size, + char *buf, size_t *rsize) +{ + struct disk_devdesc *dev; + vdisk_info_t *vd; + ssize_t rv; + + dev = devdata; + if (dev == NULL) + return (EINVAL); + vd = vdisk_get_info((struct devdesc *)dev); + if (vd == NULL) + return (EINVAL); + + if (size == 0 || (size % 512) != 0) + return (EIO); + + if (dev->dd.d_dev->dv_type == DEVT_DISK) { + daddr_t offset; + + offset = dev->d_offset * vd->vdisk_sectorsz; + offset /= 512; + blk += offset; + } + if (lseek(vd->vdisk_fd, blk << 9, SEEK_SET) == -1) + return (EIO); + + errno = 0; + switch (rw & F_MASK) { + case F_READ: + rv = read(vd->vdisk_fd, buf, size); + break; + case F_WRITE: + rv = write(vd->vdisk_fd, buf, size); + break; + default: + return (ENOSYS); + } + + if (errno == 0 && rsize != NULL) { + *rsize = rv; + } + return (errno); +} + +static int +vdisk_open(struct open_file *f, ...) +{ + va_list args; + struct disk_devdesc *dev; + vdisk_info_t *vd; + int rc = 0; + + va_start(args, f); + dev = va_arg(args, struct disk_devdesc *); + va_end(args); + if (dev == NULL) + return (EINVAL); + vd = vdisk_get_info((struct devdesc *)dev); + if (vd == NULL) + return (EINVAL); + + if (dev->dd.d_dev->dv_type == DEVT_DISK) { + rc = disk_open(dev, vd->vdisk_size, vd->vdisk_sectorsz); + } + if (rc == 0) + vd->vdisk_open++; + return (rc); +} + +static int +vdisk_close(struct open_file *f) +{ + struct disk_devdesc *dev; + vdisk_info_t *vd; + + dev = (struct disk_devdesc *)(f->f_devdata); + if (dev == NULL) + return (EINVAL); + vd = vdisk_get_info((struct devdesc *)dev); + if (vd == NULL) + return (EINVAL); + + vd->vdisk_open--; + if (dev->dd.d_dev->dv_type == DEVT_DISK) + return (disk_close(dev)); + return (0); +} + +static int +vdisk_ioctl(struct open_file *f, u_long cmd, void *data) +{ + struct disk_devdesc *dev; + vdisk_info_t *vd; + int rc; + + dev = (struct disk_devdesc *)(f->f_devdata); + if (dev == NULL) + return (EINVAL); + vd = vdisk_get_info((struct devdesc *)dev); + if (vd == NULL) + return (EINVAL); + + if (dev->dd.d_dev->dv_type == DEVT_DISK) { + rc = disk_ioctl(dev, cmd, data); + if (rc != ENOTTY) + return (rc); + } + + switch (cmd) { + case DIOCGSECTORSIZE: + *(u_int *)data = vd->vdisk_sectorsz; + break; + case DIOCGMEDIASIZE: + *(uint64_t *)data = vd->vdisk_size; + break; + default: + return (ENOTTY); + } + return (0); +} + +static int +vdisk_print(int verbose) +{ + int ret = 0; + vdisk_info_t *vd; + char line[80]; + + if (STAILQ_EMPTY(&vdisk_list)) + return (ret); + + printf("%s devices:", vdisk_dev.dv_name); + if ((ret = pager_output("\n")) != 0) + return (ret); + + STAILQ_FOREACH(vd, &vdisk_list, vdisk_link) { + struct disk_devdesc vd_dev; + + if (verbose) { + printf(" %s", vd->vdisk_path); + if ((ret = pager_output("\n")) != 0) + break; + } + snprintf(line, sizeof(line), + " %s%d", vdisk_dev.dv_name, vd->vdisk_unit); + printf("%s: %" PRIu64 " X %u blocks", line, + vd->vdisk_size / vd->vdisk_sectorsz, + vd->vdisk_sectorsz); + if ((ret = pager_output("\n")) != 0) + break; + + vd_dev.dd.d_dev = &vdisk_dev; + vd_dev.dd.d_unit = vd->vdisk_unit; + vd_dev.d_slice = -1; + vd_dev.d_partition = -1; + + ret = disk_open(&vd_dev, vd->vdisk_size, vd->vdisk_sectorsz); + if (ret == 0) { + ret = disk_print(&vd_dev, line, verbose); + disk_close(&vd_dev); + if (ret != 0) + break; + } else { + ret = 0; + } + } + + return (ret); +} Modified: stable/12/stand/efi/loader/conf.c ============================================================================== --- stable/12/stand/efi/loader/conf.c Thu Oct 24 03:52:32 2019 (r354006) +++ stable/12/stand/efi/loader/conf.c Thu Oct 24 03:57:56 2019 (r354007) @@ -33,11 +33,14 @@ __FBSDID("$FreeBSD$"); #include #include +extern struct devsw vdisk_dev; + struct devsw *devsw[] = { &efipart_fddev, &efipart_cddev, &efipart_hddev, &efinet_dev, + &vdisk_dev, #ifdef EFI_ZFS_BOOT &zfs_dev, #endif Modified: stable/12/stand/i386/loader/conf.c ============================================================================== --- stable/12/stand/i386/loader/conf.c Thu Oct 24 03:52:32 2019 (r354006) +++ stable/12/stand/i386/loader/conf.c Thu Oct 24 03:57:56 2019 (r354007) @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #if defined(LOADER_FIREWIRE_SUPPORT) extern struct devsw fwohci; #endif +extern struct devsw vdisk_dev; /* Exported for libstand */ struct devsw *devsw[] = { @@ -60,6 +61,7 @@ struct devsw *devsw[] = { #if defined(LOADER_FIREWIRE_SUPPORT) &fwohci, #endif + &vdisk_dev, #if defined(LOADER_ZFS_SUPPORT) &zfs_dev, #endif Modified: stable/12/stand/loader.mk ============================================================================== --- stable/12/stand/loader.mk Thu Oct 24 03:52:32 2019 (r354006) +++ stable/12/stand/loader.mk Thu Oct 24 03:57:56 2019 (r354007) @@ -31,7 +31,7 @@ SRCS+= metadata.c .endif .if ${LOADER_DISK_SUPPORT:Uyes} == "yes" -SRCS+= disk.c part.c +SRCS+= disk.c part.c vdisk.c .endif .if ${LOADER_NET_SUPPORT:Uno} == "yes" From owner-svn-src-stable-12@freebsd.org Thu Oct 24 06:58:18 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 54ABF160AC9; Thu, 24 Oct 2019 06:58:18 +0000 (UTC) (envelope-from kib@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zJ3t1XX8z4bK5; Thu, 24 Oct 2019 06:58:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 148DBA47A; Thu, 24 Oct 2019 06:58:18 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9O6wHhO043435; Thu, 24 Oct 2019 06:58:17 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9O6wHxY043434; Thu, 24 Oct 2019 06:58:17 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201910240658.x9O6wHxY043434@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Thu, 24 Oct 2019 06:58:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354014 - stable/12/sys/vm X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/vm X-SVN-Commit-Revision: 354014 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 06:58:18 -0000 Author: kib Date: Thu Oct 24 06:58:17 2019 New Revision: 354014 URL: https://svnweb.freebsd.org/changeset/base/354014 Log: MFC r353681: swapon_check_swzone(): use already calculated static variables. Modified: stable/12/sys/vm/swap_pager.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/vm/swap_pager.c ============================================================================== --- stable/12/sys/vm/swap_pager.c Thu Oct 24 05:54:30 2019 (r354013) +++ stable/12/sys/vm/swap_pager.c Thu Oct 24 06:58:17 2019 (r354014) @@ -589,6 +589,7 @@ swap_pager_swap_init(void) if (n < n2) printf("Swap blk zone entries changed from %lu to %lu.\n", n2, n); + /* absolute maximum we can handle assuming 100% efficiency */ swap_maxpages = n * SWAP_META_PAGES; swzone = n * sizeof(struct swblk); if (!uma_zone_reserve_kva(swpctrie_zone, n)) @@ -2267,17 +2268,12 @@ done: static void swapon_check_swzone(void) { - unsigned long maxpages, npages; - npages = swap_total; - /* absolute maximum we can handle assuming 100% efficiency */ - maxpages = uma_zone_get_max(swblk_zone) * SWAP_META_PAGES; - /* recommend using no more than half that amount */ - if (npages > maxpages / 2) { + if (swap_total > swap_maxpages / 2) { printf("warning: total configured swap (%lu pages) " "exceeds maximum recommended amount (%lu pages).\n", - npages, maxpages / 2); + swap_total, swap_maxpages / 2); printf("warning: increase kern.maxswzone " "or reduce amount of swap.\n"); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 14:18:07 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 03F5916E1B1; Thu, 24 Oct 2019 14:18:07 +0000 (UTC) (envelope-from marius@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zTqL6HlHz3K8Q; Thu, 24 Oct 2019 14:18:06 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BC7F0F64B; Thu, 24 Oct 2019 14:18:06 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OEI6o6002312; Thu, 24 Oct 2019 14:18:06 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OEI62d002311; Thu, 24 Oct 2019 14:18:06 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201910241418.x9OEI62d002311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 24 Oct 2019 14:18:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354021 - stable/12/sys/dev/e1000 X-SVN-Group: stable-12 X-SVN-Commit-Author: marius X-SVN-Commit-Paths: stable/12/sys/dev/e1000 X-SVN-Commit-Revision: 354021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 14:18:07 -0000 Author: marius Date: Thu Oct 24 14:18:06 2019 New Revision: 354021 URL: https://svnweb.freebsd.org/changeset/base/354021 Log: MFC: r353778 - In em_intr(), just call em_handle_link() instead of duplicating it. - In em_msix_link(), properly handle IGB-class devices after the iflib(4) conversion again by only setting EM_MSIX_LINK for the EM-class 82574 and by re-arming link interrupts unconditionally, i. e. not only in case of spurious interrupts. This fixes the interface link state change detection for the IGB-class. [1] - In em_if_update_admin_status(), only re-arm the link state change interrupt for 82574 and also only if such a device uses MSI-X, i. e. takes advantage of autoclearing. In case of INTx and MSI as well as for LEM- and IGB-class devices, re-arming isn't appropriate here and setting EM_MSIX_LINK isn't either. While at it, consistently take advantage of the hw variable. PR: 236724 [1] Differential Revision: https://reviews.freebsd.org/D21924 Modified: stable/12/sys/dev/e1000/if_em.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/e1000/if_em.c ============================================================================== --- stable/12/sys/dev/e1000/if_em.c Thu Oct 24 12:16:15 2019 (r354020) +++ stable/12/sys/dev/e1000/if_em.c Thu Oct 24 14:18:06 2019 (r354021) @@ -1395,10 +1395,8 @@ em_intr(void *arg) IFDI_INTR_DISABLE(ctx); /* Link status change */ - if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { - adapter->hw.mac.get_link_status = 1; - iflib_admin_intr_deferred(ctx); - } + if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) + em_handle_link(ctx); if (reg_icr & E1000_ICR_RXO) adapter->rx_overruns++; @@ -1481,22 +1479,24 @@ em_msix_link(void *arg) if (reg_icr & (E1000_ICR_RXSEQ | E1000_ICR_LSC)) { em_handle_link(adapter->ctx); - } else { - E1000_WRITE_REG(&adapter->hw, E1000_IMS, - EM_MSIX_LINK | E1000_IMS_LSC); - if (adapter->hw.mac.type >= igb_mac_min) - E1000_WRITE_REG(&adapter->hw, E1000_EIMS, adapter->link_mask); + } else if (adapter->hw.mac.type == e1000_82574) { + /* Only re-arm 82574 if em_if_update_admin_status() won't. */ + E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | + E1000_IMS_LSC); } - /* - * Because we must read the ICR for this interrupt - * it may clear other causes using autoclear, for - * this reason we simply create a soft interrupt - * for all these vectors. - */ - if (reg_icr && adapter->hw.mac.type < igb_mac_min) { - E1000_WRITE_REG(&adapter->hw, - E1000_ICS, adapter->ims); + if (adapter->hw.mac.type == e1000_82574) { + /* + * Because we must read the ICR for this interrupt it may + * clear other causes using autoclear, for this reason we + * simply create a soft interrupt for all these vectors. + */ + if (reg_icr) + E1000_WRITE_REG(&adapter->hw, E1000_ICS, adapter->ims); + } else { + /* Re-arm unconditionally */ + E1000_WRITE_REG(&adapter->hw, E1000_IMS, E1000_IMS_LSC); + E1000_WRITE_REG(&adapter->hw, E1000_EIMS, adapter->link_mask); } return (FILTER_HANDLED); @@ -1512,7 +1512,6 @@ em_handle_link(void *context) iflib_admin_intr_deferred(ctx); } - /********************************************************************* * * Media Ioctl callback @@ -1829,14 +1828,15 @@ em_if_update_admin_status(if_ctx_t ctx) em_update_stats_counters(adapter); /* Reset LAA into RAR[0] on 82571 */ - if ((adapter->hw.mac.type == e1000_82571) && - e1000_get_laa_state_82571(&adapter->hw)) - e1000_rar_set(&adapter->hw, adapter->hw.mac.addr, 0); + if (hw->mac.type == e1000_82571 && e1000_get_laa_state_82571(hw)) + e1000_rar_set(hw, hw->mac.addr, 0); - if (adapter->hw.mac.type < em_mac_min) + if (hw->mac.type < em_mac_min) lem_smartspeed(adapter); - - E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | E1000_IMS_LSC); + else if (hw->mac.type == e1000_82574 && + adapter->intr_type == IFLIB_INTR_MSIX) + E1000_WRITE_REG(&adapter->hw, E1000_IMS, EM_MSIX_LINK | + E1000_IMS_LSC); } static void From owner-svn-src-stable-12@freebsd.org Thu Oct 24 14:57:39 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 77D8B16EEEF; Thu, 24 Oct 2019 14:57:39 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zVhz2W7xz3MJf; Thu, 24 Oct 2019 14:57:39 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 39659FDA7; Thu, 24 Oct 2019 14:57:39 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OEvdZG026368; Thu, 24 Oct 2019 14:57:39 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OEvdsM026367; Thu, 24 Oct 2019 14:57:39 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910241457.x9OEvdsM026367@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 24 Oct 2019 14:57:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354022 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354022 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 14:57:39 -0000 Author: avg Date: Thu Oct 24 14:57:38 2019 New Revision: 354022 URL: https://svnweb.freebsd.org/changeset/base/354022 Log: MFC r353168: ZFS: unconditionally use atomic_swap_64 Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c Thu Oct 24 14:18:06 2019 (r354021) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfeature.c Thu Oct 24 14:57:38 2019 (r354022) @@ -313,12 +313,8 @@ feature_sync(spa_t *spa, zfeature_info_t *feature, uin if (feature->fi_feature != SPA_FEATURE_NONE) { uint64_t *refcount_cache = &spa->spa_feat_refcount_cache[feature->fi_feature]; -#ifdef atomic_swap_64 VERIFY3U(*refcount_cache, ==, atomic_swap_64(refcount_cache, refcount)); -#else - *refcount_cache = refcount; -#endif } if (refcount == 0) From owner-svn-src-stable-12@freebsd.org Thu Oct 24 15:00:56 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F10A016EFC1; Thu, 24 Oct 2019 15:00:56 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zVmm5yhqz3Mby; Thu, 24 Oct 2019 15:00:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id AFF01FDD8; Thu, 24 Oct 2019 15:00:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OF0ulZ028785; Thu, 24 Oct 2019 15:00:56 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OF0u67028784; Thu, 24 Oct 2019 15:00:56 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910241500.x9OF0u67028784@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 24 Oct 2019 15:00:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354023 - stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zfs X-SVN-Commit-Revision: 354023 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 15:00:57 -0000 Author: avg Date: Thu Oct 24 15:00:56 2019 New Revision: 354023 URL: https://svnweb.freebsd.org/changeset/base/354023 Log: MFC r353607: MFV r353606: 10067 Miscellaneous man page typos Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Thu Oct 24 14:57:38 2019 (r354022) +++ stable/12/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Thu Oct 24 15:00:56 2019 (r354023) @@ -2335,7 +2335,7 @@ option was not specified. .Ar filesystem Ns | Ns Ar volume .Xc .Pp -Remap the indirect blocks in the given fileystem or volume so that they no +Remap the indirect blocks in the given filesystem or volume so that they no longer reference blocks on previously removed vdevs and we can eventually shrink the size of the indirect mapping objects for the previously removed vdevs. Note that remapping all blocks might not be possible and that From owner-svn-src-stable-12@freebsd.org Thu Oct 24 15:04:07 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7BF1F16F252; Thu, 24 Oct 2019 15:04:07 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zVrR2gdZz3Mxv; Thu, 24 Oct 2019 15:04:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 407B5FF7C; Thu, 24 Oct 2019 15:04:07 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OF47eY031996; Thu, 24 Oct 2019 15:04:07 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OF479j031995; Thu, 24 Oct 2019 15:04:07 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910241504.x9OF479j031995@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 24 Oct 2019 15:04:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354025 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354025 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 15:04:07 -0000 Author: avg Date: Thu Oct 24 15:04:06 2019 New Revision: 354025 URL: https://svnweb.freebsd.org/changeset/base/354025 Log: MFC r353614: MFV r353613: 10731 zfs: NULL pointer errors FreeBSD already had these changes locally. This commit removes a small formatting difference. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Thu Oct 24 15:01:31 2019 (r354024) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dsl_pool.c Thu Oct 24 15:04:06 2019 (r354025) @@ -1249,8 +1249,7 @@ int dsl_pool_user_release(dsl_pool_t *dp, uint64_t dsobj, const char *tag, dmu_tx_t *tx) { - return (dsl_pool_user_hold_rele_impl(dp, dsobj, tag, 0, - tx, B_FALSE)); + return (dsl_pool_user_hold_rele_impl(dp, dsobj, tag, 0, tx, B_FALSE)); } /* From owner-svn-src-stable-12@freebsd.org Thu Oct 24 15:46:01 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9308217037F; Thu, 24 Oct 2019 15:46:01 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zWmn3Ls0z3Qg2; Thu, 24 Oct 2019 15:46:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 52BB7186B8; Thu, 24 Oct 2019 15:46:01 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OFk1e5056321; Thu, 24 Oct 2019 15:46:01 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OFk0jZ056319; Thu, 24 Oct 2019 15:46:00 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910241546.x9OFk0jZ056319@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Thu, 24 Oct 2019 15:46:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354027 - in stable/12/sys: arm/include mips/include powerpc/include X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys: arm/include mips/include powerpc/include X-SVN-Commit-Revision: 354027 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 15:46:01 -0000 Author: avg Date: Thu Oct 24 15:46:00 2019 New Revision: 354027 URL: https://svnweb.freebsd.org/changeset/base/354027 Log: MFC r341787 by hselasky: Implement atomic_swap_xxx() for all platforms. Modified: stable/12/sys/arm/include/atomic.h stable/12/sys/mips/include/atomic.h stable/12/sys/powerpc/include/atomic.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/include/atomic.h ============================================================================== --- stable/12/sys/arm/include/atomic.h Thu Oct 24 15:04:52 2019 (r354026) +++ stable/12/sys/arm/include/atomic.h Thu Oct 24 15:46:00 2019 (r354027) @@ -55,6 +55,13 @@ #include #endif /* Arch >= v6 */ +static __inline u_long +atomic_swap_long(volatile u_long *p, u_long v) +{ + + return (atomic_swap_32((volatile uint32_t *)p, v)); +} + #define atomic_clear_ptr atomic_clear_32 #define atomic_clear_acq_ptr atomic_clear_acq_32 #define atomic_clear_rel_ptr atomic_clear_rel_32 Modified: stable/12/sys/mips/include/atomic.h ============================================================================== --- stable/12/sys/mips/include/atomic.h Thu Oct 24 15:04:52 2019 (r354026) +++ stable/12/sys/mips/include/atomic.h Thu Oct 24 15:46:00 2019 (r354027) @@ -759,4 +759,68 @@ atomic_thread_fence_seq_cst(void) #define atomic_store_rel_ptr atomic_store_rel_long #define atomic_readandclear_ptr atomic_readandclear_long +static __inline unsigned int +atomic_swap_int(volatile unsigned int *ptr, const unsigned int value) +{ + unsigned int retval; + + retval = *ptr; + + while (!atomic_fcmpset_int(ptr, &retval, value)) + ; + return (retval); +} + +static __inline uint32_t +atomic_swap_32(volatile uint32_t *ptr, const uint32_t value) +{ + uint32_t retval; + + retval = *ptr; + + while (!atomic_fcmpset_32(ptr, &retval, value)) + ; + return (retval); +} + +#if defined(__mips_n64) || defined(__mips_n32) +static __inline uint64_t +atomic_swap_64(volatile uint64_t *ptr, const uint64_t value) +{ + uint64_t retval; + + retval = *ptr; + + while (!atomic_fcmpset_64(ptr, &retval, value)) + ; + return (retval); +} +#endif + +static __inline unsigned long +atomic_swap_long(volatile unsigned long *ptr, const unsigned long value) +{ + unsigned long retval; + + retval = *ptr; + + while (!atomic_fcmpset_32((volatile uint32_t *)ptr, + (uint32_t *)&retval, value)) + ; + return (retval); +} + +static __inline uintptr_t +atomic_swap_ptr(volatile uintptr_t *ptr, const uintptr_t value) +{ + uintptr_t retval; + + retval = *ptr; + + while (!atomic_fcmpset_32((volatile uint32_t *)ptr, + (uint32_t *)&retval, value)) + ; + return (retval); +} + #endif /* ! _MACHINE_ATOMIC_H_ */ Modified: stable/12/sys/powerpc/include/atomic.h ============================================================================== --- stable/12/sys/powerpc/include/atomic.h Thu Oct 24 15:04:52 2019 (r354026) +++ stable/12/sys/powerpc/include/atomic.h Thu Oct 24 15:46:00 2019 (r354027) @@ -852,6 +852,9 @@ atomic_swap_64(volatile u_long *p, u_long v) #define atomic_fetchadd_64 atomic_fetchadd_long #define atomic_swap_long atomic_swap_64 #define atomic_swap_ptr atomic_swap_64 +#else +#define atomic_swap_long(p,v) atomic_swap_32((volatile u_int *)(p), v) +#define atomic_swap_ptr(p,v) atomic_swap_32((volatile u_int *)(p), v) #endif #undef __ATOMIC_REL From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:05:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78D9D1777E4; Thu, 24 Oct 2019 19:05:29 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcBx2SG9z4TDS; Thu, 24 Oct 2019 19:05:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3390C1ABA1; Thu, 24 Oct 2019 19:05:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJ5Tc4001446; Thu, 24 Oct 2019 19:05:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJ5T8H001445; Thu, 24 Oct 2019 19:05:29 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910241905.x9OJ5T8H001445@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 24 Oct 2019 19:05:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354030 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354030 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:05:29 -0000 Author: mav Date: Thu Oct 24 19:05:28 2019 New Revision: 354030 URL: https://svnweb.freebsd.org/changeset/base/354030 Log: MFC r350972 (by jeff): Move scheduler state into the per-cpu area where it can be allocated on the correct NUMA domain. I haven't merged addition of the new field to struct pcpu to not break KBI, so this may be slightly pessimized, comparing to head. Modified: stable/12/sys/kern/sched_ule.c Modified: stable/12/sys/kern/sched_ule.c ============================================================================== --- stable/12/sys/kern/sched_ule.c Thu Oct 24 18:39:05 2019 (r354029) +++ stable/12/sys/kern/sched_ule.c Thu Oct 24 19:05:28 2019 (r354030) @@ -247,6 +247,7 @@ struct tdq { u_char tdq_ipipending; /* IPI pending. */ u_char tdq_idx; /* Current insert index. */ u_char tdq_ridx; /* Current removal index. */ + int tdq_id; /* cpuid. */ struct runq tdq_realtime; /* real-time run queue. */ struct runq tdq_timeshare; /* timeshare run queue. */ struct runq tdq_idle; /* Queue of IDLE threads. */ @@ -280,14 +281,14 @@ static int trysteal_limit = 2; /* * One thread queue per processor. */ -static struct tdq tdq_cpu[MAXCPU]; static struct tdq *balance_tdq; static int balance_ticks; +DPCPU_DEFINE_STATIC(struct tdq, tdq); DPCPU_DEFINE_STATIC(uint32_t, randomval); -#define TDQ_SELF() (&tdq_cpu[PCPU_GET(cpuid)]) -#define TDQ_CPU(x) (&tdq_cpu[(x)]) -#define TDQ_ID(x) ((int)((x) - tdq_cpu)) +#define TDQ_SELF() (DPCPU_PTR(tdq)) +#define TDQ_CPU(x) (DPCPU_ID_PTR((x), tdq)) +#define TDQ_ID(x) ((x)->tdq_id) #else /* !SMP */ static struct tdq tdq_cpu; @@ -311,7 +312,7 @@ static void sched_pctcpu_update(struct td_sched *, int /* Operations on per processor queues */ static struct thread *tdq_choose(struct tdq *); -static void tdq_setup(struct tdq *); +static void tdq_setup(struct tdq *, int i); static void tdq_load_add(struct tdq *, struct thread *); static void tdq_load_rem(struct tdq *, struct thread *); static __inline void tdq_runq_add(struct tdq *, struct thread *, int); @@ -838,6 +839,7 @@ sched_highest(const struct cpu_group *cg, cpuset_t mas static void sched_balance_group(struct cpu_group *cg) { + struct tdq *tdq; cpuset_t hmask, lmask; int high, low, anylow; @@ -853,9 +855,9 @@ sched_balance_group(struct cpu_group *cg) if (CPU_EMPTY(&lmask)) break; anylow = 1; + tdq = TDQ_CPU(high); nextlow: - low = sched_lowest(cg, lmask, -1, - TDQ_CPU(high)->tdq_load - 1, high); + low = sched_lowest(cg, lmask, -1, tdq->tdq_load - 1, high); /* Stop if we looked well and found no less loaded CPU. */ if (anylow && low == -1) break; @@ -863,7 +865,7 @@ nextlow: if (low == -1) continue; /* Transfer thread from high to low. */ - if (sched_balance_pair(TDQ_CPU(high), TDQ_CPU(low))) { + if (sched_balance_pair(tdq, TDQ_CPU(low))) { /* CPU that got thread can no longer be a donor. */ CPU_CLR(low, &hmask); } else { @@ -1271,7 +1273,7 @@ sched_pickcpu(struct thread *td, int flags) curthread->td_intr_nesting_level && ts->ts_cpu != self) { SCHED_STAT_INC(pickcpu_intrbind); ts->ts_cpu = self; - if (TDQ_CPU(self)->tdq_lowpri > pri) { + if (TDQ_SELF()->tdq_lowpri > pri) { SCHED_STAT_INC(pickcpu_affinity); return (ts->ts_cpu); } @@ -1329,9 +1331,10 @@ sched_pickcpu(struct thread *td, int flags) /* * Compare the lowest loaded cpu to current cpu. */ - if (THREAD_CAN_SCHED(td, self) && TDQ_CPU(self)->tdq_lowpri > pri && - TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE && - TDQ_CPU(self)->tdq_load <= TDQ_CPU(cpu)->tdq_load + 1) { + tdq = TDQ_CPU(cpu); + if (THREAD_CAN_SCHED(td, self) && TDQ_SELF()->tdq_lowpri > pri && + tdq->tdq_lowpri < PRI_MIN_IDLE && + TDQ_SELF()->tdq_load <= tdq->tdq_load + 1) { SCHED_STAT_INC(pickcpu_local); cpu = self; } else @@ -1376,14 +1379,15 @@ tdq_choose(struct tdq *tdq) * Initialize a thread queue. */ static void -tdq_setup(struct tdq *tdq) +tdq_setup(struct tdq *tdq, int id) { if (bootverbose) - printf("ULE: setup cpu %d\n", TDQ_ID(tdq)); + printf("ULE: setup cpu %d\n", id); runq_init(&tdq->tdq_realtime); runq_init(&tdq->tdq_timeshare); runq_init(&tdq->tdq_idle); + tdq->tdq_id = id; snprintf(tdq->tdq_name, sizeof(tdq->tdq_name), "sched lock %d", (int)TDQ_ID(tdq)); mtx_init(&tdq->tdq_lock, tdq->tdq_name, "sched lock", @@ -1403,8 +1407,8 @@ sched_setup_smp(void) cpu_top = smp_topo(); CPU_FOREACH(i) { - tdq = TDQ_CPU(i); - tdq_setup(tdq); + tdq = DPCPU_ID_PTR(i, tdq); + tdq_setup(tdq, i); tdq->tdq_cg = smp_topo_find(cpu_top, i); if (tdq->tdq_cg == NULL) panic("Can't find cpu group for %d\n", i); @@ -1422,12 +1426,12 @@ sched_setup(void *dummy) { struct tdq *tdq; - tdq = TDQ_SELF(); #ifdef SMP sched_setup_smp(); #else - tdq_setup(tdq); + tdq_setup(TDQ_SELF(), 0); #endif + tdq = TDQ_SELF(); /* Add thread0's load since it's running. */ TDQ_LOCK(tdq); @@ -2015,7 +2019,7 @@ sched_switch(struct thread *td, struct thread *newtd, KASSERT(newtd == NULL, ("sched_switch: Unsupported newtd argument")); cpuid = PCPU_GET(cpuid); - tdq = TDQ_CPU(cpuid); + tdq = TDQ_SELF(); ts = td_get_sched(td); mtx = td->td_lock; sched_pctcpu_update(ts, 1); @@ -2110,7 +2114,7 @@ sched_switch(struct thread *td, struct thread *newtd, * run queue lock. */ cpuid = PCPU_GET(cpuid); - tdq = TDQ_CPU(cpuid); + tdq = TDQ_SELF(); lock_profile_obtain_lock_success( &TDQ_LOCKPTR(tdq)->lock_object, 0, 0, __FILE__, __LINE__); @@ -2850,14 +2854,15 @@ sched_throw(struct thread *td) struct thread *newtd; struct tdq *tdq; - tdq = TDQ_SELF(); if (td == NULL) { /* Correct spinlock nesting and acquire the correct lock. */ + tdq = TDQ_SELF(); TDQ_LOCK(tdq); spinlock_exit(); PCPU_SET(switchtime, cpu_ticks()); PCPU_SET(switchticks, ticks); } else { + tdq = TDQ_SELF(); MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); tdq_load_rem(tdq, td); lock_profile_release_lock(&TDQ_LOCKPTR(tdq)->lock_object); @@ -2885,7 +2890,7 @@ sched_fork_exit(struct thread *td) * non-nested critical section with the scheduler lock held. */ cpuid = PCPU_GET(cpuid); - tdq = TDQ_CPU(cpuid); + tdq = TDQ_SELF(); if (TD_IS_IDLETHREAD(td)) td->td_lock = TDQ_LOCKPTR(tdq); MPASS(td->td_lock == TDQ_LOCKPTR(tdq)); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:07:52 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C2DA8177876; Thu, 24 Oct 2019 19:07:52 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcFh4jNdz4TMd; Thu, 24 Oct 2019 19:07:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 807431ABA2; Thu, 24 Oct 2019 19:07:52 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJ7qox001606; Thu, 24 Oct 2019 19:07:52 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJ7qns001605; Thu, 24 Oct 2019 19:07:52 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910241907.x9OJ7qns001605@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 24 Oct 2019 19:07:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354031 - in stable: 11/sys/amd64/vmm/io 12/sys/amd64/vmm/io X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/amd64/vmm/io 12/sys/amd64/vmm/io X-SVN-Commit-Revision: 354031 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:07:52 -0000 Author: jhb Date: Thu Oct 24 19:07:52 2019 New Revision: 354031 URL: https://svnweb.freebsd.org/changeset/base/354031 Log: MFC 350178: Improve the precision of bhyve's vPIT. Use 'struct bintime' instead of 'sbintime_t' to manage times in vPIT to postpone rounding to final results rather than intermediate results. In tests performed by Joyent, this reduced the error measured by Linux guests by 59 ppm. Modified: stable/12/sys/amd64/vmm/io/vatpit.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/amd64/vmm/io/vatpit.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/amd64/vmm/io/vatpit.c ============================================================================== --- stable/12/sys/amd64/vmm/io/vatpit.c Thu Oct 24 19:05:28 2019 (r354030) +++ stable/12/sys/amd64/vmm/io/vatpit.c Thu Oct 24 19:07:52 2019 (r354031) @@ -2,6 +2,7 @@ * Copyright (c) 2014 Tycho Nightingale * Copyright (c) 2011 NetApp, Inc. * All rights reserved. + * Copyright (c) 2018 Joyent, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -78,7 +79,7 @@ struct vatpit_callout_arg { struct channel { int mode; uint16_t initial; /* initial counter value */ - sbintime_t now_sbt; /* uptime when counter was loaded */ + struct bintime now_bt; /* uptime when counter was loaded */ uint8_t cr[2]; uint8_t ol[2]; bool slatched; /* status latched */ @@ -87,7 +88,7 @@ struct channel { int olbyte; int frbyte; struct callout callout; - sbintime_t callout_sbt; /* target time */ + struct bintime callout_bt; /* target time */ struct vatpit_callout_arg callout_arg; }; @@ -95,26 +96,41 @@ struct vatpit { struct vm *vm; struct mtx mtx; - sbintime_t freq_sbt; + struct bintime freq_bt; struct channel channel[3]; }; static void pit_timer_start_cntr0(struct vatpit *vatpit); +static uint64_t +vatpit_delta_ticks(struct vatpit *vatpit, struct channel *c) +{ + struct bintime delta; + uint64_t result; + + binuptime(&delta); + bintime_sub(&delta, &c->now_bt); + + result = delta.sec * PIT_8254_FREQ; + result += delta.frac / vatpit->freq_bt.frac; + + return (result); +} + static int vatpit_get_out(struct vatpit *vatpit, int channel) { struct channel *c; - sbintime_t delta_ticks; + uint64_t delta_ticks; int out; c = &vatpit->channel[channel]; switch (c->mode) { case TIMER_INTTC: - delta_ticks = (sbinuptime() - c->now_sbt) / vatpit->freq_sbt; - out = ((c->initial - delta_ticks) <= 0); + delta_ticks = vatpit_delta_ticks(vatpit, c); + out = (delta_ticks >= c->initial); break; default: out = 0; @@ -164,24 +180,28 @@ static void pit_timer_start_cntr0(struct vatpit *vatpit) { struct channel *c; - sbintime_t now, delta, precision; + struct bintime now, delta; + sbintime_t precision; c = &vatpit->channel[0]; if (c->initial != 0) { - delta = c->initial * vatpit->freq_sbt; - precision = delta >> tc_precexp; - c->callout_sbt = c->callout_sbt + delta; + delta.sec = 0; + delta.frac = vatpit->freq_bt.frac * c->initial; + bintime_add(&c->callout_bt, &delta); + precision = bttosbt(delta) >> tc_precexp; /* - * Reset 'callout_sbt' if the time that the callout + * Reset 'callout_bt' if the time that the callout * was supposed to fire is more than 'c->initial' * ticks in the past. */ - now = sbinuptime(); - if (c->callout_sbt < now) - c->callout_sbt = now + delta; + binuptime(&now); + if (bintime_cmp(&c->callout_bt, &now, <)) { + c->callout_bt = now; + bintime_add(&c->callout_bt, &delta); + } - callout_reset_sbt(&c->callout, c->callout_sbt, + callout_reset_sbt(&c->callout, bttosbt(c->callout_bt), precision, vatpit_callout_handler, &c->callout_arg, C_ABSOLUTE); } @@ -191,7 +211,7 @@ static uint16_t pit_update_counter(struct vatpit *vatpit, struct channel *c, bool latch) { uint16_t lval; - sbintime_t delta_ticks; + uint64_t delta_ticks; /* cannot latch a new value until the old one has been consumed */ if (latch && c->olbyte != 0) @@ -207,12 +227,11 @@ pit_update_counter(struct vatpit *vatpit, struct chann * here. */ c->initial = TIMER_DIV(PIT_8254_FREQ, 100); - c->now_sbt = sbinuptime(); + binuptime(&c->now_bt); c->status &= ~TIMER_STS_NULLCNT; } - delta_ticks = (sbinuptime() - c->now_sbt) / vatpit->freq_sbt; - + delta_ticks = vatpit_delta_ticks(vatpit, c); lval = c->initial - delta_ticks % c->initial; if (latch) { @@ -383,10 +402,10 @@ vatpit_handler(struct vm *vm, int vcpuid, bool in, int c->frbyte = 0; c->crbyte = 0; c->initial = c->cr[0] | (uint16_t)c->cr[1] << 8; - c->now_sbt = sbinuptime(); + binuptime(&c->now_bt); /* Start an interval timer for channel 0 */ if (port == TIMER_CNTR0) { - c->callout_sbt = c->now_sbt; + c->callout_bt = c->now_bt; pit_timer_start_cntr0(vatpit); } if (c->initial == 0) @@ -423,7 +442,6 @@ struct vatpit * vatpit_init(struct vm *vm) { struct vatpit *vatpit; - struct bintime bt; struct vatpit_callout_arg *arg; int i; @@ -432,8 +450,7 @@ vatpit_init(struct vm *vm) mtx_init(&vatpit->mtx, "vatpit lock", NULL, MTX_SPIN); - FREQ2BT(PIT_8254_FREQ, &bt); - vatpit->freq_sbt = bttosbt(bt); + FREQ2BT(PIT_8254_FREQ, &vatpit->freq_bt); for (i = 0; i < 3; i++) { callout_init(&vatpit->channel[i].callout, 1); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:11:01 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B466E1779D5; Thu, 24 Oct 2019 19:11:01 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcKK4GlHz4TfR; Thu, 24 Oct 2019 19:11:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 76E2C1ABD2; Thu, 24 Oct 2019 19:11:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJB1gN002573; Thu, 24 Oct 2019 19:11:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJB1nv002572; Thu, 24 Oct 2019 19:11:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910241911.x9OJB1nv002572@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 24 Oct 2019 19:11:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354032 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354032 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:11:01 -0000 Author: mav Date: Thu Oct 24 19:11:01 2019 New Revision: 354032 URL: https://svnweb.freebsd.org/changeset/base/354032 Log: MFC r352658, r352677, r352713: Fix/improve interrupt threads scheduling. Doing some tests with very high interrupt rates I've noticed that one of conditions I added in r232207 to make interrupt threads in most cases run on local CPU never worked as expected (worked only if previous time it was executed on some other CPU, that is quite opposite). It caused additional CPU usage to run full CPU search and could schedule interrupt threads to some other CPU. This patch removes that code and instead reuses existing non-interrupt code path with some tweaks for interrupt case: - On SMT systems, if current thread is idle, don't look on other threads. Even if they are busy, it may take more time to do fill search and bounce the interrupt thread to other core then execute it locally, even sharing CPU resources. It is other threads should migrate, not bound interrupts. - Try hard to keep interrupt threads within LLC of their original CPU. This improves scheduling cost and supposedly cache and memory locality. On a test system with 72 threads doing 2.2M IOPS to NVMe this saves few percents of CPU time while adding few percents to IOPS. Modified: stable/12/sys/kern/sched_ule.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/sched_ule.c ============================================================================== --- stable/12/sys/kern/sched_ule.c Thu Oct 24 19:07:52 2019 (r354031) +++ stable/12/sys/kern/sched_ule.c Thu Oct 24 19:11:01 2019 (r354032) @@ -1251,7 +1251,7 @@ sched_pickcpu(struct thread *td, int flags) struct td_sched *ts; struct tdq *tdq; cpuset_t mask; - int cpu, pri, self; + int cpu, pri, self, intr; self = PCPU_GET(cpuid); ts = td_get_sched(td); @@ -1268,22 +1268,26 @@ sched_pickcpu(struct thread *td, int flags) * Prefer to run interrupt threads on the processors that generate * the interrupt. */ - pri = td->td_priority; if (td->td_priority <= PRI_MAX_ITHD && THREAD_CAN_SCHED(td, self) && - curthread->td_intr_nesting_level && ts->ts_cpu != self) { - SCHED_STAT_INC(pickcpu_intrbind); - ts->ts_cpu = self; - if (TDQ_SELF()->tdq_lowpri > pri) { - SCHED_STAT_INC(pickcpu_affinity); - return (ts->ts_cpu); + curthread->td_intr_nesting_level) { + tdq = TDQ_SELF(); + if (tdq->tdq_lowpri >= PRI_MIN_IDLE) { + SCHED_STAT_INC(pickcpu_idle_affinity); + return (self); } + ts->ts_cpu = self; + intr = 1; + cg = tdq->tdq_cg; + goto llc; + } else { + intr = 0; + tdq = TDQ_CPU(ts->ts_cpu); + cg = tdq->tdq_cg; } /* * If the thread can run on the last cpu and the affinity has not * expired and it is idle, run it there. */ - tdq = TDQ_CPU(ts->ts_cpu); - cg = tdq->tdq_cg; if (THREAD_CAN_SCHED(td, ts->ts_cpu) && tdq->tdq_lowpri >= PRI_MIN_IDLE && SCHED_AFFINITY(ts, CG_SHARE_L2)) { @@ -1299,34 +1303,58 @@ sched_pickcpu(struct thread *td, int flags) return (ts->ts_cpu); } } +llc: /* * Search for the last level cache CPU group in the tree. - * Skip caches with expired affinity time and SMT groups. - * Affinity to higher level caches will be handled less aggressively. + * Skip SMT, identical groups and caches with expired affinity. + * Interrupt threads affinity is explicit and never expires. */ for (ccg = NULL; cg != NULL; cg = cg->cg_parent) { if (cg->cg_flags & CG_FLAG_THREAD) continue; - if (!SCHED_AFFINITY(ts, cg->cg_level)) + if (cg->cg_children == 1 || cg->cg_count == 1) continue; + if (cg->cg_level == CG_SHARE_NONE || + (!intr && !SCHED_AFFINITY(ts, cg->cg_level))) + continue; ccg = cg; } - if (ccg != NULL) - cg = ccg; + /* Found LLC shared by all CPUs, so do a global search. */ + if (ccg == cpu_top) + ccg = NULL; cpu = -1; - /* Search the group for the less loaded idle CPU we can run now. */ mask = td->td_cpuset->cs_mask; - if (cg != NULL && cg != cpu_top && - CPU_CMP(&cg->cg_mask, &cpu_top->cg_mask) != 0) - cpu = sched_lowest(cg, mask, max(pri, PRI_MAX_TIMESHARE), + pri = td->td_priority; + /* + * Try hard to keep interrupts within found LLC. Search the LLC for + * the least loaded CPU we can run now. For NUMA systems it should + * be within target domain, and it also reduces scheduling overhead. + */ + if (ccg != NULL && intr) { + cpu = sched_lowest(ccg, mask, pri, INT_MAX, ts->ts_cpu); + if (cpu >= 0) + SCHED_STAT_INC(pickcpu_intrbind); + } else + /* Search the LLC for the least loaded idle CPU we can run now. */ + if (ccg != NULL) { + cpu = sched_lowest(ccg, mask, max(pri, PRI_MAX_TIMESHARE), INT_MAX, ts->ts_cpu); - /* Search globally for the less loaded CPU we can run now. */ - if (cpu == -1) + if (cpu >= 0) + SCHED_STAT_INC(pickcpu_affinity); + } + /* Search globally for the least loaded CPU we can run now. */ + if (cpu < 0) { cpu = sched_lowest(cpu_top, mask, pri, INT_MAX, ts->ts_cpu); - /* Search globally for the less loaded CPU. */ - if (cpu == -1) + if (cpu >= 0) + SCHED_STAT_INC(pickcpu_lowest); + } + /* Search globally for the least loaded CPU. */ + if (cpu < 0) { cpu = sched_lowest(cpu_top, mask, -1, INT_MAX, ts->ts_cpu); - KASSERT(cpu != -1, ("sched_pickcpu: Failed to find a cpu.")); + if (cpu >= 0) + SCHED_STAT_INC(pickcpu_lowest); + } + KASSERT(cpu >= 0, ("sched_pickcpu: Failed to find a cpu.")); KASSERT(!CPU_ABSENT(cpu), ("sched_pickcpu: Picked absent CPU %d.", cpu)); /* * Compare the lowest loaded cpu to current cpu. @@ -1337,8 +1365,7 @@ sched_pickcpu(struct thread *td, int flags) TDQ_SELF()->tdq_load <= tdq->tdq_load + 1) { SCHED_STAT_INC(pickcpu_local); cpu = self; - } else - SCHED_STAT_INC(pickcpu_lowest); + } if (cpu != ts->ts_cpu) SCHED_STAT_INC(pickcpu_migration); return (cpu); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:12:02 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 03E8F177A87; Thu, 24 Oct 2019 19:12:02 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcLT6LMXz4Txq; Thu, 24 Oct 2019 19:12:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BB95C1AC2F; Thu, 24 Oct 2019 19:12:01 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJC1TV006656; Thu, 24 Oct 2019 19:12:01 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJC1GX006655; Thu, 24 Oct 2019 19:12:01 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910241912.x9OJC1GX006655@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 24 Oct 2019 19:12:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354033 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354033 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:12:02 -0000 Author: mav Date: Thu Oct 24 19:12:01 2019 New Revision: 354033 URL: https://svnweb.freebsd.org/changeset/base/354033 Log: MFC r352728: Microoptimize sched_pickcpu() CPU affinity on SMT. Use of CPU_FFS() to implement CPUSET_FOREACH() allows to save up to ~0.5% of CPU time on 72-thread SMT system doing 80K IOPS to NVMe from one thread. Modified: stable/12/sys/kern/sched_ule.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/sched_ule.c ============================================================================== --- stable/12/sys/kern/sched_ule.c Thu Oct 24 19:11:01 2019 (r354032) +++ stable/12/sys/kern/sched_ule.c Thu Oct 24 19:12:01 2019 (r354033) @@ -643,10 +643,6 @@ struct cpu_search { #define CPU_SEARCH_HIGHEST 0x2 #define CPU_SEARCH_BOTH (CPU_SEARCH_LOWEST|CPU_SEARCH_HIGHEST) -#define CPUSET_FOREACH(cpu, mask) \ - for ((cpu) = 0; (cpu) <= mp_maxid; (cpu)++) \ - if (CPU_ISSET(cpu, &mask)) - static __always_inline int cpu_search(const struct cpu_group *cg, struct cpu_search *low, struct cpu_search *high, const int match); int __noinline cpu_search_lowest(const struct cpu_group *cg, @@ -1292,13 +1288,17 @@ sched_pickcpu(struct thread *td, int flags) tdq->tdq_lowpri >= PRI_MIN_IDLE && SCHED_AFFINITY(ts, CG_SHARE_L2)) { if (cg->cg_flags & CG_FLAG_THREAD) { - CPUSET_FOREACH(cpu, cg->cg_mask) { - if (TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) + /* Check all SMT threads for being idle. */ + for (cpu = CPU_FFS(&cg->cg_mask) - 1; ; cpu++) { + if (CPU_ISSET(cpu, &cg->cg_mask) && + TDQ_CPU(cpu)->tdq_lowpri < PRI_MIN_IDLE) break; + if (cpu >= mp_maxid) { + SCHED_STAT_INC(pickcpu_idle_affinity); + return (ts->ts_cpu); + } } - } else - cpu = INT_MAX; - if (cpu > mp_maxid) { + } else { SCHED_STAT_INC(pickcpu_idle_affinity); return (ts->ts_cpu); } From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:14:38 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 34813177CB6; Thu, 24 Oct 2019 19:14:38 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcPV0cWtz4VDF; Thu, 24 Oct 2019 19:14:38 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E483A1AD72; Thu, 24 Oct 2019 19:14:37 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJEbUZ007622; Thu, 24 Oct 2019 19:14:37 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJEbcO007621; Thu, 24 Oct 2019 19:14:37 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910241914.x9OJEbcO007621@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 24 Oct 2019 19:14:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354034 - in stable: 11/lib/libutil 12/lib/libutil X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/lib/libutil 12/lib/libutil X-SVN-Commit-Revision: 354034 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:14:38 -0000 Author: jhb Date: Thu Oct 24 19:14:37 2019 New Revision: 354034 URL: https://svnweb.freebsd.org/changeset/base/354034 Log: MFC 350179: expand_number(3) parses suffixes, not prefixes. While here, tidy the opening sentence a bit. Modified: stable/12/lib/libutil/expand_number.3 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/libutil/expand_number.3 Directory Properties: stable/11/ (props changed) Modified: stable/12/lib/libutil/expand_number.3 ============================================================================== --- stable/12/lib/libutil/expand_number.3 Thu Oct 24 19:12:01 2019 (r354033) +++ stable/12/lib/libutil/expand_number.3 Thu Oct 24 19:14:37 2019 (r354034) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 15, 2010 +.Dd July 20, 2019 .Dt EXPAND_NUMBER 3 .Os .Sh NAME @@ -42,11 +42,10 @@ .Sh DESCRIPTION The .Fn expand_number -function unformats the +function parses the .Fa buf -string and stores a unsigned 64-bit quantity at address pointed out by the -.Fa num -argument. +string and stores a unsigned 64-bit quantity at +.Fa *num . .Pp The .Fn expand_number @@ -54,9 +53,9 @@ function is case-insensitive and follows the SI power of two convention. .Pp -The prefixes are: -.Bl -column "Prefix" "Description" "1000000000000000000" -offset indent -.It Sy "Prefix" Ta Sy "Description" Ta Sy "Multiplier" +The suffixes are: +.Bl -column "Suffix" "Description" "1000000000000000000" -offset indent +.It Sy "Suffix" Ta Sy "Description" Ta Sy "Multiplier" .It Li K Ta No kilo Ta 1024 .It Li M Ta No mega Ta 1048576 .It Li G Ta No giga Ta 1073741824 @@ -74,7 +73,7 @@ function will fail if: .It Bq Er EINVAL The given string contains no digits. .It Bq Er EINVAL -An unrecognized prefix was given. +An unrecognized suffix was given. .It Bq Er ERANGE Result doesn't fit into 64 bits. .El From owner-svn-src-stable-12@freebsd.org Thu Oct 24 19:18:50 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B3456177E0A; Thu, 24 Oct 2019 19:18:50 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zcVL4G1nz4VVF; Thu, 24 Oct 2019 19:18:50 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71A051AD74; Thu, 24 Oct 2019 19:18:50 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OJIodB007915; Thu, 24 Oct 2019 19:18:50 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OJIodM007914; Thu, 24 Oct 2019 19:18:50 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910241918.x9OJIodM007914@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 24 Oct 2019 19:18:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354035 - in stable: 11/share/man/man9 12/share/man/man9 X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/share/man/man9 12/share/man/man9 X-SVN-Commit-Revision: 354035 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 19:18:50 -0000 Author: jhb Date: Thu Oct 24 19:18:49 2019 New Revision: 354035 URL: https://svnweb.freebsd.org/changeset/base/354035 Log: MFC 351224: Trim a spurious blank line I added in r348969. I did not bump .Dd since there is no content change. Modified: stable/12/share/man/man9/sysctl.9 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/share/man/man9/sysctl.9 Directory Properties: stable/11/ (props changed) Modified: stable/12/share/man/man9/sysctl.9 ============================================================================== --- stable/12/share/man/man9/sysctl.9 Thu Oct 24 19:14:37 2019 (r354034) +++ stable/12/share/man/man9/sysctl.9 Thu Oct 24 19:18:49 2019 (r354035) @@ -388,7 +388,6 @@ .Fn SYSCTL_UINT parent number name ctlflags ptr val descr .Fn SYSCTL_ULONG parent number name ctlflags ptr val descr .Fn SYSCTL_UQUAD parent number name ctlflags ptr val descr - .Sh DESCRIPTION The .Nm SYSCTL From owner-svn-src-stable-12@freebsd.org Thu Oct 24 20:00:30 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F3F08158E5F; Thu, 24 Oct 2019 20:00:29 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zdQP69hgz4Y61; Thu, 24 Oct 2019 20:00:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B71DB1B4A9; Thu, 24 Oct 2019 20:00:29 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OK0T75031605; Thu, 24 Oct 2019 20:00:29 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OK0STL031601; Thu, 24 Oct 2019 20:00:28 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910242000.x9OK0STL031601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 24 Oct 2019 20:00:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354041 - in stable/12/sys: amd64/amd64 dev/acpica vm X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 dev/acpica vm X-SVN-Commit-Revision: 354041 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 20:00:30 -0000 Author: mav Date: Thu Oct 24 20:00:28 2019 New Revision: 354041 URL: https://svnweb.freebsd.org/changeset/base/354041 Log: MFC r351200 (by jeff), 351454,351456,351494-351495 (by kib): Allocate all per-cpu datastructures in domain correct memory. Modified: stable/12/sys/amd64/amd64/mp_machdep.c stable/12/sys/dev/acpica/acpi_pxm.c stable/12/sys/dev/acpica/acpivar.h stable/12/sys/vm/vm_phys.c stable/12/sys/vm/vm_phys.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/mp_machdep.c Thu Oct 24 19:57:18 2019 (r354040) +++ stable/12/sys/amd64/amd64/mp_machdep.c Thu Oct 24 20:00:28 2019 (r354041) @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #ifdef GPROF #include #endif @@ -59,6 +60,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -75,6 +78,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + #define WARMBOOT_TARGET 0 #define WARMBOOT_OFF (KERNBASE + 0x0467) #define WARMBOOT_SEG (KERNBASE + 0x0469) @@ -385,6 +391,27 @@ init_secondary(void) * local functions and data */ +#ifdef NUMA +static void +mp_realloc_pcpu(int cpuid, int domain) +{ + vm_page_t m; + vm_offset_t oa, na; + + oa = (vm_offset_t)&__pcpu[cpuid]; + if (_vm_phys_domain(pmap_kextract(oa)) == domain) + return; + m = vm_page_alloc_domain(NULL, 0, domain, + VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ); + if (m == NULL) + return; + na = PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)); + pagecopy((void *)oa, (void *)na); + pmap_enter(kernel_pmap, oa, m, VM_PROT_READ | VM_PROT_WRITE, 0, 0); + /* XXX old pcpu page leaked. */ +} +#endif + /* * start each AP in our list */ @@ -393,7 +420,7 @@ native_start_all_aps(void) { u_int64_t *pt4, *pt3, *pt2; u_int32_t mpbioswarmvec; - int apic_id, cpu, i; + int apic_id, cpu, domain, i; u_char mpbiosreason; mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN); @@ -432,21 +459,39 @@ native_start_all_aps(void) outb(CMOS_REG, BIOS_RESET); outb(CMOS_DATA, BIOS_WARM); /* 'warm-start' */ + /* Relocate pcpu areas to the correct domain. */ +#ifdef NUMA + if (vm_ndomains > 1) + for (cpu = 1; cpu < mp_ncpus; cpu++) { + apic_id = cpu_apic_ids[cpu]; + domain = acpi_pxm_get_cpu_locality(apic_id); + mp_realloc_pcpu(cpu, domain); + } +#endif + /* start each AP */ + domain = 0; for (cpu = 1; cpu < mp_ncpus; cpu++) { apic_id = cpu_apic_ids[cpu]; - +#ifdef NUMA + if (vm_ndomains > 1) + domain = acpi_pxm_get_cpu_locality(apic_id); +#endif /* allocate and set up an idle stack data page */ bootstacks[cpu] = (void *)kmem_malloc(kstack_pages * PAGE_SIZE, M_WAITOK | M_ZERO); doublefault_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); mce_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - nmi_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - dbg_stack = (char *)kmem_malloc(PAGE_SIZE, M_WAITOK | M_ZERO); - dpcpu = (void *)kmem_malloc(DPCPU_SIZE, M_WAITOK | M_ZERO); + nmi_stack = (char *)kmem_malloc_domainset( + DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + dbg_stack = (char *)kmem_malloc_domainset( + DOMAINSET_PREF(domain), PAGE_SIZE, M_WAITOK | M_ZERO); + dpcpu = (void *)kmem_malloc_domainset(DOMAINSET_PREF(domain), + DPCPU_SIZE, M_WAITOK | M_ZERO); - bootSTK = (char *)bootstacks[cpu] + kstack_pages * PAGE_SIZE - 8; + bootSTK = (char *)bootstacks[cpu] + + kstack_pages * PAGE_SIZE - 8; bootAP = cpu; /* attempt to start the Application Processor */ Modified: stable/12/sys/dev/acpica/acpi_pxm.c ============================================================================== --- stable/12/sys/dev/acpica/acpi_pxm.c Thu Oct 24 19:57:18 2019 (r354040) +++ stable/12/sys/dev/acpica/acpi_pxm.c Thu Oct 24 20:00:28 2019 (r354041) @@ -653,6 +653,17 @@ acpi_pxm_set_cpu_locality(void) } } +int +acpi_pxm_get_cpu_locality(int apic_id) +{ + struct cpu_info *cpu; + + cpu = cpu_find(apic_id); + if (cpu == NULL) + panic("SRAT: CPU with ID %u is not known", apic_id); + return (cpu->domain); +} + /* * Free data structures allocated during acpi_pxm_init. */ Modified: stable/12/sys/dev/acpica/acpivar.h ============================================================================== --- stable/12/sys/dev/acpica/acpivar.h Thu Oct 24 19:57:18 2019 (r354040) +++ stable/12/sys/dev/acpica/acpivar.h Thu Oct 24 20:00:28 2019 (r354041) @@ -528,6 +528,7 @@ int acpi_pxm_init(int ncpus, vm_paddr_t maxphys); void acpi_pxm_parse_tables(void); void acpi_pxm_set_mem_locality(void); void acpi_pxm_set_cpu_locality(void); +int acpi_pxm_get_cpu_locality(int apic_id); void acpi_pxm_free(void); /* Modified: stable/12/sys/vm/vm_phys.c ============================================================================== --- stable/12/sys/vm/vm_phys.c Thu Oct 24 19:57:18 2019 (r354040) +++ stable/12/sys/vm/vm_phys.c Thu Oct 24 20:00:28 2019 (r354041) @@ -624,6 +624,26 @@ vm_phys_register_domains(int ndomains, struct mem_affi #endif } +int +_vm_phys_domain(vm_paddr_t pa) +{ +#ifdef NUMA + int i; + + if (vm_ndomains == 1 || mem_affinity == NULL) + return (0); + + /* + * Check for any memory that overlaps. + */ + for (i = 0; mem_affinity[i].end != 0; i++) + if (mem_affinity[i].start <= pa && + mem_affinity[i].end >= pa) + return (mem_affinity[i].domain); +#endif + return (0); +} + /* * Split a contiguous, power of two-sized set of physical pages. * Modified: stable/12/sys/vm/vm_phys.h ============================================================================== --- stable/12/sys/vm/vm_phys.h Thu Oct 24 19:57:18 2019 (r354040) +++ stable/12/sys/vm/vm_phys.h Thu Oct 24 20:00:28 2019 (r354041) @@ -122,6 +122,7 @@ vm_phys_domain(vm_page_t m) return (0); #endif } +int _vm_phys_domain(vm_paddr_t pa); #endif /* _KERNEL */ #endif /* !_VM_PHYS_H_ */ From owner-svn-src-stable-12@freebsd.org Thu Oct 24 20:48:31 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 483E7159FDB; Thu, 24 Oct 2019 20:48:31 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zfTq1CbCz4brK; Thu, 24 Oct 2019 20:48:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 094481BDA2; Thu, 24 Oct 2019 20:48:31 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OKmUdi061589; Thu, 24 Oct 2019 20:48:30 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OKmUN8061587; Thu, 24 Oct 2019 20:48:30 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910242048.x9OKmUN8061587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 24 Oct 2019 20:48:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354047 - in stable: 11/sys/kern 12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/kern 12/sys/kern X-SVN-Commit-Revision: 354047 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 20:48:31 -0000 Author: jhb Date: Thu Oct 24 20:48:30 2019 New Revision: 354047 URL: https://svnweb.freebsd.org/changeset/base/354047 Log: MFC 350549: Set ISOPEN in namei flags when opening executable interpreters. These vnodes are explicitly opened via VOP_OPEN via exec_check_permissions identical to the main exectuable image. Setting ISOPEN allows filesystems to perform suitable checks in VOP_LOOKUP (e.g. close-to-open consistency in the NFS client). Modified: stable/12/sys/kern/imgact_elf.c stable/12/sys/kern/kern_exec.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/kern/imgact_elf.c stable/11/sys/kern/kern_exec.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Thu Oct 24 20:22:52 2019 (r354046) +++ stable/12/sys/kern/imgact_elf.c Thu Oct 24 20:48:30 2019 (r354047) @@ -767,8 +767,8 @@ __elfN(load_file)(struct proc *p, const char *file, u_ imgp->proc = p; imgp->attr = attr; - NDINIT(nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF, UIO_SYSSPACE, file, - curthread); + NDINIT(nd, LOOKUP, ISOPEN | FOLLOW | LOCKSHARED | LOCKLEAF, + UIO_SYSSPACE, file, curthread); if ((error = namei(nd)) != 0) { nd->ni_vp = NULL; goto fail; Modified: stable/12/sys/kern/kern_exec.c ============================================================================== --- stable/12/sys/kern/kern_exec.c Thu Oct 24 20:22:52 2019 (r354046) +++ stable/12/sys/kern/kern_exec.c Thu Oct 24 20:48:30 2019 (r354047) @@ -643,7 +643,7 @@ interpret: free(imgp->freepath, M_TEMP); imgp->freepath = NULL; /* set new name to that of the interpreter */ - NDINIT(&nd, LOOKUP, LOCKLEAF | FOLLOW | SAVENAME, + NDINIT(&nd, LOOKUP, ISOPEN | LOCKLEAF | FOLLOW | SAVENAME, UIO_SYSSPACE, imgp->interpreter_name, td); args->fname = imgp->interpreter_name; goto interpret; From owner-svn-src-stable-12@freebsd.org Thu Oct 24 21:02:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4AB4715A58C; Thu, 24 Oct 2019 21:02:25 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zfns1DpBz4ccc; Thu, 24 Oct 2019 21:02:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0DA351C12D; Thu, 24 Oct 2019 21:02:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OL2O48072799; Thu, 24 Oct 2019 21:02:24 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OL2Ovs072798; Thu, 24 Oct 2019 21:02:24 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910242102.x9OL2Ovs072798@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Thu, 24 Oct 2019 21:02:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354048 - stable/12/sys/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/conf X-SVN-Commit-Revision: 354048 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 21:02:25 -0000 Author: jhb Date: Thu Oct 24 21:02:24 2019 New Revision: 354048 URL: https://svnweb.freebsd.org/changeset/base/354048 Log: MFC 351434: Fix universe to include arm LINT kernel configs. Strip comments from the NOTES.armv[57] files as is done for other NOTES files when building the corresponding LINT configs. Without this, the LINT configs contained the NO_UNIVERSE comment from the NOTES.armv[57] files. Modified: stable/12/sys/conf/makeLINT.mk Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/conf/makeLINT.mk ============================================================================== --- stable/12/sys/conf/makeLINT.mk Thu Oct 24 20:48:30 2019 (r354047) +++ stable/12/sys/conf/makeLINT.mk Thu Oct 24 21:02:24 2019 (r354048) @@ -51,8 +51,10 @@ LINT: ${NOTES} ${MAKELINT_SED} echo "nodevice netmap" >> ${.TARGET}-NOIP .endif .if ${TARGET} == "arm" - cat ${.TARGET} ${.CURDIR}/NOTES.armv5 > ${.TARGET}-V5 - cat ${.TARGET} ${.CURDIR}/NOTES.armv7 > ${.TARGET}-V7 + cat ${NOTES} ${.CURDIR}/NOTES.armv5 | sed -E -n -f ${MAKELINT_SED} > \ + ${.TARGET}-V5 + cat ${NOTES} ${.CURDIR}/NOTES.armv7 | sed -E -n -f ${MAKELINT_SED} > \ + ${.TARGET}-V7 rm ${.TARGET} .endif .if ${TARGET} == "mips" From owner-svn-src-stable-12@freebsd.org Thu Oct 24 21:10:10 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A236E15A703; Thu, 24 Oct 2019 21:10:10 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zfyp3rBBz4cpB; Thu, 24 Oct 2019 21:10:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 673ED1C139; Thu, 24 Oct 2019 21:10:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OLAA2Q073260; Thu, 24 Oct 2019 21:10:10 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OLA91Q073256; Thu, 24 Oct 2019 21:10:09 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910242110.x9OLA91Q073256@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Thu, 24 Oct 2019 21:10:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354049 - in stable/12/sys/amd64: amd64 include X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys/amd64: amd64 include X-SVN-Commit-Revision: 354049 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 21:10:10 -0000 Author: mav Date: Thu Oct 24 21:10:09 2019 New Revision: 354049 URL: https://svnweb.freebsd.org/changeset/base/354049 Log: MFC r351457 (by kib): amd64: rework PCPU allocation Move pcpu KVA out of .bss into dynamically allocated VA at pmap_bootstrap(). This avoids demoting superpage mapping .data/.bss. Also it makes possible to use pmap_qenter() for installation of domain-local pcpu page on NUMA configs. Refactor pcpu and IST initialization by moving it to helper functions. Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/amd64/amd64/mp_machdep.c stable/12/sys/amd64/amd64/pmap.c stable/12/sys/amd64/include/counter.h stable/12/sys/amd64/include/md_var.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Thu Oct 24 21:02:24 2019 (r354048) +++ stable/12/sys/amd64/amd64/machdep.c Thu Oct 24 21:10:09 2019 (r354049) @@ -230,7 +230,8 @@ struct kva_md_info kmi; static struct trapframe proc0_tf; struct region_descriptor r_gdt, r_idt; -struct pcpu __pcpu[MAXCPU]; +struct pcpu *__pcpu; +struct pcpu temp_bsp_pcpu; struct mtx icu_lock; @@ -1559,13 +1560,68 @@ amd64_conf_fast_syscall(void) wrmsr(MSR_SF_MASK, PSL_NT | PSL_T | PSL_I | PSL_C | PSL_D | PSL_AC); } +void +amd64_bsp_pcpu_init1(struct pcpu *pc) +{ + + PCPU_SET(prvspace, pc); + PCPU_SET(curthread, &thread0); + PCPU_SET(tssp, &common_tss[0]); + PCPU_SET(commontssp, &common_tss[0]); + PCPU_SET(tss, (struct system_segment_descriptor *)&gdt[GPROC0_SEL]); + PCPU_SET(ldt, (struct system_segment_descriptor *)&gdt[GUSERLDT_SEL]); + PCPU_SET(fs32p, &gdt[GUFS32_SEL]); + PCPU_SET(gs32p, &gdt[GUGS32_SEL]); +} + +void +amd64_bsp_pcpu_init2(uint64_t rsp0) +{ + + PCPU_SET(rsp0, rsp0); + PCPU_SET(pti_rsp0, ((vm_offset_t)PCPU_PTR(pti_stack) + + PC_PTI_STACK_SZ * sizeof(uint64_t)) & ~0xful); + PCPU_SET(curpcb, thread0.td_pcb); +} + +void +amd64_bsp_ist_init(struct pcpu *pc) +{ + struct nmi_pcpu *np; + + /* doublefault stack space, runs on ist1 */ + common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; + + /* + * NMI stack, runs on ist2. The pcpu pointer is stored just + * above the start of the ist2 stack. + */ + np = ((struct nmi_pcpu *)&nmi0_stack[sizeof(nmi0_stack)]) - 1; + np->np_pcpu = (register_t)pc; + common_tss[0].tss_ist2 = (long)np; + + /* + * MC# stack, runs on ist3. The pcpu pointer is stored just + * above the start of the ist3 stack. + */ + np = ((struct nmi_pcpu *)&mce0_stack[sizeof(mce0_stack)]) - 1; + np->np_pcpu = (register_t)pc; + common_tss[0].tss_ist3 = (long)np; + + /* + * DB# stack, runs on ist4. + */ + np = ((struct nmi_pcpu *)&dbg0_stack[sizeof(dbg0_stack)]) - 1; + np->np_pcpu = (register_t)pc; + common_tss[0].tss_ist4 = (long)np; +} + u_int64_t hammer_time(u_int64_t modulep, u_int64_t physfree) { caddr_t kmdp; int gsel_tss, x; struct pcpu *pc; - struct nmi_pcpu *np; struct xstate_hdr *xhdr; u_int64_t rsp0; char *env; @@ -1639,7 +1695,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) r_gdt.rd_limit = NGDT * sizeof(gdt[0]) - 1; r_gdt.rd_base = (long) gdt; lgdt(&r_gdt); - pc = &__pcpu[0]; + pc = &temp_bsp_pcpu; wrmsr(MSR_FSBASE, 0); /* User value */ wrmsr(MSR_GSBASE, (u_int64_t)pc); @@ -1648,15 +1704,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) pcpu_init(pc, 0, sizeof(struct pcpu)); dpcpu_init((void *)(physfree + KERNBASE), 0); physfree += DPCPU_SIZE; - PCPU_SET(prvspace, pc); - PCPU_SET(curthread, &thread0); + amd64_bsp_pcpu_init1(pc); /* Non-late cninit() and printf() can be moved up to here. */ - PCPU_SET(tssp, &common_tss[0]); - PCPU_SET(commontssp, &common_tss[0]); - PCPU_SET(tss, (struct system_segment_descriptor *)&gdt[GPROC0_SEL]); - PCPU_SET(ldt, (struct system_segment_descriptor *)&gdt[GUSERLDT_SEL]); - PCPU_SET(fs32p, &gdt[GUFS32_SEL]); - PCPU_SET(gs32p, &gdt[GUGS32_SEL]); /* * Initialize mutexes. @@ -1745,31 +1794,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ - /* doublefault stack space, runs on ist1 */ - common_tss[0].tss_ist1 = (long)&dblfault_stack[sizeof(dblfault_stack)]; - - /* - * NMI stack, runs on ist2. The pcpu pointer is stored just - * above the start of the ist2 stack. - */ - np = ((struct nmi_pcpu *) &nmi0_stack[sizeof(nmi0_stack)]) - 1; - np->np_pcpu = (register_t) pc; - common_tss[0].tss_ist2 = (long) np; - - /* - * MC# stack, runs on ist3. The pcpu pointer is stored just - * above the start of the ist3 stack. - */ - np = ((struct nmi_pcpu *) &mce0_stack[sizeof(mce0_stack)]) - 1; - np->np_pcpu = (register_t) pc; - common_tss[0].tss_ist3 = (long) np; - - /* - * DB# stack, runs on ist4. - */ - np = ((struct nmi_pcpu *) &dbg0_stack[sizeof(dbg0_stack)]) - 1; - np->np_pcpu = (register_t) pc; - common_tss[0].tss_ist4 = (long) np; + amd64_bsp_ist_init(pc); /* Set the IO permission bitmap (empty due to tss seg limit) */ common_tss[0].tss_iobase = sizeof(struct amd64tss) + IOPERM_BITMAP_SIZE; @@ -1858,10 +1883,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) /* Ensure the stack is aligned to 16 bytes */ rsp0 &= ~0xFul; common_tss[0].tss_rsp0 = rsp0; - PCPU_SET(rsp0, rsp0); - PCPU_SET(pti_rsp0, ((vm_offset_t)PCPU_PTR(pti_stack) + - PC_PTI_STACK_SZ * sizeof(uint64_t)) & ~0xful); - PCPU_SET(curpcb, thread0.td_pcb); + amd64_bsp_pcpu_init2(rsp0); /* transfer to user mode */ Modified: stable/12/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/mp_machdep.c Thu Oct 24 21:02:24 2019 (r354048) +++ stable/12/sys/amd64/amd64/mp_machdep.c Thu Oct 24 21:10:09 2019 (r354049) @@ -94,7 +94,7 @@ __FBSDID("$FreeBSD$"); #define AP_BOOTPT_SZ (PAGE_SIZE * 3) -extern struct pcpu __pcpu[]; +extern struct pcpu *__pcpu; /* Temporary variables for init_secondary() */ char *doublefault_stack; @@ -407,7 +407,7 @@ mp_realloc_pcpu(int cpuid, int domain) return; na = PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)); pagecopy((void *)oa, (void *)na); - pmap_enter(kernel_pmap, oa, m, VM_PROT_READ | VM_PROT_WRITE, 0, 0); + pmap_qenter((vm_offset_t)&__pcpu[cpuid], &m, 1); /* XXX old pcpu page leaked. */ } #endif Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Thu Oct 24 21:02:24 2019 (r354048) +++ stable/12/sys/amd64/amd64/pmap.c Thu Oct 24 21:10:09 2019 (r354049) @@ -446,6 +446,10 @@ static pml4_entry_t *pti_pml4; static vm_pindex_t pti_pg_idx; static bool pti_finalized; +extern struct pcpu *__pcpu; +extern struct pcpu temp_bsp_pcpu; +extern pt_entry_t *pcpu_pte; + struct pmap_pkru_range { struct rs_el pkru_rs_el; u_int pkru_keyidx; @@ -1595,8 +1599,8 @@ void pmap_bootstrap(vm_paddr_t *firstaddr) { vm_offset_t va; - pt_entry_t *pte; - uint64_t cr4; + pt_entry_t *pte, *pcpu_pte; + uint64_t cr4, pcpu_phys; u_long res; int i; @@ -1611,6 +1615,8 @@ pmap_bootstrap(vm_paddr_t *firstaddr) */ create_pagetables(firstaddr); + pcpu_phys = allocpages(firstaddr, MAXCPU); + /* * Add a physical memory segment (vm_phys_seg) corresponding to the * preallocated kernel page table pages so that vm_page structures @@ -1678,7 +1684,20 @@ pmap_bootstrap(vm_paddr_t *firstaddr) SYSMAP(caddr_t, CMAP1, crashdumpmap, MAXDUMPPGS) CADDR1 = crashdumpmap; + SYSMAP(struct pcpu *, pcpu_pte, __pcpu, MAXCPU); virtual_avail = va; + + for (i = 0; i < MAXCPU; i++) { + pcpu_pte[i] = (pcpu_phys + ptoa(i)) | X86_PG_V | X86_PG_RW | + pg_g | pg_nx | X86_PG_M | X86_PG_A; + } + STAILQ_INIT(&cpuhead); + wrmsr(MSR_GSBASE, (uint64_t)&__pcpu[0]); + pcpu_init(&__pcpu[0], 0, sizeof(struct pcpu)); + amd64_bsp_pcpu_init1(&__pcpu[0]); + amd64_bsp_ist_init(&__pcpu[0]); + __pcpu[0].pc_dynamic = temp_bsp_pcpu.pc_dynamic; + __pcpu[0].pc_acpi_id = temp_bsp_pcpu.pc_acpi_id; /* * Initialize the PAT MSR. Modified: stable/12/sys/amd64/include/counter.h ============================================================================== --- stable/12/sys/amd64/include/counter.h Thu Oct 24 21:02:24 2019 (r354048) +++ stable/12/sys/amd64/include/counter.h Thu Oct 24 21:10:09 2019 (r354049) @@ -33,9 +33,10 @@ #include -extern struct pcpu __pcpu[]; +extern struct pcpu *__pcpu; +extern struct pcpu temp_bsp_pcpu; -#define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter +#define EARLY_COUNTER &temp_bsp_pcpu.pc_early_dummy_counter #define counter_enter() do {} while (0) #define counter_exit() do {} while (0) Modified: stable/12/sys/amd64/include/md_var.h ============================================================================== --- stable/12/sys/amd64/include/md_var.h Thu Oct 24 21:02:24 2019 (r354048) +++ stable/12/sys/amd64/include/md_var.h Thu Oct 24 21:10:09 2019 (r354049) @@ -58,6 +58,9 @@ struct sysentvec; void amd64_conf_fast_syscall(void); void amd64_db_resume_dbreg(void); void amd64_lower_shared_page(struct sysentvec *); +void amd64_bsp_pcpu_init1(struct pcpu *pc); +void amd64_bsp_pcpu_init2(uint64_t rsp0); +void amd64_bsp_ist_init(struct pcpu *pc); void amd64_syscall(struct thread *td, int traced); void amd64_syscall_ret_flush_l1d(int error); void amd64_syscall_ret_flush_l1d_recalc(void); From owner-svn-src-stable-12@freebsd.org Thu Oct 24 21:43:03 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 317DF15B1BD; Thu, 24 Oct 2019 21:43:03 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zghl0ZY1z4fMv; Thu, 24 Oct 2019 21:43:03 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E821D1C83C; Thu, 24 Oct 2019 21:43:02 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9OLh2VI096441; Thu, 24 Oct 2019 21:43:02 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9OLh205096439; Thu, 24 Oct 2019 21:43:02 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910242143.x9OLh205096439@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 24 Oct 2019 21:43:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354051 - in stable: 11/release/picobsd/build 11/share/man/man8 12/release/picobsd/build 12/share/man/man8 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/release/picobsd/build 11/share/man/man8 12/release/picobsd/build 12/share/man/man8 X-SVN-Commit-Revision: 354051 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Oct 2019 21:43:03 -0000 Author: kevans Date: Thu Oct 24 21:43:01 2019 New Revision: 354051 URL: https://svnweb.freebsd.org/changeset/base/354051 Log: MFC r353788: picobsd: add deprecation notices Notices appear both in picobsd(8) (near the top for easy notice) and are also printed to stderr on every invocation of picobsd for visibility. The tentative date for removal is October 31st, as no volunteers have stepped forward at all from postings to -arch@ at least. picobsd: add deprecation notices Modified: stable/12/release/picobsd/build/picobsd stable/12/share/man/man8/picobsd.8 Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/release/picobsd/build/picobsd stable/11/share/man/man8/picobsd.8 Directory Properties: stable/11/ (props changed) Modified: stable/12/release/picobsd/build/picobsd ============================================================================== --- stable/12/release/picobsd/build/picobsd Thu Oct 24 21:28:37 2019 (r354050) +++ stable/12/release/picobsd/build/picobsd Thu Oct 24 21:43:01 2019 (r354051) @@ -1019,6 +1019,7 @@ set_build_parameters() { # Main entry of the script. Initialize variables, parse command line # arguments. +1>&2 echo "WARNING: picobsd is deprecated and will be removed in FreeBSD 13.0." set_defaults while [ true ]; do Modified: stable/12/share/man/man8/picobsd.8 ============================================================================== --- stable/12/share/man/man8/picobsd.8 Thu Oct 24 21:28:37 2019 (r354050) +++ stable/12/share/man/man8/picobsd.8 Thu Oct 24 21:43:01 2019 (r354051) @@ -1,6 +1,6 @@ .\" -*- nroff-fill -*- .\" $FreeBSD$ -.Dd October 1, 2013 +.Dd October 20, 2019 .Dt PICOBSD 8 .Os .Sh NAME @@ -11,6 +11,10 @@ .Op Ar options .Op Ar config-name Op Ar site-name .Sh DESCRIPTION +.Nm +is deprecated and will be removed in +.Fx 13.0 . +.Pp The .Nm utility is a script which produces a minimal implementation of From owner-svn-src-stable-12@freebsd.org Fri Oct 25 00:16:58 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 49A9E15EA45; Fri, 25 Oct 2019 00:16:58 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zl6L1FxSz3KcW; Fri, 25 Oct 2019 00:16:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0FE031E31E; Fri, 25 Oct 2019 00:16:58 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9P0GvhS084683; Fri, 25 Oct 2019 00:16:57 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9P0Gv24084681; Fri, 25 Oct 2019 00:16:57 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910250016.x9P0Gv24084681@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 00:16:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354058 - in stable: 11/sys/dev/acpica 11/sys/i386/pci 12/sys/dev/acpica 12/sys/i386/pci X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/dev/acpica 11/sys/i386/pci 12/sys/dev/acpica 12/sys/i386/pci X-SVN-Commit-Revision: 354058 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 00:16:58 -0000 Author: jhb Date: Fri Oct 25 00:16:57 2019 New Revision: 354058 URL: https://svnweb.freebsd.org/changeset/base/354058 Log: MFC 350662: Detect invalid PCI devices more correctly in PCI interrupt router drivers. - Check for an invalid device (vendor is invalid) before reading the header type register when examining function 0 of a possible device. - When iterating over functions of a device, reject any device whose 16-bit vendor is invalid rather than requiring the full 32-bit vendor+device to be all 1's. In practice the latter check is probably fine, but checking the vendor is what the PCI spec recommends. Modified: stable/12/sys/dev/acpica/acpi_pci_link.c stable/12/sys/i386/pci/pci_pir.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/acpica/acpi_pci_link.c stable/11/sys/i386/pci/pci_pir.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/acpica/acpi_pci_link.c ============================================================================== --- stable/12/sys/dev/acpica/acpi_pci_link.c Thu Oct 24 22:34:48 2019 (r354057) +++ stable/12/sys/dev/acpica/acpi_pci_link.c Fri Oct 25 00:16:57 2019 (r354058) @@ -577,6 +577,9 @@ acpi_pci_link_search_irq(int bus, int device, int pin) uint8_t func, maxfunc; /* See if we have a valid device at function 0. */ + value = pci_cfgregread(bus, device, 0, PCIR_VENDOR, 2); + if (value == PCIV_INVALID) + return (PCI_INVALID_IRQ); value = pci_cfgregread(bus, device, 0, PCIR_HDRTYPE, 1); if ((value & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) return (PCI_INVALID_IRQ); @@ -587,8 +590,8 @@ acpi_pci_link_search_irq(int bus, int device, int pin) /* Scan all possible functions at this device. */ for (func = 0; func <= maxfunc; func++) { - value = pci_cfgregread(bus, device, func, PCIR_DEVVENDOR, 4); - if (value == 0xffffffff) + value = pci_cfgregread(bus, device, func, PCIR_VENDOR, 2); + if (value == PCIV_INVALID) continue; value = pci_cfgregread(bus, device, func, PCIR_INTPIN, 1); Modified: stable/12/sys/i386/pci/pci_pir.c ============================================================================== --- stable/12/sys/i386/pci/pci_pir.c Thu Oct 24 22:34:48 2019 (r354057) +++ stable/12/sys/i386/pci/pci_pir.c Fri Oct 25 00:16:57 2019 (r354058) @@ -257,8 +257,8 @@ pci_pir_create_links(struct PIR_entry *entry, struct P } /* - * Look to see if any of the function on the PCI device at bus/device have - * an interrupt routed to intpin 'pin' by the BIOS. + * Look to see if any of the functions on the PCI device at bus/device + * have an interrupt routed to intpin 'pin' by the BIOS. */ static uint8_t pci_pir_search_irq(int bus, int device, int pin) @@ -267,6 +267,9 @@ pci_pir_search_irq(int bus, int device, int pin) uint8_t func, maxfunc; /* See if we have a valid device at function 0. */ + value = pci_cfgregread(bus, device, 0, PCIR_VENDOR, 2); + if (value == PCIV_INVALID) + return (PCI_INVALID_IRQ); value = pci_cfgregread(bus, device, 0, PCIR_HDRTYPE, 1); if ((value & PCIM_HDRTYPE) > PCI_MAXHDRTYPE) return (PCI_INVALID_IRQ); @@ -277,8 +280,8 @@ pci_pir_search_irq(int bus, int device, int pin) /* Scan all possible functions at this device. */ for (func = 0; func <= maxfunc; func++) { - value = pci_cfgregread(bus, device, func, PCIR_DEVVENDOR, 4); - if (value == 0xffffffff) + value = pci_cfgregread(bus, device, func, PCIR_VENDOR, 2); + if (value == PCIV_INVALID) continue; value = pci_cfgregread(bus, device, func, PCIR_INTPIN, 1); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 00:47:39 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 43AF915F207; Fri, 25 Oct 2019 00:47:39 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zlnl1862z3LhL; Fri, 25 Oct 2019 00:47:39 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0A8031E85D; Fri, 25 Oct 2019 00:47:39 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9P0lcdn001931; Fri, 25 Oct 2019 00:47:38 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9P0lcnq001929; Fri, 25 Oct 2019 00:47:38 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910250047.x9P0lcnq001929@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 25 Oct 2019 00:47:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354059 - in stable: 11/stand/lua 12/stand/lua X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable: 11/stand/lua 12/stand/lua X-SVN-Commit-Revision: 354059 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 00:47:39 -0000 Author: kevans Date: Fri Oct 25 00:47:37 2019 New Revision: 354059 URL: https://svnweb.freebsd.org/changeset/base/354059 Log: MFC r353872-r353873: lualoader color handling fixes r353872: lualoader: don't botch disabling of color When colors are disabled, color.escape{fg,bg} would return the passed in color rather than the proper ANSI sequence for the color. color.escape{fg,bg} would be wrong. Instead return '', as the associated reset* functions will also return ''. This should get rid of the funky '2' and '4' in the kernel selector if you're booting serial. r353873: lualoader: fix setting of loader_color=NO in loader.conf(5) Previously color.disabled would be calculated at color module load time, then never touched again. We can detect serial boots beyond just what we're told by loader.conf(5) so this works out in many cases, but we must re-evaluate the situation after the config is loaded to make sure we're not supposed to be forcing it enabled/disabled. Discovered while trying to test r353872. Modified: stable/12/stand/lua/color.lua stable/12/stand/lua/screen.lua Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/stand/lua/color.lua stable/11/stand/lua/screen.lua Directory Properties: stable/11/ (props changed) Modified: stable/12/stand/lua/color.lua ============================================================================== --- stable/12/stand/lua/color.lua Fri Oct 25 00:16:57 2019 (r354058) +++ stable/12/stand/lua/color.lua Fri Oct 25 00:47:37 2019 (r354059) @@ -29,9 +29,14 @@ -- local core = require("core") +local hook = require("hook") local color = {} +local function recalcDisabled() + color.disabled = not color.isEnabled() +end + -- Module exports color.BLACK = 0 color.RED = 1 @@ -54,11 +59,9 @@ function color.isEnabled() return not core.isSerialBoot() end -color.disabled = not color.isEnabled() - function color.escapefg(color_value) if color.disabled then - return color_value + return '' end return core.KEYSTR_CSI .. "3" .. color_value .. "m" end @@ -72,7 +75,7 @@ end function color.escapebg(color_value) if color.disabled then - return color_value + return '' end return core.KEYSTR_CSI .. "4" .. color_value .. "m" end @@ -112,5 +115,8 @@ function color.highlight(str) -- case the terminal defaults don't match what we're expecting. return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m" end + +recalcDisabled() +hook.register("config.loaded", recalcDisabled) return color Modified: stable/12/stand/lua/screen.lua ============================================================================== --- stable/12/stand/lua/screen.lua Fri Oct 25 00:16:57 2019 (r354058) +++ stable/12/stand/lua/screen.lua Fri Oct 25 00:47:37 2019 (r354059) @@ -47,14 +47,14 @@ end function screen.setforeground(color_value) if color.disabled then - return color_value + return end printc(color.escapefg(color_value)) end function screen.setbackground(color_value) if color.disabled then - return color_value + return end printc(color.escapebg(color_value)) end From owner-svn-src-stable-12@freebsd.org Fri Oct 25 01:10:13 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6F33D15F973; Fri, 25 Oct 2019 01:10:13 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zmHn31djz3Mmp; Fri, 25 Oct 2019 01:10:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4A6E81EBF7; Fri, 25 Oct 2019 01:10:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9P1AD8Y014130; Fri, 25 Oct 2019 01:10:13 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9P1A8bl014107; Fri, 25 Oct 2019 01:10:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910250110.x9P1A8bl014107@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 25 Oct 2019 01:10:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354060 - in stable/12: . sbin/ifconfig share/man/man4 sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules sys/modules/if_tap sys/modules/if_tun ... X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12: . sbin/ifconfig share/man/man4 sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/conf sys/mips/conf sys/modules sys/modules/if_tap sys/modules/if_tun sys/modules/if_tuntap sys... X-SVN-Commit-Revision: 354060 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 01:10:13 -0000 Author: kevans Date: Fri Oct 25 01:10:08 2019 New Revision: 354060 URL: https://svnweb.freebsd.org/changeset/base/354060 Log: MFC tun/tap merge: r347241, r347394, r347404, r347483, r351220, r351229, r352148, r353056-r353057, r353781-r353782, r353785-r353786, r353877 Note: A little more than just the tun/tap merge has been MFC'd to ease auditing correctness/differences, as some later commits were cherry-picked back to tun+tap. r347241: tun/tap: merge and rename to `tuntap` tun(4) and tap(4) share the same general management interface and have a lot in common. Bugs exist in tap(4) that have been fixed in tun(4), and vice-versa. Let's reduce the maintenance requirements by merging them together and using flags to differentiate between the three interface types (tun, tap, vmnet). This fixes a couple of tap(4)/vmnet(4) issues right out of the gate: - tap devices may no longer be destroyed while they're open [0] - VIMAGE issues already addressed in tun by kp [0] emaste had removed an easy-panic-button in r240938 due to devdrn blocking. A naive glance over this leads me to believe that this isn't quite complete -- destroy_devl will only block while executing d_* functions, but doesn't block the device from being destroyed while a process has it open. The latter is the intent of the condvar in tun, so this is "fixed" (for certain definitions of the word -- it wasn't really broken in tap, it just wasn't quite ideal). ifconfig(8) also grew the ability to map an interface name to a kld, so that `ifconfig {tun,tap}0` can continue to autoload the correct module, and `ifconfig vmnet0 create` will now autoload the correct module. This is a low overhead addition. r347394: tuntap: Properly detach tap ifp r347404: tuntap: Don't down tap interfaces if LINK0 is set r347483: tuntap: Improve style No functional change. tun_flags of the tuntap_driver was renamed to ident_flags to reflect the fact that it's a subset of the tun_flags that identifies a tuntap device. This maps more easily (visually) to the TUN_DRIVER_IDENT_MASK that masks off the bits of tun_flags that are applicable to tuntap driver ident. This is a purely cosmetic change. r351220: if_tuntap: minor improvements Rewrite a loop to avoid duplicating the exit condition. Simplify mask processing in tunpoll(). Fix minor typos. r351229: tuntap: belatedly add MODULE_VERSION for if_tun and if_tap When tun/tap were merged, appropriate MODULE_VERSION should have been added for things like modfind(2) to continue to do the right thing with the old names. r352148: Remove empty tap/tun modules directories after r347241 r353056: if_tuntap: add a busy/unbusy mechanism, replace destroy OPEN check A future commit will create device aliases when a tuntap device is renamed so that it's still easily found in /dev after the rename. Said mechanism will want to keep the tun alive long enough to either realize that it's about to go away or complete the alias creation, even if the alias is about to get destroyed. While we're introducing it, using it to prevent open devices from going away makes plenty of sense and keeps the logic on waking up tun_destroy clean, so we don't have multiple places trying to cv_broadcast unless it's still in use elsewhere. r353057: if_tuntap: create /dev aliases when a tuntap device gets renamed Currently, if you do: $ ifconfig tun0 create $ ifconfig tun0 name wg0 $ ls -l /dev | egrep 'wg|tun' You will see tun0, but no wg0. In fact, it's slightly more annoying to make the association between the new name and the old name in order to open the device (if it hadn't been opened during the rename). Register an eventhandler for ifnet_arrival_events and catch interface renames. We can determine if the ifnet is a tun easily enough from the if_dname, which matches the cevsw.d_name from the associated tuntap_driver. Some locking dance is required because renames don't require the device to be opened, so it could go away in the middle of handling the ioctl, but as soon as we've verified this isn't the case we can attempt to busy the tun and either bail out if the tun device is dying, or we can proceed with the rename. We only create these aliases on a best-effort basis. Renaming a tun device to "usbctl", which doesn't exist as an ifnet but does as a /dev, is clearly not that disastrous, but we can't and won't create a /dev for that. r353781: tuntap(4): Drop TUN_IASET This flag appears to have been effectively unused since introduction to if_tun(4) -- drop it now. r353782: tuntap(4): break out after setting TUN_DSTADDR This is now the only flag we set in this loop, terminate early. r353785: tuntap(4): Use make_dev_s to avoid si_drv1 race This allows us to avoid some dance in tunopen for dealing with the possibility of dev->si_drv1 being NULL as it's set prior to the devfs node being created in all cases. There's still the possibility that the tun device hasn't been fully initialized, since that's done after the devfs node was created. Alleviate this by returning ENXIO if we're not to that point of tuncreate yet. This work is what sparked r353128, full initialization of cloned devices w/ specified make_dev_args. r353786: tuntap(4): use cdevpriv w/ dtor for last close instead of d_close cdevpriv dtors will be called when the reference count on the associated struct file drops to 0, while d_close can be unreliable for cleaning up state at "last close" for a number of reasons. As far as tunclose/tundtor is concerned the difference is minimal, so make the switch. r353877: tuntap(4): properly declare if_tun and if_tap modules Simply adding MODULE_VERSION does not do the trick, because the modules haven't been declared. This should actually fix modfind/kldstat, which r351229 aimed and failed to do. This should make vm-bhyve do the right thing again when using the ports version, rather than the latest version not in ports. Relnotes: yes Added: stable/12/sys/modules/if_tuntap/ - copied from r347241, head/sys/modules/if_tuntap/ stable/12/sys/net/if_tuntap.c - copied, changed from r354059, stable/12/sys/net/if_tun.c Deleted: stable/12/sys/modules/if_tap/ stable/12/sys/modules/if_tun/ stable/12/sys/net/if_tap.c stable/12/sys/net/if_tapvar.h stable/12/sys/net/if_tun.c Modified: stable/12/UPDATING stable/12/sbin/ifconfig/ifconfig.c stable/12/share/man/man4/tap.4 stable/12/share/man/man4/tun.4 stable/12/sys/amd64/conf/GENERIC stable/12/sys/amd64/conf/MINIMAL stable/12/sys/arm/conf/DOCKSTAR stable/12/sys/arm/conf/DREAMPLUG-1001 stable/12/sys/arm/conf/EFIKA_MX stable/12/sys/arm/conf/IMX53 stable/12/sys/arm/conf/IMX6 stable/12/sys/arm/conf/TEGRA124 stable/12/sys/arm64/conf/GENERIC stable/12/sys/conf/NOTES stable/12/sys/conf/files stable/12/sys/i386/conf/GENERIC stable/12/sys/mips/conf/ERL stable/12/sys/mips/conf/OCTEON1 stable/12/sys/modules/Makefile stable/12/sys/modules/if_tuntap/Makefile stable/12/sys/net/if_tap.h stable/12/sys/powerpc/conf/GENERIC stable/12/sys/powerpc/conf/GENERIC64 stable/12/sys/powerpc/conf/MPC85XX stable/12/sys/powerpc/conf/MPC85XXSPE stable/12/sys/powerpc/conf/QORIQ64 stable/12/sys/riscv/conf/GENERIC stable/12/sys/sparc64/conf/GENERIC Directory Properties: stable/12/ (props changed) Modified: stable/12/UPDATING ============================================================================== --- stable/12/UPDATING Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/UPDATING Fri Oct 25 01:10:08 2019 (r354060) @@ -16,6 +16,14 @@ from older versions of FreeBSD, try WITHOUT_CLANG and the tip of head, and then rebuild without this option. The bootstrap process from older version of current across the gcc/clang cutover is a bit fragile. +20191024: + The tap(4) driver has been folded into tun(4), and the module has been + renamed to tuntap. You should update any kld_load="if_tap" or + kld_load="if_tun" entries in /etc/rc.conf, if_tap_load="YES" or + if_tun_load="YES" entries in /boot/loader.conf to load the if_tuntap + module instead, and "device tap" or "device tun" entries in kernel + config files to select the tuntap device instead. + 20190913: ntpd no longer by default locks its pages in memory, allowing them to be paged out by the kernel. Use rlimit memlock to restore Modified: stable/12/sbin/ifconfig/ifconfig.c ============================================================================== --- stable/12/sbin/ifconfig/ifconfig.c Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sbin/ifconfig/ifconfig.c Fri Oct 25 01:10:08 2019 (r354060) @@ -136,8 +136,16 @@ static struct module_map_entry { const char *kldname; } module_map[] = { { + .ifname = "tun", + .kldname = "if_tuntap", + }, + { + .ifname = "tap", + .kldname = "if_tuntap", + }, + { .ifname = "vmnet", - .kldname = "if_tap", + .kldname = "if_tuntap", }, { .ifname = "ipsec", Modified: stable/12/share/man/man4/tap.4 ============================================================================== --- stable/12/share/man/man4/tap.4 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/share/man/man4/tap.4 Fri Oct 25 01:10:08 2019 (r354060) @@ -1,14 +1,14 @@ .\" $FreeBSD$ .\" Based on PR#2411 .\" -.Dd November 29, 2017 +.Dd April 29, 2019 .Dt TAP 4 .Os .Sh NAME .Nm tap .Nd Ethernet tunnel software network interface .Sh SYNOPSIS -.Cd device tap +.Cd device tuntap .Sh DESCRIPTION The .Nm @@ -51,7 +51,7 @@ The network interfaces are named .Dq Li tap1 , etc., one for each control device that has been opened. These Ethernet network interfaces persist until -.Pa if_tap.ko +.Pa if_tuntap.ko module is unloaded, or until removed with "ifconfig destroy" (see below). .Pp .Nm @@ -96,7 +96,7 @@ It therefore defaults to being enabled until further n .Ef .Pp Control devices (once successfully opened) persist until -.Pa if_tap.ko +.Pa if_tuntap.ko is unloaded or the interface is destroyed. .Pp Each interface supports the usual Ethernet network interface @@ -296,27 +296,6 @@ device can also be used with the VMware port as a repl for the old .Em VMnet device driver. -The driver uses the minor number -to select between -.Nm -and -.Nm vmnet -devices. -.Em VMnet -minor numbers begin at -.Va 0x800000 -+ -.Va N ; -where -.Va N -is a -.Em VMnet -unit number. -In this case the control device is expected to be -.Pa /dev/vmnet Ns Sy N , -and the network interface will be -.Sy vmnet Ns Ar N . -Additionally, .Em VMnet devices do not .Xr ifconfig 8 Modified: stable/12/share/man/man4/tun.4 ============================================================================== --- stable/12/share/man/man4/tun.4 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/share/man/man4/tun.4 Fri Oct 25 01:10:08 2019 (r354060) @@ -2,14 +2,14 @@ .\" $FreeBSD$ .\" Based on PR#2411 .\" -.Dd November 29, 2017 +.Dd April 29, 2019 .Dt TUN 4 .Os .Sh NAME .Nm tun .Nd tunnel software network interface .Sh SYNOPSIS -.Cd device tun +.Cd device tuntap .Sh DESCRIPTION The .Nm @@ -52,7 +52,7 @@ The network interfaces are named .Dq Li tun1 , etc., one for each control device that has been opened. These network interfaces persist until the -.Pa if_tun.ko +.Pa if_tuntap.ko module is unloaded, or until removed with the .Xr ifconfig 8 command. @@ -99,7 +99,7 @@ It therefore defaults to being enabled until further n .Ef .Pp Control devices (once successfully opened) persist until -.Pa if_tun.ko +.Pa if_tuntap.ko is unloaded in the same way that network interfaces persist (see above). .Pp Each interface supports the usual network-interface Modified: stable/12/sys/amd64/conf/GENERIC ============================================================================== --- stable/12/sys/amd64/conf/GENERIC Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/amd64/conf/GENERIC Fri Oct 25 01:10:08 2019 (r354060) @@ -308,7 +308,7 @@ device padlock_rng # VIA Padlock RNG device rdrand_rng # Intel Bull Mountain RNG device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/amd64/conf/MINIMAL ============================================================================== --- stable/12/sys/amd64/conf/MINIMAL Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/amd64/conf/MINIMAL Fri Oct 25 01:10:08 2019 (r354060) @@ -125,7 +125,7 @@ device padlock_rng # VIA Padlock RNG device rdrand_rng # Intel Bull Mountain RNG device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device gif # IPv6 and IPv4 tunneling # The `bpf' device enables the Berkeley Packet Filter. Modified: stable/12/sys/arm/conf/DOCKSTAR ============================================================================== --- stable/12/sys/arm/conf/DOCKSTAR Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/DOCKSTAR Fri Oct 25 01:10:08 2019 (r354060) @@ -69,7 +69,7 @@ device loop # Network loopback device md # Memory/malloc disk device pty # BSD-style compatibility pseudo ttys device random # Entropy device -device tun # Packet tunnel. +device tuntap # Packet tunnel. device ether # Required for all ethernet devices device vlan # 802.1Q VLAN support device wlan # 802.11 WLAN support Modified: stable/12/sys/arm/conf/DREAMPLUG-1001 ============================================================================== --- stable/12/sys/arm/conf/DREAMPLUG-1001 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/DREAMPLUG-1001 Fri Oct 25 01:10:08 2019 (r354060) @@ -72,7 +72,7 @@ device loop # Network loopback device md # Memory/malloc disk device pty # BSD-style compatibility pseudo ttys device random # Entropy device -device tun # Packet tunnel. +device tuntap # Packet tunnel. device ether # Required for all ethernet devices device vlan # 802.1Q VLAN support device wlan # 802.11 WLAN support Modified: stable/12/sys/arm/conf/EFIKA_MX ============================================================================== --- stable/12/sys/arm/conf/EFIKA_MX Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/EFIKA_MX Fri Oct 25 01:10:08 2019 (r354060) @@ -60,7 +60,7 @@ device loop # Network loopback device random # Entropy device device ether # Ethernet support #device vlan # 802.1Q VLAN support -#device tun # Packet tunnel. +#device tuntap # Packet tunnel. #device md # Memory "disks" #device gif # IPv6 and IPv4 tunneling #device firmware # firmware assist module Modified: stable/12/sys/arm/conf/IMX53 ============================================================================== --- stable/12/sys/arm/conf/IMX53 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/IMX53 Fri Oct 25 01:10:08 2019 (r354060) @@ -47,7 +47,7 @@ device loop # Network loopback device random # Entropy device device ether # Ethernet support #device vlan # 802.1Q VLAN support -#device tun # Packet tunnel. +#device tuntap # Packet tunnel. device md # Memory "disks" #device gif # IPv6 and IPv4 tunneling #device firmware # firmware assist module Modified: stable/12/sys/arm/conf/IMX6 ============================================================================== --- stable/12/sys/arm/conf/IMX6 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/IMX6 Fri Oct 25 01:10:08 2019 (r354060) @@ -51,7 +51,7 @@ device mpcore_timer device loop # Network loopback device random # Entropy device device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" #device gif # IPv6 and IPv4 tunneling #device firmware # firmware assist module Modified: stable/12/sys/arm/conf/TEGRA124 ============================================================================== --- stable/12/sys/arm/conf/TEGRA124 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm/conf/TEGRA124 Fri Oct 25 01:10:08 2019 (r354060) @@ -45,7 +45,7 @@ device regulator device loop # Network loopback device random # Entropy device device vlan # 802.1Q VLAN support -#device tun # Packet tunnel. +#device tuntap # Packet tunnel. device md # Memory "disks" #device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/arm64/conf/GENERIC ============================================================================== --- stable/12/sys/arm64/conf/GENERIC Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/arm64/conf/GENERIC Fri Oct 25 01:10:08 2019 (r354060) @@ -271,7 +271,7 @@ device loop # Network loopback device random # Entropy device device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/conf/NOTES ============================================================================== --- stable/12/sys/conf/NOTES Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/conf/NOTES Fri Oct 25 01:10:08 2019 (r354060) @@ -895,11 +895,9 @@ device epair # which discards all packets sent and receives none. device edsc -# The `tap' device is a pty-like virtual Ethernet interface -device tap - -# The `tun' device implements (user-)ppp and nos-tun(8) -device tun +# The `tuntap' device implements (user-)ppp, nos-tun(8) and a pty-like virtual +# Ethernet interface +device tuntap # The `gif' device implements IPv6 over IP4 tunneling, # IPv4 over IPv6 tunneling, IPv4 over IPv4 tunneling and Modified: stable/12/sys/conf/files ============================================================================== --- stable/12/sys/conf/files Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/conf/files Fri Oct 25 01:10:08 2019 (r354060) @@ -4152,8 +4152,7 @@ net/if_mib.c standard net/if_spppfr.c optional sppp | netgraph_sppp net/if_spppsubr.c optional sppp | netgraph_sppp net/if_stf.c optional stf inet inet6 -net/if_tun.c optional tun -net/if_tap.c optional tap +net/if_tuntap.c optional tuntap net/if_vlan.c optional vlan net/if_vxlan.c optional vxlan inet | vxlan inet6 net/ifdi_if.m optional ether pci iflib Modified: stable/12/sys/i386/conf/GENERIC ============================================================================== --- stable/12/sys/i386/conf/GENERIC Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/i386/conf/GENERIC Fri Oct 25 01:10:08 2019 (r354060) @@ -309,7 +309,7 @@ device padlock_rng # VIA Padlock RNG device rdrand_rng # Intel Bull Mountain RNG device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/mips/conf/ERL ============================================================================== --- stable/12/sys/mips/conf/ERL Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/mips/conf/ERL Fri Oct 25 01:10:08 2019 (r354060) @@ -151,7 +151,7 @@ device loop # Network loopback device random # Entropy device device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/mips/conf/OCTEON1 ============================================================================== --- stable/12/sys/mips/conf/OCTEON1 Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/mips/conf/OCTEON1 Fri Oct 25 01:10:08 2019 (r354060) @@ -256,7 +256,7 @@ device loop # Network loopback device random # Entropy device device ether # Ethernet support device vlan # 802.1Q VLAN support -device tun # Packet tunnel. +device tuntap # Packet tunnel. device md # Memory "disks" device gif # IPv6 and IPv4 tunneling device firmware # firmware assist module Modified: stable/12/sys/modules/Makefile ============================================================================== --- stable/12/sys/modules/Makefile Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/modules/Makefile Fri Oct 25 01:10:08 2019 (r354060) @@ -170,8 +170,7 @@ SUBDIR= \ if_lagg \ ${_if_ndis} \ ${_if_stf} \ - if_tap \ - if_tun \ + if_tuntap \ if_vlan \ if_vxlan \ iflib \ Modified: stable/12/sys/modules/if_tuntap/Makefile ============================================================================== --- head/sys/modules/if_tuntap/Makefile Wed May 8 02:32:11 2019 (r347241) +++ stable/12/sys/modules/if_tuntap/Makefile Fri Oct 25 01:10:08 2019 (r354060) @@ -31,5 +31,4 @@ alias_debug: .PHONY .endif .endif - .include Modified: stable/12/sys/net/if_tap.h ============================================================================== --- stable/12/sys/net/if_tap.h Fri Oct 25 00:47:37 2019 (r354059) +++ stable/12/sys/net/if_tap.h Fri Oct 25 01:10:08 2019 (r354060) @@ -40,24 +40,22 @@ #ifndef _NET_IF_TAP_H_ #define _NET_IF_TAP_H_ -/* refer to if_tapvar.h for the softc stuff */ +#include /* maximum receive packet size (hard limit) */ #define TAPMRU 16384 -struct tapinfo { - int baudrate; /* linespeed */ - short mtu; /* maximum transmission unit */ - u_char type; /* ethernet, tokenring, etc. */ - u_char dummy; /* place holder */ -}; +#define tapinfo tuninfo -/* ioctl's for get/set debug */ -#define TAPSDEBUG _IOW('t', 90, int) -#define TAPGDEBUG _IOR('t', 89, int) -#define TAPSIFINFO _IOW('t', 91, struct tapinfo) -#define TAPGIFINFO _IOR('t', 92, struct tapinfo) -#define TAPGIFNAME _IOR('t', 93, struct ifreq) +/* + * ioctl's for get/set debug; these are aliases of TUN* ioctls, see net/if_tun.h + * for details. + */ +#define TAPSDEBUG TUNSDEBUG +#define TAPGDEBUG TUNGDEBUG +#define TAPSIFINFO TUNSIFINFO +#define TAPGIFINFO TUNGIFINFO +#define TAPGIFNAME TUNGIFNAME /* VMware ioctl's */ #define VMIO_SIOCSIFFLAGS _IOWINT('V', 0) Copied and modified: stable/12/sys/net/if_tuntap.c (from r354059, stable/12/sys/net/if_tun.c) ============================================================================== --- stable/12/sys/net/if_tun.c Fri Oct 25 00:47:37 2019 (r354059, copy source) +++ stable/12/sys/net/if_tuntap.c Fri Oct 25 01:10:08 2019 (r354060) @@ -1,6 +1,36 @@ /* $NetBSD: if_tun.c,v 1.14 1994/06/29 06:36:25 cgd Exp $ */ - /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (C) 1999-2000 by Maksim Yevmenkin + * All rights reserved. + * Copyright (c) 2019 Kyle Evans + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * BASED ON: + * ------------------------------------------------------------------------- + * * Copyright (c) 1988, Julian Onions * Nottingham University 1987. * @@ -46,9 +76,12 @@ #include #include +#include #include #include #include +#include +#include #include #include #include @@ -57,89 +90,131 @@ #include #endif #include +#include #include #include #include - #include +struct tuntap_driver; + /* * tun_list is protected by global tunmtx. Other mutable fields are * protected by tun->tun_mtx, or by their owning subsystem. tun_dev is * static for the duration of a tunnel interface. */ -struct tun_softc { - TAILQ_ENTRY(tun_softc) tun_list; - struct cdev *tun_dev; - u_short tun_flags; /* misc flags */ +struct tuntap_softc { + TAILQ_ENTRY(tuntap_softc) tun_list; + struct cdev *tun_alias; + struct cdev *tun_dev; + u_short tun_flags; /* misc flags */ #define TUN_OPEN 0x0001 #define TUN_INITED 0x0002 -#define TUN_RCOLL 0x0004 -#define TUN_IASET 0x0008 +#define TUN_UNUSED1 0x0008 #define TUN_DSTADDR 0x0010 #define TUN_LMODE 0x0020 #define TUN_RWAIT 0x0040 #define TUN_ASYNC 0x0080 #define TUN_IFHEAD 0x0100 #define TUN_DYING 0x0200 +#define TUN_L2 0x0400 +#define TUN_VMNET 0x0800 -#define TUN_READY (TUN_OPEN | TUN_INITED) +#define TUN_DRIVER_IDENT_MASK (TUN_L2 | TUN_VMNET) +#define TUN_READY (TUN_OPEN | TUN_INITED) - pid_t tun_pid; /* owning pid */ - struct ifnet *tun_ifp; /* the interface */ - struct sigio *tun_sigio; /* information for async I/O */ - struct selinfo tun_rsel; /* read select */ - struct mtx tun_mtx; /* protect mutable softc fields */ - struct cv tun_cv; /* protect against ref'd dev destroy */ + pid_t tun_pid; /* owning pid */ + struct ifnet *tun_ifp; /* the interface */ + struct sigio *tun_sigio; /* async I/O info */ + struct tuntap_driver *tun_drv; /* appropriate driver */ + struct selinfo tun_rsel; /* read select */ + struct mtx tun_mtx; /* softc field mutex */ + struct cv tun_cv; /* for ref'd dev destroy */ + struct ether_addr tun_ether; /* remote address */ + int tun_busy; /* busy count */ }; -#define TUN2IFP(sc) ((sc)->tun_ifp) +#define TUN2IFP(sc) ((sc)->tun_ifp) -#define TUNDEBUG if (tundebug) if_printf +#define TUNDEBUG if (tundebug) if_printf +#define TUN_LOCK(tp) mtx_lock(&(tp)->tun_mtx) +#define TUN_UNLOCK(tp) mtx_unlock(&(tp)->tun_mtx) +#define TUN_LOCK_ASSERT(tp) mtx_assert(&(tp)->tun_mtx, MA_OWNED); + +#define TUN_VMIO_FLAG_MASK 0x0fff + /* * All mutable global variables in if_tun are locked using tunmtx, with - * the exception of tundebug, which is used unlocked, and tunclones, - * which is static after setup. + * the exception of tundebug, which is used unlocked, and the drivers' *clones, + * which are static after setup. */ static struct mtx tunmtx; -static eventhandler_tag tag; +static eventhandler_tag arrival_tag; +static eventhandler_tag clone_tag; static const char tunname[] = "tun"; +static const char tapname[] = "tap"; +static const char vmnetname[] = "vmnet"; static MALLOC_DEFINE(M_TUN, tunname, "Tunnel Interface"); static int tundebug = 0; static int tundclone = 1; -static struct clonedevs *tunclones; -static TAILQ_HEAD(,tun_softc) tunhead = TAILQ_HEAD_INITIALIZER(tunhead); +static int tap_allow_uopen = 0; /* allow user open() */ +static int tapuponopen = 0; /* IFF_UP on open() */ +static int tapdclone = 1; /* enable devfs cloning */ + +static TAILQ_HEAD(,tuntap_softc) tunhead = TAILQ_HEAD_INITIALIZER(tunhead); SYSCTL_INT(_debug, OID_AUTO, if_tun_debug, CTLFLAG_RW, &tundebug, 0, ""); static struct sx tun_ioctl_sx; SX_SYSINIT(tun_ioctl_sx, &tun_ioctl_sx, "tun_ioctl"); SYSCTL_DECL(_net_link); +/* tun */ static SYSCTL_NODE(_net_link, OID_AUTO, tun, CTLFLAG_RW, 0, - "IP tunnel software network interface."); + "IP tunnel software network interface"); SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tundclone, 0, - "Enable legacy devfs interface creation."); + "Enable legacy devfs interface creation"); +/* tap */ +static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0, + "Ethernet tunnel software network interface"); +SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tap_allow_uopen, 0, + "Allow user to open /dev/tap (based on node permissions)"); +SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0, + "Bring interface up when /dev/tap is opened"); +SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 0, + "Enable legacy devfs interface creation"); +SYSCTL_INT(_net_link_tap, OID_AUTO, debug, CTLFLAG_RW, &tundebug, 0, ""); + +static int tun_create_device(struct tuntap_driver *drv, int unit, + struct ucred *cr, struct cdev **dev, const char *name); +static int tun_busy_locked(struct tuntap_softc *tp); +static void tun_unbusy_locked(struct tuntap_softc *tp); +static int tun_busy(struct tuntap_softc *tp); +static void tun_unbusy(struct tuntap_softc *tp); + +static int tuntap_name2info(const char *name, int *unit, int *flags); static void tunclone(void *arg, struct ucred *cred, char *name, int namelen, struct cdev **dev); -static void tuncreate(const char *name, struct cdev *dev); +static void tuncreate(struct cdev *dev); +static void tundtor(void *data); +static void tunrename(void *arg, struct ifnet *ifp); static int tunifioctl(struct ifnet *, u_long, caddr_t); static void tuninit(struct ifnet *); -static int tunmodevent(module_t, int, void *); +static void tunifinit(void *xtp); +static int tuntapmodevent(module_t, int, void *); static int tunoutput(struct ifnet *, struct mbuf *, const struct sockaddr *, struct route *ro); static void tunstart(struct ifnet *); +static void tunstart_l2(struct ifnet *); static int tun_clone_match(struct if_clone *ifc, const char *name); +static int tap_clone_match(struct if_clone *ifc, const char *name); +static int vmnet_clone_match(struct if_clone *ifc, const char *name); static int tun_clone_create(struct if_clone *, char *, size_t, caddr_t); static int tun_clone_destroy(struct if_clone *, struct ifnet *); -static struct unrhdr *tun_unrhdr; -VNET_DEFINE_STATIC(struct if_clone *, tun_cloner); -#define V_tun_cloner VNET(tun_cloner) static d_open_t tunopen; -static d_close_t tunclose; static d_read_t tunread; static d_write_t tunwrite; static d_ioctl_t tunioctl; @@ -164,59 +239,295 @@ static struct filterops tun_write_filterops = { .f_event = tunkqwrite, }; -static struct cdevsw tun_cdevsw = { - .d_version = D_VERSION, - .d_flags = D_NEEDMINOR, - .d_open = tunopen, - .d_close = tunclose, - .d_read = tunread, - .d_write = tunwrite, - .d_ioctl = tunioctl, - .d_poll = tunpoll, - .d_kqfilter = tunkqfilter, - .d_name = tunname, +static struct tuntap_driver { + struct cdevsw cdevsw; + int ident_flags; + struct unrhdr *unrhdr; + struct clonedevs *clones; + ifc_match_t *clone_match_fn; + ifc_create_t *clone_create_fn; + ifc_destroy_t *clone_destroy_fn; +} tuntap_drivers[] = { + { + .ident_flags = 0, + .cdevsw = { + .d_version = D_VERSION, + .d_flags = D_NEEDMINOR, + .d_open = tunopen, + .d_read = tunread, + .d_write = tunwrite, + .d_ioctl = tunioctl, + .d_poll = tunpoll, + .d_kqfilter = tunkqfilter, + .d_name = tunname, + }, + .clone_match_fn = tun_clone_match, + .clone_create_fn = tun_clone_create, + .clone_destroy_fn = tun_clone_destroy, + }, + { + .ident_flags = TUN_L2, + .cdevsw = { + .d_version = D_VERSION, + .d_flags = D_NEEDMINOR, + .d_open = tunopen, + .d_read = tunread, + .d_write = tunwrite, + .d_ioctl = tunioctl, + .d_poll = tunpoll, + .d_kqfilter = tunkqfilter, + .d_name = tapname, + }, + .clone_match_fn = tap_clone_match, + .clone_create_fn = tun_clone_create, + .clone_destroy_fn = tun_clone_destroy, + }, + { + .ident_flags = TUN_L2 | TUN_VMNET, + .cdevsw = { + .d_version = D_VERSION, + .d_flags = D_NEEDMINOR, + .d_open = tunopen, + .d_read = tunread, + .d_write = tunwrite, + .d_ioctl = tunioctl, + .d_poll = tunpoll, + .d_kqfilter = tunkqfilter, + .d_name = vmnetname, + }, + .clone_match_fn = vmnet_clone_match, + .clone_create_fn = tun_clone_create, + .clone_destroy_fn = tun_clone_destroy, + }, }; +struct tuntap_driver_cloner { + SLIST_ENTRY(tuntap_driver_cloner) link; + struct tuntap_driver *drv; + struct if_clone *cloner; +}; + +VNET_DEFINE_STATIC(SLIST_HEAD(, tuntap_driver_cloner), tuntap_driver_cloners) = + SLIST_HEAD_INITIALIZER(tuntap_driver_cloners); + +#define V_tuntap_driver_cloners VNET(tuntap_driver_cloners) + +/* + * Mechanism for marking a tunnel device as busy so that we can safely do some + * orthogonal operations (such as operations on devices) without racing against + * tun_destroy. tun_destroy will wait on the condvar if we're at all busy or + * open, to be woken up when the condition is alleviated. + */ static int +tun_busy_locked(struct tuntap_softc *tp) +{ + + TUN_LOCK_ASSERT(tp); + if ((tp->tun_flags & TUN_DYING) != 0) { + /* + * Perhaps unintuitive, but the device is busy going away. + * Other interpretations of EBUSY from tun_busy make little + * sense, since making a busy device even more busy doesn't + * sound like a problem. + */ + return (EBUSY); + } + + ++tp->tun_busy; + return (0); +} + +static void +tun_unbusy_locked(struct tuntap_softc *tp) +{ + + TUN_LOCK_ASSERT(tp); + KASSERT(tp->tun_busy != 0, ("tun_unbusy: called for non-busy tunnel")); + + --tp->tun_busy; + /* Wake up anything that may be waiting on our busy tunnel. */ + if (tp->tun_busy == 0) + cv_broadcast(&tp->tun_cv); +} + +static int +tun_busy(struct tuntap_softc *tp) +{ + int ret; + + TUN_LOCK(tp); + ret = tun_busy_locked(tp); + TUN_UNLOCK(tp); + return (ret); +} + + +static void +tun_unbusy(struct tuntap_softc *tp) +{ + + TUN_LOCK(tp); + tun_unbusy_locked(tp); + TUN_UNLOCK(tp); +} + +/* + * Sets unit and/or flags given the device name. Must be called with correct + * vnet context. + */ +static int +tuntap_name2info(const char *name, int *outunit, int *outflags) +{ + struct tuntap_driver *drv; + struct tuntap_driver_cloner *drvc; + char *dname; + int flags, unit; + bool found; + + if (name == NULL) + return (EINVAL); + + /* + * Needed for dev_stdclone, but dev_stdclone will not modify, it just + * wants to be able to pass back a char * through the second param. We + * will always set that as NULL here, so we'll fake it. + */ + dname = __DECONST(char *, name); + found = false; + + KASSERT(!SLIST_EMPTY(&V_tuntap_driver_cloners), + ("tuntap_driver_cloners failed to initialize")); + SLIST_FOREACH(drvc, &V_tuntap_driver_cloners, link) { + KASSERT(drvc->drv != NULL, + ("tuntap_driver_cloners entry not properly initialized")); + drv = drvc->drv; + + if (strcmp(name, drv->cdevsw.d_name) == 0) { + found = true; + unit = -1; + flags = drv->ident_flags; + break; + } + + if (dev_stdclone(dname, NULL, drv->cdevsw.d_name, &unit) == 1) { + found = true; + flags = drv->ident_flags; + break; + } + } + + if (!found) + return (ENXIO); + + if (outunit != NULL) + *outunit = unit; + if (outflags != NULL) + *outflags = flags; + return (0); +} + +/* + * Get driver information from a set of flags specified. Masks the identifying + * part of the flags and compares it against all of the available + * tuntap_drivers. Must be called with correct vnet context. + */ +static struct tuntap_driver * +tuntap_driver_from_flags(int tun_flags) +{ + struct tuntap_driver *drv; + struct tuntap_driver_cloner *drvc; + + KASSERT(!SLIST_EMPTY(&V_tuntap_driver_cloners), + ("tuntap_driver_cloners failed to initialize")); + SLIST_FOREACH(drvc, &V_tuntap_driver_cloners, link) { + KASSERT(drvc->drv != NULL, + ("tuntap_driver_cloners entry not properly initialized")); + drv = drvc->drv; + if ((tun_flags & TUN_DRIVER_IDENT_MASK) == drv->ident_flags) + return (drv); + } + + return (NULL); +} + + + +static int tun_clone_match(struct if_clone *ifc, const char *name) { - if (strncmp(tunname, name, 3) == 0 && - (name[3] == '\0' || isdigit(name[3]))) - return (1); + int tunflags; + if (tuntap_name2info(name, NULL, &tunflags) == 0) { + if ((tunflags & TUN_L2) == 0) + return (1); + } + return (0); } static int +tap_clone_match(struct if_clone *ifc, const char *name) +{ + int tunflags; + + if (tuntap_name2info(name, NULL, &tunflags) == 0) { + if ((tunflags & (TUN_L2 | TUN_VMNET)) == TUN_L2) + return (1); + } + + return (0); +} + +static int +vmnet_clone_match(struct if_clone *ifc, const char *name) +{ + int tunflags; + + if (tuntap_name2info(name, NULL, &tunflags) == 0) { + if ((tunflags & TUN_VMNET) != 0) + return (1); + } + + return (0); +} + +static int tun_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) { + struct tuntap_driver *drv; struct cdev *dev; - int err, unit, i; + int err, i, tunflags, unit; - err = ifc_name2unit(name, &unit); + tunflags = 0; + /* The name here tells us exactly what we're creating */ + err = tuntap_name2info(name, &unit, &tunflags); if (err != 0) return (err); + drv = tuntap_driver_from_flags(tunflags); + if (drv == NULL) + return (ENXIO); + if (unit != -1) { - /* If this unit number is still available that/s okay. */ - if (alloc_unr_specific(tun_unrhdr, unit) == -1) + /* If this unit number is still available that's okay. */ + if (alloc_unr_specific(drv->unrhdr, unit) == -1) return (EEXIST); } else { - unit = alloc_unr(tun_unrhdr); + unit = alloc_unr(drv->unrhdr); } - snprintf(name, IFNAMSIZ, "%s%d", tunname, unit); + snprintf(name, IFNAMSIZ, "%s%d", drv->cdevsw.d_name, unit); /* find any existing device, or allocate new unit number */ - i = clone_create(&tunclones, &tun_cdevsw, &unit, &dev, 0); - if (i) { - /* No preexisting struct cdev *, create one */ - dev = make_dev(&tun_cdevsw, unit, - UID_UUCP, GID_DIALER, 0600, "%s%d", tunname, unit); - } - tuncreate(tunname, dev); + dev = NULL; + i = clone_create(&drv->clones, &drv->cdevsw, &unit, &dev, 0); + /* No preexisting struct cdev *, create one */ + if (i != 0) + i = tun_create_device(drv, unit, NULL, &dev, name); + if (i == 0) + tuncreate(dev); - return (0); + return (i); } static void @@ -224,76 +535,91 @@ tunclone(void *arg, struct ucred *cred, char *name, in struct cdev **dev) { char devname[SPECNAMELEN + 1]; - int u, i, append_unit; + struct tuntap_driver *drv; + int append_unit, i, u, tunflags; + bool mayclone; if (*dev != NULL) return; + tunflags = 0; + CURVNET_SET(CRED_TO_VNET(cred)); + if (tuntap_name2info(name, &u, &tunflags) != 0) + goto out; /* Not recognized */ + + if (u != -1 && u > IF_MAXUNIT) + goto out; /* Unit number too high */ + + mayclone = priv_check_cred(cred, PRIV_NET_IFCREATE, 0) == 0; + if ((tunflags & TUN_L2) != 0) { + /* tap/vmnet allow user open with a sysctl */ + mayclone = (mayclone || tap_allow_uopen) && tapdclone; + } else { + mayclone = mayclone && tundclone; + } + /* * If tun cloning is enabled, only the superuser can create an * interface. */ - if (!tundclone || priv_check_cred(cred, PRIV_NET_IFCREATE, 0) != 0) - return; + if (!mayclone) + goto out; - if (strcmp(name, tunname) == 0) { - u = -1; - } else if (dev_stdclone(name, NULL, tunname, &u) != 1) - return; /* Don't recognise the name */ - if (u != -1 && u > IF_MAXUNIT) - return; /* Unit number too high */ - if (u == -1) append_unit = 1; else append_unit = 0; - CURVNET_SET(CRED_TO_VNET(cred)); + drv = tuntap_driver_from_flags(tunflags); + if (drv == NULL) + goto out; + /* find any existing device, or allocate new unit number */ - i = clone_create(&tunclones, &tun_cdevsw, &u, dev, 0); + i = clone_create(&drv->clones, &drv->cdevsw, &u, dev, 0); if (i) { if (append_unit) { namelen = snprintf(devname, sizeof(devname), "%s%d", name, u); name = devname; } - /* No preexisting struct cdev *, create one */ - *dev = make_dev_credf(MAKEDEV_REF, &tun_cdevsw, u, cred, - UID_UUCP, GID_DIALER, 0600, "%s", name); - } - if_clone_create(name, namelen, NULL); + i = tun_create_device(drv, u, cred, dev, name); + } + if (i == 0) + if_clone_create(name, namelen, NULL); +out: CURVNET_RESTORE(); } static void -tun_destroy(struct tun_softc *tp) +tun_destroy(struct tuntap_softc *tp) { - struct cdev *dev; - mtx_lock(&tp->tun_mtx); + TUN_LOCK(tp); tp->tun_flags |= TUN_DYING; - if ((tp->tun_flags & TUN_OPEN) != 0) + if (tp->tun_busy != 0) cv_wait_unlock(&tp->tun_cv, &tp->tun_mtx); else - mtx_unlock(&tp->tun_mtx); + TUN_UNLOCK(tp); CURVNET_SET(TUN2IFP(tp)->if_vnet); - dev = tp->tun_dev; - bpfdetach(TUN2IFP(tp)); - if_detach(TUN2IFP(tp)); - + /* destroy_dev will take care of any alias. */ + destroy_dev(tp->tun_dev); + seldrain(&tp->tun_rsel); + knlist_clear(&tp->tun_rsel.si_note, 0); + knlist_destroy(&tp->tun_rsel.si_note); *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable-12@freebsd.org Fri Oct 25 09:23:54 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7A0FB16B701; Fri, 25 Oct 2019 09:23:54 +0000 (UTC) (envelope-from avg@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46zzFQ2bStz4Gfy; Fri, 25 Oct 2019 09:23:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C5172457E; Fri, 25 Oct 2019 09:23:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9P9Ns2N008146; Fri, 25 Oct 2019 09:23:54 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9P9Nsme008145; Fri, 25 Oct 2019 09:23:54 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201910250923.x9P9Nsme008145@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 25 Oct 2019 09:23:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354063 - stable/12/sys/dev/gpio X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/dev/gpio X-SVN-Commit-Revision: 354063 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 09:23:54 -0000 Author: avg Date: Fri Oct 25 09:23:53 2019 New Revision: 354063 URL: https://svnweb.freebsd.org/changeset/base/354063 Log: MFC r353727: gpioiic: add the detach method Modified: stable/12/sys/dev/gpio/gpioiic.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/gpio/gpioiic.c ============================================================================== --- stable/12/sys/dev/gpio/gpioiic.c Fri Oct 25 09:19:15 2019 (r354062) +++ stable/12/sys/dev/gpio/gpioiic.c Fri Oct 25 09:23:53 2019 (r354063) @@ -143,6 +143,15 @@ gpioiic_attach(device_t dev) return (0); } +static int +gpioiic_detach(device_t dev) +{ + + bus_generic_detach(dev); + device_delete_children(dev); + return (0); +} + /* * Reset bus by setting SDA first and then SCL. * Must always be called with gpio bus locked. @@ -241,7 +250,7 @@ static device_method_t gpioiic_methods[] = { /* Device interface */ DEVMETHOD(device_probe, gpioiic_probe), DEVMETHOD(device_attach, gpioiic_attach), - DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_detach, gpioiic_detach), /* iicbb interface */ DEVMETHOD(iicbb_setsda, gpioiic_setsda), From owner-svn-src-stable-12@freebsd.org Fri Oct 25 12:46:06 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id ECC371704C6; Fri, 25 Oct 2019 12:46:06 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4703kk5zJzz4T83; Fri, 25 Oct 2019 12:46:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id ABB3E268E9; Fri, 25 Oct 2019 12:46:06 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PCk60S027825; Fri, 25 Oct 2019 12:46:06 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PCk6E7027824; Fri, 25 Oct 2019 12:46:06 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201910251246.x9PCk6E7027824@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Fri, 25 Oct 2019 12:46:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354066 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354066 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 12:46:07 -0000 Author: kevans Date: Fri Oct 25 12:46:06 2019 New Revision: 354066 URL: https://svnweb.freebsd.org/changeset/base/354066 Log: MFC r352387: Fix if_tuntap UPDATING entry Reported by: yuripv [originally] Reported by: Helge Oldach (freebsd@oldach.net) [this time] Modified: stable/12/UPDATING Directory Properties: stable/12/ (props changed) Modified: stable/12/UPDATING ============================================================================== --- stable/12/UPDATING Fri Oct 25 09:37:54 2019 (r354065) +++ stable/12/UPDATING Fri Oct 25 12:46:06 2019 (r354066) @@ -18,8 +18,8 @@ from older version of current across the gcc/clang cut 20191024: The tap(4) driver has been folded into tun(4), and the module has been - renamed to tuntap. You should update any kld_load="if_tap" or - kld_load="if_tun" entries in /etc/rc.conf, if_tap_load="YES" or + renamed to tuntap. You should update any kld_list="if_tap" or + kld_list="if_tun" entries in /etc/rc.conf, if_tap_load="YES" or if_tun_load="YES" entries in /boot/loader.conf to load the if_tuntap module instead, and "device tap" or "device tun" entries in kernel config files to select the tuntap device instead. From owner-svn-src-stable-12@freebsd.org Fri Oct 25 12:46:53 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 22794170578; Fri, 25 Oct 2019 12:46:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4703ld03F5z4TLZ; Fri, 25 Oct 2019 12:46:53 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id CB977138BA; Fri, 25 Oct 2019 12:46:52 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qt1-f179.google.com with SMTP id e14so3047465qto.1; Fri, 25 Oct 2019 05:46:52 -0700 (PDT) X-Gm-Message-State: APjAAAU4+nMhR07vW/oDkm+Iwpbth0OzUKzH0O0cNY3M2I27hVIomhOn HqhG1rUJP+yObNVjkdtGK07d/nJrj0l95lAMxxM= X-Google-Smtp-Source: APXvYqyvu2y0UuSP0kf522l6qPSgV3NSy7O0EdwQjHmr2RU2L4T4aXHrir+1edtlI73FK0jecxYxw/oUBvQqnxcBdYM= X-Received: by 2002:ac8:411b:: with SMTP id q27mr2879059qtl.53.1572007612175; Fri, 25 Oct 2019 05:46:52 -0700 (PDT) MIME-Version: 1.0 References: <201910250110.x9P1A8bl014107@repo.freebsd.org> <201910250450.x9P4oX9Q078873@nuc.oldach.net> In-Reply-To: <201910250450.x9P4oX9Q078873@nuc.oldach.net> From: Kyle Evans Date: Fri, 25 Oct 2019 07:46:39 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r354060 - in stable/12: . sbin/ifconfig share/man/man4 sys/amd64/conf sys/arm/conf sys/arm64/conf sys/conf sys/i386/ To: Helge Oldach Cc: src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Content-Type: text/plain; charset="UTF-8" X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 12:46:53 -0000 On Thu, Oct 24, 2019 at 11:50 PM Helge Oldach wrote: > > Hi, > > Kyle Evans wrote on Fri, 25 Oct 2019 03:10:08 +0200 (CEST): > > Author: kevans > > Date: Fri Oct 25 01:10:08 2019 > > New Revision: 354060 > > URL: https://svnweb.freebsd.org/changeset/base/354060 > > > > Log: > > MFC tun/tap merge: r347241, r347394, r347404, r347483, r351220, r351229, > > r352148, r353056-r353057, r353781-r353782, r353785-r353786, r353877 > > > Modified: stable/12/UPDATING > > ============================================================================== > > --- stable/12/UPDATING Fri Oct 25 00:47:37 2019 (r354059) > > +++ stable/12/UPDATING Fri Oct 25 01:10:08 2019 (r354060) > > @@ -16,6 +16,14 @@ from older versions of FreeBSD, try WITHOUT_CLANG and > > the tip of head, and then rebuild without this option. The bootstrap process > > from older version of current across the gcc/clang cutover is a bit fragile. > > > > +20191024: > > + The tap(4) driver has been folded into tun(4), and the module has been > > + renamed to tuntap. You should update any kld_load="if_tap" or > > + kld_load="if_tun" entries in /etc/rc.conf, if_tap_load="YES" or > > + if_tun_load="YES" entries in /boot/loader.conf to load the if_tuntap > > + module instead, and "device tap" or "device tun" entries in kernel > > + config files to select the tuntap device instead. > > + > > Should the /etc/rc.conf reference read kld_list instead of kld_load? > Ah, but of course I would do it a second time. Fixed in r354066- thanks! From owner-svn-src-stable-12@freebsd.org Fri Oct 25 14:33:08 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 14FC817242F; Fri, 25 Oct 2019 14:33:08 +0000 (UTC) (envelope-from markj@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47066C6pjKz4ZVY; Fri, 25 Oct 2019 14:33:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CD94327C6E; Fri, 25 Oct 2019 14:33:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PEX7q2092939; Fri, 25 Oct 2019 14:33:07 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PEX70S092938; Fri, 25 Oct 2019 14:33:07 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201910251433.x9PEX70S092938@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 25 Oct 2019 14:33:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354071 - stable/12/sys/ufs/ffs X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/ufs/ffs X-SVN-Commit-Revision: 354071 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 14:33:08 -0000 Author: markj Date: Fri Oct 25 14:33:07 2019 New Revision: 354071 URL: https://svnweb.freebsd.org/changeset/base/354071 Log: MFC r353733: Abbreviate softdep lock names. Modified: stable/12/sys/ufs/ffs/ffs_softdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ufs/ffs/ffs_softdep.c ============================================================================== --- stable/12/sys/ufs/ffs/ffs_softdep.c Fri Oct 25 14:30:27 2019 (r354070) +++ stable/12/sys/ufs/ffs/ffs_softdep.c Fri Oct 25 14:33:07 2019 (r354071) @@ -975,7 +975,7 @@ static int softdep_count_dependencies(struct buf *bp, * Global lock over all of soft updates. */ static struct mtx lk; -MTX_SYSINIT(softdep_lock, &lk, "Global Softdep Lock", MTX_DEF); +MTX_SYSINIT(softdep_lock, &lk, "global softdep", MTX_DEF); #define ACQUIRE_GBLLOCK(lk) mtx_lock(lk) #define FREE_GBLLOCK(lk) mtx_unlock(lk) @@ -2478,7 +2478,7 @@ softdep_mount(devvp, mp, fs, cred) ump = VFSTOUFS(mp); ump->um_softdep = sdp; MNT_IUNLOCK(mp); - rw_init(LOCK_PTR(ump), "Per-Filesystem Softdep Lock"); + rw_init(LOCK_PTR(ump), "per-fs softdep"); sdp->sd_ump = ump; LIST_INIT(&ump->softdep_workitem_pending); LIST_INIT(&ump->softdep_journal_pending); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 14:51:23 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 919F1172BAC; Fri, 25 Oct 2019 14:51:23 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4706WH3MFbz4bZ3; Fri, 25 Oct 2019 14:51:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 569F127FD2; Fri, 25 Oct 2019 14:51:23 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PEpNdQ002433; Fri, 25 Oct 2019 14:51:23 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PEpLvA002425; Fri, 25 Oct 2019 14:51:21 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910251451.x9PEpLvA002425@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 25 Oct 2019 14:51:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354073 - in stable/12: share/man/man4 sys/kern sys/powerpc/powernv sys/powerpc/powerpc sys/powerpc/ps3 sys/powerpc/pseries sys/sys sys/x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12: share/man/man4 sys/kern sys/powerpc/powernv sys/powerpc/powerpc sys/powerpc/ps3 sys/powerpc/pseries sys/sys sys/x86/x86 X-SVN-Commit-Revision: 354073 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 14:51:23 -0000 Author: mav Date: Fri Oct 25 14:51:21 2019 New Revision: 354073 URL: https://svnweb.freebsd.org/changeset/base/354073 Log: MFC r342771 (by cem): Expose threads-per-core and physical core count information With new sysctls (to the best of our ability do detect them). Restructured smp.4 slightly for clarity (keep relevant stuff closer to the top) while documenting. Modified: stable/12/share/man/man4/smp.4 stable/12/sys/kern/subr_smp.c stable/12/sys/powerpc/powernv/platform_powernv.c stable/12/sys/powerpc/powerpc/mp_machdep.c stable/12/sys/powerpc/ps3/platform_ps3.c stable/12/sys/powerpc/pseries/platform_chrp.c stable/12/sys/sys/smp.h stable/12/sys/x86/x86/mp_x86.c Directory Properties: stable/12/ (props changed) Modified: stable/12/share/man/man4/smp.4 ============================================================================== --- stable/12/share/man/man4/smp.4 Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/share/man/man4/smp.4 Fri Oct 25 14:51:21 2019 (r354073) @@ -23,7 +23,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 6, 2018 +.Dd January 4, 2019 .Dt SMP 4 .Os .Sh NAME @@ -35,27 +35,6 @@ The .Nm kernel implements symmetric multi-processor support. -.Sh COMPATIBILITY -Support for multi-processor systems is present for all Tier-1 -architectures on -.Fx . -Currently, this includes amd64, i386 and sparc64. -Support is enabled using -.Cd options SMP . -It is permissible to use the SMP kernel configuration on non-SMP equipped -motherboards. -.Sh I386 NOTES -For i386 systems, the -.Nm -kernel supports motherboards that follow the Intel MP specification, -version 1.4. -In addition to -.Cd options SMP , -i386 also requires -.Cd device apic . -The -.Xr mptable 1 -command may be used to view the status of multi-processor support. .Pp .Nm support can be disabled by setting the loader tunable @@ -66,6 +45,13 @@ The number of CPUs detected by the system is available the read-only sysctl variable .Va hw.ncpu . .Pp +The number of online threads per CPU core is available in the read-only sysctl +variable +.Va kern.smp.threads_per_core . +The number of physical CPU cores detected by the system is available in the +read-only sysctl variable +.Va kern.smp.cores . +.Pp .Fx allows specific CPUs on a multi-processor system to be disabled. This can be done using the @@ -74,6 +60,12 @@ tunable, where X is the APIC ID of a CPU. Setting this tunable to 1 will result in the corresponding CPU being disabled. .Pp +.Fx +supports simultaneous multithreading on x86 and powerpc platforms. +On x86, the logical CPUs can be disabled by setting the +.Va machdep.hyperthreading_allowed +tunable to zero. +.Pp The .Xr sched_ule 4 scheduler implements CPU topology detection and adjusts the scheduling @@ -122,13 +114,26 @@ two quad-core processors is: .Pp This information is used internally by the kernel to schedule related tasks on CPUs that are closely grouped together. -.Pp -.Fx -supports hyperthreading on Intel CPU's on the i386 and AMD64 platforms. -Because using logical CPUs can cause performance penalties under certain loads, -the logical CPUs can be disabled by setting the -.Va machdep.hyperthreading_allowed -tunable to zero. +.Sh COMPATIBILITY +Support for multi-processor systems is present for all Tier-1 and Tier-2 +architectures on +.Fx . +Currently, this includes x86, powerpc, arm, and sparc64. +Support is enabled using +.Cd options SMP . +It is permissible to use the SMP kernel configuration on non-SMP hardware. +.Sh I386 NOTES +For i386 systems, the +.Nm +kernel supports motherboards that follow the Intel MP specification, +version 1.4. +In addition to +.Cd options SMP , +i386 also requires +.Cd device apic . +The +.Xr mptable 1 +command may be used to view the status of multi-processor support. .Sh SEE ALSO .Xr cpuset 1 , .Xr mptable 1 , @@ -166,3 +171,20 @@ in also introduced support for SMP on the sparc64 architecture. .Sh AUTHORS .An Steve Passe Aq Mt fsmp@FreeBSD.org +.Sh CAVEATS +The +.Va kern.smp.threads_per_core +and +.Va kern.smp.cores +sysctl variables are provided as a best-effort guess. +If an architecture or platform adds SMT and +.Fx +has not yet implemented detection, the reported values may be inaccurate. +In this case, +.Va kern.smp.threads_per_core +will report +.Dv 1 +and +.Va kern.smp.cores +will report the same value as +.Va hw.ncpu . Modified: stable/12/sys/kern/subr_smp.c ============================================================================== --- stable/12/sys/kern/subr_smp.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/kern/subr_smp.c Fri Oct 25 14:51:21 2019 (r354073) @@ -98,6 +98,14 @@ int smp_cpus = 1; /* how many cpu's running */ SYSCTL_INT(_kern_smp, OID_AUTO, cpus, CTLFLAG_RD|CTLFLAG_CAPRD, &smp_cpus, 0, "Number of CPUs online"); +int smp_threads_per_core = 1; /* how many SMT threads are running per core */ +SYSCTL_INT(_kern_smp, OID_AUTO, threads_per_core, CTLFLAG_RD|CTLFLAG_CAPRD, + &smp_threads_per_core, 0, "Number of SMT threads online per core"); + +int mp_ncores = -1; /* how many physical cores running */ +SYSCTL_INT(_kern_smp, OID_AUTO, cores, CTLFLAG_RD|CTLFLAG_CAPRD, &mp_ncores, 0, + "Number of CPUs online"); + int smp_topology = 0; /* Which topology we're using. */ SYSCTL_INT(_kern_smp, OID_AUTO, topology, CTLFLAG_RDTUN, &smp_topology, 0, "Topology override setting; 0 is default provided by hardware."); @@ -154,6 +162,7 @@ mp_start(void *dummy) /* Probe for MP hardware. */ if (smp_disabled != 0 || cpu_mp_probe() == 0) { + mp_ncores = 1; mp_ncpus = 1; CPU_SETOF(PCPU_GET(cpuid), &all_cpus); return; @@ -162,6 +171,11 @@ mp_start(void *dummy) cpu_mp_start(); printf("FreeBSD/SMP: Multiprocessor System Detected: %d CPUs\n", mp_ncpus); + + /* Provide a default for most architectures that don't have SMT/HTT. */ + if (mp_ncores < 0) + mp_ncores = mp_ncpus; + cpu_mp_announce(); } SYSINIT(cpu_mp, SI_SUB_CPU, SI_ORDER_THIRD, mp_start, NULL); @@ -823,6 +837,7 @@ static void mp_setvariables_for_up(void *dummy) { mp_ncpus = 1; + mp_ncores = 1; mp_maxid = PCPU_GET(cpuid); CPU_SETOF(mp_maxid, &all_cpus); KASSERT(PCPU_GET(cpuid) == 0, ("UP must have a CPU ID of zero")); Modified: stable/12/sys/powerpc/powernv/platform_powernv.c ============================================================================== --- stable/12/sys/powerpc/powernv/platform_powernv.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/powerpc/powernv/platform_powernv.c Fri Oct 25 14:51:21 2019 (r354073) @@ -435,12 +435,16 @@ powernv_smp_topo(platform_t plat) break; } + smp_threads_per_core = nthreads; + if (mp_ncpus % nthreads != 0) { printf("WARNING: Irregular SMP topology. Performance may be " "suboptimal (%d threads, %d on first core)\n", mp_ncpus, nthreads); return (smp_topo_none()); } + + mp_ncores = mp_ncpus / nthreads; /* Don't do anything fancier for non-threaded SMP */ if (nthreads == 1) Modified: stable/12/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/mp_machdep.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/powerpc/powerpc/mp_machdep.c Fri Oct 25 14:51:21 2019 (r354073) @@ -182,6 +182,11 @@ cpu_mp_start(void) next: error = platform_smp_next_cpu(&cpu); } + +#ifdef SMP + /* Probe mp_ncores and smp_threads_per_core as a side effect. */ + (void)cpu_topo(); +#endif } void Modified: stable/12/sys/powerpc/ps3/platform_ps3.c ============================================================================== --- stable/12/sys/powerpc/ps3/platform_ps3.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/powerpc/ps3/platform_ps3.c Fri Oct 25 14:51:21 2019 (r354073) @@ -246,6 +246,8 @@ ps3_smp_start_cpu(platform_t plat, struct pcpu *pc) static struct cpu_group * ps3_smp_topo(platform_t plat) { + mp_ncores = 1; + smp_threads_per_core = 2; return (smp_topo_1level(CG_SHARE_L1, 2, CG_FLAG_SMT)); } #endif Modified: stable/12/sys/powerpc/pseries/platform_chrp.c ============================================================================== --- stable/12/sys/powerpc/pseries/platform_chrp.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/powerpc/pseries/platform_chrp.c Fri Oct 25 14:51:21 2019 (r354073) @@ -517,6 +517,8 @@ chrp_smp_topo(platform_t plat) ncpus++; } + mp_ncores = ncores; + if (ncpus % ncores != 0) { printf("WARNING: Irregular SMP topology. Performance may be " "suboptimal (%d CPUS, %d cores)\n", ncpus, ncores); @@ -527,6 +529,7 @@ chrp_smp_topo(platform_t plat) if (ncpus == ncores) return (smp_topo_none()); + smp_threads_per_core = ncpus / ncores; return (smp_topo_1level(CG_SHARE_L1, ncpus / ncores, CG_FLAG_SMT)); } #endif Modified: stable/12/sys/sys/smp.h ============================================================================== --- stable/12/sys/sys/smp.h Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/sys/smp.h Fri Oct 25 14:51:21 2019 (r354073) @@ -167,8 +167,10 @@ extern cpuset_t logical_cpus_mask; extern u_int mp_maxid; extern int mp_maxcpus; +extern int mp_ncores; extern int mp_ncpus; extern volatile int smp_started; +extern int smp_threads_per_core; extern cpuset_t all_cpus; extern cpuset_t cpuset_domain[MAXMEMDOM]; /* CPUs in each NUMA domain. */ Modified: stable/12/sys/x86/x86/mp_x86.c ============================================================================== --- stable/12/sys/x86/x86/mp_x86.c Fri Oct 25 14:46:09 2019 (r354072) +++ stable/12/sys/x86/x86/mp_x86.c Fri Oct 25 14:51:21 2019 (r354073) @@ -608,6 +608,7 @@ assign_cpu_ids(void) { struct topo_node *node; u_int smt_mask; + int nhyper; smt_mask = (1u << core_id_shift) - 1; @@ -616,6 +617,7 @@ assign_cpu_ids(void) * beyond MAXCPU. CPU 0 is always assigned to the BSP. */ mp_ncpus = 0; + nhyper = 0; TOPO_FOREACH(node, &topo_root) { if (node->type != TOPO_TYPE_PU) continue; @@ -643,6 +645,9 @@ assign_cpu_ids(void) continue; } + if (cpu_info[node->hwid].cpu_hyperthread) + nhyper++; + cpu_apic_ids[mp_ncpus] = node->hwid; apic_cpuids[node->hwid] = mp_ncpus; topo_set_pu_id(node, mp_ncpus); @@ -652,6 +657,9 @@ assign_cpu_ids(void) KASSERT(mp_maxid >= mp_ncpus - 1, ("%s: counters out of sync: max %d, count %d", __func__, mp_maxid, mp_ncpus)); + + mp_ncores = mp_ncpus - nhyper; + smp_threads_per_core = mp_ncpus / mp_ncores; } /* From owner-svn-src-stable-12@freebsd.org Fri Oct 25 14:55:39 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3E9A5172DF9; Fri, 25 Oct 2019 14:55:39 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4706cC1cSbz4c3Q; Fri, 25 Oct 2019 14:55:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1A95028054; Fri, 25 Oct 2019 14:55:39 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PEtcBI004978; Fri, 25 Oct 2019 14:55:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PEtb9U004971; Fri, 25 Oct 2019 14:55:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910251455.x9PEtb9U004971@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 25 Oct 2019 14:55:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354074 - stable/12/sys/dev/nvme X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/dev/nvme X-SVN-Commit-Revision: 354074 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 14:55:39 -0000 Author: mav Date: Fri Oct 25 14:55:37 2019 New Revision: 354074 URL: https://svnweb.freebsd.org/changeset/base/354074 Log: MFC r352630: Make nvme(4) driver some more NUMA aware. - For each queue pair precalculate CPU and domain it is bound to. If queue pairs are not per-CPU, then use the domain of the device. - Allocate most of queue pair memory from the domain it is bound to. - Bind callouts to the same CPUs as queue pair to avoid migrations. - Do not assign queue pairs to each SMT thread. It just wasted resources and increased lock congestions. - Remove fixed multiplier of CPUs per queue pair, spread them even. This allows to use more queue pairs in some hardware configurations. - If queue pair serves multiple CPUs, bind different NVMe devices to different CPUs. Modified: stable/12/sys/dev/nvme/nvme_ahci.c stable/12/sys/dev/nvme/nvme_ctrlr.c stable/12/sys/dev/nvme/nvme_ctrlr_cmd.c stable/12/sys/dev/nvme/nvme_pci.c stable/12/sys/dev/nvme/nvme_private.h stable/12/sys/dev/nvme/nvme_qpair.c stable/12/sys/dev/nvme/nvme_sysctl.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/nvme/nvme_ahci.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ahci.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_ahci.c Fri Oct 25 14:55:37 2019 (r354074) @@ -96,7 +96,6 @@ nvme_ahci_attach(device_t dev) ctrlr->msix_enabled = 0; ctrlr->num_io_queues = 1; - ctrlr->num_cpus_per_ioq = mp_ncpus; if (bus_setup_intr(dev, ctrlr->res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, nvme_ctrlr_intx_handler, ctrlr, &ctrlr->tag) != 0) { Modified: stable/12/sys/dev/nvme/nvme_ctrlr.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_ctrlr.c Fri Oct 25 14:55:37 2019 (r354074) @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include "nvme_private.h" @@ -57,6 +58,9 @@ nvme_ctrlr_construct_admin_qpair(struct nvme_controlle int error; qpair = &ctrlr->adminq; + qpair->id = 0; + qpair->cpu = CPU_FFS(&cpuset_domain[ctrlr->domain]) - 1; + qpair->domain = ctrlr->domain; num_entries = NVME_ADMIN_ENTRIES; TUNABLE_INT_FETCH("hw.nvme.admin_entries", &num_entries); @@ -75,22 +79,21 @@ nvme_ctrlr_construct_admin_qpair(struct nvme_controlle * The admin queue's max xfer size is treated differently than the * max I/O xfer size. 16KB is sufficient here - maybe even less? */ - error = nvme_qpair_construct(qpair, - 0, /* qpair ID */ - 0, /* vector */ - num_entries, - NVME_ADMIN_TRACKERS, - ctrlr); + error = nvme_qpair_construct(qpair, num_entries, NVME_ADMIN_TRACKERS, + ctrlr); return (error); } +#define QP(ctrlr, c) ((c) * (ctrlr)->num_io_queues / mp_ncpus) + static int nvme_ctrlr_construct_io_qpairs(struct nvme_controller *ctrlr) { struct nvme_qpair *qpair; uint32_t cap_lo; uint16_t mqes; - int i, error, num_entries, num_trackers, max_entries; + int c, error, i, n; + int num_entries, num_trackers, max_entries; /* * NVMe spec sets a hard limit of 64K max entries, but devices may @@ -130,32 +133,35 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller */ ctrlr->max_hw_pend_io = num_trackers * ctrlr->num_io_queues * 3 / 4; - /* - * This was calculated previously when setting up interrupts, but - * a controller could theoretically support fewer I/O queues than - * MSI-X vectors. So calculate again here just to be safe. - */ - ctrlr->num_cpus_per_ioq = howmany(mp_ncpus, ctrlr->num_io_queues); - ctrlr->ioq = malloc(ctrlr->num_io_queues * sizeof(struct nvme_qpair), M_NVME, M_ZERO | M_WAITOK); - for (i = 0; i < ctrlr->num_io_queues; i++) { + for (i = c = n = 0; i < ctrlr->num_io_queues; i++, c += n) { qpair = &ctrlr->ioq[i]; /* * Admin queue has ID=0. IO queues start at ID=1 - * hence the 'i+1' here. - * + */ + qpair->id = i + 1; + if (ctrlr->num_io_queues > 1) { + /* Find number of CPUs served by this queue. */ + for (n = 1; QP(ctrlr, c + n) == i; n++) + ; + /* Shuffle multiple NVMe devices between CPUs. */ + qpair->cpu = c + (device_get_unit(ctrlr->dev)+n/2) % n; + qpair->domain = pcpu_find(qpair->cpu)->pc_domain; + } else { + qpair->cpu = CPU_FFS(&cpuset_domain[ctrlr->domain]) - 1; + qpair->domain = ctrlr->domain; + } + + /* * For I/O queues, use the controller-wide max_xfer_size * calculated in nvme_attach(). */ - error = nvme_qpair_construct(qpair, - i+1, /* qpair ID */ - ctrlr->msix_enabled ? i+1 : 0, /* vector */ - num_entries, - num_trackers, - ctrlr); + error = nvme_qpair_construct(qpair, num_entries, num_trackers, + ctrlr); if (error) return (error); @@ -164,8 +170,7 @@ nvme_ctrlr_construct_io_qpairs(struct nvme_controller * interrupt thread for this controller. */ if (ctrlr->num_io_queues > 1) - bus_bind_intr(ctrlr->dev, qpair->res, - i * ctrlr->num_cpus_per_ioq); + bus_bind_intr(ctrlr->dev, qpair->res, qpair->cpu); } return (0); @@ -458,6 +463,8 @@ nvme_ctrlr_set_num_qpairs(struct nvme_controller *ctrl */ ctrlr->num_io_queues = min(ctrlr->num_io_queues, sq_allocated); ctrlr->num_io_queues = min(ctrlr->num_io_queues, cq_allocated); + if (ctrlr->num_io_queues > vm_ndomains) + ctrlr->num_io_queues -= ctrlr->num_io_queues % vm_ndomains; return (0); } @@ -473,7 +480,7 @@ nvme_ctrlr_create_qpairs(struct nvme_controller *ctrlr qpair = &ctrlr->ioq[i]; status.done = 0; - nvme_ctrlr_cmd_create_io_cq(ctrlr, qpair, qpair->vector, + nvme_ctrlr_cmd_create_io_cq(ctrlr, qpair, nvme_completion_poll_cb, &status); nvme_completion_poll(&status); if (nvme_completion_is_error(&status.cpl)) { @@ -1132,6 +1139,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, de ctrlr->dev = dev; mtx_init(&ctrlr->lock, "nvme ctrlr lock", NULL, MTX_DEF); + if (bus_get_domain(dev, &ctrlr->domain) != 0) + ctrlr->domain = 0; cap_hi = nvme_mmio_read_4(ctrlr, cap_hi); ctrlr->dstrd = NVME_CAP_HI_DSTRD(cap_hi) + 2; @@ -1296,7 +1305,7 @@ nvme_ctrlr_submit_io_request(struct nvme_controller *c { struct nvme_qpair *qpair; - qpair = &ctrlr->ioq[curcpu / ctrlr->num_cpus_per_ioq]; + qpair = &ctrlr->ioq[QP(ctrlr, curcpu)]; nvme_qpair_submit_request(qpair, req); } Modified: stable/12/sys/dev/nvme/nvme_ctrlr_cmd.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_ctrlr_cmd.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_ctrlr_cmd.c Fri Oct 25 14:55:37 2019 (r354074) @@ -76,8 +76,7 @@ nvme_ctrlr_cmd_identify_namespace(struct nvme_controll void nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ctrlr, - struct nvme_qpair *io_que, uint16_t vector, nvme_cb_fn_t cb_fn, - void *cb_arg) + struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg) { struct nvme_request *req; struct nvme_command *cmd; @@ -93,7 +92,7 @@ nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ct */ cmd->cdw10 = htole32(((io_que->num_entries-1) << 16) | io_que->id); /* 0x3 = interrupts enabled | physically contiguous */ - cmd->cdw11 = htole32((vector << 16) | 0x3); + cmd->cdw11 = htole32((io_que->vector << 16) | 0x3); cmd->prp1 = htole64(io_que->cpl_bus_addr); nvme_ctrlr_submit_admin_request(ctrlr, req); Modified: stable/12/sys/dev/nvme/nvme_pci.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_pci.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_pci.c Fri Oct 25 14:55:37 2019 (r354074) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -233,7 +234,6 @@ nvme_ctrlr_configure_intx(struct nvme_controller *ctrl ctrlr->msix_enabled = 0; ctrlr->num_io_queues = 1; - ctrlr->num_cpus_per_ioq = mp_ncpus; ctrlr->rid = 0; ctrlr->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ, &ctrlr->rid, RF_SHAREABLE | RF_ACTIVE); @@ -259,82 +259,61 @@ static void nvme_ctrlr_setup_interrupts(struct nvme_controller *ctrlr) { device_t dev; - int per_cpu_io_queues; + int force_intx, num_io_queues, per_cpu_io_queues; int min_cpus_per_ioq; int num_vectors_requested, num_vectors_allocated; - int num_vectors_available; dev = ctrlr->dev; - min_cpus_per_ioq = 1; - TUNABLE_INT_FETCH("hw.nvme.min_cpus_per_ioq", &min_cpus_per_ioq); - if (min_cpus_per_ioq < 1) { - min_cpus_per_ioq = 1; - } else if (min_cpus_per_ioq > mp_ncpus) { - min_cpus_per_ioq = mp_ncpus; + force_intx = 0; + TUNABLE_INT_FETCH("hw.nvme.force_intx", &force_intx); + if (force_intx || pci_msix_count(dev) < 2) { + nvme_ctrlr_configure_intx(ctrlr); + return; } + num_io_queues = mp_ncpus; + TUNABLE_INT_FETCH("hw.nvme.num_io_queues", &num_io_queues); + if (num_io_queues < 1 || num_io_queues > mp_ncpus) + num_io_queues = mp_ncpus; + per_cpu_io_queues = 1; TUNABLE_INT_FETCH("hw.nvme.per_cpu_io_queues", &per_cpu_io_queues); + if (per_cpu_io_queues == 0) + num_io_queues = 1; - if (per_cpu_io_queues == 0) { - min_cpus_per_ioq = mp_ncpus; + min_cpus_per_ioq = smp_threads_per_core; + TUNABLE_INT_FETCH("hw.nvme.min_cpus_per_ioq", &min_cpus_per_ioq); + if (min_cpus_per_ioq > 1) { + num_io_queues = min(num_io_queues, + max(1, mp_ncpus / min_cpus_per_ioq)); } - ctrlr->force_intx = 0; - TUNABLE_INT_FETCH("hw.nvme.force_intx", &ctrlr->force_intx); + num_io_queues = min(num_io_queues, pci_msix_count(dev) - 1); - /* - * FreeBSD currently cannot allocate more than about 190 vectors at - * boot, meaning that systems with high core count and many devices - * requesting per-CPU interrupt vectors will not get their full - * allotment. So first, try to allocate as many as we may need to - * understand what is available, then immediately release them. - * Then figure out how many of those we will actually use, based on - * assigning an equal number of cores to each I/O queue. - */ - +again: + if (num_io_queues > vm_ndomains) + num_io_queues -= num_io_queues % vm_ndomains; /* One vector for per core I/O queue, plus one vector for admin queue. */ - num_vectors_available = min(pci_msix_count(dev), mp_ncpus + 1); - if (pci_alloc_msix(dev, &num_vectors_available) != 0) { - num_vectors_available = 0; - } - pci_release_msi(dev); - - if (ctrlr->force_intx || num_vectors_available < 2) { - nvme_ctrlr_configure_intx(ctrlr); - return; - } - - /* - * Do not use all vectors for I/O queues - one must be saved for the - * admin queue. - */ - ctrlr->num_cpus_per_ioq = max(min_cpus_per_ioq, - howmany(mp_ncpus, num_vectors_available - 1)); - - ctrlr->num_io_queues = howmany(mp_ncpus, ctrlr->num_cpus_per_ioq); - num_vectors_requested = ctrlr->num_io_queues + 1; + num_vectors_requested = num_io_queues + 1; num_vectors_allocated = num_vectors_requested; - - /* - * Now just allocate the number of vectors we need. This should - * succeed, since we previously called pci_alloc_msix() - * successfully returning at least this many vectors, but just to - * be safe, if something goes wrong just revert to INTx. - */ if (pci_alloc_msix(dev, &num_vectors_allocated) != 0) { nvme_ctrlr_configure_intx(ctrlr); return; } - - if (num_vectors_allocated < num_vectors_requested) { + if (num_vectors_allocated < 2) { pci_release_msi(dev); nvme_ctrlr_configure_intx(ctrlr); return; } + if (num_vectors_allocated != num_vectors_requested) { + pci_release_msi(dev); + num_io_queues = num_vectors_allocated - 1; + goto again; + } ctrlr->msix_enabled = 1; + ctrlr->num_io_queues = num_io_queues; } static int Modified: stable/12/sys/dev/nvme/nvme_private.h ============================================================================== --- stable/12/sys/dev/nvme/nvme_private.h Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_private.h Fri Oct 25 14:55:37 2019 (r354074) @@ -175,7 +175,8 @@ struct nvme_qpair { struct nvme_controller *ctrlr; uint32_t id; - uint32_t phase; + int domain; + int cpu; uint16_t vector; int rid; @@ -187,6 +188,7 @@ struct nvme_qpair { uint32_t sq_tdbl_off; uint32_t cq_hdbl_off; + uint32_t phase; uint32_t sq_head; uint32_t sq_tail; uint32_t cq_head; @@ -238,7 +240,7 @@ struct nvme_controller { device_t dev; struct mtx lock; - + int domain; uint32_t ready_timeout_in_ms; uint32_t quirks; #define QUIRK_DELAY_B4_CHK_RDY 1 /* Can't touch MMIO on disable */ @@ -258,11 +260,9 @@ struct nvme_controller { struct resource *bar4_resource; uint32_t msix_enabled; - uint32_t force_intx; uint32_t enable_aborts; uint32_t num_io_queues; - uint32_t num_cpus_per_ioq; uint32_t max_hw_pend_io; /* Fields for tracking progress during controller initialization. */ @@ -377,7 +377,7 @@ void nvme_ctrlr_cmd_get_firmware_page(struct nvme_cont nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_ctrlr_cmd_create_io_cq(struct nvme_controller *ctrlr, - struct nvme_qpair *io_que, uint16_t vector, + struct nvme_qpair *io_que, nvme_cb_fn_t cb_fn, void *cb_arg); void nvme_ctrlr_cmd_create_io_sq(struct nvme_controller *ctrlr, struct nvme_qpair *io_que, @@ -413,9 +413,8 @@ void nvme_ctrlr_submit_io_request(struct nvme_controll void nvme_ctrlr_post_failed_request(struct nvme_controller *ctrlr, struct nvme_request *req); -int nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id, - uint16_t vector, uint32_t num_entries, - uint32_t num_trackers, +int nvme_qpair_construct(struct nvme_qpair *qpair, + uint32_t num_entries, uint32_t num_trackers, struct nvme_controller *ctrlr); void nvme_qpair_submit_tracker(struct nvme_qpair *qpair, struct nvme_tracker *tr); Modified: stable/12/sys/dev/nvme/nvme_qpair.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_qpair.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_qpair.c Fri Oct 25 14:55:37 2019 (r354074) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -637,8 +638,8 @@ nvme_qpair_msix_handler(void *arg) } int -nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id, - uint16_t vector, uint32_t num_entries, uint32_t num_trackers, +nvme_qpair_construct(struct nvme_qpair *qpair, + uint32_t num_entries, uint32_t num_trackers, struct nvme_controller *ctrlr) { struct nvme_tracker *tr; @@ -647,8 +648,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ uint8_t *queuemem, *prpmem, *prp_list; int i, err; - qpair->id = id; - qpair->vector = vector; + qpair->vector = ctrlr->msix_enabled ? qpair->id : 0; qpair->num_entries = num_entries; qpair->num_trackers = num_trackers; qpair->ctrlr = ctrlr; @@ -659,19 +659,19 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ * MSI-X vector resource IDs start at 1, so we add one to * the queue's vector to get the corresponding rid to use. */ - qpair->rid = vector + 1; + qpair->rid = qpair->vector + 1; qpair->res = bus_alloc_resource_any(ctrlr->dev, SYS_RES_IRQ, &qpair->rid, RF_ACTIVE); bus_setup_intr(ctrlr->dev, qpair->res, INTR_TYPE_MISC | INTR_MPSAFE, NULL, nvme_qpair_msix_handler, qpair, &qpair->tag); - if (id == 0) { + if (qpair->id == 0) { bus_describe_intr(ctrlr->dev, qpair->res, qpair->tag, "admin"); } else { bus_describe_intr(ctrlr->dev, qpair->res, qpair->tag, - "io%d", id - 1); + "io%d", qpair->id - 1); } } @@ -707,6 +707,7 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ nvme_printf(ctrlr, "tag create failed %d\n", err); goto out; } + bus_dma_tag_set_domain(qpair->dma_tag, qpair->domain); if (bus_dmamem_alloc(qpair->dma_tag, (void **)&queuemem, BUS_DMA_NOWAIT, &qpair->queuemem_map)) { @@ -737,9 +738,9 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ * it to various small values. */ qpair->sq_tdbl_off = nvme_mmio_offsetof(doorbell[0]) + - (id << (ctrlr->dstrd + 1)); + (qpair->id << (ctrlr->dstrd + 1)); qpair->cq_hdbl_off = nvme_mmio_offsetof(doorbell[0]) + - (id << (ctrlr->dstrd + 1)) + (1 << ctrlr->dstrd); + (qpair->id << (ctrlr->dstrd + 1)) + (1 << ctrlr->dstrd); TAILQ_INIT(&qpair->free_tr); TAILQ_INIT(&qpair->outstanding_tr); @@ -765,7 +766,8 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ (uint8_t *)roundup2((uintptr_t)prp_list, PAGE_SIZE); } - tr = malloc(sizeof(*tr), M_NVME, M_ZERO | M_WAITOK); + tr = malloc_domainset(sizeof(*tr), M_NVME, + DOMAINSET_PREF(qpair->domain), M_ZERO | M_WAITOK); bus_dmamap_create(qpair->dma_tag_payload, 0, &tr->payload_dma_map); callout_init(&tr->timer, 1); @@ -783,8 +785,9 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_ goto out; } - qpair->act_tr = malloc(sizeof(struct nvme_tracker *) * - qpair->num_entries, M_NVME, M_ZERO | M_WAITOK); + qpair->act_tr = malloc_domainset(sizeof(struct nvme_tracker *) * + qpair->num_entries, M_NVME, DOMAINSET_PREF(qpair->domain), + M_ZERO | M_WAITOK); return (0); out: @@ -814,14 +817,14 @@ nvme_qpair_destroy(struct nvme_qpair *qpair) } if (qpair->act_tr) - free(qpair->act_tr, M_NVME); + free_domain(qpair->act_tr, M_NVME); while (!TAILQ_EMPTY(&qpair->free_tr)) { tr = TAILQ_FIRST(&qpair->free_tr); TAILQ_REMOVE(&qpair->free_tr, tr, tailq); bus_dmamap_destroy(qpair->dma_tag_payload, tr->payload_dma_map); - free(tr, M_NVME); + free_domain(tr, M_NVME); } if (qpair->dma_tag) @@ -938,8 +941,8 @@ nvme_qpair_submit_tracker(struct nvme_qpair *qpair, st ctrlr = qpair->ctrlr; if (req->timeout) - callout_reset_curcpu(&tr->timer, ctrlr->timeout_period * hz, - nvme_timeout, tr); + callout_reset_on(&tr->timer, ctrlr->timeout_period * hz, + nvme_timeout, tr, qpair->cpu); /* Copy the command from the tracker to the submission queue. */ memcpy(&qpair->cmd[qpair->sq_tail], &req->cmd, sizeof(req->cmd)); Modified: stable/12/sys/dev/nvme/nvme_sysctl.c ============================================================================== --- stable/12/sys/dev/nvme/nvme_sysctl.c Fri Oct 25 14:51:21 2019 (r354073) +++ stable/12/sys/dev/nvme/nvme_sysctl.c Fri Oct 25 14:55:37 2019 (r354074) @@ -306,9 +306,9 @@ nvme_sysctl_initialize_ctrlr(struct nvme_controller *c ctrlr_tree = device_get_sysctl_tree(ctrlr->dev); ctrlr_list = SYSCTL_CHILDREN(ctrlr_tree); - SYSCTL_ADD_UINT(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_cpus_per_ioq", - CTLFLAG_RD, &ctrlr->num_cpus_per_ioq, 0, - "Number of CPUs assigned per I/O queue pair"); + SYSCTL_ADD_UINT(ctrlr_ctx, ctrlr_list, OID_AUTO, "num_io_queues", + CTLFLAG_RD, &ctrlr->num_io_queues, 0, + "Number of I/O queue pairs"); SYSCTL_ADD_PROC(ctrlr_ctx, ctrlr_list, OID_AUTO, "int_coal_time", CTLTYPE_UINT | CTLFLAG_RW, ctrlr, 0, From owner-svn-src-stable-12@freebsd.org Fri Oct 25 15:02:50 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AA6481731AC; Fri, 25 Oct 2019 15:02:50 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4706mV45Kxz4cX3; Fri, 25 Oct 2019 15:02:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6FB9428228; Fri, 25 Oct 2019 15:02:50 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PF2oPk010492; Fri, 25 Oct 2019 15:02:50 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PF2oJc010491; Fri, 25 Oct 2019 15:02:50 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910251502.x9PF2oJc010491@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 25 Oct 2019 15:02:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354075 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354075 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 15:02:50 -0000 Author: mav Date: Fri Oct 25 15:02:50 2019 New Revision: 354075 URL: https://svnweb.freebsd.org/changeset/base/354075 Log: MFC r353454: Allocate device softc from the device domain. Since we are trying to bind device interrupt threads to the device domain, it should have sense to make memory often accessed by them local. If domain is not known, fall back to round-robin. Modified: stable/12/sys/kern/subr_bus.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_bus.c ============================================================================== --- stable/12/sys/kern/subr_bus.c Fri Oct 25 14:55:37 2019 (r354074) +++ stable/12/sys/kern/subr_bus.c Fri Oct 25 15:02:50 2019 (r354075) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -2523,7 +2524,7 @@ void device_set_softc(device_t dev, void *softc) { if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) - free(dev->softc, M_BUS_SC); + free_domain(dev->softc, M_BUS_SC); dev->softc = softc; if (dev->softc) dev->flags |= DF_EXTERNALSOFTC; @@ -2540,7 +2541,7 @@ device_set_softc(device_t dev, void *softc) void device_free_softc(void *softc) { - free(softc, M_BUS_SC); + free_domain(softc, M_BUS_SC); } /** @@ -2789,6 +2790,9 @@ device_set_devclass_fixed(device_t dev, const char *cl int device_set_driver(device_t dev, driver_t *driver) { + int domain; + struct domainset *policy; + if (dev->state >= DS_ATTACHED) return (EBUSY); @@ -2796,7 +2800,7 @@ device_set_driver(device_t dev, driver_t *driver) return (0); if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) { - free(dev->softc, M_BUS_SC); + free_domain(dev->softc, M_BUS_SC); dev->softc = NULL; } device_set_desc(dev, NULL); @@ -2805,8 +2809,12 @@ device_set_driver(device_t dev, driver_t *driver) if (driver) { kobj_init((kobj_t) dev, (kobj_class_t) driver); if (!(dev->flags & DF_EXTERNALSOFTC) && driver->size > 0) { - dev->softc = malloc(driver->size, M_BUS_SC, - M_NOWAIT | M_ZERO); + if (bus_get_domain(dev, &domain) == 0) + policy = DOMAINSET_PREF(domain); + else + policy = DOMAINSET_RR(); + dev->softc = malloc_domainset(driver->size, M_BUS_SC, + policy, M_NOWAIT | M_ZERO); if (!dev->softc) { kobj_delete((kobj_t) dev, NULL); kobj_init((kobj_t) dev, &null_class); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 17:26:17 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4A3ED175FE0; Fri, 25 Oct 2019 17:26:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4709y11GKfz3J4l; Fri, 25 Oct 2019 17:26:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-4.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 7399615887; Fri, 25 Oct 2019 17:26:16 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Subject: Re: svn commit: r354049 - in stable/12/sys/amd64: amd64 include To: Alexander Motin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <201910242110.x9OLA91Q073256@repo.freebsd.org> From: John Baldwin Openpgp: preference=signencrypt Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGfnQH+rNAaH0livoSBQ0IPI/8WfIW7ub4qV6HYwWKVqkDkqwcpmGNDbz3gfaDht6nsie5Z pcuCcul4M9CW7Md6zzyvktjnbz61BADGDCopfZC4of0Z3Ka0u8Wik6UJOuqShBt1WcFS8ya1 oB4rc4tXfSHyMF63aPUBMxHR5DXeH+EO2edoSwViDMqWk1jTnYza51rbGY+pebLQOVOxAY7k do5Ordl3wklBPMVEPWoZ61SdbcjhHVwaC5zfiskcxj5wwXd2E9qYlBqRg7QeSm9obiBCYWxk d2luIDxqaGJARnJlZUJTRC5vcmc+iGAEExECACAFAkTQ+awCGwMGCwkIBwMCBBUCCAMEFgID AQIeAQIXgAAKCRBy3lIGd+N/BI6RAJ9S97fvbME+3hxzE3JUyUZ6vTewDACdE1stFuSfqMvM jomvZdYxIYyTUpC5Ag0ERND5ghAIAPwsO0B7BL+bz8sLlLoQktGxXwXQfS5cInvL17Dsgnr3 1AKa94j9EnXQyPEj7u0d+LmEe6CGEGDh1OcGFTMVrof2ZzkSy4+FkZwMKJpTiqeaShMh+Goj XlwIMDxyADYvBIg3eN5YdFKaPQpfgSqhT+7El7w+wSZZD8pPQuLAnie5iz9C8iKy4/cMSOrH YUK/tO+Nhw8Jjlw94Ik0T80iEhI2t+XBVjwdfjbq3HrJ0ehqdBwukyeJRYKmbn298KOFQVHO EVbHA4rF/37jzaMadK43FgJ0SAhPPF5l4l89z5oPu0b/+5e2inA3b8J3iGZxywjM+Csq1tqz hltEc7Q+E08AAwUIAL+15XH8bPbjNJdVyg2CMl10JNW2wWg2Q6qdljeaRqeR6zFus7EZTwtX sNzs5bP8y51PSUDJbeiy2RNCNKWFMndM22TZnk3GNG45nQd4OwYK0RZVrikalmJY5Q6m7Z16 4yrZgIXFdKj2t8F+x613/SJW1lIr9/bDp4U9tw0V1g3l2dFtD3p3ZrQ3hpoDtoK70ioIAjjH aIXIAcm3FGZFXy503DOA0KaTWwvOVdYCFLm3zWuSOmrX/GsEc7ovasOWwjPn878qVjbUKWwx Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: <4c3b715f-28c3-44d1-f472-63edafab46d0@FreeBSD.org> Date: Fri, 25 Oct 2019 10:26:15 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <201910242110.x9OLA91Q073256@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 17:26:17 -0000 On 10/24/19 2:10 PM, Alexander Motin wrote: > Author: mav > Date: Thu Oct 24 21:10:09 2019 > New Revision: 354049 > URL: https://svnweb.freebsd.org/changeset/base/354049 > > Log: > MFC r351457 (by kib): amd64: rework PCPU allocation > > Move pcpu KVA out of .bss into dynamically allocated VA at > pmap_bootstrap(). This avoids demoting superpage mapping .data/.bss. > Also it makes possible to use pmap_qenter() for installation of > domain-local pcpu page on NUMA configs. > > Refactor pcpu and IST initialization by moving it to helper functions. I'll merge the bhyve change today, but this probably broke bhyve. There was a followup fix from kib with some other fixes for this beyond bhyve, or was that just fixes to the actual NUMA allocation of pcpu? -- John Baldwin From owner-svn-src-stable-12@freebsd.org Fri Oct 25 17:54:38 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7AE651766C2; Fri, 25 Oct 2019 17:54:38 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470BZk2dlnz3KC4; Fri, 25 Oct 2019 17:54:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E86C2A0DF; Fri, 25 Oct 2019 17:54:38 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PHscBU011284; Fri, 25 Oct 2019 17:54:38 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PHsbu0011283; Fri, 25 Oct 2019 17:54:37 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910251754.x9PHsbu0011283@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 25 Oct 2019 17:54:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354085 - in stable/12/sys/amd64/vmm: . amd X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys/amd64/vmm: . amd X-SVN-Commit-Revision: 354085 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 17:54:38 -0000 Author: mav Date: Fri Oct 25 17:54:37 2019 New Revision: 354085 URL: https://svnweb.freebsd.org/changeset/base/354085 Log: MFC r351591 (by jhb): Use get_pcpu() to fetch the current CPU's pcpu pointer. This avoids encoding knowledge about how pcpu objects are allocated and is also a few instructions shorter. Modified: stable/12/sys/amd64/vmm/amd/svm.c stable/12/sys/amd64/vmm/vmm_host.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/vmm/amd/svm.c ============================================================================== --- stable/12/sys/amd64/vmm/amd/svm.c Fri Oct 25 17:41:08 2019 (r354084) +++ stable/12/sys/amd64/vmm/amd/svm.c Fri Oct 25 17:54:37 2019 (r354085) @@ -102,9 +102,6 @@ SYSCTL_INT(_hw_vmm_svm, OID_AUTO, vmcb_clean, CTLFLAG_ static MALLOC_DEFINE(M_SVM, "svm", "svm"); static MALLOC_DEFINE(M_SVM_VLAPIC, "svm-vlapic", "svm-vlapic"); -/* Per-CPU context area. */ -extern struct pcpu __pcpu[]; - static uint32_t svm_feature = ~0U; /* AMD SVM features. */ SYSCTL_UINT(_hw_vmm_svm, OID_AUTO, features, CTLFLAG_RDTUN, &svm_feature, 0, "SVM features advertised by CPUID.8000000AH:EDX"); @@ -2054,7 +2051,7 @@ svm_vmrun(void *arg, int vcpu, register_t rip, pmap_t /* Launch Virtual Machine. */ VCPU_CTR1(vm, vcpu, "Resume execution at %#lx", state->rip); svm_dr_enter_guest(gctx); - svm_launch(vmcb_pa, gctx, &__pcpu[curcpu]); + svm_launch(vmcb_pa, gctx, get_pcpu()); svm_dr_leave_guest(gctx); CPU_CLR_ATOMIC(curcpu, &pmap->pm_active); Modified: stable/12/sys/amd64/vmm/vmm_host.h ============================================================================== --- stable/12/sys/amd64/vmm/vmm_host.h Fri Oct 25 17:41:08 2019 (r354084) +++ stable/12/sys/amd64/vmm/vmm_host.h Fri Oct 25 17:54:37 2019 (r354085) @@ -72,14 +72,11 @@ vmm_get_host_gdtrbase(void) return ((uint64_t)&gdt[NGDT * curcpu]); } -struct pcpu; -extern struct pcpu __pcpu[]; - static __inline uint64_t vmm_get_host_gsbase(void) { - return ((uint64_t)&__pcpu[curcpu]); + return ((uint64_t)get_pcpu()); } #endif From owner-svn-src-stable-12@freebsd.org Fri Oct 25 18:04:49 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6C900176C5E; Fri, 25 Oct 2019 18:04:49 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: from mail-yb1-xb43.google.com (mail-yb1-xb43.google.com [IPv6:2607:f8b0:4864:20::b43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470BpS2stSz3Ky5; Fri, 25 Oct 2019 18:04:48 +0000 (UTC) (envelope-from mavbsd@gmail.com) Received: by mail-yb1-xb43.google.com with SMTP id 206so1213148ybc.8; Fri, 25 Oct 2019 11:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=SgfjeGdKL2/3NDTKlFdweTNR3xaVTg76lnd0MHRTIsU=; b=dLCSXm9N1p/q7vnHZ+CkFyeepkrvuuk+LaPWJ2S7m/O91wDDE9WXHDl9yGK6apMff4 2AryMOOq48DZxyS/4phIuNm3Aj3xvVplzPJz0bsNedK37iKId60r00L39tcV0MZtlyzC am6+QXLahEIDKEVJVgoA/8dROuXOkgoTeIoR9wRwqQjvCaxGSkjJEYXJQLmjXzz0/bqg obvh62vw0ENAngTECK24IGimGU6LVM4zgjmNKu+7FvOng2xOf6G0QMF3IVGw5gkdJmFo rqDLz8BSy2aZp4/4/n7eoHgH9nj+/ivGUnZ/KQX0aKurKWVPIDZBNc7HODSYyo0HrWQM 7W1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=SgfjeGdKL2/3NDTKlFdweTNR3xaVTg76lnd0MHRTIsU=; b=q+3K/AD+lWQbuqHOZv7gusRRIxXTRdVHk5Y5NKD8yJyQS6UMGTiIys2ILQKJZP+pc2 BV8KUofVFL3j1mBhItobRvfg1NkK4P6OWIv/iITFPlp5O9DfWurJ83y5tXM+FkUuFcR+ /NAenfvIAOqGnPBWVLJtFw1Yk9iq8lOqKmkpQ692+u93RiV5ScXLJj25+1TV/b4awlu5 FJrLgJIrXQdQX9EBMX/u63aTKAFStIcY1e2Jdu5bZso11ZKSumf4LEiXoXB+dVzWiXKy dXQc8zuxVBnlrCd/d3PQID+QjMPdRXWPxxBJyBZTq0r9WyYZrfzAUfcnWm+6QUkwpZAq Y/wA== X-Gm-Message-State: APjAAAU80ILhh+2HG5IcPP8l5hyjrIdnBkcfYl1w6k1uol6+4+cE7iKj UcGkuWJ8YQy5GP5gOAMB8PUcE5/W X-Google-Smtp-Source: APXvYqyceZyPPOgiMolA/3gYyKmEmsQDsLkJIG+4vR7v0GpE6cN7MxS52IzE9k11maOdBoxl2SF7Qg== X-Received: by 2002:a25:d604:: with SMTP id n4mr4202110ybg.460.1572026686619; Fri, 25 Oct 2019 11:04:46 -0700 (PDT) Received: from mavoffice.ixsystems.com ([12.189.233.129]) by smtp.gmail.com with ESMTPSA id d16sm1148822ywh.74.2019.10.25.11.04.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 25 Oct 2019 11:04:45 -0700 (PDT) Sender: Alexander Motin Subject: Re: svn commit: r354049 - in stable/12/sys/amd64: amd64 include To: John Baldwin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org References: <201910242110.x9OLA91Q073256@repo.freebsd.org> <4c3b715f-28c3-44d1-f472-63edafab46d0@FreeBSD.org> From: Alexander Motin Autocrypt: addr=mav@FreeBSD.org; prefer-encrypt=mutual; keydata= mQENBFOzxAwBCADkPrax0pI2W/ig0CK9nRJJwsHitAGEZ2HZiFEuti+6/4UVxj81yr4ak/4g 9bKUyC7rMEAp/ZHNhd+MFCPAAcHPvtovnfykqE/vuosCS3wlSLloix2iKVLks0CwbLHGAyne 46lTQW74Xl/33c3W1Z6d8jD9gVFT/xaVzZ0U9xdzOmsYAZaAj4ki0tuxO9F7L+ct9grRe7iP g8t9hai7BL4ee3VRwk2JXnKb7UvBiVITKYWKz1jRvZIrjPokgEcCLOSlv7x/1kjuFnj3xWZU 7HSFFT8J93epBbrSSCsYsppIk2fZH41kaaFXsMQfTPH8wkeM6qwrvOh4HiQM08R+9tThABEB AAG0IUFsZXhhbmRlciBNb3RpbiA8bWF2QEZyZWVCU0Qub3JnPokBVwQTAQoAQQIbAwULCQgH AwUVCgkICwUWAwIBAAIeAQIXgAIZARYhBOmM88TmnMPNDledVYMYw5VbqyJ/BQJZYMKuBQkN McyiAAoJEIMYw5VbqyJ/tuUIAOG3ONOSNYqjK4eTZ1TVh9jdUBAhWk5nhDFnODN49Wj0AbYm 7aIqy8O1hnCDSZG5LttjSAo3UfXJZDKQM0BLb0gpRMBnAYqO6tdolLNqAbPGJBnGoPjsh24y 6KcbDaNnis+lD4GwPXwQM+92wZGhCUFElPV9NciZGVS65TNIgk7X+yEjjhD1MSWKKijZ1r9Z zIt4OzUTxxNOvzdlABZS88nNRdJkatOQJPmFdd1mpP6UzTNCiLUo1pIqOEtJgvVVDYq5WHY6 tciWWYdmZG/tIBexJmv2mV2OLVjXR6ZeKmntVH14H72/wRHJuYHQC+r5SVRcWWayrThsY6jZ Yr4+raS5AQ0EU7PEDAEIAOZgWf2cJIu+58IzP2dkXE/urj3tr4OqrB/yHGWUf71Lz6D0Fi6Z AXgDtmcFLGPfMyWuLAvSM+xmoguk7zC4hRBYvQycmIhuqBq1jO1Wp/Z+lpoPM/1cDYLn8Flv mI/c40MhUZh345DA4jYWWaZNjQHUWVQ1fPf595vdVVMPT/abE8E5DaF6fSkRmqFTmfYRkfbt 3ytU8NdUapDcJVY7cEP2nJBVNZPnOIObR/ZIgSxjjrG5o34yXoqeup8JvwEv+/NylzzuyXEZ R1EdEIzQ/a1nh/0j4NXtzZEqKW4aTWlmSqb6wN8jh1OSOOqkYsfnE3nfxcZbxi4IRoNQYlm5 9R8AEQEAAYkBPAQYAQoAJgIbDBYhBOmM88TmnMPNDledVYMYw5VbqyJ/BQJZYMLYBQkNMczM AAoJEIMYw5VbqyJ/TqgH/RQHClkvecE0262lwKoP/m0Mh4I5TLRgoJJn8S7G1BnqohYJkiLq A6xe6urGD7OqdNAl12UbrjWbdJV+zvea3vJoM4MZuYiYrGaXWxzFXqWJcPwMU9sAh8MRghHu uC5vgPb45Tnftw9/+n0i8GfVhQhOqepUGdQg4NPcXviSkoAvig6pp9Lcxisn0groUQKt15Gc sS9YcQWg3j9Hnipc6Mu416HX98Fb113NHJqc2geTHLkRyuBFOoyIqB6N9GKjzOAIzxxsVdl9 TevwGsrp4M4/RFzWbSgsbOnbE7454lmuVZGfReEjnUm8RHp9Q2UWKXlp3exlZjvOp/uVEpCg lz65AQ0EU7PEDAEIAOZgWf2cJIu+58IzP2dkXE/urj3tr4OqrB/yHGWUf71Lz6D0Fi6ZAXgD tmcFLGPfMyWuLAvSM+xmoguk7zC4hRBYvQycmIhuqBq1jO1Wp/Z+lpoPM/1cDYLn8FlvmI/c 40MhUZh345DA4jYWWaZNjQHUWVQ1fPf595vdVVMPT/abE8E5DaF6fSkRmqFTmfYRkfbt3ytU 8NdUapDcJVY7cEP2nJBVNZPnOIObR/ZIgSxjjrG5o34yXoqeup8JvwEv+/NylzzuyXEZR1Ed EIzQ/a1nh/0j4NXtzZEqKW4aTWlmSqb6wN8jh1OSOOqkYsfnE3nfxcZbxi4IRoNQYlm59R8A EQEAAYkBPAQYAQoAJgIbDBYhBOmM88TmnMPNDledVYMYw5VbqyJ/BQJZYMLYBQkNMczMAAoJ EIMYw5VbqyJ/TqgH/RQHClkvecE0262lwKoP/m0Mh4I5TLRgoJJn8S7G1BnqohYJkiLqA6xe 6urGD7OqdNAl12UbrjWbdJV+zvea3vJoM4MZuYiYrGaXWxzFXqWJcPwMU9sAh8MRghHuuC5v gPb45Tnftw9/+n0i8GfVhQhOqepUGdQg4NPcXviSkoAvig6pp9Lcxisn0groUQKt15GcsS9Y cQWg3j9Hnipc6Mu416HX98Fb113NHJqc2geTHLkRyuBFOoyIqB6N9GKjzOAIzxxsVdl9Tevw Gsrp4M4/RFzWbSgsbOnbE7454lmuVZGfReEjnUm8RHp9Q2UWKXlp3exlZjvOp/uVEpCglz4= Message-ID: Date: Fri, 25 Oct 2019 14:04:45 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: <4c3b715f-28c3-44d1-f472-63edafab46d0@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 470BpS2stSz3Ky5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=dLCSXm9N; dmarc=none; spf=pass (mx1.freebsd.org: domain of mavbsd@gmail.com designates 2607:f8b0:4864:20::b43 as permitted sender) smtp.mailfrom=mavbsd@gmail.com X-Spamd-Result: default: False [-2.77 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[FreeBSD.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; IP_SCORE(-0.57)[ip: (1.66), ipnet: 2607:f8b0::/32(-2.41), asn: 15169(-2.05), country: US(-0.05)]; DKIM_TRACE(0.00)[gmail.com:+]; RCVD_IN_DNSWL_NONE(0.00)[3.4.b.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FORGED_SENDER(0.30)[mav@FreeBSD.org,mavbsd@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[mav@FreeBSD.org,mavbsd@gmail.com]; MID_RHS_MATCH_FROM(0.00)[] X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 18:04:49 -0000 On 25.10.2019 13:26, John Baldwin wrote: > On 10/24/19 2:10 PM, Alexander Motin wrote: >> Author: mav >> Date: Thu Oct 24 21:10:09 2019 >> New Revision: 354049 >> URL: https://svnweb.freebsd.org/changeset/base/354049 >> >> Log: >> MFC r351457 (by kib): amd64: rework PCPU allocation >> >> Move pcpu KVA out of .bss into dynamically allocated VA at >> pmap_bootstrap(). This avoids demoting superpage mapping .data/.bss. >> Also it makes possible to use pmap_qenter() for installation of >> domain-local pcpu page on NUMA configs. >> >> Refactor pcpu and IST initialization by moving it to helper functions. > > I'll merge the bhyve change today, but this probably broke bhyve. There > was a followup fix from kib with some other fixes for this beyond bhyve, > or was that just fixes to the actual NUMA allocation of pcpu? Oops, I've missed the bhyve fix. Merged it now. Thanks for notice. As far as I see, the bhyve issue was one of its kind. There were few pcpu allocation fixes, which I merged, and one header reorganization patch, which I think is cosmetic, so I haven't merged it so far, but will take another look. -- Alexander Motin From owner-svn-src-stable-12@freebsd.org Fri Oct 25 18:17:58 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18DC6177B04; Fri, 25 Oct 2019 18:17:58 +0000 (UTC) (envelope-from tuexen@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470C5d6wcdz3MgP; Fri, 25 Oct 2019 18:17:57 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id CBC7E2A472; Fri, 25 Oct 2019 18:17:57 +0000 (UTC) (envelope-from tuexen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PIHvbV023880; Fri, 25 Oct 2019 18:17:57 GMT (envelope-from tuexen@FreeBSD.org) Received: (from tuexen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PIHvpw023878; Fri, 25 Oct 2019 18:17:57 GMT (envelope-from tuexen@FreeBSD.org) Message-Id: <201910251817.x9PIHvpw023878@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tuexen set sender to tuexen@FreeBSD.org using -f From: Michael Tuexen Date: Fri, 25 Oct 2019 18:17:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354090 - in stable/12/sys: netinet netinet6 X-SVN-Group: stable-12 X-SVN-Commit-Author: tuexen X-SVN-Commit-Paths: in stable/12/sys: netinet netinet6 X-SVN-Commit-Revision: 354090 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 18:17:58 -0000 Author: tuexen Date: Fri Oct 25 18:17:56 2019 New Revision: 354090 URL: https://svnweb.freebsd.org/changeset/base/354090 Log: MFC r354044: Ensure that the flags indicating IPv4/IPv6 are not changed by failing bind() calls. This would lead to inconsistent state resulting in a panic. A fix for stable/11 was committed in https://svnweb.freebsd.org/base?view=revision&revision=338986 Reported by: syzbot+2609a378d89264ff5a42@syzkaller.appspotmail.com Obtained from: jtl@ Sponsored by: Netflix, Inc. Modified: stable/12/sys/netinet/tcp_usrreq.c stable/12/sys/netinet6/sctp6_usrreq.c stable/12/sys/netinet6/udp6_usrreq.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/netinet/tcp_usrreq.c ============================================================================== --- stable/12/sys/netinet/tcp_usrreq.c Fri Oct 25 18:10:02 2019 (r354089) +++ stable/12/sys/netinet/tcp_usrreq.c Fri Oct 25 18:17:56 2019 (r354090) @@ -345,6 +345,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct inpcb *inp; struct tcpcb *tp = NULL; struct sockaddr_in6 *sin6p; + u_char vflagsav; sin6p = (struct sockaddr_in6 *)nam; if (nam->sa_len != sizeof (*sin6p)) @@ -361,6 +362,7 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp6_usr_bind: inp == NULL")); INP_WLOCK(inp); + vflagsav = inp->inp_vflag; if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { error = EINVAL; goto out; @@ -395,6 +397,8 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, error = in6_pcbbind(inp, nam, td->td_ucred); INP_HASH_WUNLOCK(&V_tcbinfo); out: + if (error != 0) + inp->inp_vflag = vflagsav; TCPDEBUG2(PRU_BIND); TCP_PROBE2(debug__user, tp, PRU_BIND); INP_WUNLOCK(inp); @@ -457,6 +461,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; + u_char vflagsav; TCPDEBUG0; inp = sotoinpcb(so); @@ -466,6 +471,7 @@ tcp6_usr_listen(struct socket *so, int backlog, struct error = EINVAL; goto out; } + vflagsav = inp->inp_vflag; tp = intotcpcb(inp); TCPDEBUG1(); SOCK_LOCK(so); @@ -491,6 +497,9 @@ tcp6_usr_listen(struct socket *so, int backlog, struct if (IS_FASTOPEN(tp->t_flags)) tp->t_tfo_pending = tcp_fastopen_alloc_counter(); + if (error != 0) + inp->inp_vflag = vflagsav; + out: TCPDEBUG2(PRU_LISTEN); TCP_PROBE2(debug__user, tp, PRU_LISTEN); @@ -567,6 +576,8 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n struct inpcb *inp; struct tcpcb *tp = NULL; struct sockaddr_in6 *sin6p; + u_int8_t incflagsav; + u_char vflagsav; TCPDEBUG0; @@ -583,6 +594,8 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp6_usr_connect: inp == NULL")); INP_WLOCK(inp); + vflagsav = inp->inp_vflag; + incflagsav = inp->inp_inc.inc_flags; if (inp->inp_flags & INP_TIMEWAIT) { error = EADDRINUSE; goto out; @@ -616,11 +629,11 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n error = EAFNOSUPPORT; goto out; } - inp->inp_vflag |= INP_IPV4; - inp->inp_vflag &= ~INP_IPV6; if ((error = prison_remote_ip4(td->td_ucred, &sin.sin_addr)) != 0) goto out; + inp->inp_vflag |= INP_IPV4; + inp->inp_vflag &= ~INP_IPV6; if ((error = tcp_connect(tp, (struct sockaddr *)&sin, td)) != 0) goto out; #ifdef TCP_OFFLOAD @@ -638,11 +651,11 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n } } #endif + if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0) + goto out; inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; inp->inp_inc.inc_flags |= INC_ISIPV6; - if ((error = prison_remote_ip6(td->td_ucred, &sin6p->sin6_addr)) != 0) - goto out; if ((error = tcp6_connect(tp, nam, td)) != 0) goto out; #ifdef TCP_OFFLOAD @@ -655,6 +668,15 @@ tcp6_usr_connect(struct socket *so, struct sockaddr *n error = tp->t_fb->tfb_tcp_output(tp); out: + /* + * If the implicit bind in the connect call fails, restore + * the flags we modified. + */ + if (error != 0 && inp->inp_lport == 0) { + inp->inp_vflag = vflagsav; + inp->inp_inc.inc_flags = incflagsav; + } + TCPDEBUG2(PRU_CONNECT); TCP_PROBE2(debug__user, tp, PRU_CONNECT); INP_WUNLOCK(inp); @@ -910,6 +932,9 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf #ifdef INET6 int isipv6; #endif + u_int8_t incflagsav; + u_char vflagsav; + bool restoreflags; TCPDEBUG0; /* @@ -921,6 +946,9 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf inp = sotoinpcb(so); KASSERT(inp != NULL, ("tcp_usr_send: inp == NULL")); INP_WLOCK(inp); + vflagsav = inp->inp_vflag; + incflagsav = inp->inp_inc.inc_flags; + restoreflags = false; if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { if (control) m_freem(control); @@ -1001,6 +1029,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf m_freem(m); goto out; } + restoreflags = true; inp->inp_vflag &= ~INP_IPV6; sinp = &sin; in6_sin6_2_sin(sinp, sin6p); @@ -1031,6 +1060,7 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf error = EAFNOSUPPORT; goto out; } + restoreflags = true; inp->inp_vflag &= ~INP_IPV4; inp->inp_inc.inc_flags |= INC_ISIPV6; if ((error = prison_remote_ip6(td->td_ucred, @@ -1081,6 +1111,14 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf error = tcp_connect(tp, (struct sockaddr *)sinp, td); #endif + /* + * The bind operation in tcp_connect succeeded. We + * no longer want to restore the flags if later + * operations fail. + */ + if (error == 0 || inp->inp_lport != 0) + restoreflags = false; + if (error) goto out; if (IS_FASTOPEN(tp->t_flags)) @@ -1151,6 +1189,14 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf error = tcp_connect(tp, (struct sockaddr *)sinp, td); #endif + /* + * The bind operation in tcp_connect succeeded. We + * no longer want to restore the flags if later + * operations fail. + */ + if (error == 0 || inp->inp_lport != 0) + restoreflags = false; + if (error) goto out; tp->snd_wnd = TTCP_CLIENT_SND_WND; @@ -1169,6 +1215,14 @@ tcp_usr_send(struct socket *so, int flags, struct mbuf TCP_LOG_USERSEND, error, 0, NULL, false); out: + /* + * If the request was unsuccessful and we changed flags, + * restore the original flags. + */ + if (error != 0 && restoreflags) { + inp->inp_vflag = vflagsav; + inp->inp_inc.inc_flags = incflagsav; + } TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB : ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); TCP_PROBE2(debug__user, tp, (flags & PRUS_OOB) ? PRU_SENDOOB : Modified: stable/12/sys/netinet6/sctp6_usrreq.c ============================================================================== --- stable/12/sys/netinet6/sctp6_usrreq.c Fri Oct 25 18:10:02 2019 (r354089) +++ stable/12/sys/netinet6/sctp6_usrreq.c Fri Oct 25 18:17:56 2019 (r354090) @@ -563,6 +563,7 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, s struct sctp_inpcb *inp; struct in6pcb *inp6; int error; + u_char vflagsav; inp = (struct sctp_inpcb *)so->so_pcb; if (inp == NULL) { @@ -594,6 +595,7 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, s } } inp6 = (struct in6pcb *)inp; + vflagsav = inp6->inp_vflag; inp6->inp_vflag &= ~INP_IPV4; inp6->inp_vflag |= INP_IPV6; if ((addr != NULL) && (SCTP_IPV6_V6ONLY(inp6) == 0)) { @@ -623,7 +625,7 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, s inp6->inp_vflag |= INP_IPV4; inp6->inp_vflag &= ~INP_IPV6; error = sctp_inpcb_bind(so, (struct sockaddr *)&sin, NULL, p); - return (error); + goto out; } #endif break; @@ -640,7 +642,8 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, s if (addr->sa_family == AF_INET) { /* can't bind v4 addr to v6 only socket! */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); - return (EINVAL); + error = EINVAL; + goto out; } #endif sin6_p = (struct sockaddr_in6 *)addr; @@ -649,10 +652,14 @@ sctp6_bind(struct socket *so, struct sockaddr *addr, s /* can't bind v4-mapped addrs either! */ /* NOTE: we don't support SIIT */ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP6_USRREQ, EINVAL); - return (EINVAL); + error = EINVAL; + goto out; } } error = sctp_inpcb_bind(so, addr, NULL, p); +out: + if (error != 0) + inp6->inp_vflag = vflagsav; return (error); } Modified: stable/12/sys/netinet6/udp6_usrreq.c ============================================================================== --- stable/12/sys/netinet6/udp6_usrreq.c Fri Oct 25 18:10:02 2019 (r354089) +++ stable/12/sys/netinet6/udp6_usrreq.c Fri Oct 25 18:17:56 2019 (r354090) @@ -1143,6 +1143,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, str struct inpcb *inp; struct inpcbinfo *pcbinfo; int error; + u_char vflagsav; pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); @@ -1150,6 +1151,7 @@ udp6_bind(struct socket *so, struct sockaddr *nam, str INP_WLOCK(inp); INP_HASH_WLOCK(pcbinfo); + vflagsav = inp->inp_vflag; inp->inp_vflag &= ~INP_IPV4; inp->inp_vflag |= INP_IPV6; if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) { @@ -1177,6 +1179,8 @@ udp6_bind(struct socket *so, struct sockaddr *nam, str #ifdef INET out: #endif + if (error != 0) + inp->inp_vflag = vflagsav; INP_HASH_WUNLOCK(pcbinfo); INP_WUNLOCK(inp); return (error); @@ -1223,6 +1227,7 @@ udp6_connect(struct socket *so, struct sockaddr *nam, struct inpcbinfo *pcbinfo; struct sockaddr_in6 *sin6; int error; + u_char vflagsav; pcbinfo = udp_get_inpcbinfo(so->so_proto->pr_protocol); inp = sotoinpcb(so); @@ -1250,17 +1255,26 @@ udp6_connect(struct socket *so, struct sockaddr *nam, goto out; } in6_sin6_2_sin(&sin, sin6); - inp->inp_vflag |= INP_IPV4; - inp->inp_vflag &= ~INP_IPV6; error = prison_remote_ip4(td->td_ucred, &sin.sin_addr); if (error != 0) goto out; + vflagsav = inp->inp_vflag; + inp->inp_vflag |= INP_IPV4; + inp->inp_vflag &= ~INP_IPV6; INP_HASH_WLOCK(pcbinfo); error = in_pcbconnect(inp, (struct sockaddr *)&sin, td->td_ucred); INP_HASH_WUNLOCK(pcbinfo); + /* + * If connect succeeds, mark socket as connected. If + * connect fails and socket is unbound, reset inp_vflag + * field. + */ if (error == 0) soisconnected(so); + else if (inp->inp_laddr.s_addr == INADDR_ANY && + inp->inp_lport == 0) + inp->inp_vflag = vflagsav; goto out; } else { if ((inp->inp_vflag & INP_IPV6) == 0) { @@ -1273,16 +1287,25 @@ udp6_connect(struct socket *so, struct sockaddr *nam, error = EISCONN; goto out; } - inp->inp_vflag &= ~INP_IPV4; - inp->inp_vflag |= INP_IPV6; error = prison_remote_ip6(td->td_ucred, &sin6->sin6_addr); if (error != 0) goto out; + vflagsav = inp->inp_vflag; + inp->inp_vflag &= ~INP_IPV4; + inp->inp_vflag |= INP_IPV6; INP_HASH_WLOCK(pcbinfo); error = in6_pcbconnect(inp, nam, td->td_ucred); INP_HASH_WUNLOCK(pcbinfo); + /* + * If connect succeeds, mark socket as connected. If + * connect fails and socket is unbound, reset inp_vflag + * field. + */ if (error == 0) soisconnected(so); + else if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr) && + inp->inp_lport == 0) + inp->inp_vflag = vflagsav; out: INP_WUNLOCK(inp); return (error); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 18:56:52 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 942A31586A1; Fri, 25 Oct 2019 18:56:52 +0000 (UTC) (envelope-from mav@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470CyX48nLz3Pc1; Fri, 25 Oct 2019 18:56:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 71A8B2ABDB; Fri, 25 Oct 2019 18:56:52 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PIuqG6047694; Fri, 25 Oct 2019 18:56:52 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PIuk3B047667; Fri, 25 Oct 2019 18:56:46 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201910251856.x9PIuk3B047667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Fri, 25 Oct 2019 18:56:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354093 - in stable/12/sys: amd64/amd64 amd64/include arm/arm arm/include arm64/arm64 arm64/include i386/i386 i386/include mips/include powerpc/include powerpc/powerpc riscv/include ris... X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 amd64/include arm/arm arm/include arm64/arm64 arm64/include i386/i386 i386/include mips/include powerpc/include powerpc/powerpc riscv/include riscv/riscv sparc64/include ... X-SVN-Commit-Revision: 354093 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 18:56:52 -0000 Author: mav Date: Fri Oct 25 18:56:46 2019 New Revision: 354093 URL: https://svnweb.freebsd.org/changeset/base/354093 Log: MFC r351594 (by kib): Centralize __pcpu definitions. Many extern struct pcpu __pcpu declarations were copied/pasted in sources. The issue is that the definition is MD, but it cannot be provided by machine/pcpu.h due to actual struct pcpu defined in sys/pcpu.h later than the inclusion of machine/pcpu.h. This forced the copying when other code needed direct access to __pcpu. There is no way around it, due to machine/pcpu.h supplying part of struct pcpu fields. To work around the problem, add a new machine/pcpu_aux.h header, which should fill any needed MD definitions after struct pcpu definition is completed. This allows to remove copies of __pcpu spread around the source. Also on x86 it makes it possible to remove work arounds like OFFSETOF_CURTHREAD or clang specific warnings supressions. Added: stable/12/sys/amd64/include/pcpu_aux.h - copied unchanged from r351594, head/sys/amd64/include/pcpu_aux.h stable/12/sys/arm/include/pcpu_aux.h - copied unchanged from r351594, head/sys/arm/include/pcpu_aux.h stable/12/sys/arm64/include/pcpu_aux.h - copied unchanged from r351594, head/sys/arm64/include/pcpu_aux.h stable/12/sys/i386/include/pcpu_aux.h - copied unchanged from r351594, head/sys/i386/include/pcpu_aux.h stable/12/sys/mips/include/pcpu_aux.h - copied unchanged from r351594, head/sys/mips/include/pcpu_aux.h stable/12/sys/powerpc/include/pcpu_aux.h - copied unchanged from r351594, head/sys/powerpc/include/pcpu_aux.h stable/12/sys/riscv/include/pcpu_aux.h - copied unchanged from r351594, head/sys/riscv/include/pcpu_aux.h stable/12/sys/sparc64/include/pcpu_aux.h - copied unchanged from r351594, head/sys/sparc64/include/pcpu_aux.h Modified: stable/12/sys/amd64/amd64/mp_machdep.c stable/12/sys/amd64/amd64/pmap.c stable/12/sys/amd64/amd64/vm_machdep.c stable/12/sys/amd64/include/counter.h stable/12/sys/amd64/include/pcpu.h stable/12/sys/arm/arm/mp_machdep.c stable/12/sys/arm/include/counter.h stable/12/sys/arm64/arm64/mp_machdep.c stable/12/sys/arm64/include/counter.h stable/12/sys/i386/i386/mp_machdep.c stable/12/sys/i386/i386/vm_machdep.c stable/12/sys/i386/include/counter.h stable/12/sys/i386/include/pcpu.h stable/12/sys/powerpc/include/counter.h stable/12/sys/powerpc/powerpc/mp_machdep.c stable/12/sys/riscv/include/counter.h stable/12/sys/riscv/riscv/mp_machdep.c stable/12/sys/sys/pcpu.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/mp_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/amd64/amd64/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -94,8 +94,6 @@ __FBSDID("$FreeBSD$"); #define AP_BOOTPT_SZ (PAGE_SIZE * 3) -extern struct pcpu *__pcpu; - /* Temporary variables for init_secondary() */ char *doublefault_stack; char *mce_stack; Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/amd64/amd64/pmap.c Fri Oct 25 18:56:46 2019 (r354093) @@ -446,10 +446,6 @@ static pml4_entry_t *pti_pml4; static vm_pindex_t pti_pg_idx; static bool pti_finalized; -extern struct pcpu *__pcpu; -extern struct pcpu temp_bsp_pcpu; -extern pt_entry_t *pcpu_pte; - struct pmap_pkru_range { struct rs_el pkru_rs_el; u_int pkru_keyidx; Modified: stable/12/sys/amd64/amd64/vm_machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/vm_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/amd64/amd64/vm_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -84,10 +84,6 @@ __FBSDID("$FreeBSD$"); #include #include -_Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread), - "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread."); -_Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), - "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), "OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); Modified: stable/12/sys/amd64/include/counter.h ============================================================================== --- stable/12/sys/amd64/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/amd64/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -33,9 +33,6 @@ #include -extern struct pcpu *__pcpu; -extern struct pcpu temp_bsp_pcpu; - #define EARLY_COUNTER &temp_bsp_pcpu.pc_early_dummy_counter #define counter_enter() do {} while (0) Modified: stable/12/sys/amd64/include/pcpu.h ============================================================================== --- stable/12/sys/amd64/include/pcpu.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/amd64/include/pcpu.h Fri Oct 25 18:56:46 2019 (r354093) @@ -221,35 +221,6 @@ #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) -#define OFFSETOF_CURTHREAD 0 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -static __inline __pure2 struct thread * -__curthread(void) -{ - struct thread *td; - - __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (OFFSETOF_CURTHREAD)); - return (td); -} -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#define curthread (__curthread()) - -#define OFFSETOF_CURPCB 32 -static __inline __pure2 struct pcb * -__curpcb(void) -{ - struct pcb *pcb; - - __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (OFFSETOF_CURPCB)); - return (pcb); -} -#define curpcb (__curpcb()) - #define IS_BSP() (PCPU_GET(cpuid) == 0) #else /* !__GNUCLIKE_ASM || !__GNUCLIKE___TYPEOF */ Copied: stable/12/sys/amd64/include/pcpu_aux.h (from r351594, head/sys/amd64/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/amd64/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/amd64/include/pcpu_aux.h) @@ -0,0 +1,72 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* Required for counters(9) to work on x86. */ +_Static_assert(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE, "fix pcpu size"); + +extern struct pcpu *__pcpu; +extern struct pcpu temp_bsp_pcpu; + +static __inline __pure2 struct thread * +__curthread(void) +{ + struct thread *td; + + __asm("movq %%gs:%P1,%0" : "=r" (td) : "n" (offsetof(struct pcpu, + pc_curthread))); + return (td); +} +#define curthread (__curthread()) + +static __inline __pure2 struct pcb * +__curpcb(void) +{ + struct pcb *pcb; + + __asm("movq %%gs:%P1,%0" : "=r" (pcb) : "n" (offsetof(struct pcpu, + pc_curpcb))); + return (pcb); +} +#define curpcb (__curpcb()) + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/arm/arm/mp_machdep.c ============================================================================== --- stable/12/sys/arm/arm/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/arm/arm/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$"); #include #endif -extern struct pcpu __pcpu[]; /* used to hold the AP's until we are ready to release them */ struct mtx ap_boot_mtx; struct pcb stoppcbs[MAXCPU]; Modified: stable/12/sys/arm/include/counter.h ============================================================================== --- stable/12/sys/arm/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/arm/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -34,8 +34,6 @@ #include #include -extern struct pcpu __pcpu[]; - #define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter #define counter_enter() do {} while (0) Copied: stable/12/sys/arm/include/pcpu_aux.h (from r351594, head/sys/arm/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/arm/include/pcpu_aux.h) @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/arm64/arm64/mp_machdep.c ============================================================================== --- stable/12/sys/arm64/arm64/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/arm64/arm64/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -110,8 +111,6 @@ static struct intr_ipi ipi_sources[INTR_IPI_COUNT]; static struct intr_ipi *intr_ipi_lookup(u_int); static void intr_pic_ipi_setup(u_int, const char *, intr_ipi_handler_t *, void *); - -extern struct pcpu __pcpu[]; static device_identify_t arm64_cpu_identify; static device_probe_t arm64_cpu_probe; Modified: stable/12/sys/arm64/include/counter.h ============================================================================== --- stable/12/sys/arm64/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/arm64/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -32,8 +32,6 @@ #include #include -extern struct pcpu __pcpu[]; - #define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter #define counter_enter() do {} while (0) Copied: stable/12/sys/arm64/include/pcpu_aux.h (from r351594, head/sys/arm64/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/arm64/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/arm64/include/pcpu_aux.h) @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/i386/i386/mp_machdep.c ============================================================================== --- stable/12/sys/i386/i386/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/i386/i386/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -130,8 +130,6 @@ __FBSDID("$FreeBSD$"); #endif /* CHECK_POINTS */ -extern struct pcpu __pcpu[]; - /* * Local data and functions. */ Modified: stable/12/sys/i386/i386/vm_machdep.c ============================================================================== --- stable/12/sys/i386/i386/vm_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/i386/i386/vm_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -90,10 +90,6 @@ __FBSDID("$FreeBSD$"); #define NSFBUFS (512 + maxusers * 16) #endif -_Static_assert(OFFSETOF_CURTHREAD == offsetof(struct pcpu, pc_curthread), - "OFFSETOF_CURTHREAD does not correspond with offset of pc_curthread."); -_Static_assert(OFFSETOF_CURPCB == offsetof(struct pcpu, pc_curpcb), - "OFFSETOF_CURPCB does not correspond with offset of pc_curpcb."); _Static_assert(__OFFSETOF_MONITORBUF == offsetof(struct pcpu, pc_monitorbuf), "__OFFSETOF_MONITORBUF does not correspond with offset of pc_monitorbuf."); Modified: stable/12/sys/i386/include/counter.h ============================================================================== --- stable/12/sys/i386/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/i386/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -38,8 +38,6 @@ #include #include -extern struct pcpu __pcpu[]; - #define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter #define counter_enter() do { \ Modified: stable/12/sys/i386/include/pcpu.h ============================================================================== --- stable/12/sys/i386/include/pcpu.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/i386/include/pcpu.h Fri Oct 25 18:56:46 2019 (r354093) @@ -217,36 +217,6 @@ #define PCPU_PTR(member) __PCPU_PTR(pc_ ## member) #define PCPU_SET(member, val) __PCPU_SET(pc_ ## member, val) -#define OFFSETOF_CURTHREAD 0 -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wnull-dereference" -#endif -static __inline __pure2 struct thread * -__curthread(void) -{ - struct thread *td; - - __asm("movl %%fs:%1,%0" : "=r" (td) - : "m" (*(char *)OFFSETOF_CURTHREAD)); - return (td); -} -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#define curthread (__curthread()) - -#define OFFSETOF_CURPCB 16 -static __inline __pure2 struct pcb * -__curpcb(void) -{ - struct pcb *pcb; - - __asm("movl %%fs:%1,%0" : "=r" (pcb) : "m" (*(char *)OFFSETOF_CURPCB)); - return (pcb); -} -#define curpcb (__curpcb()) - #define IS_BSP() (PCPU_GET(cpuid) == 0) #else /* defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE___TYPEOF) */ Copied: stable/12/sys/i386/include/pcpu_aux.h (from r351594, head/sys/i386/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/i386/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/i386/include/pcpu_aux.h) @@ -0,0 +1,71 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* Required for counters(9) to work on x86. */ +_Static_assert(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +static __inline __pure2 struct thread * +__curthread(void) +{ + struct thread *td; + + __asm("movl %%fs:%1,%0" : "=r" (td) + : "m" (*(char *)offsetof(struct pcpu, pc_curthread))); + return (td); +} +#define curthread (__curthread()) + +static __inline __pure2 struct pcb * +__curpcb(void) +{ + struct pcb *pcb; + + __asm("movl %%fs:%1,%0" : "=r" (pcb) + : "m" (*(char *)offsetof(struct pcpu, pc_curpcb))); + return (pcb); +} +#define curpcb (__curpcb()) + +#endif /* _MACHINE_PCPU_AUX_H_ */ Copied: stable/12/sys/mips/include/pcpu_aux.h (from r351594, head/sys/mips/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/mips/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/mips/include/pcpu_aux.h) @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/powerpc/include/counter.h ============================================================================== --- stable/12/sys/powerpc/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/powerpc/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -36,8 +36,6 @@ #include #endif -extern struct pcpu __pcpu[]; - #define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter #ifdef __powerpc64__ Copied: stable/12/sys/powerpc/include/pcpu_aux.h (from r351594, head/sys/powerpc/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/powerpc/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/powerpc/include/pcpu_aux.h) @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/powerpc/powerpc/mp_machdep.c ============================================================================== --- stable/12/sys/powerpc/powerpc/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/powerpc/powerpc/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -61,8 +61,6 @@ __FBSDID("$FreeBSD$"); #include "pic_if.h" -extern struct pcpu __pcpu[MAXCPU]; - volatile static int ap_awake; volatile static u_int ap_letgo; volatile static u_quad_t ap_timebase; Modified: stable/12/sys/riscv/include/counter.h ============================================================================== --- stable/12/sys/riscv/include/counter.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/riscv/include/counter.h Fri Oct 25 18:56:46 2019 (r354093) @@ -34,8 +34,6 @@ #include #endif -extern struct pcpu __pcpu[]; - #define EARLY_COUNTER &__pcpu[0].pc_early_dummy_counter #define counter_enter() critical_enter() Copied: stable/12/sys/riscv/include/pcpu_aux.h (from r351594, head/sys/riscv/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/riscv/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/riscv/include/pcpu_aux.h) @@ -0,0 +1,52 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +extern struct pcpu __pcpu[]; + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/riscv/riscv/mp_machdep.c ============================================================================== --- stable/12/sys/riscv/riscv/mp_machdep.c Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/riscv/riscv/mp_machdep.c Fri Oct 25 18:56:46 2019 (r354093) @@ -71,8 +71,6 @@ __FBSDID("$FreeBSD$"); boolean_t ofw_cpu_reg(phandle_t node, u_int, cell_t *); -extern struct pcpu __pcpu[]; - uint32_t __riscv_boot_ap[MAXCPU]; static enum { Copied: stable/12/sys/sparc64/include/pcpu_aux.h (from r351594, head/sys/sparc64/include/pcpu_aux.h) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/sparc64/include/pcpu_aux.h Fri Oct 25 18:56:46 2019 (r354093, copy of r351594, head/sys/sparc64/include/pcpu_aux.h) @@ -0,0 +1,50 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2019 The FreeBSD Foundation + * + * This software was developed by Konstantin Belousov + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _MACHINE_PCPU_AUX_H_ +#define _MACHINE_PCPU_AUX_H_ + +#ifndef _KERNEL +#error "Not for userspace" +#endif + +#ifndef _SYS_PCPU_H_ +#error "Do not include machine/pcpu_aux.h directly" +#endif + +/* + * To minimize memory waste in per-cpu UMA zones, the page size should + * be a multiple of the size of struct pcpu. + */ +_Static_assert(PAGE_SIZE % sizeof(struct pcpu) == 0, "fix pcpu size"); + +#endif /* _MACHINE_PCPU_AUX_H_ */ Modified: stable/12/sys/sys/pcpu.h ============================================================================== --- stable/12/sys/sys/pcpu.h Fri Oct 25 18:54:06 2019 (r354092) +++ stable/12/sys/sys/pcpu.h Fri Oct 25 18:56:46 2019 (r354093) @@ -213,26 +213,16 @@ extern struct cpuhead cpuhead; extern struct pcpu *cpuid_to_pcpu[]; #define curcpu PCPU_GET(cpuid) -#define curproc (curthread->td_proc) -#ifndef curthread -#define curthread PCPU_GET(curthread) -#endif #define curvidata PCPU_GET(vidata) #define UMA_PCPU_ALLOC_SIZE PAGE_SIZE -#ifdef CTASSERT -#if defined(__i386__) || defined(__amd64__) -/* Required for counters(9) to work on x86. */ -CTASSERT(sizeof(struct pcpu) == UMA_PCPU_ALLOC_SIZE); -#else -/* - * To minimize memory waste in per-cpu UMA zones, size of struct pcpu - * should be denominator of PAGE_SIZE. - */ -CTASSERT((PAGE_SIZE / sizeof(struct pcpu)) * sizeof(struct pcpu) == PAGE_SIZE); -#endif /* UMA_PCPU_ALLOC_SIZE && x86 */ -#endif /* CTASSERT */ +#include + +#ifndef curthread +#define curthread PCPU_GET(curthread) +#endif +#define curproc (curthread->td_proc) /* Accessor to elements allocated via UMA_ZONE_PCPU zone. */ static inline void * From owner-svn-src-stable-12@freebsd.org Fri Oct 25 21:14:44 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 059C515B668; Fri, 25 Oct 2019 21:14:44 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470H1b6PS4z4448; Fri, 25 Oct 2019 21:14:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C05762C583; Fri, 25 Oct 2019 21:14:43 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PLEhaP033626; Fri, 25 Oct 2019 21:14:43 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PLEhIM033625; Fri, 25 Oct 2019 21:14:43 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252114.x9PLEhIM033625@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 21:14:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354098 - in stable: 11/sys/dev/cxgbe/crypto 12/sys/dev/cxgbe/crypto X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/dev/cxgbe/crypto 12/sys/dev/cxgbe/crypto X-SVN-Commit-Revision: 354098 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 21:14:44 -0000 Author: jhb Date: Fri Oct 25 21:14:43 2019 New Revision: 354098 URL: https://svnweb.freebsd.org/changeset/base/354098 Log: MFC 353323: Set the FID field in lookaside crypto requests to the rx queue ID. The PCI block in the adapter requires this field to be set to a valid queue ID. It is not clear why it did not fail on all machines, but the effect was that crypto operations reading input data via DMA failed with an internal PCI read error on machines with 128G or more of RAM. Modified: stable/12/sys/dev/cxgbe/crypto/t4_crypto.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/cxgbe/crypto/t4_crypto.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/cxgbe/crypto/t4_crypto.c ============================================================================== --- stable/12/sys/dev/cxgbe/crypto/t4_crypto.c Fri Oct 25 21:00:49 2019 (r354097) +++ stable/12/sys/dev/cxgbe/crypto/t4_crypto.c Fri Oct 25 21:14:43 2019 (r354098) @@ -419,7 +419,7 @@ ccr_populate_wreq(struct ccr_softc *sc, struct chcr_wr crwr->ulptx.cmd_dest = htobe32(V_ULPTX_CMD(ULP_TX_PKT) | V_ULP_TXPKT_DATAMODIFY(0) | V_ULP_TXPKT_CHANNELID(sc->tx_channel_id) | V_ULP_TXPKT_DEST(0) | - V_ULP_TXPKT_FID(0) | V_ULP_TXPKT_RO(1)); + V_ULP_TXPKT_FID(sc->rxq->iq.abs_id) | V_ULP_TXPKT_RO(1)); crwr->ulptx.len = htobe32( ((wr_len - sizeof(struct fw_crypto_lookaside_wr)) / 16)); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 21:20:05 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id A898915B821; Fri, 25 Oct 2019 21:20:05 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470H7n3y4qz44Kv; Fri, 25 Oct 2019 21:20:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6AEF82C58C; Fri, 25 Oct 2019 21:20:05 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PLK5HD033968; Fri, 25 Oct 2019 21:20:05 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PLK5km033967; Fri, 25 Oct 2019 21:20:05 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252120.x9PLK5km033967@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 21:20:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354099 - in stable: 11/sys/dev/cxgbe 12/sys/dev/cxgbe X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/dev/cxgbe 12/sys/dev/cxgbe X-SVN-Commit-Revision: 354099 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 21:20:05 -0000 Author: jhb Date: Fri Oct 25 21:20:04 2019 New Revision: 354099 URL: https://svnweb.freebsd.org/changeset/base/354099 Log: MFC 353369: Remove adapters from t4_list earlier during detach. This ensures the clip task won't race with t4_destroy_clip_table. While here, make some mutex destroys unconditional since attach always initializes them. Sponsored by: Chelsio Communications Modified: stable/12/sys/dev/cxgbe/t4_main.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/cxgbe/t4_main.c Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/cxgbe/t4_main.c ============================================================================== --- stable/12/sys/dev/cxgbe/t4_main.c Fri Oct 25 21:14:43 2019 (r354098) +++ stable/12/sys/dev/cxgbe/t4_main.c Fri Oct 25 21:20:04 2019 (r354099) @@ -1475,6 +1475,10 @@ t4_detach_common(device_t dev) sc->cdev = NULL; } + sx_xlock(&t4_list_lock); + SLIST_REMOVE(&t4_list, sc, adapter, link); + sx_xunlock(&t4_list_lock); + sc->flags &= ~CHK_MBOX_ACCESS; if (sc->flags & FULL_INIT_DONE) { if (!(sc->flags & IS_VF)) @@ -1568,12 +1572,6 @@ t4_detach_common(device_t dev) free(sc->tids.tid_tab, M_CXGBE); free(sc->tt.tls_rx_ports, M_CXGBE); t4_destroy_dma_tag(sc); - if (mtx_initialized(&sc->sc_lock)) { - sx_xlock(&t4_list_lock); - SLIST_REMOVE(&t4_list, sc, adapter, link); - sx_xunlock(&t4_list_lock); - mtx_destroy(&sc->sc_lock); - } callout_drain(&sc->sfl_callout); if (mtx_initialized(&sc->tids.ftid_lock)) { @@ -1582,12 +1580,8 @@ t4_detach_common(device_t dev) } if (mtx_initialized(&sc->tids.atid_lock)) mtx_destroy(&sc->tids.atid_lock); - if (mtx_initialized(&sc->sfl_lock)) - mtx_destroy(&sc->sfl_lock); if (mtx_initialized(&sc->ifp_lock)) mtx_destroy(&sc->ifp_lock); - if (mtx_initialized(&sc->reg_lock)) - mtx_destroy(&sc->reg_lock); if (rw_initialized(&sc->policy_lock)) { rw_destroy(&sc->policy_lock); @@ -1603,6 +1597,10 @@ t4_detach_common(device_t dev) if (rw_initialized(&mw->mw_lock)) rw_destroy(&mw->mw_lock); } + + mtx_destroy(&sc->sfl_lock); + mtx_destroy(&sc->reg_lock); + mtx_destroy(&sc->sc_lock); bzero(sc, sizeof(*sc)); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 21:23:45 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6EB2C15BB56; Fri, 25 Oct 2019 21:23:45 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470HD12N3cz44xF; Fri, 25 Oct 2019 21:23:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 34BFC2C758; Fri, 25 Oct 2019 21:23:45 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PLNjZj039667; Fri, 25 Oct 2019 21:23:45 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PLNjJX039666; Fri, 25 Oct 2019 21:23:45 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252123.x9PLNjJX039666@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 21:23:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354101 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354101 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 21:23:45 -0000 Author: jhb Date: Fri Oct 25 21:23:44 2019 New Revision: 354101 URL: https://svnweb.freebsd.org/changeset/base/354101 Log: MFC 353371: Don't free the cursor boundary tag during vmem_destroy(). The cursor boundary tag is statically allocated in the vmem instead of from the vmem_bt_zone. Explicitly remove it from the vmem's segment list in vmem_destroy before freeing all the segments from the vmem. Modified: stable/12/sys/kern/subr_vmem.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/subr_vmem.c ============================================================================== --- stable/12/sys/kern/subr_vmem.c Fri Oct 25 21:21:21 2019 (r354100) +++ stable/12/sys/kern/subr_vmem.c Fri Oct 25 21:23:44 2019 (r354101) @@ -466,6 +466,7 @@ static void bt_remseg(vmem_t *vm, bt_t *bt) { + MPASS(bt->bt_type != BT_TYPE_CURSOR); TAILQ_REMOVE(&vm->vm_seglist, bt, bt_seglist); bt_free(vm, bt); } @@ -843,6 +844,7 @@ vmem_destroy1(vmem_t *vm) VMEM_LOCK(vm); MPASS(vm->vm_nbusytag == 0); + TAILQ_REMOVE(&vm->vm_seglist, &vm->vm_cursor, bt_seglist); while ((bt = TAILQ_FIRST(&vm->vm_seglist)) != NULL) bt_remseg(vm, bt); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 21:52:02 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id F134B15CB48; Fri, 25 Oct 2019 21:52:02 +0000 (UTC) (envelope-from lwhsu@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470Hrf6BZ3z46vZ; Fri, 25 Oct 2019 21:52:02 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B95062CCBD; Fri, 25 Oct 2019 21:52:02 +0000 (UTC) (envelope-from lwhsu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PLq26n055719; Fri, 25 Oct 2019 21:52:02 GMT (envelope-from lwhsu@FreeBSD.org) Received: (from lwhsu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PLq2ak055718; Fri, 25 Oct 2019 21:52:02 GMT (envelope-from lwhsu@FreeBSD.org) Message-Id: <201910252152.x9PLq2ak055718@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: lwhsu set sender to lwhsu@FreeBSD.org using -f From: Li-Wen Hsu Date: Fri, 25 Oct 2019 21:52:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354105 - stable/12/tests/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: lwhsu X-SVN-Commit-Paths: stable/12/tests/sys/kern X-SVN-Commit-Revision: 354105 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 21:52:03 -0000 Author: lwhsu Date: Fri Oct 25 21:52:02 2019 New Revision: 354105 URL: https://svnweb.freebsd.org/changeset/base/354105 Log: MFC r350211, r350220, r350235, r350238-r350239, r350295, r350512, r350700, r352219 r350211: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__follow_fork_child_detached_unrelated_debugger PR: 239292 Sponsored by: The FreeBSD Foundation r350220: Fix URL. Sponsored by: The FreeBSD Foundation r350235: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__PT_KILL_competing_stop PR: 220841 Sponsored by: The FreeBSD Foundation r350238: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__follow_fork_both_attached_unrelated_debugger PR: 239397 Sponsored by: The FreeBSD Foundation r350239: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__parent_sees_exit_after_child_debugger PR: 239399 Sponsored by: The FreeBSD Foundation r350295: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__follow_fork_parent_detached_unrelated_debugger PR: 239425 Sponsored by: The FreeBSD Foundation r350512: Only skip test cases sometimes failing in CI when they are running in CI Suggested by: jhb Sponsored by: The FreeBSD Foundation r350700: Get configuration variable with default value for not breaking default setting Reported by: markj Sponsored by: The FreeBSD Foundation r352219: Temporarily skip flakey test case sys.kern.ptrace_test.ptrace__getppid PR: 240510 Sponsored by: The FreeBSD Foundation Modified: stable/12/tests/sys/kern/ptrace_test.c Directory Properties: stable/12/ (props changed) Modified: stable/12/tests/sys/kern/ptrace_test.c ============================================================================== --- stable/12/tests/sys/kern/ptrace_test.c Fri Oct 25 21:39:29 2019 (r354104) +++ stable/12/tests/sys/kern/ptrace_test.c Fri Oct 25 21:52:02 2019 (r354105) @@ -261,6 +261,9 @@ ATF_TC_BODY(ptrace__parent_sees_exit_after_child_debug int cpipe[2], dpipe[2], status; char c; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/239399"); + ATF_REQUIRE(pipe(cpipe) == 0); ATF_REQUIRE((child = fork()) != -1); @@ -802,6 +805,9 @@ ATF_TC_BODY(ptrace__follow_fork_both_attached_unrelate pid_t children[2], fpid, wpid; int cpipe[2], status; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/239397"); + ATF_REQUIRE(pipe(cpipe) == 0); ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { @@ -870,6 +876,9 @@ ATF_TC_BODY(ptrace__follow_fork_child_detached_unrelat pid_t children[2], fpid, wpid; int cpipe[2], status; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/239292"); + ATF_REQUIRE(pipe(cpipe) == 0); ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { @@ -933,6 +942,9 @@ ATF_TC_BODY(ptrace__follow_fork_parent_detached_unrela pid_t children[2], fpid, wpid; int cpipe[2], status; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/239425"); + ATF_REQUIRE(pipe(cpipe) == 0); ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { @@ -995,6 +1007,10 @@ ATF_TC_BODY(ptrace__getppid, tc) int cpipe[2], dpipe[2], status; char c; + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/240510"); + + ATF_REQUIRE(pipe(cpipe) == 0); ATF_REQUIRE((child = fork()) != -1); @@ -2078,6 +2094,9 @@ ATF_TC_BODY(ptrace__PT_KILL_competing_stop, tc) lwpid_t main_lwp; struct ptrace_lwpinfo pl; struct sched_param sched_param; + + if (atf_tc_get_config_var_as_bool_wd(tc, "ci", false)) + atf_tc_skip("https://bugs.freebsd.org/220841"); ATF_REQUIRE((fpid = fork()) != -1); if (fpid == 0) { From owner-svn-src-stable-12@freebsd.org Fri Oct 25 22:04:07 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 08EA215D025; Fri, 25 Oct 2019 22:04:07 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470J6Z5Kl0z47fj; Fri, 25 Oct 2019 22:04:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9ACDC2CF07; Fri, 25 Oct 2019 22:04:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PM46ui063247; Fri, 25 Oct 2019 22:04:06 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PM46cs063244; Fri, 25 Oct 2019 22:04:06 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252204.x9PM46cs063244@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 22:04:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354107 - in stable: 11/sys/dev/acpica 11/sys/dev/pci 12/sys/dev/acpica 12/sys/dev/pci X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/dev/acpica 11/sys/dev/pci 12/sys/dev/acpica 12/sys/dev/pci X-SVN-Commit-Revision: 354107 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 22:04:07 -0000 Author: jhb Date: Fri Oct 25 22:04:05 2019 New Revision: 354107 URL: https://svnweb.freebsd.org/changeset/base/354107 Log: MFC 353585,353586: Support hot insertion and removal of PCI devices on EC2. 353585: Export pci_attach() and pci_detach(). 353586: Support hot insertion and removal of PCI devices on EC2. Install ACPI notify handlers on PCI devices with an _EJ0 method. This handler is invoked when devices are added or removed. - When an ACPI_NOTIFY_DEVICE_CHECK event posts, rescan the parent bus device. Note that strictly speaking we only need to rescan the specified device, but BUS_RESCAN is what is available, so we rescan the entire bus. - When an ACPI_NOTIFY_EJECT_REQUEST event posts, detach the device associated with the ACPI handle, invoke the _EJ0 method, and then delete the device. Eventually this might be changed to vector notify events to devd in userspace where devctl can be used instead to permit more complex actions such as graceful unmounting of filesystems. Modified: stable/12/sys/dev/acpica/acpi_pci.c stable/12/sys/dev/pci/pci.c stable/12/sys/dev/pci/pci_private.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/dev/acpica/acpi_pci.c stable/11/sys/dev/pci/pci.c stable/11/sys/dev/pci/pci_private.h Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/dev/acpica/acpi_pci.c ============================================================================== --- stable/12/sys/dev/acpica/acpi_pci.c Fri Oct 25 21:53:05 2019 (r354106) +++ stable/12/sys/dev/acpica/acpi_pci.c Fri Oct 25 22:04:05 2019 (r354107) @@ -71,9 +71,11 @@ CTASSERT(ACPI_STATE_D2 == PCI_POWERSTATE_D2); CTASSERT(ACPI_STATE_D3 == PCI_POWERSTATE_D3); static struct pci_devinfo *acpi_pci_alloc_devinfo(device_t dev); +static int acpi_pci_attach(device_t dev); static void acpi_pci_child_deleted(device_t dev, device_t child); static int acpi_pci_child_location_str_method(device_t cbdev, device_t child, char *buf, size_t buflen); +static int acpi_pci_detach(device_t dev); static int acpi_pci_probe(device_t dev); static int acpi_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result); @@ -89,6 +91,8 @@ static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus static device_method_t acpi_pci_methods[] = { /* Device interface */ DEVMETHOD(device_probe, acpi_pci_probe), + DEVMETHOD(device_attach, acpi_pci_attach), + DEVMETHOD(device_detach, acpi_pci_detach), /* Bus interface */ DEVMETHOD(bus_read_ivar, acpi_pci_read_ivar), @@ -324,6 +328,108 @@ acpi_pci_probe(device_t dev) return (ENXIO); device_set_desc(dev, "ACPI PCI bus"); return (BUS_PROBE_DEFAULT); +} + +static void +acpi_pci_device_notify_handler(ACPI_HANDLE h, UINT32 notify, void *context) +{ + device_t child, dev; + ACPI_STATUS status; + int error; + + dev = context; + + switch (notify) { + case ACPI_NOTIFY_DEVICE_CHECK: + mtx_lock(&Giant); + BUS_RESCAN(dev); + mtx_unlock(&Giant); + break; + case ACPI_NOTIFY_EJECT_REQUEST: + child = acpi_get_device(h); + if (child == NULL) { + device_printf(dev, "no device to eject for %s\n", + acpi_name(h)); + return; + } + mtx_lock(&Giant); + error = device_detach(child); + if (error) { + mtx_unlock(&Giant); + device_printf(dev, "failed to detach %s: %d\n", + device_get_nameunit(child), error); + return; + } + status = acpi_SetInteger(h, "_EJ0", 1); + if (ACPI_FAILURE(status)) { + mtx_unlock(&Giant); + device_printf(dev, "failed to eject %s: %s\n", + acpi_name(h), AcpiFormatException(status)); + return; + } + BUS_RESCAN(dev); + mtx_unlock(&Giant); + break; + default: + device_printf(dev, "unknown notify %#x for %s\n", notify, + acpi_name(h)); + break; + } +} + +static ACPI_STATUS +acpi_pci_install_device_notify_handler(ACPI_HANDLE handle, UINT32 level, + void *context, void **status) +{ + ACPI_HANDLE h; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + if (ACPI_FAILURE(AcpiGetHandle(handle, "_EJ0", &h))) + return_ACPI_STATUS (AE_OK); + + AcpiInstallNotifyHandler(handle, ACPI_SYSTEM_NOTIFY, + acpi_pci_device_notify_handler, context); + return_ACPI_STATUS (AE_OK); +} + +static int +acpi_pci_attach(device_t dev) +{ + int error; + + error = pci_attach(dev); + if (error) + return (error); + AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, + acpi_pci_install_device_notify_handler, NULL, dev, NULL); + + return (0); +} + +static ACPI_STATUS +acpi_pci_remove_notify_handler(ACPI_HANDLE handle, UINT32 level, void *context, + void **status) +{ + ACPI_HANDLE h; + + ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__); + + if (ACPI_FAILURE(AcpiGetHandle(handle, "_EJ0", &h))) + return_ACPI_STATUS (AE_OK); + + AcpiRemoveNotifyHandler(handle, ACPI_SYSTEM_NOTIFY, + acpi_pci_device_notify_handler); + return_ACPI_STATUS (AE_OK); +} + +static int +acpi_pci_detach(device_t dev) +{ + + AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1, + acpi_pci_remove_notify_handler, NULL, dev, NULL); + return (pci_detach(dev)); } #ifdef ACPI_DMAR Modified: stable/12/sys/dev/pci/pci.c ============================================================================== --- stable/12/sys/dev/pci/pci.c Fri Oct 25 21:53:05 2019 (r354106) +++ stable/12/sys/dev/pci/pci.c Fri Oct 25 22:04:05 2019 (r354107) @@ -98,8 +98,6 @@ static void pci_assign_interrupt(device_t bus, device static int pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, int force, int prefetch); static int pci_probe(device_t dev); -static int pci_attach(device_t dev); -static int pci_detach(device_t dev); static void pci_load_vendor_data(void); static int pci_describe_parse_line(char **ptr, int *vendor, int *device, char **desc); @@ -4380,7 +4378,7 @@ pci_attach_common(device_t dev) return (0); } -static int +int pci_attach(device_t dev) { int busno, domain, error; @@ -4401,7 +4399,7 @@ pci_attach(device_t dev) return (bus_generic_attach(dev)); } -static int +int pci_detach(device_t dev) { #ifdef PCI_RES_BUS Modified: stable/12/sys/dev/pci/pci_private.h ============================================================================== --- stable/12/sys/dev/pci/pci_private.h Fri Oct 25 21:53:05 2019 (r354106) +++ stable/12/sys/dev/pci/pci_private.h Fri Oct 25 22:04:05 2019 (r354107) @@ -58,7 +58,9 @@ void pci_add_resources(device_t bus, device_t dev, in uint32_t prefetchmask); void pci_add_resources_ea(device_t bus, device_t dev, int alloc_iov); struct pci_devinfo *pci_alloc_devinfo_method(device_t dev); +int pci_attach(device_t dev); int pci_attach_common(device_t dev); +int pci_detach(device_t dev); int pci_rescan_method(device_t dev); void pci_driver_added(device_t dev, driver_t *driver); int pci_ea_is_enabled(device_t dev, int rid); From owner-svn-src-stable-12@freebsd.org Fri Oct 25 22:15:21 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7880D15D53C; Fri, 25 Oct 2019 22:15:21 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470JMY2bS5z48LG; Fri, 25 Oct 2019 22:15:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3C3F22D0C7; Fri, 25 Oct 2019 22:15:21 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PMFLNS069317; Fri, 25 Oct 2019 22:15:21 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PMFL2G069316; Fri, 25 Oct 2019 22:15:21 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252215.x9PMFL2G069316@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 22:15:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354108 - in stable: 11/usr.bin/netstat 12/usr.bin/netstat X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/usr.bin/netstat 12/usr.bin/netstat X-SVN-Commit-Revision: 354108 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 22:15:21 -0000 Author: jhb Date: Fri Oct 25 22:15:20 2019 New Revision: 354108 URL: https://svnweb.freebsd.org/changeset/base/354108 Log: MFC 353059: Restore description of packets dropped due to full reassembly queue. r265408 renamed tcps_rcvmemdrop to tcps_rcvreassfull and gave it a more specific description. r279122 (libxo-ification) reverted that change. This commit brings it back, but with a small tweak to the description. Modified: stable/12/usr.bin/netstat/inet.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/usr.bin/netstat/inet.c Directory Properties: stable/11/ (props changed) Modified: stable/12/usr.bin/netstat/inet.c ============================================================================== --- stable/12/usr.bin/netstat/inet.c Fri Oct 25 22:04:05 2019 (r354107) +++ stable/12/usr.bin/netstat/inet.c Fri Oct 25 22:15:20 2019 (r354108) @@ -640,8 +640,8 @@ tcp_stats(u_long off, const char *name, int af1 __unus "{N:/discarded for bad header offset field%s}\n"); p1a(tcps_rcvshort, "\t\t{:discard-too-short/%ju} " "{N:discarded because packet too short}\n"); - p1a(tcps_rcvmemdrop, "\t\t{:discard-memory-problems/%ju} " - "{N:discarded due to memory problems}\n"); + p1a(tcps_rcvreassfull, "\t\t{:discard-reassembly-queue-full/%ju} " + "{N:discarded due to full reassembly queue}\n"); p(tcps_connattempt, "\t{:connection-requests/%ju} " "{N:/connection request%s}\n"); p(tcps_accepts, "\t{:connections-accepts/%ju} " From owner-svn-src-stable-12@freebsd.org Fri Oct 25 22:17:25 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9F21C15D6D7; Fri, 25 Oct 2019 22:17:25 +0000 (UTC) (envelope-from jhb@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470JPx3lfbz48bN; Fri, 25 Oct 2019 22:17:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5FA292D0C9; Fri, 25 Oct 2019 22:17:25 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9PMHPbb069489; Fri, 25 Oct 2019 22:17:25 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9PMHPSE069488; Fri, 25 Oct 2019 22:17:25 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201910252217.x9PMHPSE069488@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Fri, 25 Oct 2019 22:17:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354109 - in stable: 11/sys/conf 12/sys/conf X-SVN-Group: stable-12 X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in stable: 11/sys/conf 12/sys/conf X-SVN-Commit-Revision: 354109 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Oct 2019 22:17:25 -0000 Author: jhb Date: Fri Oct 25 22:17:24 2019 New Revision: 354109 URL: https://svnweb.freebsd.org/changeset/base/354109 Log: MFC 353023: Fix the EMBEDFS_FORMAT helper variable for riscv64. It was defined with the wrong MACHINE_ARCH previously. This permits using an MFS image without defining MD_ROOT_SIZE which has various benefits (one being that the build is able to treat the MFS image as a dependency and properly re-link the kernel with the new image when building with NO_CLEAN). Modified: stable/12/sys/conf/kern.pre.mk Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/sys/conf/kern.pre.mk Directory Properties: stable/11/ (props changed) Modified: stable/12/sys/conf/kern.pre.mk ============================================================================== --- stable/12/sys/conf/kern.pre.mk Fri Oct 25 22:15:20 2019 (r354108) +++ stable/12/sys/conf/kern.pre.mk Fri Oct 25 22:17:24 2019 (r354109) @@ -288,7 +288,7 @@ EMBEDFS_FORMAT.mips?= elf32-tradbigmips EMBEDFS_FORMAT.mipsel?= elf32-tradlittlemips EMBEDFS_FORMAT.mips64?= elf64-tradbigmips EMBEDFS_FORMAT.mips64el?= elf64-tradlittlemips -EMBEDFS_FORMAT.riscv?= elf64-littleriscv +EMBEDFS_FORMAT.riscv64?= elf64-littleriscv .endif .endif From owner-svn-src-stable-12@freebsd.org Sat Oct 26 03:07:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 47B2A179206; Sat, 26 Oct 2019 03:07:29 +0000 (UTC) (envelope-from cy@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470Qrd08r4z4b9t; Sat, 26 Oct 2019 03:07:29 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DD782168E; Sat, 26 Oct 2019 03:07:28 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9Q37SWV042303; Sat, 26 Oct 2019 03:07:28 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9Q37SQf042302; Sat, 26 Oct 2019 03:07:28 GMT (envelope-from cy@FreeBSD.org) Message-Id: <201910260307.x9Q37SQf042302@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sat, 26 Oct 2019 03:07:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354111 - in stable: 11/contrib/ipfilter/tools 12/contrib/ipfilter/tools X-SVN-Group: stable-12 X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in stable: 11/contrib/ipfilter/tools 12/contrib/ipfilter/tools X-SVN-Commit-Revision: 354111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2019 03:07:29 -0000 Author: cy Date: Sat Oct 26 03:07:28 2019 New Revision: 354111 URL: https://svnweb.freebsd.org/changeset/base/354111 Log: MFC r352738: Teach the ippool parser about address families. This is a precursor to implementing IPv6 support within ippool which requires reworking radix_ipf.c. Modified: stable/12/contrib/ipfilter/tools/ippool_y.y Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/ipfilter/tools/ippool_y.y Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/ipfilter/tools/ippool_y.y ============================================================================== --- stable/12/contrib/ipfilter/tools/ippool_y.y Fri Oct 25 22:39:26 2019 (r354110) +++ stable/12/contrib/ipfilter/tools/ippool_y.y Sat Oct 26 03:07:28 2019 (r354111) @@ -309,11 +309,27 @@ range: addrmask { $$ = calloc(1, sizeof(*$$)); $$->ipn_info = 0; $$->ipn_addr = $1[0]; $$->ipn_mask = $1[1]; +#ifdef USE_INET6 + if (use_inet6) + $$->ipn_addr.adf_family = + AF_INET6; + else +#endif + $$->ipn_addr.adf_family = + AF_INET; } | '!' addrmask { $$ = calloc(1, sizeof(*$$)); $$->ipn_info = 1; $$->ipn_addr = $2[0]; $$->ipn_mask = $2[1]; +#ifdef USE_INET6 + if (use_inet6) + $$->ipn_addr.adf_family = + AF_INET6; + else +#endif + $$->ipn_addr.adf_family = + AF_INET; } | YY_STR { $$ = add_poolhosts($1); free($1); From owner-svn-src-stable-12@freebsd.org Sat Oct 26 08:37:29 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 10E1C165664; Sat, 26 Oct 2019 08:37:29 +0000 (UTC) (envelope-from kib@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470Z9N6fVvz3Q7t; Sat, 26 Oct 2019 08:37:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C45555482; Sat, 26 Oct 2019 08:37:28 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9Q8bSQf036252; Sat, 26 Oct 2019 08:37:28 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9Q8bScl036251; Sat, 26 Oct 2019 08:37:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201910260837.x9Q8bScl036251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 26 Oct 2019 08:37:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354113 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354113 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2019 08:37:29 -0000 Author: kib Date: Sat Oct 26 08:37:28 2019 New Revision: 354113 URL: https://svnweb.freebsd.org/changeset/base/354113 Log: MFC r353928: vn_printf(): Decode VI_TEXT_REF. Modified: stable/12/sys/kern/vfs_subr.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/vfs_subr.c ============================================================================== --- stable/12/sys/kern/vfs_subr.c Sat Oct 26 06:59:59 2019 (r354112) +++ stable/12/sys/kern/vfs_subr.c Sat Oct 26 08:37:28 2019 (r354113) @@ -3656,8 +3656,10 @@ vn_printf(struct vnode *vp, const char *fmt, ...) strlcat(buf, "|VI_DOINGINACT", sizeof(buf)); if (vp->v_iflag & VI_OWEINACT) strlcat(buf, "|VI_OWEINACT", sizeof(buf)); + if (vp->v_iflag & VI_TEXT_REF) + strlcat(buf, "|VI_TEXT_REF", sizeof(buf)); flags = vp->v_iflag & ~(VI_MOUNT | VI_DOOMED | VI_FREE | - VI_ACTIVE | VI_DOINGINACT | VI_OWEINACT); + VI_ACTIVE | VI_DOINGINACT | VI_OWEINACT | VI_TEXT_REF); if (flags != 0) { snprintf(buf2, sizeof(buf2), "|VI(0x%lx)", flags); strlcat(buf, buf2, sizeof(buf)); From owner-svn-src-stable-12@freebsd.org Sat Oct 26 10:33:22 2019 Return-Path: Delivered-To: svn-src-stable-12@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3633716A92A; Sat, 26 Oct 2019 10:33:22 +0000 (UTC) (envelope-from tsoome@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 470cl60hDNz41Cr; Sat, 26 Oct 2019 10:33:22 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EEE0A6A24; Sat, 26 Oct 2019 10:33:21 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9QAXLAW006956; Sat, 26 Oct 2019 10:33:21 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9QAXLNC006955; Sat, 26 Oct 2019 10:33:21 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201910261033.x9QAXLNC006955@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sat, 26 Oct 2019 10:33:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354114 - stable/12/stand/libsa/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/libsa/zfs X-SVN-Commit-Revision: 354114 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-12@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 12-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Oct 2019 10:33:22 -0000 Author: tsoome Date: Sat Oct 26 10:33:21 2019 New Revision: 354114 URL: https://svnweb.freebsd.org/changeset/base/354114 Log: MFC r353757: loader: zfs_fmtdev can crash when pool discovery did fail and we have no spa When zfs probe did fail and no spa was created, but zfs_fmtdev() is called, we will crash while dereferencing spa (NULL pointer dereference). Modified: stable/12/stand/libsa/zfs/zfs.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfs.c ============================================================================== --- stable/12/stand/libsa/zfs/zfs.c Sat Oct 26 08:37:28 2019 (r354113) +++ stable/12/stand/libsa/zfs/zfs.c Sat Oct 26 10:33:21 2019 (r354114) @@ -769,11 +769,16 @@ zfs_fmtdev(void *vdev) if (dev->dd.d_dev->dv_type != DEVT_ZFS) return (buf); - if (dev->pool_guid == 0) { - spa = STAILQ_FIRST(&zfs_pools); + /* Do we have any pools? */ + spa = STAILQ_FIRST(&zfs_pools); + if (spa == NULL) + return (buf); + + if (dev->pool_guid == 0) dev->pool_guid = spa->spa_guid; - } else + else spa = spa_find_by_guid(dev->pool_guid); + if (spa == NULL) { printf("ZFS: can't find pool by guid\n"); return (buf);