From nobody Tue Apr 7 08:08:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 23E443793D2; Sat, 14 Mar 2026 14:18:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497911; cv=none; b=ozvGM2EvMlJtKKZj5O2a1JwW9y8c9gZ2svN1NU8jQzeXeCkpqDlf3YWZbKb087G0t8ZlYUUkqdcyGeo/ige8ZjAhkbBuae2UVqX9b6iy2w4JN98hddGzsutJDP76QrQpuepH4oKaIs32klnx3StYimpFKt8ZQahwvr4Q+4+tPkU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497911; c=relaxed/simple; bh=AXumW6HXOmazXM7FvHVA3w8Ta2j/RD3IL+MZjJT8dsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MgLwwOlGrunxalSX4Vi3kSpG4G7M1Ca2GbmFIMpkBxI2mpnpYsWv+oQVaDEJTnMp9CBZshlbGoO+snKVQALFILg0j6lioa0dkEfU7UQ3hQqoNtzhi4G+UqLNq0qXzkuZx7sh7+hTpFs4K4Ngs+aLh+o/nl0blNbn8MSWOSbHDtI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZGseERTq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZGseERTq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4BD6C19424; Sat, 14 Mar 2026 14:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773497910; bh=AXumW6HXOmazXM7FvHVA3w8Ta2j/RD3IL+MZjJT8dsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZGseERTqZP+tt0Q8PxEyLv1q8B0SVG+WOUeX3RsgUemLWzFIo7WbKsgrvxUGYnYxV v7U4aBZKcZ0IUN476ddbPMz4IWLPB26G/M1d+jhRjAzOBMwiRMmu9rgTYhmrgWU+Zh WQZZJ5eCrLjipA+nJKZlvyTayy5ZYNvTRMxjptBcqSxe5j7o3deVMO7zb5UpBR8XV8 t6AzoyzKwAMBdrwu7sGkkLnd5w7FJnayDvtf73slFU441mHQhBZgIIWG/yohDKfy5B A4TDcaZk0cAMeSqc76KvR2nLf9Eao8tAmc+O7Ed5kJ3hUi0W8rNzhI6WuDP4jUQtGL hOVwCgYq41WXw== From: Sasha Levin To: oberpar@linux.ibm.com Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Sasha Levin Subject: [PATCH 1/4] gcov: fix gcov_info_add() merge semantics for IOR counters Date: Sat, 14 Mar 2026 10:17:46 -0400 Message-ID: <20260314141749.3382679-2-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260314141749.3382679-1-sashal@kernel.org> References: <20260314141749.3382679-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" gcov_info_add() unconditionally uses +=3D to merge all counter types. This is wrong for counters that use IOR merge semantics (bitwise OR), such as GCOV_COUNTER_IOR and GCC 14's GCOV_COUNTER_CONDS (MC/DC condition coverage). These counters store bitsets that must be merged with |=3D, not accumulated with +=3D. Detect IOR merge semantics by comparing the merge function pointer against __gcov_merge_ior, matching how GCC's own libgcov identifies merge semantics. This fixes the pre-existing bug for GCOV_COUNTER_IOR and also enables correct merging for MC/DC condition coverage data. Fixes: 5f41ea0386a5 ("gcov: add support for gcc 4.7 gcov format") Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Sasha Levin --- kernel/gcov/gcc_4_7.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/kernel/gcov/gcc_4_7.c b/kernel/gcov/gcc_4_7.c index 8fa22ababd943..923cfb34966b2 100644 --- a/kernel/gcov/gcc_4_7.c +++ b/kernel/gcov/gcc_4_7.c @@ -18,6 +18,8 @@ #include #include "gcov.h" =20 +extern void __gcov_merge_ior(gcov_type *, unsigned int); + #if (__GNUC__ >=3D 15) #define GCOV_COUNTERS 10 #elif (__GNUC__ >=3D 14) @@ -187,6 +189,15 @@ static int counter_active(struct gcov_info *info, unsi= gned int type) return info->merge[type] ? 1 : 0; } =20 +/* + * Determine whether a counter uses IOR merge semantics (bitwise OR of + * bitsets). Used for condition coverage (MC/DC) and other IOR-based count= ers. + */ +static bool counter_is_ior(struct gcov_info *info, unsigned int type) +{ + return info->merge[type] =3D=3D __gcov_merge_ior; +} + /* Determine number of active counters. Based on gcc magic. */ static unsigned int num_counter_active(struct gcov_info *info) { @@ -259,9 +270,17 @@ void gcov_info_add(struct gcov_info *dst, struct gcov_= info *src) if (!counter_active(src, ct_idx)) continue; =20 - for (val_idx =3D 0; val_idx < sci_ptr->num; val_idx++) - dci_ptr->values[val_idx] +=3D - sci_ptr->values[val_idx]; + if (counter_is_ior(src, ct_idx)) { + for (val_idx =3D 0; val_idx < sci_ptr->num; + val_idx++) + dci_ptr->values[val_idx] |=3D + sci_ptr->values[val_idx]; + } else { + for (val_idx =3D 0; val_idx < sci_ptr->num; + val_idx++) + dci_ptr->values[val_idx] +=3D + sci_ptr->values[val_idx]; + } =20 dci_ptr++; sci_ptr++; --=20 2.51.0 From nobody Tue Apr 7 08:08:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31779379EDA; Sat, 14 Mar 2026 14:18:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497912; cv=none; b=h5efcFFPAR7ghO80QAr/OfuVKLtbVEikZ0hv0NXXfEXtogQZK+IL6Bg8jQRQk4mXxp9Y9Z4cbHuBkr6Dw/fHPqehsTzPsdChc8E6+lBPMNeaoi4BI28O7P64koZNslARjT1olHfXnoeKiyHAD0L4Z8v8xsJ/i3gSPxgJ+Ko06ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497912; c=relaxed/simple; bh=RgrUA5TJU4QzuOsX9G//7Vx9Q7W7ExiHVFw2qC39ujU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=enmiKwipsAbKeWdHBfNFue0TyzkCtYV2GrzAGkeZQyzSOMIvmWSDNSPjIjH7uLHaPqJfNImglUxo7kykEd+Hm4KuAu8ydvXjEOsXo82x52Y1Ks+NQA+WKiOehI9tnW0B/j1odmecjxaub0MCTWyb/SShHjUQfdMc4XrpBZfHM/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uBJOagMD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uBJOagMD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C153C116C6; Sat, 14 Mar 2026 14:18:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773497911; bh=RgrUA5TJU4QzuOsX9G//7Vx9Q7W7ExiHVFw2qC39ujU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uBJOagMDgJtOPruL8phc3IYViyRGJ00R671+/t2u+72aE7B4UA0l8E5+bIUtGDgqG lv3LvW7jrmeYSs+nFg2Z1m4EcsPY+P+bZ3xi1kPNT+TfFTfZ5Z18nQrur3qe1K7x7V QToBUOrshtqRXw3MHpofoGekwVFAy4xfhNiQQH0GL46VuWnmRRiVx4H291vz0qhcQe HIS/DzRsOQIGCJBbTDe4E3qNVKUPyg+GJvOQr7NQ3zupJU2HJ8xF7wskLm7JpTxLm9 /GjtOi4r+elBw81GzMeUnICWAKZaCW4eV9a1dVKfLKA0K2KMp6xIwFGsDtmodE2B1W UMd0BDTCkvovA== From: Sasha Levin To: oberpar@linux.ibm.com Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Sasha Levin Subject: [PATCH 2/4] kconfig: add CC_HAS_CONDITION_COVERAGE for MC/DC support detection Date: Sat, 14 Mar 2026 10:17:47 -0400 Message-ID: <20260314141749.3382679-3-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260314141749.3382679-1-sashal@kernel.org> References: <20260314141749.3382679-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a Kconfig symbol to detect compiler support for -fcondition-coverage, which enables MC/DC (Modified Condition/Decision Coverage) instrumentation. This flag is available since GCC 14. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Sasha Levin --- init/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 444ce811ea674..38c8e06ad6d08 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -132,6 +132,9 @@ config CC_HAS_ASSUME config CC_HAS_NO_PROFILE_FN_ATTR def_bool $(success,echo '__attribute__((no_profile_instrument_function)) = int x();' | $(CC) -x c - -c -o /dev/null -Werror) =20 +config CC_HAS_CONDITION_COVERAGE + def_bool $(cc-option,-fcondition-coverage) + config CC_HAS_COUNTED_BY bool # clang needs to be at least 20.1.0 to avoid potential crashes --=20 2.51.0 From nobody Tue Apr 7 08:08:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AE7B379987; Sat, 14 Mar 2026 14:18:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497913; cv=none; b=AlzaOhKdlmb5Vev+7zVyiEA1AGiVqa7D5QpMcVgS8Eb3R+7KIq7CncHTTy1RSaaoAw2WEj8SEYUpyOs0RE3Hw1FTthuGMxMr+Pb3PkGGDxaJ4QeMKU7gZAnj1TPZ69MTknYFwEkRgzDYmDhLJeJtjDGjZufRx7Hc55+AaHCNwAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497913; c=relaxed/simple; bh=R7Eoxjt0rpoDjuA01JdtLx3RDGIy8zj4SJQms4s/xVA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZLSosXCRpozf/xzmHbxNrhCfDDZxYWda4ne4frPUaPK/NT4PeTQTgD/Tp66HSJnt7Zmx3GXpOIXgJ5nAI5N7TBdfdXFqrG9zBhGBrYow62SkIRe1mWEB3BkxNrjEEgrbsL1ZFSRiRkjQJV8panJ4J60AqEt5w7xUM+oWsJXobuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hqLirCrh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hqLirCrh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36D70C19424; Sat, 14 Mar 2026 14:18:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773497913; bh=R7Eoxjt0rpoDjuA01JdtLx3RDGIy8zj4SJQms4s/xVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hqLirCrhe5uvArb44+ijjOke8NkRc2pTnsYtEtQvLC6fSqq9/ekuzZgwQzL4DM30m ITP5r0Gj88Q5PaDf4iBEU8NUd9jhg9KYxJ35jZutddLbTre6mMVqJ5f6Rw6xVbqC8y BeahEq09FyRzD+QKK1JF49NDGsxHO9cf0pvXqbwsPbmL3ADcShuVELr81nlm92Y+x8 sNd/p6rwmGZJ2sTi+yUt/zsGQrmuJAS+tjkl9PmllO6MJ5yqlyaZSMXi3lgfC4lOQK qGK+g9NR2RXk5s0FuaVwQ44j6QICYzIcphNg28z8qQMSiGUgNdKUEuZzBAJ30b9ms8 h/um7kXP1ZRhQ== From: Sasha Levin To: oberpar@linux.ibm.com Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Sasha Levin Subject: [PATCH 3/4] gcov: add MC/DC condition coverage support Date: Sat, 14 Mar 2026 10:17:48 -0400 Message-ID: <20260314141749.3382679-4-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260314141749.3382679-1-sashal@kernel.org> References: <20260314141749.3382679-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add CONFIG_GCOV_CONDITION_COVERAGE option to enable GCC's MC/DC condition coverage instrumentation (-fcondition-coverage). MC/DC is required by safety standards such as DO-178C and ISO 26262. Add -fcondition-coverage and -Wno-error=3Dcoverage-too-many-conditions to CFLAGS_GCOV when enabled. Both flags are gated on the config option to avoid Clang warnings about unknown options. Also add -fcondition-coverage to CFLAGS_REMOVE in the x86 UML vDSO Makefile to prevent instrumentation of userspace vDSO code. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Sasha Levin --- Makefile | 3 +++ arch/x86/um/vdso/Makefile | 4 ++-- kernel/gcov/Kconfig | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2b15f0b4a0cb5..5b0657cd3e534 100644 --- a/Makefile +++ b/Makefile @@ -807,6 +807,9 @@ CFLAGS_GCOV :=3D -fprofile-arcs -ftest-coverage ifdef CONFIG_CC_IS_GCC CFLAGS_GCOV +=3D -fno-tree-loop-im endif +ifdef CONFIG_GCOV_CONDITION_COVERAGE +CFLAGS_GCOV +=3D -fcondition-coverage -Wno-error=3Dcoverage-too-many-condi= tions +endif export CFLAGS_GCOV =20 # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it l= ater. diff --git a/arch/x86/um/vdso/Makefile b/arch/x86/um/vdso/Makefile index 8a7c8b37cb6eb..3c8909f96a4c0 100644 --- a/arch/x86/um/vdso/Makefile +++ b/arch/x86/um/vdso/Makefile @@ -44,8 +44,8 @@ $(vobjs): KBUILD_CFLAGS +=3D $(CFL) # # vDSO code runs in userspace and -pg doesn't help with profiling anyway. # -CFLAGS_REMOVE_vdso-note.o =3D -pg -fprofile-arcs -ftest-coverage -CFLAGS_REMOVE_um_vdso.o =3D -pg -fprofile-arcs -ftest-coverage +CFLAGS_REMOVE_vdso-note.o =3D -pg -fprofile-arcs -ftest-coverage -fconditi= on-coverage +CFLAGS_REMOVE_um_vdso.o =3D -pg -fprofile-arcs -ftest-coverage -fcondition= -coverage =20 # # The DSO images are built using a special linker script. diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig index 04f4ebdc3cf59..7939c8f5ced3c 100644 --- a/kernel/gcov/Kconfig +++ b/kernel/gcov/Kconfig @@ -52,4 +52,19 @@ config GCOV_PROFILE_ALL larger and run slower. Also be sure to exclude files from profiling which are not linked to the kernel image to prevent linker errors. =20 +config GCOV_CONDITION_COVERAGE + bool "Enable MC/DC condition coverage instrumentation" + depends on GCOV_KERNEL + depends on CC_HAS_CONDITION_COVERAGE + default n + help + This option adds Modified Condition/Decision Coverage (MC/DC) + instrumentation using GCC's -fcondition-coverage flag. MC/DC + coverage data can be viewed using gcov --conditions. + + MC/DC is required by safety standards such as DO-178C (avionics) + and ISO 26262 (automotive). + + This increases instrumentation overhead. If unsure, say N. + endmenu --=20 2.51.0 From nobody Tue Apr 7 08:08:27 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9604C377EBA; Sat, 14 Mar 2026 14:18:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497914; cv=none; b=NkUmrcTpErtXamnOK4ig/FI6Xl63/xRTNjBa1kYMTG+ADcqfoauCoBm+c0p700dP/xObtpYowHEVDKuFQjDobIyS6Gy15NGsjgjOMFnb7hIIOjvv1k+jly4q+aIVlXxuedGf7eudjcyGPoxJ3pv218llUWQ+hpEqljzkzJXOohQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773497914; c=relaxed/simple; bh=cI+kSXFXn30p+LMwB0/AK36QZVSloLPjESbeCuBih94=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ViVjx8YGzrG4fFV/z2UUXYtdm7eOGR7wAm+IqAUbd/cl8O0lseD1JBCGOwSBBLxpkeF6wu76/9sVh5R2u41NODnhLdrEps5kxfZwTEJrIYkJRYlqJpjmtnXfsaimLDza9WpUtKe30pz3sKamatgiCPZXjTcC0wiIhD9JQI6ZTwM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H4p/LfWl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="H4p/LfWl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64D17C116C6; Sat, 14 Mar 2026 14:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1773497914; bh=cI+kSXFXn30p+LMwB0/AK36QZVSloLPjESbeCuBih94=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4p/LfWlHMy3AKoJMvno1mFyoiirZTQoEF3RTU+QWjYt1labE+zD9RHkcaRjTJoHW fJXnClziyP0RxhfVpG3Tmr8QVoWXemj/pv8QdAl5O+hQYxbIj9RMjJ0wWtqtHjKu/6 WVM9ME+qWo1cG1XGYrGvc/0dJVChqgV4utM8hNl+HIVF55QwD6j4swUitSevLULGk5 2xKFsWXxnhHlyb2I9KVkAQfO85CuaXLNtpYDgXb+h2S5KflovLqH4YBC1MZiE3Y/nh cnjAOtsHR6l2Vfjw0cSvsYNdBVTRrT9Q+/bJUavM4Z4WMq587sJnd+twoD2PwgBZQr eF+ggmPuyGFBg== From: Sasha Levin To: oberpar@linux.ibm.com Cc: corbet@lwn.net, skhan@linuxfoundation.org, nathan@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Sasha Levin Subject: [PATCH 4/4] Documentation: gcov: document MC/DC condition coverage support Date: Sat, 14 Mar 2026 10:17:49 -0400 Message-ID: <20260314141749.3382679-5-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260314141749.3382679-1-sashal@kernel.org> References: <20260314141749.3382679-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a section documenting MC/DC support, including the GCC 14 requirement, how to view condition coverage data with gcov --conditions, and the 64-condition-per-expression limitation. Assisted-by: Claude:claude-opus-4-6 Signed-off-by: Sasha Levin --- Documentation/dev-tools/gcov.rst | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Documentation/dev-tools/gcov.rst b/Documentation/dev-tools/gco= v.rst index 075df6a4598d8..57b9345060c5e 100644 --- a/Documentation/dev-tools/gcov.rst +++ b/Documentation/dev-tools/gcov.rst @@ -180,6 +180,31 @@ b) gcov is run on the BUILD machine [user@build] gcov -o /tmp/coverage/tmp/out/init main.c =20 =20 +MC/DC Coverage +-------------- + +When using GCC 14 or later with ``CONFIG_GCOV_CONDITION_COVERAGE=3Dy``, +Modified Condition/Decision Coverage (MC/DC) data is collected alongside +standard branch coverage. MC/DC verifies that each condition in a +decision independently affects the decision's outcome. + +To view MC/DC data, use:: + + gcov --conditions -o /sys/kernel/debug/gcov/path/to/dir file.c + +MC/DC coverage is required by safety standards such as DO-178C +(avionics) and ISO 26262 (automotive). + +GCC's condition coverage implementation has a limit of 64 conditions per +boolean expression, due to the use of 64-bit bitmasks internally. +Expressions exceeding this limit cannot be instrumented and will produce +a compiler warning. This does not affect the correctness of the kernel; +those expressions simply will not have MC/DC coverage data. + +Note that MC/DC instrumentation increases binary size and execution +overhead compared to standard gcov profiling. + + Note on compilers ----------------- =20 --=20 2.51.0