Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: introduce nospec_uses_trampoline()

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>

authored by

Sven Schnelle and committed by
Vasily Gorbik
5d17d4ed 26c21aa4

+10 -5
+5
arch/s390/include/asm/nospec-branch.h
··· 12 12 void nospec_auto_detect(void); 13 13 void nospec_revert(s32 *start, s32 *end); 14 14 15 + static inline bool nospec_uses_trampoline(void) 16 + { 17 + return __is_defined(CC_USING_EXPOLINE) && !nospec_disable; 18 + } 19 + 15 20 #endif /* __ASSEMBLY__ */ 16 21 17 22 #endif /* _ASM_S390_EXPOLINE_H */
+1 -1
arch/s390/kernel/nospec-branch.c
··· 38 38 { 39 39 if (test_facility(156)) 40 40 pr_info("Spectre V2 mitigation: etokens\n"); 41 - if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) 41 + if (nospec_uses_trampoline()) 42 42 pr_info("Spectre V2 mitigation: execute trampolines\n"); 43 43 if (__test_facility(82, alt_stfle_fac_list)) 44 44 pr_info("Spectre V2 mitigation: limited branch prediction\n");
+1 -1
arch/s390/kernel/nospec-sysfs.c
··· 15 15 { 16 16 if (test_facility(156)) 17 17 return sprintf(buf, "Mitigation: etokens\n"); 18 - if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) 18 + if (nospec_uses_trampoline()) 19 19 return sprintf(buf, "Mitigation: execute trampolines\n"); 20 20 if (__test_facility(82, alt_stfle_fac_list)) 21 21 return sprintf(buf, "Mitigation: limited branch prediction\n");
+3 -3
arch/s390/net/bpf_jit_comp.c
··· 567 567 EMIT4(0xb9040000, REG_2, BPF_REG_0); 568 568 /* Restore registers */ 569 569 save_restore_regs(jit, REGS_RESTORE, stack_depth); 570 - if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) { 570 + if (nospec_uses_trampoline()) { 571 571 jit->r14_thunk_ip = jit->prg; 572 572 /* Generate __s390_indirect_jump_r14 thunk */ 573 573 if (test_facility(35)) { ··· 585 585 /* br %r14 */ 586 586 _EMIT2(0x07fe); 587 587 588 - if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable && 588 + if ((nospec_uses_trampoline()) && 589 589 (is_first_pass(jit) || (jit->seen & SEEN_FUNC))) { 590 590 jit->r1_thunk_ip = jit->prg; 591 591 /* Generate __s390_indirect_jump_r1 thunk */ ··· 1332 1332 jit->seen |= SEEN_FUNC; 1333 1333 /* lgrl %w1,func */ 1334 1334 EMIT6_PCREL_RILB(0xc4080000, REG_W1, _EMIT_CONST_U64(func)); 1335 - if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) { 1335 + if (nospec_uses_trampoline()) { 1336 1336 /* brasl %r14,__s390_indirect_jump_r1 */ 1337 1337 EMIT6_PCREL_RILB(0xc0050000, REG_14, jit->r1_thunk_ip); 1338 1338 } else {