From owner-svn-src-all@freebsd.org Thu May 21 02:08:35 2020 Return-Path: Delivered-To: svn-src-all@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 AF9252FC88F; Thu, 21 May 2020 02:08:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49SChg4B0Yz497v; Thu, 21 May 2020 02:08:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8AB1D25F84; Thu, 21 May 2020 02:08:35 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04L28ZK4068594; Thu, 21 May 2020 02:08:35 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04L28Y5u068587; Thu, 21 May 2020 02:08:34 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202005210208.04L28Y5u068587@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 21 May 2020 02:08:34 +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: r361315 - in stable/12/sys: ddb dev/nvdimm dev/ow net sys X-SVN-Group: stable-12 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: in stable/12/sys: ddb dev/nvdimm dev/ow net sys X-SVN-Commit-Revision: 361315 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 May 2020 02:08:35 -0000 Author: kevans Date: Thu May 21 02:08:34 2020 New Revision: 361315 URL: https://svnweb.freebsd.org/changeset/base/361315 Log: MFC r361011: kernel: provide panicky version of __unreachable __builtin_unreachable doesn't raise any compile-time warnings/errors on its own, so problems with its usage can't be easily detected. While it would be nice for this situation to change and compilers to at least add a warning for trivial cases where local state means the instruction can't be reached, this isn't the case at the moment and likely will not happen. This commit adds an __assert_unreachable, whose intent is incredibly clear: it asserts that this instruction is unreachable. On INVARIANTS builds, it's a panic(), and on non-INVARIANTS it expands to __unreachable(). Existing users of __unreachable() are converted to __assert_unreachable, to improve debuggability if this assumption is violated. Modified: stable/12/sys/ddb/db_expr.c stable/12/sys/dev/nvdimm/nvdimm.c stable/12/sys/dev/ow/ow.c stable/12/sys/net/mppcc.c stable/12/sys/sys/systm.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/ddb/db_expr.c ============================================================================== --- stable/12/sys/ddb/db_expr.c Thu May 21 02:04:10 2020 (r361314) +++ stable/12/sys/ddb/db_expr.c Thu May 21 02:08:34 2020 (r361315) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -229,7 +230,7 @@ db_add_expr(db_expr_t *valuep) lhs |= rhs; break; default: - __unreachable(); + __assert_unreachable(); } t = db_read_token(); } @@ -313,7 +314,7 @@ db_logical_relation_expr( lhs = (lhs <= rhs); break; default: - __unreachable(); + __assert_unreachable(); } t = db_read_token(); } Modified: stable/12/sys/dev/nvdimm/nvdimm.c ============================================================================== --- stable/12/sys/dev/nvdimm/nvdimm.c Thu May 21 02:04:10 2020 (r361314) +++ stable/12/sys/dev/nvdimm/nvdimm.c Thu May 21 02:08:34 2020 (r361315) @@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$"); #include "opt_ddb.h" #include +#include #include #include #include @@ -235,7 +236,7 @@ read_label(struct nvdimm_dev *nv, int num) return (0); } } - __unreachable(); + __assert_unreachable(); } static int Modified: stable/12/sys/dev/ow/ow.c ============================================================================== --- stable/12/sys/dev/ow/ow.c Thu May 21 02:04:10 2020 (r361314) +++ stable/12/sys/dev/ow/ow.c Thu May 21 02:08:34 2020 (r361315) @@ -505,7 +505,7 @@ again: return (EIO); goto again; default: /* NOTREACHED */ - __unreachable(); + __assert_unreachable(); } if (dir) { OWLL_WRITE_ONE(lldev, &timing_regular); Modified: stable/12/sys/net/mppcc.c ============================================================================== --- stable/12/sys/net/mppcc.c Thu May 21 02:04:10 2020 (r361314) +++ stable/12/sys/net/mppcc.c Thu May 21 02:08:34 2020 (r361315) @@ -232,7 +232,7 @@ int MPPC_Compress(u_char **src, u_char **dst, u_long * } else if (off < 8192) { /* 16-bit offset; 320 <= offset < 8192 */ putbits16(*dst, 0xc000|(off-320), 16, &olen, &l); } else { /* NOTREACHED */ - __unreachable(); + __assert_unreachable(); rtn &= ~MPPC_OK; return (rtn); } Modified: stable/12/sys/sys/systm.h ============================================================================== --- stable/12/sys/sys/systm.h Thu May 21 02:04:10 2020 (r361314) +++ stable/12/sys/sys/systm.h Thu May 21 02:08:34 2020 (r361315) @@ -108,12 +108,16 @@ void kassert_panic(const char *fmt, ...) __printflike kassert_panic msg; \ } \ } while (0) +#define __assert_unreachable() \ + panic("executing segment marked as unreachable at %s:%d (%s)\n", \ + __FILE__, __LINE__, __func__) #else #define KASSERT(exp,msg) do { \ } while (0) #define VNASSERT(exp, vp, msg) do { \ } while (0) +#define __assert_unreachable() __unreachable() #endif #ifndef CTASSERT /* Allow lint to override */