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

Re: [PATCH] x86/shim: adjust for Misra C:2012 rule 20.12


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Date: Wed, 13 May 2026 23:07:18 +0200
  • Arc-authentication-results: i=1; bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Arc-message-signature: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; c=relaxed/relaxed; t=1778706438; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:X-Sender:Organization:Content-Type: Content-Transfer-Encoding; bh=EJJPGORqhSahaG4Yo4YCJnTQFEkFGg7G9VmW7fkOktY=; b=jL81OBv/jDmMzaMllh0tWpOinFJ83UyVEZRGk9aHIR3dKCqRa5osC9AuYP8OaCt4R9XK tOJnJZIrrY7t7aVXGf0XwaV78Byx5oC8MJQNqNMucRmp3wxUbLy4Qfo4kjXc+TVO/dzUg aVOSXnuI7BPaK3feh1MvkjRVZ2sx2wn0aYi8K5Xg+6QEOOV5ipKMtDMZ+NOMaEj8sBf5w tzDngkV5LsnNZOY5BP7FsSS7QFdMLm3fW6DcWabC4icc2dNvh9tZwx/1F9IyRsac7gUiC M/6L0UPeefmxfl5txDiGG4z2bD55Jh7Ocbs3AQi3vrtlWwNkMZ0xYMrD+9+JY0L2KSrKb CWYOdZ/fAbiywG9xR83nv8INDMYV4OAE0F7XaacF6W2RlpZZnl9lUdzn+Ezq4zmmULWIS GpVil0npQ7fGxgnn6pvdeIkLUvWMaBvkIlQkHmE8P/IiyKO9WZPTvl/RLDF5TCzfWw9+X db8H73WiwTpapxAnZATxbrvvO0KJibyIYYI0PGdqD3DqKEYHymTRmYn9js/x7PHE4trtz qxQ7o/ppU+S/YNvMzlFFM5Y5AWQw5M6gLiU41feKTCYd+o+PuW4Y4i5w/iWeEZYIy6sOl 34d7/S2YqH1ZkcQJ7oE1QpwsVXJeF8ZXcd+14eC9GYrl1L+FIRq8i5wNw7u6c0w=
  • Arc-seal: i=1; d=bugseng.com; s=openarc; a=rsa-sha256; cv=none; t=1778706438; b=lKYF5CtIub/XWAkXp17OZplT/s0L8RDupaMeV2fcptHWimgDLVVyayXjxd0izOuSQ5kK HP/xFU4Q0IbNXDeZ5zurZ7KXQIuGoZoez7GgnXjEhBl9HT7dWf3ZyxWtdT6XDfnkkL/QV xq48BShyJpP76l/8Ifb8H5UMn9CJGb+oGnW4XR90WfDMqwcMGYB8YUAMzH5US+mcsfwYJ Bw9Pm57cgQqWYkq8yF2NBzNt/P1kmWziirY5mge6S3NFl6Bb5jbfnXklA3WFi9D9/2wcc 7Y/m7XTBkUGbBXHvVeejUyV8Pi44mCkc+yUYxzZIEelCh2cVvpnbuKam64Gq+6VIgWvbO 7VyIL86BmhHGMYE9cFKk+gfjhFycAmxQDO9ile21ZLL1d5yGpR1znBKROvGaFtiyXhEyt D98bMP9Qa5qmRGpC1eNC7GiwpcFF0q+4a8aUEglS+R5DfJzEwZr4zA7rCf1BxH/r2Op2V YBAB8V+lVUUyXksT2vQKTUqEcGWnqj77HDB1QcrSJ4s5pHX3la+X1eycO98Cy+LD+mbed fOox3BuuWJBrvqI3eXrH6tZxdIMa68GaSVXTP7JV5LcuMRYEXKtL4Y9LU7DUtMH+yHWqj 6Q4cJqHVn0FCeKGNrDXlknn74a0zJnfj0z78DRsOXZj7gpFE2J1/Q72KUQtvtnM=
  • Authentication-results: eu.smtp.expurgate.cloud; none
  • Authentication-results: bugseng.com; arc=none smtp.remote-ip=162.55.131.47
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Wed, 13 May 2026 21:07:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 2026-05-13 18:30, Andrew Cooper wrote:
On 13/05/2026 4:52 pm, Jan Beulich wrote:
... ("A macro parameter used as an operand to the `#' or `##' operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators"). Move the HVM_PARAM_ prefixes into the
macro body, to use ## on the 2nd use (each) of the macro parameter.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
I understand that this "absorbing" of prefixes isn't liked by some people,
so I'm all ears towards alternative suggestions.

https://gitlab.com/xen-project/hardware/xen-staging/-/jobs/14354119193
(also covering the 17.5 patch)

Yeah, I'm a firm -1 to absorbing the prefixes.  This is simple
obfuscation just to hide it from Eclair's eyes.

The ARM folks fixed this by using a SAF-6 annotation.  e.g. 195d754170891

Although honestly, the more I think about this, the more I think we
should just globally deviate.  I don't consider the concept having a
well-named constant be used both as a value and a string a confusing thing.


There are already special cases for R20.12 also for things like GENERATE_CASE

-doc_begin="The helper macro GENERATE_CASE may use a macro parameter for ordinary expansion and token pasting to improve readability. Only instances where this
leads to a violation of the Rule are deviated."
-file_tag+={deliberate_generate_case, "^xen/arch/arm/vcpreg\\.c$"}
-config=MC3A2.R20.12,macros+={deliberate, "name(GENERATE_CASE)&&loc(file(deliberate_generate_case))"}
-doc_end

which fits this macro perfectly. The more general question is whether we want to whitelist certain macros uniformely, or in general Xen developers want to use that pattern, because that conversation has two very different outcomes: one is the disabling of the rule, though there is an associated unspecified behaviour. Us.B 25 for C99 to be precise: The order in which # and ## operations are evaluated during macro substitution (6.10.3.2, 6.10.3.3). The other possible outcome is deciding that the allowed cases, which should be very few (and indeed they are currently) should use a single deviation pattern to be handled uniformely.

--
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253



 


Rackspace

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