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

[PATCH] misra: add deviation for MISRA C Rule 18.3


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Wed, 20 Aug 2025 12:44:19 +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=9iH5dFHiOKWzkPchOkXAXALka1CWtQksfFajkNb5o98=; b=H7Ujz1vOstDp/G3q9DZ3+/tGZPt8jfQwoPbLs2PuO/FON8rli2VZ30vT3xnKcH4kAnMnLO8nYQUhYxsF5wS59c1r5ve0DJARVgPV+LgvHR7YMabDl2Vk23XHp5SFe4XwAKorpaJ3m2NFXcnKUR2wnLvIDn0hQXkE9W22t4inNs8NHnhcRV/XBkvHHz+aujDIl67Yrj6yPu3JvgTDjJ4C2W/dIgKq+es3rJXDZXTRX2F0COdEQzjVZdewiM70Sf4MH7tsMwai5FsYSKw2F6Djg2lYGv+ty1yPzMgBUTIl3tZfgsHrAPoadxoT4HuQbfnZxffs4xWbwDRXO/8Jnu1zGA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=d8B0zMFH7QfCTV4ubQbVJnKcPGPY+1Ehj1bd9fDEzP2Bd1neBkNIClXsVD07BzllvIRxnrB/OP+TDJadSQp5LK8peTgMupEp+dPL36uYpz16ZKlwhP02VtMMpqPjGk3gkvoJY9H+eHZShYI3E25P6IhI79hTI0RSeXd9j2hf8M37yE8rnRJe+ekVBFB9zws7esRHm+RlzciJmTYmD1neuV0jBVpVR++83PZ7H3eHpkcf/K7P16XY01XHFZKwPiQQfgbAN8xqzyQ7FuujaozAuDVvLHsccmsFna2UYsMvKIUh2akwXjce5DZagHP4uPgN4Zgc3sQriek3olN9SCN/6w==
  • Authentication-results: 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.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 20 Aug 2025 12:44:29 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcEdAlL6ZgiilPSEOu1KBVqkWanQ==
  • Thread-topic: [PATCH] misra: add deviation for MISRA C Rule 18.3

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 in the 'find_text_region()' function are safe because linker
symbols '_stext' and '_etext' represent fixed virtual addresses within
the same '.text' region, and the function 'addr' argument is explicitly
compared to known valid memory bounds ('text_start' and 'text_end')
derived from these linker symbols:
    if ( (void *)addr >= iter->text_start &&
         (void *)addr <  iter->text_end )

Configure Eclair to suppress violation reports occured in the function
'find_text_region()'. Update 'deviations.rst' file accordingly.
No functional changes.

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

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 7f3fd35a33..32b596c9da 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -590,6 +590,12 @@ C99 Undefined Behaviour 45: Pointers that do not point 
into, or just beyond, the
 -config=MC3A2.R18.2,reports+={safe, 
"any_area(any_loc(any_exp(macro(^page_to_mfn$))))"}
 -doc_end
 
+-doc_begin="Comparisons in the 'find_text_region()' function are safe because 
linker symbols '_stext' and '_etext' represent fixed
+virtual addresses within the same '.text' region, and the function 'addr' 
argument is explicitly compared to known valid memory
+bounds ('text_start' and 'text_end') derived from these linker symbols."
+-config=MC3A2.R18.3,reports+={safe, 
"any_area(any_loc(file(^xen/common/virtual_region\\.c$))&&context(name(find_text_region)))"}
+-doc_end
+
 -doc_begin="Flexible array members are deliberately used and XEN developers 
are aware of the dangers related to them:
 unexpected result when the structure is given as argument to a sizeof() 
operator and the truncation in assignment between structures."
 -config=MC3A2.R18.7,reports+={deliberate, "any()"}
diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst
index 2119066531..a726fb22a8 100644
--- a/docs/misra/deviations.rst
+++ b/docs/misra/deviations.rst
@@ -586,6 +586,14 @@ Deviations related to MISRA C:2012 Rules:
        are safe.
      - Tagged as `safe` for ECLAIR.
 
+   * - R18.3
+     - Comparisons in the 'find_text_region()' function are safe because
+       linker symbols '_stext' and '_etext' represent fixed virtual
+       addresses within the same '.text' region, and the function 'addr'
+       argument is explicitly compared to known valid memory bounds
+       ('text_start' and 'text_end') derived from these linker symbols.
+     - 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®.