s390: introduce nospec_uses_trampoline()
authorSven Schnelle <svens@linux.ibm.com>
Mon, 4 Oct 2021 06:51:06 +0000 (08:51 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Tue, 26 Oct 2021 13:21:29 +0000 (15:21 +0200)
and replace all of the "__is_defined(CC_USING_EXPOLINE) && !nospec_disable"
occurrences.

Signed-off-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/include/asm/nospec-branch.h
arch/s390/kernel/nospec-branch.c
arch/s390/kernel/nospec-sysfs.c
arch/s390/net/bpf_jit_comp.c

index b4bd8c41e9d33d4f01ef8950be79f0fd02cd59c6..82725cf783c70cfcaf511931be6b26dfc4522303 100644 (file)
@@ -12,6 +12,11 @@ void nospec_init_branches(void);
 void nospec_auto_detect(void);
 void nospec_revert(s32 *start, s32 *end);
 
+static inline bool nospec_uses_trampoline(void)
+{
+       return __is_defined(CC_USING_EXPOLINE) && !nospec_disable;
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* _ASM_S390_EXPOLINE_H */
index 250e4dbf653cc03ab7f891c929c3fe48a10e0960..60e6fec27bba085b525887a74bdff7775880629c 100644 (file)
@@ -38,7 +38,7 @@ static int __init nospec_report(void)
 {
        if (test_facility(156))
                pr_info("Spectre V2 mitigation: etokens\n");
-       if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
+       if (nospec_uses_trampoline())
                pr_info("Spectre V2 mitigation: execute trampolines\n");
        if (__test_facility(82, alt_stfle_fac_list))
                pr_info("Spectre V2 mitigation: limited branch prediction\n");
index b4b5c8c211663d7d406309d40f6dec17c98a1e6d..52d4353188ad8cb3328dabe3f437f2e57fa6baaa 100644 (file)
@@ -15,7 +15,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
 {
        if (test_facility(156))
                return sprintf(buf, "Mitigation: etokens\n");
-       if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
+       if (nospec_uses_trampoline())
                return sprintf(buf, "Mitigation: execute trampolines\n");
        if (__test_facility(82, alt_stfle_fac_list))
                return sprintf(buf, "Mitigation: limited branch prediction\n");
index 1a374d021e256d90ad06e77a1d945509ee902c2f..233cc9bcd6527b51b2bfa74494ed5dcae9085a41 100644 (file)
@@ -567,7 +567,7 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
        EMIT4(0xb9040000, REG_2, BPF_REG_0);
        /* Restore registers */
        save_restore_regs(jit, REGS_RESTORE, stack_depth);
-       if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) {
+       if (nospec_uses_trampoline()) {
                jit->r14_thunk_ip = jit->prg;
                /* Generate __s390_indirect_jump_r14 thunk */
                if (test_facility(35)) {
@@ -585,7 +585,7 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
        /* br %r14 */
        _EMIT2(0x07fe);
 
-       if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable &&
+       if ((nospec_uses_trampoline()) &&
            (is_first_pass(jit) || (jit->seen & SEEN_FUNC))) {
                jit->r1_thunk_ip = jit->prg;
                /* Generate __s390_indirect_jump_r1 thunk */
@@ -1332,7 +1332,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
                jit->seen |= SEEN_FUNC;
                /* lgrl %w1,func */
                EMIT6_PCREL_RILB(0xc4080000, REG_W1, _EMIT_CONST_U64(func));
-               if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) {
+               if (nospec_uses_trampoline()) {
                        /* brasl %r14,__s390_indirect_jump_r1 */
                        EMIT6_PCREL_RILB(0xc0050000, REG_14, jit->r1_thunk_ip);
                } else {