[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 09/12] Eclair: deviate BUILD_ERROR() wrt rule 2.1 and introduce variants


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Sat, 29 Aug 2026 16:04:42 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1788012283; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=YPq55LcariTfRIgkToCnifE9romNqBh34Zbm15cX+N8=; b=Bgtu9QbAuanLWeUc+YiMedoRGpq0TLTfiisknIbjDXOIwcnU/XAqc2EP6E2mhXEzdjZu WbFrzlFgxjJiXA+g3H8l3H/VsOZBZyeWZV1fPqLtnupWJD0I4D2urz7qNbD9XP65NcdA0 4uPA6TzMwSJi26woKcJ4wqqKBg7n6LilmsoyPeS6dH2DSenjqwbkurmEg3yirVEbW04n9 RuLdQt8JooEvBvTvmm0xsYHr2h8nh+GNRdmzjGGMLb1v95FqEhndPFWz//XRZfODi5YdT rrTF9FZIa6MJr6SE1xpjucmfzmoZ9XrbgIV2AZAsBM/BJ9xPhawF7166HfTa3BAYOXOJS xiBWwmhO5xHkuSMIf+2LCI2CNsAsEwMTwYyxg4jleJXvWJR5gDXWRRmDQNBYeQY8U8KAb RbqVhsFCnrfBFNIaiFXW0Ywo0OhYNGf380QK3BLnnYEwUAG3k155n3XFH/X2PGMPJCn+u XUUVEjfLeL3CXUXmJabuq+KlF5QEBscNXGDCHVwNV95jFxOkH5jEaTzKUKuiWLGbFCWO2 cBitMp22B/SCHMQAdnOUm3Jc/7fWoZ/09V0t3iyUxNH8IKNJf0RO5V0jV3fxfP9Qlan4Q LKqX1CAOK7dX4M9Dt/vlp52MPPiGgdtv7QuwVgQeEZTFbwkAJr9ux9CTK0izIo0=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1788012283; b=McTwEUebFObeKEVigMbKpOIXwZRDo29CsdbGhfQrGTyGxdalmyUXpADoQPg5Dj6bTab9 9v19MeivsBsq343sLyLIjk/kPxtzpEVxdotFmeQmtzdrz9p/6ev9iLTEgMt5fQpEf1M59 iQihR777jb2A534M6T8sWmHBYDpShNOC08LhrPsnoXK6m9aSsrh/xMPdzaXGJ2ztxDO5Y 6KtgzEMsvav8ZMtkh6fAdsIGaFuvT+9XlpIsGBFkqCB4tKZv0qdEkIJKeVHC1jxQECfzg WghW9yDUxnTa7dVy/H4BkdQgMT+Yk7Y0RNSNnsMjSg67EKABRuyKioxJxJIZHSogo/QsE 6uo1doGUJu8d+5cEKuODUahA80UIR5wpwt/tIej5L8V52K4fYfK+lB4KDUA+TDxWAdvRv 7WSNiUeDCGzdVTAYlQlifwsjXWMNy864y4q0RC7vlyNfIWxbXoqM2Zvlrz1wjfANUHsOx U8NvJLa/iEQGiC2zOwJMBqrNKyD0k8h5GJPz55uX9BNi51hIxGrAn866UZCuA6/FrTo2Q +iDc1F5tBD8a3Bo7tKzm+nMkigjOlfyx1lBdipsdfnZwTuPyR0X2+etPI4/Nt1TnM6kx/ vM5s6z+p7dIp75IW16IZUHIxpsH3ZS8qn4/WsX3DUOacuq6aC3IO+q8rO0L76xg=
  • Authentication-results: eu.smtp.expurgate.cloud; none
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
  • Delivery-date: Sat, 29 Aug 2026 14:04:51 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-08-28 09:04, Jan Beulich wrote:
BUILD_ERROR() is even stronger a guard than assertions in general, and
ASSERT_UNREACHABLE() (or BUG()) in particular. Deviate it just like those
to allow use for marking unreachable portions of code.

In some cases code being unreachable is dependent upon configuration.
Introduce two variants, as constructs like

    if ( IS_ENABLED(CONFIG_...) )
        BUILD_ERROR("...");

results in the if() still being reported as unreachable. Sadly these two
new macros introduce a new 20.12 violation each, which hence also needs
deviating.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>

Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>

Presumably you did not fold at least one of the following patches where the construct is actually used into this one to separate concerns?


--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -19,6 +19,7 @@ Constant expressions and unreachable bra

-doc_begin="Unreachability inside an ASSERT_UNREACHABLE() and analogous macro calls is deliberate and safe." -config=MC3A2.R2.1,reports+={deliberate, "any_area(any_loc(any_exp(macro(name(ASSERT_UNREACHABLE||PARSE_ERR_RET||PARSE_ERR||FAIL_MSR||FAIL_CPUID)))))"} +-config=MC3A2.R2.1,reports+={deliberate, "any_area(any_loc(any_exp(macro(^BUILD_ERROR(|_IF(|_NOT))$))))"}
 -doc_end

-doc_begin="The asm-offset files are not linked deliberately, since they are used to generate definitions for asm modules."
@@ -667,6 +668,7 @@ deliberate."
to the # or ## operators within the following macros are deliberate, to provide
 useful diagnostic messages to the user."
-config=MC3A2.R20.12,macros+={deliberate, "name(ASSERT||BUILD_BUG_ON||BUILD_BUG_ON_ZERO||RUNTIME_CHECK)"} +-config=MC3A2.R20.12,macros+={deliberate, "^BUILD_ERROR(|_IF(|_NOT))$"}
 -doc_end

-doc_begin="The helper macro GENERATE_CASE may use a macro parameter for ordinary
--- a/xen/include/xen/macros.h
+++ b/xen/include/xen/macros.h
@@ -64,6 +64,21 @@
  */
 #define BUILD_ERROR(msg) asm ( ".error \"" msg "\"" )

+/*
+ * Like above, but conditional upon @cfg (not) being enabled. @cfg must be
+ * suitable to pass to IS_ENABLED().
+ */
+#define BUILD_ERROR_IF(cfg)                               \
+    (IS_ENABLED(cfg)                                      \
+     ? ({ BUILD_ERROR( #cfg " unexpectedly enabled"); })  \
+     : (void)0)
+
+#define BUILD_ERROR_IF_NOT(cfg)                           \
+    (!IS_ENABLED(cfg)                                     \
+     ? ({ BUILD_ERROR( #cfg " unexpectedly disabled"); }) \
+     : (void)0)
+
+
 /* Hide a value from the optimiser. */
 #define HIDE(x)                                 \
     ({                                          \

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.