[PATCH v2] ARM: Spectre-BHB: provide empty stub for non-config

From: Randy Dunlap
Date: Fri Mar 11 2022 - 14:49:19 EST


When CONFIG_GENERIC_CPU_VULNERABILITIES is not set, references
to spectre_v2_update_state() cause a build error, so provide an
empty stub for that function when the Kconfig option is not set.

Fixes this build error:

arm-linux-gnueabi-ld: arch/arm/mm/proc-v7-bugs.o: in function `cpu_v7_bugs_init':
proc-v7-bugs.c:(.text+0x52): undefined reference to `spectre_v2_update_state'
arm-linux-gnueabi-ld: proc-v7-bugs.c:(.text+0x82): undefined reference to `spectre_v2_update_state'

Fixes: b9baf5c8c5c3 ("ARM: Spectre-BHB workaround")
Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Cc: Russell King <rmk+kernel@xxxxxxxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: patches@xxxxxxxxxxxxxxx
Acked-by: Russell King (Oracle) <rmk+kernel@xxxxxxxxxxxxxxx>
---
v2: add Russell's Ack and suggestion to send directly to Linus.

Linus- Russel King says:

I'd suggest sending this direct to Linus as I've been doing with the
other fixes for Spectre BHB. Trying to fit it now into a pull request
is just going to be very messy.

KernelVersion: v5.17-rc7-205-g79b00034e9dc

arch/arm/include/asm/spectre.h | 6 ++++++
1 file changed, 6 insertions(+)

--- linux-next-20220310.orig/arch/arm/include/asm/spectre.h
+++ linux-next-20220310/arch/arm/include/asm/spectre.h
@@ -25,7 +25,13 @@ enum {
SPECTRE_V2_METHOD_LOOP8 = BIT(__SPECTRE_V2_METHOD_LOOP8),
};

+#ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
void spectre_v2_update_state(unsigned int state, unsigned int methods);
+#else
+static inline void spectre_v2_update_state(unsigned int state,
+ unsigned int methods)
+{}
+#endif

int spectre_bhb_update_vectors(unsigned int method);