From nobody Sun Oct 20 15:52:54 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XWjdL3lcLz5ZSlP; Sun, 20 Oct 2024 15:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XWjdL1qHfz46nj; Sun, 20 Oct 2024 15:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729439574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8S9Eb9WlWd7htdLGyoA1gEJmbQUNl5CE+vuUROSVag0=; b=E4y6NPqVqNQYkrOqlUWt+49h4658XC9Z5/IpSEUVSx0gK1sG1W+XOfciz8+MGP8sOGV2KT hEYuX1GAcoERGJ/s/23O/8YwWwr7Pzh6v5CiTd+XuEes/JbtiRe8ft6OyDrRem3EO2N9qm OkjYi/EsLfrWN3aK0CdoXB6OxnSDo6NPCdhfulKz7qANk3GGVYQ+fFPReAT2N/ZZACGEbG Oln1apSzy1lQ+MkAiNLzgixZ+dCyfbCZqP2J1GwaOnUJJ3/dj4PwMzX8W0MLleKzQYI4ZV bdgV6oaBIYTo1Qac6axqJJpxs9xeRKOPYMxjJlLknMPwvyjRFxluHhwy+KK+xA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729439574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8S9Eb9WlWd7htdLGyoA1gEJmbQUNl5CE+vuUROSVag0=; b=oKhyvFc7PP3LmHW6BFaSJtJKMjqaZjax1xUqnPOvNi15Q2HJxcSCTrSZ3zhPfmYWhCfTm1 0HkjDdvHBB6UtJgkq4dCkCiZf4r1+cPDST0u+9z99MkWGOYABW/7w2IBZp2dj/hwzs27Ad tnhzAKq5cyoznmpIe2xyn9ieK62nGFf3kRgtA4DjiS2oohEdbazL5AfYLvtLRLMQEt3cwk JG2+wLMa+A+uw/OoaD54sens68UT/XEL2o2OnckOnm8whPlpR0Lfhe6GX64kqvpRd07fH2 M8l0McscO28ocZw2kgSdgydeErNCJtf979wpDxXV+tlmh+EqDPESPMR9s8Aipw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729439574; a=rsa-sha256; cv=none; b=pliASpbjn/Ya1GBpL35cWUJY57S++8w1WMkzCJ7Z57soogGWGaSl2ymtnX57keMd9xOpG+ t50haoD6c8jrd+jakfrnlXdFY1CBfZ/QifuuQYikoTYIv142vD5OPgrG4UgjosXfvJbHzc QGbPrtKA4sty55MAPx16TsibYvucmciqZ93kyBH0nsQEp/ctuNSMK946EZtq+tjrUhZmP2 MiTF16/oApC3WvDgK0L3qQyB7OIOiEXwqM1OiGliicDHTCacQNSTZOJr2wubxH9pKlae9a XdCc7fxMug5u/qvIzA/wOaj+ZsVdl0VWMChNzwv/OdKwPvZ7pWu3enieiTH7vQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XWjdL17Zwz17Lr; Sun, 20 Oct 2024 15:52:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49KFqsMZ064089; Sun, 20 Oct 2024 15:52:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49KFqsiA064085; Sun, 20 Oct 2024 15:52:54 GMT (envelope-from git) Date: Sun, 20 Oct 2024 15:52:54 GMT Message-Id: <202410201552.49KFqsiA064085@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 3dc6188294dd - main - cdefs: Use __has_feature to gate the definition of __nosanitize* List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3dc6188294dd4f907f5f63cc3f1a79ea20dba99f Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=3dc6188294dd4f907f5f63cc3f1a79ea20dba99f commit 3dc6188294dd4f907f5f63cc3f1a79ea20dba99f Author: Mark Johnston AuthorDate: 2024-10-19 13:55:12 +0000 Commit: Mark Johnston CommitDate: 2024-10-20 14:25:30 +0000 cdefs: Use __has_feature to gate the definition of __nosanitize* clang 12 does not implement the coverage sanitizer, and the build fails when __attribute__((no_sanitize("coverage"))) is used. Try to work around the problem by giving __nosanitize* a non-trivial definition only when the corresponding sanitizer is actually enabled in the build. Tested by reading disassembly of pmap_update_strided() and pmap_enter() in a kernel compiled with "options COVERAGE", and similar sanity checks for the other sanitizers. I also test-booted KASAN and KMSAN kernels in amd64 bhyve. Suggested by: jrtc27 Reviewed by: imp Fixes: a78bacf3b0ec ("cdefs: Add __nosanitizecoverage") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D47193 --- sys/sys/cdefs.h | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h index 353090db6995..6521a34595cb 100644 --- a/sys/sys/cdefs.h +++ b/sys/sys/cdefs.h @@ -712,21 +712,33 @@ * GCC has the nosanitize attribute, but as a function attribute only, and * warns on use as a variable attribute. */ -#if __has_attribute(no_sanitize) && defined(__clang__) +#if __has_feature(address_sanitizer) && defined(__clang__) #ifdef _KERNEL -#define __nosanitizeaddress __attribute__((no_sanitize("kernel-address"))) -#define __nosanitizememory __attribute__((no_sanitize("kernel-memory"))) +#define __nosanitizeaddress __attribute__((no_sanitize("kernel-address"))) #else -#define __nosanitizeaddress __attribute__((no_sanitize("address"))) -#define __nosanitizememory __attribute__((no_sanitize("memory"))) +#define __nosanitizeaddress __attribute__((no_sanitize("address"))) #endif -#define __nosanitizecoverage __attribute__((no_sanitize("coverage"))) -#define __nosanitizethread __attribute__((no_sanitize("thread"))) #else -#define __nosanitizeaddress -#define __nosanitizecoverage -#define __nosanitizememory -#define __nosanitizethread +#define __nosanitizeaddress +#endif +#if __has_feature(coverage_sanitizer) && defined(__clang__) +#define __nosanitizecoverage __attribute__((no_sanitize("coverage"))) +#else +#define __nosanitizecoverage +#endif +#if __has_feature(memory_sanitizer) && defined(__clang__) +#ifdef _KERNEL +#define __nosanitizememory __attribute__((no_sanitize("kernel-memory"))) +#else +#define __nosanitizememory __attribute__((no_sanitize("memory"))) +#endif +#else +#define __nosanitizememory +#endif +#if __has_feature(thread_sanitizer) && defined(__clang__) +#define __nosanitizethread __attribute__((no_sanitize("thread"))) +#else +#define __nosanitizethread #endif /*