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

[PATCH] misra: deviate MISRA C Rule 18.3 for linker symbols


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 1 Dec 2026 20:24:10 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • 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=rpFpdU5rpDa62zOcn7MCMok7wgv+v5M38jrU3xhHrjw=; b=MTSjxYWD+pMSmOXBrQnVA0exacerjoUKHG5f/PvylqPKnhu+3P2SEE0MGHKevoPrltOetc7camxvAHki4lPD44mKtdmtwesM279IDwwSQ01Fc0XhTy52SXOoAjK1un9fb37j1K+bDKG3bj2CPALMY+obKt4flhpojG27hgbH1lRXGgtr9Pg5m8mmU7AQEH43uUuzKx46qCuDoaqx5B15sLajrQq3LZptkvIY4ve9Z3CYyVAg4XAr/BJ5y+hoY5erRRj+DBKFIwkuD5WxwfqhfSOy2adoxlOYGRR82mqOusp/26tsLLq0XO14yrkSQpyJziFQt11B4OPNIqAMeFk6Lw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=MeL6kTbVl2x1KoADnPJ6a9kPytBIHpFibWPeOu0HaDn0kSuVRxEFh2f7yCEaBvOSNR5cc5t4/tBVZDIRKRzkW84HtavmnwC/Lz6ybMPcPPcBi1B7rPJA3YxjFQzJYh29hri2xdHG6e/+FrUZcdTzq49lg29EqtvnpXo7cDz/M07nRpEEjhMHd5yzXghQQ8Y+yR0byK54lJSqNxTl5l90vLLPGjYtTgtnlo8RG+1U4pZL5mSr96/ItYkNnkQoBHGJaOf/yT/hic693eE8cAis9wCFMcsmilkX61DE9Y46NQdx6m8YheZSbjU8O5vO50rPq9SKuJLmTiu/J/2J1kws4g==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>
  • Client-request-id: 484c2700-8b56-4b80-875b-e9319f2a7aa9
  • Delivery-date: Tue, 01 Dec 2026 20:24:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Request-id: d7e7e901-e566-4c7e-7d7f-08df4fe90ecf
  • Thread-index: AQHdgdHsVlYzt60DaUmsACRLd4JJVA==
  • Thread-topic: [PATCH] misra: deviate MISRA C Rule 18.3 for linker symbols

MISRA C Rule 18.3 states: "The relational operators >, >=, < and <= shall
not be applied to objects of pointer type except where they point into
the same object".

Comparisons against symbols defined by the linker (e.g. _stext/_etext
in is_kernel_text()) are used to check whether an address lies within
a given section. Such comparisons are safe, as section boundaries are
laid out by the linker.

Deviate the rule for relational operators where at least one operand
refers to a linker symbol, in the same way as already done for
Rule 18.2.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/3139308713
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 5 +++++
 docs/misra/deviations.rst                        | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index cdcdb4622c..d45af2f895 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -626,6 +626,11 @@ C99 Undefined Behaviour 45: Pointers that do not point 
into, or just beyond, the
 -config=MC3A2.R18.2,reports+={safe, 
"any_area(stmt(operator(sub)&&child(lhs||rhs, skip(__non_syntactic_paren_stmts, 
ref(linker_symbols)))))"}
 -doc_end
 
+-doc_begin="Relational comparisons between pointers involving at least one of 
the linker symbols (see the linker_symbols selector above)
+are safe, as such symbols mark section boundaries laid out by the linker."
+-config=MC3A2.R18.3,reports+={safe, 
"any_area(stmt(operator(lt||gt||le||ge)&&child(lhs||rhs, 
skip(__non_syntactic_paren_stmts, ref(linker_symbols)))))"}
+-doc_end
+
 -doc_begin="The following macro performs a subtraction between pointers to 
obtain the mfn, but does not lead to undefined behaviour."
 -config=MC3A2.R18.2,reports+={safe, 
"any_area(any_loc(any_exp(macro(^page_to_mfn$))))"}
 -doc_end
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index eb5817f88b..6adec8ca29 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -644,6 +644,11 @@ Deviations related to MISRA C:2012 Rules:
        are safe.
      - Tagged as `safe` for ECLAIR.
 
+   * - R18.3
+     - Relational comparisons between pointers where at least one of the
+       operands is a pointer to a symbol defined by the linker are safe.
+     - Tagged as `safe` for ECLAIR.
+
    * - R20.4
      - The override of the keyword \"inline\" in xen/compiler.h is present so
        that section contents checks pass when the compiler chooses not to
-- 
2.43.0

 


Rackspace

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