1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */ 24bfc86ceSHeiko Carstens/* 34bfc86ceSHeiko Carstens * S390 low-level entry points. 44bfc86ceSHeiko Carstens * 54bfc86ceSHeiko Carstens * Copyright IBM Corp. 1999, 2012 64bfc86ceSHeiko Carstens * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 74bfc86ceSHeiko Carstens * Hartmut Penner (hp@de.ibm.com), 84bfc86ceSHeiko Carstens * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 94bfc86ceSHeiko Carstens * Heiko Carstens <heiko.carstens@de.ibm.com> 104bfc86ceSHeiko Carstens */ 114bfc86ceSHeiko Carstens 124bfc86ceSHeiko Carstens#include <linux/init.h> 134bfc86ceSHeiko Carstens#include <linux/linkage.h> 14b058661aSMartin Schwidefsky#include <asm/alternative-asm.h> 154bfc86ceSHeiko Carstens#include <asm/processor.h> 164bfc86ceSHeiko Carstens#include <asm/cache.h> 173037a52fSMartin Schwidefsky#include <asm/ctl_reg.h> 18dc24b7b4SHendrik Brueckner#include <asm/dwarf.h> 194bfc86ceSHeiko Carstens#include <asm/errno.h> 204bfc86ceSHeiko Carstens#include <asm/ptrace.h> 214bfc86ceSHeiko Carstens#include <asm/thread_info.h> 224bfc86ceSHeiko Carstens#include <asm/asm-offsets.h> 234bfc86ceSHeiko Carstens#include <asm/unistd.h> 244bfc86ceSHeiko Carstens#include <asm/page.h> 254bfc86ceSHeiko Carstens#include <asm/sigp.h> 264bfc86ceSHeiko Carstens#include <asm/irq.h> 279977e886SHendrik Brueckner#include <asm/vx-insn.h> 2883abeffbSHendrik Brueckner#include <asm/setup.h> 2983abeffbSHendrik Brueckner#include <asm/nmi.h> 30711f5df7SAl Viro#include <asm/export.h> 316dd85fbbSMartin Schwidefsky#include <asm/nospec-insn.h> 324bfc86ceSHeiko Carstens 334bfc86ceSHeiko Carstens__PT_R0 = __PT_GPRS 344bfc86ceSHeiko Carstens__PT_R1 = __PT_GPRS + 8 354bfc86ceSHeiko Carstens__PT_R2 = __PT_GPRS + 16 364bfc86ceSHeiko Carstens__PT_R3 = __PT_GPRS + 24 374bfc86ceSHeiko Carstens__PT_R4 = __PT_GPRS + 32 384bfc86ceSHeiko Carstens__PT_R5 = __PT_GPRS + 40 394bfc86ceSHeiko Carstens__PT_R6 = __PT_GPRS + 48 404bfc86ceSHeiko Carstens__PT_R7 = __PT_GPRS + 56 414bfc86ceSHeiko Carstens__PT_R8 = __PT_GPRS + 64 424bfc86ceSHeiko Carstens__PT_R9 = __PT_GPRS + 72 434bfc86ceSHeiko Carstens__PT_R10 = __PT_GPRS + 80 444bfc86ceSHeiko Carstens__PT_R11 = __PT_GPRS + 88 454bfc86ceSHeiko Carstens__PT_R12 = __PT_GPRS + 96 464bfc86ceSHeiko Carstens__PT_R13 = __PT_GPRS + 104 474bfc86ceSHeiko Carstens__PT_R14 = __PT_GPRS + 112 484bfc86ceSHeiko Carstens__PT_R15 = __PT_GPRS + 120 494bfc86ceSHeiko Carstens 503a890380SHeiko CarstensSTACK_SHIFT = PAGE_SHIFT + THREAD_SIZE_ORDER 514bfc86ceSHeiko CarstensSTACK_SIZE = 1 << STACK_SHIFT 524bfc86ceSHeiko CarstensSTACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE 534bfc86ceSHeiko Carstens 54e5b98199SMartin Schwidefsky_LPP_OFFSET = __LC_LPP 55e5b98199SMartin Schwidefsky 56ce3dc447SMartin Schwidefsky .macro CHECK_STACK savearea 574bfc86ceSHeiko Carstens#ifdef CONFIG_CHECK_STACK 58ce3dc447SMartin Schwidefsky tml %r15,STACK_SIZE - CONFIG_STACK_GUARD 594bfc86ceSHeiko Carstens lghi %r14,\savearea 604bfc86ceSHeiko Carstens jz stack_overflow 614bfc86ceSHeiko Carstens#endif 624bfc86ceSHeiko Carstens .endm 634bfc86ceSHeiko Carstens 64ce3dc447SMartin Schwidefsky .macro CHECK_VMAP_STACK savearea,oklabel 65ce3dc447SMartin Schwidefsky#ifdef CONFIG_VMAP_STACK 66ce3dc447SMartin Schwidefsky lgr %r14,%r15 67ce3dc447SMartin Schwidefsky nill %r14,0x10000 - STACK_SIZE 68ce3dc447SMartin Schwidefsky oill %r14,STACK_INIT 69ce3dc447SMartin Schwidefsky clg %r14,__LC_KERNEL_STACK 70ce3dc447SMartin Schwidefsky je \oklabel 71ce3dc447SMartin Schwidefsky clg %r14,__LC_ASYNC_STACK 72ce3dc447SMartin Schwidefsky je \oklabel 73ce3dc447SMartin Schwidefsky clg %r14,__LC_NODAT_STACK 74ce3dc447SMartin Schwidefsky je \oklabel 75ce3dc447SMartin Schwidefsky clg %r14,__LC_RESTART_STACK 76ce3dc447SMartin Schwidefsky je \oklabel 77ce3dc447SMartin Schwidefsky lghi %r14,\savearea 78ce3dc447SMartin Schwidefsky j stack_overflow 79ce3dc447SMartin Schwidefsky#else 80ce3dc447SMartin Schwidefsky j \oklabel 81ce3dc447SMartin Schwidefsky#endif 82ce3dc447SMartin Schwidefsky .endm 83ce3dc447SMartin Schwidefsky 844bfc86ceSHeiko Carstens .macro STCK savearea 8578f65709SHeiko Carstens ALTERNATIVE ".insn s,0xb2050000,\savearea", \ 8678f65709SHeiko Carstens ".insn s,0xb27c0000,\savearea", 25 874bfc86ceSHeiko Carstens .endm 884bfc86ceSHeiko Carstens 8983abeffbSHendrik Brueckner /* 9083abeffbSHendrik Brueckner * The TSTMSK macro generates a test-under-mask instruction by 9183abeffbSHendrik Brueckner * calculating the memory offset for the specified mask value. 9283abeffbSHendrik Brueckner * Mask value can be any constant. The macro shifts the mask 9383abeffbSHendrik Brueckner * value to calculate the memory offset for the test-under-mask 9483abeffbSHendrik Brueckner * instruction. 9583abeffbSHendrik Brueckner */ 9683abeffbSHendrik Brueckner .macro TSTMSK addr, mask, size=8, bytepos=0 9783abeffbSHendrik Brueckner .if (\bytepos < \size) && (\mask >> 8) 9883abeffbSHendrik Brueckner .if (\mask & 0xff) 9983abeffbSHendrik Brueckner .error "Mask exceeds byte boundary" 10083abeffbSHendrik Brueckner .endif 10183abeffbSHendrik Brueckner TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)" 10283abeffbSHendrik Brueckner .exitm 10383abeffbSHendrik Brueckner .endif 10483abeffbSHendrik Brueckner .ifeq \mask 10583abeffbSHendrik Brueckner .error "Mask must not be zero" 10683abeffbSHendrik Brueckner .endif 10783abeffbSHendrik Brueckner off = \size - \bytepos - 1 10883abeffbSHendrik Brueckner tm off+\addr, \mask 10983abeffbSHendrik Brueckner .endm 11083abeffbSHendrik Brueckner 111d768bd89SMartin Schwidefsky .macro BPOFF 112b058661aSMartin Schwidefsky ALTERNATIVE "", ".long 0xb2e8c000", 82 113d768bd89SMartin Schwidefsky .endm 114d768bd89SMartin Schwidefsky 115d768bd89SMartin Schwidefsky .macro BPON 116b058661aSMartin Schwidefsky ALTERNATIVE "", ".long 0xb2e8d000", 82 117d768bd89SMartin Schwidefsky .endm 118d768bd89SMartin Schwidefsky 1196b73044bSMartin Schwidefsky .macro BPENTER tif_ptr,tif_mask 120b058661aSMartin Schwidefsky ALTERNATIVE "TSTMSK \tif_ptr,\tif_mask; jz .+8; .long 0xb2e8d000", \ 121b058661aSMartin Schwidefsky "", 82 1226b73044bSMartin Schwidefsky .endm 1236b73044bSMartin Schwidefsky 1246b73044bSMartin Schwidefsky .macro BPEXIT tif_ptr,tif_mask 1256b73044bSMartin Schwidefsky TSTMSK \tif_ptr,\tif_mask 126b058661aSMartin Schwidefsky ALTERNATIVE "jz .+8; .long 0xb2e8c000", \ 127b058661aSMartin Schwidefsky "jnz .+8; .long 0xb2e8d000", 82 1286b73044bSMartin Schwidefsky .endm 1296b73044bSMartin Schwidefsky 1306dd85fbbSMartin Schwidefsky GEN_BR_THUNK %r14 1316dd85fbbSMartin Schwidefsky GEN_BR_THUNK %r14,%r11 132f19fbd5eSMartin Schwidefsky 1334bfc86ceSHeiko Carstens .section .kprobes.text, "ax" 13446210c44SHeiko Carstens.Ldummy: 13546210c44SHeiko Carstens /* 13656e62a73SSven Schnelle * This nop exists only in order to avoid that __bpon starts at 13746210c44SHeiko Carstens * the beginning of the kprobes text section. In that case we would 13846210c44SHeiko Carstens * have several symbols at the same address. E.g. objdump would take 13946210c44SHeiko Carstens * an arbitrary symbol name when disassembling this code. 14056e62a73SSven Schnelle * With the added nop in between the __bpon symbol is unique 14146210c44SHeiko Carstens * again. 14246210c44SHeiko Carstens */ 14346210c44SHeiko Carstens nop 0 1444bfc86ceSHeiko Carstens 145d768bd89SMartin SchwidefskyENTRY(__bpon) 146d768bd89SMartin Schwidefsky .globl __bpon 147d768bd89SMartin Schwidefsky BPON 1486dd85fbbSMartin Schwidefsky BR_EX %r14 14926a374aeSMartin SchwidefskyENDPROC(__bpon) 150d768bd89SMartin Schwidefsky 1514bfc86ceSHeiko Carstens/* 1524bfc86ceSHeiko Carstens * Scheduler resume function, called by switch_to 1534bfc86ceSHeiko Carstens * gpr2 = (task_struct *) prev 1544bfc86ceSHeiko Carstens * gpr3 = (task_struct *) next 1554bfc86ceSHeiko Carstens * Returns: 1564bfc86ceSHeiko Carstens * gpr2 = prev 1574bfc86ceSHeiko Carstens */ 1584bfc86ceSHeiko CarstensENTRY(__switch_to) 1594bfc86ceSHeiko Carstens stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task 1603241d3ebSHeiko Carstens lghi %r4,__TASK_stack 1613241d3ebSHeiko Carstens lghi %r1,__TASK_thread 1629fed920eSVasily Gorbik llill %r5,STACK_INIT 1633241d3ebSHeiko Carstens stg %r15,__THREAD_ksp(%r1,%r2) # store kernel stack of prev 1649fed920eSVasily Gorbik lg %r15,0(%r4,%r3) # start of kernel stack of next 1659fed920eSVasily Gorbik agr %r15,%r5 # end of kernel stack of next 1664bfc86ceSHeiko Carstens stg %r3,__LC_CURRENT # store task struct of next 1674bfc86ceSHeiko Carstens stg %r15,__LC_KERNEL_STACK # store end of kernel stack 1683241d3ebSHeiko Carstens lg %r15,__THREAD_ksp(%r1,%r3) # load kernel stack of next 1693241d3ebSHeiko Carstens aghi %r3,__TASK_pid 1703241d3ebSHeiko Carstens mvc __LC_CURRENT_PID(4,%r0),0(%r3) # store pid of next 1714bfc86ceSHeiko Carstens lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task 172e5b98199SMartin Schwidefsky ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40 1736dd85fbbSMartin Schwidefsky BR_EX %r14 17426a374aeSMartin SchwidefskyENDPROC(__switch_to) 1754bfc86ceSHeiko Carstens 176d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 177d0fc4107SMartin Schwidefsky/* 178d0fc4107SMartin Schwidefsky * sie64a calling convention: 179d0fc4107SMartin Schwidefsky * %r2 pointer to sie control block 180d0fc4107SMartin Schwidefsky * %r3 guest register save area 181d0fc4107SMartin Schwidefsky */ 182d0fc4107SMartin SchwidefskyENTRY(sie64a) 183d0fc4107SMartin Schwidefsky stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers 1846b73044bSMartin Schwidefsky lg %r12,__LC_CURRENT 18592fa7a13SMartin Schwidefsky stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer 18692fa7a13SMartin Schwidefsky stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area 18792fa7a13SMartin Schwidefsky xc __SF_SIE_REASON(8,%r15),__SF_SIE_REASON(%r15) # reason code = 0 18892fa7a13SMartin Schwidefsky mvc __SF_SIE_FLAGS(8,%r15),__TI_flags(%r12) # copy thread flags 189d0fc4107SMartin Schwidefsky lmg %r0,%r13,0(%r3) # load guest gprs 0-13 190d0fc4107SMartin Schwidefsky lg %r14,__LC_GMAP # get gmap pointer 191d0fc4107SMartin Schwidefsky ltgr %r14,%r14 192d0fc4107SMartin Schwidefsky jz .Lsie_gmap 193d0fc4107SMartin Schwidefsky lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce 194d0fc4107SMartin Schwidefsky.Lsie_gmap: 19592fa7a13SMartin Schwidefsky lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer 196d0fc4107SMartin Schwidefsky oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now 197d0fc4107SMartin Schwidefsky tm __SIE_PROG20+3(%r14),3 # last exit... 198d0fc4107SMartin Schwidefsky jnz .Lsie_skip 19983abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 200d0fc4107SMartin Schwidefsky jo .Lsie_skip # exit if fp/vx regs changed 20192fa7a13SMartin Schwidefsky BPEXIT __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) 202c929500dSQingFeng Hao.Lsie_entry: 203d0fc4107SMartin Schwidefsky sie 0(%r14) 204d768bd89SMartin Schwidefsky BPOFF 20592fa7a13SMartin Schwidefsky BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) 206d0fc4107SMartin Schwidefsky.Lsie_skip: 207d0fc4107SMartin Schwidefsky ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE 20887d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce 209d0fc4107SMartin Schwidefsky.Lsie_done: 210d0fc4107SMartin Schwidefsky# some program checks are suppressing. C code (e.g. do_protection_exception) 211c0e7bb38SChristian Borntraeger# will rewind the PSW by the ILC, which is often 4 bytes in case of SIE. There 212c0e7bb38SChristian Borntraeger# are some corner cases (e.g. runtime instrumentation) where ILC is unpredictable. 213c0e7bb38SChristian Borntraeger# Other instructions between sie64a and .Lsie_done should not cause program 214c0e7bb38SChristian Borntraeger# interrupts. So lets use 3 nops as a landing pad for all possible rewinds. 215d0fc4107SMartin Schwidefsky# See also .Lcleanup_sie 216c0e7bb38SChristian Borntraeger.Lrewind_pad6: 217c0e7bb38SChristian Borntraeger nopr 7 218c0e7bb38SChristian Borntraeger.Lrewind_pad4: 219c0e7bb38SChristian Borntraeger nopr 7 220c0e7bb38SChristian Borntraeger.Lrewind_pad2: 221c0e7bb38SChristian Borntraeger nopr 7 222d0fc4107SMartin Schwidefsky .globl sie_exit 223d0fc4107SMartin Schwidefskysie_exit: 22492fa7a13SMartin Schwidefsky lg %r14,__SF_SIE_SAVEAREA(%r15) # load guest register save area 225d0fc4107SMartin Schwidefsky stmg %r0,%r13,0(%r14) # save guest gprs 0-13 2267041d281SMartin Schwidefsky xgr %r0,%r0 # clear guest registers to 2277041d281SMartin Schwidefsky xgr %r1,%r1 # prevent speculative use 2287041d281SMartin Schwidefsky xgr %r3,%r3 2297041d281SMartin Schwidefsky xgr %r4,%r4 2307041d281SMartin Schwidefsky xgr %r5,%r5 231d0fc4107SMartin Schwidefsky lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers 23292fa7a13SMartin Schwidefsky lg %r2,__SF_SIE_REASON(%r15) # return exit reason code 2336dd85fbbSMartin Schwidefsky BR_EX %r14 234d0fc4107SMartin Schwidefsky.Lsie_fault: 235d0fc4107SMartin Schwidefsky lghi %r14,-EFAULT 23692fa7a13SMartin Schwidefsky stg %r14,__SF_SIE_REASON(%r15) # set exit reason code 237d0fc4107SMartin Schwidefsky j sie_exit 238d0fc4107SMartin Schwidefsky 239c0e7bb38SChristian Borntraeger EX_TABLE(.Lrewind_pad6,.Lsie_fault) 240c0e7bb38SChristian Borntraeger EX_TABLE(.Lrewind_pad4,.Lsie_fault) 241c0e7bb38SChristian Borntraeger EX_TABLE(.Lrewind_pad2,.Lsie_fault) 242d0fc4107SMartin Schwidefsky EX_TABLE(sie_exit,.Lsie_fault) 24326a374aeSMartin SchwidefskyENDPROC(sie64a) 244711f5df7SAl ViroEXPORT_SYMBOL(sie64a) 245711f5df7SAl ViroEXPORT_SYMBOL(sie_exit) 246d0fc4107SMartin Schwidefsky#endif 247d0fc4107SMartin Schwidefsky 2484bfc86ceSHeiko Carstens/* 2494bfc86ceSHeiko Carstens * SVC interrupt handler routine. System calls are synchronous events and 2507b7735c5SChristian Borntraeger * are entered with interrupts disabled. 2514bfc86ceSHeiko Carstens */ 2524bfc86ceSHeiko Carstens 2534bfc86ceSHeiko CarstensENTRY(system_call) 25456e62a73SSven Schnelle stpt __LC_SYS_ENTER_TIMER 2554bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_SYNC 256d768bd89SMartin Schwidefsky BPOFF 25756e62a73SSven Schnelle lghi %r14,0 2584bfc86ceSHeiko Carstens.Lsysc_per: 25987d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE 26056e62a73SSven Schnelle lg %r12,__LC_CURRENT 2614bfc86ceSHeiko Carstens lg %r15,__LC_KERNEL_STACK 2629365965dSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 26356e62a73SSven Schnelle stmg %r0,%r7,STACK_FRAME_OVERHEAD+__PT_R0(%r15) 26456e62a73SSven Schnelle BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP 265d3f46896SChristian Borntraeger # clear user controlled register to prevent speculative use 266d3f46896SChristian Borntraeger xgr %r0,%r0 26756e62a73SSven Schnelle xgr %r1,%r1 26856e62a73SSven Schnelle xgr %r4,%r4 26956e62a73SSven Schnelle xgr %r5,%r5 27056e62a73SSven Schnelle xgr %r6,%r6 27156e62a73SSven Schnelle xgr %r7,%r7 27256e62a73SSven Schnelle xgr %r8,%r8 27356e62a73SSven Schnelle xgr %r9,%r9 27456e62a73SSven Schnelle xgr %r10,%r10 27556e62a73SSven Schnelle xgr %r11,%r11 27656e62a73SSven Schnelle la %r2,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs 27756e62a73SSven Schnelle lgr %r3,%r14 27856e62a73SSven Schnelle brasl %r14,__do_syscall 27987d59863SHeiko Carstens lctlg %c1,%c1,__LC_USER_ASCE 28056e62a73SSven Schnelle mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15) 2816b73044bSMartin Schwidefsky BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP 28256e62a73SSven Schnelle lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15) 2834bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 2840b0ed657SSven Schnelle b __LC_RETURN_LPSWE 28526a374aeSMartin SchwidefskyENDPROC(system_call) 2864bfc86ceSHeiko Carstens 2874bfc86ceSHeiko Carstens# 2884bfc86ceSHeiko Carstens# a new process exits the kernel with ret_from_fork 2894bfc86ceSHeiko Carstens# 2904bfc86ceSHeiko CarstensENTRY(ret_from_fork) 29156e62a73SSven Schnelle lgr %r3,%r11 29256e62a73SSven Schnelle brasl %r14,__ret_from_fork 29356e62a73SSven Schnelle lctlg %c1,%c1,__LC_USER_ASCE 29456e62a73SSven Schnelle mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15) 29556e62a73SSven Schnelle BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP 29656e62a73SSven Schnelle lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15) 29756e62a73SSven Schnelle stpt __LC_EXIT_TIMER 29856e62a73SSven Schnelle b __LC_RETURN_LPSWE 29926a374aeSMartin SchwidefskyENDPROC(ret_from_fork) 30026a374aeSMartin Schwidefsky 3014bfc86ceSHeiko Carstens/* 3024bfc86ceSHeiko Carstens * Program check handler routine 3034bfc86ceSHeiko Carstens */ 3044bfc86ceSHeiko Carstens 3054bfc86ceSHeiko CarstensENTRY(pgm_check_handler) 30656e62a73SSven Schnelle stpt __LC_SYS_ENTER_TIMER 307d768bd89SMartin Schwidefsky BPOFF 3084bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_SYNC 30956e62a73SSven Schnelle lg %r12,__LC_CURRENT 31056e62a73SSven Schnelle lghi %r10,0 3114bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_PGM_OLD_PSW 31287d59863SHeiko Carstens tmhh %r8,0x0001 # coming from user space? 31387d59863SHeiko Carstens jno .Lpgm_skip_asce 31487d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE 31556e62a73SSven Schnelle j 3f # -> fault in user space 31687d59863SHeiko Carstens.Lpgm_skip_asce: 317d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 3180a5e2ec2SMartin Schwidefsky # cleanup critical section for program checks in sie64a 319d0fc4107SMartin Schwidefsky lgr %r14,%r9 3200b0ed657SSven Schnelle larl %r13,.Lsie_gmap 3210b0ed657SSven Schnelle slgr %r14,%r13 3220b0ed657SSven Schnelle lghi %r13,.Lsie_done - .Lsie_gmap 3230b0ed657SSven Schnelle clgr %r14,%r13 3240b38b5e1SSven Schnelle jhe 1f 32592fa7a13SMartin Schwidefsky lg %r14,__SF_SIE_CONTROL(%r15) # get control block pointer 3260a5e2ec2SMartin Schwidefsky ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE 32787d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE # load primary asce 3280a5e2ec2SMartin Schwidefsky larl %r9,sie_exit # skip forward to sie_exit 32956e62a73SSven Schnelle lghi %r10,_PIF_GUEST_FAULT 330d0fc4107SMartin Schwidefsky#endif 3310b38b5e1SSven Schnelle1: tmhh %r8,0x4000 # PER bit set in old PSW ? 3320b38b5e1SSven Schnelle jnz 2f # -> enabled, can't be a double fault 3334bfc86ceSHeiko Carstens tm __LC_PGM_ILC+3,0x80 # check for per exception 3344bfc86ceSHeiko Carstens jnz .Lpgm_svcper # -> single stepped svc 3350b38b5e1SSven Schnelle2: CHECK_STACK __LC_SAVE_AREA_SYNC 3364bfc86ceSHeiko Carstens aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 33756e62a73SSven Schnelle # CHECK_VMAP_STACK branches to stack_overflow or 4f 33856e62a73SSven Schnelle CHECK_VMAP_STACK __LC_SAVE_AREA_SYNC,4f 33956e62a73SSven Schnelle3: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP 3404bfc86ceSHeiko Carstens lg %r15,__LC_KERNEL_STACK 34156e62a73SSven Schnelle4: la %r11,STACK_FRAME_OVERHEAD(%r15) 34256e62a73SSven Schnelle stg %r10,__PT_FLAGS(%r11) 34356e62a73SSven Schnelle xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 3444bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 34556e62a73SSven Schnelle mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC 34656e62a73SSven Schnelle stmg %r8,%r9,__PT_PSW(%r11) 34756e62a73SSven Schnelle 3487041d281SMartin Schwidefsky # clear user controlled registers to prevent speculative use 3497041d281SMartin Schwidefsky xgr %r0,%r0 3507041d281SMartin Schwidefsky xgr %r1,%r1 3517041d281SMartin Schwidefsky xgr %r3,%r3 3527041d281SMartin Schwidefsky xgr %r4,%r4 3537041d281SMartin Schwidefsky xgr %r5,%r5 3547041d281SMartin Schwidefsky xgr %r6,%r6 3557041d281SMartin Schwidefsky xgr %r7,%r7 35656e62a73SSven Schnelle lgr %r2,%r11 35756e62a73SSven Schnelle brasl %r14,__do_pgm_check 35856e62a73SSven Schnelle tmhh %r8,0x0001 # returning to user space? 35956e62a73SSven Schnelle jno .Lpgm_exit_kernel 36056e62a73SSven Schnelle lctlg %c1,%c1,__LC_USER_ASCE 36156e62a73SSven Schnelle BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP 3620cd9b723SHeiko Carstens stpt __LC_EXIT_TIMER 36356e62a73SSven Schnelle.Lpgm_exit_kernel: 36456e62a73SSven Schnelle mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15) 36556e62a73SSven Schnelle lmg %r0,%r15,STACK_FRAME_OVERHEAD+__PT_R0(%r15) 3660cd9b723SHeiko Carstens b __LC_RETURN_LPSWE 3674bfc86ceSHeiko Carstens 3684bfc86ceSHeiko Carstens# 3694bfc86ceSHeiko Carstens# single stepped system call 3704bfc86ceSHeiko Carstens# 3714bfc86ceSHeiko Carstens.Lpgm_svcper: 3724bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW 3734bfc86ceSHeiko Carstens larl %r14,.Lsysc_per 3744bfc86ceSHeiko Carstens stg %r14,__LC_RETURN_PSW+8 37556e62a73SSven Schnelle lghi %r14,1 3760b0ed657SSven Schnelle lpswe __LC_RETURN_PSW # branch to .Lsysc_per 37726a374aeSMartin SchwidefskyENDPROC(pgm_check_handler) 3784bfc86ceSHeiko Carstens 3794bfc86ceSHeiko Carstens/* 38056e62a73SSven Schnelle * Interrupt handler macro used for external and IO interrupts. 3814bfc86ceSHeiko Carstens */ 38256e62a73SSven Schnelle.macro INT_HANDLER name,lc_old_psw,handler 38356e62a73SSven SchnelleENTRY(\name) 3844bfc86ceSHeiko Carstens STCK __LC_INT_CLOCK 38556e62a73SSven Schnelle stpt __LC_SYS_ENTER_TIMER 386d768bd89SMartin Schwidefsky BPOFF 3874bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_ASYNC 388d5c352cdSHeiko Carstens lg %r12,__LC_CURRENT 38956e62a73SSven Schnelle lmg %r8,%r9,\lc_old_psw 390*b0d31159SSven Schnelle tmhh %r8,0x0001 # interrupting from user ? 391*b0d31159SSven Schnelle jnz 1f 392*b0d31159SSven Schnelle#if IS_ENABLED(CONFIG_KVM) 393*b0d31159SSven Schnelle lgr %r14,%r9 394*b0d31159SSven Schnelle larl %r13,.Lsie_gmap 395*b0d31159SSven Schnelle slgr %r14,%r13 396*b0d31159SSven Schnelle lghi %r13,.Lsie_done - .Lsie_gmap 397*b0d31159SSven Schnelle clgr %r14,%r13 398*b0d31159SSven Schnelle jhe 0f 399*b0d31159SSven Schnelle lghi %r11,__LC_SAVE_AREA_ASYNC # inside critical section, do cleanup 400*b0d31159SSven Schnelle brasl %r14,.Lcleanup_sie 401*b0d31159SSven Schnelle#endif 402*b0d31159SSven Schnelle0: CHECK_STACK __LC_SAVE_AREA_ASYNC 403*b0d31159SSven Schnelle lgr %r11,%r15 404*b0d31159SSven Schnelle aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 405*b0d31159SSven Schnelle stg %r11,__SF_BACKCHAIN(%r15) 406*b0d31159SSven Schnelle j 2f 407*b0d31159SSven Schnelle1: BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP 408*b0d31159SSven Schnelle lctlg %c1,%c1,__LC_KERNEL_ASCE 409*b0d31159SSven Schnelle lg %r15,__LC_KERNEL_STACK 410*b0d31159SSven Schnelle xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 411*b0d31159SSven Schnelle2: la %r11,STACK_FRAME_OVERHEAD(%r15) 4124bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 4137041d281SMartin Schwidefsky # clear user controlled registers to prevent speculative use 4147041d281SMartin Schwidefsky xgr %r0,%r0 4157041d281SMartin Schwidefsky xgr %r1,%r1 4167041d281SMartin Schwidefsky xgr %r3,%r3 4177041d281SMartin Schwidefsky xgr %r4,%r4 4187041d281SMartin Schwidefsky xgr %r5,%r5 4197041d281SMartin Schwidefsky xgr %r6,%r6 4207041d281SMartin Schwidefsky xgr %r7,%r7 4217041d281SMartin Schwidefsky xgr %r10,%r10 4224bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC 4234bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 42456e62a73SSven Schnelle tm %r8,0x0001 # coming from user space? 42556e62a73SSven Schnelle jno 1f 42687d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE 42756e62a73SSven Schnelle1: lgr %r2,%r11 # pass pointer to pt_regs 42856e62a73SSven Schnelle brasl %r14,\handler 4294bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) 43056e62a73SSven Schnelle tmhh %r8,0x0001 # returning to user ? 43156e62a73SSven Schnelle jno 2f 43287d59863SHeiko Carstens lctlg %c1,%c1,__LC_USER_ASCE 4336b73044bSMartin Schwidefsky BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP 4344bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 43556e62a73SSven Schnelle2: lmg %r0,%r15,__PT_R0(%r11) 4360b0ed657SSven Schnelle b __LC_RETURN_LPSWE 43756e62a73SSven SchnelleENDPROC(\name) 43856e62a73SSven Schnelle.endm 4394bfc86ceSHeiko Carstens 44056e62a73SSven SchnelleINT_HANDLER ext_int_handler,__LC_EXT_OLD_PSW,do_ext_irq 44156e62a73SSven SchnelleINT_HANDLER io_int_handler,__LC_IO_OLD_PSW,do_io_irq 4424bfc86ceSHeiko Carstens 4434bfc86ceSHeiko Carstens/* 4440b0ed657SSven Schnelle * Load idle PSW. 4454bfc86ceSHeiko Carstens */ 4464bfc86ceSHeiko CarstensENTRY(psw_idle) 4474bfc86ceSHeiko Carstens stg %r3,__SF_EMPTY(%r15) 44856e62a73SSven Schnelle larl %r1,psw_idle_exit 4494bfc86ceSHeiko Carstens stg %r1,__SF_EMPTY+8(%r15) 45072d38b19SMartin Schwidefsky larl %r1,smp_cpu_mtid 45172d38b19SMartin Schwidefsky llgf %r1,0(%r1) 45272d38b19SMartin Schwidefsky ltgr %r1,%r1 45372d38b19SMartin Schwidefsky jz .Lpsw_idle_stcctm 45456e62a73SSven Schnelle .insn rsy,0xeb0000000017,%r1,5,__MT_CYCLES_ENTER(%r2) 45572d38b19SMartin Schwidefsky.Lpsw_idle_stcctm: 456419123f9SMartin Schwidefsky oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT 457d768bd89SMartin Schwidefsky BPON 4584bfc86ceSHeiko Carstens STCK __CLOCK_IDLE_ENTER(%r2) 4594bfc86ceSHeiko Carstens stpt __TIMER_IDLE_ENTER(%r2) 4604bfc86ceSHeiko Carstens lpswe __SF_EMPTY(%r15) 46156e62a73SSven Schnelle.globl psw_idle_exit 46256e62a73SSven Schnellepsw_idle_exit: 4636dd85fbbSMartin Schwidefsky BR_EX %r14 46426a374aeSMartin SchwidefskyENDPROC(psw_idle) 4654bfc86ceSHeiko Carstens 466b5510d9bSHendrik Brueckner/* 4674bfc86ceSHeiko Carstens * Machine check handler routines 4684bfc86ceSHeiko Carstens */ 4694bfc86ceSHeiko CarstensENTRY(mcck_int_handler) 4704bfc86ceSHeiko Carstens STCK __LC_MCCK_CLOCK 471d768bd89SMartin Schwidefsky BPOFF 4723037a52fSMartin Schwidefsky la %r1,4095 # validate r1 4733037a52fSMartin Schwidefsky spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # validate cpu timer 4743037a52fSMartin Schwidefsky sckc __LC_CLOCK_COMPARATOR # validate comparator 4753037a52fSMartin Schwidefsky lam %a0,%a15,__LC_AREGS_SAVE_AREA-4095(%r1) # validate acrs 4763037a52fSMartin Schwidefsky lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# validate gprs 477d5c352cdSHeiko Carstens lg %r12,__LC_CURRENT 4784bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_MCK_OLD_PSW 47983abeffbSHendrik Brueckner TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE 4804bfc86ceSHeiko Carstens jo .Lmcck_panic # yes -> rest of mcck code invalid 4813037a52fSMartin Schwidefsky TSTMSK __LC_MCCK_CODE,MCCK_CODE_CR_VALID 4823037a52fSMartin Schwidefsky jno .Lmcck_panic # control registers invalid -> panic 4833037a52fSMartin Schwidefsky la %r14,4095 4843037a52fSMartin Schwidefsky lctlg %c0,%c15,__LC_CREGS_SAVE_AREA-4095(%r14) # validate ctl regs 4853037a52fSMartin Schwidefsky ptlb 4862a2d7befSVasily Gorbik lg %r11,__LC_MCESAD-4095(%r14) # extended machine check save area 4873037a52fSMartin Schwidefsky nill %r11,0xfc00 # MCESA_ORIGIN_MASK 4883037a52fSMartin Schwidefsky TSTMSK __LC_CREGS_SAVE_AREA+16-4095(%r14),CR2_GUARDED_STORAGE 4893037a52fSMartin Schwidefsky jno 0f 4903037a52fSMartin Schwidefsky TSTMSK __LC_MCCK_CODE,MCCK_CODE_GS_VALID 4913037a52fSMartin Schwidefsky jno 0f 4923037a52fSMartin Schwidefsky .insn rxy,0xe3000000004d,0,__MCESA_GS_SAVE_AREA(%r11) # LGSC 4933037a52fSMartin Schwidefsky0: l %r14,__LC_FP_CREG_SAVE_AREA-4095(%r14) 4943037a52fSMartin Schwidefsky TSTMSK __LC_MCCK_CODE,MCCK_CODE_FC_VALID 4953037a52fSMartin Schwidefsky jo 0f 4963037a52fSMartin Schwidefsky sr %r14,%r14 4973037a52fSMartin Schwidefsky0: sfpc %r14 4983037a52fSMartin Schwidefsky TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 4993037a52fSMartin Schwidefsky jo 0f 5003037a52fSMartin Schwidefsky lghi %r14,__LC_FPREGS_SAVE_AREA 5013037a52fSMartin Schwidefsky ld %f0,0(%r14) 5023037a52fSMartin Schwidefsky ld %f1,8(%r14) 5033037a52fSMartin Schwidefsky ld %f2,16(%r14) 5043037a52fSMartin Schwidefsky ld %f3,24(%r14) 5053037a52fSMartin Schwidefsky ld %f4,32(%r14) 5063037a52fSMartin Schwidefsky ld %f5,40(%r14) 5073037a52fSMartin Schwidefsky ld %f6,48(%r14) 5083037a52fSMartin Schwidefsky ld %f7,56(%r14) 5093037a52fSMartin Schwidefsky ld %f8,64(%r14) 5103037a52fSMartin Schwidefsky ld %f9,72(%r14) 5113037a52fSMartin Schwidefsky ld %f10,80(%r14) 5123037a52fSMartin Schwidefsky ld %f11,88(%r14) 5133037a52fSMartin Schwidefsky ld %f12,96(%r14) 5143037a52fSMartin Schwidefsky ld %f13,104(%r14) 5153037a52fSMartin Schwidefsky ld %f14,112(%r14) 5163037a52fSMartin Schwidefsky ld %f15,120(%r14) 5173037a52fSMartin Schwidefsky j 1f 5183037a52fSMartin Schwidefsky0: VLM %v0,%v15,0,%r11 5193037a52fSMartin Schwidefsky VLM %v16,%v31,256,%r11 5203037a52fSMartin Schwidefsky1: lghi %r14,__LC_CPU_TIMER_SAVE_AREA 5214bfc86ceSHeiko Carstens mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) 52283abeffbSHendrik Brueckner TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID 5234bfc86ceSHeiko Carstens jo 3f 52456e62a73SSven Schnelle la %r14,__LC_SYS_ENTER_TIMER 52556e62a73SSven Schnelle clc 0(8,%r14),__LC_EXIT_TIMER 5264bfc86ceSHeiko Carstens jl 1f 5274bfc86ceSHeiko Carstens la %r14,__LC_EXIT_TIMER 5284bfc86ceSHeiko Carstens1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER 5294bfc86ceSHeiko Carstens jl 2f 5304bfc86ceSHeiko Carstens la %r14,__LC_LAST_UPDATE_TIMER 5314bfc86ceSHeiko Carstens2: spt 0(%r14) 5324bfc86ceSHeiko Carstens mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) 5333037a52fSMartin Schwidefsky3: TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_MWP_VALID 5343037a52fSMartin Schwidefsky jno .Lmcck_panic 5353037a52fSMartin Schwidefsky tmhh %r8,0x0001 # interrupting from user ? 5363037a52fSMartin Schwidefsky jnz 4f 5373037a52fSMartin Schwidefsky TSTMSK __LC_MCCK_CODE,MCCK_CODE_PSW_IA_VALID 5383037a52fSMartin Schwidefsky jno .Lmcck_panic 539ce3dc447SMartin Schwidefsky4: ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off 540*b0d31159SSven Schnelle tmhh %r8,0x0001 # interrupting from user ? 541*b0d31159SSven Schnelle jnz .Lmcck_user 542*b0d31159SSven Schnelle#if IS_ENABLED(CONFIG_KVM) 543*b0d31159SSven Schnelle lgr %r14,%r9 544*b0d31159SSven Schnelle larl %r13,.Lsie_gmap 545*b0d31159SSven Schnelle slgr %r14,%r13 546*b0d31159SSven Schnelle lghi %r13,.Lsie_done - .Lsie_gmap 547*b0d31159SSven Schnelle clgr %r14,%r13 548*b0d31159SSven Schnelle jhe .Lmcck_stack 549*b0d31159SSven Schnelle lghi %r11,__LC_GPREGS_SAVE_AREA+64 # inside critical section, do cleanup 550*b0d31159SSven Schnelle brasl %r14,.Lcleanup_sie 551*b0d31159SSven Schnelle.Lmcck_stack: 552*b0d31159SSven Schnelle#endif 553*b0d31159SSven Schnelle CHECK_STACK __LC_GPREGS_SAVE_AREA+64 554*b0d31159SSven Schnelle lgr %r11,%r15 555*b0d31159SSven Schnelle aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 556*b0d31159SSven Schnelle stg %r11,__SF_BACKCHAIN(%r15) 557*b0d31159SSven Schnelle j 5f 558*b0d31159SSven Schnelle.Lmcck_user: 559*b0d31159SSven Schnelle BPENTER __TI_flags(%r12),_TIF_ISOLATE_BP 560*b0d31159SSven Schnelle lctlg %c1,%c1,__LC_KERNEL_ASCE 561*b0d31159SSven Schnelle lg %r15,__LC_KERNEL_STACK 562*b0d31159SSven Schnelle xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 563*b0d31159SSven Schnelle5: la %r11,STACK_FRAME_OVERHEAD(%r15) 5644bfc86ceSHeiko Carstens.Lmcck_skip: 5654bfc86ceSHeiko Carstens lghi %r14,__LC_GPREGS_SAVE_AREA+64 5664bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 5677041d281SMartin Schwidefsky # clear user controlled registers to prevent speculative use 5687041d281SMartin Schwidefsky xgr %r0,%r0 5697041d281SMartin Schwidefsky xgr %r1,%r1 5707041d281SMartin Schwidefsky xgr %r3,%r3 5717041d281SMartin Schwidefsky xgr %r4,%r4 5727041d281SMartin Schwidefsky xgr %r5,%r5 5737041d281SMartin Schwidefsky xgr %r6,%r6 5747041d281SMartin Schwidefsky xgr %r7,%r7 5757041d281SMartin Schwidefsky xgr %r10,%r10 5764bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),0(%r14) 5774bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 57887d59863SHeiko Carstens la %r14,4095 57987d59863SHeiko Carstens mvc __PT_CR1(8,%r11),__LC_CREGS_SAVE_AREA-4095+8(%r14) 5804bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 5814bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 5824bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 5834bfc86ceSHeiko Carstens brasl %r14,s390_do_machine_check 5840b0ed657SSven Schnelle cghi %r2,0 5850b0ed657SSven Schnelle je .Lmcck_return 5864bfc86ceSHeiko Carstens lg %r1,__LC_KERNEL_STACK # switch to kernel stack 5874bfc86ceSHeiko Carstens mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) 5884bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) 5894bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r1) 5904bfc86ceSHeiko Carstens lgr %r15,%r1 5914bfc86ceSHeiko Carstens brasl %r14,s390_handle_mcck 5924bfc86ceSHeiko Carstens.Lmcck_return: 59387d59863SHeiko Carstens lctlg %c1,%c1,__PT_CR1(%r11) 5944bfc86ceSHeiko Carstens lmg %r0,%r10,__PT_R0(%r11) 5954bfc86ceSHeiko Carstens mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW 5964bfc86ceSHeiko Carstens tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ? 5974bfc86ceSHeiko Carstens jno 0f 5986b73044bSMartin Schwidefsky BPEXIT __TI_flags(%r12),_TIF_ISOLATE_BP 5994bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 6004bfc86ceSHeiko Carstens0: lmg %r11,%r15,__PT_R11(%r11) 6010b38b5e1SSven Schnelle b __LC_RETURN_MCCK_LPSWE 6024bfc86ceSHeiko Carstens 6034bfc86ceSHeiko Carstens.Lmcck_panic: 604ce3dc447SMartin Schwidefsky lg %r15,__LC_NODAT_STACK 605ce4dda3fSMartin Schwidefsky la %r11,STACK_FRAME_OVERHEAD(%r15) 6064bfc86ceSHeiko Carstens j .Lmcck_skip 60726a374aeSMartin SchwidefskyENDPROC(mcck_int_handler) 6084bfc86ceSHeiko Carstens 6094bfc86ceSHeiko Carstens# 6104bfc86ceSHeiko Carstens# PSW restart interrupt handler 6114bfc86ceSHeiko Carstens# 6124bfc86ceSHeiko CarstensENTRY(restart_int_handler) 613e5b98199SMartin Schwidefsky ALTERNATIVE "", ".insn s,0xb2800000,_LPP_OFFSET", 40 614e5b98199SMartin Schwidefsky stg %r15,__LC_SAVE_AREA_RESTART 6154bfc86ceSHeiko Carstens lg %r15,__LC_RESTART_STACK 616ce3dc447SMartin Schwidefsky xc STACK_FRAME_OVERHEAD(__PT_SIZE,%r15),STACK_FRAME_OVERHEAD(%r15) 617ce3dc447SMartin Schwidefsky stmg %r0,%r14,STACK_FRAME_OVERHEAD+__PT_R0(%r15) 618ce3dc447SMartin Schwidefsky mvc STACK_FRAME_OVERHEAD+__PT_R15(8,%r15),__LC_SAVE_AREA_RESTART 619ce3dc447SMartin Schwidefsky mvc STACK_FRAME_OVERHEAD+__PT_PSW(16,%r15),__LC_RST_OLD_PSW 6204bfc86ceSHeiko Carstens xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15) 6214bfc86ceSHeiko Carstens lg %r1,__LC_RESTART_FN # load fn, parm & source cpu 6224bfc86ceSHeiko Carstens lg %r2,__LC_RESTART_DATA 6234bfc86ceSHeiko Carstens lg %r3,__LC_RESTART_SOURCE 6244bfc86ceSHeiko Carstens ltgr %r3,%r3 # test source cpu address 6254bfc86ceSHeiko Carstens jm 1f # negative -> skip source stop 6264bfc86ceSHeiko Carstens0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu 6274bfc86ceSHeiko Carstens brc 10,0b # wait for status stored 6284bfc86ceSHeiko Carstens1: basr %r14,%r1 # call function 6294bfc86ceSHeiko Carstens stap __SF_EMPTY(%r15) # store cpu address 6304bfc86ceSHeiko Carstens llgh %r3,__SF_EMPTY(%r15) 6314bfc86ceSHeiko Carstens2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu 6324bfc86ceSHeiko Carstens brc 2,2b 6334bfc86ceSHeiko Carstens3: j 3b 63426a374aeSMartin SchwidefskyENDPROC(restart_int_handler) 6354bfc86ceSHeiko Carstens 6364bfc86ceSHeiko Carstens .section .kprobes.text, "ax" 6374bfc86ceSHeiko Carstens 638ce3dc447SMartin Schwidefsky#if defined(CONFIG_CHECK_STACK) || defined(CONFIG_VMAP_STACK) 6394bfc86ceSHeiko Carstens/* 6404bfc86ceSHeiko Carstens * The synchronous or the asynchronous stack overflowed. We are dead. 6414bfc86ceSHeiko Carstens * No need to properly save the registers, we are going to panic anyway. 6424bfc86ceSHeiko Carstens * Setup a pt_regs so that show_trace can provide a good call trace. 6434bfc86ceSHeiko Carstens */ 64426a374aeSMartin SchwidefskyENTRY(stack_overflow) 645ce3dc447SMartin Schwidefsky lg %r15,__LC_NODAT_STACK # change to panic stack 6464bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r15) 6474bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 6484bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 6494bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),0(%r14) 6504bfc86ceSHeiko Carstens stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2 6514bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 6524bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 6534bfc86ceSHeiko Carstens jg kernel_stack_overflow 65426a374aeSMartin SchwidefskyENDPROC(stack_overflow) 6554bfc86ceSHeiko Carstens#endif 6564bfc86ceSHeiko Carstens 657d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 658d0fc4107SMartin Schwidefsky.Lcleanup_sie: 659c929500dSQingFeng Hao cghi %r11,__LC_SAVE_AREA_ASYNC #Is this in normal interrupt? 660c929500dSQingFeng Hao je 1f 6610b0ed657SSven Schnelle larl %r13,.Lsie_entry 6620b0ed657SSven Schnelle slgr %r9,%r13 6630b0ed657SSven Schnelle larl %r13,.Lsie_skip 6640b0ed657SSven Schnelle clgr %r9,%r13 665c929500dSQingFeng Hao jh 1f 666c929500dSQingFeng Hao oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST 66792fa7a13SMartin Schwidefsky1: BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) 66892fa7a13SMartin Schwidefsky lg %r9,__SF_SIE_CONTROL(%r15) # get control block pointer 669e22cf8caSChristian Borntraeger ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE 67087d59863SHeiko Carstens lctlg %c1,%c1,__LC_KERNEL_ASCE 671d0fc4107SMartin Schwidefsky larl %r9,sie_exit # skip forward to sie_exit 672891f6a72SChristian Borntraeger BR_EX %r14,%r11 6734bfc86ceSHeiko Carstens 6744bfc86ceSHeiko Carstens#endif 6754bfc86ceSHeiko Carstens .section .rodata, "a" 676ff4a742dSGerald Schaefer#define SYSCALL(esame,emu) .quad __s390x_ ## esame 6774bfc86ceSHeiko Carstens .globl sys_call_table 6784bfc86ceSHeiko Carstenssys_call_table: 6794381f9f1SHendrik Brueckner#include "asm/syscall_table.h" 6804bfc86ceSHeiko Carstens#undef SYSCALL 6814bfc86ceSHeiko Carstens 6824bfc86ceSHeiko Carstens#ifdef CONFIG_COMPAT 6834bfc86ceSHeiko Carstens 684ff4a742dSGerald Schaefer#define SYSCALL(esame,emu) .quad __s390_ ## emu 6854bfc86ceSHeiko Carstens .globl sys_call_table_emu 6864bfc86ceSHeiko Carstenssys_call_table_emu: 6874381f9f1SHendrik Brueckner#include "asm/syscall_table.h" 6884bfc86ceSHeiko Carstens#undef SYSCALL 6894bfc86ceSHeiko Carstens#endif 690