s390: always clear kernel stack backchain before calling functions
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 4 Dec 2020 16:56:57 +0000 (17:56 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 16 Dec 2020 13:55:48 +0000 (14:55 +0100)
Clear the kernel stack backchain before potentially calling the
lockdep trace_hardirqs_off/on functions. Without this walking the
kernel backchain, e.g. during a panic, might stop too early.

Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/kernel/entry.S

index 8bb9ebb..aa44520 100644 (file)
@@ -413,6 +413,7 @@ ENTRY(system_call)
        mvc     __PT_PSW(16,%r11),__LC_SVC_OLD_PSW
        mvc     __PT_INT_CODE(4,%r11),__LC_SVC_ILC
        stg     %r14,__PT_FLAGS(%r11)
+       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        ENABLE_INTS
 .Lsysc_do_svc:
        # clear user controlled register to prevent speculative use
@@ -429,7 +430,6 @@ ENTRY(system_call)
        jnl     .Lsysc_nr_ok
        slag    %r8,%r1,3
 .Lsysc_nr_ok:
-       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        stg     %r2,__PT_ORIG_GPR2(%r11)
        stg     %r7,STACK_FRAME_OVERHEAD(%r15)
        lg      %r9,0(%r8,%r10)                 # get system call add.
@@ -698,8 +698,8 @@ ENTRY(pgm_check_handler)
        mvc     __THREAD_per_address(8,%r14),__LC_PER_ADDRESS
        mvc     __THREAD_per_cause(2,%r14),__LC_PER_CODE
        mvc     __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID
-6:     RESTORE_SM_CLEAR_PER
-       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
+6:     xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
+       RESTORE_SM_CLEAR_PER
        larl    %r1,pgm_check_table
        llgh    %r10,__PT_INT_CODE+2(%r11)
        nill    %r10,0x007f
@@ -730,8 +730,8 @@ ENTRY(pgm_check_handler)
 # PER event in supervisor state, must be kprobes
 #
 .Lpgm_kprobe:
-       RESTORE_SM_CLEAR_PER
        xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
+       RESTORE_SM_CLEAR_PER
        lgr     %r2,%r11                # pass pointer to pt_regs
        brasl   %r14,do_per_trap
        j       .Lpgm_return
@@ -777,10 +777,10 @@ ENTRY(io_int_handler)
 .Lio_skip_asce:
        mvc     __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID
        xc      __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
+       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        TSTMSK  __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
        jo      .Lio_restore
        TRACE_IRQS_OFF
-       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
 .Lio_loop:
        lgr     %r2,%r11                # pass pointer to pt_regs
        lghi    %r3,IO_INTERRUPT
@@ -965,10 +965,10 @@ ENTRY(ext_int_handler)
        mvc     __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS
        mvc     __PT_INT_PARM_LONG(8,%r11),0(%r1)
        xc      __PT_FLAGS(8,%r11),__PT_FLAGS(%r11)
+       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        TSTMSK  __LC_CPU_FLAGS,_CIF_IGNORE_IRQ
        jo      .Lio_restore
        TRACE_IRQS_OFF
-       xc      __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15)
        lgr     %r2,%r11                # pass pointer to pt_regs
        lghi    %r3,EXT_INTERRUPT
        brasl   %r14,do_IRQ