All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simone Ballarin <simone.ballarin@bugseng.com>
To: xen-devel@lists.xenproject.org
Cc: consulting@bugseng.com,
	"Maria Celeste Cesario" <maria.celeste.cesario@bugseng.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"George Dunlap" <george.dunlap@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Julien Grall" <julien@xen.org>,
	"Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wl@xen.org>, "Roger Pau Monné" <roger.pau@citrix.com>,
	"Simone Ballarin" <simone.ballarin@bugseng.com>
Subject: [PATCH 9/9] xen: add SAF deviation for safe cast removal.
Date: Thu, 14 Dec 2023 13:07:51 +0100	[thread overview]
Message-ID: <36e996b864853dba26a9c9fb9c9c674e92cc935e.1702555387.git.maria.celeste.cesario@bugseng.com> (raw)
In-Reply-To: <cover.1702555386.git.maria.celeste.cesario@bugseng.com>

From: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>

The xen sources contain violations of MISRA C:2012 Rule 11.8 whose
headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification
from the type pointed to by a pointer".

In function __hvm_copy, the const qualifier is cast away to comply with its
function signature. There's no modification of the pointee during its
execution, therefore its use can be deemed as safe.

Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@bugseng.com>
Signed-off-by: Simone Ballarin  <simone.ballarin@bugseng.com>
---
 docs/misra/safe.json   | 8 ++++++++
 xen/arch/x86/hvm/hvm.c | 1 +
 2 files changed, 9 insertions(+)

diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index 952324f85c..e748bc6cf5 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -28,6 +28,14 @@
         },
         {
             "id": "SAF-3-safe",
+            "analyser": {
+                "eclair": "MC3R1.R11.8"
+            },
+            "name": "MC3R1.R11.8: removal of const qualifier to comply with function signature",
+            "text": "It is safe to cast away const qualifiers to comply with function signature if the function does not modify the pointee."
+        },
+        {
+            "id": "SAF-4-safe",
             "analyser": {},
             "name": "Sentinel",
             "text": "Next ID to be used"
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 523e0df57c..414853254f 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -3413,6 +3413,7 @@ static enum hvm_translation_result __hvm_copy(
 enum hvm_translation_result hvm_copy_to_guest_phys(
     paddr_t paddr, const void *buf, unsigned int size, struct vcpu *v)
 {
+    /* SAF-3-safe */
     return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */,
                       paddr, size, v,
                       HVMCOPY_to_guest | HVMCOPY_phys, 0, NULL);
-- 
2.40.0



  parent reply	other threads:[~2023-12-14 12:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-14 12:07 [PATCH 0/9] xen: address violations of MISRA C:2012 Rule 11.8 Simone Ballarin
2023-12-14 12:07 ` [PATCH 1/9] xen/arm64: " Simone Ballarin
2023-12-14 21:38   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 2/9] xen/arm: " Simone Ballarin
2023-12-14 21:42   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 3/9] xen/efi: " Simone Ballarin
2023-12-14 16:32   ` Jan Beulich
2023-12-18 14:32     ` Simone Ballarin
2023-12-14 21:45   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 4/9] ACPI: " Simone Ballarin
2023-12-14 16:36   ` Jan Beulich
2023-12-18 15:05     ` Simone Ballarin
2023-12-14 21:49   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 5/9] xen/x86: " Simone Ballarin
2023-12-14 16:41   ` Jan Beulich
2023-12-14 21:50   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 6/9] xen/ppc: " Simone Ballarin
2023-12-14 21:51   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 7/9] x86/hvm: " Simone Ballarin
2023-12-14 16:43   ` Jan Beulich
2023-12-14 21:52   ` Stefano Stabellini
2023-12-14 12:07 ` [PATCH 8/9] xen: add deviations for " Simone Ballarin
2023-12-14 12:46   ` Jan Beulich
2023-12-14 12:07 ` Simone Ballarin [this message]
2023-12-14 16:51   ` [PATCH 9/9] xen: add SAF deviation for safe cast removal Jan Beulich
2023-12-14 22:04     ` Stefano Stabellini
2023-12-15  7:59       ` Jan Beulich
2023-12-15 21:02         ` Stefano Stabellini
2023-12-18  8:18           ` Jan Beulich
2023-12-19  1:23             ` Stefano Stabellini
2023-12-14 12:36 ` [PATCH 0/9] xen: address violations of MISRA C:2012 Rule 11.8 Jan Beulich
2023-12-18 14:28   ` Simone Ballarin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36e996b864853dba26a9c9fb9c9c674e92cc935e.1702555387.git.maria.celeste.cesario@bugseng.com \
    --to=simone.ballarin@bugseng.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=consulting@bugseng.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=maria.celeste.cesario@bugseng.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.