File xen.3fd3b266d4198c06e8e421ca515d9ba09ccd5155.patch of Package xen
From: Jan Beulich <jbeulich@suse.com>
Date: Mon, 13 May 2019 09:51:23 +0200
Subject: 3fd3b266d4198c06e8e421ca515d9ba09ccd5155
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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@suse.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@citrix.com>
---
xen/common/trace.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
--- a/xen/common/trace.c
+++ b/xen/common/trace.c
@@ -814,30 +814,36 @@ unlock:
spin_unlock_irqrestore(&this_cpu(t_lock), flags);
/* Notify trace buffer consumer that we've crossed the high water mark. */
if ( likely(buf!=NULL)
&& started_below_highwater
&& (calc_unconsumed_bytes(buf) >= t_buf_highwater) )
tasklet_schedule(&trace_notify_dom0_tasklet);
}
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); \
*a++ = args[(i_)]; \
d.op |= TRC_PV_HYPERCALL_V2_ARG_32(i_); \
} while( 0 )
/*
* This shouldn't happen as @op should be small enough but just in
* case, warn if the argument bits in the trace record would
* clobber the hypercall op.
*/