Skip to content

Commit d6702d8

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Martin Schwidefsky: "A couple of bug fixes for s390. The ftrace comile fix is quite large for a -rc6 release, but it would be nice to have it in 4.0" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/smp: reenable smt after resume s390/mm: limit STACK_RND_MASK for compat tasks s390/ftrace: fix compile error if CONFIG_KPROBES is disabled s390/cpum_sf: add diagnostic sampling event only if it is authorized
2 parents 4c4fe4c + 1833c9f commit d6702d8

File tree

4 files changed

+62
-19
lines changed

4 files changed

+62
-19
lines changed

arch/s390/include/asm/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ do { \
211211

212212
extern unsigned long mmap_rnd_mask;
213213

214-
#define STACK_RND_MASK (mmap_rnd_mask)
214+
#define STACK_RND_MASK (test_thread_flag(TIF_31BIT) ? 0x7ff : mmap_rnd_mask)
215215

216216
#define ARCH_DLINFO \
217217
do { \

arch/s390/kernel/ftrace.c

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,44 @@
5757

5858
unsigned long ftrace_plt;
5959

60+
static inline void ftrace_generate_orig_insn(struct ftrace_insn *insn)
61+
{
62+
#ifdef CC_USING_HOTPATCH
63+
/* brcl 0,0 */
64+
insn->opc = 0xc004;
65+
insn->disp = 0;
66+
#else
67+
/* stg r14,8(r15) */
68+
insn->opc = 0xe3e0;
69+
insn->disp = 0xf0080024;
70+
#endif
71+
}
72+
73+
static inline int is_kprobe_on_ftrace(struct ftrace_insn *insn)
74+
{
75+
#ifdef CONFIG_KPROBES
76+
if (insn->opc == BREAKPOINT_INSTRUCTION)
77+
return 1;
78+
#endif
79+
return 0;
80+
}
81+
82+
static inline void ftrace_generate_kprobe_nop_insn(struct ftrace_insn *insn)
83+
{
84+
#ifdef CONFIG_KPROBES
85+
insn->opc = BREAKPOINT_INSTRUCTION;
86+
insn->disp = KPROBE_ON_FTRACE_NOP;
87+
#endif
88+
}
89+
90+
static inline void ftrace_generate_kprobe_call_insn(struct ftrace_insn *insn)
91+
{
92+
#ifdef CONFIG_KPROBES
93+
insn->opc = BREAKPOINT_INSTRUCTION;
94+
insn->disp = KPROBE_ON_FTRACE_CALL;
95+
#endif
96+
}
97+
6098
int ftrace_modify_call(struct dyn_ftrace *rec, unsigned long old_addr,
6199
unsigned long addr)
62100
{
@@ -72,26 +110,18 @@ int ftrace_make_nop(struct module *mod, struct dyn_ftrace *rec,
72110
return -EFAULT;
73111
if (addr == MCOUNT_ADDR) {
74112
/* Initial code replacement */
75-
#ifdef CC_USING_HOTPATCH
76-
/* We expect to see brcl 0,0 */
77-
ftrace_generate_nop_insn(&orig);
78-
#else
79-
/* We expect to see stg r14,8(r15) */
80-
orig.opc = 0xe3e0;
81-
orig.disp = 0xf0080024;
82-
#endif
113+
ftrace_generate_orig_insn(&orig);
83114
ftrace_generate_nop_insn(&new);
84-
} else if (old.opc == BREAKPOINT_INSTRUCTION) {
115+
} else if (is_kprobe_on_ftrace(&old)) {
85116
/*
86117
* If we find a breakpoint instruction, a kprobe has been
87118
* placed at the beginning of the function. We write the
88119
* constant KPROBE_ON_FTRACE_NOP into the remaining four
89120
* bytes of the original instruction so that the kprobes
90121
* handler can execute a nop, if it reaches this breakpoint.
91122
*/
92-
new.opc = orig.opc = BREAKPOINT_INSTRUCTION;
93-
orig.disp = KPROBE_ON_FTRACE_CALL;
94-
new.disp = KPROBE_ON_FTRACE_NOP;
123+
ftrace_generate_kprobe_call_insn(&orig);
124+
ftrace_generate_kprobe_nop_insn(&new);
95125
} else {
96126
/* Replace ftrace call with a nop. */
97127
ftrace_generate_call_insn(&orig, rec->ip);
@@ -111,17 +141,16 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
111141

112142
if (probe_kernel_read(&old, (void *) rec->ip, sizeof(old)))
113143
return -EFAULT;
114-
if (old.opc == BREAKPOINT_INSTRUCTION) {
144+
if (is_kprobe_on_ftrace(&old)) {
115145
/*
116146
* If we find a breakpoint instruction, a kprobe has been
117147
* placed at the beginning of the function. We write the
118148
* constant KPROBE_ON_FTRACE_CALL into the remaining four
119149
* bytes of the original instruction so that the kprobes
120150
* handler can execute a brasl if it reaches this breakpoint.
121151
*/
122-
new.opc = orig.opc = BREAKPOINT_INSTRUCTION;
123-
orig.disp = KPROBE_ON_FTRACE_NOP;
124-
new.disp = KPROBE_ON_FTRACE_CALL;
152+
ftrace_generate_kprobe_nop_insn(&orig);
153+
ftrace_generate_kprobe_call_insn(&new);
125154
} else {
126155
/* Replace nop with an ftrace call. */
127156
ftrace_generate_nop_insn(&orig);

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ CPUMF_EVENT_ATTR(SF, SF_CYCLES_BASIC_DIAG, PERF_EVENT_CPUM_SF_DIAG);
14151415

14161416
static struct attribute *cpumsf_pmu_events_attr[] = {
14171417
CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC),
1418-
CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC_DIAG),
1418+
NULL,
14191419
NULL,
14201420
};
14211421

@@ -1606,8 +1606,11 @@ static int __init init_cpum_sampling_pmu(void)
16061606
return -EINVAL;
16071607
}
16081608

1609-
if (si.ad)
1609+
if (si.ad) {
16101610
sfb_set_limits(CPUM_SF_MIN_SDB, CPUM_SF_MAX_SDB);
1611+
cpumsf_pmu_events_attr[1] =
1612+
CPUMF_EVENT_PTR(SF, SF_CYCLES_BASIC_DIAG);
1613+
}
16111614

16121615
sfdbg = debug_register(KMSG_COMPONENT, 2, 1, 80);
16131616
if (!sfdbg)

arch/s390/kernel/swsusp_asm64.S

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ restart_entry:
177177
lhi %r1,1
178178
sigp %r1,%r0,SIGP_SET_ARCHITECTURE
179179
sam64
180+
#ifdef CONFIG_SMP
181+
larl %r1,smp_cpu_mt_shift
182+
icm %r1,15,0(%r1)
183+
jz smt_done
184+
llgfr %r1,%r1
185+
smt_loop:
186+
sigp %r1,%r0,SIGP_SET_MULTI_THREADING
187+
brc 8,smt_done /* accepted */
188+
brc 2,smt_loop /* busy, try again */
189+
smt_done:
190+
#endif
180191
larl %r1,.Lnew_pgm_check_psw
181192
lpswe 0(%r1)
182193
pgm_check_entry:

0 commit comments

Comments
 (0)