Skip to content

Commit 67870eb

Browse files
arndbchazy
authored andcommitted
ARM: kvm: fix building with gcc-8
In banked-sr.c, we use a top-level '__asm__(".arch_extension virt")' statement to allow compilation of a multi-CPU kernel for ARMv6 and older ARMv7-A that don't normally support access to the banked registers. This is considered to be a programming error by the gcc developers and will no longer work in gcc-8, where we now get a build error: /tmp/cc4Qy7GR.s:34: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_usr' /tmp/cc4Qy7GR.s:41: Error: Banked registers are not available with this architecture. -- `mrs r3,ELR_hyp' /tmp/cc4Qy7GR.s:55: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_svc' /tmp/cc4Qy7GR.s:62: Error: Banked registers are not available with this architecture. -- `mrs r3,LR_svc' /tmp/cc4Qy7GR.s:69: Error: Banked registers are not available with this architecture. -- `mrs r3,SPSR_svc' /tmp/cc4Qy7GR.s:76: Error: Banked registers are not available with this architecture. -- `mrs r3,SP_abt' Passign the '-march-armv7ve' flag to gcc works, and is ok here, because we know the functions won't ever be called on pre-ARMv7VE machines. Unfortunately, older compiler versions (4.8 and earlier) do not understand that flag, so we still need to keep the asm around. Backporting to stable kernels (4.6+) is needed to allow those to be built with future compilers as well. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84129 Fixes: 33280b4 ("ARM: KVM: Add banked registers save/restore") Cc: [email protected] Signed-off-by: Arnd Bergmann <[email protected]> Signed-off-by: Christoffer Dall <[email protected]>
1 parent d60d8b6 commit 67870eb

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

arch/arm/kvm/hyp/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ccflags-y += -fno-stack-protector -DDISABLE_BRANCH_PROFILING
77

88
KVM=../../../../virt/kvm
99

10+
CFLAGS_ARMV7VE :=$(call cc-option, -march=armv7ve)
11+
1012
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v2-sr.o
1113
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/vgic-v3-sr.o
1214
obj-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/hyp/timer-sr.o
@@ -15,7 +17,10 @@ obj-$(CONFIG_KVM_ARM_HOST) += tlb.o
1517
obj-$(CONFIG_KVM_ARM_HOST) += cp15-sr.o
1618
obj-$(CONFIG_KVM_ARM_HOST) += vfp.o
1719
obj-$(CONFIG_KVM_ARM_HOST) += banked-sr.o
20+
CFLAGS_banked-sr.o += $(CFLAGS_ARMV7VE)
21+
1822
obj-$(CONFIG_KVM_ARM_HOST) += entry.o
1923
obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
2024
obj-$(CONFIG_KVM_ARM_HOST) += switch.o
25+
CFLAGS_switch.o += $(CFLAGS_ARMV7VE)
2126
obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o

arch/arm/kvm/hyp/banked-sr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020

2121
#include <asm/kvm_hyp.h>
2222

23+
/*
24+
* gcc before 4.9 doesn't understand -march=armv7ve, so we have to
25+
* trick the assembler.
26+
*/
2327
__asm__(".arch_extension virt");
2428

2529
void __hyp_text __banked_save_state(struct kvm_cpu_context *ctxt)

0 commit comments

Comments
 (0)