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

[Xen-changelog] [xen staging-4.12] trace: fix build with gcc9



commit 0dcd945a675cd12d283121e9b7f1626104b60bcc
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Jun 4 15:32:55 2019 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jun 4 15:32:55 2019 +0200

    trace: fix build with gcc9
    
    While I've not observed this myself, gcc 9 (imo validly) reportedly may
    complain
    
    trace.c: In function '__trace_hypercall':
    trace.c:826:19: error: taking address of packed member of 'struct 
<anonymous>' may result in an unaligned pointer value 
[-Werror=address-of-packed-member]
      826 |     uint32_t *a = d.args;
    
    and the fix is rather simple - remove the __packed attribute. Introduce
    a BUILD_BUG_ON() as replacement, for the unlikely case that Xen might
    get ported to an architecture where array alignment higher that that of
    its elements.
    
    Reported-by: Martin Liška <martin.liska@xxxxxxxx>
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: George Dunlap <george.dunlap@xxxxxxxxxx>
    master commit: 3fd3b266d4198c06e8e421ca515d9ba09ccd5155
    master date: 2019-05-13 09:51:23 +0200
---
 xen/common/trace.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/common/trace.c b/xen/common/trace.c
index cc294fc384..d1ef81407b 100644
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -819,12 +819,18 @@ unlock:
 void __trace_hypercall(uint32_t event, unsigned long op,
                        const xen_ulong_t *args)
 {
-    struct __packed {
+    struct {
         uint32_t op;
         uint32_t args[6];
     } d;
     uint32_t *a = d.args;
 
+    /*
+     * In lieu of using __packed above, which gcc9 legitimately doesn't
+     * like in combination with the address of d.args[] taken.
+     */
+    BUILD_BUG_ON(offsetof(typeof(d), args) != sizeof(d.op));
+
 #define APPEND_ARG32(i)                         \
     do {                                        \
         unsigned i_ = (i);                      \
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.12

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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