1 From 3fd3b266d4198c06e8e421ca515d9ba09ccd5155 Mon Sep 17 00:00:00 2001
2 From: Jan Beulich <jbeulich@suse.com>
3 Date: Mon, 13 May 2019 09:51:23 +0200
4 Subject: [PATCH] trace: fix build with gcc9
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 While I've not observed this myself, gcc 9 (imo validly) reportedly may
12 trace.c: In function '__trace_hypercall':
13 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]
14 826 | uint32_t *a = d.args;
16 and the fix is rather simple - remove the __packed attribute. Introduce
17 a BUILD_BUG_ON() as replacement, for the unlikely case that Xen might
18 get ported to an architecture where array alignment higher that that of
21 Reported-by: Martin Liška <martin.liska@suse.com>
22 Signed-off-by: Jan Beulich <jbeulich@suse.com>
23 Acked-by: George Dunlap <george.dunlap@citrix.com>
25 xen/common/trace.c | 8 +++++++-
26 1 file changed, 7 insertions(+), 1 deletion(-)
28 diff --git a/xen/common/trace.c b/xen/common/trace.c
29 index cc294fc38473..d1ef81407b71 100644
30 --- a/xen/common/trace.c
31 +++ b/xen/common/trace.c
32 @@ -819,12 +819,18 @@ void __trace_var(u32 event, bool_t cycles, unsigned int extra,
33 void __trace_hypercall(uint32_t event, unsigned long op,
34 const xen_ulong_t *args)
44 + * In lieu of using __packed above, which gcc9 legitimately doesn't
45 + * like in combination with the address of d.args[] taken.
47 + BUILD_BUG_ON(offsetof(typeof(d), args) != sizeof(d.op));
49 #define APPEND_ARG32(i) \
52 --- xen-4.11.1/xen/drivers/passthrough/vtd/vtd.h.orig 2018-11-29 14:04:11.000000000 +0000
53 +++ xen-4.11.1/xen/drivers/passthrough/vtd/vtd.h 2019-02-05 21:32:50.056774501 +0000
55 /* Allow for both IOAPIC and IOSAPIC. */
56 #define IO_xAPIC_route_entry IO_APIC_route_entry
58 -struct IO_APIC_route_remap_entry {
59 +struct __packed IO_APIC_route_remap_entry {
63 --- xen-4.11.1/xen/arch/x86/cpu/mtrr/generic.c.orig 2018-11-29 14:04:11.000000000 +0000
64 +++ xen-4.11.1/xen/arch/x86/cpu/mtrr/generic.c 2019-02-10 19:24:09.378805103 +0000
66 printk("%sMTRR variable ranges %sabled:\n", level,
67 mtrr_state.enabled ? "en" : "dis");
68 width = (paddr_bits - PAGE_SHIFT + 3) / 4;
73 for (i = 0; i < num_var_ranges; ++i) {
74 if (mtrr_state.var_ranges[i].mask & MTRR_PHYSMASK_VALID)