From: Nicola Vetrini <nicola.vetr...@bugseng.com>

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.vetr...@bugseng.com>
Signed-off-by: Victor Lira <victorm.l...@amd.com>
---
Cc: Andrew Cooper <andrew.coop...@citrix.com>
Cc: Anthony PERARD <anthony.per...@vates.tech>
Cc: Michal Orzel <michal.or...@amd.com>
Cc: Jan Beulich <jbeul...@suse.com>
Cc: Julien Grall <jul...@xen.org>
Cc: Roger Pau Monné <roger....@citrix.com>
Cc: Stefano Stabellini <sstabell...@kernel.org>
Cc: Nicola Vetrini <nicola.vetr...@bugseng.com>
Cc: Federico Serafini <federico.seraf...@bugseng.com>
Cc: Bertrand Marquis <bertrand.marq...@arm.com>
---
 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

Reply via email to