Skip to content

Commit 60b04df

Browse files
committed
Merge tag 's390-5.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Vasily Gorbik: - Fix unwinding from irq context of interrupted user process. - Add purgatory build missing symbols check. That helped to uncover and fix missing symbols when built with kasan support enabled. - Couple of ftrace fixes. Avoid broken stack trace and fix recursion loop in function_graph tracer. * tag 's390-5.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/ftrace: save traced function caller s390/unwind: stop gracefully at user mode pt_regs in irq stack s390/purgatory: do not build purgatory with kcov, kasan and friends s390/purgatory: Make sure we fail the build if purgatory has missing symbols s390/ftrace: fix endless recursion in function_graph tracer
2 parents fd7a6d2 + b4adfe5 commit 60b04df

File tree

6 files changed

+32
-11
lines changed

6 files changed

+32
-11
lines changed

arch/s390/include/asm/timex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ static inline unsigned long long get_tod_clock_monotonic(void)
194194
{
195195
unsigned long long tod;
196196

197-
preempt_disable();
197+
preempt_disable_notrace();
198198
tod = get_tod_clock() - *(unsigned long long *) &tod_clock_base[1];
199-
preempt_enable();
199+
preempt_enable_notrace();
200200
return tod;
201201
}
202202

arch/s390/kernel/mcount.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ EXPORT_SYMBOL(_mcount)
3535
ENTRY(ftrace_caller)
3636
.globl ftrace_regs_caller
3737
.set ftrace_regs_caller,ftrace_caller
38+
stg %r14,(__SF_GPRS+8*8)(%r15) # save traced function caller
3839
lgr %r1,%r15
3940
#if !(defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT))
4041
aghi %r0,MCOUNT_RETURN_FIXUP

arch/s390/kernel/unwind_bc.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,17 @@ static bool update_stack_info(struct unwind_state *state, unsigned long sp)
3636
return true;
3737
}
3838

39-
static inline bool is_task_pt_regs(struct unwind_state *state,
40-
struct pt_regs *regs)
39+
static inline bool is_final_pt_regs(struct unwind_state *state,
40+
struct pt_regs *regs)
4141
{
42-
return task_pt_regs(state->task) == regs;
42+
/* user mode or kernel thread pt_regs at the bottom of task stack */
43+
if (task_pt_regs(state->task) == regs)
44+
return true;
45+
46+
/* user mode pt_regs at the bottom of irq stack */
47+
return state->stack_info.type == STACK_TYPE_IRQ &&
48+
state->stack_info.end - sizeof(struct pt_regs) == (unsigned long)regs &&
49+
READ_ONCE_NOCHECK(regs->psw.mask) & PSW_MASK_PSTATE;
4350
}
4451

4552
bool unwind_next_frame(struct unwind_state *state)
@@ -80,7 +87,7 @@ bool unwind_next_frame(struct unwind_state *state)
8087
if (!on_stack(info, sp, sizeof(struct pt_regs)))
8188
goto out_err;
8289
regs = (struct pt_regs *) sp;
83-
if (is_task_pt_regs(state, regs))
90+
if (is_final_pt_regs(state, regs))
8491
goto out_stop;
8592
ip = READ_ONCE_NOCHECK(regs->psw.addr);
8693
sp = READ_ONCE_NOCHECK(regs->gprs[15]);

arch/s390/purgatory/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
purgatory
2+
purgatory.chk
23
purgatory.lds
34
purgatory.ro

arch/s390/purgatory/Makefile

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ OBJECT_FILES_NON_STANDARD := y
44

55
purgatory-y := head.o purgatory.o string.o sha256.o mem.o
66

7-
targets += $(purgatory-y) purgatory.lds purgatory purgatory.ro
7+
targets += $(purgatory-y) purgatory.lds purgatory purgatory.chk purgatory.ro
88
PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y))
99

1010
$(obj)/sha256.o: $(srctree)/lib/crypto/sha256.c FORCE
@@ -15,8 +15,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS
1515
$(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
1616
$(call if_changed_rule,as_o_S)
1717

18-
$(obj)/string.o: $(srctree)/arch/s390/lib/string.c FORCE
19-
$(call if_changed_rule,cc_o_c)
18+
KCOV_INSTRUMENT := n
19+
GCOV_PROFILE := n
20+
UBSAN_SANITIZE := n
21+
KASAN_SANITIZE := n
2022

2123
KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
2224
KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
@@ -26,15 +28,22 @@ KBUILD_CFLAGS += $(CLANG_FLAGS)
2628
KBUILD_CFLAGS += $(call cc-option,-fno-PIE)
2729
KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS))
2830

29-
LDFLAGS_purgatory := -r --no-undefined -nostdlib -z nodefaultlib -T
31+
# Since we link purgatory with -r unresolved symbols are not checked, so we
32+
# also link a purgatory.chk binary without -r to check for unresolved symbols.
33+
PURGATORY_LDFLAGS := -nostdlib -z nodefaultlib
34+
LDFLAGS_purgatory := -r $(PURGATORY_LDFLAGS) -T
35+
LDFLAGS_purgatory.chk := -e purgatory_start $(PURGATORY_LDFLAGS)
3036
$(obj)/purgatory: $(obj)/purgatory.lds $(PURGATORY_OBJS) FORCE
3137
$(call if_changed,ld)
3238

39+
$(obj)/purgatory.chk: $(obj)/purgatory FORCE
40+
$(call if_changed,ld)
41+
3342
OBJCOPYFLAGS_purgatory.ro := -O elf64-s390
3443
OBJCOPYFLAGS_purgatory.ro += --remove-section='*debug*'
3544
OBJCOPYFLAGS_purgatory.ro += --remove-section='.comment'
3645
OBJCOPYFLAGS_purgatory.ro += --remove-section='.note.*'
37-
$(obj)/purgatory.ro: $(obj)/purgatory FORCE
46+
$(obj)/purgatory.ro: $(obj)/purgatory $(obj)/purgatory.chk FORCE
3847
$(call if_changed,objcopy)
3948

4049
$(obj)/kexec-purgatory.o: $(obj)/kexec-purgatory.S $(obj)/purgatory.ro FORCE

arch/s390/purgatory/string.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
#define __HAVE_ARCH_MEMCMP /* arch function */
3+
#include "../lib/string.c"

0 commit comments

Comments
 (0)