From owner-svn-src-stable@freebsd.org Sun Nov 10 09:13:13 2019 Return-Path: Delivered-To: svn-src-stable@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 29BC11AF48A; Sun, 10 Nov 2019 09:13:13 +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 479pFj0Fthz3Gvs; Sun, 10 Nov 2019 09:13:13 +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 E0D7624CB7; Sun, 10 Nov 2019 09:13:12 +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 xAA9DCaA056034; Sun, 10 Nov 2019 09:13:12 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAA9DCKE056033; Sun, 10 Nov 2019 09:13:12 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911100913.xAA9DCKE056033@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 10 Nov 2019 09:13: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: r354586 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 354586 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 09:13:13 -0000 Author: kib Date: Sun Nov 10 09:13:12 2019 New Revision: 354586 URL: https://svnweb.freebsd.org/changeset/base/354586 Log: MFC r354280: amd64 ddb: Add printing of kernel/user and saved user %cr3 values from pcpu. Modified: stable/12/sys/amd64/amd64/db_interface.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/db_interface.c ============================================================================== --- stable/12/sys/amd64/amd64/db_interface.c Sun Nov 10 05:22:01 2019 (r354585) +++ stable/12/sys/amd64/amd64/db_interface.c Sun Nov 10 09:13:12 2019 (r354586) @@ -101,6 +101,9 @@ db_show_mdpcpu(struct pcpu *pc) db_printf("tssp = %p\n", pc->pc_tssp); db_printf("commontssp = %p\n", pc->pc_commontssp); db_printf("rsp0 = 0x%lx\n", pc->pc_rsp0); + db_printf("kcr3 = 0x%lx\n", pc->pc_kcr3); + db_printf("ucr3 = 0x%lx\n", pc->pc_ucr3); + db_printf("scr3 = 0x%lx\n", pc->pc_saved_ucr3); db_printf("gs32p = %p\n", pc->pc_gs32p); db_printf("ldt = %p\n", pc->pc_ldt); db_printf("tss = %p\n", pc->pc_tss); From owner-svn-src-stable@freebsd.org Sun Nov 10 09:14:23 2019 Return-Path: Delivered-To: svn-src-stable@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 A25DF1AF52D; Sun, 10 Nov 2019 09:14:23 +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 479pH33mSyz3H3t; Sun, 10 Nov 2019 09:14:23 +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 6556F24CB9; Sun, 10 Nov 2019 09:14:23 +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 xAA9ENQI056144; Sun, 10 Nov 2019 09:14:23 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAA9EN9H056143; Sun, 10 Nov 2019 09:14:23 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911100914.xAA9EN9H056143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 10 Nov 2019 09:14: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: r354587 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 354587 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 09:14:23 -0000 Author: kib Date: Sun Nov 10 09:14:22 2019 New Revision: 354587 URL: https://svnweb.freebsd.org/changeset/base/354587 Log: MFC r354281: amd64: Store %cr3 into pcpu saved_ucr3 on double fault. Modified: stable/12/sys/amd64/amd64/exception.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/exception.S ============================================================================== --- stable/12/sys/amd64/amd64/exception.S Sun Nov 10 09:13:12 2019 (r354586) +++ stable/12/sys/amd64/amd64/exception.S Sun Nov 10 09:14:22 2019 (r354587) @@ -349,6 +349,8 @@ IDTVEC(dblfault) jz 1f /* already running with kernel GS.base */ swapgs 1: lfence + movq %cr3,%rax + movq %rax,PCPU(SAVED_UCR3) movq PCPU(KCR3),%rax cmpq $~0,%rax je 2f From owner-svn-src-stable@freebsd.org Sun Nov 10 09:32:18 2019 Return-Path: Delivered-To: svn-src-stable@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 7BAE91AFD29; Sun, 10 Nov 2019 09:32:18 +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 479pgk2gr4z3JMM; Sun, 10 Nov 2019 09:32:18 +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 3E3242503C; Sun, 10 Nov 2019 09:32:18 +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 xAA9WI1E067083; Sun, 10 Nov 2019 09:32:18 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAA9WHsl067081; Sun, 10 Nov 2019 09:32:17 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911100932.xAA9WHsl067081@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 10 Nov 2019 09:32: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: r354590 - in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: in stable/12: stand/libsa/zfs sys/cddl/boot/zfs X-SVN-Commit-Revision: 354590 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 09:32:18 -0000 Author: tsoome Date: Sun Nov 10 09:32:17 2019 New Revision: 354590 URL: https://svnweb.freebsd.org/changeset/base/354590 Log: MFC r354279: loader: calculate physical vdev psize from asize Since physical device asize is calculated from psize and the asize is stored in pool label, we can use asize to set the value of psize, which is used to calculate the location of the pool labels. Modified: stable/12/stand/libsa/zfs/zfsimpl.c stable/12/sys/cddl/boot/zfs/zfsimpl.h Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/libsa/zfs/zfsimpl.c ============================================================================== --- stable/12/stand/libsa/zfs/zfsimpl.c Sun Nov 10 09:28:18 2019 (r354589) +++ stable/12/stand/libsa/zfs/zfsimpl.c Sun Nov 10 09:32:17 2019 (r354590) @@ -1102,7 +1102,7 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vde vdev_t **vdevp, int is_newer) { int rc; - uint64_t guid, id, ashift, nparity; + uint64_t guid, id, ashift, asize, nparity; const char *type; const char *path; vdev_t *vdev, *kid; @@ -1181,6 +1181,11 @@ vdev_init_from_nvlist(const unsigned char *nvlist, vde } else { vdev->v_ashift = 0; } + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, + DATA_TYPE_UINT64, NULL, &asize) == 0) { + vdev->v_psize = asize + + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + } if (nvlist_find(nvlist, ZPOOL_CONFIG_NPARITY, DATA_TYPE_UINT64, NULL, &nparity) == 0) { vdev->v_nparity = nparity; @@ -1547,7 +1552,6 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s uint64_t guid; uint64_t best_txg = 0; uint64_t pool_txg, pool_guid; - uint64_t psize; const char *pool_name; const unsigned char *vdevs; const unsigned char *features; @@ -1562,17 +1566,17 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s memset(&vtmp, 0, sizeof(vtmp)); vtmp.v_phys_read = _read; vtmp.v_read_priv = read_priv; - psize = P2ALIGN(ldi_get_size(read_priv), + vtmp.v_psize = P2ALIGN(ldi_get_size(read_priv), (uint64_t)sizeof (vdev_label_t)); /* Test for minimum pool size. */ - if (psize < SPA_MINDEVSIZE) + if (vtmp.v_psize < SPA_MINDEVSIZE) return (EIO); tmp_label = zfs_alloc(sizeof(vdev_phys_t)); for (l = 0; l < VDEV_LABELS; l++) { - off = vdev_label_offset(psize, l, + off = vdev_label_offset(vtmp.v_psize, l, offsetof(vdev_label_t, vl_vdev_phys)); BP_ZERO(&bp); @@ -1595,8 +1599,20 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s continue; if (best_txg <= pool_txg) { + uint64_t asize; + best_txg = pool_txg; memcpy(vdev_label, tmp_label, sizeof (vdev_phys_t)); + + /* + * Use asize from pool config. We need this + * because we can get bad value from BIOS. + */ + if (nvlist_find(nvlist, ZPOOL_CONFIG_ASIZE, + DATA_TYPE_UINT64, NULL, &asize) == 0) { + vtmp.v_psize = asize + + VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE; + } } } @@ -1716,6 +1732,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s vdev->v_phys_read = _read; vdev->v_read_priv = read_priv; vdev->v_state = VDEV_STATE_HEALTHY; + vdev->v_psize = vtmp.v_psize; } else { printf("ZFS: inconsistent nvlist contents\n"); return (EIO); @@ -1735,7 +1752,7 @@ vdev_probe(vdev_phys_read_t *_read, void *read_priv, s up = (const struct uberblock *)upbuf; for (l = 0; l < VDEV_LABELS; l++) { for (i = 0; i < VDEV_UBERBLOCK_COUNT(vdev); i++) { - off = vdev_label_offset(psize, l, + off = vdev_label_offset(vdev->v_psize, l, VDEV_UBERBLOCK_OFFSET(vdev, i)); BP_ZERO(&bp); DVA_SET_OFFSET(&bp.blk_dva[0], off); Modified: stable/12/sys/cddl/boot/zfs/zfsimpl.h ============================================================================== --- stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 10 09:28:18 2019 (r354589) +++ stable/12/sys/cddl/boot/zfs/zfsimpl.h Sun Nov 10 09:32:17 2019 (r354590) @@ -1660,7 +1660,8 @@ typedef struct vdev { vdev_list_t v_children; /* children of this vdev */ const char *v_name; /* vdev name */ uint64_t v_guid; /* vdev guid */ - int v_id; /* index in parent */ + uint64_t v_id; /* index in parent */ + uint64_t v_psize; /* physical device capacity */ int v_ashift; /* offset to block shift */ int v_nparity; /* # parity for raidz */ struct vdev *v_top; /* parent vdev */ From owner-svn-src-stable@freebsd.org Sun Nov 10 17:33:11 2019 Return-Path: Delivered-To: svn-src-stable@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 EEF521B9C54; Sun, 10 Nov 2019 17:33:11 +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 47B1Lb65JRz4Bst; Sun, 10 Nov 2019 17:33:11 +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 B473A2626; Sun, 10 Nov 2019 17:33:11 +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 xAAHXBOT050652; Sun, 10 Nov 2019 17:33:11 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAHXBEO050649; Sun, 10 Nov 2019 17:33:11 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911101733.xAAHXBEO050649@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Nov 2019 17:33:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354596 - in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Commit-Revision: 354596 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 17:33:12 -0000 Author: dim Date: Sun Nov 10 17:33:10 2019 New Revision: 354596 URL: https://svnweb.freebsd.org/changeset/base/354596 Log: MFC r354255: Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from :1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 Modified: stable/11/lib/libc/gen/isnan.c stable/11/lib/msun/src/math.h stable/11/lib/msun/src/s_isnan.c Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/lib/libc/gen/isnan.c stable/10/lib/msun/src/math.h stable/10/lib/msun/src/s_isnan.c stable/12/lib/libc/gen/isnan.c stable/12/lib/msun/src/math.h stable/12/lib/msun/src/s_isnan.c Directory Properties: stable/10/ (props changed) stable/12/ (props changed) Modified: stable/11/lib/libc/gen/isnan.c ============================================================================== --- stable/11/lib/libc/gen/isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/11/lib/libc/gen/isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -41,6 +41,13 @@ */ #ifdef PIC +/* + * Because math.h defines __isnan and __isnanf as aliases for compatibility with + * glibc and CUDA, we have to undefine them here to avoid redefinition errors. + */ +#undef __isnan +#undef __isnanf + __weak_reference(__isnan, isnan); __weak_reference(__isnanf, isnanf); Modified: stable/11/lib/msun/src/math.h ============================================================================== --- stable/11/lib/msun/src/math.h Sun Nov 10 17:00:23 2019 (r354595) +++ stable/11/lib/msun/src/math.h Sun Nov 10 17:33:10 2019 (r354596) @@ -215,6 +215,12 @@ __inline_isnanl(__const long double __x) } /* + * Define the following aliases, for compatibility with glibc and CUDA. + */ +#define __isnan __inline_isnan +#define __isnanf __inline_isnanf + +/* * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and * isinf() as functions taking double. C99, and the subsequent POSIX revisions * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating Modified: stable/11/lib/msun/src/s_isnan.c ============================================================================== --- stable/11/lib/msun/src/s_isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/11/lib/msun/src/s_isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -43,6 +43,12 @@ isnan(double d) } #endif /* !PIC */ +/* + * Because math.h defines __isnanf as an alias for compatibility with glibc and + * CUDA, we have to undefine it here to avoid redefinition errors. + */ +#undef __isnanf + int __isnanf(float f) { From owner-svn-src-stable@freebsd.org Sun Nov 10 17:33:11 2019 Return-Path: Delivered-To: svn-src-stable@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 2F4521B9C3B; Sun, 10 Nov 2019 17:33:11 +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 47B1Lb0TF5z4Bsr; Sun, 10 Nov 2019 17:33:11 +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 E794D2625; Sun, 10 Nov 2019 17:33:10 +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 xAAHXAV1050644; Sun, 10 Nov 2019 17:33:10 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAHXAZS050640; Sun, 10 Nov 2019 17:33:10 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911101733.xAAHXAZS050640@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Nov 2019 17:33:10 +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: r354596 - in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Commit-Revision: 354596 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 17:33:11 -0000 Author: dim Date: Sun Nov 10 17:33:10 2019 New Revision: 354596 URL: https://svnweb.freebsd.org/changeset/base/354596 Log: MFC r354255: Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from :1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 Modified: stable/12/lib/libc/gen/isnan.c stable/12/lib/msun/src/math.h stable/12/lib/msun/src/s_isnan.c Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/10/lib/libc/gen/isnan.c stable/10/lib/msun/src/math.h stable/10/lib/msun/src/s_isnan.c stable/11/lib/libc/gen/isnan.c stable/11/lib/msun/src/math.h stable/11/lib/msun/src/s_isnan.c Directory Properties: stable/10/ (props changed) stable/11/ (props changed) Modified: stable/12/lib/libc/gen/isnan.c ============================================================================== --- stable/12/lib/libc/gen/isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/12/lib/libc/gen/isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -43,6 +43,13 @@ */ #ifdef PIC +/* + * Because math.h defines __isnan and __isnanf as aliases for compatibility with + * glibc and CUDA, we have to undefine them here to avoid redefinition errors. + */ +#undef __isnan +#undef __isnanf + __weak_reference(__isnan, isnan); __weak_reference(__isnanf, isnanf); Modified: stable/12/lib/msun/src/math.h ============================================================================== --- stable/12/lib/msun/src/math.h Sun Nov 10 17:00:23 2019 (r354595) +++ stable/12/lib/msun/src/math.h Sun Nov 10 17:33:10 2019 (r354596) @@ -215,6 +215,12 @@ __inline_isnanl(__const long double __x) } /* + * Define the following aliases, for compatibility with glibc and CUDA. + */ +#define __isnan __inline_isnan +#define __isnanf __inline_isnanf + +/* * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and * isinf() as functions taking double. C99, and the subsequent POSIX revisions * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating Modified: stable/12/lib/msun/src/s_isnan.c ============================================================================== --- stable/12/lib/msun/src/s_isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/12/lib/msun/src/s_isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -45,6 +45,12 @@ isnan(double d) } #endif /* !PIC */ +/* + * Because math.h defines __isnanf as an alias for compatibility with glibc and + * CUDA, we have to undefine it here to avoid redefinition errors. + */ +#undef __isnanf + int __isnanf(float f) { From owner-svn-src-stable@freebsd.org Sun Nov 10 17:33:12 2019 Return-Path: Delivered-To: svn-src-stable@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 BBFC11B9C7D; Sun, 10 Nov 2019 17:33:12 +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 47B1Lc4dwhz4Bt9; Sun, 10 Nov 2019 17:33:12 +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 8170B2627; Sun, 10 Nov 2019 17:33:12 +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 xAAHXCMm050660; Sun, 10 Nov 2019 17:33:12 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAHXBE1050657; Sun, 10 Nov 2019 17:33:11 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911101733.xAAHXBE1050657@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Nov 2019 17:33:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r354596 - in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Group: stable-10 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 10/lib/libc/gen 10/lib/msun/src 11/lib/libc/gen 11/lib/msun/src 12/lib/libc/gen 12/lib/msun/src X-SVN-Commit-Revision: 354596 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 17:33:12 -0000 Author: dim Date: Sun Nov 10 17:33:10 2019 New Revision: 354596 URL: https://svnweb.freebsd.org/changeset/base/354596 Log: MFC r354255: Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDA Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from :1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 Modified: stable/10/lib/libc/gen/isnan.c stable/10/lib/msun/src/math.h stable/10/lib/msun/src/s_isnan.c Directory Properties: stable/10/ (props changed) Changes in other areas also in this revision: Modified: stable/11/lib/libc/gen/isnan.c stable/11/lib/msun/src/math.h stable/11/lib/msun/src/s_isnan.c stable/12/lib/libc/gen/isnan.c stable/12/lib/msun/src/math.h stable/12/lib/msun/src/s_isnan.c Directory Properties: stable/11/ (props changed) stable/12/ (props changed) Modified: stable/10/lib/libc/gen/isnan.c ============================================================================== --- stable/10/lib/libc/gen/isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/10/lib/libc/gen/isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -41,6 +41,13 @@ */ #ifdef PIC +/* + * Because math.h defines __isnan and __isnanf as aliases for compatibility with + * glibc and CUDA, we have to undefine them here to avoid redefinition errors. + */ +#undef __isnan +#undef __isnanf + __weak_reference(__isnan, isnan); __weak_reference(__isnanf, isnanf); Modified: stable/10/lib/msun/src/math.h ============================================================================== --- stable/10/lib/msun/src/math.h Sun Nov 10 17:00:23 2019 (r354595) +++ stable/10/lib/msun/src/math.h Sun Nov 10 17:33:10 2019 (r354596) @@ -219,6 +219,12 @@ __inline_isnanl(__const long double __x) } /* + * Define the following aliases, for compatibility with glibc and CUDA. + */ +#define __isnan __inline_isnan +#define __isnanf __inline_isnanf + +/* * Version 2 of the Single UNIX Specification (UNIX98) defined isnan() and * isinf() as functions taking double. C99, and the subsequent POSIX revisions * (SUSv3, POSIX.1-2001, define it as a macro that accepts any real floating Modified: stable/10/lib/msun/src/s_isnan.c ============================================================================== --- stable/10/lib/msun/src/s_isnan.c Sun Nov 10 17:00:23 2019 (r354595) +++ stable/10/lib/msun/src/s_isnan.c Sun Nov 10 17:33:10 2019 (r354596) @@ -43,6 +43,12 @@ isnan(double d) } #endif /* !PIC */ +/* + * Because math.h defines __isnanf as an alias for compatibility with glibc and + * CUDA, we have to undefine it here to avoid redefinition errors. + */ +#undef __isnanf + int __isnanf(float f) { From owner-svn-src-stable@freebsd.org Sun Nov 10 18:41:15 2019 Return-Path: Delivered-To: svn-src-stable@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 693321BB771; Sun, 10 Nov 2019 18:41:15 +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 47B2s726M8z4G6x; Sun, 10 Nov 2019 18:41:15 +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 2C9343225; Sun, 10 Nov 2019 18:41:15 +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 xAAIfFVY088999; Sun, 10 Nov 2019 18:41:15 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAIfEXV088995; Sun, 10 Nov 2019 18:41:14 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911101841.xAAIfEXV088995@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Nov 2019 18:41:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys X-SVN-Commit-Revision: 354598 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 18:41:15 -0000 Author: dim Date: Sun Nov 10 18:41:13 2019 New Revision: 354598 URL: https://svnweb.freebsd.org/changeset/base/354598 Log: MFC r354460: Merge commit e8316372b from llvm git (by Louis Dionne): [libc++] Add `__truncating_cast` for safely casting float types to integers This is needed anytime we need to clamp an arbitrary floating point value to an integer type. Thanks to Eric Fiselier for the patch. Differential Revision: https://reviews.llvm.org/D66836 llvm-svn: 370891 Merge commit b92deded8 from llvm git (by Louis Dionne): [libc++] Move __clamp_to_integral to , and harden against min()/max() macros llvm-svn: 370900 Merge commit 0ec6a4882 from llvm git (by Louis Dionne): [libc++] Fix potential OOB in poisson_distribution See details in the original Chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=994957 Together, these fix a security issue in libc++'s implementation of std::poisson_distribution, which can be exploited to read data which is out of bounds. Note there are no programs in the FreeBSD base system that use std::poisson_distribution, so this is only a possible issue for ports and external programs which have been built against libc++. Therefore, I am bumping __FreeBSD_version for the benefit of our port maintainers. Requested by: emaste Security: potential OOB read Modified: stable/11/contrib/libc++/include/cmath stable/11/contrib/libc++/include/random stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/contrib/libc++/include/cmath stable/12/contrib/libc++/include/random stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/libc++/include/cmath ============================================================================== --- stable/11/contrib/libc++/include/cmath Sun Nov 10 18:07:02 2019 (r354597) +++ stable/11/contrib/libc++/include/cmath Sun Nov 10 18:41:13 2019 (r354598) @@ -304,11 +304,15 @@ long double truncl(long double x); #include <__config> #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD using ::signbit; @@ -607,6 +611,38 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT return isfinite(__lcpp_x); } +template ::digits > numeric_limits<_IntT>::digits), + int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT { + static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); + static_assert(is_integral<_IntT>::value, "must be an integral type"); + static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); + static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value + || is_same<_FloatT,long double>::value, "unsupported floating point type"); + return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); +} + +// Convert a floating point number to the specified integral type after +// clamping to the integral types representable range. +// +// The behavior is undefined if `__r` is NaN. +template +_LIBCPP_INLINE_VISIBILITY +_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { + using _Lim = std::numeric_limits<_IntT>; + const _IntT _MaxVal = std::__max_representable_int_for_float<_IntT, _RealT>(); + if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) { + return _Lim::max(); + } else if (__r <= _Lim::lowest()) { + return _Lim::min(); + } + return static_cast<_IntT>(__r); +} + _LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS #endif // _LIBCPP_CMATH Modified: stable/11/contrib/libc++/include/random ============================================================================== --- stable/11/contrib/libc++/include/random Sun Nov 10 18:07:02 2019 (r354597) +++ stable/11/contrib/libc++/include/random Sun Nov 10 18:41:13 2019 (r354598) @@ -4593,7 +4593,10 @@ class _LIBCPP_TEMPLATE_VIS poisson_distribution (publi template poisson_distribution<_IntType>::param_type::param_type(double __mean) - : __mean_(__mean) + // According to the standard `inf` is a valid input, but it causes the + // distribution to hang, so we replace it with the maximum representable + // mean. + : __mean_(isinf(__mean) ? numeric_limits::max() : __mean) { if (__mean_ < 10) { @@ -4611,7 +4614,7 @@ poisson_distribution<_IntType>::param_type::param_type { __s_ = _VSTD::sqrt(__mean_); __d_ = 6 * __mean_ * __mean_; - __l_ = static_cast(__mean_ - 1.1484); + __l_ = std::trunc(__mean_ - 1.1484); __omega_ = .3989423 / __s_; double __b1_ = .4166667E-1 / __mean_; double __b2_ = .3 * __b1_ * __b1_; @@ -4628,12 +4631,12 @@ template _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) { - result_type __x; + double __tx; uniform_real_distribution __urd; if (__pr.__mean_ < 10) { - __x = 0; - for (double __p = __urd(__urng); __p > __pr.__l_; ++__x) + __tx = 0; + for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx) __p *= __urd(__urng); } else @@ -4643,19 +4646,19 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur double __u; if (__g > 0) { - __x = static_cast(__g); - if (__x >= __pr.__l_) - return __x; - __difmuk = __pr.__mean_ - __x; + __tx = std::trunc(__g); + if (__tx >= __pr.__l_) + return std::__clamp_to_integral(__tx); + __difmuk = __pr.__mean_ - __tx; __u = __urd(__urng); if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk) - return __x; + return std::__clamp_to_integral(__tx); } exponential_distribution __edist; for (bool __using_exp_dist = false; true; __using_exp_dist = true) { double __e; - if (__using_exp_dist || __g < 0) + if (__using_exp_dist || __g <= 0) { double __t; do @@ -4665,31 +4668,31 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur __u += __u - 1; __t = 1.8 + (__u < 0 ? -__e : __e); } while (__t <= -.6744); - __x = __pr.__mean_ + __pr.__s_ * __t; - __difmuk = __pr.__mean_ - __x; + __tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t); + __difmuk = __pr.__mean_ - __tx; __using_exp_dist = true; } double __px; double __py; - if (__x < 10) + if (__tx < 10 && __tx >= 0) { const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; __px = -__pr.__mean_; - __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x]; + __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast(__tx)]; } else { - double __del = .8333333E-1 / __x; + double __del = .8333333E-1 / __tx; __del -= 4.8 * __del * __del * __del; - double __v = __difmuk / __x; + double __v = __difmuk / __tx; if (_VSTD::abs(__v) > 0.25) - __px = __x * _VSTD::log(1 + __v) - __difmuk - __del; + __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del; else - __px = __x * __v * __v * (((((((.1250060 * __v + -.1384794) * + __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) * __v + .1421878) * __v + -.1661269) * __v + .2000118) * __v + -.2500068) * __v + .3333333) * __v + -.5) - __del; - __py = .3989423 / _VSTD::sqrt(__x); + __py = .3989423 / _VSTD::sqrt(__tx); } double __r = (0.5 - __difmuk) / __pr.__s_; double __r2 = __r * __r; @@ -4709,7 +4712,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur } } } - return __x; + return std::__clamp_to_integral(__tx); } template Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Sun Nov 10 18:07:02 2019 (r354597) +++ stable/11/sys/sys/param.h Sun Nov 10 18:41:13 2019 (r354598) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1103500 /* Master, propagated to newvers */ +#define __FreeBSD_version 1103501 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Sun Nov 10 18:41:14 2019 Return-Path: Delivered-To: svn-src-stable@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 AC2731BB76B; Sun, 10 Nov 2019 18:41:14 +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 47B2s63xmQz4G6v; Sun, 10 Nov 2019 18:41:14 +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 6B4193223; Sun, 10 Nov 2019 18:41:14 +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 xAAIfEvw088990; Sun, 10 Nov 2019 18:41:14 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAIfDgG088987; Sun, 10 Nov 2019 18:41:13 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911101841.xAAIfDgG088987@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 10 Nov 2019 18:41: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: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys X-SVN-Commit-Revision: 354598 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 18:41:14 -0000 Author: dim Date: Sun Nov 10 18:41:13 2019 New Revision: 354598 URL: https://svnweb.freebsd.org/changeset/base/354598 Log: MFC r354460: Merge commit e8316372b from llvm git (by Louis Dionne): [libc++] Add `__truncating_cast` for safely casting float types to integers This is needed anytime we need to clamp an arbitrary floating point value to an integer type. Thanks to Eric Fiselier for the patch. Differential Revision: https://reviews.llvm.org/D66836 llvm-svn: 370891 Merge commit b92deded8 from llvm git (by Louis Dionne): [libc++] Move __clamp_to_integral to , and harden against min()/max() macros llvm-svn: 370900 Merge commit 0ec6a4882 from llvm git (by Louis Dionne): [libc++] Fix potential OOB in poisson_distribution See details in the original Chromium bug report: https://bugs.chromium.org/p/chromium/issues/detail?id=994957 Together, these fix a security issue in libc++'s implementation of std::poisson_distribution, which can be exploited to read data which is out of bounds. Note there are no programs in the FreeBSD base system that use std::poisson_distribution, so this is only a possible issue for ports and external programs which have been built against libc++. Therefore, I am bumping __FreeBSD_version for the benefit of our port maintainers. Requested by: emaste Security: potential OOB read Modified: stable/12/contrib/libc++/include/cmath stable/12/contrib/libc++/include/random stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/libc++/include/cmath stable/11/contrib/libc++/include/random stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/libc++/include/cmath ============================================================================== --- stable/12/contrib/libc++/include/cmath Sun Nov 10 18:07:02 2019 (r354597) +++ stable/12/contrib/libc++/include/cmath Sun Nov 10 18:41:13 2019 (r354598) @@ -304,11 +304,15 @@ long double truncl(long double x); #include <__config> #include #include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + _LIBCPP_BEGIN_NAMESPACE_STD using ::signbit; @@ -607,6 +611,38 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT return isfinite(__lcpp_x); } +template ::digits > numeric_limits<_IntT>::digits), + int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)> +_LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR _IntT __max_representable_int_for_float() _NOEXCEPT { + static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); + static_assert(is_integral<_IntT>::value, "must be an integral type"); + static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); + static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value + || is_same<_FloatT,long double>::value, "unsupported floating point type"); + return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); +} + +// Convert a floating point number to the specified integral type after +// clamping to the integral types representable range. +// +// The behavior is undefined if `__r` is NaN. +template +_LIBCPP_INLINE_VISIBILITY +_IntT __clamp_to_integral(_RealT __r) _NOEXCEPT { + using _Lim = std::numeric_limits<_IntT>; + const _IntT _MaxVal = std::__max_representable_int_for_float<_IntT, _RealT>(); + if (__r >= ::nextafter(static_cast<_RealT>(_MaxVal), INFINITY)) { + return _Lim::max(); + } else if (__r <= _Lim::lowest()) { + return _Lim::min(); + } + return static_cast<_IntT>(__r); +} + _LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS #endif // _LIBCPP_CMATH Modified: stable/12/contrib/libc++/include/random ============================================================================== --- stable/12/contrib/libc++/include/random Sun Nov 10 18:07:02 2019 (r354597) +++ stable/12/contrib/libc++/include/random Sun Nov 10 18:41:13 2019 (r354598) @@ -4593,7 +4593,10 @@ class _LIBCPP_TEMPLATE_VIS poisson_distribution (publi template poisson_distribution<_IntType>::param_type::param_type(double __mean) - : __mean_(__mean) + // According to the standard `inf` is a valid input, but it causes the + // distribution to hang, so we replace it with the maximum representable + // mean. + : __mean_(isinf(__mean) ? numeric_limits::max() : __mean) { if (__mean_ < 10) { @@ -4611,7 +4614,7 @@ poisson_distribution<_IntType>::param_type::param_type { __s_ = _VSTD::sqrt(__mean_); __d_ = 6 * __mean_ * __mean_; - __l_ = static_cast(__mean_ - 1.1484); + __l_ = std::trunc(__mean_ - 1.1484); __omega_ = .3989423 / __s_; double __b1_ = .4166667E-1 / __mean_; double __b2_ = .3 * __b1_ * __b1_; @@ -4628,12 +4631,12 @@ template _IntType poisson_distribution<_IntType>::operator()(_URNG& __urng, const param_type& __pr) { - result_type __x; + double __tx; uniform_real_distribution __urd; if (__pr.__mean_ < 10) { - __x = 0; - for (double __p = __urd(__urng); __p > __pr.__l_; ++__x) + __tx = 0; + for (double __p = __urd(__urng); __p > __pr.__l_; ++__tx) __p *= __urd(__urng); } else @@ -4643,19 +4646,19 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur double __u; if (__g > 0) { - __x = static_cast(__g); - if (__x >= __pr.__l_) - return __x; - __difmuk = __pr.__mean_ - __x; + __tx = std::trunc(__g); + if (__tx >= __pr.__l_) + return std::__clamp_to_integral(__tx); + __difmuk = __pr.__mean_ - __tx; __u = __urd(__urng); if (__pr.__d_ * __u >= __difmuk * __difmuk * __difmuk) - return __x; + return std::__clamp_to_integral(__tx); } exponential_distribution __edist; for (bool __using_exp_dist = false; true; __using_exp_dist = true) { double __e; - if (__using_exp_dist || __g < 0) + if (__using_exp_dist || __g <= 0) { double __t; do @@ -4665,31 +4668,31 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur __u += __u - 1; __t = 1.8 + (__u < 0 ? -__e : __e); } while (__t <= -.6744); - __x = __pr.__mean_ + __pr.__s_ * __t; - __difmuk = __pr.__mean_ - __x; + __tx = std::trunc(__pr.__mean_ + __pr.__s_ * __t); + __difmuk = __pr.__mean_ - __tx; __using_exp_dist = true; } double __px; double __py; - if (__x < 10) + if (__tx < 10 && __tx >= 0) { const double __fac[] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; __px = -__pr.__mean_; - __py = _VSTD::pow(__pr.__mean_, (double)__x) / __fac[__x]; + __py = _VSTD::pow(__pr.__mean_, (double)__tx) / __fac[static_cast(__tx)]; } else { - double __del = .8333333E-1 / __x; + double __del = .8333333E-1 / __tx; __del -= 4.8 * __del * __del * __del; - double __v = __difmuk / __x; + double __v = __difmuk / __tx; if (_VSTD::abs(__v) > 0.25) - __px = __x * _VSTD::log(1 + __v) - __difmuk - __del; + __px = __tx * _VSTD::log(1 + __v) - __difmuk - __del; else - __px = __x * __v * __v * (((((((.1250060 * __v + -.1384794) * + __px = __tx * __v * __v * (((((((.1250060 * __v + -.1384794) * __v + .1421878) * __v + -.1661269) * __v + .2000118) * __v + -.2500068) * __v + .3333333) * __v + -.5) - __del; - __py = .3989423 / _VSTD::sqrt(__x); + __py = .3989423 / _VSTD::sqrt(__tx); } double __r = (0.5 - __difmuk) / __pr.__s_; double __r2 = __r * __r; @@ -4709,7 +4712,7 @@ poisson_distribution<_IntType>::operator()(_URNG& __ur } } } - return __x; + return std::__clamp_to_integral(__tx); } template Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Sun Nov 10 18:07:02 2019 (r354597) +++ stable/12/sys/sys/param.h Sun Nov 10 18:41:13 2019 (r354598) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201500 /* Master, propagated to newvers */ +#define __FreeBSD_version 1201501 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Sun Nov 10 18:43:10 2019 Return-Path: Delivered-To: svn-src-stable@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 5FBA41BB88B; Sun, 10 Nov 2019 18:43:10 +0000 (UTC) (envelope-from vmaffione@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 47B2vL1r6Sz4GXr; Sun, 10 Nov 2019 18:43:10 +0000 (UTC) (envelope-from vmaffione@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 224A532A6; Sun, 10 Nov 2019 18:43:10 +0000 (UTC) (envelope-from vmaffione@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAAIhA5Z092336; Sun, 10 Nov 2019 18:43:10 GMT (envelope-from vmaffione@FreeBSD.org) Received: (from vmaffione@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAAIhAr2092335; Sun, 10 Nov 2019 18:43:10 GMT (envelope-from vmaffione@FreeBSD.org) Message-Id: <201911101843.xAAIhAr2092335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: vmaffione set sender to vmaffione@FreeBSD.org using -f From: Vincenzo Maffione Date: Sun, 10 Nov 2019 18:43:10 +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: r354599 - stable/12/usr.sbin/bhyve X-SVN-Group: stable-12 X-SVN-Commit-Author: vmaffione X-SVN-Commit-Paths: stable/12/usr.sbin/bhyve X-SVN-Commit-Revision: 354599 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Nov 2019 18:43:10 -0000 Author: vmaffione Date: Sun Nov 10 18:43:09 2019 New Revision: 354599 URL: https://svnweb.freebsd.org/changeset/base/354599 Log: MFC r354287 bhyve: fix mistake introduced by r352841 MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D20973 Modified: stable/12/usr.sbin/bhyve/net_backends.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/bhyve/net_backends.c ============================================================================== --- stable/12/usr.sbin/bhyve/net_backends.c Sun Nov 10 18:41:13 2019 (r354598) +++ stable/12/usr.sbin/bhyve/net_backends.c Sun Nov 10 18:43:09 2019 (r354599) @@ -860,12 +860,12 @@ void netbe_rx_disable(struct net_backend *be) { - return be->recv_enable(be); + return be->recv_disable(be); } void netbe_rx_enable(struct net_backend *be) { - return be->recv_disable(be); + return be->recv_enable(be); } From owner-svn-src-stable@freebsd.org Mon Nov 11 08:03:50 2019 Return-Path: Delivered-To: svn-src-stable@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 B34591AEA3A; Mon, 11 Nov 2019 08:03:50 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) (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 47BNg73x4Nz3PBQ; Mon, 11 Nov 2019 08:03:47 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: by mail-qv1-f67.google.com with SMTP id c9so4499694qvz.9; Mon, 11 Nov 2019 00:03:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=02SEFZZ6/rJoM1txdfQFf+2fmMYuAGF/4DYlI3R3+fI=; b=gzRBZmCEPyUTvl7/4ZpYTE6Vm/wGHr51IObF+obMwDlbUSogPunGH1EBHbSyARzhgp SilDOok1bxj1qmct2hmzjlXWCselLim6uARGVAJH+VULZGw1dM2urzIsGailgBpCPLM9 t7K4IDPGpXwxslSgYrlrjIc5QRdRidY2Hl4FA20VD14y00mjp26RmWg9G1A5MtH3mswj K1uMOElLkEVPmau8uODyzaEI9sIkKJnVX1RZoAiTco+AUKV8xNpZKi+wpSMrqD0CsXez 3NwtWwf5N7hAqAA1uguiR3nI1MFzedwSsC6f1RIo4I3Y8Zj0NtGKhXeRWHeWTx08H5er KzVQ== X-Gm-Message-State: APjAAAXcdzsHNAHJgGuJoCkzdCN/FF3f9RKbCq+tZo/cyXgXu+6NPk/3 ugkS+sHqvie/bb9thRKGXMlLAo1C+V8qFvTVCEPi6dkc X-Google-Smtp-Source: APXvYqwM5j6uiuoOTwqlNZUYxunUiYE8EKd9Q1nT+NZj6kAJwzNRrXPurowCvre9KbeGSWQ8f5DvQTwfJVzhpMj4g6k= X-Received: by 2002:a0c:facf:: with SMTP id p15mr1265583qvo.212.1573459420618; Mon, 11 Nov 2019 00:03:40 -0800 (PST) MIME-Version: 1.0 References: <201911101841.xAAIfEXV088995@repo.freebsd.org> In-Reply-To: <201911101841.xAAIfEXV088995@repo.freebsd.org> From: Antoine Brodin Date: Mon, 11 Nov 2019 09:03:28 +0100 Message-ID: Subject: Re: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys To: Dimitry Andric Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 47BNg73x4Nz3PBQ X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 08:03:50 -0000 On Sun, Nov 10, 2019 at 7:41 PM Dimitry Andric wrote: > > Author: dim > Date: Sun Nov 10 18:41:13 2019 > New Revision: 354598 > URL: https://svnweb.freebsd.org/changeset/base/354598 > > Log: > MFC r354460: > > Merge commit e8316372b from llvm git (by Louis Dionne): > > [libc++] Add `__truncating_cast` for safely casting float types to > integers > > This is needed anytime we need to clamp an arbitrary floating point > value to an integer type. > > Thanks to Eric Fiselier for the patch. > > Differential Revision: https://reviews.llvm.org/D66836 > > llvm-svn: 370891 > > Merge commit b92deded8 from llvm git (by Louis Dionne): > > [libc++] Move __clamp_to_integral to , and harden against > min()/max() macros > > llvm-svn: 370900 > > Merge commit 0ec6a4882 from llvm git (by Louis Dionne): > > [libc++] Fix potential OOB in poisson_distribution > > See details in the original Chromium bug report: > https://bugs.chromium.org/p/chromium/issues/detail?id=994957 > > Together, these fix a security issue in libc++'s implementation of > std::poisson_distribution, which can be exploited to read data which is > out of bounds. > > Note there are no programs in the FreeBSD base system that use > std::poisson_distribution, so this is only a possible issue for ports > and external programs which have been built against libc++. Therefore, > I am bumping __FreeBSD_version for the benefit of our port maintainers. > > Requested by: emaste > Security: potential OOB read > > Modified: > stable/11/contrib/libc++/include/cmath > stable/11/contrib/libc++/include/random > stable/11/sys/sys/param.h > Directory Properties: > stable/11/ (props changed) > > Changes in other areas also in this revision: > Modified: > stable/12/contrib/libc++/include/cmath > stable/12/contrib/libc++/include/random > stable/12/sys/sys/param.h > Directory Properties: > stable/12/ (props changed) Hi, It seems that some recent changes to stable/11 are broken, lots of ports now fail to build on stable/11. Antoine (with hat: portmgr) From owner-svn-src-stable@freebsd.org Mon Nov 11 09:29:29 2019 Return-Path: Delivered-To: svn-src-stable@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 D6CF11B072F; Mon, 11 Nov 2019 09:29:29 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-qt1-f194.google.com (mail-qt1-f194.google.com [209.85.160.194]) (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 47BQZ06MYrz3xyK; Mon, 11 Nov 2019 09:29:28 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: by mail-qt1-f194.google.com with SMTP id r20so888133qtp.13; Mon, 11 Nov 2019 01:29:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6Umj3DYIUrQePS0aA10Xg7RaNEUwtLfhL4xLeOWVpkM=; b=uf/xSViDWPpesM2vE33VO+chymzgH9YBZKheP2GJV8NHuihuSIX0MZMNOWeWeso4vC aQFYsH9s41wf2NKaDs7Ujy/JwOTtFTLODCN+zyBemjR8iiGbNeIyOojAD+dGEaDwl1Lq JRJHKizerX4QT9kFMV1pjvhH/6zGnBnkvToUuGbd+SMqEBjAR/aiLw+4B8MPCCNS1AjK OPdNChKWBIqeUuFXFghFwcBOVQPrG39nSea9Zlc0ChUjWN9qy8jls3M3ZmHUph6awpHJ e+LEqwjl58JYkyLayamTAHLcZTcRbyOgYRhClxxmfBUHUxIJzskJGqZtuY4xbO/NaMiY gM6w== X-Gm-Message-State: APjAAAWr/I+pYoLMfS0xcBtgHT1dfoiR3zRyFgPWk61mQCUpR+xTyRT6 ocYYtyi/JCqAB2l4FCglzqc0dx4uh2sYywu6v32zOg== X-Google-Smtp-Source: APXvYqwJPDDr+gYd7yXVniZarYwSkmRIOEZ/uLZzhj0BZragQ5tL24JlFLGZ6E9B+MFPsNEixjOGdWm6YtSqgVIcmVA= X-Received: by 2002:ac8:6944:: with SMTP id n4mr25405815qtr.360.1573464567103; Mon, 11 Nov 2019 01:29:27 -0800 (PST) MIME-Version: 1.0 References: <201911101841.xAAIfEXV088995@repo.freebsd.org> In-Reply-To: From: Antoine Brodin Date: Mon, 11 Nov 2019 10:29:15 +0100 Message-ID: Subject: Re: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys To: Dimitry Andric Cc: src-committers , svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 47BQZ06MYrz3xyK X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of antoinebrodinfreebsd@gmail.com designates 209.85.160.194 as permitted sender) smtp.mailfrom=antoinebrodinfreebsd@gmail.com X-Spamd-Result: default: False [-4.04 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17:c]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; DMARC_NA(0.00)[freebsd.org]; RWL_MAILSPIKE_GOOD(0.00)[194.160.85.209.rep.mailspike.net : 127.0.0.18]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-2.04)[ip: (-4.96), ipnet: 209.85.128.0/17(-3.19), asn: 15169(-2.00), country: US(-0.05)]; RCVD_IN_DNSWL_NONE(0.00)[194.160.85.209.list.dnswl.org : 127.0.5.0]; FORGED_SENDER(0.30)[antoine@freebsd.org,antoinebrodinfreebsd@gmail.com]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; TAGGED_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[antoine@freebsd.org,antoinebrodinfreebsd@gmail.com]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 09:29:29 -0000 On Mon, Nov 11, 2019 at 9:03 AM Antoine Brodin wrote: > > On Sun, Nov 10, 2019 at 7:41 PM Dimitry Andric wrote: > > > > Author: dim > > Date: Sun Nov 10 18:41:13 2019 > > New Revision: 354598 > > URL: https://svnweb.freebsd.org/changeset/base/354598 > > > > Log: > > MFC r354460: > > > > Merge commit e8316372b from llvm git (by Louis Dionne): > > > > [libc++] Add `__truncating_cast` for safely casting float types to > > integers > > > > This is needed anytime we need to clamp an arbitrary floating point > > value to an integer type. > > > > Thanks to Eric Fiselier for the patch. > > > > Differential Revision: https://reviews.llvm.org/D66836 > > > > llvm-svn: 370891 > > > > Merge commit b92deded8 from llvm git (by Louis Dionne): > > > > [libc++] Move __clamp_to_integral to , and harden against > > min()/max() macros > > > > llvm-svn: 370900 > > > > Merge commit 0ec6a4882 from llvm git (by Louis Dionne): > > > > [libc++] Fix potential OOB in poisson_distribution > > > > See details in the original Chromium bug report: > > https://bugs.chromium.org/p/chromium/issues/detail?id=994957 > > > > Together, these fix a security issue in libc++'s implementation of > > std::poisson_distribution, which can be exploited to read data which is > > out of bounds. > > > > Note there are no programs in the FreeBSD base system that use > > std::poisson_distribution, so this is only a possible issue for ports > > and external programs which have been built against libc++. Therefore, > > I am bumping __FreeBSD_version for the benefit of our port maintainers. > > > > Requested by: emaste > > Security: potential OOB read > > > > Modified: > > stable/11/contrib/libc++/include/cmath > > stable/11/contrib/libc++/include/random > > stable/11/sys/sys/param.h > > Directory Properties: > > stable/11/ (props changed) > > > > Changes in other areas also in this revision: > > Modified: > > stable/12/contrib/libc++/include/cmath > > stable/12/contrib/libc++/include/random > > stable/12/sys/sys/param.h > > Directory Properties: > > stable/12/ (props changed) > > Hi, > > It seems that some recent changes to stable/11 are broken, lots of > ports now fail to build on stable/11. This affects stable/12 too. It seems that the cmath header can't be compiled. Antoine From owner-svn-src-stable@freebsd.org Mon Nov 11 10:10:04 2019 Return-Path: Delivered-To: svn-src-stable@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 16E421B144F; Mon, 11 Nov 2019 10:10:04 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 47BRSq6wyhz40lM; Mon, 11 Nov 2019 10:10:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id BA3751D064; Mon, 11 Nov 2019 10:10:03 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [192.168.1.58] (92-111-45-100.static.v4.ziggozakelijk.nl [92.111.45.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 280B92C1E3; Mon, 11 Nov 2019 11:10:02 +0100 (CET) From: Dimitry Andric Message-Id: <4FEA5BCC-A9E7-4FDB-8392-04027239D9B0@FreeBSD.org> Content-Type: multipart/signed; boundary="Apple-Mail=_B7FA7644-3FA1-4324-BA00-4497784FC089"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys Date: Mon, 11 Nov 2019 11:09:57 +0100 In-Reply-To: Cc: src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org To: Antoine Brodin References: <201911101841.xAAIfEXV088995@repo.freebsd.org> X-Mailer: Apple Mail (2.3445.104.11) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 10:10:04 -0000 --Apple-Mail=_B7FA7644-3FA1-4324-BA00-4497784FC089 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 11 Nov 2019, at 10:29, Antoine Brodin wrote: > > On Mon, Nov 11, 2019 at 9:03 AM Antoine Brodin wrote: >> >> On Sun, Nov 10, 2019 at 7:41 PM Dimitry Andric wrote: >>> >>> Author: dim >>> Date: Sun Nov 10 18:41:13 2019 >>> New Revision: 354598 >>> URL: https://svnweb.freebsd.org/changeset/base/354598 >>> >>> Log: >>> MFC r354460: >>> >>> Merge commit e8316372b from llvm git (by Louis Dionne): >>> >>> [libc++] Add `__truncating_cast` for safely casting float types to >>> integers >>> >>> This is needed anytime we need to clamp an arbitrary floating point >>> value to an integer type. >>> >>> Thanks to Eric Fiselier for the patch. >>> >>> Differential Revision: https://reviews.llvm.org/D66836 >>> >>> llvm-svn: 370891 >>> >>> Merge commit b92deded8 from llvm git (by Louis Dionne): >>> >>> [libc++] Move __clamp_to_integral to , and harden against >>> min()/max() macros >>> >>> llvm-svn: 370900 >>> >>> Merge commit 0ec6a4882 from llvm git (by Louis Dionne): >>> >>> [libc++] Fix potential OOB in poisson_distribution >>> >>> See details in the original Chromium bug report: >>> https://bugs.chromium.org/p/chromium/issues/detail?id=994957 >>> >>> Together, these fix a security issue in libc++'s implementation of >>> std::poisson_distribution, which can be exploited to read data which is >>> out of bounds. >>> >>> Note there are no programs in the FreeBSD base system that use >>> std::poisson_distribution, so this is only a possible issue for ports >>> and external programs which have been built against libc++. Therefore, >>> I am bumping __FreeBSD_version for the benefit of our port maintainers. >>> >>> Requested by: emaste >>> Security: potential OOB read >>> >>> Modified: >>> stable/11/contrib/libc++/include/cmath >>> stable/11/contrib/libc++/include/random >>> stable/11/sys/sys/param.h >>> Directory Properties: >>> stable/11/ (props changed) >>> >>> Changes in other areas also in this revision: >>> Modified: >>> stable/12/contrib/libc++/include/cmath >>> stable/12/contrib/libc++/include/random >>> stable/12/sys/sys/param.h >>> Directory Properties: >>> stable/12/ (props changed) >> >> Hi, >> >> It seems that some recent changes to stable/11 are broken, lots of >> ports now fail to build on stable/11. > > This affects stable/12 too. > It seems that the cmath header can't be compiled. Interesting, it works fine here on e.g. stable/12: $ cat test-cmath.cpp #include $ c++ -c test-cmath.cpp Are there any build logs available showing errors? -Dimitry --Apple-Mail=_B7FA7644-3FA1-4324-BA00-4497784FC089 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXckzdQAKCRCwXqMKLiCW o4y3AJ9GvaN7RcZPoaiwVm7G4oQaH+ly3ACeLF7IErSgpIbwNqNn6argKKIdGpE= =MZkc -----END PGP SIGNATURE----- --Apple-Mail=_B7FA7644-3FA1-4324-BA00-4497784FC089-- From owner-svn-src-stable@freebsd.org Mon Nov 11 10:30:41 2019 Return-Path: Delivered-To: svn-src-stable@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 23E291B1AD3; Mon, 11 Nov 2019 10:30:41 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) (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 47BRwd0BGcz41lQ; Mon, 11 Nov 2019 10:30:40 +0000 (UTC) (envelope-from antoine.brodin.freebsd@gmail.com) Received: by mail-qk1-f194.google.com with SMTP id z16so10703948qkg.7; Mon, 11 Nov 2019 02:30:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LDMDsW8RtfaSJGK6YnL4Hi3cA6dnJOeSpggXlzX+u1c=; b=IAfYJ1NVxmBgIEfP5Bk2ukm/WELiheW7I0eIo2T+KNHLKc07sAOM0eOy3acR1cl459 /zV8eStJVKrMVstI7i+fSk5Kc25FpIEnpN7J5cF5r6oup517KcVWNUx2eup32c16HbPX 9QhMC+9jTu4t2hIOSNWJ3VKjOb+kv18VMc2ABwBBWp95zLMgNVjruPxUQR6CXyD0msEr n1KFhQpnjcW9IKetB4qz9w4cnoGvVC0X9vUw4xLUDT5/4DIJdxmOfsAk36RS3b71XK34 QBEQAUzqjVe9W4aQ8qpL9dillTuEOZRTE1mrBmuRr+Fj1yuKIj36yiJyY1g4Pcez9/mx IE4g== X-Gm-Message-State: APjAAAUHMS+Ji/TRluI/3B0wWIKmU5iC1tFXfL9jmfUUm4/217pqTFVN LOBsozT4yIB28+YXpZ3nmr/Wfx9ZzhIbraani1ux5vd3 X-Google-Smtp-Source: APXvYqxrP1GUuqyb06DyOCexcVc8gogUvm3RdkdmVwNR+NsMHqk0Q/4BSrxMkQbocsFk9lCjc50Lk9qy6oyRQqk/J38= X-Received: by 2002:a37:b885:: with SMTP id i127mr5286075qkf.485.1573468239376; Mon, 11 Nov 2019 02:30:39 -0800 (PST) MIME-Version: 1.0 References: <201911101841.xAAIfEXV088995@repo.freebsd.org> <4FEA5BCC-A9E7-4FDB-8392-04027239D9B0@FreeBSD.org> In-Reply-To: <4FEA5BCC-A9E7-4FDB-8392-04027239D9B0@FreeBSD.org> From: Antoine Brodin Date: Mon, 11 Nov 2019 11:30:27 +0100 Message-ID: Subject: Re: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys To: Dimitry Andric Cc: src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 47BRwd0BGcz41lQ X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; REPLY(-4.00)[]; TAGGED_FROM(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 10:30:41 -0000 On Mon, Nov 11, 2019 at 11:10 AM Dimitry Andric wrote: > > On 11 Nov 2019, at 10:29, Antoine Brodin wrote: > > > > On Mon, Nov 11, 2019 at 9:03 AM Antoine Brodin wrote: > >> > >> On Sun, Nov 10, 2019 at 7:41 PM Dimitry Andric wrote: > >>> > >>> Author: dim > >>> Date: Sun Nov 10 18:41:13 2019 > >>> New Revision: 354598 > >>> URL: https://svnweb.freebsd.org/changeset/base/354598 > >>> > >>> Log: > >>> MFC r354460: > >>> > >>> Merge commit e8316372b from llvm git (by Louis Dionne): > >>> > >>> [libc++] Add `__truncating_cast` for safely casting float types to > >>> integers > >>> > >>> This is needed anytime we need to clamp an arbitrary floating point > >>> value to an integer type. > >>> > >>> Thanks to Eric Fiselier for the patch. > >>> > >>> Differential Revision: https://reviews.llvm.org/D66836 > >>> > >>> llvm-svn: 370891 > >>> > >>> Merge commit b92deded8 from llvm git (by Louis Dionne): > >>> > >>> [libc++] Move __clamp_to_integral to , and harden against > >>> min()/max() macros > >>> > >>> llvm-svn: 370900 > >>> > >>> Merge commit 0ec6a4882 from llvm git (by Louis Dionne): > >>> > >>> [libc++] Fix potential OOB in poisson_distribution > >>> > >>> See details in the original Chromium bug report: > >>> https://bugs.chromium.org/p/chromium/issues/detail?id=994957 > >>> > >>> Together, these fix a security issue in libc++'s implementation of > >>> std::poisson_distribution, which can be exploited to read data which is > >>> out of bounds. > >>> > >>> Note there are no programs in the FreeBSD base system that use > >>> std::poisson_distribution, so this is only a possible issue for ports > >>> and external programs which have been built against libc++. Therefore, > >>> I am bumping __FreeBSD_version for the benefit of our port maintainers. > >>> > >>> Requested by: emaste > >>> Security: potential OOB read > >>> > >>> Modified: > >>> stable/11/contrib/libc++/include/cmath > >>> stable/11/contrib/libc++/include/random > >>> stable/11/sys/sys/param.h > >>> Directory Properties: > >>> stable/11/ (props changed) > >>> > >>> Changes in other areas also in this revision: > >>> Modified: > >>> stable/12/contrib/libc++/include/cmath > >>> stable/12/contrib/libc++/include/random > >>> stable/12/sys/sys/param.h > >>> Directory Properties: > >>> stable/12/ (props changed) > >> > >> Hi, > >> > >> It seems that some recent changes to stable/11 are broken, lots of > >> ports now fail to build on stable/11. > > > > This affects stable/12 too. > > It seems that the cmath header can't be compiled. > > Interesting, it works fine here on e.g. stable/12: > > $ cat test-cmath.cpp > #include > > $ c++ -c test-cmath.cpp > > Are there any build logs available showing errors? For instance these logs: http://gohan01.nyi.freebsd.org/data/12stable-i386-quarterly-baseline/517228/logs/errors/x265-3.1.2_2.log http://gohan01.nyi.freebsd.org/data/12stable-i386-quarterly-baseline/517228/logs/errors/exiv2-0.27.1_2,1.log /usr/include/c++/v1/cmath:622:68: error: too many arguments provided to function-like macro invocation static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value ^ /usr/include/c++/v1/__config:873:13: note: macro 'static_assert' defined here # define static_assert(__b, __m) _Static_assert(__b, __m) ^ Antoine From owner-svn-src-stable@freebsd.org Mon Nov 11 14:07:12 2019 Return-Path: Delivered-To: svn-src-stable@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 47B021B63F3; Mon, 11 Nov 2019 14:07:12 +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 47BXkS1HD3z4CkF; Mon, 11 Nov 2019 14:07:12 +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 0F39418702; Mon, 11 Nov 2019 14:07:12 +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 xABE7BDP074727; Mon, 11 Nov 2019 14:07:11 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABE7Bv6074726; Mon, 11 Nov 2019 14:07:11 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201911111407.xABE7Bv6074726@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Mon, 11 Nov 2019 14:07: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: r354608 - stable/12/sys/dev/ksyms X-SVN-Group: stable-12 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/12/sys/dev/ksyms X-SVN-Commit-Revision: 354608 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:07:12 -0000 Author: markj Date: Mon Nov 11 14:07:11 2019 New Revision: 354608 URL: https://svnweb.freebsd.org/changeset/base/354608 Log: MFC r353935, r354402: Set OBJ_NOSPLIT on the ksyms(4) VM object. Modified: stable/12/sys/dev/ksyms/ksyms.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/ksyms/ksyms.c ============================================================================== --- stable/12/sys/dev/ksyms/ksyms.c Mon Nov 11 06:28:25 2019 (r354607) +++ stable/12/sys/dev/ksyms/ksyms.c Mon Nov 11 14:07:11 2019 (r354608) @@ -397,6 +397,7 @@ ksyms_open(struct cdev *dev, int flags, int fmt __unus { struct tsizes ts; struct ksyms_softc *sc; + vm_object_t object; vm_size_t elfsz; int error, try; @@ -434,8 +435,9 @@ ksyms_open(struct cdev *dev, int flags, int fmt __unus ksyms_size_calc(&ts); elfsz = sizeof(struct ksyms_hdr) + ts.ts_symsz + ts.ts_strsz; - sc->sc_obj = vm_object_allocate(OBJT_DEFAULT, + object = vm_object_allocate(OBJT_PHYS, OFF_TO_IDX(round_page(elfsz))); + sc->sc_obj = object; sc->sc_objsz = elfsz; error = ksyms_snapshot(sc, &ts); From owner-svn-src-stable@freebsd.org Mon Nov 11 14:41:06 2019 Return-Path: Delivered-To: svn-src-stable@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 4ED0C1B6D44; Mon, 11 Nov 2019 14:41:06 +0000 (UTC) (envelope-from hselasky@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 47BYTZ1QCHz4FBQ; Mon, 11 Nov 2019 14:41:06 +0000 (UTC) (envelope-from hselasky@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 13F6F18C8C; Mon, 11 Nov 2019 14:41:06 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABEf5t3094457; Mon, 11 Nov 2019 14:41:05 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABEf5eI094441; Mon, 11 Nov 2019 14:41:05 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111441.xABEf5eI094441@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 14:41: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: r354609 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 354609 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:41:06 -0000 Author: hselasky Date: Mon Nov 11 14:41:05 2019 New Revision: 354609 URL: https://svnweb.freebsd.org/changeset/base/354609 Log: MFC r353275: Compile time assert a valid subsystem for all VNET init and uninit functions. Using VNET init and uninit functions outside the given range has undefined behaviour. Sponsored by: Mellanox Technologies Modified: stable/12/sys/net/vnet.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/vnet.h ============================================================================== --- stable/12/sys/net/vnet.h Mon Nov 11 14:07:11 2019 (r354608) +++ stable/12/sys/net/vnet.h Mon Nov 11 14:41:05 2019 (r354609) @@ -325,6 +325,8 @@ struct vnet_sysinit { }; #define VNET_SYSINIT(ident, subsystem, order, func, arg) \ + CTASSERT((subsystem) > SI_SUB_VNET && \ + (subsystem) <= SI_SUB_VNET_DONE); \ static struct vnet_sysinit ident ## _vnet_init = { \ subsystem, \ order, \ @@ -337,6 +339,8 @@ struct vnet_sysinit { vnet_deregister_sysinit, &ident ## _vnet_init) #define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ + CTASSERT((subsystem) > SI_SUB_VNET && \ + (subsystem) <= SI_SUB_VNET_DONE); \ static struct vnet_sysinit ident ## _vnet_uninit = { \ subsystem, \ order, \ From owner-svn-src-stable@freebsd.org Mon Nov 11 14:49:46 2019 Return-Path: Delivered-To: svn-src-stable@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 7D4C41B72D6; Mon, 11 Nov 2019 14:49:46 +0000 (UTC) (envelope-from hselasky@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 47BYgZ2NWzz4Ft1; Mon, 11 Nov 2019 14:49:46 +0000 (UTC) (envelope-from hselasky@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 30E0318E25; Mon, 11 Nov 2019 14:49:46 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABEnkxK098456; Mon, 11 Nov 2019 14:49:46 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABEnkhi098455; Mon, 11 Nov 2019 14:49:46 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111449.xABEnkhi098455@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 14:49:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354610 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 354610 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:49:46 -0000 Author: hselasky Date: Mon Nov 11 14:49:45 2019 New Revision: 354610 URL: https://svnweb.freebsd.org/changeset/base/354610 Log: MFC r353275: Compile time assert a valid subsystem for all VNET init and uninit functions. Using VNET init and uninit functions outside the given range has undefined behaviour. Sponsored by: Mellanox Technologies Modified: stable/11/sys/net/vnet.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/vnet.h ============================================================================== --- stable/11/sys/net/vnet.h Mon Nov 11 14:41:05 2019 (r354609) +++ stable/11/sys/net/vnet.h Mon Nov 11 14:49:45 2019 (r354610) @@ -308,6 +308,8 @@ struct vnet_sysinit { }; #define VNET_SYSINIT(ident, subsystem, order, func, arg) \ + CTASSERT((subsystem) > SI_SUB_VNET && \ + (subsystem) <= SI_SUB_VNET_DONE); \ static struct vnet_sysinit ident ## _vnet_init = { \ subsystem, \ order, \ @@ -320,6 +322,8 @@ struct vnet_sysinit { vnet_deregister_sysinit, &ident ## _vnet_init) #define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ + CTASSERT((subsystem) > SI_SUB_VNET && \ + (subsystem) <= SI_SUB_VNET_DONE); \ static struct vnet_sysinit ident ## _vnet_uninit = { \ subsystem, \ order, \ From owner-svn-src-stable@freebsd.org Mon Nov 11 14:51:08 2019 Return-Path: Delivered-To: svn-src-stable@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 C61581B7372; Mon, 11 Nov 2019 14:51:08 +0000 (UTC) (envelope-from hselasky@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 47BYj84vMVz4G3T; Mon, 11 Nov 2019 14:51:08 +0000 (UTC) (envelope-from hselasky@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 8CBFC18F53; Mon, 11 Nov 2019 14:51:08 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABEp8v2000453; Mon, 11 Nov 2019 14:51:08 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABEp8jY000452; Mon, 11 Nov 2019 14:51:08 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111451.xABEp8jY000452@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 14:51: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: r354611 - stable/12/sys/dev/usb/controller X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/12/sys/dev/usb/controller X-SVN-Commit-Revision: 354611 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:51:08 -0000 Author: hselasky Date: Mon Nov 11 14:51:08 2019 New Revision: 354611 URL: https://svnweb.freebsd.org/changeset/base/354611 Log: MFC r353273: Make control endpoint quirk for xhci(4) configurable. Sponsored by: Mellanox Technologies Modified: stable/12/sys/dev/usb/controller/xhci.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/12/sys/dev/usb/controller/xhci.c Mon Nov 11 14:49:45 2019 (r354610) +++ stable/12/sys/dev/usb/controller/xhci.c Mon Nov 11 14:51:08 2019 (r354611) @@ -95,6 +95,10 @@ static int xhcistreams; SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, &xhcistreams, 0, "Set to enable streams mode support"); +static int xhcictlquirk = 1; +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, ctlquirk, CTLFLAG_RWTUN, + &xhcictlquirk, 0, "Set to enable control endpoint quirk"); + #ifdef USB_DEBUG static int xhcidebug; static int xhciroute; @@ -602,7 +606,7 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_ sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); /* enable 64Kbyte control endpoint quirk */ - sc->sc_bus.control_ep_quirk = 1; + sc->sc_bus.control_ep_quirk = (xhcictlquirk ? 1 : 0); temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); From owner-svn-src-stable@freebsd.org Mon Nov 11 14:51:56 2019 Return-Path: Delivered-To: svn-src-stable@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 DFCAE1B751B; Mon, 11 Nov 2019 14:51:56 +0000 (UTC) (envelope-from hselasky@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 47BYk45jH0z4GL4; Mon, 11 Nov 2019 14:51:56 +0000 (UTC) (envelope-from hselasky@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 A72BA18F9E; Mon, 11 Nov 2019 14:51:56 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABEpuPF003716; Mon, 11 Nov 2019 14:51:56 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABEpuno003715; Mon, 11 Nov 2019 14:51:56 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111451.xABEpuno003715@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 14:51:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354612 - stable/11/sys/dev/usb/controller X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: stable/11/sys/dev/usb/controller X-SVN-Commit-Revision: 354612 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:51:56 -0000 Author: hselasky Date: Mon Nov 11 14:51:56 2019 New Revision: 354612 URL: https://svnweb.freebsd.org/changeset/base/354612 Log: MFC r353273: Make control endpoint quirk for xhci(4) configurable. Sponsored by: Mellanox Technologies Modified: stable/11/sys/dev/usb/controller/xhci.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/usb/controller/xhci.c ============================================================================== --- stable/11/sys/dev/usb/controller/xhci.c Mon Nov 11 14:51:08 2019 (r354611) +++ stable/11/sys/dev/usb/controller/xhci.c Mon Nov 11 14:51:56 2019 (r354612) @@ -93,6 +93,10 @@ static int xhcistreams; SYSCTL_INT(_hw_usb_xhci, OID_AUTO, streams, CTLFLAG_RWTUN, &xhcistreams, 0, "Set to enable streams mode support"); +static int xhcictlquirk = 1; +SYSCTL_INT(_hw_usb_xhci, OID_AUTO, ctlquirk, CTLFLAG_RWTUN, + &xhcictlquirk, 0, "Set to enable control endpoint quirk"); + #ifdef USB_DEBUG static int xhcidebug; static int xhciroute; @@ -600,7 +604,7 @@ xhci_init(struct xhci_softc *sc, device_t self, uint8_ sc->sc_ctx_is_64_byte ? 64 : 32, (int)sc->sc_bus.dma_bits); /* enable 64Kbyte control endpoint quirk */ - sc->sc_bus.control_ep_quirk = 1; + sc->sc_bus.control_ep_quirk = (xhcictlquirk ? 1 : 0); temp = XREAD4(sc, capa, XHCI_HCSPARAMS1); From owner-svn-src-stable@freebsd.org Mon Nov 11 14:56:23 2019 Return-Path: Delivered-To: svn-src-stable@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 69A051B76B6; Mon, 11 Nov 2019 14:56:23 +0000 (UTC) (envelope-from hselasky@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 47BYqC27cJz4Gct; Mon, 11 Nov 2019 14:56:23 +0000 (UTC) (envelope-from hselasky@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 279F118FE0; Mon, 11 Nov 2019 14:56:23 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABEuMqD004938; Mon, 11 Nov 2019 14:56:22 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABEuMcJ004936; Mon, 11 Nov 2019 14:56:22 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111456.xABEuMcJ004936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 14:56: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: r354613 - in stable/12/sys: compat/linuxkpi/common/include/linux sys X-SVN-Group: stable-12 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/12/sys: compat/linuxkpi/common/include/linux sys X-SVN-Commit-Revision: 354613 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 14:56:23 -0000 Author: hselasky Date: Mon Nov 11 14:56:22 2019 New Revision: 354613 URL: https://svnweb.freebsd.org/changeset/base/354613 Log: MFC r354335: Enable device class group attributes in the LinuxKPI. Bump the __FreeBSD_version to force recompilation of external kernel modules due to structure change. Differential Revision: https://reviews.freebsd.org/D21564 Submitted by: Greg V Sponsored by: Mellanox Technologies Modified: stable/12/sys/compat/linuxkpi/common/include/linux/device.h stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h stable/12/sys/sys/param.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/compat/linuxkpi/common/include/linux/device.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 14:56:22 2019 (r354613) @@ -54,6 +54,7 @@ struct class { struct kobject kobj; devclass_t bsdclass; const struct dev_pm_ops *pm; + const struct attribute_group **dev_groups; void (*class_release)(struct class *class); void (*dev_release)(struct device *dev); char * (*devnode)(struct device *dev, umode_t *mode); @@ -426,6 +427,8 @@ done: kobject_init(&dev->kobj, &linux_dev_ktype); kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev)); + sysfs_create_groups(&dev->kobj, dev->class->dev_groups); + return (0); } @@ -433,6 +436,8 @@ static inline void device_unregister(struct device *dev) { device_t bsddev; + + sysfs_remove_groups(&dev->kobj, dev->class->dev_groups); bsddev = dev->bsddev; dev->bsddev = NULL; Modified: stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h ============================================================================== --- stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 14:56:22 2019 (r354613) @@ -62,12 +62,13 @@ struct attribute_group { #define ATTRIBUTE_GROUPS(_name) \ static struct attribute_group _name##_group = { \ + .name = __stringify(_name), \ .attrs = _name##_attrs, \ }; \ - static struct attribute_group *_name##_groups[] = { \ + static const struct attribute_group *_name##_groups[] = { \ &_name##_group, \ NULL, \ - }; + } /* * Handle our generic '\0' terminated 'C' string. @@ -210,12 +211,25 @@ sysfs_create_groups(struct kobject *kobj, const struct int error = 0; int i; + if (grps == NULL) + goto done; for (i = 0; grps[i] && !error; i++) error = sysfs_create_group(kobj, grps[i]); while (error && --i >= 0) sysfs_remove_group(kobj, grps[i]); - +done: return (error); +} + +static inline void +sysfs_remove_groups(struct kobject *kobj, const struct attribute_group **grps) +{ + int i; + + if (grps == NULL) + return; + for (i = 0; grps[i]; i++) + sysfs_remove_group(kobj, grps[i]); } static inline int Modified: stable/12/sys/sys/param.h ============================================================================== --- stable/12/sys/sys/param.h Mon Nov 11 14:51:56 2019 (r354612) +++ stable/12/sys/sys/param.h Mon Nov 11 14:56:22 2019 (r354613) @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1201501 /* Master, propagated to newvers */ +#define __FreeBSD_version 1201502 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Mon Nov 11 15:23:59 2019 Return-Path: Delivered-To: svn-src-stable@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 412D51B7C23; Mon, 11 Nov 2019 15:23:59 +0000 (UTC) (envelope-from hselasky@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 47BZR30wdMz4Hk6; Mon, 11 Nov 2019 15:23:59 +0000 (UTC) (envelope-from hselasky@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 0425019557; Mon, 11 Nov 2019 15:23:59 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABFNwT1022193; Mon, 11 Nov 2019 15:23:58 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABFNwMK022191; Mon, 11 Nov 2019 15:23:58 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111523.xABFNwMK022191@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 15:23:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354614 - in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Commit-Revision: 354614 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 15:23:59 -0000 Author: hselasky Date: Mon Nov 11 15:23:58 2019 New Revision: 354614 URL: https://svnweb.freebsd.org/changeset/base/354614 Log: MFC r351701: LinuxKPI: Add sysfs create/remove functions that handles multiple files in one call. Differential Revision: D21475 Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 14:56:22 2019 (r354613) +++ stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 15:23:58 2019 (r354614) @@ -152,6 +152,29 @@ sysfs_remove_file(struct kobject *kobj, const struct a sysctl_remove_name(kobj->oidp, attr->name, 1, 1); } +static inline int +sysfs_create_files(struct kobject *kobj, const struct attribute * const *attrs) +{ + int error = 0; + int i; + + for (i = 0; attrs[i] && !error; i++) + error = sysfs_create_file(kobj, attrs[i]); + while (error && --i >= 0) + sysfs_remove_file(kobj, attrs[i]); + + return (error); +} + +static inline void +sysfs_remove_files(struct kobject *kobj, const struct attribute * const *attrs) +{ + int i; + + for (i = 0; attrs[i]; i++) + sysfs_remove_file(kobj, attrs[i]); +} + static inline void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp) { Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Mon Nov 11 14:56:22 2019 (r354613) +++ stable/11/sys/sys/param.h Mon Nov 11 15:23:58 2019 (r354614) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1103501 /* Master, propagated to newvers */ +#define __FreeBSD_version 1103502 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Mon Nov 11 15:26:06 2019 Return-Path: Delivered-To: svn-src-stable@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 E30501B7CA9; Mon, 11 Nov 2019 15:26:06 +0000 (UTC) (envelope-from hselasky@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 47BZTV5ckQz4Hs4; Mon, 11 Nov 2019 15:26:06 +0000 (UTC) (envelope-from hselasky@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 A411019559; Mon, 11 Nov 2019 15:26:06 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABFQ6JG022360; Mon, 11 Nov 2019 15:26:06 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABFQ6dC022358; Mon, 11 Nov 2019 15:26:06 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111526.xABFQ6dC022358@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 15:26:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354615 - in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Commit-Revision: 354615 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 15:26:07 -0000 Author: hselasky Date: Mon Nov 11 15:26:05 2019 New Revision: 354615 URL: https://svnweb.freebsd.org/changeset/base/354615 Log: MFC r351937: LinuxKPI: Improve sysfs support. - Add functions for creating and merging sysfs groups. - Add sysfs_streq function to compare strings ignoring newline from the sysctl userland call. - Add a call to sysfs_create_groups in device_add. - Remove duplicate header include. - Bump __FreeBSD_version. Differential Revision: D21542 Modified: stable/11/sys/compat/linuxkpi/common/include/linux/device.h stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/device.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 15:23:58 2019 (r354614) +++ stable/11/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 15:26:05 2019 (r354615) @@ -40,7 +40,6 @@ #include #include #include -#include #include #include @@ -315,6 +314,10 @@ device_add(struct device *dev) dev->devt = makedev(0, device_get_unit(dev->bsddev)); } kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev)); + + if (dev->groups) + return (sysfs_create_groups(&dev->kobj, dev->groups)); + return (0); } Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 15:23:58 2019 (r354614) +++ stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 15:26:05 2019 (r354615) @@ -175,6 +175,27 @@ sysfs_remove_files(struct kobject *kobj, const struct sysfs_remove_file(kobj, attrs[i]); } +static inline int +sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) +{ + struct attribute **attr; + struct sysctl_oid *oidp; + + /* Don't create the group node if grp->name is undefined. */ + if (grp->name) + oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->oidp), + OID_AUTO, grp->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, grp->name); + else + oidp = kobj->oidp; + for (attr = grp->attrs; *attr != NULL; attr++) { + SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO, + (*attr)->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, + kobj, (uintptr_t)*attr, sysctl_handle_attr, "A", ""); + } + + return (0); +} + static inline void sysfs_remove_group(struct kobject *kobj, const struct attribute_group *grp) { @@ -184,20 +205,40 @@ sysfs_remove_group(struct kobject *kobj, const struct } static inline int -sysfs_create_group(struct kobject *kobj, const struct attribute_group *grp) +sysfs_create_groups(struct kobject *kobj, const struct attribute_group **grps) { + int error = 0; + int i; + + for (i = 0; grps[i] && !error; i++) + error = sysfs_create_group(kobj, grps[i]); + while (error && --i >= 0) + sysfs_remove_group(kobj, grps[i]); + + return (error); +} + +static inline int +sysfs_merge_group(struct kobject *kobj, const struct attribute_group *grp) +{ + + /* Really expected behavior is to return failure if group exists. */ + return (sysfs_create_group(kobj, grp)); +} + +static inline void +sysfs_unmerge_group(struct kobject *kobj, const struct attribute_group *grp) +{ struct attribute **attr; struct sysctl_oid *oidp; - oidp = SYSCTL_ADD_NODE(NULL, SYSCTL_CHILDREN(kobj->oidp), - OID_AUTO, grp->name, CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, grp->name); - for (attr = grp->attrs; *attr != NULL; attr++) { - SYSCTL_ADD_OID(NULL, SYSCTL_CHILDREN(oidp), OID_AUTO, - (*attr)->name, CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, - kobj, (uintptr_t)*attr, sysctl_handle_attr, "A", ""); + SLIST_FOREACH(oidp, SYSCTL_CHILDREN(kobj->oidp), oid_link) { + if (strcmp(oidp->oid_name, grp->name) != 0) + continue; + for (attr = grp->attrs; *attr != NULL; attr++) { + sysctl_remove_name(oidp, (*attr)->name, 1, 1); + } } - - return (0); } static inline int @@ -222,6 +263,22 @@ sysfs_remove_dir(struct kobject *kobj) if (kobj->oidp == NULL) return; sysctl_remove_oid(kobj->oidp, 1, 1); +} + +static inline bool +sysfs_streq(const char *s1, const char *s2) +{ + int l1, l2; + + l1 = strlen(s1); + l2 = strlen(s2); + + if (l1 != 0 && s1[l1-1] == '\n') + l1--; + if (l2 != 0 && s2[l2-1] == '\n') + l2--; + + return (l1 == l2 && strncmp(s1, s2, l1) == 0); } #define sysfs_attr_init(attr) do {} while(0) Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Mon Nov 11 15:23:58 2019 (r354614) +++ stable/11/sys/sys/param.h Mon Nov 11 15:26:05 2019 (r354615) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1103502 /* Master, propagated to newvers */ +#define __FreeBSD_version 1103503 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Mon Nov 11 15:28:29 2019 Return-Path: Delivered-To: svn-src-stable@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 26D351B7D3E; Mon, 11 Nov 2019 15:28:29 +0000 (UTC) (envelope-from hselasky@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 47BZXD75bkz4J1N; Mon, 11 Nov 2019 15:28:28 +0000 (UTC) (envelope-from hselasky@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 D6ED31955B; Mon, 11 Nov 2019 15:28:28 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xABFSS5N022519; Mon, 11 Nov 2019 15:28:28 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABFSSmL022516; Mon, 11 Nov 2019 15:28:28 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201911111528.xABFSSmL022516@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 11 Nov 2019 15:28:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354616 - in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Group: stable-11 X-SVN-Commit-Author: hselasky X-SVN-Commit-Paths: in stable/11/sys: compat/linuxkpi/common/include/linux sys X-SVN-Commit-Revision: 354616 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 15:28:29 -0000 Author: hselasky Date: Mon Nov 11 15:28:27 2019 New Revision: 354616 URL: https://svnweb.freebsd.org/changeset/base/354616 Log: MFC r354335: Enable device class group attributes in the LinuxKPI. Bump the __FreeBSD_version to force recompilation of external kernel modules due to structure change. Differential Revision: https://reviews.freebsd.org/D21564 Submitted by: Greg V Sponsored by: Mellanox Technologies Modified: stable/11/sys/compat/linuxkpi/common/include/linux/device.h stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h stable/11/sys/sys/param.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/compat/linuxkpi/common/include/linux/device.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 15:26:05 2019 (r354615) +++ stable/11/sys/compat/linuxkpi/common/include/linux/device.h Mon Nov 11 15:28:27 2019 (r354616) @@ -54,6 +54,7 @@ struct class { struct kobject kobj; devclass_t bsdclass; const struct dev_pm_ops *pm; + const struct attribute_group **dev_groups; void (*class_release)(struct class *class); void (*dev_release)(struct device *dev); char * (*devnode)(struct device *dev, umode_t *mode); @@ -423,6 +424,8 @@ done: kobject_init(&dev->kobj, &linux_dev_ktype); kobject_add(&dev->kobj, &dev->class->kobj, dev_name(dev)); + sysfs_create_groups(&dev->kobj, dev->class->dev_groups); + return (0); } @@ -430,6 +433,8 @@ static inline void device_unregister(struct device *dev) { device_t bsddev; + + sysfs_remove_groups(&dev->kobj, dev->class->dev_groups); bsddev = dev->bsddev; dev->bsddev = NULL; Modified: stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h ============================================================================== --- stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 15:26:05 2019 (r354615) +++ stable/11/sys/compat/linuxkpi/common/include/linux/sysfs.h Mon Nov 11 15:28:27 2019 (r354616) @@ -62,12 +62,13 @@ struct attribute_group { #define ATTRIBUTE_GROUPS(_name) \ static struct attribute_group _name##_group = { \ + .name = __stringify(_name), \ .attrs = _name##_attrs, \ }; \ - static struct attribute_group *_name##_groups[] = { \ + static const struct attribute_group *_name##_groups[] = { \ &_name##_group, \ NULL, \ - }; + } /* * Handle our generic '\0' terminated 'C' string. @@ -210,12 +211,25 @@ sysfs_create_groups(struct kobject *kobj, const struct int error = 0; int i; + if (grps == NULL) + goto done; for (i = 0; grps[i] && !error; i++) error = sysfs_create_group(kobj, grps[i]); while (error && --i >= 0) sysfs_remove_group(kobj, grps[i]); - +done: return (error); +} + +static inline void +sysfs_remove_groups(struct kobject *kobj, const struct attribute_group **grps) +{ + int i; + + if (grps == NULL) + return; + for (i = 0; grps[i]; i++) + sysfs_remove_group(kobj, grps[i]); } static inline int Modified: stable/11/sys/sys/param.h ============================================================================== --- stable/11/sys/sys/param.h Mon Nov 11 15:26:05 2019 (r354615) +++ stable/11/sys/sys/param.h Mon Nov 11 15:28:27 2019 (r354616) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1103503 /* Master, propagated to newvers */ +#define __FreeBSD_version 1103504 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From owner-svn-src-stable@freebsd.org Mon Nov 11 17:45:07 2019 Return-Path: Delivered-To: svn-src-stable@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 43F091BA89C; Mon, 11 Nov 2019 17:45:07 +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 47BdYv14ZLz4Rlt; Mon, 11 Nov 2019 17:45:07 +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 03F991AEDB; Mon, 11 Nov 2019 17:45:07 +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 xABHj6mB005328; Mon, 11 Nov 2019 17:45:06 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABHj6cR005327; Mon, 11 Nov 2019 17:45:06 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911111745.xABHj6cR005327@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 11 Nov 2019 17:45:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354626 - in stable: 11/contrib/libc++/include 12/contrib/libc++/include X-SVN-Group: stable-11 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/libc++/include 12/contrib/libc++/include X-SVN-Commit-Revision: 354626 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 17:45:07 -0000 Author: dim Date: Mon Nov 11 17:45:06 2019 New Revision: 354626 URL: https://svnweb.freebsd.org/changeset/base/354626 Log: MFC r354625: Merge commit 371ea70bb from llvm git (by Louis Dionne): [libc++] Harden usage of static_assert against C++03 In C++03, we emulate static_assert with a macro, and we must parenthesize multiple arguments. llvm-svn: 373328 This is a follow-up to r354460, which causes errors for pre-C++11 programs using , similar to: /usr/include/c++/v1/cmath:622:68: error: too many arguments provided to function-like macro invocation Reported by: antoine Modified: stable/11/contrib/libc++/include/cmath Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/12/contrib/libc++/include/cmath Directory Properties: stable/12/ (props changed) Modified: stable/11/contrib/libc++/include/cmath ============================================================================== --- stable/11/contrib/libc++/include/cmath Mon Nov 11 17:41:56 2019 (r354625) +++ stable/11/contrib/libc++/include/cmath Mon Nov 11 17:45:06 2019 (r354626) @@ -619,8 +619,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_fl static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); static_assert(is_integral<_IntT>::value, "must be an integral type"); static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); - static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value - || is_same<_FloatT,long double>::value, "unsupported floating point type"); + static_assert((is_same<_FloatT, float>::value || is_same<_FloatT, double>::value + || is_same<_FloatT,long double>::value), "unsupported floating point type"); return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); } From owner-svn-src-stable@freebsd.org Mon Nov 11 17:45:07 2019 Return-Path: Delivered-To: svn-src-stable@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 0958D1BA896; Mon, 11 Nov 2019 17:45:07 +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 47BdYt6V0Dz4Rls; Mon, 11 Nov 2019 17:45:06 +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 C1E471AEDA; Mon, 11 Nov 2019 17:45:06 +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 xABHj6ux005322; Mon, 11 Nov 2019 17:45:06 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABHj6Bj005321; Mon, 11 Nov 2019 17:45:06 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201911111745.xABHj6Bj005321@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 11 Nov 2019 17:45: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: r354626 - in stable: 11/contrib/libc++/include 12/contrib/libc++/include X-SVN-Group: stable-12 X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in stable: 11/contrib/libc++/include 12/contrib/libc++/include X-SVN-Commit-Revision: 354626 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 17:45:07 -0000 Author: dim Date: Mon Nov 11 17:45:06 2019 New Revision: 354626 URL: https://svnweb.freebsd.org/changeset/base/354626 Log: MFC r354625: Merge commit 371ea70bb from llvm git (by Louis Dionne): [libc++] Harden usage of static_assert against C++03 In C++03, we emulate static_assert with a macro, and we must parenthesize multiple arguments. llvm-svn: 373328 This is a follow-up to r354460, which causes errors for pre-C++11 programs using , similar to: /usr/include/c++/v1/cmath:622:68: error: too many arguments provided to function-like macro invocation Reported by: antoine Modified: stable/12/contrib/libc++/include/cmath Directory Properties: stable/12/ (props changed) Changes in other areas also in this revision: Modified: stable/11/contrib/libc++/include/cmath Directory Properties: stable/11/ (props changed) Modified: stable/12/contrib/libc++/include/cmath ============================================================================== --- stable/12/contrib/libc++/include/cmath Mon Nov 11 17:41:56 2019 (r354625) +++ stable/12/contrib/libc++/include/cmath Mon Nov 11 17:45:06 2019 (r354626) @@ -619,8 +619,8 @@ _LIBCPP_CONSTEXPR _IntT __max_representable_int_for_fl static_assert(is_floating_point<_FloatT>::value, "must be a floating point type"); static_assert(is_integral<_IntT>::value, "must be an integral type"); static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix"); - static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, double>::value - || is_same<_FloatT,long double>::value, "unsupported floating point type"); + static_assert((is_same<_FloatT, float>::value || is_same<_FloatT, double>::value + || is_same<_FloatT,long double>::value), "unsupported floating point type"); return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits); } From owner-svn-src-stable@freebsd.org Mon Nov 11 17:48:22 2019 Return-Path: Delivered-To: svn-src-stable@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 755701BA9DB; Mon, 11 Nov 2019 17:48:22 +0000 (UTC) (envelope-from dim@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 47Bddf2Rqvz4S7Y; Mon, 11 Nov 2019 17:48:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:470:7a58:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) (Authenticated sender: dim) by smtp.freebsd.org (Postfix) with ESMTPSA id 1F24A892; Mon, 11 Nov 2019 17:48:22 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::4967:b668:de9c:4138] (unknown [IPv6:2001:470:7a58:0:4967:b668:de9c:4138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 7FD1E2C217; Mon, 11 Nov 2019 18:48:20 +0100 (CET) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_97F0F766-BFC7-4F1A-89B6-1DE2A586CECE"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: svn commit: r354598 - in stable: 11/contrib/libc++/include 11/sys/sys 12/contrib/libc++/include 12/sys/sys Date: Mon, 11 Nov 2019 18:48:13 +0100 In-Reply-To: Cc: src-committers , svn-src-all , svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org To: Antoine Brodin References: <201911101841.xAAIfEXV088995@repo.freebsd.org> <4FEA5BCC-A9E7-4FDB-8392-04027239D9B0@FreeBSD.org> X-Mailer: Apple Mail (2.3445.104.11) X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 17:48:22 -0000 --Apple-Mail=_97F0F766-BFC7-4F1A-89B6-1DE2A586CECE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 11 Nov 2019, at 11:30, Antoine Brodin wrote: >=20 > On Mon, Nov 11, 2019 at 11:10 AM Dimitry Andric = wrote: >>=20 >> On 11 Nov 2019, at 10:29, Antoine Brodin wrote: >>>=20 >>> On Mon, Nov 11, 2019 at 9:03 AM Antoine Brodin = wrote: >>>>=20 >>>> On Sun, Nov 10, 2019 at 7:41 PM Dimitry Andric = wrote: >>>>>=20 >>>>> Author: dim >>>>> Date: Sun Nov 10 18:41:13 2019 >>>>> New Revision: 354598 >>>>> URL: https://svnweb.freebsd.org/changeset/base/354598 ... >> Are there any build logs available showing errors? >=20 > For instance these logs: > = http://gohan01.nyi.freebsd.org/data/12stable-i386-quarterly-baseline/51722= 8/logs/errors/x265-3.1.2_2.log > = http://gohan01.nyi.freebsd.org/data/12stable-i386-quarterly-baseline/51722= 8/logs/errors/exiv2-0.27.1_2,1.log >=20 > /usr/include/c++/v1/cmath:622:68: error: too many arguments provided > to function-like macro invocation > static_assert(is_same<_FloatT, float>::value || is_same<_FloatT, > double>::value > ^ > /usr/include/c++/v1/__config:873:13: note: macro 'static_assert' = defined here > # define static_assert(__b, __m) _Static_assert(__b, __m) > ^ This should now be fixed by r354626, which is an insta-MFC of r354625. -Dimitry --Apple-Mail=_97F0F766-BFC7-4F1A-89B6-1DE2A586CECE Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXcme3QAKCRCwXqMKLiCW o6J9AJ94jucqH7Hjex1WpA4VSdtHz97jQACg5gOJ9dBtgjdgQRC8NcO6Z67fU54= =aWA/ -----END PGP SIGNATURE----- --Apple-Mail=_97F0F766-BFC7-4F1A-89B6-1DE2A586CECE-- From owner-svn-src-stable@freebsd.org Mon Nov 11 19:54:10 2019 Return-Path: Delivered-To: svn-src-stable@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 338611BD113; Mon, 11 Nov 2019 19:54:10 +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 47BhQp15r4z4b7G; Mon, 11 Nov 2019 19:54:10 +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 09D381C6CF; Mon, 11 Nov 2019 19:54:10 +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 xABJsAUJ083342; Mon, 11 Nov 2019 19:54:10 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xABJs87W083335; Mon, 11 Nov 2019 19:54:08 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201911111954.xABJs87W083335@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 11 Nov 2019 19:54:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354628 - in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/11: contrib/netbsd-tests/usr.bin/grep usr.bin/grep usr.bin/grep/tests X-SVN-Commit-Revision: 354628 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Nov 2019 19:54:10 -0000 Author: kevans Date: Mon Nov 11 19:54:08 2019 New Revision: 354628 URL: https://svnweb.freebsd.org/changeset/base/354628 Log: MFC bsdgrep(1) fixes: r320414, r328559, r332805-r332806, r332809, r332832, r332850-r332852, r332856, r332858, r332876, r333351, r334803, r334806-r334809, r334821, r334837, r334889, r335188, r351769, r352691 r320414: Expect :mmap_eof_not_eol to fail It relies on a jemalloc feature (opt.redzone) no longer available after r319971. r328559: Remove t_grep:mmap_eof_not_eol test The test was marked as an expected failure in r320414 after r319971's import of a newer jemalloc removed an essential feature (opt.redzone) for reproducing the behavior it was testing. Since then, no way has been found or demonstrated to reliably test the behavior, so remove the test. r332805: bsdgrep: Split match processing out of procfile procfile is getting kind of hairy, and it's not going to get better as we correct some more bits that assume we process one line at a time. r332806: bsdgrep: Clean up procmatches a little bit r332809: bsdgrep: Add some TODOs for future work on operating on chunks r332832: bsdgrep: Break procmatches down a little bit more Split the matching and non-matching cases out into their own functions to reduce future complexity. As the name implies, procmatches will eventually process more than one match itself in the future. r332850: bsdgrep: Some light cleanup There's no point checking for a bunch of file modes if we're not a practicing believer of DIR_SKIP or DEV_SKIP. This also reduces some style violations that were particularly ugly looking when browsing through. r332851: bsdgrep: More trivial cleanup/style cleanup We can avoid branching for these easily reduced patterns r332852: bsdgrep: if chain => switch This makes some of this a little easier to follow (in my opinion). r332856: bsdgrep: Fix --include/--exclude ordering issues Prior to r332851: * --exclude always win out over --include * --exclude-dir always wins out over --include-dir r332851 broke that behavior, resulting in: * First of --exclude, --include wins * First of --exclude-dir, --include-dir wins As it turns out, both behaviors are wrong by modern grep standards- the latest rule wins. e.g.: `grep --exclude foo --include foo 'thing' foo` foo is included `grep --include foo --exclude foo 'thing' foo` foo is excluded As tested with GNU grep 3.1. This commit makes bsdgrep follow this behavior. r332858: bsdgrep: Use grep_strdup instead of grep_malloc+strcpy r332876: bsdgrep: Fix build failure WITHOUT_LZMA (incorrect bracket placement) r333351: bsdgrep: Allow "-" to be passed to -f to mean "standard input" A version of this patch was originally sent to me by se@, matching behavior from newer versions of GNU grep. While there have been some differences of opinion on whether stdin should be closed or not after depleting it in process of -f, I've opted to leave stdin open and just let the later matching stuff fail and result in a no-match. I'm not married to the current behavior- it was generally chosen since we are adopting this in particular from GNU grep, and I would like to stay consistent without a strong argument to the contrary. The current behavior isn't technically wrong, it's just fairly unfriendly to the developer-user of grep that may not realize their usage is trivially invalid. r334803: netbsd-tests: grep(1): Add test for -c flag Someone might be inclined to accidentally break this. someone might have written said test because they broke it locally. r334806: bsdgrep(1): Do some less dirty things with return types Neither procfile nor grep_tree return anything meaningful to their callers. None of the callers actually care about how many lines were matched in all of the files they processed; it's all about "did anything match?" This is generally just a light refactoring to remind me of what actually matters as I'm rewriting these bits to care less about 'stuff'. r334807: bsdgrep(1): whoops, garbage collect the now write-only variable r334808: bsdgrep(1): Don't initialize fts_flags twice Admittedly, this is a clang-scan complaint... but it wasn't wrong. fts_flags is initialized by all cases in the switch(), which should be fairly obvious. Annotate this anyways. r334809: netbsd-tests: bsdgrep(1): Add a test for -m, too r334821: bsdgrep(1): Slooowly peel away the chunky onion (or peel off the band-aid, whatever floats your boat) This addresses two separate issues: 1.) Nothing within bsdgrep actually knew whether it cared about line numbers or not. 2.) The file layer knew nothing about the context in which it was being called. #1 is only important when we're *not* processing line-by-line. #2 is debatably a good idea; the parsing context is only handy because that's where we store current offset information and, as of this commit, whether or not it needs to be line-aware. r334837: bsdgrep(1): Evict character sequence that moved in r334889: bsdgrep(1): Some more int -> bool conversions and name changes Again motivated by upcoming work to rewrite a bunch of this- single-letter variable names and slightly misleading variable names ("lastmatches" to indicate that the last matched) are not helpful. r335188: bsdgrep(1): Remove redundant initialization; unconditionally assigned later r351769: bsdgrep(1): add some basic tests for some GNU Extension support These will be expanded later as I come up with good test cases; for now, these seem to be enough to trigger bugs in base gnugrep and expose missing features in bsdgrep. r352691: bsdgrep(1): various fixes of empty pattern/exit code/-c behavior When an empty pattern is encountered in the pattern list, I had previously broken bsdgrep to count that as a "match all" and ignore any other patterns in the list. This commit rectifies that mistake, among others: - The -v flag semantics were not quite right; lines matched should have been counted differently based on whether the -v flag was set or not. procline now definitively returns whether it's matched or not, and interpreting that result has been kicked up a level. - Empty patterns with the -x flag was broken similarly to empty patterns with the -w flag. The former is a whole-line match and should be more strict, only matching blank lines. No -x and no -w will will match the empty string at the beginning of each line. - The exit code with -L was broken, w.r.t. modern grep. Modern grap will exit(0) if any file that didn't match was output, so our interpretation was simply backwards. The new interpretation makes sense to me. Tests updated and added to try and catch some of this. This misbehavior was found by autoconf while fixing ports found in PR 229925 expecting either a more sane or a more GNU-like sed. Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh stable/11/usr.bin/grep/file.c stable/11/usr.bin/grep/grep.1 stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/tests/grep_freebsd_test.sh stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh ============================================================================== --- stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/contrib/netbsd-tests/usr.bin/grep/t_grep.sh Mon Nov 11 19:54:08 2019 (r354628) @@ -413,6 +413,60 @@ wflag_emptypat_body() atf_check -o file:test4 grep -w -e "" test4 } +atf_test_case xflag_emptypat +xflag_emptypat_body() +{ + printf "" > test1 + printf "\n" > test2 + printf "qaz" > test3 + printf " qaz\n" > test4 + + # -x is whole-line, more strict than -w. + atf_check -s exit:1 -o empty grep -x -e "" test1 + + atf_check -o file:test2 grep -x -e "" test2 + + atf_check -s exit:1 -o empty grep -x -e "" test3 + + atf_check -s exit:1 -o empty grep -x -e "" test4 + + total=$(wc -l /COPYRIGHT | sed 's/[^0-9]//g') + + # Simple checks that grep -x with an empty pattern isn't matching every + # line. The exact counts aren't important, as long as they don't + # match the total line count and as long as they don't match each other. + atf_check -o save:xpositive.count grep -Fxc '' /COPYRIGHT + atf_check -o save:xnegative.count grep -Fvxc '' /COPYRIGHT + + atf_check -o not-inline:"${total}" cat xpositive.count + atf_check -o not-inline:"${total}" cat xnegative.count + + atf_check -o not-file:xnegative.count cat xpositive.count +} + +atf_test_case xflag_emptypat_plus +xflag_emptypat_plus_body() +{ + printf "foo\n\nbar\n\nbaz\n" > target + printf "foo\n \nbar\n \nbaz\n" > target_spacelines + printf "foo\nbar\nbaz\n" > matches + printf " \n \n" > spacelines + + printf "foo\n\nbar\n\nbaz\n" > patlist1 + printf "foo\n\nba\n\nbaz\n" > patlist2 + + sed -e '/bar/d' target > matches_not2 + + # Normal handling first + atf_check -o file:target grep -Fxf patlist1 target + atf_check -o file:matches grep -Fxf patlist1 target_spacelines + atf_check -o file:matches_not2 grep -Fxf patlist2 target + + # -v handling + atf_check -s exit:1 -o empty grep -Fvxf patlist1 target + atf_check -o file:spacelines grep -Fxvf patlist1 target_spacelines +} + atf_test_case excessive_matches excessive_matches_head() { @@ -551,6 +605,12 @@ grep_nomatch_flags_head() grep_nomatch_flags_body() { + grep_type + + if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "this test does not pass with GNU grep in base" + fi + printf "A\nB\nC\n" > test1 atf_check -o inline:"1\n" grep -c -C 1 -e "B" test1 @@ -563,7 +623,7 @@ grep_nomatch_flags_body() atf_check -o inline:"test1\n" grep -l -A 1 -e "B" test1 atf_check -o inline:"test1\n" grep -l -C 1 -e "B" test1 - atf_check -s exit:1 -o inline:"test1\n" grep -L -e "D" test1 + atf_check -o inline:"test1\n" grep -L -e "D" test1 atf_check -o empty grep -q -e "B" test1 atf_check -o empty grep -q -B 1 -e "B" test1 @@ -646,28 +706,6 @@ mmap_body() atf_check -s exit:1 grep --mmap -e "Z" test1 } -atf_test_case mmap_eof_not_eol -mmap_eof_not_eol_head() -{ - atf_set "descr" "Check --mmap flag handling of encountering EOF without EOL (PR 165471, 219402)" -} -mmap_eof_not_eol_body() -{ - grep_type - if [ $? -eq $GREP_TYPE_GNU ]; then - atf_expect_fail "gnu grep from ports has no --mmap option" - fi - - printf "ABC" > test1 - jot -b " " -s "" 4096 >> test2 - - atf_check -s exit:0 -o inline:"B\n" grep --mmap -oe "B" test1 - # Dependency on jemalloc(3) to detect buffer overflow, otherwise this - # unreliably produces a SIGSEGV or SIGBUS - atf_check -s exit:0 -o not-empty \ - env MALLOC_CONF="redzone:true" grep --mmap -e " " test2 -} - atf_test_case matchall matchall_head() { @@ -738,6 +776,38 @@ fgrep_oflag_body() atf_check -s exit:1 grep -Fo "ghix" test1 atf_check -s exit:1 grep -Fo "abcdefghiklmnopqrstuvwxyz" test1 } + +atf_test_case cflag +cflag_head() +{ + atf_set "descr" "Check proper handling of -c" +} +cflag_body() +{ + printf "a\nb\nc\n" > test1 + + atf_check -o inline:"1\n" grep -Ec "a" test1 + atf_check -o inline:"2\n" grep -Ec "a|b" test1 + atf_check -o inline:"3\n" grep -Ec "a|b|c" test1 + + atf_check -o inline:"test1:2\n" grep -EHc "a|b" test1 +} + +atf_test_case mflag +mflag_head() +{ + atf_set "descr" "Check proper handling of -m" +} +mflag_body() +{ + printf "a\nb\nc\nd\ne\nf\n" > test1 + + atf_check -o inline:"1\n" grep -m 1 -Ec "a" test1 + atf_check -o inline:"2\n" grep -m 2 -Ec "a|b" test1 + atf_check -o inline:"3\n" grep -m 3 -Ec "a|b|c|f" test1 + + atf_check -o inline:"test1:2\n" grep -m 2 -EHc "a|b|e|f" test1 +} # End FreeBSD atf_init_test_cases() @@ -767,6 +837,8 @@ atf_init_test_cases() atf_add_test_case egrep_empty_invalid atf_add_test_case zerolen atf_add_test_case wflag_emptypat + atf_add_test_case xflag_emptypat + atf_add_test_case xflag_emptypat_plus atf_add_test_case excessive_matches atf_add_test_case wv_combo_break atf_add_test_case fgrep_sanity @@ -777,10 +849,11 @@ atf_init_test_cases() atf_add_test_case binary_flags atf_add_test_case badcontext atf_add_test_case mmap - atf_add_test_case mmap_eof_not_eol atf_add_test_case matchall atf_add_test_case fgrep_multipattern atf_add_test_case fgrep_icase atf_add_test_case fgrep_oflag + atf_add_test_case cflag + atf_add_test_case mflag # End FreeBSD } Modified: stable/11/usr.bin/grep/file.c ============================================================================== --- stable/11/usr.bin/grep/file.c Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/file.c Mon Nov 11 19:54:08 2019 (r354628) @@ -86,6 +86,9 @@ static inline int grep_refill(struct file *f) { ssize_t nr; +#ifndef WITHOUT_LZMA + lzma_ret lzmaret; +#endif if (filebehave == FILE_MMAP) return (0); @@ -93,41 +96,52 @@ grep_refill(struct file *f) bufpos = buffer; bufrem = 0; - if (filebehave == FILE_GZIP) { + switch (filebehave) { + case FILE_GZIP: nr = gzread(gzbufdesc, buffer, MAXBUFSIZ); + break; #ifndef WITHOUT_BZIP2 - } else if (filebehave == FILE_BZIP && bzbufdesc != NULL) { - int bzerr; + case FILE_BZIP: + if (bzbufdesc != NULL) { + int bzerr; - nr = BZ2_bzRead(&bzerr, bzbufdesc, buffer, MAXBUFSIZ); - switch (bzerr) { - case BZ_OK: - case BZ_STREAM_END: - /* No problem, nr will be okay */ - break; - case BZ_DATA_ERROR_MAGIC: + nr = BZ2_bzRead(&bzerr, bzbufdesc, buffer, MAXBUFSIZ); + switch (bzerr) { + case BZ_OK: + case BZ_STREAM_END: + /* No problem, nr will be okay */ + break; + case BZ_DATA_ERROR_MAGIC: + /* + * As opposed to gzread(), which simply returns the + * plain file data, if it is not in the correct + * compressed format, BZ2_bzRead() instead aborts. + * + * So, just restart at the beginning of the file again, + * and use plain reads from now on. + */ + BZ2_bzReadClose(&bzerr, bzbufdesc); + bzbufdesc = NULL; + if (lseek(f->fd, 0, SEEK_SET) == -1) + return (-1); + nr = read(f->fd, buffer, MAXBUFSIZ); + break; + default: + /* Make sure we exit with an error */ + nr = -1; + } + } else /* - * As opposed to gzread(), which simply returns the - * plain file data, if it is not in the correct - * compressed format, BZ2_bzRead() instead aborts. - * - * So, just restart at the beginning of the file again, - * and use plain reads from now on. + * Also an error case; we should never have a scenario + * where we have an open file but no bzip descriptor + * at this point. See: grep_open */ - BZ2_bzReadClose(&bzerr, bzbufdesc); - bzbufdesc = NULL; - if (lseek(f->fd, 0, SEEK_SET) == -1) - return (-1); - nr = read(f->fd, buffer, MAXBUFSIZ); - break; - default: - /* Make sure we exit with an error */ nr = -1; - } + break; #endif #ifndef WITHOUT_LZMA - } else if ((filebehave == FILE_XZ) || (filebehave == FILE_LZMA)) { - lzma_ret ret; + case FILE_XZ: + case FILE_LZMA: lstrm.next_out = buffer; do { @@ -143,23 +157,23 @@ grep_refill(struct file *f) lstrm.avail_in = nr; } - ret = lzma_code(&lstrm, laction); + lzmaret = lzma_code(&lstrm, laction); - if (ret != LZMA_OK && ret != LZMA_STREAM_END) + if (lzmaret != LZMA_OK && lzmaret != LZMA_STREAM_END) return (-1); - if (lstrm.avail_out == 0 || ret == LZMA_STREAM_END) { + if (lstrm.avail_out == 0 || lzmaret == LZMA_STREAM_END) { bufrem = MAXBUFSIZ - lstrm.avail_out; lstrm.next_out = buffer; lstrm.avail_out = MAXBUFSIZ; } - } while (bufrem == 0 && ret != LZMA_STREAM_END); + } while (bufrem == 0 && lzmaret != LZMA_STREAM_END); return (0); -#endif /* WIHTOUT_LZMA */ - } else +#endif /* WITHOUT_LZMA */ + default: nr = read(f->fd, buffer, MAXBUFSIZ); - + } if (nr < 0) return (-1); @@ -180,7 +194,7 @@ grep_lnbufgrow(size_t newlen) } char * -grep_fgetln(struct file *f, size_t *lenp) +grep_fgetln(struct file *f, struct parsec *pc) { unsigned char *p; char *ret; @@ -194,7 +208,7 @@ grep_fgetln(struct file *f, size_t *lenp) if (bufrem == 0) { /* Return zero length to indicate EOF */ - *lenp = 0; + pc->ln.len= 0; return (bufpos); } @@ -205,7 +219,7 @@ grep_fgetln(struct file *f, size_t *lenp) len = p - bufpos; bufrem -= len; bufpos = p; - *lenp = len; + pc->ln.len = len; return (ret); } @@ -240,11 +254,11 @@ grep_fgetln(struct file *f, size_t *lenp) bufpos = p; break; } - *lenp = len; + pc->ln.len = len; return (lnbuf); error: - *lenp = 0; + pc->ln.len = 0; return (NULL); } @@ -255,6 +269,9 @@ struct file * grep_open(const char *path) { struct file *f; +#ifndef WITHOUT_LZMA + lzma_ret lzmaret; +#endif f = grep_malloc(sizeof *f); memset(f, 0, sizeof *f); @@ -292,32 +309,36 @@ grep_open(const char *path) if ((buffer == NULL) || (buffer == MAP_FAILED)) buffer = grep_malloc(MAXBUFSIZ); - if (filebehave == FILE_GZIP && - (gzbufdesc = gzdopen(f->fd, "r")) == NULL) - goto error2; - + switch (filebehave) { + case FILE_GZIP: + if ((gzbufdesc = gzdopen(f->fd, "r")) == NULL) + goto error2; + break; #ifndef WITHOUT_BZIP2 - if (filebehave == FILE_BZIP && - (bzbufdesc = BZ2_bzdopen(f->fd, "r")) == NULL) - goto error2; + case FILE_BZIP: + if ((bzbufdesc = BZ2_bzdopen(f->fd, "r")) == NULL) + goto error2; + break; #endif #ifndef WITHOUT_LZMA - else if ((filebehave == FILE_XZ) || (filebehave == FILE_LZMA)) { - lzma_ret ret; + case FILE_XZ: + case FILE_LZMA: - ret = (filebehave == FILE_XZ) ? - lzma_stream_decoder(&lstrm, UINT64_MAX, - LZMA_CONCATENATED) : - lzma_alone_decoder(&lstrm, UINT64_MAX); + if (filebehave == FILE_XZ) + lzmaret = lzma_stream_decoder(&lstrm, UINT64_MAX, + LZMA_CONCATENATED); + else + lzmaret = lzma_alone_decoder(&lstrm, UINT64_MAX); - if (ret != LZMA_OK) + if (lzmaret != LZMA_OK) goto error2; lstrm.avail_in = 0; lstrm.avail_out = MAXBUFSIZ; laction = LZMA_RUN; - } + break; #endif + } /* Fill read buffer, also catches errors early */ if (bufrem == 0 && grep_refill(f) != 0) @@ -326,7 +347,7 @@ grep_open(const char *path) /* Check for binary stuff, if necessary */ if (binbehave != BINFILE_TEXT && fileeol != '\0' && memchr(bufpos, '\0', bufrem) != NULL) - f->binary = true; + f->binary = true; return (f); Modified: stable/11/usr.bin/grep/grep.1 ============================================================================== --- stable/11/usr.bin/grep/grep.1 Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/grep.1 Mon Nov 11 19:54:08 2019 (r354628) @@ -30,7 +30,7 @@ .\" .\" @(#)grep.1 8.3 (Berkeley) 4/18/94 .\" -.Dd April 17, 2017 +.Dd May 7, 2018 .Dt GREP 1 .Os .Sh NAME @@ -410,6 +410,13 @@ and block buffered otherwise. .El .Pp If no file arguments are specified, the standard input is used. +Additionally, +.Dq - +may be used in place of a file name, anywhere that a file name is accepted, to +read from standard input. +This includes both +.Fl f +and file arguments. .Sh EXIT STATUS The .Nm grep Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/grep.c Mon Nov 11 19:54:08 2019 (r354628) @@ -239,20 +239,9 @@ static void add_pattern(char *pat, size_t len) { - /* Do not add further pattern is we already match everything */ - if (matchall) - return; - /* Check if we can do a shortcut */ if (len == 0) { matchall = true; - for (unsigned int i = 0; i < patterns; i++) { - free(pattern[i].pat); - } - pattern = grep_realloc(pattern, sizeof(struct pat)); - pattern[0].pat = NULL; - pattern[0].len = 0; - patterns = 1; return; } /* Increase size if necessary */ @@ -319,7 +308,9 @@ read_patterns(const char *fn) size_t len; ssize_t rlen; - if ((f = fopen(fn, "r")) == NULL) + if (strcmp(fn, "-") == 0) + f = stdin; + else if ((f = fopen(fn, "r")) == NULL) err(2, "%s", fn); if ((fstat(fileno(f), &st) == -1) || (S_ISDIR(st.st_mode))) { fclose(f); @@ -336,7 +327,8 @@ read_patterns(const char *fn) free(line); if (ferror(f)) err(2, "%s", fn); - fclose(f); + if (strcmp(fn, "-") != 0) + fclose(f); } static inline const char * @@ -357,6 +349,7 @@ main(int argc, char *argv[]) long long l; unsigned int aargc, eargc, i; int c, lastc, needpattern, newarg, prevoptind; + bool matched; setlocale(LC_ALL, ""); @@ -701,7 +694,7 @@ main(int argc, char *argv[]) aargv += optind; /* Empty pattern file matches nothing */ - if (!needpattern && (patterns == 0)) + if (!needpattern && (patterns == 0) && !matchall) exit(1); /* Fail if we don't have any pattern */ @@ -751,11 +744,10 @@ main(int argc, char *argv[]) #endif r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); - /* Don't process any patterns if we have a blank one */ #ifdef WITH_INTERNAL_NOSPEC - if (!matchall && grepbehave != GREP_FIXED) { + if (grepbehave != GREP_FIXED) { #else - if (!matchall) { + { #endif /* Check if cheating is allowed (always is for fgrep). */ for (i = 0; i < patterns; ++i) { @@ -787,12 +779,13 @@ main(int argc, char *argv[]) exit(!procfile("-")); if (dirbehave == DIR_RECURSE) - c = grep_tree(aargv); + matched = grep_tree(aargv); else - for (c = 0; aargc--; ++aargv) { + for (matched = false; aargc--; ++aargv) { if ((finclude || fexclude) && !file_matching(*aargv)) continue; - c+= procfile(*aargv); + if (procfile(*aargv)) + matched = true; } #ifndef WITHOUT_NLS @@ -801,5 +794,8 @@ main(int argc, char *argv[]) /* Find out the correct return value according to the results and the command line option. */ - exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); + if (Lflag) + matched = !matched; + + exit(matched ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); } Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/grep.h Mon Nov 11 19:54:08 2019 (r354628) @@ -114,6 +114,21 @@ struct epat { int mode; }; +/* + * Parsing context; used to hold things like matches made and + * other useful bits + */ +struct parsec { + regmatch_t matches[MAX_MATCHES]; /* Matches made */ + /* XXX TODO: This should be a chunk, not a line */ + struct str ln; /* Current line */ + size_t lnstart; /* Position in line */ + size_t matchidx; /* Latest match index */ + int printed; /* Metadata printed? */ + bool binary; /* Binary file? */ + bool cntlines; /* Count lines? */ +}; + /* Flags passed to regcomp() and regexec() */ extern int cflags, eflags; @@ -145,8 +160,8 @@ extern char re_error[RE_ERROR_BUF + 1]; /* Seems big /* util.c */ bool file_matching(const char *fname); -int procfile(const char *fn); -int grep_tree(char **argv); +bool procfile(const char *fn); +bool grep_tree(char **argv); void *grep_malloc(size_t size); void *grep_calloc(size_t nmemb, size_t size); void *grep_realloc(void *ptr, size_t size); @@ -161,4 +176,4 @@ void clearqueue(void); /* file.c */ void grep_close(struct file *f); struct file *grep_open(const char *path); -char *grep_fgetln(struct file *f, size_t *len); +char *grep_fgetln(struct file *f, struct parsec *pc); Modified: stable/11/usr.bin/grep/tests/grep_freebsd_test.sh ============================================================================== --- stable/11/usr.bin/grep/tests/grep_freebsd_test.sh Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/tests/grep_freebsd_test.sh Mon Nov 11 19:54:08 2019 (r354628) @@ -81,8 +81,34 @@ rgrep_body() atf_check -o file:d_grep_r_implied.out rgrep --exclude="*.out" -e "test" "$(atf_get_srcdir)" } +atf_test_case gnuext +gnuext_body() +{ + grep_type + _type=$? + if [ $_type -eq $GREP_TYPE_BSD ]; then + atf_expect_fail "this test requires GNU extensions in regex(3)" + elif [ $_type -eq $GREP_TYPE_GNU_FREEBSD ]; then + atf_expect_fail "\\s and \\S are known to be buggy in base gnugrep" + fi + + atf_check -o save:grep_alnum.out grep -o '[[:alnum:]]' /COPYRIGHT + atf_check -o file:grep_alnum.out grep -o '\w' /COPYRIGHT + + atf_check -o save:grep_nalnum.out grep -o '[^[:alnum:]]' /COPYRIGHT + atf_check -o file:grep_nalnum.out grep -o '\W' /COPYRIGHT + + atf_check -o save:grep_space.out grep -o '[[:space:]]' /COPYRIGHT + atf_check -o file:grep_space.out grep -o '\s' /COPYRIGHT + + atf_check -o save:grep_nspace.out grep -o '[^[:space:]]' /COPYRIGHT + atf_check -o file:grep_nspace.out grep -o '\S' /COPYRIGHT + +} + atf_init_test_cases() { atf_add_test_case grep_r_implied atf_add_test_case rgrep + atf_add_test_case gnuext } Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Mon Nov 11 19:06:04 2019 (r354627) +++ stable/11/usr.bin/grep/util.c Mon Nov 11 19:54:08 2019 (r354628) @@ -60,23 +60,24 @@ __FBSDID("$FreeBSD$"); static bool first_match = true; /* - * Parsing context; used to hold things like matches made and - * other useful bits + * Match printing context */ -struct parsec { - regmatch_t matches[MAX_MATCHES]; /* Matches made */ - struct str ln; /* Current line */ - size_t lnstart; /* Position in line */ - size_t matchidx; /* Latest match index */ - int printed; /* Metadata printed? */ - bool binary; /* Binary file? */ +struct mprintc { + long long tail; /* Number of trailing lines to record */ + int last_outed; /* Number of lines since last output */ + bool doctx; /* Printing context? */ + bool printmatch; /* Printing matches? */ + bool same_file; /* Same file as previously printed? */ }; +static void procmatch_match(struct mprintc *mc, struct parsec *pc); +static void procmatch_nomatch(struct mprintc *mc, struct parsec *pc); +static bool procmatches(struct mprintc *mc, struct parsec *pc, bool matched); #ifdef WITH_INTERNAL_NOSPEC static int litexec(const struct pat *pat, const char *string, size_t nmatch, regmatch_t pmatch[]); #endif -static int procline(struct parsec *pc); +static bool procline(struct parsec *pc); static void printline(struct parsec *pc, int sep); static void printline_metadata(struct str *line, int sep); @@ -94,13 +95,12 @@ file_matching(const char *fname) for (unsigned int i = 0; i < fpatterns; ++i) { if (fnmatch(fpattern[i].pat, fname, 0) == 0 || - fnmatch(fpattern[i].pat, fname_base, 0) == 0) { - if (fpattern[i].mode == EXCL_PAT) { - ret = false; - break; - } else - ret = true; - } + fnmatch(fpattern[i].pat, fname_base, 0) == 0) + /* + * The last pattern matched wins exclusion/inclusion + * rights, so we can't reasonably bail out early here. + */ + ret = (fpattern[i].mode != EXCL_PAT); } free(fname_buf); return (ret); @@ -114,13 +114,12 @@ dir_matching(const char *dname) ret = dinclude ? false : true; for (unsigned int i = 0; i < dpatterns; ++i) { - if (dname != NULL && - fnmatch(dpattern[i].pat, dname, 0) == 0) { - if (dpattern[i].mode == EXCL_PAT) - return (false); - else - ret = true; - } + if (dname != NULL && fnmatch(dpattern[i].pat, dname, 0) == 0) + /* + * The last pattern matched wins exclusion/inclusion + * rights, so we can't reasonably bail out early here. + */ + ret = (dpattern[i].mode != EXCL_PAT); } return (ret); } @@ -129,17 +128,18 @@ dir_matching(const char *dname) * Processes a directory when a recursive search is performed with * the -R option. Each appropriate file is passed to procfile(). */ -int +bool grep_tree(char **argv) { FTS *fts; FTSENT *p; - int c, fts_flags; - bool ok; + int fts_flags; + bool matched, ok; const char *wd[] = { ".", NULL }; - c = fts_flags = 0; + matched = false; + /* This switch effectively initializes 'fts_flags' */ switch(linkbehave) { case LINK_EXPLICIT: fts_flags = FTS_COMFOLLOW; @@ -149,7 +149,6 @@ grep_tree(char **argv) break; default: fts_flags = FTS_LOGICAL; - } fts_flags |= FTS_NOSTAT | FTS_NOCHDIR; @@ -178,7 +177,7 @@ grep_tree(char **argv) case FTS_DC: /* Print a warning for recursive directory loop */ warnx("warning: %s: recursive directory loop", - p->fts_path); + p->fts_path); break; default: /* Check for file exclusion/inclusion */ @@ -186,44 +185,122 @@ grep_tree(char **argv) if (fexclude || finclude) ok &= file_matching(p->fts_path); - if (ok) - c += procfile(p->fts_path); + if (ok && procfile(p->fts_path)) + matched = true; break; } } fts_close(fts); - return (c); + return (matched); } +static void +procmatch_match(struct mprintc *mc, struct parsec *pc) +{ + + if (mc->doctx) { + if (!first_match && (!mc->same_file || mc->last_outed > 0)) + printf("--\n"); + if (Bflag > 0) + printqueue(); + mc->tail = Aflag; + } + + /* Print the matching line, but only if not quiet/binary */ + if (mc->printmatch) { + printline(pc, ':'); + while (pc->matchidx >= MAX_MATCHES) { + /* Reset matchidx and try again */ + pc->matchidx = 0; + if (procline(pc) == !vflag) + printline(pc, ':'); + else + break; + } + first_match = false; + mc->same_file = true; + mc->last_outed = 0; + } +} + +static void +procmatch_nomatch(struct mprintc *mc, struct parsec *pc) +{ + + /* Deal with any -A context as needed */ + if (mc->tail > 0) { + grep_printline(&pc->ln, '-'); + mc->tail--; + if (Bflag > 0) + clearqueue(); + } else if (Bflag == 0 || (Bflag > 0 && enqueue(&pc->ln))) + /* + * Enqueue non-matching lines for -B context. If we're not + * actually doing -B context or if the enqueue resulted in a + * line being rotated out, then go ahead and increment + * last_outed to signify a gap between context/match. + */ + ++mc->last_outed; +} + /* + * Process any matches in the current parsing context, return a boolean + * indicating whether we should halt any further processing or not. 'true' to + * continue processing, 'false' to halt. + */ +static bool +procmatches(struct mprintc *mc, struct parsec *pc, bool matched) +{ + + /* + * XXX TODO: This should loop over pc->matches and handle things on a + * line-by-line basis, setting up a `struct str` as needed. + */ + /* Deal with any -B context or context separators */ + if (matched) { + procmatch_match(mc, pc); + + /* Count the matches if we have a match limit */ + if (mflag) { + /* XXX TODO: Decrement by number of matched lines */ + mcount -= 1; + if (mcount <= 0) + return (false); + } + } else if (mc->doctx) + procmatch_nomatch(mc, pc); + + return (true); +} + +/* * Opens a file and processes it. Each file is processed line-by-line * passing the lines to procline(). */ -int +bool procfile(const char *fn) { struct parsec pc; - long long tail; + struct mprintc mc; struct file *f; struct stat sb; - struct str *ln; mode_t s; - int c, last_outed, t; - bool doctx, printmatch, same_file; + int lines; + bool line_matched; if (strcmp(fn, "-") == 0) { fn = label != NULL ? label : getstr(1); f = grep_open(NULL); } else { - if (!stat(fn, &sb)) { + if (stat(fn, &sb) == 0) { /* Check if we need to process the file */ s = sb.st_mode & S_IFMT; - if (s == S_IFDIR && dirbehave == DIR_SKIP) - return (0); - if ((s == S_IFIFO || s == S_IFCHR || s == S_IFBLK - || s == S_IFSOCK) && devbehave == DEV_SKIP) - return (0); + if (dirbehave == DIR_SKIP && s == S_IFDIR) + return (false); + if (devbehave == DEV_SKIP && (s == S_IFIFO || + s == S_IFCHR || s == S_IFBLK || s == S_IFSOCK)) + return (false); } f = grep_open(fn); } @@ -231,39 +308,41 @@ procfile(const char *fn) file_err = true; if (!sflag) warn("%s", fn); - return (0); + return (false); } - /* Convenience */ - ln = &pc.ln; - pc.ln.file = grep_malloc(strlen(fn) + 1); - strcpy(pc.ln.file, fn); + pc.ln.file = grep_strdup(fn); pc.ln.line_no = 0; pc.ln.len = 0; pc.ln.boff = 0; pc.ln.off = -1; pc.binary = f->binary; - pc.printed = 0; - tail = 0; - last_outed = 0; - same_file = false; - doctx = false; - printmatch = true; + pc.cntlines = false; + memset(&mc, 0, sizeof(mc)); + mc.printmatch = true; if ((pc.binary && binbehave == BINFILE_BIN) || cflag || qflag || lflag || Lflag) - printmatch = false; - if (printmatch && (Aflag != 0 || Bflag != 0)) - doctx = true; + mc.printmatch = false; + if (mc.printmatch && (Aflag != 0 || Bflag != 0)) + mc.doctx = true; + if (mc.printmatch && (Aflag != 0 || Bflag != 0 || mflag || nflag)) + pc.cntlines = true; mcount = mlimit; - for (c = 0; c == 0 || !(lflag || qflag); ) { + for (lines = 0; lines == 0 || !(lflag || qflag); ) { + /* + * XXX TODO: We need to revisit this in a chunking world. We're + * not going to be doing per-line statistics because of the + * overhead involved. procmatches can figure that stuff out as + * needed. */ /* Reset per-line statistics */ pc.printed = 0; pc.matchidx = 0; pc.lnstart = 0; pc.ln.boff = 0; pc.ln.off += pc.ln.len + 1; - if ((pc.ln.dat = grep_fgetln(f, &pc.ln.len)) == NULL || + /* XXX TODO: Grab a chunk */ + if ((pc.ln.dat = grep_fgetln(f, &pc)) == NULL || pc.ln.len == 0) break; @@ -279,59 +358,13 @@ procfile(const char *fn) return (0); } - if ((t = procline(&pc)) == 0) - ++c; + line_matched = procline(&pc) == !vflag; + if (line_matched) + ++lines; - /* Deal with any -B context or context separators */ - if (t == 0 && doctx) { - if (!first_match && (!same_file || last_outed > 0)) - printf("--\n"); - if (Bflag > 0) - printqueue(); - tail = Aflag; - } - /* Print the matching line, but only if not quiet/binary */ - if (t == 0 && printmatch) { - printline(&pc, ':'); - while (pc.matchidx >= MAX_MATCHES) { - /* Reset matchidx and try again */ - pc.matchidx = 0; - if (procline(&pc) == 0) - printline(&pc, ':'); - else - break; - } - first_match = false; - same_file = true; - last_outed = 0; - } - if (t != 0 && doctx) { - /* Deal with any -A context */ - if (tail > 0) { - grep_printline(&pc.ln, '-'); - tail--; - if (Bflag > 0) - clearqueue(); - } else { - /* - * Enqueue non-matching lines for -B context. - * If we're not actually doing -B context or if - * the enqueue resulted in a line being rotated - * out, then go ahead and increment last_outed - * to signify a gap between context/match. - */ - if (Bflag == 0 || (Bflag > 0 && enqueue(ln))) - ++last_outed; - } - } - - /* Count the matches if we have a match limit */ - if (t == 0 && mflag) { - --mcount; - if (mflag && mcount <= 0) - break; - } - + /* Halt processing if we hit our match limit */ + if (!procmatches(&mc, &pc, line_matched)) + break; } if (Bflag > 0) clearqueue(); @@ -340,19 +373,19 @@ procfile(const char *fn) if (cflag) { if (!hflag) printf("%s:", pc.ln.file); - printf("%u\n", c); + printf("%u\n", lines); } *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-stable@freebsd.org Tue Nov 12 09:54:51 2019 Return-Path: Delivered-To: svn-src-stable@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 0DC0A17FEE3; Tue, 12 Nov 2019 09:54:51 +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 47C34p6ZWSz4LKB; Tue, 12 Nov 2019 09:54:50 +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 C4B9F25F1A; Tue, 12 Nov 2019 09:54:50 +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 xAC9so9w096204; Tue, 12 Nov 2019 09:54:50 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAC9smaX096195; Tue, 12 Nov 2019 09:54:48 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911120954.xAC9smaX096195@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 12 Nov 2019 09:54: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: r354634 - in stable/12/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys cddl/contrib/opensolaris/common/atomic/aarch64 cddl/contrib/opensolaris/common/atomic/amd64 cddl/con... X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys: cddl/compat/opensolaris/kern cddl/compat/opensolaris/sys cddl/contrib/opensolaris/common/atomic/aarch64 cddl/contrib/opensolaris/common/atomic/amd64 cddl/contrib/opensolaris/common/a... X-SVN-Commit-Revision: 354634 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 09:54:51 -0000 Author: avg Date: Tue Nov 12 09:54:48 2019 New Revision: 354634 URL: https://svnweb.freebsd.org/changeset/base/354634 Log: MFC r353381: emulate illumos membar_producer with atomic_thread_fence_rel Deleted: stable/12/sys/cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S stable/12/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S 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 stable/12/sys/conf/files.amd64 stable/12/sys/conf/files.arm stable/12/sys/conf/files.arm64 stable/12/sys/conf/files.powerpc stable/12/sys/conf/files.riscv stable/12/sys/conf/files.sparc64 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 Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/cddl/compat/opensolaris/kern/opensolaris_atomic.c Tue Nov 12 09:54:48 2019 (r354634) @@ -120,9 +120,3 @@ atomic_cas_64(volatile uint64_t *target, uint64_t cmp, return (oldval); } #endif - -void -membar_producer(void) -{ - /* nothing */ -} Modified: stable/12/sys/cddl/compat/opensolaris/sys/atomic.h ============================================================================== --- stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/cddl/compat/opensolaris/sys/atomic.h Tue Nov 12 09:54:48 2019 (r354634) @@ -52,7 +52,7 @@ extern uint64_t atomic_cas_64(volatile uint64_t *targe uint64_t newval); #endif -extern void membar_producer(void); +#define membar_producer atomic_thread_fence_rel static __inline uint32_t atomic_add_32_nv(volatile uint32_t *target, int32_t delta) 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 Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Tue Nov 12 09:54:48 2019 (r354634) @@ -131,9 +131,3 @@ popl %esi ret SET_SIZE(atomic_load_64) - - ENTRY(membar_producer) - lock - xorl $0, (%esp) - ret - SET_SIZE(membar_producer) Modified: stable/12/sys/conf/files.amd64 ============================================================================== --- stable/12/sys/conf/files.amd64 Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.amd64 Tue Nov 12 09:54:48 2019 (r354634) @@ -162,7 +162,6 @@ amd64/amd64/vm_machdep.c standard amd64/cloudabi32/cloudabi32_sysvec.c optional compat_cloudabi32 amd64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64 amd64/pci/pci_cfgreg.c optional pci -cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S optional zfs | dtrace compile-with "${ZFS_S}" cddl/dev/dtrace/amd64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/amd64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/x86/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" Modified: stable/12/sys/conf/files.arm ============================================================================== --- stable/12/sys/conf/files.arm Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.arm Tue Nov 12 09:54:48 2019 (r354634) @@ -94,7 +94,7 @@ board_id.h standard \ compile-with "${AWK} -f $S/arm/conf/genboardid.awk $S/arm/conf/mach-types > board_id.h" \ no-obj no-implicit-rule before-depend \ clean "board_id.h" -cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs | dtrace compile-with "${CDDL_C}" +cddl/compat/opensolaris/kern/opensolaris_atomic.c optional !armv7 !armv6 zfs | !armv7 !armv6 dtrace compile-with "${CDDL_C}" cddl/dev/dtrace/arm/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/arm/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/arm/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" Modified: stable/12/sys/conf/files.arm64 ============================================================================== --- stable/12/sys/conf/files.arm64 Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.arm64 Tue Nov 12 09:54:48 2019 (r354634) @@ -266,7 +266,6 @@ libkern/flsll.c standard libkern/memcmp.c standard libkern/memset.c standard libkern/arm64/crc32c_armv8.S standard -cddl/contrib/opensolaris/common/atomic/aarch64/opensolaris_atomic.S optional zfs | dtrace compile-with "${CDDL_C}" cddl/dev/dtrace/aarch64/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/aarch64/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/aarch64/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" Modified: stable/12/sys/conf/files.powerpc ============================================================================== --- stable/12/sys/conf/files.powerpc Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.powerpc Tue Nov 12 09:54:48 2019 (r354634) @@ -16,7 +16,6 @@ font.h optional sc \ # # There is only an asm version on ppc64. cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs powerpc | dtrace powerpc | zfs powerpcspe | dtrace powerpcspe compile-with "${ZFS_C}" -cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S optional zfs powerpc64 | dtrace powerpc64 compile-with "${ZFS_S}" cddl/dev/dtrace/powerpc/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/powerpc/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/powerpc/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" Modified: stable/12/sys/conf/files.riscv ============================================================================== --- stable/12/sys/conf/files.riscv Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.riscv Tue Nov 12 09:54:48 2019 (r354634) @@ -1,5 +1,4 @@ # $FreeBSD$ -cddl/compat/opensolaris/kern/opensolaris_atomic.c optional zfs | dtrace compile-with "${CDDL_C}" cddl/dev/dtrace/riscv/dtrace_asm.S optional dtrace compile-with "${DTRACE_S}" cddl/dev/dtrace/riscv/dtrace_subr.c optional dtrace compile-with "${DTRACE_C}" cddl/dev/fbt/riscv/fbt_isa.c optional dtrace_fbt | dtraceall compile-with "${FBT_C}" Modified: stable/12/sys/conf/files.sparc64 ============================================================================== --- stable/12/sys/conf/files.sparc64 Tue Nov 12 01:03:08 2019 (r354633) +++ stable/12/sys/conf/files.sparc64 Tue Nov 12 09:54:48 2019 (r354634) @@ -22,7 +22,6 @@ ukbdmap.h optional ukbd_dflt_keymap \ no-obj no-implicit-rule before-depend \ clean "ukbdmap.h" # -cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S optional zfs compile-with "${ZFS_S}" crypto/blowfish/bf_enc.c optional crypto | ipsec | ipsec_support crypto/des/des_enc.c optional crypto | ipsec | ipsec_support | netsmb dev/atkbdc/atkbd.c optional atkbd atkbdc From owner-svn-src-stable@freebsd.org Tue Nov 12 10:22:49 2019 Return-Path: Delivered-To: svn-src-stable@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 271541A8DCE; Tue, 12 Nov 2019 10:22:49 +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 47C3j50Cq8z4N31; Tue, 12 Nov 2019 10:22:49 +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 DEB1C26468; Tue, 12 Nov 2019 10:22:48 +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 xACAMmsQ013673; Tue, 12 Nov 2019 10:22:48 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACAMmWW013672; Tue, 12 Nov 2019 10:22:48 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911121022.xACAMmWW013672@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 12 Nov 2019 10:22: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: r354636 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354636 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 10:22:49 -0000 Author: avg Date: Tue Nov 12 10:22:48 2019 New Revision: 354636 URL: https://svnweb.freebsd.org/changeset/base/354636 Log: allow NO_CLEAN builds to work after opensolaris_atomic.S removal in r354634 This is a direct commit modelled after r353408 in head. Modified: stable/12/Makefile.inc1 Modified: stable/12/Makefile.inc1 ============================================================================== --- stable/12/Makefile.inc1 Tue Nov 12 10:02:39 2019 (r354635) +++ stable/12/Makefile.inc1 Tue Nov 12 10:22:48 2019 (r354636) @@ -902,7 +902,7 @@ _sanity_check: .PHONY .MAKE # replacing generated files. Handle these cases here in an ad-hoc fashion. _cleanobj_fast_depend_hack: .PHONY # Syscall stubs rewritten in C and obsolete MD assembly implementations -# Date SVN Rev Syscalls +# Date SVN Rev Syscalls/Changes # 20170624 r320278 fstat fstatat fstatfs getdirentries getfsstat statfs # 20180404 r332048 sigreturn # 20180405 r332080 shmat @@ -970,6 +970,17 @@ _cleanobj_fast_depend_hack: .PHONY echo "Removing stale wpa dependencies"; \ rm -f ${OBJTOP}/usr.sbin/wpa/*/.depend*; \ fi +# 20191112 r354634 removal of opensolaris_atomic.S +.if ${MACHINE} != i386 +.for f in opensolaris_atomic + @if [ -e "${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o" ] && \ + egrep -qw 'opensolaris_atomic\.S' ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.o; then \ + echo "Removing stale dependencies for opensolaris_atomic"; \ + rm -f ${OBJTOP}/cddl/lib/libzpool/.depend.${f}.* \ + ${LIBCOMPAT:D${LIBCOMPAT_OBJTOP}/cddl/lib/libzpool/.depend.${f}.*}; \ + fi +.endfor +.endif _worldtmp: .PHONY @echo From owner-svn-src-stable@freebsd.org Tue Nov 12 14:08:22 2019 Return-Path: Delivered-To: svn-src-stable@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 8B11E1AEA8B; Tue, 12 Nov 2019 14:08: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 47C8jL3Cv1z4bCG; Tue, 12 Nov 2019 14:08:22 +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 521D7C71; Tue, 12 Nov 2019 14:08:22 +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 xACE8MEQ043857; Tue, 12 Nov 2019 14:08:22 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACE8MTp043856; Tue, 12 Nov 2019 14:08:22 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911121408.xACE8MTp043856@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Tue, 12 Nov 2019 14:08: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: r354640 - stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/cddl/contrib/opensolaris/cmd/zpool X-SVN-Commit-Revision: 354640 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 14:08:22 -0000 Author: avg Date: Tue Nov 12 14:08:21 2019 New Revision: 354640 URL: https://svnweb.freebsd.org/changeset/base/354640 Log: MFC r354437: fix zpool list property names Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Directory Properties: stable/12/ (props changed) Modified: stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 ============================================================================== --- stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Tue Nov 12 13:57:17 2019 (r354639) +++ stable/12/cddl/contrib/opensolaris/cmd/zpool/zpool.8 Tue Nov 12 14:08:21 2019 (r354640) @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 20, 2019 +.Dd November 7, 2019 .Dt ZPOOL 8 .Os .Sh NAME @@ -599,8 +599,8 @@ Each pool has several properties associated with it. S read-only statistics while others are configurable and change the behavior of the pool. The following are read-only properties: .Bl -tag -width "dedupratio" -.It Sy alloc -Amount of storage space within the pool that has been physically allocated. +.It Sy allocated +Amount of storage space used within the pool. .It Sy capacity Percentage of pool space used. This property can also be referred to by its shortened column name, "cap". @@ -650,8 +650,6 @@ Information about unsupported features that are enable See .Xr zpool-features 7 for details. -.It Sy used -Amount of storage space used within the pool. .El .Pp The space usage properties report actual physical space available to the @@ -1573,8 +1571,8 @@ Comma-separated list of properties to display. See the section for a list of valid properties. The default list is .Sy name , .Sy size , -.Sy used , -.Sy available , +.Sy allocated , +.Sy free , .Sy checkpoint , .Sy expandsize , .Sy fragmentation , From owner-svn-src-stable@freebsd.org Tue Nov 12 15:32:16 2019 Return-Path: Delivered-To: svn-src-stable@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 C01D21B0E2A; Tue, 12 Nov 2019 15:32:16 +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 47CBZ84l5qz3C5S; Tue, 12 Nov 2019 15:32:16 +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 85D231CAB; Tue, 12 Nov 2019 15:32:16 +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 xACFWGbF097497; Tue, 12 Nov 2019 15:32:16 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACFWGHZ097496; Tue, 12 Nov 2019 15:32:16 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911121532.xACFWGHZ097496@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 12 Nov 2019 15:32: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: r354641 - stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-12 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354641 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 15:32:16 -0000 Author: mav Date: Tue Nov 12 15:32:16 2019 New Revision: 354641 URL: https://svnweb.freebsd.org/changeset/base/354641 Log: MFC r354360: Add vfs.zfs.zio.taskq_batch_pct tunable. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Nov 12 14:08:21 2019 (r354640) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Nov 12 15:32:16 2019 (r354641) @@ -241,6 +241,10 @@ uint64_t zfs_max_missing_tvds_cachefile = SPA_DVAS_PER uint64_t zfs_max_missing_tvds_scan = 0; +SYSCTL_DECL(_vfs_zfs_zio); +SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, taskq_batch_pct, CTLFLAG_RDTUN, + &zio_taskq_batch_pct, 0, + "Percentage of CPUs to run an IO worker thread"); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_load_print_vdev_tree, CTLFLAG_RWTUN, &spa_load_print_vdev_tree, 0, "print out vdev tree during pool import"); From owner-svn-src-stable@freebsd.org Tue Nov 12 15:34:20 2019 Return-Path: Delivered-To: svn-src-stable@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 0819F1B0EFC; Tue, 12 Nov 2019 15:34:20 +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 47CBcW6SnGz3CKb; Tue, 12 Nov 2019 15:34:19 +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 C11D61CCB; Tue, 12 Nov 2019 15:34:19 +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 xACFYJsE097764; Tue, 12 Nov 2019 15:34:19 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACFYJJ6097763; Tue, 12 Nov 2019 15:34:19 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201911121534.xACFYJJ6097763@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 12 Nov 2019 15:34:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354642 - stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: mav X-SVN-Commit-Paths: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs X-SVN-Commit-Revision: 354642 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 15:34:20 -0000 Author: mav Date: Tue Nov 12 15:34:19 2019 New Revision: 354642 URL: https://svnweb.freebsd.org/changeset/base/354642 Log: MFC r354360: Add vfs.zfs.zio.taskq_batch_pct tunable. Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c ============================================================================== --- stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Nov 12 15:32:16 2019 (r354641) +++ stable/11/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c Tue Nov 12 15:34:19 2019 (r354642) @@ -241,6 +241,10 @@ uint64_t zfs_max_missing_tvds_cachefile = SPA_DVAS_PER uint64_t zfs_max_missing_tvds_scan = 0; +SYSCTL_DECL(_vfs_zfs_zio); +SYSCTL_INT(_vfs_zfs_zio, OID_AUTO, taskq_batch_pct, CTLFLAG_RDTUN, + &zio_taskq_batch_pct, 0, + "Percentage of CPUs to run an IO worker thread"); SYSCTL_INT(_vfs_zfs, OID_AUTO, spa_load_print_vdev_tree, CTLFLAG_RWTUN, &spa_load_print_vdev_tree, 0, "print out vdev tree during pool import"); From owner-svn-src-stable@freebsd.org Tue Nov 12 18:03:27 2019 Return-Path: Delivered-To: svn-src-stable@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 EC0921B40EE; Tue, 12 Nov 2019 18:03:27 +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 47CFwb5xVmz3M6r; Tue, 12 Nov 2019 18:03:27 +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 B000739EA; Tue, 12 Nov 2019 18:03:27 +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 xACI3Rtd086518; Tue, 12 Nov 2019 18:03:27 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACI3QcO086514; Tue, 12 Nov 2019 18:03:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911121803.xACI3QcO086514@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 12 Nov 2019 18:03:26 +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: r354650 - in stable/12/sys: amd64/amd64 amd64/include dev/cpuctl x86/include X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 amd64/include dev/cpuctl x86/include X-SVN-Commit-Revision: 354650 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 18:03:28 -0000 Author: kib Date: Tue Nov 12 18:03:26 2019 New Revision: 354650 URL: https://svnweb.freebsd.org/changeset/base/354650 Log: MFC r354649: Workaround for Intel SKL002/SKL012S errata. Security: CVE-2018-12207 Modified: stable/12/sys/amd64/amd64/pmap.c stable/12/sys/amd64/include/pmap.h stable/12/sys/dev/cpuctl/cpuctl.c stable/12/sys/x86/include/specialreg.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/pmap.c ============================================================================== --- stable/12/sys/amd64/amd64/pmap.c Tue Nov 12 18:01:33 2019 (r354649) +++ stable/12/sys/amd64/amd64/pmap.c Tue Nov 12 18:03:26 2019 (r354650) @@ -1805,6 +1805,51 @@ pmap_page_init(vm_page_t m) m->md.pat_mode = PAT_WRITE_BACK; } +static int pmap_allow_2m_x_ept; +SYSCTL_INT(_vm_pmap, OID_AUTO, allow_2m_x_ept, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + &pmap_allow_2m_x_ept, 0, + "Allow executable superpage mappings in EPT"); + +void +pmap_allow_2m_x_ept_recalculate(void) +{ + /* + * SKL002, SKL012S. Since the EPT format is only used by + * Intel CPUs, the vendor check is merely a formality. + */ + if (!(cpu_vendor_id != CPU_VENDOR_INTEL || + (cpu_ia32_arch_caps & IA32_ARCH_CAP_IF_PSCHANGE_MC_NO) != 0 || + (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x26 || /* Atoms */ + CPUID_TO_MODEL(cpu_id) == 0x27 || + CPUID_TO_MODEL(cpu_id) == 0x35 || + CPUID_TO_MODEL(cpu_id) == 0x36 || + CPUID_TO_MODEL(cpu_id) == 0x37 || + CPUID_TO_MODEL(cpu_id) == 0x86 || + CPUID_TO_MODEL(cpu_id) == 0x1c || + CPUID_TO_MODEL(cpu_id) == 0x4a || + CPUID_TO_MODEL(cpu_id) == 0x4c || + CPUID_TO_MODEL(cpu_id) == 0x4d || + CPUID_TO_MODEL(cpu_id) == 0x5a || + CPUID_TO_MODEL(cpu_id) == 0x5c || + CPUID_TO_MODEL(cpu_id) == 0x5d || + CPUID_TO_MODEL(cpu_id) == 0x5f || + CPUID_TO_MODEL(cpu_id) == 0x6e || + CPUID_TO_MODEL(cpu_id) == 0x7a || + CPUID_TO_MODEL(cpu_id) == 0x57 || /* Knights */ + CPUID_TO_MODEL(cpu_id) == 0x85)))) + pmap_allow_2m_x_ept = 1; + TUNABLE_INT_FETCH("hw.allow_2m_x_ept", &pmap_allow_2m_x_ept); +} + +static bool +pmap_allow_2m_x_page(pmap_t pmap, bool executable) +{ + + return (pmap->pm_type != PT_EPT || !executable || + !pmap_allow_2m_x_ept); +} + /* * Initialize the pmap module. * Called by vm_init, to initialize any structures that the pmap @@ -1849,6 +1894,9 @@ pmap_init(void) } } + /* IFU */ + pmap_allow_2m_x_ept_recalculate(); + /* * Initialize the vm page array entries for the kernel pmap's * page table pages. @@ -5452,6 +5500,15 @@ retry: } #if VM_NRESERVLEVEL > 0 +static bool +pmap_pde_ept_executable(pmap_t pmap, pd_entry_t pde) +{ + + if (pmap->pm_type != PT_EPT) + return (false); + return ((pde & EPT_PG_EXECUTE) != 0); +} + /* * Tries to promote the 512, contiguous 4KB page mappings that are within a * single page table page (PTP) to a single 2MB page mapping. For promotion @@ -5487,7 +5544,9 @@ pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offs firstpte = (pt_entry_t *)PHYS_TO_DMAP(*pde & PG_FRAME); setpde: newpde = *firstpte; - if ((newpde & ((PG_FRAME & PDRMASK) | PG_A | PG_V)) != (PG_A | PG_V)) { + if ((newpde & ((PG_FRAME & PDRMASK) | PG_A | PG_V)) != (PG_A | PG_V) || + !pmap_allow_2m_x_page(pmap, pmap_pde_ept_executable(pmap, + newpde))) { atomic_add_long(&pmap_pde_p_failures, 1); CTR2(KTR_PMAP, "pmap_promote_pde: failure for va %#lx" " in pmap %p", va, pmap); @@ -5917,6 +5976,12 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t PG_V = pmap_valid_bit(pmap); PMAP_LOCK_ASSERT(pmap, MA_OWNED); + if (!pmap_allow_2m_x_page(pmap, pmap_pde_ept_executable(pmap, + newpde))) { + CTR2(KTR_PMAP, "pmap_enter_pde: 2m x blocked for va %#lx" + " in pmap %p", va, pmap); + return (KERN_FAILURE); + } if ((pdpg = pmap_allocpde(pmap, va, (flags & PMAP_ENTER_NOSLEEP) != 0 ? NULL : lockp)) == NULL) { CTR2(KTR_PMAP, "pmap_enter_pde: failure for va %#lx" @@ -6063,6 +6128,7 @@ pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_o va = start + ptoa(diff); if ((va & PDRMASK) == 0 && va + NBPDR <= end && m->psind == 1 && pmap_ps_enabled(pmap) && + pmap_allow_2m_x_page(pmap, (prot & VM_PROT_EXECUTE) != 0) && pmap_enter_2mpage(pmap, va, m, prot, &lock)) m = &m[NBPDR / PAGE_SIZE - 1]; else Modified: stable/12/sys/amd64/include/pmap.h ============================================================================== --- stable/12/sys/amd64/include/pmap.h Tue Nov 12 18:01:33 2019 (r354649) +++ stable/12/sys/amd64/include/pmap.h Tue Nov 12 18:03:26 2019 (r354650) @@ -424,6 +424,7 @@ struct thread; void pmap_activate_boot(pmap_t pmap); void pmap_activate_sw(struct thread *); +void pmap_allow_2m_x_ept_recalculate(void); void pmap_bootstrap(vm_paddr_t *); int pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde); int pmap_change_attr(vm_offset_t, vm_size_t, int); Modified: stable/12/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/12/sys/dev/cpuctl/cpuctl.c Tue Nov 12 18:01:33 2019 (r354649) +++ stable/12/sys/dev/cpuctl/cpuctl.c Tue Nov 12 18:03:26 2019 (r354650) @@ -50,6 +50,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include @@ -539,6 +543,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td hw_ssb_recalculate(true); #ifdef __amd64__ amd64_syscall_ret_flush_l1d_recalc(); + pmap_allow_2m_x_ept_recalculate(); #endif hw_mds_recalculate(); printcpuinfo(); Modified: stable/12/sys/x86/include/specialreg.h ============================================================================== --- stable/12/sys/x86/include/specialreg.h Tue Nov 12 18:01:33 2019 (r354649) +++ stable/12/sys/x86/include/specialreg.h Tue Nov 12 18:03:26 2019 (r354650) @@ -447,6 +447,7 @@ #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY 0x00000008 #define IA32_ARCH_CAP_SSB_NO 0x00000010 #define IA32_ARCH_CAP_MDS_NO 0x00000020 +#define IA32_ARCH_CAP_IF_PSCHANGE_MC_NO 0x00000040 /* * CPUID manufacturers identifiers From owner-svn-src-stable@freebsd.org Tue Nov 12 18:04:29 2019 Return-Path: Delivered-To: svn-src-stable@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 D49BE1B4167; Tue, 12 Nov 2019 18:04: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 47CFxn5Gn2z3MFg; Tue, 12 Nov 2019 18:04:29 +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 9855B39EB; Tue, 12 Nov 2019 18:04:29 +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 xACI4T6b086630; Tue, 12 Nov 2019 18:04:29 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACI4Sw0086627; Tue, 12 Nov 2019 18:04:28 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911121804.xACI4Sw0086627@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 12 Nov 2019 18:04:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354651 - in stable/11/sys: amd64/amd64 amd64/include dev/cpuctl x86/include X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 amd64/include dev/cpuctl x86/include X-SVN-Commit-Revision: 354651 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 18:04:29 -0000 Author: kib Date: Tue Nov 12 18:04:28 2019 New Revision: 354651 URL: https://svnweb.freebsd.org/changeset/base/354651 Log: MFC r354649: Workaround for Intel SKL002/SKL012S errata. Security: CVE-2018-12207 Modified: stable/11/sys/amd64/amd64/pmap.c stable/11/sys/amd64/include/pmap.h stable/11/sys/dev/cpuctl/cpuctl.c stable/11/sys/x86/include/specialreg.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/pmap.c ============================================================================== --- stable/11/sys/amd64/amd64/pmap.c Tue Nov 12 18:03:26 2019 (r354650) +++ stable/11/sys/amd64/amd64/pmap.c Tue Nov 12 18:04:28 2019 (r354651) @@ -1226,6 +1226,51 @@ pmap_page_init(vm_page_t m) m->md.pat_mode = PAT_WRITE_BACK; } +static int pmap_allow_2m_x_ept; +SYSCTL_INT(_vm_pmap, OID_AUTO, allow_2m_x_ept, CTLFLAG_RWTUN | CTLFLAG_NOFETCH, + &pmap_allow_2m_x_ept, 0, + "Allow executable superpage mappings in EPT"); + +void +pmap_allow_2m_x_ept_recalculate(void) +{ + /* + * SKL002, SKL012S. Since the EPT format is only used by + * Intel CPUs, the vendor check is merely a formality. + */ + if (!(cpu_vendor_id != CPU_VENDOR_INTEL || + (cpu_ia32_arch_caps & IA32_ARCH_CAP_IF_PSCHANGE_MC_NO) != 0 || + (CPUID_TO_FAMILY(cpu_id) == 0x6 && + (CPUID_TO_MODEL(cpu_id) == 0x26 || /* Atoms */ + CPUID_TO_MODEL(cpu_id) == 0x27 || + CPUID_TO_MODEL(cpu_id) == 0x35 || + CPUID_TO_MODEL(cpu_id) == 0x36 || + CPUID_TO_MODEL(cpu_id) == 0x37 || + CPUID_TO_MODEL(cpu_id) == 0x86 || + CPUID_TO_MODEL(cpu_id) == 0x1c || + CPUID_TO_MODEL(cpu_id) == 0x4a || + CPUID_TO_MODEL(cpu_id) == 0x4c || + CPUID_TO_MODEL(cpu_id) == 0x4d || + CPUID_TO_MODEL(cpu_id) == 0x5a || + CPUID_TO_MODEL(cpu_id) == 0x5c || + CPUID_TO_MODEL(cpu_id) == 0x5d || + CPUID_TO_MODEL(cpu_id) == 0x5f || + CPUID_TO_MODEL(cpu_id) == 0x6e || + CPUID_TO_MODEL(cpu_id) == 0x7a || + CPUID_TO_MODEL(cpu_id) == 0x57 || /* Knights */ + CPUID_TO_MODEL(cpu_id) == 0x85)))) + pmap_allow_2m_x_ept = 1; + TUNABLE_INT_FETCH("hw.allow_2m_x_ept", &pmap_allow_2m_x_ept); +} + +static bool +pmap_allow_2m_x_page(pmap_t pmap, bool executable) +{ + + return (pmap->pm_type != PT_EPT || !executable || + !pmap_allow_2m_x_ept); +} + /* * Initialize the pmap module. * Called by vm_init, to initialize any structures that the pmap @@ -1270,6 +1315,9 @@ pmap_init(void) } } + /* IFU */ + pmap_allow_2m_x_ept_recalculate(); + /* * Initialize the vm page array entries for the kernel pmap's * page table pages. @@ -4550,6 +4598,15 @@ retry: } #if VM_NRESERVLEVEL > 0 +static bool +pmap_pde_ept_executable(pmap_t pmap, pd_entry_t pde) +{ + + if (pmap->pm_type != PT_EPT) + return (false); + return ((pde & EPT_PG_EXECUTE) != 0); +} + /* * Tries to promote the 512, contiguous 4KB page mappings that are within a * single page table page (PTP) to a single 2MB page mapping. For promotion @@ -4584,7 +4641,9 @@ pmap_promote_pde(pmap_t pmap, pd_entry_t *pde, vm_offs firstpte = (pt_entry_t *)PHYS_TO_DMAP(*pde & PG_FRAME); setpde: newpde = *firstpte; - if ((newpde & ((PG_FRAME & PDRMASK) | PG_A | PG_V)) != (PG_A | PG_V)) { + if ((newpde & ((PG_FRAME & PDRMASK) | PG_A | PG_V)) != (PG_A | PG_V) || + !pmap_allow_2m_x_page(pmap, pmap_pde_ept_executable(pmap, + newpde))) { atomic_add_long(&pmap_pde_p_failures, 1); CTR2(KTR_PMAP, "pmap_promote_pde: failure for va %#lx" " in pmap %p", va, pmap); @@ -5010,6 +5069,12 @@ pmap_enter_pde(pmap_t pmap, vm_offset_t va, pd_entry_t PG_V = pmap_valid_bit(pmap); PMAP_LOCK_ASSERT(pmap, MA_OWNED); + if (!pmap_allow_2m_x_page(pmap, pmap_pde_ept_executable(pmap, + newpde))) { + CTR2(KTR_PMAP, "pmap_enter_pde: 2m x blocked for va %#lx" + " in pmap %p", va, pmap); + return (KERN_FAILURE); + } if ((pdpg = pmap_allocpde(pmap, va, (flags & PMAP_ENTER_NOSLEEP) != 0 ? NULL : lockp)) == NULL) { CTR2(KTR_PMAP, "pmap_enter_pde: failure for va %#lx" @@ -5139,6 +5204,7 @@ pmap_enter_object(pmap_t pmap, vm_offset_t start, vm_o va = start + ptoa(diff); if ((va & PDRMASK) == 0 && va + NBPDR <= end && m->psind == 1 && pmap_ps_enabled(pmap) && + pmap_allow_2m_x_page(pmap, (prot & VM_PROT_EXECUTE) != 0) && pmap_enter_2mpage(pmap, va, m, prot, &lock)) m = &m[NBPDR / PAGE_SIZE - 1]; else Modified: stable/11/sys/amd64/include/pmap.h ============================================================================== --- stable/11/sys/amd64/include/pmap.h Tue Nov 12 18:03:26 2019 (r354650) +++ stable/11/sys/amd64/include/pmap.h Tue Nov 12 18:04:28 2019 (r354651) @@ -407,6 +407,7 @@ struct thread; void pmap_activate_boot(pmap_t pmap); void pmap_activate_sw(struct thread *); +void pmap_allow_2m_x_ept_recalculate(void); void pmap_bootstrap(vm_paddr_t *); int pmap_cache_bits(pmap_t pmap, int mode, boolean_t is_pde); int pmap_change_attr(vm_offset_t, vm_size_t, int); Modified: stable/11/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/11/sys/dev/cpuctl/cpuctl.c Tue Nov 12 18:03:26 2019 (r354650) +++ stable/11/sys/dev/cpuctl/cpuctl.c Tue Nov 12 18:04:28 2019 (r354651) @@ -48,6 +48,10 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include +#include + #include #include #include @@ -535,6 +539,9 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td hw_ibrs_recalculate(); restore_cpu(oldcpu, is_bound, td); hw_ssb_recalculate(true); +#ifdef __amd64__ + pmap_allow_2m_x_ept_recalculate(); +#endif hw_mds_recalculate(); printcpuinfo(); return (0); Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Tue Nov 12 18:03:26 2019 (r354650) +++ stable/11/sys/x86/include/specialreg.h Tue Nov 12 18:04:28 2019 (r354651) @@ -406,6 +406,7 @@ #define IA32_ARCH_CAP_SKIP_L1DFL_VMENTRY 0x00000008 #define IA32_ARCH_CAP_SSB_NO 0x00000010 #define IA32_ARCH_CAP_MDS_NO 0x00000020 +#define IA32_ARCH_CAP_IF_PSCHANGE_MC_NO 0x00000040 /* * CPUID manufacturers identifiers From owner-svn-src-stable@freebsd.org Tue Nov 12 19:19:28 2019 Return-Path: Delivered-To: svn-src-stable@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 5A43B1B7C60; Tue, 12 Nov 2019 19:19:28 +0000 (UTC) (envelope-from gjb@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 47CHcJ18rPz40Nx; Tue, 12 Nov 2019 19:19:28 +0000 (UTC) (envelope-from gjb@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 0B28E4737; Tue, 12 Nov 2019 19:19:28 +0000 (UTC) (envelope-from gjb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xACJJRdR028871; Tue, 12 Nov 2019 19:19:27 GMT (envelope-from gjb@FreeBSD.org) Received: (from gjb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACJJRld028869; Tue, 12 Nov 2019 19:19:27 GMT (envelope-from gjb@FreeBSD.org) Message-Id: <201911121919.xACJJRld028869@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gjb set sender to gjb@FreeBSD.org using -f From: Glen Barber Date: Tue, 12 Nov 2019 19:19:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354656 - stable/11/release/doc/share/xml X-SVN-Group: stable-11 X-SVN-Commit-Author: gjb X-SVN-Commit-Paths: stable/11/release/doc/share/xml X-SVN-Commit-Revision: 354656 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 19:19:28 -0000 Author: gjb Date: Tue Nov 12 19:19:27 2019 New Revision: 354656 URL: https://svnweb.freebsd.org/changeset/base/354656 Log: Document EN-19:18, EN-19:19, SA-19:25, SA-19:26. Sponsored by: Rubicon Communications, LLC (netgate.com) Modified: stable/11/release/doc/share/xml/errata.xml stable/11/release/doc/share/xml/security.xml Modified: stable/11/release/doc/share/xml/errata.xml ============================================================================== --- stable/11/release/doc/share/xml/errata.xml Tue Nov 12 19:15:16 2019 (r354655) +++ stable/11/release/doc/share/xml/errata.xml Tue Nov 12 19:19:27 2019 (r354656) @@ -46,6 +46,14 @@ 20 August 2019 "jail" keyword fix + + + FreeBSD-EN-19:18.tzdata + 23 October 2019 + Timezone database information + update + Modified: stable/11/release/doc/share/xml/security.xml ============================================================================== --- stable/11/release/doc/share/xml/security.xml Tue Nov 12 19:15:16 2019 (r354655) +++ stable/11/release/doc/share/xml/security.xml Tue Nov 12 19:19:27 2019 (r354656) @@ -110,6 +110,21 @@ 20 August 2019 Reference count overflow + + + FreeBSD-SA-19:25.mcepce + 12 November 2019 + Machine Check Exception on Page Size + Change + + + + FreeBSD-SA-19:26.mcu + 12 November 2019 + Intel CPU Microcode Update + From owner-svn-src-stable@freebsd.org Tue Nov 12 19:29:32 2019 Return-Path: Delivered-To: svn-src-stable@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 E8AEA1B89E1; Tue, 12 Nov 2019 19:29:32 +0000 (UTC) (envelope-from scottl@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 47CHqw5wmwz41LS; Tue, 12 Nov 2019 19:29:32 +0000 (UTC) (envelope-from scottl@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 AEAEF4905; Tue, 12 Nov 2019 19:29:32 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xACJTWGf035025; Tue, 12 Nov 2019 19:29:32 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACJTWX2035023; Tue, 12 Nov 2019 19:29:32 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911121929.xACJTWX2035023@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 12 Nov 2019 19:29: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: r354657 - in stable/12/sys/x86: include x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/12/sys/x86: include x86 X-SVN-Commit-Revision: 354657 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 19:29:33 -0000 Author: scottl Date: Tue Nov 12 19:29:32 2019 New Revision: 354657 URL: https://svnweb.freebsd.org/changeset/base/354657 Log: MFC: Add new bit definitions for TSX, related to the TAA issue. The actual mitigation will follow in a future commit. Sponsored by: Intel Modified: stable/12/sys/x86/include/specialreg.h stable/12/sys/x86/x86/identcpu.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/x86/include/specialreg.h ============================================================================== --- stable/12/sys/x86/include/specialreg.h Tue Nov 12 19:19:27 2019 (r354656) +++ stable/12/sys/x86/include/specialreg.h Tue Nov 12 19:29:32 2019 (r354657) @@ -448,7 +448,13 @@ #define IA32_ARCH_CAP_SSB_NO 0x00000010 #define IA32_ARCH_CAP_MDS_NO 0x00000020 #define IA32_ARCH_CAP_IF_PSCHANGE_MC_NO 0x00000040 +#define IA32_ARCH_CAP_TSX_CTRL 0x00000080 +#define IA32_ARCH_CAP_TAA_NO 0x00000100 +/* MSR IA32_TSX_CTRL bits */ +#define IA32_TSX_CTRL_RTM_DISABLE 0x00000001 +#define IA32_TSX_CTRL_TSX_CPUID_CLEAR 0x00000002 + /* * CPUID manufacturers identifiers */ @@ -500,6 +506,7 @@ #define MSR_BBL_CR_TRIG 0x11a #define MSR_BBL_CR_BUSY 0x11b #define MSR_BBL_CR_CTL3 0x11e +#define MSR_IA32_TSX_CTRL 0x122 #define MSR_SYSENTER_CS_MSR 0x174 #define MSR_SYSENTER_ESP_MSR 0x175 #define MSR_SYSENTER_EIP_MSR 0x176 Modified: stable/12/sys/x86/x86/identcpu.c ============================================================================== --- stable/12/sys/x86/x86/identcpu.c Tue Nov 12 19:19:27 2019 (r354656) +++ stable/12/sys/x86/x86/identcpu.c Tue Nov 12 19:29:32 2019 (r354657) @@ -1025,6 +1025,9 @@ printcpuinfo(void) "\003RSBA" "\004SKIP_L1DFL_VME" "\005SSB_NO" + "\005MDS_NO" + "\010TSX_CTRL" + "\011TAA_NO" ); } From owner-svn-src-stable@freebsd.org Tue Nov 12 19:35:47 2019 Return-Path: Delivered-To: svn-src-stable@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 CD1D31B8C96; Tue, 12 Nov 2019 19:35:47 +0000 (UTC) (envelope-from scottl@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 47CHz7567Fz41lB; Tue, 12 Nov 2019 19:35:47 +0000 (UTC) (envelope-from scottl@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 7432A4ABF; Tue, 12 Nov 2019 19:35:47 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xACJZl7m040950; Tue, 12 Nov 2019 19:35:47 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xACJZkfE040948; Tue, 12 Nov 2019 19:35:46 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911121935.xACJZkfE040948@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Tue, 12 Nov 2019 19:35:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354658 - in stable/11/sys/x86: include x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/11/sys/x86: include x86 X-SVN-Commit-Revision: 354658 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Nov 2019 19:35:47 -0000 Author: scottl Date: Tue Nov 12 19:35:46 2019 New Revision: 354658 URL: https://svnweb.freebsd.org/changeset/base/354658 Log: MFC: Add new bit definitions for TSX, related to the TAA issue. The actual mitigation will follow in a future commit. Obtained from: Intel Modified: stable/11/sys/x86/include/specialreg.h stable/11/sys/x86/x86/identcpu.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/x86/include/specialreg.h ============================================================================== --- stable/11/sys/x86/include/specialreg.h Tue Nov 12 19:29:32 2019 (r354657) +++ stable/11/sys/x86/include/specialreg.h Tue Nov 12 19:35:46 2019 (r354658) @@ -407,7 +407,13 @@ #define IA32_ARCH_CAP_SSB_NO 0x00000010 #define IA32_ARCH_CAP_MDS_NO 0x00000020 #define IA32_ARCH_CAP_IF_PSCHANGE_MC_NO 0x00000040 +#define IA32_ARCH_CAP_TSX_CTRL 0x00000080 +#define IA32_ARCH_CAP_TAA_NO 0x00000100 +/* MSR IA32_TSX_CTRL bits */ +#define IA32_TSX_CTRL_RTM_DISABLE 0x00000001 +#define IA32_TSX_CTRL_TSX_CPUID_CLEAR 0x00000002 + /* * CPUID manufacturers identifiers */ @@ -459,6 +465,7 @@ #define MSR_BBL_CR_TRIG 0x11a #define MSR_BBL_CR_BUSY 0x11b #define MSR_BBL_CR_CTL3 0x11e +#define MSR_IA32_TSX_CTRL 0x122 #define MSR_SYSENTER_CS_MSR 0x174 #define MSR_SYSENTER_ESP_MSR 0x175 #define MSR_SYSENTER_EIP_MSR 0x176 Modified: stable/11/sys/x86/x86/identcpu.c ============================================================================== --- stable/11/sys/x86/x86/identcpu.c Tue Nov 12 19:29:32 2019 (r354657) +++ stable/11/sys/x86/x86/identcpu.c Tue Nov 12 19:35:46 2019 (r354658) @@ -1024,6 +1024,9 @@ printcpuinfo(void) "\003RSBA" "\004SKIP_L1DFL_VME" "\005SSB_NO" + "\006MDS_NO" + "\010TSX_CTRL" + "\011TAA_NO" ); } From owner-svn-src-stable@freebsd.org Wed Nov 13 07:04:11 2019 Return-Path: Delivered-To: svn-src-stable@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 C4DA51A84F1; Wed, 13 Nov 2019 07:04:11 +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 47CbFR4hWWz4dnP; Wed, 13 Nov 2019 07:04:11 +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 6AB29C861; Wed, 13 Nov 2019 07:04:11 +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 xAD74BKN047451; Wed, 13 Nov 2019 07:04:11 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAD74BhH047450; Wed, 13 Nov 2019 07:04:11 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911130704.xAD74BhH047450@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Wed, 13 Nov 2019 07:04: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: r354674 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 354674 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 07:04:11 -0000 Author: tsoome Date: Wed Nov 13 07:04:11 2019 New Revision: 354674 URL: https://svnweb.freebsd.org/changeset/base/354674 Log: MFC: r354415 loader.efi: HARDDRIVE_DEVICE_PATH may have subpaths The macos does create Vendor Media devices on top of APFS container (like partition table inside the partition), so we need to collect such devices into respective device tree. Modified: stable/12/stand/efi/libefi/efipart.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/efipart.c ============================================================================== --- stable/12/stand/efi/libefi/efipart.c Wed Nov 13 03:56:51 2019 (r354673) +++ stable/12/stand/efi/libefi/efipart.c Wed Nov 13 07:04:11 2019 (r354674) @@ -313,11 +313,14 @@ efipart_floppy(EFI_DEVICE_PATH *node) static pdinfo_t * efipart_find_parent(pdinfo_list_t *pdi, EFI_DEVICE_PATH *devpath) { - pdinfo_t *pd; + pdinfo_t *pd, *part; STAILQ_FOREACH(pd, pdi, pd_link) { if (efi_devpath_is_prefix(pd->pd_devpath, devpath)) return (pd); + part = efipart_find_parent(&pd->pd_part, devpath); + if (part != NULL) + return (part); } return (NULL); } @@ -500,22 +503,44 @@ efipart_initcd(void) return (0); } -static void -efipart_hdinfo_add(pdinfo_t *hd, HARDDRIVE_DEVICE_PATH *node) +static bool +efipart_hdinfo_add_node(pdinfo_t *hd, EFI_DEVICE_PATH *node) { pdinfo_t *pd, *last; + VENDOR_DEVICE_PATH *ven_node; STAILQ_FOREACH(pd, &hdinfo, pd_link) { - if (efi_devpath_is_prefix(pd->pd_devpath, hd->pd_devpath)) { - /* Add the partition. */ - hd->pd_unit = node->PartitionNumber; - hd->pd_parent = pd; - hd->pd_devsw = &efipart_hddev; - STAILQ_INSERT_TAIL(&pd->pd_part, hd, pd_link); - return; - } + if (efi_devpath_is_prefix(pd->pd_devpath, hd->pd_devpath)) + break; } + if (pd == NULL) + return (false); + /* Add the partition. */ + if (DevicePathSubType(node) == MEDIA_HARDDRIVE_DP) { + hd->pd_unit = ((HARDDRIVE_DEVICE_PATH *)node)->PartitionNumber; + } else { + last = STAILQ_LAST(&pd->pd_part, pdinfo, pd_link); + if (last != NULL) + hd->pd_unit = last->pd_unit + 1; + else + hd->pd_unit = 0; + } + hd->pd_parent = pd; + hd->pd_devsw = &efipart_hddev; + + STAILQ_INSERT_TAIL(&pd->pd_part, hd, pd_link); + return (true); +} + +static void +efipart_hdinfo_add(pdinfo_t *hd, EFI_DEVICE_PATH *node) +{ + pdinfo_t *pd, *last; + + if (efipart_hdinfo_add_node(hd, node)) + return; + last = STAILQ_LAST(&hdinfo, pdinfo, pd_link); if (last != NULL) hd->pd_unit = last->pd_unit + 1; @@ -677,7 +702,7 @@ restart: efipart_hdinfo_add(parent, NULL); } - efipart_hdinfo_add(hd, (HARDDRIVE_DEVICE_PATH *)node); + efipart_hdinfo_add(hd, node); goto restart; } } From owner-svn-src-stable@freebsd.org Wed Nov 13 07:39:23 2019 Return-Path: Delivered-To: svn-src-stable@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 F3C2D1A8B2D; Wed, 13 Nov 2019 07:39: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 47Cc226DDdz4g8d; Wed, 13 Nov 2019 07:39:22 +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 B8C51CDAA; Wed, 13 Nov 2019 07:39:22 +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 xAD7dMDK065259; Wed, 13 Nov 2019 07:39:22 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAD7dL9N065251; Wed, 13 Nov 2019 07:39:21 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911130739.xAD7dL9N065251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 13 Nov 2019 07:39: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: r354675 - in stable/12/sys/cddl/contrib/opensolaris/uts/common: fs/zfs sys X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12/sys/cddl/contrib/opensolaris/uts/common: fs/zfs sys X-SVN-Commit-Revision: 354675 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 07:39:23 -0000 Author: avg Date: Wed Nov 13 07:39:20 2019 New Revision: 354675 URL: https://svnweb.freebsd.org/changeset/base/354675 Log: MFC r353636: MFV r353630: 10809 Performance optimization of AVL tree comparator functions Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ddt.c Wed Nov 13 07:39:20 2019 (r354675) @@ -768,22 +768,31 @@ ddt_prefetch(spa_t *spa, const blkptr_t *bp) } } +/* + * Opaque struct used for ddt_key comparison + */ +#define DDT_KEY_CMP_LEN (sizeof (ddt_key_t) / sizeof (uint16_t)) + +typedef struct ddt_key_cmp { + uint16_t u16[DDT_KEY_CMP_LEN]; +} ddt_key_cmp_t; + int ddt_entry_compare(const void *x1, const void *x2) { const ddt_entry_t *dde1 = x1; const ddt_entry_t *dde2 = x2; - const uint64_t *u1 = (const uint64_t *)&dde1->dde_key; - const uint64_t *u2 = (const uint64_t *)&dde2->dde_key; + const ddt_key_cmp_t *k1 = (const ddt_key_cmp_t *)&dde1->dde_key; + const ddt_key_cmp_t *k2 = (const ddt_key_cmp_t *)&dde2->dde_key; + int32_t cmp = 0; - for (int i = 0; i < DDT_KEY_WORDS; i++) { - if (u1[i] < u2[i]) - return (-1); - if (u1[i] > u2[i]) - return (1); + for (int i = 0; i < DDT_KEY_CMP_LEN; i++) { + cmp = (int32_t)k1->u16[i] - (int32_t)k2->u16[i]; + if (likely(cmp)) + break; } - return (0); + return (AVL_ISIGN(cmp)); } static ddt_t * Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c Wed Nov 13 07:39:20 2019 (r354675) @@ -259,8 +259,13 @@ lz4_decompress(void *s_start, void *d_start, size_t s_ #undef unlikely #endif +#ifndef likely #define likely(expr) expect((expr) != 0, 1) +#endif + +#ifndef unlikely #define unlikely(expr) expect((expr) != 0, 0) +#endif /* Basic types */ #define BYTE uint8_t Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/metaslab.c Wed Nov 13 07:39:20 2019 (r354675) @@ -1203,9 +1203,6 @@ metaslab_rangesize_compare(const void *x1, const void if (likely(cmp)) return (cmp); - if (r1->rs_start < r2->rs_start) - return (-1); - return (AVL_CMP(r1->rs_start, r2->rs_start)); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/range_tree.c Wed Nov 13 07:39:20 2019 (r354675) @@ -164,7 +164,7 @@ range_tree_seg_compare(const void *x1, const void *x2) ASSERT3U(r1->rs_start, <=, r1->rs_end); ASSERT3U(r2->rs_start, <=, r2->rs_end); - + return ((r1->rs_start >= r2->rs_end) - (r1->rs_end <= r2->rs_start)); } Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_cache.c Wed Nov 13 07:39:20 2019 (r354675) @@ -114,29 +114,24 @@ static vdc_stats_t vdc_stats = { #define VDCSTAT_BUMP(stat) atomic_inc_64(&vdc_stats.stat.value.ui64); -static int +static inline int vdev_cache_offset_compare(const void *a1, const void *a2) { - const vdev_cache_entry_t *ve1 = a1; - const vdev_cache_entry_t *ve2 = a2; + const vdev_cache_entry_t *ve1 = (const vdev_cache_entry_t *)a1; + const vdev_cache_entry_t *ve2 = (const vdev_cache_entry_t *)a2; - if (ve1->ve_offset < ve2->ve_offset) - return (-1); - if (ve1->ve_offset > ve2->ve_offset) - return (1); - return (0); + return (AVL_CMP(ve1->ve_offset, ve2->ve_offset)); } static int vdev_cache_lastused_compare(const void *a1, const void *a2) { - const vdev_cache_entry_t *ve1 = a1; - const vdev_cache_entry_t *ve2 = a2; + const vdev_cache_entry_t *ve1 = (const vdev_cache_entry_t *)a1; + const vdev_cache_entry_t *ve2 = (const vdev_cache_entry_t *)a2; - if (ve1->ve_lastused < ve2->ve_lastused) - return (-1); - if (ve1->ve_lastused > ve2->ve_lastused) - return (1); + int cmp = AVL_CMP(ve1->ve_lastused, ve2->ve_lastused); + if (likely(cmp)) + return (cmp); /* * Among equally old entries, sort by offset to ensure uniqueness. Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_queue.c Wed Nov 13 07:39:20 2019 (r354675) @@ -353,25 +353,15 @@ vdev_queue_type_tree(vdev_queue_t *vq, zio_type_t t) int vdev_queue_timestamp_compare(const void *x1, const void *x2) { - const zio_t *z1 = x1; - const zio_t *z2 = x2; + const zio_t *z1 = (const zio_t *)x1; + const zio_t *z2 = (const zio_t *)x2; - if (z1->io_timestamp < z2->io_timestamp) - return (-1); - if (z1->io_timestamp > z2->io_timestamp) - return (1); + int cmp = AVL_CMP(z1->io_timestamp, z2->io_timestamp); - if (z1->io_offset < z2->io_offset) - return (-1); - if (z1->io_offset > z2->io_offset) - return (1); + if (likely(cmp)) + return (cmp); - if (z1 < z2) - return (-1); - if (z1 > z2) - return (1); - - return (0); + return (AVL_PCMP(z1, z2)); } void Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_rlock.c Wed Nov 13 07:39:20 2019 (r354675) @@ -107,14 +107,10 @@ static int rangelock_compare(const void *arg1, const void *arg2) { - const locked_range_t *rl1 = arg1; - const locked_range_t *rl2 = arg2; + const locked_range_t *rl1 = (const locked_range_t *)arg1; + const locked_range_t *rl2 = (const locked_range_t *)arg2; - if (rl1->lr_offset > rl2->lr_offset) - return (1); - if (rl1->lr_offset < rl2->lr_offset) - return (-1); - return (0); + return (AVL_CMP(rl1->lr_offset, rl2->lr_offset)); } /* Modified: stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h ============================================================================== --- stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h Wed Nov 13 07:04:11 2019 (r354674) +++ stable/12/sys/cddl/contrib/opensolaris/uts/common/sys/avl.h Wed Nov 13 07:39:20 2019 (r354675) @@ -105,6 +105,13 @@ extern "C" { * as is needed for any linked list implementation. */ +/* + * AVL comparator helpers + */ +#define AVL_ISIGN(a) (((a) > 0) - ((a) < 0)) +#define AVL_CMP(a, b) (((a) > (b)) - ((a) < (b))) +#define AVL_PCMP(a, b) \ + (((uintptr_t)(a) > (uintptr_t)(b)) - ((uintptr_t)(a) < (uintptr_t)(b))) /* * AVL comparator helpers From owner-svn-src-stable@freebsd.org Wed Nov 13 07:41:20 2019 Return-Path: Delivered-To: svn-src-stable@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 1FBEF1A8BED; Wed, 13 Nov 2019 07:41:20 +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 47Cc4J05pYz3BrK; Wed, 13 Nov 2019 07:41:20 +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 C2863CDE9; Wed, 13 Nov 2019 07:41:19 +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 xAD7fJMd067651; Wed, 13 Nov 2019 07:41:19 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAD7fJup067650; Wed, 13 Nov 2019 07:41:19 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911130741.xAD7fJup067650@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 13 Nov 2019 07:41: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: r354676 - stable/12/sys/amd64/vmm X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/amd64/vmm X-SVN-Commit-Revision: 354676 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 07:41:20 -0000 Author: avg Date: Wed Nov 13 07:41:19 2019 New Revision: 354676 URL: https://svnweb.freebsd.org/changeset/base/354676 Log: MFC r353747: vmm: remove a wmb() call After removing wmb(), vm_set_rendezvous_func() became super trivial, so there was no point in keeping it. The wmb (sfence on amd64, lock nop on i386) was not needed. This can be explained from several points of view. First, wmb() is used for store-store ordering (although, the primitive is undocumented). There was no obvious subsequent store that needed the barrier. Second, x86 has a memory model with strong ordering including total store order. An explicit store barrier may be needed only when working with special memory (device, special caching mode) or using special instructions (non-temporal stores). That was not the case for this code. Third, I believe that there is a misconception that sfence "flushes" the store buffer in a sense that it speeds up the propagation of stores from the store buffer to the global visibility. I think that such propagation always happens as fast as possible. sfence only makes subsequent stores wait for that propagation to complete. So, sfence is only useful for ordering of stores and only in the situations described above. Modified: stable/12/sys/amd64/vmm/vmm.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/vmm/vmm.c ============================================================================== --- stable/12/sys/amd64/vmm/vmm.c Wed Nov 13 07:39:20 2019 (r354675) +++ stable/12/sys/amd64/vmm/vmm.c Wed Nov 13 07:41:19 2019 (r354676) @@ -1236,22 +1236,6 @@ vcpu_require_state_locked(struct vm *vm, int vcpuid, e panic("Error %d setting state to %d", error, newstate); } -static void -vm_set_rendezvous_func(struct vm *vm, vm_rendezvous_func_t func) -{ - - KASSERT(mtx_owned(&vm->rendezvous_mtx), ("rendezvous_mtx not locked")); - - /* - * Update 'rendezvous_func' and execute a write memory barrier to - * ensure that it is visible across all host cpus. This is not needed - * for correctness but it does ensure that all the vcpus will notice - * that the rendezvous is requested immediately. - */ - vm->rendezvous_func = func; - wmb(); -} - #define RENDEZVOUS_CTR0(vm, vcpuid, fmt) \ do { \ if (vcpuid >= 0) \ @@ -1282,7 +1266,7 @@ vm_handle_rendezvous(struct vm *vm, int vcpuid) if (CPU_CMP(&vm->rendezvous_req_cpus, &vm->rendezvous_done_cpus) == 0) { VCPU_CTR0(vm, vcpuid, "Rendezvous completed"); - vm_set_rendezvous_func(vm, NULL); + vm->rendezvous_func = NULL; wakeup(&vm->rendezvous_func); break; } @@ -2536,7 +2520,7 @@ restart: vm->rendezvous_req_cpus = dest; CPU_ZERO(&vm->rendezvous_done_cpus); vm->rendezvous_arg = arg; - vm_set_rendezvous_func(vm, func); + vm->rendezvous_func = func; mtx_unlock(&vm->rendezvous_mtx); /* From owner-svn-src-stable@freebsd.org Wed Nov 13 07:43:12 2019 Return-Path: Delivered-To: svn-src-stable@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 247C51A8E0F; Wed, 13 Nov 2019 07:43:12 +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 47Cc6S0BXcz3C9V; Wed, 13 Nov 2019 07:43:12 +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 DE2C7CF5F; Wed, 13 Nov 2019 07:43:11 +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 xAD7hBKx070673; Wed, 13 Nov 2019 07:43:11 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAD7hBIu070672; Wed, 13 Nov 2019 07:43:11 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911130743.xAD7hBIu070672@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 13 Nov 2019 07:43: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: r354677 - stable/12/sys/x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: stable/12/sys/x86/x86 X-SVN-Commit-Revision: 354677 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 07:43:12 -0000 Author: avg Date: Wed Nov 13 07:43:11 2019 New Revision: 354677 URL: https://svnweb.freebsd.org/changeset/base/354677 Log: MFC r353748: remove wmb() call from x86 cpu_reset() The rationale is pretty much the same as in r353747. There is no subsequent dependent store. The store is to the regular (TSO) memory anyway. Modified: stable/12/sys/x86/x86/cpu_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/12/sys/x86/x86/cpu_machdep.c Wed Nov 13 07:41:19 2019 (r354676) +++ stable/12/sys/x86/x86/cpu_machdep.c Wed Nov 13 07:43:11 2019 (r354677) @@ -379,7 +379,6 @@ cpu_reset(void) /* Restart CPU #0. */ CPU_SETOF(0, &started_cpus); - wmb(); cnt = 0; while (cpu_reset_proxy_active == 0 && cnt < 10000000) { From owner-svn-src-stable@freebsd.org Wed Nov 13 10:08:46 2019 Return-Path: Delivered-To: svn-src-stable@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 556FD1AC68A; Wed, 13 Nov 2019 10:08:46 +0000 (UTC) (envelope-from ganbold@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 47CgLQ1NRMz3L9V; Wed, 13 Nov 2019 10:08:46 +0000 (UTC) (envelope-from ganbold@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 0E155E832; Wed, 13 Nov 2019 10:08:46 +0000 (UTC) (envelope-from ganbold@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xADA8jIB053001; Wed, 13 Nov 2019 10:08:45 GMT (envelope-from ganbold@FreeBSD.org) Received: (from ganbold@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xADA8jmc052999; Wed, 13 Nov 2019 10:08:45 GMT (envelope-from ganbold@FreeBSD.org) Message-Id: <201911131008.xADA8jmc052999@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ganbold set sender to ganbold@FreeBSD.org using -f From: Ganbold Tsagaankhuu Date: Wed, 13 Nov 2019 10:08: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: r354678 - in stable/12/sys: dts/arm/overlays modules/dtb/allwinner X-SVN-Group: stable-12 X-SVN-Commit-Author: ganbold X-SVN-Commit-Paths: in stable/12/sys: dts/arm/overlays modules/dtb/allwinner X-SVN-Commit-Revision: 354678 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 10:08:46 -0000 Author: ganbold Date: Wed Nov 13 10:08:45 2019 New Revision: 354678 URL: https://svnweb.freebsd.org/changeset/base/354678 Log: MFC r351452 dtso: allwinner: Add an overlay for H3 thermal node Added: stable/12/sys/dts/arm/overlays/sun8i-h3-ths.dtso (contents, props changed) Modified: stable/12/sys/dts/arm/overlays/sun8i-h3-sid.dtso stable/12/sys/modules/dtb/allwinner/Makefile Modified: stable/12/sys/dts/arm/overlays/sun8i-h3-sid.dtso ============================================================================== --- stable/12/sys/dts/arm/overlays/sun8i-h3-sid.dtso Wed Nov 13 07:43:11 2019 (r354677) +++ stable/12/sys/dts/arm/overlays/sun8i-h3-sid.dtso Wed Nov 13 10:08:45 2019 (r354678) @@ -10,5 +10,10 @@ compatible = "allwinner,sun8i-h3-sid"; reg = <0x1c14000 0x400>; status = "okay"; + + /* Data cells */ + ths_calib: calib@234 { + reg = <0x234 0x2>; + }; }; }; Added: stable/12/sys/dts/arm/overlays/sun8i-h3-ths.dtso ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/12/sys/dts/arm/overlays/sun8i-h3-ths.dtso Wed Nov 13 10:08:45 2019 (r354678) @@ -0,0 +1,27 @@ +/dts-v1/; +/plugin/; + +#include +#include +#include + +/ { + compatible = "allwinner,sun8i-h3"; +}; + +&{/soc} { + ths: thermal_sensor@1c25000 { + compatible = "allwinner,sun8i-h3-ths"; + reg = <0x01c25000 0x100>; + interrupts = ; + clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_THS>; + clock-names = "apb", "ths"; + resets = <&ccu RST_BUS_THS>; + reset-names = "apb"; + #thermal-sensor-cells = <0>; + status = "okay"; + + nvmem-cells = <&ths_calib>; + nvmem-cell-names = "ths-calib"; + }; +}; Modified: stable/12/sys/modules/dtb/allwinner/Makefile ============================================================================== --- stable/12/sys/modules/dtb/allwinner/Makefile Wed Nov 13 07:43:11 2019 (r354677) +++ stable/12/sys/modules/dtb/allwinner/Makefile Wed Nov 13 10:08:45 2019 (r354678) @@ -24,7 +24,8 @@ DTS= \ sun8i-h3-orangepi-plus2e.dts DTSO= sun8i-a83t-sid.dtso \ - sun8i-h3-sid.dtso + sun8i-h3-sid.dtso \ + sun8i-h3-ths.dtso LINKS= \ ${DTBDIR}/sun4i-a10-cubieboard.dtb ${DTBDIR}/cubieboard.dtb \ From owner-svn-src-stable@freebsd.org Wed Nov 13 22:25:54 2019 Return-Path: Delivered-To: svn-src-stable@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 3C0AE1BDCBC; Wed, 13 Nov 2019 22:25:54 +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 47Czhy0sV5z4Vmw; Wed, 13 Nov 2019 22:25:54 +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 008061EC7F; Wed, 13 Nov 2019 22:25:54 +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 xADMPrWD095389; Wed, 13 Nov 2019 22:25:53 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xADMPr0I095388; Wed, 13 Nov 2019 22:25:53 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201911132225.xADMPr0I095388@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 13 Nov 2019 22:25: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: r354695 - stable/12/sys/sys X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12/sys/sys X-SVN-Commit-Revision: 354695 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 22:25:54 -0000 Author: brooks Date: Wed Nov 13 22:25:53 2019 New Revision: 354695 URL: https://svnweb.freebsd.org/changeset/base/354695 Log: MFC r354420: Fix the alignment of struct xunpcb on systems with >64-bit pointers. Reviewed by: emaste Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22268 Modified: stable/12/sys/sys/unpcb.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/sys/unpcb.h ============================================================================== --- stable/12/sys/sys/unpcb.h Wed Nov 13 21:51:55 2019 (r354694) +++ stable/12/sys/sys/unpcb.h Wed Nov 13 22:25:53 2019 (r354695) @@ -156,7 +156,7 @@ struct xunpcb { char xu_dummy2[256]; }; struct xsocket xu_socket; -} __aligned(8); +} __aligned(MAX(8, sizeof(void *))); struct xunpgen { ksize_t xug_len; From owner-svn-src-stable@freebsd.org Wed Nov 13 23:26:13 2019 Return-Path: Delivered-To: svn-src-stable@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 9790C1BF699; Wed, 13 Nov 2019 23:26:13 +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 47D12Y3Jbmz4BXM; Wed, 13 Nov 2019 23:26:13 +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 1B75F1F75F; Wed, 13 Nov 2019 23:26:12 +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 xADNQCfQ033889; Wed, 13 Nov 2019 23:26:12 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xADNQCoV033888; Wed, 13 Nov 2019 23:26:12 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201911132326.xADNQCoV033888@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 13 Nov 2019 23:26: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: r354698 - stable/12 X-SVN-Group: stable-12 X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: stable/12 X-SVN-Commit-Revision: 354698 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Nov 2019 23:26:13 -0000 Author: brooks Date: Wed Nov 13 23:26:12 2019 New Revision: 354698 URL: https://svnweb.freebsd.org/changeset/base/354698 Log: MFC r353871 Record prior MFC of r353408 r353408: Fix -DNO_CLEAN build across r353340 and r353381 opensolaris_atomic.S is now only used on i386 with opensolaris_atomic.c used on other platforms. After r353381 it doesn't exist on those platforms so the stale dependency would result in a build error. r353871: Additional fix for -DNO_CLEAN build across r353340 and r353381 opensolaris_atomic.S is now only used on i386 with opensolaris_atomic.c used on other platforms. After r353381 it doesn't exist on those platforms so the stale dependency would result in a build error. r353408 addressed this issue for cddl/lib/libzpool, but it persisted with the opensolaris and zfs modules. Modified: stable/12/Makefile.inc1 Directory Properties: stable/12/ (props changed) Modified: stable/12/Makefile.inc1 ============================================================================== --- stable/12/Makefile.inc1 Wed Nov 13 22:43:11 2019 (r354697) +++ stable/12/Makefile.inc1 Wed Nov 13 23:26:12 2019 (r354698) @@ -1564,6 +1564,18 @@ _cleankernobj_fast_depend_hack: .PHONY rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \ ${OBJTOP}/sys/${KERNCONF}/.depend.assym.*; \ fi +# 20191112 r354634 removal of opensolaris_atomic.S +.if ${MACHINE} != i386 +.for f in opensolaris_atomic +.for m in opensolaris zfs + @if [ -e "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] && \ + grep -q ${f}.S "${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; then \ + echo "Removing stale dependencies for opensolaris_atomic"; \ + rm -f ${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \ + fi +.endfor +.endfor +.endif ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: .MAKE .PHONY From owner-svn-src-stable@freebsd.org Thu Nov 14 09:39:03 2019 Return-Path: Delivered-To: svn-src-stable@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 E599417AD1B; Thu, 14 Nov 2019 09:39:03 +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 47DGdg5blgz4DSM; Thu, 14 Nov 2019 09:39:03 +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 8796C264CE; Thu, 14 Nov 2019 09:39:03 +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 xAE9d3nj006987; Thu, 14 Nov 2019 09:39:03 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAE9d3fF006986; Thu, 14 Nov 2019 09:39:03 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201911140939.xAE9d3fF006986@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Thu, 14 Nov 2019 09:39:03 +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: r354704 - stable/12/stand/efi/libefi X-SVN-Group: stable-12 X-SVN-Commit-Author: tsoome X-SVN-Commit-Paths: stable/12/stand/efi/libefi X-SVN-Commit-Revision: 354704 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Nov 2019 09:39:04 -0000 Author: tsoome Date: Thu Nov 14 09:39:03 2019 New Revision: 354704 URL: https://svnweb.freebsd.org/changeset/base/354704 Log: MFC r354435: loader: implement fallback efi_devpath_to_name() UEFI 1.10 on macs does not seem to provide devpath to name translation, provide our own (limited) version, so we can get information about commmon devices. Modified: stable/12/stand/efi/libefi/devpath.c Directory Properties: stable/12/ (props changed) Modified: stable/12/stand/efi/libefi/devpath.c ============================================================================== --- stable/12/stand/efi/libefi/devpath.c Thu Nov 14 04:39:48 2019 (r354703) +++ stable/12/stand/efi/libefi/devpath.c Thu Nov 14 09:39:03 2019 (r354704) @@ -30,13 +30,16 @@ __FBSDID("$FreeBSD$"); #include #include #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 *toTextProtocol; -static EFI_GUID DevicePathFromTextGUID = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; +static EFI_GUID DevicePathFromTextGUID = + EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; static EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL *fromTextProtocol; EFI_DEVICE_PATH * @@ -65,6 +68,427 @@ efi_lookup_devpath(EFI_HANDLE handle) return (devpath); } +static char * +efi_make_tail(char *suffix) +{ + char *tail; + + tail = NULL; + if (suffix != NULL) + (void)asprintf(&tail, "/%s", suffix); + else + tail = strdup(""); + return (tail); +} + +typedef struct { + EFI_DEVICE_PATH Header; + EFI_GUID Guid; + UINT8 VendorDefinedData[1]; +} __packed VENDOR_DEVICE_PATH_WITH_DATA; + +static char * +efi_vendor_path(const char *type, VENDOR_DEVICE_PATH *node, char *suffix) +{ + uint32_t size = DevicePathNodeLength(&node->Header) - sizeof(*node); + VENDOR_DEVICE_PATH_WITH_DATA *dp = (VENDOR_DEVICE_PATH_WITH_DATA *)node; + char *name, *tail, *head; + char *uuid; + int rv; + + uuid_to_string((const uuid_t *)(void *)&node->Guid, &uuid, &rv); + if (rv != uuid_s_ok) + return (NULL); + + tail = efi_make_tail(suffix); + rv = asprintf(&head, "%sVendor(%s)[%x:", type, uuid, size); + free(uuid); + if (rv < 0) + return (NULL); + + if (DevicePathNodeLength(&node->Header) > sizeof(*node)) { + for (uint32_t i = 0; i < size; i++) { + rv = asprintf(&name, "%s%02x", head, + dp->VendorDefinedData[i]); + if (rv < 0) { + free(tail); + free(head); + return (NULL); + } + free(head); + head = name; + } + } + + if (asprintf(&name, "%s]%s", head, tail) < 0) + name = NULL; + free(head); + free(tail); + return (name); +} + +static char * +efi_hw_dev_path(EFI_DEVICE_PATH *node, char *suffix) +{ + uint8_t subtype = DevicePathSubType(node); + char *name, *tail; + + tail = efi_make_tail(suffix); + switch (subtype) { + case HW_PCI_DP: + if (asprintf(&name, "Pci(%x,%x)%s", + ((PCI_DEVICE_PATH *)node)->Function, + ((PCI_DEVICE_PATH *)node)->Device, tail) < 0) + name = NULL; + break; + case HW_PCCARD_DP: + if (asprintf(&name, "PCCARD(%x)%s", + ((PCCARD_DEVICE_PATH *)node)->FunctionNumber, tail) < 0) + name = NULL; + break; + case HW_MEMMAP_DP: + if (asprintf(&name, "MMap(%x,%" PRIx64 ",%" PRIx64 ")%s", + ((MEMMAP_DEVICE_PATH *)node)->MemoryType, + ((MEMMAP_DEVICE_PATH *)node)->StartingAddress, + ((MEMMAP_DEVICE_PATH *)node)->EndingAddress, tail) < 0) + name = NULL; + break; + case HW_VENDOR_DP: + name = efi_vendor_path("Hardware", + (VENDOR_DEVICE_PATH *)node, tail); + break; + case HW_CONTROLLER_DP: + if (asprintf(&name, "Ctrl(%x)%s", + ((CONTROLLER_DEVICE_PATH *)node)->Controller, tail) < 0) + name = NULL; + break; + default: + if (asprintf(&name, "UnknownHW(%x)%s", subtype, tail) < 0) + name = NULL; + break; + } + free(tail); + return (name); +} + +static char * +efi_acpi_dev_path(EFI_DEVICE_PATH *node, char *suffix) +{ + uint8_t subtype = DevicePathSubType(node); + ACPI_HID_DEVICE_PATH *acpi = (ACPI_HID_DEVICE_PATH *)node; + char *name, *tail; + + tail = efi_make_tail(suffix); + switch (subtype) { + case ACPI_DP: + if ((acpi->HID & PNP_EISA_ID_MASK) == PNP_EISA_ID_CONST) { + switch (EISA_ID_TO_NUM (acpi->HID)) { + case 0x0a03: + if (asprintf(&name, "PciRoot(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + case 0x0a08: + if (asprintf(&name, "PcieRoot(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + case 0x0604: + if (asprintf(&name, "Floppy(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + case 0x0301: + if (asprintf(&name, "Keyboard(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + case 0x0501: + if (asprintf(&name, "Serial(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + case 0x0401: + if (asprintf(&name, "ParallelPort(%x)%s", + acpi->UID, tail) < 0) + name = NULL; + break; + default: + if (asprintf(&name, "Acpi(PNP%04x,%x)%s", + EISA_ID_TO_NUM(acpi->HID), + acpi->UID, tail) < 0) + name = NULL; + break; + } + } else { + if (asprintf(&name, "Acpi(%08x,%x)%s", + acpi->HID, acpi->UID, tail) < 0) + name = NULL; + } + break; + case ACPI_EXTENDED_DP: + default: + if (asprintf(&name, "UnknownACPI(%x)%s", subtype, tail) < 0) + name = NULL; + break; + } + free(tail); + return (name); +} + +static char * +efi_messaging_dev_path(EFI_DEVICE_PATH *node, char *suffix) +{ + uint8_t subtype = DevicePathSubType(node); + char *name; + char *tail; + + tail = efi_make_tail(suffix); + switch (subtype) { + case MSG_ATAPI_DP: + if (asprintf(&name, "ATA(%s,%s,%x)%s", + ((ATAPI_DEVICE_PATH *)node)->PrimarySecondary == 1 ? + "Secondary" : "Primary", + ((ATAPI_DEVICE_PATH *)node)->SlaveMaster == 1 ? + "Slave" : "Master", + ((ATAPI_DEVICE_PATH *)node)->Lun, tail) < 0) + name = NULL; + break; + case MSG_SCSI_DP: + if (asprintf(&name, "SCSI(%x,%x)%s", + ((SCSI_DEVICE_PATH *)node)->Pun, + ((SCSI_DEVICE_PATH *)node)->Lun, tail) < 0) + name = NULL; + break; + case MSG_FIBRECHANNEL_DP: + if (asprintf(&name, "Fibre(%" PRIx64 ",%" PRIx64 ")%s", + ((FIBRECHANNEL_DEVICE_PATH *)node)->WWN, + ((FIBRECHANNEL_DEVICE_PATH *)node)->Lun, tail) < 0) + name = NULL; + break; + case MSG_1394_DP: + if (asprintf(&name, "I1394(%016" PRIx64 ")%s", + ((F1394_DEVICE_PATH *)node)->Guid, tail) < 0) + name = NULL; + break; + case MSG_USB_DP: + if (asprintf(&name, "USB(%x,%x)%s", + ((USB_DEVICE_PATH *)node)->ParentPortNumber, + ((USB_DEVICE_PATH *)node)->InterfaceNumber, tail) < 0) + name = NULL; + break; + case MSG_USB_CLASS_DP: + if (asprintf(&name, "UsbClass(%x,%x,%x,%x,%x)%s", + ((USB_CLASS_DEVICE_PATH *)node)->VendorId, + ((USB_CLASS_DEVICE_PATH *)node)->ProductId, + ((USB_CLASS_DEVICE_PATH *)node)->DeviceClass, + ((USB_CLASS_DEVICE_PATH *)node)->DeviceSubClass, + ((USB_CLASS_DEVICE_PATH *)node)->DeviceProtocol, tail) < 0) + name = NULL; + break; + case MSG_MAC_ADDR_DP: + if (asprintf(&name, "MAC(%02x:%02x:%02x:%02x:%02x:%02x,%x)%s", + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[0], + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[1], + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[2], + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[3], + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[4], + ((MAC_ADDR_DEVICE_PATH *)node)->MacAddress.Addr[5], + ((MAC_ADDR_DEVICE_PATH *)node)->IfType, tail) < 0) + name = NULL; + break; + case MSG_VENDOR_DP: + name = efi_vendor_path("Messaging", + (VENDOR_DEVICE_PATH *)node, tail); + break; + case MSG_UART_DP: + if (asprintf(&name, "UART(%" PRIu64 ",%u,%x,%x)%s", + ((UART_DEVICE_PATH *)node)->BaudRate, + ((UART_DEVICE_PATH *)node)->DataBits, + ((UART_DEVICE_PATH *)node)->Parity, + ((UART_DEVICE_PATH *)node)->StopBits, tail) < 0) + name = NULL; + break; + case MSG_SATA_DP: + if (asprintf(&name, "Sata(%x,%x,%x)%s", + ((SATA_DEVICE_PATH *)node)->HBAPortNumber, + ((SATA_DEVICE_PATH *)node)->PortMultiplierPortNumber, + ((SATA_DEVICE_PATH *)node)->Lun, tail) < 0) + name = NULL; + break; + default: + if (asprintf(&name, "UnknownMessaging(%x)%s", + subtype, tail) < 0) + name = NULL; + break; + } + free(tail); + return (name); +} + +static char * +efi_media_dev_path(EFI_DEVICE_PATH *node, char *suffix) +{ + uint8_t subtype = DevicePathSubType(node); + HARDDRIVE_DEVICE_PATH *hd; + char *name; + char *str; + char *tail; + int rv; + + tail = efi_make_tail(suffix); + name = NULL; + switch (subtype) { + case MEDIA_HARDDRIVE_DP: + hd = (HARDDRIVE_DEVICE_PATH *)node; + switch (hd->SignatureType) { + case SIGNATURE_TYPE_MBR: + if (asprintf(&name, "HD(%d,MBR,%08x,%" PRIx64 + ",%" PRIx64 ")%s", + hd->PartitionNumber, + *((uint32_t *)(uintptr_t)&hd->Signature[0]), + hd->PartitionStart, + hd->PartitionSize, tail) < 0) + name = NULL; + break; + case SIGNATURE_TYPE_GUID: + name = NULL; + uuid_to_string((const uuid_t *)(void *) + &hd->Signature[0], &str, &rv); + if (rv != uuid_s_ok) + break; + rv = asprintf(&name, "HD(%d,GPT,%s,%" PRIx64 ",%" + PRIx64 ")%s", + hd->PartitionNumber, str, + hd->PartitionStart, hd->PartitionSize, tail); + free(str); + break; + default: + if (asprintf(&name, "HD(%d,%d,0)%s", + hd->PartitionNumber, + hd->SignatureType, tail) < 0) { + name = NULL; + } + break; + } + break; + case MEDIA_CDROM_DP: + if (asprintf(&name, "CD(%x,%" PRIx64 ",%" PRIx64 ")%s", + ((CDROM_DEVICE_PATH *)node)->BootEntry, + ((CDROM_DEVICE_PATH *)node)->PartitionStart, + ((CDROM_DEVICE_PATH *)node)->PartitionSize, tail) < 0) { + name = NULL; + } + break; + case MEDIA_VENDOR_DP: + name = efi_vendor_path("Media", + (VENDOR_DEVICE_PATH *)node, tail); + break; + case MEDIA_FILEPATH_DP: + name = NULL; + str = NULL; + if (ucs2_to_utf8(((FILEPATH_DEVICE_PATH *)node)->PathName, + &str) == 0) { + (void)asprintf(&name, "%s%s", str, tail); + free(str); + } + break; + case MEDIA_PROTOCOL_DP: + name = NULL; + uuid_to_string((const uuid_t *)(void *) + &((MEDIA_PROTOCOL_DEVICE_PATH *)node)->Protocol, + &str, &rv); + if (rv != uuid_s_ok) + break; + rv = asprintf(&name, "Protocol(%s)%s", str, tail); + free(str); + break; + default: + if (asprintf(&name, "UnknownMedia(%x)%s", + subtype, tail) < 0) + name = NULL; + } + free(tail); + return (name); +} + +static char * +efi_translate_devpath(EFI_DEVICE_PATH *devpath) +{ + EFI_DEVICE_PATH *dp = NextDevicePathNode(devpath); + char *name, *ptr; + uint8_t type; + + if (!IsDevicePathEnd(devpath)) + name = efi_translate_devpath(dp); + else + return (NULL); + + ptr = NULL; + type = DevicePathType(devpath); + switch (type) { + case HARDWARE_DEVICE_PATH: + ptr = efi_hw_dev_path(devpath, name); + break; + case ACPI_DEVICE_PATH: + ptr = efi_acpi_dev_path(devpath, name); + break; + case MESSAGING_DEVICE_PATH: + ptr = efi_messaging_dev_path(devpath, name); + break; + case MEDIA_DEVICE_PATH: + ptr = efi_media_dev_path(devpath, name); + break; + case BBS_DEVICE_PATH: + default: + if (asprintf(&ptr, "UnknownPath(%x)%s", type, + name? name : "") < 0) + ptr = NULL; + break; + } + + if (ptr != NULL) { + free(name); + name = ptr; + } + return (name); +} + +static CHAR16 * +efi_devpath_to_name(EFI_DEVICE_PATH *devpath) +{ + char *name = NULL; + CHAR16 *ptr = NULL; + size_t len; + int rv; + + name = efi_translate_devpath(devpath); + if (name == NULL) + return (NULL); + + /* + * We need to return memory from AllocatePool, so it can be freed + * with FreePool() in efi_free_devpath_name(). + */ + rv = utf8_to_ucs2(name, &ptr, &len); + free(name); + if (rv == 0) { + CHAR16 *out = NULL; + EFI_STATUS status; + + status = BS->AllocatePool(EfiLoaderData, len, (void **)&out); + if (EFI_ERROR(status)) { + free(ptr); + return (out); + } + memcpy(out, ptr, len); + free(ptr); + ptr = out; + } + + return (ptr); +} + CHAR16 * efi_devpath_name(EFI_DEVICE_PATH *devpath) { @@ -79,7 +503,7 @@ efi_devpath_name(EFI_DEVICE_PATH *devpath) toTextProtocol = NULL; } if (toTextProtocol == NULL) - return (NULL); + return (efi_devpath_to_name(devpath)); return (toTextProtocol->ConvertDevicePathToText(devpath, TRUE, TRUE)); } @@ -87,8 +511,8 @@ efi_devpath_name(EFI_DEVICE_PATH *devpath) void efi_free_devpath_name(CHAR16 *text) { - - BS->FreePool(text); + if (text != NULL) + BS->FreePool(text); } EFI_DEVICE_PATH * From owner-svn-src-stable@freebsd.org Thu Nov 14 12:07:50 2019 Return-Path: Delivered-To: svn-src-stable@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 29EFB17E7EB; Thu, 14 Nov 2019 12:07:50 +0000 (UTC) (envelope-from ae@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 47DKxK6mRbz3x5L; Thu, 14 Nov 2019 12:07:49 +0000 (UTC) (envelope-from ae@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 AFEFA27F59; Thu, 14 Nov 2019 12:07:49 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAEC7nx8094252; Thu, 14 Nov 2019 12:07:49 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAEC7nOc094251; Thu, 14 Nov 2019 12:07:49 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201911141207.xAEC7nOc094251@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 14 Nov 2019 12:07: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: r354705 - stable/12/sys/net X-SVN-Group: stable-12 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/12/sys/net X-SVN-Commit-Revision: 354705 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Nov 2019 12:07:50 -0000 Author: ae Date: Thu Nov 14 12:07:49 2019 New Revision: 354705 URL: https://svnweb.freebsd.org/changeset/base/354705 Log: MFC r354443: Enqueue lladdr_task to update link level address of vlan, when its parent interface has changed. During vlan reconfiguration without destroying interface, it is possible, that parent interface will be changed. This usually means, that link layer address of vlan will be different. Therefore we need to update all associated with vlan's addresses permanent llentries - NDP for IPv6 addresses, and ARP for IPv4 addresses. This is done via lladdr_task execution. To avoid extra work, before execution do the check, that L2 address is different. Modified: stable/12/sys/net/if_vlan.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/net/if_vlan.c ============================================================================== --- stable/12/sys/net/if_vlan.c Thu Nov 14 09:39:03 2019 (r354704) +++ stable/12/sys/net/if_vlan.c Thu Nov 14 12:07:49 2019 (r354705) @@ -1408,11 +1408,19 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, uint1 * Set up our interface address to reflect the underlying * physical interface's. */ - bcopy(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen); + TASK_INIT(&ifv->lladdr_task, 0, vlan_lladdr_fn, ifv); ((struct sockaddr_dl *)ifp->if_addr->ifa_addr)->sdl_alen = p->if_addrlen; - TASK_INIT(&ifv->lladdr_task, 0, vlan_lladdr_fn, ifv); + /* + * Do not schedule link address update if it was the same + * as previous parent's. This helps avoid updating for each + * associated llentry. + */ + if (memcmp(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen) != 0) { + bcopy(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen); + taskqueue_enqueue(taskqueue_thread, &ifv->lladdr_task); + } /* We are ready for operation now. */ ifp->if_drv_flags |= IFF_DRV_RUNNING; From owner-svn-src-stable@freebsd.org Thu Nov 14 12:14:56 2019 Return-Path: Delivered-To: svn-src-stable@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 4DB5417EA83; Thu, 14 Nov 2019 12:14:56 +0000 (UTC) (envelope-from ae@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 47DL5X0B0nz43ST; Thu, 14 Nov 2019 12:14:55 +0000 (UTC) (envelope-from ae@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 A403114E; Thu, 14 Nov 2019 12:14:55 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAECEt0n000157; Thu, 14 Nov 2019 12:14:55 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAECEtqX000156; Thu, 14 Nov 2019 12:14:55 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201911141214.xAECEtqX000156@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 14 Nov 2019 12:14:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354706 - stable/11/sys/net X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/net X-SVN-Commit-Revision: 354706 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Nov 2019 12:14:56 -0000 Author: ae Date: Thu Nov 14 12:14:55 2019 New Revision: 354706 URL: https://svnweb.freebsd.org/changeset/base/354706 Log: MFC r354443: Enqueue lladdr_task to update link level address of vlan, when its parent interface has changed. During vlan reconfiguration without destroying interface, it is possible, that parent interface will be changed. This usually means, that link layer address of vlan will be different. Therefore we need to update all associated with vlan's addresses permanent llentries - NDP for IPv6 addresses, and ARP for IPv4 addresses. This is done via lladdr_task execution. To avoid extra work, before execution do the check, that L2 address is different. Modified: stable/11/sys/net/if_vlan.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/net/if_vlan.c ============================================================================== --- stable/11/sys/net/if_vlan.c Thu Nov 14 12:07:49 2019 (r354705) +++ stable/11/sys/net/if_vlan.c Thu Nov 14 12:14:55 2019 (r354706) @@ -1424,17 +1424,25 @@ vlan_config(struct ifvlan *ifv, struct ifnet *p, uint1 * Set up our interface address to reflect the underlying * physical interface's. */ - bcopy(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen); + TASK_INIT(&ifv->lladdr_task, 0, vlan_lladdr_fn, ifv); ((struct sockaddr_dl *)ifp->if_addr->ifa_addr)->sdl_alen = p->if_addrlen; /* + * Do not schedule link address update if it was the same + * as previous parent's. This helps avoid updating for each + * associated llentry. + */ + if (memcmp(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen) != 0) { + bcopy(IF_LLADDR(p), IF_LLADDR(ifp), p->if_addrlen); + taskqueue_enqueue(taskqueue_thread, &ifv->lladdr_task); + } + + /* * Configure multicast addresses that may already be * joined on the vlan device. */ (void)vlan_setmulti(ifp); - - TASK_INIT(&ifv->lladdr_task, 0, vlan_lladdr_fn, ifv); /* We are ready for operation now. */ ifp->if_drv_flags |= IFF_DRV_RUNNING; From owner-svn-src-stable@freebsd.org Fri Nov 15 07:01:07 2019 Return-Path: Delivered-To: svn-src-stable@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 900421BE58D; Fri, 15 Nov 2019 07:01: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 47Dq4z3LZxz4fTP; Fri, 15 Nov 2019 07:01: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 55F41D1A4; Fri, 15 Nov 2019 07:01: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 xAF717D9071518; Fri, 15 Nov 2019 07:01:07 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAF714pR071505; Fri, 15 Nov 2019 07:01:04 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201911150701.xAF714pR071505@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Fri, 15 Nov 2019 07:01:04 +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: r354725 - in stable/12: libexec/rc libexec/rc/rc.d sbin/init share/examples/jails share/man/man5 share/man/man8 usr.sbin/jail X-SVN-Group: stable-12 X-SVN-Commit-Author: avg X-SVN-Commit-Paths: in stable/12: libexec/rc libexec/rc/rc.d sbin/init share/examples/jails share/man/man5 share/man/man8 usr.sbin/jail X-SVN-Commit-Revision: 354725 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2019 07:01:07 -0000 Author: avg Date: Fri Nov 15 07:01:04 2019 New Revision: 354725 URL: https://svnweb.freebsd.org/changeset/base/354725 Log: MFC r353039: add ability to set watchdog timeout for a shutdown This change allows to specify a watchdog(9) timeout for a system shutdown. The timeout is activated when the watchdogd daemon is stopped. The idea is to a prevent any indefinite hang during late stages of the shutdown. The feature is implemented in rc.d/watchdogd, it builds upon watchdogd -x option. Note that the shutdown timeout is not actiavted when the watchdogd service is individually stopped by an operator. It is also not activated for the 'shutdown' to the single-user mode. In those cases it is assumed that the operator knows what they are doing and they have means to recover the system should it hang. Significant subchanges and implementation details: - the argument to rc.shutdown, completely unused before, is assigned to rc_shutdown variable that can be inspected by rc scripts - init(8) passes "single" or "reboot" as the argument, this is not changed - the argument is not mandatory and if it is not set then rc_shutdown is set to "unspecified" - however, the default jail management scripts and jail configuration examples have been updated to pass "jail" to rc.shutdown, just in case - the new timeout can be set via watchdogd_shutdown_timeout rc option - for consistency, the regular timeout can now be set via watchdogd_timeout rc option - watchdogd_shutdown_timeout and watchdogd_timeout override timeout specifications in watchdogd_flags - existing configurations, where the new rc options are not set, should keep working as before Modified: stable/12/libexec/rc/rc.conf stable/12/libexec/rc/rc.d/jail stable/12/libexec/rc/rc.d/watchdogd stable/12/libexec/rc/rc.shutdown stable/12/sbin/init/init.8 stable/12/share/examples/jails/jail.xxx.conf stable/12/share/examples/jails/jib stable/12/share/examples/jails/jng stable/12/share/man/man5/rc.conf.5 stable/12/share/man/man8/rc.8 stable/12/usr.sbin/jail/jail.8 stable/12/usr.sbin/jail/jail.conf.5 Directory Properties: stable/12/ (props changed) Modified: stable/12/libexec/rc/rc.conf ============================================================================== --- stable/12/libexec/rc/rc.conf Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/libexec/rc/rc.conf Fri Nov 15 07:01:04 2019 (r354725) @@ -683,6 +683,10 @@ harvest_mask="511" # Entropy device harvests all but t dmesg_enable="YES" # Save dmesg(8) to /var/run/dmesg.boot watchdogd_enable="NO" # Start the software watchdog daemon watchdogd_flags="" # Flags to watchdogd (if enabled) +watchdogd_timeout="" # watchdogd timeout, overrides -t in watchdogd_flags +watchdogd_shutdown_timeout="" # Timeout to use after watchdogd is stopped. + # Has effect only for system shutdown. + # Overrides -x in watchdogd_flags. devfs_rulesets="/etc/defaults/devfs.rules /etc/devfs.rules" # Files containing # devfs(8) rules. devfs_system_ruleset="" # The name (NOT number) of a ruleset to apply to /dev Modified: stable/12/libexec/rc/rc.d/jail ============================================================================== --- stable/12/libexec/rc/rc.d/jail Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/libexec/rc/rc.d/jail Fri Nov 15 07:01:04 2019 (r354725) @@ -168,7 +168,7 @@ parse_options() if [ -z "${_exec_start}" ]; then _exec_start="/bin/sh /etc/rc" if [ -z "${_exec_stop}" ]; then - _exec_stop="/bin/sh /etc/rc.shutdown" + _exec_stop="/bin/sh /etc/rc.shutdown jail" fi fi fi Modified: stable/12/libexec/rc/rc.d/watchdogd ============================================================================== --- stable/12/libexec/rc/rc.d/watchdogd Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/libexec/rc/rc.d/watchdogd Fri Nov 15 07:01:04 2019 (r354725) @@ -38,9 +38,55 @@ desc="Watchdog daemon" rcvar="watchdogd_enable" command="/usr/sbin/${name}" pidfile="/var/run/${name}.pid" +start_precmd="watchdogd_prestart" +stop_precmd="watchdogd_prestop" +stop_postcmd="watchdogd_poststop" +watchdog_command="/usr/sbin/watchdog" -load_rc_config $name +watchdogd_prestart() +{ + if [ -n "${watchdogd_timeout}" ] ; then + rc_flags="${rc_flags} -t ${watchdogd_timeout}" + fi + if [ -n "$watchdogd_shutdown_timeout" ] ; then + rc_flags="${rc_flags} -x ${watchdogd_shutdown_timeout}" + fi + return 0 +} -sig_stop="${watchdogd_sig_stop:-TERM}" +watchdogd_prestop() +{ + sig_stop="${watchdogd_sig_stop:-TERM}" +} +watchdogd_poststop() +{ + if [ ${watchdogd_shutdown_timeout:-0} -gt 0 ] ; then + case "${rc_shutdown}" in + "reboot") + info "watchdog timer is set to" \ + ${watchdogd_shutdown_timeout} "before shutdown" + return 0 + ;; + "single") + info "watchdog timer is disabled before going to" \ + "single user mode" + ${watchdog_command} -t 0 + ;; + "") + info "watchdog timer is disabled after administrative" \ + "${name} stop" + ${watchdog_command} -t 0 + ;; + *) + warn "unknown shutdown mode '${rc_shutdown}'" + warn "watchdog timer is set to ${watchdogd_shutdown_timeout}" + return 0 + ;; + esac + fi + return 0 +} + +load_rc_config $name run_rc_command "$1" Modified: stable/12/libexec/rc/rc.shutdown ============================================================================== --- stable/12/libexec/rc/rc.shutdown Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/libexec/rc/rc.shutdown Fri Nov 15 07:01:04 2019 (r354725) @@ -43,6 +43,8 @@ HOME=/ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin export HOME PATH +rc_shutdown=${1:-"unspecified"} + . /etc/rc.subr load_rc_config Modified: stable/12/sbin/init/init.8 ============================================================================== --- stable/12/sbin/init/init.8 Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/sbin/init/init.8 Fri Nov 15 07:01:04 2019 (r354725) @@ -31,7 +31,7 @@ .\" @(#)init.8 8.3 (Berkeley) 4/18/94 .\" $FreeBSD$ .\" -.Dd August 15, 2018 +.Dd August 6, 2019 .Dt INIT 8 .Os .Sh NAME @@ -269,6 +269,15 @@ The timeout can be configured via the .Xr sysctl 8 variable .Va kern.init_shutdown_timeout . +.Pp +.Nm init +passes +.Dq Li single +as the argument to the shutdown script if return to single-user mode +is requested. +Otherwise, +.Dq Li reboot +argument is used. .Pp The role of .Nm Modified: stable/12/share/examples/jails/jail.xxx.conf ============================================================================== --- stable/12/share/examples/jails/jail.xxx.conf Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/share/examples/jails/jail.xxx.conf Fri Nov 15 07:01:04 2019 (r354725) @@ -23,7 +23,7 @@ xxx { # Standard recipe exec.start += "/bin/sh /etc/rc"; - exec.stop = "/bin/sh /etc/rc.shutdown"; + exec.stop = "/bin/sh /etc/rc.shutdown jail"; exec.consolelog = "/var/log/jail_xxx_console.log"; mount.devfs; # mount devfs Modified: stable/12/share/examples/jails/jib ============================================================================== --- stable/12/share/examples/jails/jib Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/share/examples/jails/jib Fri Nov 15 07:01:04 2019 (r354725) @@ -67,7 +67,7 @@ # # # Standard recipe # exec.start += "/bin/sh /etc/rc"; -# exec.stop = "/bin/sh /etc/rc.shutdown"; +# exec.stop = "/bin/sh /etc/rc.shutdown jail"; # exec.consolelog = "/var/log/jail_xxx_console.log"; # mount.devfs; # Modified: stable/12/share/examples/jails/jng ============================================================================== --- stable/12/share/examples/jails/jng Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/share/examples/jails/jng Fri Nov 15 07:01:04 2019 (r354725) @@ -67,7 +67,7 @@ # # # Standard recipe # exec.start += "/bin/sh /etc/rc"; -# exec.stop = "/bin/sh /etc/rc.shutdown"; +# exec.stop = "/bin/sh /etc/rc.shutdown jail"; # exec.consolelog = "/var/log/jail_xxx_console.log"; # mount.devfs; # Modified: stable/12/share/man/man5/rc.conf.5 ============================================================================== --- stable/12/share/man/man5/rc.conf.5 Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/share/man/man5/rc.conf.5 Fri Nov 15 07:01:04 2019 (r354725) @@ -3753,6 +3753,41 @@ is set to these are the flags passed to the .Xr watchdogd 8 daemon. +.It Va watchdogd_timeout +.Pq Vt int +If +.Va watchdogd_enable +is set to +.Dq Li YES , +this is a timeout that will be used by the +.Xr watchdogd 8 +daemon. +If this option is set, it overrides +.Fl t +in +.Va watchdogd_flags . +.It Va watchdogd_shutdown_timeout +.Pq Vt int +If +.Va watchdogd_enable +is set to +.Dq Li YES , +this is a timeout that will be set by the +.Xr watchdogd 8 +daemon when it exits during the system shutdown. +This timeout will not be set when returning to the single-user mode +or when the watchdogd service is stopped individually using the +.Xr service 8 +command or the rc.d script. +Note that the timeout will be applied if +.Xr watchdogd 8 +is stopped outside of +.Xr rc 8 +framework. +If this option is set, it overrides +.Fl x +in +.Va watchdogd_flags . .It Va devfs_rulesets .Pq Vt str List of files containing sets of rules for Modified: stable/12/share/man/man8/rc.8 ============================================================================== --- stable/12/share/man/man8/rc.8 Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/share/man/man8/rc.8 Fri Nov 15 07:01:04 2019 (r354725) @@ -189,6 +189,14 @@ also exists (because it was created by a script), then .Ss Operation of Nm rc.shutdown .Bl -enum .It +Set +.Va rc_shutdown +to the value of the first argument passed to +.Nm rc.shutdown +or to +.Dq Li unspecified +if no argument was passed. +.It Source .Pa /etc/rc.subr to load various Modified: stable/12/usr.sbin/jail/jail.8 ============================================================================== --- stable/12/usr.sbin/jail/jail.8 Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/usr.sbin/jail/jail.8 Fri Nov 15 07:01:04 2019 (r354725) @@ -25,7 +25,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 27, 2018 +.Dd August 6, 2019 .Dt JAIL 8 .Os .Sh NAME @@ -679,7 +679,7 @@ A value of .Dq inherit will keep the same environment, and .Dq new -will give the jail it's own environment (still originally inherited when +will give the jail its own environment (still originally inherited when the jail is created). .It Va linux.osname , linux.osrelease , linux.oss_version The Linux OS name, OS release, and OSS version associated with this jail. @@ -752,7 +752,7 @@ and after any .Va exec.prestop commands have completed. A typical command to run is -.Dq sh /etc/rc.shutdown . +.Dq sh /etc/rc.shutdown jail . .It Va exec.poststop Command(s) to run in the system environment after a jail is removed. .It Va exec.clean @@ -1101,7 +1101,7 @@ testjail { ip4.addr = 192.0.2.100; interface = ed0; exec.start = "/bin/sh /etc/rc"; - exec.stop = "/bin/sh /etc/rc.shutdown"; + exec.stop = "/bin/sh /etc/rc.shutdown jail"; } .Ed .Pp Modified: stable/12/usr.sbin/jail/jail.conf.5 ============================================================================== --- stable/12/usr.sbin/jail/jail.conf.5 Fri Nov 15 06:56:25 2019 (r354724) +++ stable/12/usr.sbin/jail/jail.conf.5 Fri Nov 15 07:01:04 2019 (r354725) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 13, 2014 +.Dd August 6, 2019 .Dt JAIL.CONF 5 .Os .Sh NAME @@ -182,7 +182,7 @@ in the middle of a string or a token. # Typical static defaults: # Use the rc scripts to start and stop jails. Mount jail's /dev. exec.start = "/bin/sh /etc/rc"; -exec.stop = "/bin/sh /etc/rc.shutdown"; +exec.stop = "/bin/sh /etc/rc.shutdown jail"; exec.clean; mount.devfs; From owner-svn-src-stable@freebsd.org Fri Nov 15 16:40:11 2019 Return-Path: Delivered-To: svn-src-stable@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 7CD111AA5BE; Fri, 15 Nov 2019 16:40:11 +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 47F3x721hlz4CTx; Fri, 15 Nov 2019 16:40:11 +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 12BE81BA80; Fri, 15 Nov 2019 16:40:11 +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 xAFGeAgU018423; Fri, 15 Nov 2019 16:40:10 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAFGeA75018422; Fri, 15 Nov 2019 16:40:10 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201911151640.xAFGeA75018422@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 15 Nov 2019 16:40:10 +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: r354734 - stable/12/sys/kern X-SVN-Group: stable-12 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/12/sys/kern X-SVN-Commit-Revision: 354734 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2019 16:40:11 -0000 Author: emaste Date: Fri Nov 15 16:40:10 2019 New Revision: 354734 URL: https://svnweb.freebsd.org/changeset/base/354734 Log: MFC r354228: avoid kernel stack data leak in core dump thrmisc note bzero the entire thrmisc struct, not just the padding. Other core dump notes are already done this way. Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/kern/imgact_elf.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/kern/imgact_elf.c ============================================================================== --- stable/12/sys/kern/imgact_elf.c Fri Nov 15 16:34:35 2019 (r354733) +++ stable/12/sys/kern/imgact_elf.c Fri Nov 15 16:40:10 2019 (r354734) @@ -2233,7 +2233,7 @@ __elfN(note_thrmisc)(void *arg, struct sbuf *sb, size_ td = (struct thread *)arg; if (sb != NULL) { KASSERT(*sizep == sizeof(thrmisc), ("invalid size")); - bzero(&thrmisc._pad, sizeof(thrmisc._pad)); + bzero(&thrmisc, sizeof(thrmisc)); strcpy(thrmisc.pr_tname, td->td_name); sbuf_bcat(sb, &thrmisc, sizeof(thrmisc)); } From owner-svn-src-stable@freebsd.org Fri Nov 15 16:40:55 2019 Return-Path: Delivered-To: svn-src-stable@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 CE4431AA773; Fri, 15 Nov 2019 16:40:55 +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 47F3xz4q0Zz4F0r; Fri, 15 Nov 2019 16:40:55 +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 7F7CC1BAA2; Fri, 15 Nov 2019 16:40:55 +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 xAFGetHc019141; Fri, 15 Nov 2019 16:40:55 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAFGetj3019140; Fri, 15 Nov 2019 16:40:55 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201911151640.xAFGetj3019140@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 15 Nov 2019 16:40:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354735 - stable/11/sys/kern X-SVN-Group: stable-11 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: stable/11/sys/kern X-SVN-Commit-Revision: 354735 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2019 16:40:55 -0000 Author: emaste Date: Fri Nov 15 16:40:55 2019 New Revision: 354735 URL: https://svnweb.freebsd.org/changeset/base/354735 Log: MFC r354228: avoid kernel stack data leak in core dump thrmisc note bzero the entire thrmisc struct, not just the padding. Other core dump notes are already done this way. Sponsored by: The FreeBSD Foundation Modified: stable/11/sys/kern/imgact_elf.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/imgact_elf.c ============================================================================== --- stable/11/sys/kern/imgact_elf.c Fri Nov 15 16:40:10 2019 (r354734) +++ stable/11/sys/kern/imgact_elf.c Fri Nov 15 16:40:55 2019 (r354735) @@ -2008,7 +2008,7 @@ __elfN(note_thrmisc)(void *arg, struct sbuf *sb, size_ td = (struct thread *)arg; if (sb != NULL) { KASSERT(*sizep == sizeof(thrmisc), ("invalid size")); - bzero(&thrmisc._pad, sizeof(thrmisc._pad)); + bzero(&thrmisc, sizeof(thrmisc)); strcpy(thrmisc.pr_tname, td->td_name); sbuf_bcat(sb, &thrmisc, sizeof(thrmisc)); } From owner-svn-src-stable@freebsd.org Sat Nov 16 00:29:30 2019 Return-Path: Delivered-To: svn-src-stable@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 204581B4D4C; Sat, 16 Nov 2019 00:29:30 +0000 (UTC) (envelope-from scottl@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 47FGLc4pQWz4Dnl; Sat, 16 Nov 2019 00:29:28 +0000 (UTC) (envelope-from scottl@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 0A176210E2; Sat, 16 Nov 2019 00:29:28 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAG0TRJC097354; Sat, 16 Nov 2019 00:29:27 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAG0TQh9097347; Sat, 16 Nov 2019 00:29:26 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911160029.xAG0TQh9097347@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sat, 16 Nov 2019 00:29:26 +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: r354760 - in stable/12/sys: amd64/amd64 dev/cpuctl kern sys x86/include x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 dev/cpuctl kern sys x86/include x86/x86 X-SVN-Commit-Revision: 354760 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 00:29:30 -0000 Author: scottl Date: Sat Nov 16 00:29:26 2019 New Revision: 354760 URL: https://svnweb.freebsd.org/changeset/base/354760 Log: MFC r354756: Create a new sysctl tree, machdep.mitigations Sponsored by: Intel Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/dev/cpuctl/cpuctl.c stable/12/sys/kern/kern_mib.c stable/12/sys/sys/sysctl.h stable/12/sys/x86/include/x86_var.h stable/12/sys/x86/x86/cpu_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:29:26 2019 (r354760) @@ -1790,6 +1790,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush", &syscall_ret_l1d_flush_mode); TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); + TUNABLE_INT_FETCH("hw.tsx_disable", &hw_tsx_disable); finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ Modified: stable/12/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:29:26 2019 (r354760) @@ -546,6 +546,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td pmap_allow_2m_x_ept_recalculate(); #endif hw_mds_recalculate(); + hw_tsx_recalculate(); printcpuinfo(); return (0); } Modified: stable/12/sys/kern/kern_mib.c ============================================================================== --- stable/12/sys/kern/kern_mib.c Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/kern/kern_mib.c Sat Nov 16 00:29:26 2019 (r354760) @@ -78,6 +78,8 @@ SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, "hardware"); SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, "machine dependent"); +SYSCTL_NODE(_machdep, OID_AUTO, mitigations, CTLFLAG_RW, 0, + "Machine dependent platform mitigations."); SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, "user-level"); SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, Modified: stable/12/sys/sys/sysctl.h ============================================================================== --- stable/12/sys/sys/sysctl.h Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/sys/sysctl.h Sat Nov 16 00:29:26 2019 (r354760) @@ -1056,6 +1056,7 @@ SYSCTL_DECL(_hw_bus); SYSCTL_DECL(_hw_bus_devices); SYSCTL_DECL(_hw_bus_info); SYSCTL_DECL(_machdep); +SYSCTL_DECL(_machdep_mitigations); SYSCTL_DECL(_user); SYSCTL_DECL(_compat); SYSCTL_DECL(_regression); Modified: stable/12/sys/x86/include/x86_var.h ============================================================================== --- stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:29:26 2019 (r354760) @@ -87,6 +87,7 @@ extern int pti; extern int hw_ibrs_active; extern int hw_mds_disable; extern int hw_ssb_active; +extern int hw_tsx_disable; struct pcb; struct thread; @@ -143,6 +144,7 @@ void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); +void hw_tsx_recalculate(void); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); void nmi_handle_intr(u_int type, struct trapframe *frame); Modified: stable/12/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:26:42 2019 (r354759) +++ stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:29:26 2019 (r354760) @@ -1120,6 +1120,187 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | "Microarchitectural Data Sampling Mitigation " "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); +int hw_tsx_disable; +int hw_tsx_state; +enum { + TSX_TAA_NONE = 0, + TSX_TAA_DISABLE = 1, + TSX_TAA_VERW = 2, + TSX_TAA_AUTO = 3 +}; + +static void +hw_tsx_set_one(bool enable) +{ + uint64_t v; + + v = rdmsr(MSR_IA32_TSX_CTRL); + if (enable) + v |= (uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + else + v &= ~(uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + + wrmsr(MSR_IA32_TSX_CTRL, v); +} + +static void +hw_tsx_set(bool enable, bool all) +{ + struct thread *td; + int bound_cpu, i, is_bound; + + if (all) { + td = curthread; + thread_lock(td); + is_bound = sched_is_bound(td); + bound_cpu = td->td_oncpu; + CPU_FOREACH(i) { + sched_bind(td, i); + hw_tsx_set_one(enable); + } + if (is_bound) + sched_bind(td, bound_cpu); + else + sched_unbind(td); + thread_unlock(td); + } else + hw_tsx_set_one(enable); + +} + +void +hw_tsx_recalculate(void) +{ + static int tsx_saved_mds_disable = 0; + int tsx_need = 0, tsx_state = 0; + int mds_disable = 0, need_mds_recalc = 0; + + /* Check CPUID.07h.EBX.HLE and RTM for the presence of TSX */ + if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 || + (cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) { + /* TSX is not present */ + hw_tsx_state = 0; + return; + } + + /* Check to see what mitigation options the CPU gives us */ + if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) + tsx_need = TSX_TAA_NONE; + else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) + tsx_need = TSX_TAA_DISABLE; + else { + /* No TSX specific remedies are available. */ + if (hw_tsx_disable == TSX_TAA_DISABLE) { + /* The user asked for the disable option, but + * it's not available. */ + if (bootverbose) + printf("TSX control not available\n"); + return; + } else + tsx_need = TSX_TAA_VERW; + } + + /* Can we automatically take action, or are we being forced? */ + if (hw_tsx_disable == TSX_TAA_AUTO) + tsx_state = tsx_need; + else + tsx_state = hw_tsx_disable; + + /* No state change, nothing to do */ + if (tsx_state == hw_tsx_state) { + if (bootverbose) + printf("No TSX change made\n"); + return; + } + + /* Does the MSR need to be turned on or off? */ + if (tsx_state == TSX_TAA_DISABLE) + hw_tsx_set(1 /* enable */, 1 /* all */); + else if (hw_tsx_state == TSX_TAA_DISABLE) + hw_tsx_set(0 /* disable */, 1 /* all */); + + /* Does MDS need to be set to turn on VERW? */ + if (tsx_state == TSX_TAA_VERW) { + tsx_saved_mds_disable = hw_mds_disable; + mds_disable = hw_mds_disable = 1; + need_mds_recalc = 1; + } else if (hw_tsx_state == TSX_TAA_VERW) { + mds_disable = hw_mds_disable = tsx_saved_mds_disable; + need_mds_recalc = 1; + } + if (need_mds_recalc) { + hw_mds_recalculate(); + if (mds_disable != hw_mds_disable) { + if (bootverbose) + printf("Cannot change MDS state for TSX\n"); + /* Don't update our state */ + return; + } + } + + hw_tsx_state = tsx_state; + return; +} + +static void +hw_tsx_recalculate_boot(void * arg __unused) +{ + + hw_tsx_recalculate(); +} +SYSINIT(tsx_recalc, SI_SUB_SMP, SI_ORDER_ANY, hw_tsx_recalculate_boot, NULL); + +static int +sysctl_tsx_disable_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = hw_tsx_disable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < 0 || val > 3) + return (EINVAL); + hw_tsx_disable = val; + hw_tsx_recalculate(); + return (0); +} + +SYSCTL_PROC(_hw, OID_AUTO, tsx_disable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_tsx_disable_handler, "I", + "TSX Asynchronous Abort Mitigation " + "(0 - off, 1 - disable TSX, 2 - MDS/VERW, 3 - on AUTO"); + +static int +sysctl_hw_tsx_disable_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + switch (hw_tsx_state) { + case TSX_TAA_NONE: + state = "inactive"; + break; + case TSX_TAA_DISABLE: + state = "TSX disabled"; + break; + case TSX_TAA_VERW: + state = "MDS/VERW"; + break; + default: + state = "unknown"; + } + + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_hw, OID_AUTO, tsx_disable_state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_hw_tsx_disable_state_handler, "A", + "Transactional Memory Asynchronous Abort Mitigation state"); + /* * Enable and restore kernel text write permissions. * Callers must ensure that disable_wp()/restore_wp() are executed From owner-svn-src-stable@freebsd.org Sat Nov 16 00:31:59 2019 Return-Path: Delivered-To: svn-src-stable@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 8B9141B4F3C; Sat, 16 Nov 2019 00:31:59 +0000 (UTC) (envelope-from scottl@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 47FGPW24h2z4HLt; Sat, 16 Nov 2019 00:31:59 +0000 (UTC) (envelope-from scottl@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 A94B82125D; Sat, 16 Nov 2019 00:31:58 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAG0VwH1002849; Sat, 16 Nov 2019 00:31:58 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAG0VvA5002844; Sat, 16 Nov 2019 00:31:57 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911160031.xAG0VvA5002844@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sat, 16 Nov 2019 00:31: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: r354761 - in stable/12/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Commit-Revision: 354761 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 00:31:59 -0000 Author: scottl Date: Sat Nov 16 00:31:57 2019 New Revision: 354761 URL: https://svnweb.freebsd.org/changeset/base/354761 Log: Partially revert r354760, it included a patch that wasn't ready yet. Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/dev/cpuctl/cpuctl.c stable/12/sys/x86/include/x86_var.h stable/12/sys/x86/x86/cpu_machdep.c Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:29:26 2019 (r354760) +++ stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:31:57 2019 (r354761) @@ -1790,7 +1790,6 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush", &syscall_ret_l1d_flush_mode); TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); - TUNABLE_INT_FETCH("hw.tsx_disable", &hw_tsx_disable); finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ Modified: stable/12/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:29:26 2019 (r354760) +++ stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:31:57 2019 (r354761) @@ -546,7 +546,6 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td pmap_allow_2m_x_ept_recalculate(); #endif hw_mds_recalculate(); - hw_tsx_recalculate(); printcpuinfo(); return (0); } Modified: stable/12/sys/x86/include/x86_var.h ============================================================================== --- stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:29:26 2019 (r354760) +++ stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:31:57 2019 (r354761) @@ -87,7 +87,6 @@ extern int pti; extern int hw_ibrs_active; extern int hw_mds_disable; extern int hw_ssb_active; -extern int hw_tsx_disable; struct pcb; struct thread; @@ -144,7 +143,6 @@ void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); -void hw_tsx_recalculate(void); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); void nmi_handle_intr(u_int type, struct trapframe *frame); Modified: stable/12/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:29:26 2019 (r354760) +++ stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:31:57 2019 (r354761) @@ -1120,187 +1120,6 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | "Microarchitectural Data Sampling Mitigation " "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); -int hw_tsx_disable; -int hw_tsx_state; -enum { - TSX_TAA_NONE = 0, - TSX_TAA_DISABLE = 1, - TSX_TAA_VERW = 2, - TSX_TAA_AUTO = 3 -}; - -static void -hw_tsx_set_one(bool enable) -{ - uint64_t v; - - v = rdmsr(MSR_IA32_TSX_CTRL); - if (enable) - v |= (uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | - IA32_TSX_CTRL_TSX_CPUID_CLEAR); - else - v &= ~(uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | - IA32_TSX_CTRL_TSX_CPUID_CLEAR); - - wrmsr(MSR_IA32_TSX_CTRL, v); -} - -static void -hw_tsx_set(bool enable, bool all) -{ - struct thread *td; - int bound_cpu, i, is_bound; - - if (all) { - td = curthread; - thread_lock(td); - is_bound = sched_is_bound(td); - bound_cpu = td->td_oncpu; - CPU_FOREACH(i) { - sched_bind(td, i); - hw_tsx_set_one(enable); - } - if (is_bound) - sched_bind(td, bound_cpu); - else - sched_unbind(td); - thread_unlock(td); - } else - hw_tsx_set_one(enable); - -} - -void -hw_tsx_recalculate(void) -{ - static int tsx_saved_mds_disable = 0; - int tsx_need = 0, tsx_state = 0; - int mds_disable = 0, need_mds_recalc = 0; - - /* Check CPUID.07h.EBX.HLE and RTM for the presence of TSX */ - if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 || - (cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) { - /* TSX is not present */ - hw_tsx_state = 0; - return; - } - - /* Check to see what mitigation options the CPU gives us */ - if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) - tsx_need = TSX_TAA_NONE; - else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) - tsx_need = TSX_TAA_DISABLE; - else { - /* No TSX specific remedies are available. */ - if (hw_tsx_disable == TSX_TAA_DISABLE) { - /* The user asked for the disable option, but - * it's not available. */ - if (bootverbose) - printf("TSX control not available\n"); - return; - } else - tsx_need = TSX_TAA_VERW; - } - - /* Can we automatically take action, or are we being forced? */ - if (hw_tsx_disable == TSX_TAA_AUTO) - tsx_state = tsx_need; - else - tsx_state = hw_tsx_disable; - - /* No state change, nothing to do */ - if (tsx_state == hw_tsx_state) { - if (bootverbose) - printf("No TSX change made\n"); - return; - } - - /* Does the MSR need to be turned on or off? */ - if (tsx_state == TSX_TAA_DISABLE) - hw_tsx_set(1 /* enable */, 1 /* all */); - else if (hw_tsx_state == TSX_TAA_DISABLE) - hw_tsx_set(0 /* disable */, 1 /* all */); - - /* Does MDS need to be set to turn on VERW? */ - if (tsx_state == TSX_TAA_VERW) { - tsx_saved_mds_disable = hw_mds_disable; - mds_disable = hw_mds_disable = 1; - need_mds_recalc = 1; - } else if (hw_tsx_state == TSX_TAA_VERW) { - mds_disable = hw_mds_disable = tsx_saved_mds_disable; - need_mds_recalc = 1; - } - if (need_mds_recalc) { - hw_mds_recalculate(); - if (mds_disable != hw_mds_disable) { - if (bootverbose) - printf("Cannot change MDS state for TSX\n"); - /* Don't update our state */ - return; - } - } - - hw_tsx_state = tsx_state; - return; -} - -static void -hw_tsx_recalculate_boot(void * arg __unused) -{ - - hw_tsx_recalculate(); -} -SYSINIT(tsx_recalc, SI_SUB_SMP, SI_ORDER_ANY, hw_tsx_recalculate_boot, NULL); - -static int -sysctl_tsx_disable_handler(SYSCTL_HANDLER_ARGS) -{ - int error, val; - - val = hw_tsx_disable; - error = sysctl_handle_int(oidp, &val, 0, req); - if (error != 0 || req->newptr == NULL) - return (error); - if (val < 0 || val > 3) - return (EINVAL); - hw_tsx_disable = val; - hw_tsx_recalculate(); - return (0); -} - -SYSCTL_PROC(_hw, OID_AUTO, tsx_disable, CTLTYPE_INT | - CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, - sysctl_tsx_disable_handler, "I", - "TSX Asynchronous Abort Mitigation " - "(0 - off, 1 - disable TSX, 2 - MDS/VERW, 3 - on AUTO"); - -static int -sysctl_hw_tsx_disable_state_handler(SYSCTL_HANDLER_ARGS) -{ - const char *state; - - switch (hw_tsx_state) { - case TSX_TAA_NONE: - state = "inactive"; - break; - case TSX_TAA_DISABLE: - state = "TSX disabled"; - break; - case TSX_TAA_VERW: - state = "MDS/VERW"; - break; - default: - state = "unknown"; - } - - return (SYSCTL_OUT(req, state, strlen(state))); -} - -SYSCTL_PROC(_hw, OID_AUTO, tsx_disable_state, - CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, - sysctl_hw_tsx_disable_state_handler, "A", - "Transactional Memory Asynchronous Abort Mitigation state"); - /* * Enable and restore kernel text write permissions. * Callers must ensure that disable_wp()/restore_wp() are executed From owner-svn-src-stable@freebsd.org Sat Nov 16 00:33:03 2019 Return-Path: Delivered-To: svn-src-stable@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 9F2E11B4FE5; Sat, 16 Nov 2019 00:33:03 +0000 (UTC) (envelope-from scottl@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 47FGQl3Rwvz4KFh; Sat, 16 Nov 2019 00:33:03 +0000 (UTC) (envelope-from scottl@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 4C4D92129B; Sat, 16 Nov 2019 00:33:03 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAG0X30R002974; Sat, 16 Nov 2019 00:33:03 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAG0X3ji002973; Sat, 16 Nov 2019 00:33:03 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911160033.xAG0X3ji002973@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sat, 16 Nov 2019 00:33:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354762 - in stable/11/sys: kern sys X-SVN-Group: stable-11 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/11/sys: kern sys X-SVN-Commit-Revision: 354762 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 00:33:03 -0000 Author: scottl Date: Sat Nov 16 00:33:02 2019 New Revision: 354762 URL: https://svnweb.freebsd.org/changeset/base/354762 Log: MFC r354756: Create a new sysctl tree, machdep.mitigations Sponsored by: Intel Modified: stable/11/sys/kern/kern_mib.c stable/11/sys/sys/sysctl.h Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/kern/kern_mib.c ============================================================================== --- stable/11/sys/kern/kern_mib.c Sat Nov 16 00:31:57 2019 (r354761) +++ stable/11/sys/kern/kern_mib.c Sat Nov 16 00:33:02 2019 (r354762) @@ -76,6 +76,8 @@ SYSCTL_ROOT_NODE(CTL_HW, hw, CTLFLAG_RW, 0, "hardware"); SYSCTL_ROOT_NODE(CTL_MACHDEP, machdep, CTLFLAG_RW, 0, "machine dependent"); +SYSCTL_NODE(_machdep, OID_AUTO, mitigations, CTLFLAG_RW, 0, + "Machine dependent platform mitigations."); SYSCTL_ROOT_NODE(CTL_USER, user, CTLFLAG_RW, 0, "user-level"); SYSCTL_ROOT_NODE(CTL_P1003_1B, p1003_1b, CTLFLAG_RW, 0, Modified: stable/11/sys/sys/sysctl.h ============================================================================== --- stable/11/sys/sys/sysctl.h Sat Nov 16 00:31:57 2019 (r354761) +++ stable/11/sys/sys/sysctl.h Sat Nov 16 00:33:02 2019 (r354762) @@ -1018,6 +1018,7 @@ SYSCTL_DECL(_hw_bus); SYSCTL_DECL(_hw_bus_devices); SYSCTL_DECL(_hw_bus_info); SYSCTL_DECL(_machdep); +SYSCTL_DECL(_machdep_mitigations); SYSCTL_DECL(_user); SYSCTL_DECL(_compat); SYSCTL_DECL(_regression); From owner-svn-src-stable@freebsd.org Sat Nov 16 00:36:44 2019 Return-Path: Delivered-To: svn-src-stable@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 26F641B5081; Sat, 16 Nov 2019 00:36:44 +0000 (UTC) (envelope-from scottl@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 47FGVz68FQz4SbT; Sat, 16 Nov 2019 00:36:43 +0000 (UTC) (envelope-from scottl@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 A95C7212A1; Sat, 16 Nov 2019 00:36:43 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAG0ah6X003205; Sat, 16 Nov 2019 00:36:43 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAG0ag3W003201; Sat, 16 Nov 2019 00:36:42 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911160036.xAG0ag3W003201@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sat, 16 Nov 2019 00: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: r354763 - in stable/12/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Group: stable-12 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/12/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Commit-Revision: 354763 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 00:36:44 -0000 Author: scottl Date: Sat Nov 16 00:36:42 2019 New Revision: 354763 URL: https://svnweb.freebsd.org/changeset/base/354763 Log: MFC r354759: TSX Asynchronous Abort mitigation for Intel CVE-2019-11135. This CVE has already been announced in FreeBSD SA-19:26.mcu. Mitigation for TAA involves either turning off TSX or turning on the VERW mitigation used for MDS. Some CPUs will also be self-mitigating for TAA and require no software workaround. Control knobs are: machdep.mitigations.taa.enable: 0 - no software mitigation is enabled 1 - attempt to disable TSX 2 - use the VERW mitigation 3 - automatically select the mitigation based on processor features. machdep.mitigations.taa.state: inactive - no mitigation is active/enabled TSX disable - TSX is disabled in the bare metal CPU as well as - any virtualized CPUs VERW - VERW instruction clears CPU buffers not vulnerable - The CPU has identified itself as not being vulnerable Nothing in the base FreeBSD system uses TSX. However, the instructions are straight-forward to add to custom applications and require no kernel support, so the mitigation is provided for users with untrusted applications and tenants. Reviewed by: emaste, imp, kib, scottph Sponsored by: Intel Differential Revision: 22374 Modified: stable/12/sys/amd64/amd64/machdep.c stable/12/sys/dev/cpuctl/cpuctl.c stable/12/sys/x86/include/x86_var.h stable/12/sys/x86/x86/cpu_machdep.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/machdep.c ============================================================================== --- stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:33:02 2019 (r354762) +++ stable/12/sys/amd64/amd64/machdep.c Sat Nov 16 00:36:42 2019 (r354763) @@ -1790,6 +1790,7 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) TUNABLE_INT_FETCH("machdep.syscall_ret_l1d_flush", &syscall_ret_l1d_flush_mode); TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); + TUNABLE_INT_FETCH("machdep.mitigations.taa.enable", &x86_taa_enable); finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ Modified: stable/12/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:33:02 2019 (r354762) +++ stable/12/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:36:42 2019 (r354763) @@ -546,6 +546,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td pmap_allow_2m_x_ept_recalculate(); #endif hw_mds_recalculate(); + x86_taa_recalculate(); printcpuinfo(); return (0); } Modified: stable/12/sys/x86/include/x86_var.h ============================================================================== --- stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:33:02 2019 (r354762) +++ stable/12/sys/x86/include/x86_var.h Sat Nov 16 00:36:42 2019 (r354763) @@ -87,6 +87,7 @@ extern int pti; extern int hw_ibrs_active; extern int hw_mds_disable; extern int hw_ssb_active; +extern int x86_taa_enable; struct pcb; struct thread; @@ -143,6 +144,7 @@ void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); +void x86_taa_recalculate(void); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); void nmi_handle_intr(u_int type, struct trapframe *frame); Modified: stable/12/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:33:02 2019 (r354762) +++ stable/12/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:36:42 2019 (r354763) @@ -1120,6 +1120,202 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | "Microarchitectural Data Sampling Mitigation " "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); + +/* + * Intel Transactional Memory Asynchronous Abort Mitigation + * CVE-2019-11135 + */ +int x86_taa_enable; +int x86_taa_state; +enum { + TAA_NONE = 0, + TAA_TSX_DISABLE = 1, + TAA_VERW = 2, + TAA_AUTO = 3, + TAA_TAA_NO = 4 +}; + +static void +taa_set_one(bool enable) +{ + uint64_t v; + + v = rdmsr(MSR_IA32_TSX_CTRL); + if (enable) + v |= (uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + else + v &= ~(uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + + wrmsr(MSR_IA32_TSX_CTRL, v); +} + +static void +taa_set(bool enable, bool all) +{ + struct thread *td; + int bound_cpu, i, is_bound; + + if (all) { + td = curthread; + thread_lock(td); + is_bound = sched_is_bound(td); + bound_cpu = td->td_oncpu; + CPU_FOREACH(i) { + sched_bind(td, i); + taa_set_one(enable); + } + if (is_bound) + sched_bind(td, bound_cpu); + else + sched_unbind(td); + thread_unlock(td); + } else + taa_set_one(enable); +} + +void +x86_taa_recalculate(void) +{ + static int taa_saved_mds_disable = 0; + int taa_need = 0, taa_state = 0; + int mds_disable = 0, need_mds_recalc = 0; + + /* Check CPUID.07h.EBX.HLE and RTM for the presence of TSX */ + if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 || + (cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) { + /* TSX is not present */ + x86_taa_state = 0; + return; + } + + /* Check to see what mitigation options the CPU gives us */ + if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) { + /* CPU is not suseptible to TAA */ + taa_need = TAA_NONE; + taa_state = TAA_TAA_NO; + } else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) { + /* + * CPU can turn off TSX. This is the next best option + * if TAA_NO hardware mitigation isn't present + */ + taa_need = TAA_TSX_DISABLE; + } else { + /* No TSX/TAA specific remedies are available. */ + if (x86_taa_enable == TAA_TSX_DISABLE) { + if (bootverbose) + printf("TSX control not available\n"); + return; + } else + taa_need = TAA_VERW; + } + + /* Can we automatically take action, or are we being forced? */ + if (x86_taa_enable == TAA_AUTO) + taa_state = taa_need; + else + taa_state = x86_taa_enable; + + /* No state change, nothing to do */ + if (taa_state == x86_taa_state) { + if (bootverbose) + printf("No TSX change made\n"); + return; + } + + /* Does the MSR need to be turned on or off? */ + if (taa_state == TAA_TSX_DISABLE) + taa_set(true, true); + else if (x86_taa_state == TAA_TSX_DISABLE) + taa_set(false, true); + + /* Does MDS need to be set to turn on VERW? */ + if (taa_state == TAA_VERW) { + taa_saved_mds_disable = hw_mds_disable; + mds_disable = hw_mds_disable = 1; + need_mds_recalc = 1; + } else if (x86_taa_state == TAA_VERW) { + mds_disable = hw_mds_disable = taa_saved_mds_disable; + need_mds_recalc = 1; + } + if (need_mds_recalc) { + hw_mds_recalculate(); + if (mds_disable != hw_mds_disable) { + if (bootverbose) + printf("Cannot change MDS state for TAA\n"); + /* Don't update our state */ + return; + } + } + + x86_taa_state = taa_state; + return; +} + +static void +taa_recalculate_boot(void * arg __unused) +{ + + x86_taa_recalculate(); +} +SYSINIT(taa_recalc, SI_SUB_SMP, SI_ORDER_ANY, taa_recalculate_boot, NULL); + +SYSCTL_NODE(_machdep_mitigations, OID_AUTO, taa, CTLFLAG_RW, 0, + "TSX Asynchronous Abort Mitigation"); + +static int +sysctl_taa_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = x86_taa_enable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < TAA_NONE || val > TAA_AUTO) + return (EINVAL); + x86_taa_enable = val; + x86_taa_recalculate(); + return (0); +} + +SYSCTL_PROC(_machdep_mitigations_taa, OID_AUTO, enable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_taa_handler, "I", + "TAA Mitigation enablement control " + "(0 - off, 1 - disable TSX, 2 - VERW, 3 - on AUTO"); + +static int +sysctl_taa_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + switch (x86_taa_state) { + case TAA_NONE: + state = "inactive"; + break; + case TAA_TSX_DISABLE: + state = "TSX disabled"; + break; + case TAA_VERW: + state = "VERW"; + break; + case TAA_TAA_NO: + state = "Not vulnerable"; + break; + default: + state = "unknown"; + } + + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_machdep_mitigations_taa, OID_AUTO, state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_taa_state_handler, "A", + "TAA Mitigation state"); + /* * Enable and restore kernel text write permissions. * Callers must ensure that disable_wp()/restore_wp() are executed From owner-svn-src-stable@freebsd.org Sat Nov 16 00:52:06 2019 Return-Path: Delivered-To: svn-src-stable@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 2ADB91B5546; Sat, 16 Nov 2019 00:52:06 +0000 (UTC) (envelope-from scottl@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 47FGrj5qgjz3Mw8; Sat, 16 Nov 2019 00:52:05 +0000 (UTC) (envelope-from scottl@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 9C91521612; Sat, 16 Nov 2019 00:52:05 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id xAG0q5IO014803; Sat, 16 Nov 2019 00:52:05 GMT (envelope-from scottl@FreeBSD.org) Received: (from scottl@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAG0q4ET014800; Sat, 16 Nov 2019 00:52:04 GMT (envelope-from scottl@FreeBSD.org) Message-Id: <201911160052.xAG0q4ET014800@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: scottl set sender to scottl@FreeBSD.org using -f From: Scott Long Date: Sat, 16 Nov 2019 00:52:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354764 - in stable/11/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Group: stable-11 X-SVN-Commit-Author: scottl X-SVN-Commit-Paths: in stable/11/sys: amd64/amd64 dev/cpuctl x86/include x86/x86 X-SVN-Commit-Revision: 354764 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 00:52:06 -0000 Author: scottl Date: Sat Nov 16 00:52:04 2019 New Revision: 354764 URL: https://svnweb.freebsd.org/changeset/base/354764 Log: MFC r354759: TSX Asynchronous Abort mitigation for Intel CVE-2019-11135. This CVE has already been announced in FreeBSD SA-19:26.mcu. Mitigation for TAA involves either turning off TSX or turning on the VERW mitigation used for MDS. Some CPUs will also be self-mitigating for TAA and require no software workaround. Control knobs are: machdep.mitigations.taa.enable: 0 - no software mitigation is enabled 1 - attempt to disable TSX 2 - use the VERW mitigation 3 - automatically select the mitigation based on processor features. machdep.mitigations.taa.state: inactive - no mitigation is active/enabled TSX disable - TSX is disabled in the bare metal CPU as well as - any virtualized CPUs VERW - VERW instruction clears CPU buffers not vulnerable - The CPU has identified itself as not being vulnerable Nothing in the base FreeBSD system uses TSX. However, the instructions are straight-forward to add to custom applications and require no kernel support, so the mitigation is provided for users with untrusted applications and tenants. Reviewed by: emaste, imp, kib, scottph Sponsored by: Intel Differential Revision: 22374 Modified: stable/11/sys/amd64/amd64/machdep.c stable/11/sys/dev/cpuctl/cpuctl.c stable/11/sys/x86/include/x86_var.h stable/11/sys/x86/x86/cpu_machdep.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/machdep.c ============================================================================== --- stable/11/sys/amd64/amd64/machdep.c Sat Nov 16 00:36:42 2019 (r354763) +++ stable/11/sys/amd64/amd64/machdep.c Sat Nov 16 00:52:04 2019 (r354764) @@ -1722,6 +1722,11 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) != NULL) vty_set_preferred(VTY_VT); + TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable); + TUNABLE_INT_FETCH("hw.spec_store_bypass_disable", &hw_ssb_disable); + TUNABLE_INT_FETCH("hw.mds_disable", &hw_mds_disable); + TUNABLE_INT_FETCH("machdep.mitigations.taa.enable", &x86_taa_enable); + finishidentcpu(); /* Final stage of CPU initialization */ initializecpu(); /* Initialize CPU registers */ initializecpucache(); Modified: stable/11/sys/dev/cpuctl/cpuctl.c ============================================================================== --- stable/11/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:36:42 2019 (r354763) +++ stable/11/sys/dev/cpuctl/cpuctl.c Sat Nov 16 00:52:04 2019 (r354764) @@ -543,6 +543,7 @@ cpuctl_do_eval_cpu_features(int cpu, struct thread *td pmap_allow_2m_x_ept_recalculate(); #endif hw_mds_recalculate(); + x86_taa_recalculate(); printcpuinfo(); return (0); } Modified: stable/11/sys/x86/include/x86_var.h ============================================================================== --- stable/11/sys/x86/include/x86_var.h Sat Nov 16 00:36:42 2019 (r354763) +++ stable/11/sys/x86/include/x86_var.h Sat Nov 16 00:52:04 2019 (r354764) @@ -85,6 +85,7 @@ extern int pti; extern int hw_ibrs_active; extern int hw_mds_disable; extern int hw_ssb_active; +extern int x86_taa_enable; struct pcb; struct thread; @@ -137,6 +138,7 @@ void handle_ibrs_exit(void); void hw_ibrs_recalculate(void); void hw_mds_recalculate(void); void hw_ssb_recalculate(bool all_cpus); +void x86_taa_recalculate(void); void nmi_call_kdb(u_int cpu, u_int type, struct trapframe *frame); void nmi_call_kdb_smp(u_int type, struct trapframe *frame); void nmi_handle_intr(u_int type, struct trapframe *frame); Modified: stable/11/sys/x86/x86/cpu_machdep.c ============================================================================== --- stable/11/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:36:42 2019 (r354763) +++ stable/11/sys/x86/x86/cpu_machdep.c Sat Nov 16 00:52:04 2019 (r354764) @@ -1148,3 +1148,199 @@ SYSCTL_PROC(_hw, OID_AUTO, mds_disable, CTLTYPE_INT | "Microarchitectural Data Sampling Mitigation " "(0 - off, 1 - on VERW, 2 - on SW, 3 - on AUTO"); + +/* + * Intel Transactional Memory Asynchronous Abort Mitigation + * CVE-2019-11135 + */ +int x86_taa_enable; +int x86_taa_state; +enum { + TAA_NONE = 0, + TAA_TSX_DISABLE = 1, + TAA_VERW = 2, + TAA_AUTO = 3, + TAA_TAA_NO = 4 +}; + +static void +taa_set_one(bool enable) +{ + uint64_t v; + + v = rdmsr(MSR_IA32_TSX_CTRL); + if (enable) + v |= (uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + else + v &= ~(uint64_t)(IA32_TSX_CTRL_RTM_DISABLE | + IA32_TSX_CTRL_TSX_CPUID_CLEAR); + + wrmsr(MSR_IA32_TSX_CTRL, v); +} + +static void +taa_set(bool enable, bool all) +{ + struct thread *td; + int bound_cpu, i, is_bound; + + if (all) { + td = curthread; + thread_lock(td); + is_bound = sched_is_bound(td); + bound_cpu = td->td_oncpu; + CPU_FOREACH(i) { + sched_bind(td, i); + taa_set_one(enable); + } + if (is_bound) + sched_bind(td, bound_cpu); + else + sched_unbind(td); + thread_unlock(td); + } else + taa_set_one(enable); +} + +void +x86_taa_recalculate(void) +{ + static int taa_saved_mds_disable = 0; + int taa_need = 0, taa_state = 0; + int mds_disable = 0, need_mds_recalc = 0; + + /* Check CPUID.07h.EBX.HLE and RTM for the presence of TSX */ + if ((cpu_stdext_feature & CPUID_STDEXT_HLE) == 0 || + (cpu_stdext_feature & CPUID_STDEXT_RTM) == 0) { + /* TSX is not present */ + x86_taa_state = 0; + return; + } + + /* Check to see what mitigation options the CPU gives us */ + if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TAA_NO) { + /* CPU is not suseptible to TAA */ + taa_need = TAA_NONE; + taa_state = TAA_TAA_NO; + } else if (cpu_ia32_arch_caps & IA32_ARCH_CAP_TSX_CTRL) { + /* + * CPU can turn off TSX. This is the next best option + * if TAA_NO hardware mitigation isn't present + */ + taa_need = TAA_TSX_DISABLE; + } else { + /* No TSX/TAA specific remedies are available. */ + if (x86_taa_enable == TAA_TSX_DISABLE) { + if (bootverbose) + printf("TSX control not available\n"); + return; + } else + taa_need = TAA_VERW; + } + + /* Can we automatically take action, or are we being forced? */ + if (x86_taa_enable == TAA_AUTO) + taa_state = taa_need; + else + taa_state = x86_taa_enable; + + /* No state change, nothing to do */ + if (taa_state == x86_taa_state) { + if (bootverbose) + printf("No TSX change made\n"); + return; + } + + /* Does the MSR need to be turned on or off? */ + if (taa_state == TAA_TSX_DISABLE) + taa_set(true, true); + else if (x86_taa_state == TAA_TSX_DISABLE) + taa_set(false, true); + + /* Does MDS need to be set to turn on VERW? */ + if (taa_state == TAA_VERW) { + taa_saved_mds_disable = hw_mds_disable; + mds_disable = hw_mds_disable = 1; + need_mds_recalc = 1; + } else if (x86_taa_state == TAA_VERW) { + mds_disable = hw_mds_disable = taa_saved_mds_disable; + need_mds_recalc = 1; + } + if (need_mds_recalc) { + hw_mds_recalculate(); + if (mds_disable != hw_mds_disable) { + if (bootverbose) + printf("Cannot change MDS state for TAA\n"); + /* Don't update our state */ + return; + } + } + + x86_taa_state = taa_state; + return; +} + +static void +taa_recalculate_boot(void * arg __unused) +{ + + x86_taa_recalculate(); +} +SYSINIT(taa_recalc, SI_SUB_SMP, SI_ORDER_ANY, taa_recalculate_boot, NULL); + +SYSCTL_NODE(_machdep_mitigations, OID_AUTO, taa, CTLFLAG_RW, 0, + "TSX Asynchronous Abort Mitigation"); + +static int +sysctl_taa_handler(SYSCTL_HANDLER_ARGS) +{ + int error, val; + + val = x86_taa_enable; + error = sysctl_handle_int(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if (val < TAA_NONE || val > TAA_AUTO) + return (EINVAL); + x86_taa_enable = val; + x86_taa_recalculate(); + return (0); +} + +SYSCTL_PROC(_machdep_mitigations_taa, OID_AUTO, enable, CTLTYPE_INT | + CTLFLAG_RWTUN | CTLFLAG_NOFETCH | CTLFLAG_MPSAFE, NULL, 0, + sysctl_taa_handler, "I", + "TAA Mitigation enablement control " + "(0 - off, 1 - disable TSX, 2 - VERW, 3 - on AUTO"); + +static int +sysctl_taa_state_handler(SYSCTL_HANDLER_ARGS) +{ + const char *state; + + switch (x86_taa_state) { + case TAA_NONE: + state = "inactive"; + break; + case TAA_TSX_DISABLE: + state = "TSX disabled"; + break; + case TAA_VERW: + state = "VERW"; + break; + case TAA_TAA_NO: + state = "Not vulnerable"; + break; + default: + state = "unknown"; + } + + return (SYSCTL_OUT(req, state, strlen(state))); +} + +SYSCTL_PROC(_machdep_mitigations_taa, OID_AUTO, state, + CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, + sysctl_taa_state_handler, "A", + "TAA Mitigation state"); + From owner-svn-src-stable@freebsd.org Sat Nov 16 10:49:18 2019 Return-Path: Delivered-To: svn-src-stable@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 8F6681C1C93; Sat, 16 Nov 2019 10:49: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 47FX5p3HGwz4BrN; Sat, 16 Nov 2019 10:49: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 500F53C2; Sat, 16 Nov 2019 10:49: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 xAGAnIQo064983; Sat, 16 Nov 2019 10:49:18 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAGAnI4W064982; Sat, 16 Nov 2019 10:49:18 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911161049.xAGAnI4W064982@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 Nov 2019 10:49:18 +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: r354767 - stable/12/sys/amd64/amd64 X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/sys/amd64/amd64 X-SVN-Commit-Revision: 354767 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 10:49:18 -0000 Author: kib Date: Sat Nov 16 10:49:17 2019 New Revision: 354767 URL: https://svnweb.freebsd.org/changeset/base/354767 Log: MFC r354766: amd64: only set PCB_FULL_IRET pcb flag when #gp or similar exception comes from usermode. Modified: stable/12/sys/amd64/amd64/exception.S Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/amd64/amd64/exception.S ============================================================================== --- stable/12/sys/amd64/amd64/exception.S Sat Nov 16 08:16:50 2019 (r354766) +++ stable/12/sys/amd64/amd64/exception.S Sat Nov 16 10:49:17 2019 (r354767) @@ -497,8 +497,8 @@ prot_addrf: 3: cmpw $KUG32SEL,TF_GS(%rsp) jne 4f movq %rdx,PCB_GSBASE(%rdi) + orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* full iret from user #gp */ 4: call handle_ibrs_entry - orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* always full iret from GPF */ movw %es,TF_ES(%rsp) movw %ds,TF_DS(%rsp) testl $PSL_I,TF_RFLAGS(%rsp) From owner-svn-src-stable@freebsd.org Sat Nov 16 10:50:11 2019 Return-Path: Delivered-To: svn-src-stable@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 AF8111C1D31; Sat, 16 Nov 2019 10:50:11 +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 47FX6q21G7z4CmG; Sat, 16 Nov 2019 10:50:11 +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 0D5B13C6; Sat, 16 Nov 2019 10:50:11 +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 xAGAoAUl065118; Sat, 16 Nov 2019 10:50:10 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAGAoArq065117; Sat, 16 Nov 2019 10:50:10 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911161050.xAGAoArq065117@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 Nov 2019 10:50:10 +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: r354768 - stable/12/usr.sbin/cpucontrol X-SVN-Group: stable-12 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/12/usr.sbin/cpucontrol X-SVN-Commit-Revision: 354768 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 10:50:11 -0000 Author: kib Date: Sat Nov 16 10:50:10 2019 New Revision: 354768 URL: https://svnweb.freebsd.org/changeset/base/354768 Log: MFC r354697: cpucontrol: print more useful information when MSR access fails. Modified: stable/12/usr.sbin/cpucontrol/cpucontrol.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/cpucontrol/cpucontrol.c ============================================================================== --- stable/12/usr.sbin/cpucontrol/cpucontrol.c Sat Nov 16 10:49:17 2019 (r354767) +++ stable/12/usr.sbin/cpucontrol/cpucontrol.c Sat Nov 16 10:50:10 2019 (r354768) @@ -307,7 +307,7 @@ do_msr(const char *cmdarg, const char *dev) } error = ioctl(fd, command, &args); if (error < 0) { - WARN(0, "ioctl(%s, CPUCTL_%s (%lu))", dev, command_name, command); + WARN(0, "ioctl(%s, CPUCTL_%s (%#x))", dev, command_name, msr); close(fd); return (1); } From owner-svn-src-stable@freebsd.org Sat Nov 16 11:00:23 2019 Return-Path: Delivered-To: svn-src-stable@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 28B291C2255; Sat, 16 Nov 2019 11:00:23 +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 47FXLb0Kbsz4cFn; Sat, 16 Nov 2019 11:00:23 +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 E3B50596; Sat, 16 Nov 2019 11:00:22 +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 xAGB0M52071131; Sat, 16 Nov 2019 11:00:22 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAGB0M8i071130; Sat, 16 Nov 2019 11:00:22 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911161100.xAGB0M8i071130@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 Nov 2019 11:00:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354769 - stable/11/sys/amd64/amd64 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/sys/amd64/amd64 X-SVN-Commit-Revision: 354769 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 11:00:23 -0000 Author: kib Date: Sat Nov 16 11:00:22 2019 New Revision: 354769 URL: https://svnweb.freebsd.org/changeset/base/354769 Log: MFC r354696: amd64: only set PCB_FULL_IRET pcb flag when #gp or similar exception comes from usermode. Modified: stable/11/sys/amd64/amd64/exception.S Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/amd64/amd64/exception.S ============================================================================== --- stable/11/sys/amd64/amd64/exception.S Sat Nov 16 10:50:10 2019 (r354768) +++ stable/11/sys/amd64/amd64/exception.S Sat Nov 16 11:00:22 2019 (r354769) @@ -492,8 +492,8 @@ prot_addrf: 3: cmpw $KUG32SEL,TF_GS(%rsp) jne 4f movq %rdx,PCB_GSBASE(%rdi) + orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* full iret from user #gp */ 4: call handle_ibrs_entry - orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* always full iret from GPF */ movw %es,TF_ES(%rsp) movw %ds,TF_DS(%rsp) testl $PSL_I,TF_RFLAGS(%rsp) From owner-svn-src-stable@freebsd.org Sat Nov 16 11:01:22 2019 Return-Path: Delivered-To: svn-src-stable@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 BFC171C22DD; Sat, 16 Nov 2019 11:01:22 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 47FXMj1gkfz4cm9; Sat, 16 Nov 2019 11:01:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id xAGB17EP059639 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 16 Nov 2019 13:01:10 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua xAGB17EP059639 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id xAGB17mg059637; Sat, 16 Nov 2019 13:01:07 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 16 Nov 2019 13:01:07 +0200 From: Konstantin Belousov To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: Re: svn commit: r354767 - stable/12/sys/amd64/amd64 Message-ID: <20191116110107.GK2707@kib.kiev.ua> References: <201911161049.xAGAnI4W064982@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201911161049.xAGAnI4W064982@repo.freebsd.org> User-Agent: Mutt/1.12.2 (2019-09-21) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-Rspamd-Queue-Id: 47FXMj1gkfz4cm9 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_XAW(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; IP_SCORE(0.00)[ip: (-2.70), ipnet: 2001:470::/32(-4.61), asn: 6939(-3.49), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 11:01:22 -0000 On Sat, Nov 16, 2019 at 10:49:18AM +0000, Konstantin Belousov wrote: > Author: kib > Date: Sat Nov 16 10:49:17 2019 > New Revision: 354767 > URL: https://svnweb.freebsd.org/changeset/base/354767 > > Log: > MFC r354766: r354696 really. > amd64: only set PCB_FULL_IRET pcb flag when #gp or similar exception comes > from usermode. > > Modified: > stable/12/sys/amd64/amd64/exception.S > Directory Properties: > stable/12/ (props changed) > > Modified: stable/12/sys/amd64/amd64/exception.S > ============================================================================== > --- stable/12/sys/amd64/amd64/exception.S Sat Nov 16 08:16:50 2019 (r354766) > +++ stable/12/sys/amd64/amd64/exception.S Sat Nov 16 10:49:17 2019 (r354767) > @@ -497,8 +497,8 @@ prot_addrf: > 3: cmpw $KUG32SEL,TF_GS(%rsp) > jne 4f > movq %rdx,PCB_GSBASE(%rdi) > + orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* full iret from user #gp */ > 4: call handle_ibrs_entry > - orl $PCB_FULL_IRET,PCB_FLAGS(%rdi) /* always full iret from GPF */ > movw %es,TF_ES(%rsp) > movw %ds,TF_DS(%rsp) > testl $PSL_I,TF_RFLAGS(%rsp) From owner-svn-src-stable@freebsd.org Sat Nov 16 11:01:57 2019 Return-Path: Delivered-To: svn-src-stable@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 9AC311C2360; Sat, 16 Nov 2019 11:01:57 +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 47FXNP3f7Vz4dFd; Sat, 16 Nov 2019 11:01:57 +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 61D9A616; Sat, 16 Nov 2019 11:01:57 +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 xAGB1vEx075867; Sat, 16 Nov 2019 11:01:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id xAGB1vxJ075865; Sat, 16 Nov 2019 11:01:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201911161101.xAGB1vxJ075865@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sat, 16 Nov 2019 11:01:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r354770 - stable/11/usr.sbin/cpucontrol X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/usr.sbin/cpucontrol X-SVN-Commit-Revision: 354770 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@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Nov 2019 11:01:57 -0000 Author: kib Date: Sat Nov 16 11:01:56 2019 New Revision: 354770 URL: https://svnweb.freebsd.org/changeset/base/354770 Log: MFC r354697: cpucontrol: print more useful information when MSR access fails. Modified: stable/11/usr.sbin/cpucontrol/cpucontrol.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/cpucontrol/cpucontrol.c ============================================================================== --- stable/11/usr.sbin/cpucontrol/cpucontrol.c Sat Nov 16 11:00:22 2019 (r354769) +++ stable/11/usr.sbin/cpucontrol/cpucontrol.c Sat Nov 16 11:01:56 2019 (r354770) @@ -330,7 +330,7 @@ do_msr(const char *cmdarg, const char *dev) } error = ioctl(fd, command, &args); if (error < 0) { - WARN(0, "ioctl(%s, CPUCTL_%s (%lu))", dev, command_name, command); + WARN(0, "ioctl(%s, CPUCTL_%s (%#x))", dev, command_name, msr); close(fd); return (1); }