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

[PATCH v1 2/3] compat: address violations of MISRA C Rule 19.1


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: <victorm.lira@xxxxxxx>
  • Date: Fri, 25 Apr 2025 16:42:37 -0700
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=D8E/bPc0PJUR1517qnR2GX1GX93U2VDwCoULoW2ZQwk=; b=qjeq1utWZAbYlRljYxJ6D3oUOM/641N50WhOMX71xA5zc+woRz+Z6lmEga7WcEpU/APRWBTh4WJvSOBDtuuaGcUeJsEF2oj8DZ6PLmMl4ECuB41sfqTUBzP9/DzaBN9s1EDefFizoSsPMl+e000S5kB2uDI8D80uEWI1K2mUMYhffGiay4uihdJIV5cTpZcZROdlXVIG7dw3XvhtNwBJ4f+zhwCDEJSwyg6RuXxYc2ckZhny8vQzXIeXaX+6BVJasXG2l4ZSRKj+mgWqzKnBZxvYelnScE9Q9cmyS6rj7ic31LnLgVbOAkaRsPsEwiVnPfpmtDqX0+KdaB6+XPUBSA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=r6GRTe27VOvnE0t+MjpxBXTq/znf3G/QC/xw9bwMAkObbk4dFSeAJEhSB3u7/zX121LW2yr+vXY1E+790RYPww0rulnun/Zq2tMRJxRn8TxkmLA7Pff+D8jYGhZVQUR2UgKIlMNz1CDaTl8kshqGMM6yi+QA0upWtID4AyVdsuz+AVGjyfHfkJ2zC6jX3epTmRi+/R9QMw5+hRnjC6/XsUfqFUnyxaQSeZAh6I+zYsjsrCtlCa/GtuFZGBh7YygtOjV16tEMn5sIEqphO7QkMVtJynzMUJIw4h0In/40j3WzBh5w3EDogF3LEbanSmcNcjiE/95sn+0YC7E5juEc6Q==
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Victor Lira <victorm.lira@xxxxxxx>, 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>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Federico Serafini <federico.serafini@xxxxxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Fri, 25 Apr 2025 23:43:40 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>

Rule 19.1 states: "An object shall not be assigned or copied
to an overlapping object". Since the "call" and "compat_call" are
fields of the same union, reading from one member and writing to
the other violates the rule, while not causing Undefined Behavior
due to their relative sizes. However, a dummy variable is used to
address the violation and prevent the future possibility of
incurring in UB.

No functional change.

Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Signed-off-by: Victor Lira <victorm.lira@xxxxxxx>
---
Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Cc: Michal Orzel <michal.orzel@xxxxxxx>
Cc: Jan Beulich <jbeulich@xxxxxxxx>
Cc: Julien Grall <julien@xxxxxxx>
Cc: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>
Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Cc: Federico Serafini <federico.serafini@xxxxxxxxxxx>
Cc: Bertrand Marquis <bertrand.marquis@xxxxxxx>
---
 xen/common/compat/multicall.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/common/compat/multicall.c b/xen/common/compat/multicall.c
index b17739d218..1740fb2172 100644
--- a/xen/common/compat/multicall.c
+++ b/xen/common/compat/multicall.c
@@ -15,8 +15,13 @@ typedef int ret_t;
 static inline void xlat_multicall_entry(struct mc_state *mcs)
 {
     int i;
+    xen_ulong_t arg;
+
     for (i=0; i<6; i++)
-        mcs->compat_call.args[i] = mcs->call.args[i];
+    {
+        arg = mcs->call.args[i];
+        mcs->compat_call.args[i] = arg;
+    }
 }

 #define multicall_entry      compat_multicall_entry
--
2.47.0



 


Rackspace

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