s390: simplify early program check handler
authorHeiko Carstens <hca@linux.ibm.com>
Fri, 20 May 2022 17:23:48 +0000 (19:23 +0200)
committerHeiko Carstens <hca@linux.ibm.com>
Wed, 25 May 2022 09:46:02 +0000 (11:46 +0200)
Due to historic reasons the base program check handler calls a
configurable function. Given that there is only the early program
check handler left, simplify the code by directly calling that
function.

The only other user was removed with commit d485235b0054 ("s390:
assume diag308 set always works").

Also rename all functions and the asm file to reflect this.

Reviewed-by: Sven Schnelle <svens@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/include/asm/processor.h
arch/s390/kernel/Makefile
arch/s390/kernel/early.c
arch/s390/kernel/earlypgm.S [moved from arch/s390/kernel/base.S with 55% similarity]
arch/s390/kernel/entry.h

index add764a..bd66f8e 100644 (file)
@@ -304,12 +304,6 @@ static __always_inline void __noreturn disabled_wait(void)
        while (1);
 }
 
-/*
- * Basic Program Check Handler.
- */
-extern void s390_base_pgm_handler(void);
-extern void (*s390_base_pgm_handler_fn)(struct pt_regs *regs);
-
 #define ARCH_LOW_ADDRESS_LIMIT 0x7fffffffUL
 
 extern int memcpy_real(void *, unsigned long, size_t);
index 5851041..27d6b3c 100644 (file)
@@ -33,7 +33,7 @@ CFLAGS_stacktrace.o   += -fno-optimize-sibling-calls
 CFLAGS_dumpstack.o     += -fno-optimize-sibling-calls
 CFLAGS_unwind_bc.o     += -fno-optimize-sibling-calls
 
-obj-y  := traps.o time.o process.o base.o early.o setup.o idle.o vtime.o
+obj-y  := traps.o time.o process.o earlypgm.o early.o setup.o idle.o vtime.o
 obj-y  += processor.o syscall.o ptrace.o signal.o cpcmd.o ebcdic.o nmi.o
 obj-y  += debug.o irq.o ipl.o dis.o diag.o vdso.o
 obj-y  += sysinfo.o lgr.o os_info.o machine_kexec.o
index 08cc86a..432c8c9 100644 (file)
@@ -149,7 +149,7 @@ static __init void setup_topology(void)
        topology_max_mnest = max_mnest;
 }
 
-static void early_pgm_check_handler(struct pt_regs *regs)
+void __do_early_pgm_check(struct pt_regs *regs)
 {
        if (!fixup_exception(regs))
                disabled_wait();
@@ -159,12 +159,11 @@ static noinline __init void setup_lowcore_early(void)
 {
        psw_t psw;
 
-       psw.addr = (unsigned long)s390_base_pgm_handler;
+       psw.addr = (unsigned long)early_pgm_check_handler;
        psw.mask = PSW_MASK_BASE | PSW_DEFAULT_KEY | PSW_MASK_EA | PSW_MASK_BA;
        if (IS_ENABLED(CONFIG_KASAN))
                psw.mask |= PSW_MASK_DAT;
        S390_lowcore.program_new_psw = psw;
-       s390_base_pgm_handler_fn = early_pgm_check_handler;
        S390_lowcore.preempt_count = INIT_PREEMPT_COUNT;
 }
 
similarity index 55%
rename from arch/s390/kernel/base.S
rename to arch/s390/kernel/earlypgm.S
index 172c23c..fbc7d2d 100644 (file)
@@ -1,23 +1,16 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- *  arch/s390/kernel/base.S
- *
  *    Copyright IBM Corp. 2006, 2007
  *    Author(s): Michael Holzheu <holzheu@de.ibm.com>
  */
 
 #include <linux/linkage.h>
 #include <asm/asm-offsets.h>
-#include <asm/nospec-insn.h>
-#include <asm/ptrace.h>
-
-       GEN_BR_THUNK %r9
-       GEN_BR_THUNK %r14
 
 __PT_R0 = __PT_GPRS
 __PT_R8 = __PT_GPRS + 64
 
-ENTRY(s390_base_pgm_handler)
+ENTRY(early_pgm_check_handler)
        stmg    %r8,%r15,__LC_SAVE_AREA_SYNC
        aghi    %r15,-(STACK_FRAME_OVERHEAD+__PT_SIZE)
        la      %r11,STACK_FRAME_OVERHEAD(%r15)
@@ -26,25 +19,8 @@ ENTRY(s390_base_pgm_handler)
        mvc     __PT_PSW(16,%r11),__LC_PGM_OLD_PSW
        mvc     __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC
        lgr     %r2,%r11
-       larl    %r1,s390_base_pgm_handler_fn
-       lg      %r9,0(%r1)
-       ltgr    %r9,%r9
-       jz      1f
-       BASR_EX %r14,%r9
+       brasl   %r14,__do_early_pgm_check
        mvc     __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15)
        lmg     %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15)
        lpswe   __LC_RETURN_PSW
-1:     larl    %r13,disabled_wait_psw
-       lpswe   0(%r13)
-ENDPROC(s390_base_pgm_handler)
-
-       .align  8
-disabled_wait_psw:
-       .quad   0x0002000180000000,0x0000000000000000 + s390_base_pgm_handler
-
-       .section .bss
-       .align 8
-       .globl s390_base_pgm_handler_fn
-s390_base_pgm_handler_fn:
-       .quad   0
-       .previous
+ENDPROC(early_pgm_check_handler)
index 56e5e37..995ec74 100644 (file)
@@ -17,10 +17,12 @@ void ext_int_handler(void);
 void io_int_handler(void);
 void mcck_int_handler(void);
 void restart_int_handler(void);
+void early_pgm_check_handler(void);
 
 void __ret_from_fork(struct task_struct *prev, struct pt_regs *regs);
 void __do_pgm_check(struct pt_regs *regs);
 void __do_syscall(struct pt_regs *regs, int per_trap);
+void __do_early_pgm_check(struct pt_regs *regs);
 
 void do_protection_exception(struct pt_regs *regs);
 void do_dat_exception(struct pt_regs *regs);