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

[RFC PATCH 2/2] misra: deviate R2.6 for the labels generated by CASE_SIMD_*


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Shuaidong Chen <shuaidong.chen@xxxxxxx>
  • Date: Tue, 10 Nov 2026 15:12:31 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lwG8GIj9d9ouz4R9r6IwbYqqep3MBKMHa8e6lIDKyFM=; b=ryPmXEcOxZFULNrvIPMgKvKljAUTVWnjm4dQfssuPP5msW+yLyB8izgruhMgKwAvkOuDgXovBWQKH4nAhfdgQ0Lng9Al2dBvKL/97Lk4IQpKNS7PFdEuwiTXSQeb8BTCp/aOF/Zj3DwFiQX/xkGPPV1MGRDPTW7Yg0tYE1+w4yHd8lwvnZCMN3mBDEqxmboeTM1Zc7VrzNjfzhaaaNTvwRGlJ/z5V5ep2o98CCniku9eIw4b9ymUs4fLRlbKbt0MXCwlrcTVFA5KfD3k4/ZA5kXd3WKATFN1DAKMOE7FREVtGZJy+ZjCQGZFjMsleWcEXN4rCjUTDyHevR9HxphpvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=pDULDHevmnKHo3WGUqScNRVDUfJYphkfsChOTznnclfiQXLtnkM9uY0Vn2FlpCztKiICsAPpfNoPn6OfRerJbkcVhEYmtgDV1qRGLukhKvzo7fiJPe4sVLRTc7s3oGGfp6Umoeim67dXY8xwfGZz2BB9ltNhCscGo4ASJyZlcjZR6PSu0iHddtwPgsMG3bY159wOX6ajRBhlMWm2oBIZzx+8ofBUV9Y/JO04/m2TDRgl577b1pFXVQBg/bUPMLV1pVTTYYZIEYKeROUV0kUIYLukwfkrnKOuaNJ03dUrNlW8CCKq2ILly4uxhM/eh59TQgdJivRJtruG2ZU58qMwcw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Nicola Vetrini" <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>, Grygorii Strashko <grygorii_strashko@xxxxxxxx>, Penny Zheng <penny.zheng@xxxxxxx>, Ray Huang <Ray.Huang@xxxxxxx>, Shuaidong Chen <shuaidong.chen@xxxxxxx>
  • Delivery-date: Tue, 10 Nov 2026 07:13:26 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

MISRA C:2012 Rule 2.6 (advisory) states that "a function should not
contain unused label declarations".

When SIMD emulation is compiled out of the x86 emulator (CONFIG_HVM=n),
private.h defines X86EMUL_NO_SIMD and the CASE_SIMD_* macros
deliberately expand to plain identifiers instead of case labels, so
that the opcode switch builds without conditionals around every case.
The labels they produce (e.g. Cs0x0f_0x2b) are never the target of a
goto, and the build already passes -Wno-unused-label for this object.

These cannot be annotated in the source: ECLAIR reports them at the
macro's use site, while __maybe_unused could only live in the macro's
replacement list, out of reach of the existing text-based R2.6
deviation.  Extend that deviation to labels coming from the expansion
of a CASE_SIMD_* macro, and document it.

Signed-off-by: Shuaidong Chen <shuaidong.chen@xxxxxxx>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 4 +++-
 docs/misra/deviations.rst                        | 9 +++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 296340bb4c..6055279674 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -51,8 +51,10 @@ removed by the compiler, the resulting slowdown is 
negligible."
 -config=MC3A2.R2.2,reports+={disapplied,"any()"}
 -doc_end
 
--doc_begin="Some labels are unused in certain build configurations, or are 
deliberately marked as unused, so that the compiler is entitled to remove them."
+-doc_begin="Some labels are unused in certain build configurations, or are 
deliberately marked as unused, so that the compiler is entitled to remove them.
+With SIMD emulation compiled out, the CASE_SIMD_* macros of the x86 emulator 
expand to plain labels in place of case labels."
 -config=MC3A2.R2.6,reports+={deliberate, 
"any_area(text(^.*__maybe_unused.*$))"}
+-config=MC3A2.R2.6,reports+={deliberate, 
"any_area(any_loc(any_exp(macro(^CASE_SIMD_.*$))))"}
 -doc_end
 
 #
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index bee4686675..658e438980 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -116,6 +116,15 @@ Deviations related to MISRA C:2012 Rules:
        such labels poses no risks.
      - Tagged as `deliberate` for ECLAIR.
 
+   * - R2.6
+     - When SIMD emulation is compiled out of the x86 instruction emulator
+       (X86EMUL_NO_SIMD), the CASE_SIMD_* macros deliberately expand to plain
+       labels instead of case labels, so that the opcode switch builds
+       without conditionals around every case.  Nothing jumps to these
+       labels, and the code behind them stays reachable through the
+       remaining case labels.
+     - Tagged as `deliberate` for ECLAIR.
+
    * - R3.1
      - Comments starting with '/\*' and containing URLs are safe as they are
        not instances of commented-out code.
-- 
2.34.1




 


Rackspace

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