From bbe6fa04b52644191da96aa5a289ae00b026641d Mon Sep 17 00:00:00 2001 From: Andy Ross Date: Fri, 22 Feb 2019 15:34:29 -0800 Subject: [PATCH] arch/x86_64: Flag xuk shared page volatile The shared page is inherently used in multiprocessor contexts where the compiler optimizer can trip us up (specifically, a spin on num_active_pus was being hoisted out of the loop on some gcc's). Put the volatile declartion into the struct pointer itself instead of relying on the code to get it right. Signed-off-by: Andy Ross --- arch/x86_64/core/shared-page.h | 2 +- arch/x86_64/core/xuk.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86_64/core/shared-page.h b/arch/x86_64/core/shared-page.h index 253ab442b7b..fad0e1346df 100644 --- a/arch/x86_64/core/shared-page.h +++ b/arch/x86_64/core/shared-page.h @@ -57,7 +57,7 @@ struct xuk_shared_mem { int vgacol; }; -#define _shared (*((struct xuk_shared_mem *)(long)SHARED_ADDR)) +#define _shared (*((volatile struct xuk_shared_mem *)(long)SHARED_ADDR)) static inline void shared_init(void) { diff --git a/arch/x86_64/core/xuk.c b/arch/x86_64/core/xuk.c index 800227e4243..406e9b38f65 100644 --- a/arch/x86_64/core/xuk.c +++ b/arch/x86_64/core/xuk.c @@ -314,8 +314,8 @@ void xuk_set_isr_mask(int interrupt, int masked) static void setup_fg_segs(int cpu) { int fi = 3 + 2 * cpu, gi = 3 + 2 * cpu + 1; - struct gdt64 *fs = &_shared.gdt[fi]; - struct gdt64 *gs = &_shared.gdt[gi]; + struct gdt64 *fs = (struct gdt64 *) &_shared.gdt[fi]; + struct gdt64 *gs = (struct gdt64 *) &_shared.gdt[gi]; gdt64_set_base(fs, (long)&_shared.fs_ptrs[cpu]); gdt64_set_base(gs, (long)&_shared.gs_ptrs[cpu]);