Skip to content

Commit 5d17d4e

Browse files
svens-s390Vasily Gorbik
authored andcommitted
s390: introduce nospec_uses_trampoline()
and replace all of the "__is_defined(CC_USING_EXPOLINE) && !nospec_disable" occurrences. Signed-off-by: Sven Schnelle <[email protected]> Reviewed-by: Heiko Carstens <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent 26c21aa commit 5d17d4e

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

arch/s390/include/asm/nospec-branch.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ void nospec_init_branches(void);
1212
void nospec_auto_detect(void);
1313
void nospec_revert(s32 *start, s32 *end);
1414

15+
static inline bool nospec_uses_trampoline(void)
16+
{
17+
return __is_defined(CC_USING_EXPOLINE) && !nospec_disable;
18+
}
19+
1520
#endif /* __ASSEMBLY__ */
1621

1722
#endif /* _ASM_S390_EXPOLINE_H */

arch/s390/kernel/nospec-branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static int __init nospec_report(void)
3838
{
3939
if (test_facility(156))
4040
pr_info("Spectre V2 mitigation: etokens\n");
41-
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
41+
if (nospec_uses_trampoline())
4242
pr_info("Spectre V2 mitigation: execute trampolines\n");
4343
if (__test_facility(82, alt_stfle_fac_list))
4444
pr_info("Spectre V2 mitigation: limited branch prediction\n");

arch/s390/kernel/nospec-sysfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
1515
{
1616
if (test_facility(156))
1717
return sprintf(buf, "Mitigation: etokens\n");
18-
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable)
18+
if (nospec_uses_trampoline())
1919
return sprintf(buf, "Mitigation: execute trampolines\n");
2020
if (__test_facility(82, alt_stfle_fac_list))
2121
return sprintf(buf, "Mitigation: limited branch prediction\n");

arch/s390/net/bpf_jit_comp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
567567
EMIT4(0xb9040000, REG_2, BPF_REG_0);
568568
/* Restore registers */
569569
save_restore_regs(jit, REGS_RESTORE, stack_depth);
570-
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) {
570+
if (nospec_uses_trampoline()) {
571571
jit->r14_thunk_ip = jit->prg;
572572
/* Generate __s390_indirect_jump_r14 thunk */
573573
if (test_facility(35)) {
@@ -585,7 +585,7 @@ static void bpf_jit_epilogue(struct bpf_jit *jit, u32 stack_depth)
585585
/* br %r14 */
586586
_EMIT2(0x07fe);
587587

588-
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable &&
588+
if ((nospec_uses_trampoline()) &&
589589
(is_first_pass(jit) || (jit->seen & SEEN_FUNC))) {
590590
jit->r1_thunk_ip = jit->prg;
591591
/* Generate __s390_indirect_jump_r1 thunk */
@@ -1332,7 +1332,7 @@ static noinline int bpf_jit_insn(struct bpf_jit *jit, struct bpf_prog *fp,
13321332
jit->seen |= SEEN_FUNC;
13331333
/* lgrl %w1,func */
13341334
EMIT6_PCREL_RILB(0xc4080000, REG_W1, _EMIT_CONST_U64(func));
1335-
if (__is_defined(CC_USING_EXPOLINE) && !nospec_disable) {
1335+
if (nospec_uses_trampoline()) {
13361336
/* brasl %r14,__s390_indirect_jump_r1 */
13371337
EMIT6_PCREL_RILB(0xc0050000, REG_14, jit->r1_thunk_ip);
13381338
} else {

0 commit comments

Comments
 (0)