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

[XEN PATCH 2/2] Address violation of MISRA C Rule 13.1 involving asm side effects.


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Fri, 8 Aug 2025 23:40:47 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=93.57.251.141
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1754689259; h=DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=NGuzVXZc9lVbFupjO0fco9+V+MPeZQpDHOKUM0agI9I=; b=PuVOB3kGCIWKxZSRdepALhZMBzzlpFCTdwU9KWNpECW618asLW0TbcUDesRxFjmFinbc 9qgTVLgjDXkZku0kLiannJj2lP4HyoGbyD0EjAKtCvWGz843l7UOpEVV1v/0eJ7w8dI8O vZr+w6VvP96PiaQtGQvq5DdesaOaJVUSjKmTyGGKOIJsaMkP2iZ8cw1CwpJ2ifuQDQzpf mzmEFUcq6o4XEAhJzciuo93+igxkBY6dVf3D46dl0G9n4dB1zStAn1N9CCdvOXP6CXWQn 1zGVStea10bl9aWbaebQQdLH4czUdSq+hIPEt5BoxK/5sPYt/NJZceAJ5MbyZHkVkQVim 772nQAwA7okaVB+711FCPAPF+rD2SOeUjygUB4JwkHeoyuuzg4RFNjYstmdAlXoAPAb8d roS2bavCgJm/FYMk+S/MlkqoYEDqYlkCRzwi+ILPaumD0CRBoVBdar7vANf1joTKszUXT YNJHW+oQjfw1AYuz2lIn1GvLvTKXqbUvctCp277x8Mf5F0nbZjVjyidDr6K384v8YKJsR yKpBVvj35y2R3z9m3OOyaX4QIzJBDdavMu5lIhmiVHzOM39DZRuqXWyyq4ESRmzphIgLU kKpm3setpvm26KBoNKgC9wgBeDR1bnEpXmdmKHUMcYZ+Ax2hucjR7CBKX9X+xRc=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1754689259; b=q5g7RvThsuYjmcpBItnZcbFV9lVRoa5sTlyqsaJ17n+nRnMD5iPp+5SOh0xOGvczGUQK 0FaJkU6Xh4mXo6BnaAfewvWoVwkcxfdgKbEHLU7SsMG7gJ4BjNypNgGIjPDfC8/lHUmq7 xUGuBrQKsmgUEIOFrowpYEB+cpShayMOlOR/DF8CiWXmBbdYPhCxUxdyGH0MvPQgTrg6Z LgiPyYRDe66a6MFFTyqfvUjuxDD57v9zF9DE3+eKaw+zzBqlrYeh81NKxhHkmQfwT4a85 X5hGvwjQf+5M+kHagn7tTGfjUn4nBif2k839RB+t3DgvzNWKUxHdVjlqRTyUaKaXRJ9+d kP/LUqMctQZR3HD/dHkkumUVwpSHJan0o9QUcIqIVB0LOF/T4qTAcVAEL5A9vBhdZ3AK0 SlE47Tx8Ieds9yRzMV89W2xfJnLN/Fp5+xs8XSeFbKnH5PTRpIbbqm0ROA1q6WAFNzQZF Ci2fDcJQme7fZ+7/j0mgQ0I34MMvLwst6FkV6CFGGBno7cn09f+C9f15e5IRwcC6K9gFb 8WeIr/MGByHMjYP2o/eHVotugVnEnZHrh4zCiP+iCBPulHnR8rNU/v2kC6DdMbP2ONLPE f3j8TkCCQyrlJlMDyfCKsQRl+t/zQNNxSM1XovBdkSwfV8UO2sU9sid+wVrVhEY=
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=93.57.251.141
  • Cc: sstabellini@xxxxxxxxxx, consulting@xxxxxxxxxxx, dmytro_prokopchuk1@xxxxxxxx, andrew.cooper3@xxxxxxxxxx, jbeulich@xxxxxxxx, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>
  • Delivery-date: Fri, 08 Aug 2025 21:41:09 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The rule states: "Initializer lists shall not contain persistent side effects".
The specific way in which the 'mrs' instruction is used does not lead to
visible side effects for the surrounding code.

Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
---
Not yet tested on the Xen ECLAIR runner, as the syntax used in the deviation
is only supported after updating the runner.

What the tool is reporting is that due to the '=r' constraint and the
semantics of the instruction, there is the side effect of writing to '_r',
but this is not observable outside the stmt expr. The deviation ends up being
a bit too general for my taste, but the restriction on the actual istruction
should be enough to limit applicability to cases that are arguably safe in
practice.

An alternative approach would be represented by stating that side effects in
'READ_SYSREG64' are safe, but this is not true in general.
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index ec0cac797e5f..6b492e38505d 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -437,6 +437,10 @@ write or not"
 # Series 13
 #
 
+-doc_begin="Consider the asm instruction to read an Arm system register to 
have no side effects."
+-asm_properties+={"asm(any())&&child(text, ast_field(value,^mrs\\s+%0.*$))", 
{no_side_effect}}
+-doc_end
+
 -doc_begin="All developers and reviewers can be safely assumed to be well aware
 of the short-circuit evaluation strategy of such logical operators."
 -config=MC3A2.R13.5,reports+={disapplied,"any()"}
-- 
2.43.0




 


Rackspace

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