14bfc86ceSHeiko Carstens/* 24bfc86ceSHeiko Carstens * S390 low-level entry points. 34bfc86ceSHeiko Carstens * 44bfc86ceSHeiko Carstens * Copyright IBM Corp. 1999, 2012 54bfc86ceSHeiko Carstens * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com), 64bfc86ceSHeiko Carstens * Hartmut Penner (hp@de.ibm.com), 74bfc86ceSHeiko Carstens * Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com), 84bfc86ceSHeiko Carstens * Heiko Carstens <heiko.carstens@de.ibm.com> 94bfc86ceSHeiko Carstens */ 104bfc86ceSHeiko Carstens 114bfc86ceSHeiko Carstens#include <linux/init.h> 124bfc86ceSHeiko Carstens#include <linux/linkage.h> 134bfc86ceSHeiko Carstens#include <asm/processor.h> 144bfc86ceSHeiko Carstens#include <asm/cache.h> 154bfc86ceSHeiko Carstens#include <asm/errno.h> 164bfc86ceSHeiko Carstens#include <asm/ptrace.h> 174bfc86ceSHeiko Carstens#include <asm/thread_info.h> 184bfc86ceSHeiko Carstens#include <asm/asm-offsets.h> 194bfc86ceSHeiko Carstens#include <asm/unistd.h> 204bfc86ceSHeiko Carstens#include <asm/page.h> 214bfc86ceSHeiko Carstens#include <asm/sigp.h> 224bfc86ceSHeiko Carstens#include <asm/irq.h> 239977e886SHendrik Brueckner#include <asm/vx-insn.h> 2483abeffbSHendrik Brueckner#include <asm/setup.h> 2583abeffbSHendrik Brueckner#include <asm/nmi.h> 264bfc86ceSHeiko Carstens 274bfc86ceSHeiko Carstens__PT_R0 = __PT_GPRS 284bfc86ceSHeiko Carstens__PT_R1 = __PT_GPRS + 8 294bfc86ceSHeiko Carstens__PT_R2 = __PT_GPRS + 16 304bfc86ceSHeiko Carstens__PT_R3 = __PT_GPRS + 24 314bfc86ceSHeiko Carstens__PT_R4 = __PT_GPRS + 32 324bfc86ceSHeiko Carstens__PT_R5 = __PT_GPRS + 40 334bfc86ceSHeiko Carstens__PT_R6 = __PT_GPRS + 48 344bfc86ceSHeiko Carstens__PT_R7 = __PT_GPRS + 56 354bfc86ceSHeiko Carstens__PT_R8 = __PT_GPRS + 64 364bfc86ceSHeiko Carstens__PT_R9 = __PT_GPRS + 72 374bfc86ceSHeiko Carstens__PT_R10 = __PT_GPRS + 80 384bfc86ceSHeiko Carstens__PT_R11 = __PT_GPRS + 88 394bfc86ceSHeiko Carstens__PT_R12 = __PT_GPRS + 96 404bfc86ceSHeiko Carstens__PT_R13 = __PT_GPRS + 104 414bfc86ceSHeiko Carstens__PT_R14 = __PT_GPRS + 112 424bfc86ceSHeiko Carstens__PT_R15 = __PT_GPRS + 120 434bfc86ceSHeiko Carstens 444bfc86ceSHeiko CarstensSTACK_SHIFT = PAGE_SHIFT + THREAD_ORDER 454bfc86ceSHeiko CarstensSTACK_SIZE = 1 << STACK_SHIFT 464bfc86ceSHeiko CarstensSTACK_INIT = STACK_SIZE - STACK_FRAME_OVERHEAD - __PT_SIZE 474bfc86ceSHeiko Carstens 484bfc86ceSHeiko Carstens_TIF_WORK = (_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NEED_RESCHED | \ 494bfc86ceSHeiko Carstens _TIF_UPROBE) 504bfc86ceSHeiko Carstens_TIF_TRACE = (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SECCOMP | \ 514bfc86ceSHeiko Carstens _TIF_SYSCALL_TRACEPOINT) 529977e886SHendrik Brueckner_CIF_WORK = (_CIF_MCCK_PENDING | _CIF_ASCE | _CIF_FPU) 534bfc86ceSHeiko Carstens_PIF_WORK = (_PIF_PER_TRAP) 544bfc86ceSHeiko Carstens 559977e886SHendrik Brueckner#define BASED(name) name-cleanup_critical(%r13) 564bfc86ceSHeiko Carstens 574bfc86ceSHeiko Carstens .macro TRACE_IRQS_ON 584bfc86ceSHeiko Carstens#ifdef CONFIG_TRACE_IRQFLAGS 594bfc86ceSHeiko Carstens basr %r2,%r0 604bfc86ceSHeiko Carstens brasl %r14,trace_hardirqs_on_caller 614bfc86ceSHeiko Carstens#endif 624bfc86ceSHeiko Carstens .endm 634bfc86ceSHeiko Carstens 644bfc86ceSHeiko Carstens .macro TRACE_IRQS_OFF 654bfc86ceSHeiko Carstens#ifdef CONFIG_TRACE_IRQFLAGS 664bfc86ceSHeiko Carstens basr %r2,%r0 674bfc86ceSHeiko Carstens brasl %r14,trace_hardirqs_off_caller 684bfc86ceSHeiko Carstens#endif 694bfc86ceSHeiko Carstens .endm 704bfc86ceSHeiko Carstens 714bfc86ceSHeiko Carstens .macro LOCKDEP_SYS_EXIT 724bfc86ceSHeiko Carstens#ifdef CONFIG_LOCKDEP 734bfc86ceSHeiko Carstens tm __PT_PSW+1(%r11),0x01 # returning to user ? 744bfc86ceSHeiko Carstens jz .+10 754bfc86ceSHeiko Carstens brasl %r14,lockdep_sys_exit 764bfc86ceSHeiko Carstens#endif 774bfc86ceSHeiko Carstens .endm 784bfc86ceSHeiko Carstens 794bfc86ceSHeiko Carstens .macro CHECK_STACK stacksize,savearea 804bfc86ceSHeiko Carstens#ifdef CONFIG_CHECK_STACK 814bfc86ceSHeiko Carstens tml %r15,\stacksize - CONFIG_STACK_GUARD 824bfc86ceSHeiko Carstens lghi %r14,\savearea 834bfc86ceSHeiko Carstens jz stack_overflow 844bfc86ceSHeiko Carstens#endif 854bfc86ceSHeiko Carstens .endm 864bfc86ceSHeiko Carstens 872acb94f4SMartin Schwidefsky .macro SWITCH_ASYNC savearea,timer 884bfc86ceSHeiko Carstens tmhh %r8,0x0001 # interrupting from user ? 894bfc86ceSHeiko Carstens jnz 1f 904bfc86ceSHeiko Carstens lgr %r14,%r9 914bfc86ceSHeiko Carstens slg %r14,BASED(.Lcritical_start) 924bfc86ceSHeiko Carstens clg %r14,BASED(.Lcritical_length) 934bfc86ceSHeiko Carstens jhe 0f 944bfc86ceSHeiko Carstens lghi %r11,\savearea # inside critical section, do cleanup 954bfc86ceSHeiko Carstens brasl %r14,cleanup_critical 964bfc86ceSHeiko Carstens tmhh %r8,0x0001 # retest problem state after cleanup 974bfc86ceSHeiko Carstens jnz 1f 982acb94f4SMartin Schwidefsky0: lg %r14,__LC_ASYNC_STACK # are we already on the async stack? 994bfc86ceSHeiko Carstens slgr %r14,%r15 1002acb94f4SMartin Schwidefsky srag %r14,%r14,STACK_SHIFT 101a359bb11SMartin Schwidefsky jnz 2f 1022acb94f4SMartin Schwidefsky CHECK_STACK 1<<STACK_SHIFT,\savearea 1034bfc86ceSHeiko Carstens aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 104a359bb11SMartin Schwidefsky j 3f 105a359bb11SMartin Schwidefsky1: LAST_BREAK %r14 106a359bb11SMartin Schwidefsky UPDATE_VTIME %r14,%r15,\timer 1072acb94f4SMartin Schwidefsky2: lg %r15,__LC_ASYNC_STACK # load async stack 108a359bb11SMartin Schwidefsky3: la %r11,STACK_FRAME_OVERHEAD(%r15) 1094bfc86ceSHeiko Carstens .endm 1104bfc86ceSHeiko Carstens 111a359bb11SMartin Schwidefsky .macro UPDATE_VTIME w1,w2,enter_timer 112a359bb11SMartin Schwidefsky lg \w1,__LC_EXIT_TIMER 113a359bb11SMartin Schwidefsky lg \w2,__LC_LAST_UPDATE_TIMER 114a359bb11SMartin Schwidefsky slg \w1,\enter_timer 115a359bb11SMartin Schwidefsky slg \w2,__LC_EXIT_TIMER 116a359bb11SMartin Schwidefsky alg \w1,__LC_USER_TIMER 117a359bb11SMartin Schwidefsky alg \w2,__LC_SYSTEM_TIMER 118a359bb11SMartin Schwidefsky stg \w1,__LC_USER_TIMER 119a359bb11SMartin Schwidefsky stg \w2,__LC_SYSTEM_TIMER 1204bfc86ceSHeiko Carstens mvc __LC_LAST_UPDATE_TIMER(8),\enter_timer 1214bfc86ceSHeiko Carstens .endm 1224bfc86ceSHeiko Carstens 1234bfc86ceSHeiko Carstens .macro LAST_BREAK scratch 1244bfc86ceSHeiko Carstens srag \scratch,%r10,23 1254bfc86ceSHeiko Carstens jz .+10 1264bfc86ceSHeiko Carstens stg %r10,__TI_last_break(%r12) 1274bfc86ceSHeiko Carstens .endm 1284bfc86ceSHeiko Carstens 1294bfc86ceSHeiko Carstens .macro REENABLE_IRQS 1304bfc86ceSHeiko Carstens stg %r8,__LC_RETURN_PSW 1314bfc86ceSHeiko Carstens ni __LC_RETURN_PSW,0xbf 1324bfc86ceSHeiko Carstens ssm __LC_RETURN_PSW 1334bfc86ceSHeiko Carstens .endm 1344bfc86ceSHeiko Carstens 1354bfc86ceSHeiko Carstens .macro STCK savearea 1364bfc86ceSHeiko Carstens#ifdef CONFIG_HAVE_MARCH_Z9_109_FEATURES 1374bfc86ceSHeiko Carstens .insn s,0xb27c0000,\savearea # store clock fast 1384bfc86ceSHeiko Carstens#else 1394bfc86ceSHeiko Carstens .insn s,0xb2050000,\savearea # store clock 1404bfc86ceSHeiko Carstens#endif 1414bfc86ceSHeiko Carstens .endm 1424bfc86ceSHeiko Carstens 14383abeffbSHendrik Brueckner /* 14483abeffbSHendrik Brueckner * The TSTMSK macro generates a test-under-mask instruction by 14583abeffbSHendrik Brueckner * calculating the memory offset for the specified mask value. 14683abeffbSHendrik Brueckner * Mask value can be any constant. The macro shifts the mask 14783abeffbSHendrik Brueckner * value to calculate the memory offset for the test-under-mask 14883abeffbSHendrik Brueckner * instruction. 14983abeffbSHendrik Brueckner */ 15083abeffbSHendrik Brueckner .macro TSTMSK addr, mask, size=8, bytepos=0 15183abeffbSHendrik Brueckner .if (\bytepos < \size) && (\mask >> 8) 15283abeffbSHendrik Brueckner .if (\mask & 0xff) 15383abeffbSHendrik Brueckner .error "Mask exceeds byte boundary" 15483abeffbSHendrik Brueckner .endif 15583abeffbSHendrik Brueckner TSTMSK \addr, "(\mask >> 8)", \size, "(\bytepos + 1)" 15683abeffbSHendrik Brueckner .exitm 15783abeffbSHendrik Brueckner .endif 15883abeffbSHendrik Brueckner .ifeq \mask 15983abeffbSHendrik Brueckner .error "Mask must not be zero" 16083abeffbSHendrik Brueckner .endif 16183abeffbSHendrik Brueckner off = \size - \bytepos - 1 16283abeffbSHendrik Brueckner tm off+\addr, \mask 16383abeffbSHendrik Brueckner .endm 16483abeffbSHendrik Brueckner 1654bfc86ceSHeiko Carstens .section .kprobes.text, "ax" 1664bfc86ceSHeiko Carstens 1674bfc86ceSHeiko Carstens/* 1684bfc86ceSHeiko Carstens * Scheduler resume function, called by switch_to 1694bfc86ceSHeiko Carstens * gpr2 = (task_struct *) prev 1704bfc86ceSHeiko Carstens * gpr3 = (task_struct *) next 1714bfc86ceSHeiko Carstens * Returns: 1724bfc86ceSHeiko Carstens * gpr2 = prev 1734bfc86ceSHeiko Carstens */ 1744bfc86ceSHeiko CarstensENTRY(__switch_to) 1754bfc86ceSHeiko Carstens stmg %r6,%r15,__SF_GPRS(%r15) # store gprs of prev task 1763827ec3dSMartin Schwidefsky lgr %r1,%r2 1773827ec3dSMartin Schwidefsky aghi %r1,__TASK_thread # thread_struct of prev task 1783827ec3dSMartin Schwidefsky lg %r4,__TASK_thread_info(%r2) # get thread_info of prev 1793827ec3dSMartin Schwidefsky lg %r5,__TASK_thread_info(%r3) # get thread_info of next 1803827ec3dSMartin Schwidefsky stg %r15,__THREAD_ksp(%r1) # store kernel stack of prev 1813827ec3dSMartin Schwidefsky lgr %r1,%r3 1823827ec3dSMartin Schwidefsky aghi %r1,__TASK_thread # thread_struct of next task 1834bfc86ceSHeiko Carstens lgr %r15,%r5 1844bfc86ceSHeiko Carstens aghi %r15,STACK_INIT # end of kernel stack of next 1854bfc86ceSHeiko Carstens stg %r3,__LC_CURRENT # store task struct of next 1864bfc86ceSHeiko Carstens stg %r5,__LC_THREAD_INFO # store thread info of next 1874bfc86ceSHeiko Carstens stg %r15,__LC_KERNEL_STACK # store end of kernel stack 1883827ec3dSMartin Schwidefsky lg %r15,__THREAD_ksp(%r1) # load kernel stack of next 1894bfc86ceSHeiko Carstens lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4 190e22cf8caSChristian Borntraeger mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next 1914bfc86ceSHeiko Carstens lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task 192e22cf8caSChristian Borntraeger TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP 193e22cf8caSChristian Borntraeger bzr %r14 194e22cf8caSChristian Borntraeger .insn s,0xb2800000,__LC_LPP # set program parameter 1954bfc86ceSHeiko Carstens br %r14 1964bfc86ceSHeiko Carstens 1974bfc86ceSHeiko Carstens.L__critical_start: 198d0fc4107SMartin Schwidefsky 199d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 200d0fc4107SMartin Schwidefsky/* 201d0fc4107SMartin Schwidefsky * sie64a calling convention: 202d0fc4107SMartin Schwidefsky * %r2 pointer to sie control block 203d0fc4107SMartin Schwidefsky * %r3 guest register save area 204d0fc4107SMartin Schwidefsky */ 205d0fc4107SMartin SchwidefskyENTRY(sie64a) 206d0fc4107SMartin Schwidefsky stmg %r6,%r14,__SF_GPRS(%r15) # save kernel registers 207d0fc4107SMartin Schwidefsky stg %r2,__SF_EMPTY(%r15) # save control block pointer 208d0fc4107SMartin Schwidefsky stg %r3,__SF_EMPTY+8(%r15) # save guest register save area 209e22cf8caSChristian Borntraeger xc __SF_EMPTY+16(8,%r15),__SF_EMPTY+16(%r15) # reason code = 0 21083abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU # load guest fp/vx registers ? 211d0fc4107SMartin Schwidefsky jno .Lsie_load_guest_gprs 212d0fc4107SMartin Schwidefsky brasl %r14,load_fpu_regs # load guest fp/vx regs 213d0fc4107SMartin Schwidefsky.Lsie_load_guest_gprs: 214d0fc4107SMartin Schwidefsky lmg %r0,%r13,0(%r3) # load guest gprs 0-13 215d0fc4107SMartin Schwidefsky lg %r14,__LC_GMAP # get gmap pointer 216d0fc4107SMartin Schwidefsky ltgr %r14,%r14 217d0fc4107SMartin Schwidefsky jz .Lsie_gmap 218d0fc4107SMartin Schwidefsky lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce 219d0fc4107SMartin Schwidefsky.Lsie_gmap: 220d0fc4107SMartin Schwidefsky lg %r14,__SF_EMPTY(%r15) # get control block pointer 221d0fc4107SMartin Schwidefsky oi __SIE_PROG0C+3(%r14),1 # we are going into SIE now 222d0fc4107SMartin Schwidefsky tm __SIE_PROG20+3(%r14),3 # last exit... 223d0fc4107SMartin Schwidefsky jnz .Lsie_skip 22483abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 225d0fc4107SMartin Schwidefsky jo .Lsie_skip # exit if fp/vx regs changed 226d0fc4107SMartin Schwidefsky sie 0(%r14) 227d0fc4107SMartin Schwidefsky.Lsie_skip: 228d0fc4107SMartin Schwidefsky ni __SIE_PROG0C+3(%r14),0xfe # no longer in SIE 229d0fc4107SMartin Schwidefsky lctlg %c1,%c1,__LC_USER_ASCE # load primary asce 230d0fc4107SMartin Schwidefsky.Lsie_done: 231d0fc4107SMartin Schwidefsky# some program checks are suppressing. C code (e.g. do_protection_exception) 232d0fc4107SMartin Schwidefsky# will rewind the PSW by the ILC, which is 4 bytes in case of SIE. Other 233d0fc4107SMartin Schwidefsky# instructions between sie64a and .Lsie_done should not cause program 234d0fc4107SMartin Schwidefsky# interrupts. So lets use a nop (47 00 00 00) as a landing pad. 235d0fc4107SMartin Schwidefsky# See also .Lcleanup_sie 236d0fc4107SMartin Schwidefsky.Lrewind_pad: 237d0fc4107SMartin Schwidefsky nop 0 238d0fc4107SMartin Schwidefsky .globl sie_exit 239d0fc4107SMartin Schwidefskysie_exit: 240d0fc4107SMartin Schwidefsky lg %r14,__SF_EMPTY+8(%r15) # load guest register save area 241d0fc4107SMartin Schwidefsky stmg %r0,%r13,0(%r14) # save guest gprs 0-13 242d0fc4107SMartin Schwidefsky lmg %r6,%r14,__SF_GPRS(%r15) # restore kernel registers 243e22cf8caSChristian Borntraeger lg %r2,__SF_EMPTY+16(%r15) # return exit reason code 244d0fc4107SMartin Schwidefsky br %r14 245d0fc4107SMartin Schwidefsky.Lsie_fault: 246d0fc4107SMartin Schwidefsky lghi %r14,-EFAULT 247e22cf8caSChristian Borntraeger stg %r14,__SF_EMPTY+16(%r15) # set exit reason code 248d0fc4107SMartin Schwidefsky j sie_exit 249d0fc4107SMartin Schwidefsky 250d0fc4107SMartin Schwidefsky EX_TABLE(.Lrewind_pad,.Lsie_fault) 251d0fc4107SMartin Schwidefsky EX_TABLE(sie_exit,.Lsie_fault) 252d0fc4107SMartin Schwidefsky#endif 253d0fc4107SMartin Schwidefsky 2544bfc86ceSHeiko Carstens/* 2554bfc86ceSHeiko Carstens * SVC interrupt handler routine. System calls are synchronous events and 2564bfc86ceSHeiko Carstens * are executed with interrupts enabled. 2574bfc86ceSHeiko Carstens */ 2584bfc86ceSHeiko Carstens 2594bfc86ceSHeiko CarstensENTRY(system_call) 2604bfc86ceSHeiko Carstens stpt __LC_SYNC_ENTER_TIMER 2614bfc86ceSHeiko Carstens.Lsysc_stmg: 2624bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_SYNC 2634bfc86ceSHeiko Carstens lg %r10,__LC_LAST_BREAK 2644bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 2654bfc86ceSHeiko Carstens lghi %r14,_PIF_SYSCALL 2664bfc86ceSHeiko Carstens.Lsysc_per: 2674bfc86ceSHeiko Carstens lg %r15,__LC_KERNEL_STACK 2684bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r15) # pointer to pt_regs 2694bfc86ceSHeiko Carstens LAST_BREAK %r13 270a359bb11SMartin Schwidefsky.Lsysc_vtime: 271a359bb11SMartin Schwidefsky UPDATE_VTIME %r10,%r13,__LC_SYNC_ENTER_TIMER 2724bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 2734bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC 2744bfc86ceSHeiko Carstens mvc __PT_PSW(16,%r11),__LC_SVC_OLD_PSW 2754bfc86ceSHeiko Carstens mvc __PT_INT_CODE(4,%r11),__LC_SVC_ILC 2764bfc86ceSHeiko Carstens stg %r14,__PT_FLAGS(%r11) 2774bfc86ceSHeiko Carstens.Lsysc_do_svc: 2784bfc86ceSHeiko Carstens lg %r10,__TI_sysc_table(%r12) # address of system call table 2794bfc86ceSHeiko Carstens llgh %r8,__PT_INT_CODE+2(%r11) 2804bfc86ceSHeiko Carstens slag %r8,%r8,2 # shift and test for svc 0 2814bfc86ceSHeiko Carstens jnz .Lsysc_nr_ok 2824bfc86ceSHeiko Carstens # svc 0: system call number in %r1 2834bfc86ceSHeiko Carstens llgfr %r1,%r1 # clear high word in r1 2844bfc86ceSHeiko Carstens cghi %r1,NR_syscalls 2854bfc86ceSHeiko Carstens jnl .Lsysc_nr_ok 2864bfc86ceSHeiko Carstens sth %r1,__PT_INT_CODE+2(%r11) 2874bfc86ceSHeiko Carstens slag %r8,%r1,2 2884bfc86ceSHeiko Carstens.Lsysc_nr_ok: 2894bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 2904bfc86ceSHeiko Carstens stg %r2,__PT_ORIG_GPR2(%r11) 2914bfc86ceSHeiko Carstens stg %r7,STACK_FRAME_OVERHEAD(%r15) 2924bfc86ceSHeiko Carstens lgf %r9,0(%r8,%r10) # get system call add. 29383abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_TRACE 2944bfc86ceSHeiko Carstens jnz .Lsysc_tracesys 2954bfc86ceSHeiko Carstens basr %r14,%r9 # call sys_xxxx 2964bfc86ceSHeiko Carstens stg %r2,__PT_R2(%r11) # store return value 2974bfc86ceSHeiko Carstens 2984bfc86ceSHeiko Carstens.Lsysc_return: 2994bfc86ceSHeiko Carstens LOCKDEP_SYS_EXIT 3004bfc86ceSHeiko Carstens.Lsysc_tif: 30183abeffbSHendrik Brueckner TSTMSK __PT_FLAGS(%r11),_PIF_WORK 3024bfc86ceSHeiko Carstens jnz .Lsysc_work 30383abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_WORK 3044bfc86ceSHeiko Carstens jnz .Lsysc_work # check for work 30583abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_WORK 3064bfc86ceSHeiko Carstens jnz .Lsysc_work 3074bfc86ceSHeiko Carstens.Lsysc_restore: 3084bfc86ceSHeiko Carstens lg %r14,__LC_VDSO_PER_CPU 3094bfc86ceSHeiko Carstens lmg %r0,%r10,__PT_R0(%r11) 3104bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) 3114bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 3124bfc86ceSHeiko Carstens mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER 3134bfc86ceSHeiko Carstens lmg %r11,%r15,__PT_R11(%r11) 3144bfc86ceSHeiko Carstens lpswe __LC_RETURN_PSW 3154bfc86ceSHeiko Carstens.Lsysc_done: 3164bfc86ceSHeiko Carstens 3174bfc86ceSHeiko Carstens# 3184bfc86ceSHeiko Carstens# One of the work bits is on. Find out which one. 3194bfc86ceSHeiko Carstens# 3204bfc86ceSHeiko Carstens.Lsysc_work: 32183abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING 3224bfc86ceSHeiko Carstens jo .Lsysc_mcck_pending 32383abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED 3244bfc86ceSHeiko Carstens jo .Lsysc_reschedule 3254bfc86ceSHeiko Carstens#ifdef CONFIG_UPROBES 32683abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_UPROBE 3274bfc86ceSHeiko Carstens jo .Lsysc_uprobe_notify 3284bfc86ceSHeiko Carstens#endif 32983abeffbSHendrik Brueckner TSTMSK __PT_FLAGS(%r11),_PIF_PER_TRAP 3304bfc86ceSHeiko Carstens jo .Lsysc_singlestep 33183abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_SIGPENDING 3324bfc86ceSHeiko Carstens jo .Lsysc_sigpending 33383abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME 3344bfc86ceSHeiko Carstens jo .Lsysc_notify_resume 33583abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 3369977e886SHendrik Brueckner jo .Lsysc_vxrs 33783abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_ASCE 3384bfc86ceSHeiko Carstens jo .Lsysc_uaccess 3394bfc86ceSHeiko Carstens j .Lsysc_return # beware of critical section cleanup 3404bfc86ceSHeiko Carstens 3414bfc86ceSHeiko Carstens# 3424bfc86ceSHeiko Carstens# _TIF_NEED_RESCHED is set, call schedule 3434bfc86ceSHeiko Carstens# 3444bfc86ceSHeiko Carstens.Lsysc_reschedule: 3454bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 3464bfc86ceSHeiko Carstens jg schedule 3474bfc86ceSHeiko Carstens 3484bfc86ceSHeiko Carstens# 3494bfc86ceSHeiko Carstens# _CIF_MCCK_PENDING is set, call handler 3504bfc86ceSHeiko Carstens# 3514bfc86ceSHeiko Carstens.Lsysc_mcck_pending: 3524bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 3534bfc86ceSHeiko Carstens jg s390_handle_mcck # TIF bit will be cleared by handler 3544bfc86ceSHeiko Carstens 3554bfc86ceSHeiko Carstens# 3564bfc86ceSHeiko Carstens# _CIF_ASCE is set, load user space asce 3574bfc86ceSHeiko Carstens# 3584bfc86ceSHeiko Carstens.Lsysc_uaccess: 3594bfc86ceSHeiko Carstens ni __LC_CPU_FLAGS+7,255-_CIF_ASCE 3604bfc86ceSHeiko Carstens lctlg %c1,%c1,__LC_USER_ASCE # load primary asce 3614bfc86ceSHeiko Carstens j .Lsysc_return 3624bfc86ceSHeiko Carstens 3634bfc86ceSHeiko Carstens# 3649977e886SHendrik Brueckner# CIF_FPU is set, restore floating-point controls and floating-point registers. 3659977e886SHendrik Brueckner# 3669977e886SHendrik Brueckner.Lsysc_vxrs: 3679977e886SHendrik Brueckner larl %r14,.Lsysc_return 3689977e886SHendrik Brueckner jg load_fpu_regs 3699977e886SHendrik Brueckner 3709977e886SHendrik Brueckner# 3714bfc86ceSHeiko Carstens# _TIF_SIGPENDING is set, call do_signal 3724bfc86ceSHeiko Carstens# 3734bfc86ceSHeiko Carstens.Lsysc_sigpending: 3744bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 3754bfc86ceSHeiko Carstens brasl %r14,do_signal 37683abeffbSHendrik Brueckner TSTMSK __PT_FLAGS(%r11),_PIF_SYSCALL 3774bfc86ceSHeiko Carstens jno .Lsysc_return 3784bfc86ceSHeiko Carstens lmg %r2,%r7,__PT_R2(%r11) # load svc arguments 3794bfc86ceSHeiko Carstens lg %r10,__TI_sysc_table(%r12) # address of system call table 3804bfc86ceSHeiko Carstens lghi %r8,0 # svc 0 returns -ENOSYS 3814bfc86ceSHeiko Carstens llgh %r1,__PT_INT_CODE+2(%r11) # load new svc number 3824bfc86ceSHeiko Carstens cghi %r1,NR_syscalls 3834bfc86ceSHeiko Carstens jnl .Lsysc_nr_ok # invalid svc number -> do svc 0 3844bfc86ceSHeiko Carstens slag %r8,%r1,2 3854bfc86ceSHeiko Carstens j .Lsysc_nr_ok # restart svc 3864bfc86ceSHeiko Carstens 3874bfc86ceSHeiko Carstens# 3884bfc86ceSHeiko Carstens# _TIF_NOTIFY_RESUME is set, call do_notify_resume 3894bfc86ceSHeiko Carstens# 3904bfc86ceSHeiko Carstens.Lsysc_notify_resume: 3914bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 3924bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 3934bfc86ceSHeiko Carstens jg do_notify_resume 3944bfc86ceSHeiko Carstens 3954bfc86ceSHeiko Carstens# 3964bfc86ceSHeiko Carstens# _TIF_UPROBE is set, call uprobe_notify_resume 3974bfc86ceSHeiko Carstens# 3984bfc86ceSHeiko Carstens#ifdef CONFIG_UPROBES 3994bfc86ceSHeiko Carstens.Lsysc_uprobe_notify: 4004bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 4014bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 4024bfc86ceSHeiko Carstens jg uprobe_notify_resume 4034bfc86ceSHeiko Carstens#endif 4044bfc86ceSHeiko Carstens 4054bfc86ceSHeiko Carstens# 4064bfc86ceSHeiko Carstens# _PIF_PER_TRAP is set, call do_per_trap 4074bfc86ceSHeiko Carstens# 4084bfc86ceSHeiko Carstens.Lsysc_singlestep: 4094bfc86ceSHeiko Carstens ni __PT_FLAGS+7(%r11),255-_PIF_PER_TRAP 4104bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 4114bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 4124bfc86ceSHeiko Carstens jg do_per_trap 4134bfc86ceSHeiko Carstens 4144bfc86ceSHeiko Carstens# 4154bfc86ceSHeiko Carstens# call tracehook_report_syscall_entry/tracehook_report_syscall_exit before 4164bfc86ceSHeiko Carstens# and after the system call 4174bfc86ceSHeiko Carstens# 4184bfc86ceSHeiko Carstens.Lsysc_tracesys: 4194bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 4204bfc86ceSHeiko Carstens la %r3,0 4214bfc86ceSHeiko Carstens llgh %r0,__PT_INT_CODE+2(%r11) 4224bfc86ceSHeiko Carstens stg %r0,__PT_R2(%r11) 4234bfc86ceSHeiko Carstens brasl %r14,do_syscall_trace_enter 4244bfc86ceSHeiko Carstens lghi %r0,NR_syscalls 4254bfc86ceSHeiko Carstens clgr %r0,%r2 4264bfc86ceSHeiko Carstens jnh .Lsysc_tracenogo 4274bfc86ceSHeiko Carstens sllg %r8,%r2,2 4284bfc86ceSHeiko Carstens lgf %r9,0(%r8,%r10) 4294bfc86ceSHeiko Carstens.Lsysc_tracego: 4304bfc86ceSHeiko Carstens lmg %r3,%r7,__PT_R3(%r11) 4314bfc86ceSHeiko Carstens stg %r7,STACK_FRAME_OVERHEAD(%r15) 4324bfc86ceSHeiko Carstens lg %r2,__PT_ORIG_GPR2(%r11) 4334bfc86ceSHeiko Carstens basr %r14,%r9 # call sys_xxx 4344bfc86ceSHeiko Carstens stg %r2,__PT_R2(%r11) # store return value 4354bfc86ceSHeiko Carstens.Lsysc_tracenogo: 43683abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_TRACE 4374bfc86ceSHeiko Carstens jz .Lsysc_return 4384bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 4394bfc86ceSHeiko Carstens larl %r14,.Lsysc_return 4404bfc86ceSHeiko Carstens jg do_syscall_trace_exit 4414bfc86ceSHeiko Carstens 4424bfc86ceSHeiko Carstens# 4434bfc86ceSHeiko Carstens# a new process exits the kernel with ret_from_fork 4444bfc86ceSHeiko Carstens# 4454bfc86ceSHeiko CarstensENTRY(ret_from_fork) 4464bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r15) 4474bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 4484bfc86ceSHeiko Carstens brasl %r14,schedule_tail 4494bfc86ceSHeiko Carstens TRACE_IRQS_ON 4504bfc86ceSHeiko Carstens ssm __LC_SVC_NEW_PSW # reenable interrupts 4514bfc86ceSHeiko Carstens tm __PT_PSW+1(%r11),0x01 # forking a kernel thread ? 4524bfc86ceSHeiko Carstens jne .Lsysc_tracenogo 4534bfc86ceSHeiko Carstens # it's a kernel thread 4544bfc86ceSHeiko Carstens lmg %r9,%r10,__PT_R9(%r11) # load gprs 4554bfc86ceSHeiko CarstensENTRY(kernel_thread_starter) 4564bfc86ceSHeiko Carstens la %r2,0(%r10) 4574bfc86ceSHeiko Carstens basr %r14,%r9 4584bfc86ceSHeiko Carstens j .Lsysc_tracenogo 4594bfc86ceSHeiko Carstens 4604bfc86ceSHeiko Carstens/* 4614bfc86ceSHeiko Carstens * Program check handler routine 4624bfc86ceSHeiko Carstens */ 4634bfc86ceSHeiko Carstens 4644bfc86ceSHeiko CarstensENTRY(pgm_check_handler) 4654bfc86ceSHeiko Carstens stpt __LC_SYNC_ENTER_TIMER 4664bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_SYNC 4674bfc86ceSHeiko Carstens lg %r10,__LC_LAST_BREAK 4684bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 4699977e886SHendrik Brueckner larl %r13,cleanup_critical 4704bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_PGM_OLD_PSW 4714bfc86ceSHeiko Carstens tmhh %r8,0x0001 # test problem state bit 472d0fc4107SMartin Schwidefsky jnz 2f # -> fault in user space 473d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 474d0fc4107SMartin Schwidefsky # cleanup critical section for sie64a 475d0fc4107SMartin Schwidefsky lgr %r14,%r9 476d0fc4107SMartin Schwidefsky slg %r14,BASED(.Lsie_critical_start) 477d0fc4107SMartin Schwidefsky clg %r14,BASED(.Lsie_critical_length) 478d0fc4107SMartin Schwidefsky jhe 0f 479d0fc4107SMartin Schwidefsky brasl %r14,.Lcleanup_sie 480d0fc4107SMartin Schwidefsky#endif 481d0fc4107SMartin Schwidefsky0: tmhh %r8,0x4000 # PER bit set in old PSW ? 482d0fc4107SMartin Schwidefsky jnz 1f # -> enabled, can't be a double fault 4834bfc86ceSHeiko Carstens tm __LC_PGM_ILC+3,0x80 # check for per exception 4844bfc86ceSHeiko Carstens jnz .Lpgm_svcper # -> single stepped svc 485d0fc4107SMartin Schwidefsky1: CHECK_STACK STACK_SIZE,__LC_SAVE_AREA_SYNC 4864bfc86ceSHeiko Carstens aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 487d0fc4107SMartin Schwidefsky j 3f 488a359bb11SMartin Schwidefsky2: LAST_BREAK %r14 489a359bb11SMartin Schwidefsky UPDATE_VTIME %r14,%r15,__LC_SYNC_ENTER_TIMER 4904bfc86ceSHeiko Carstens lg %r15,__LC_KERNEL_STACK 4914bfc86ceSHeiko Carstens lg %r14,__TI_task(%r12) 4923827ec3dSMartin Schwidefsky aghi %r14,__TASK_thread # pointer to thread_struct 4934bfc86ceSHeiko Carstens lghi %r13,__LC_PGM_TDB 4944bfc86ceSHeiko Carstens tm __LC_PGM_ILC+2,0x02 # check for transaction abort 495d0fc4107SMartin Schwidefsky jz 3f 4964bfc86ceSHeiko Carstens mvc __THREAD_trap_tdb(256,%r14),0(%r13) 497d0fc4107SMartin Schwidefsky3: la %r11,STACK_FRAME_OVERHEAD(%r15) 4984bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 4994bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),__LC_SAVE_AREA_SYNC 5004bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 5014bfc86ceSHeiko Carstens mvc __PT_INT_CODE(4,%r11),__LC_PGM_ILC 5024bfc86ceSHeiko Carstens mvc __PT_INT_PARM_LONG(8,%r11),__LC_TRANS_EXC_CODE 5034bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 5044bfc86ceSHeiko Carstens stg %r10,__PT_ARGS(%r11) 5054bfc86ceSHeiko Carstens tm __LC_PGM_ILC+3,0x80 # check for per exception 506d0fc4107SMartin Schwidefsky jz 4f 5074bfc86ceSHeiko Carstens tmhh %r8,0x0001 # kernel per event ? 5084bfc86ceSHeiko Carstens jz .Lpgm_kprobe 5094bfc86ceSHeiko Carstens oi __PT_FLAGS+7(%r11),_PIF_PER_TRAP 5104bfc86ceSHeiko Carstens mvc __THREAD_per_address(8,%r14),__LC_PER_ADDRESS 5114bfc86ceSHeiko Carstens mvc __THREAD_per_cause(2,%r14),__LC_PER_CODE 5124bfc86ceSHeiko Carstens mvc __THREAD_per_paid(1,%r14),__LC_PER_ACCESS_ID 513d0fc4107SMartin Schwidefsky4: REENABLE_IRQS 5144bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 5154bfc86ceSHeiko Carstens larl %r1,pgm_check_table 5164bfc86ceSHeiko Carstens llgh %r10,__PT_INT_CODE+2(%r11) 5174bfc86ceSHeiko Carstens nill %r10,0x007f 5184bfc86ceSHeiko Carstens sll %r10,2 519a359bb11SMartin Schwidefsky je .Lpgm_return 5204bfc86ceSHeiko Carstens lgf %r1,0(%r10,%r1) # load address of handler routine 5214bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 5224bfc86ceSHeiko Carstens basr %r14,%r1 # branch to interrupt-handler 523a359bb11SMartin Schwidefsky.Lpgm_return: 524a359bb11SMartin Schwidefsky LOCKDEP_SYS_EXIT 525a359bb11SMartin Schwidefsky tm __PT_PSW+1(%r11),0x01 # returning to user ? 526a359bb11SMartin Schwidefsky jno .Lsysc_restore 527a359bb11SMartin Schwidefsky j .Lsysc_tif 5284bfc86ceSHeiko Carstens 5294bfc86ceSHeiko Carstens# 5304bfc86ceSHeiko Carstens# PER event in supervisor state, must be kprobes 5314bfc86ceSHeiko Carstens# 5324bfc86ceSHeiko Carstens.Lpgm_kprobe: 5334bfc86ceSHeiko Carstens REENABLE_IRQS 5344bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 5354bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 5364bfc86ceSHeiko Carstens brasl %r14,do_per_trap 537a359bb11SMartin Schwidefsky j .Lpgm_return 5384bfc86ceSHeiko Carstens 5394bfc86ceSHeiko Carstens# 5404bfc86ceSHeiko Carstens# single stepped system call 5414bfc86ceSHeiko Carstens# 5424bfc86ceSHeiko Carstens.Lpgm_svcper: 5434bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(8),__LC_SVC_NEW_PSW 5444bfc86ceSHeiko Carstens larl %r14,.Lsysc_per 5454bfc86ceSHeiko Carstens stg %r14,__LC_RETURN_PSW+8 5464bfc86ceSHeiko Carstens lghi %r14,_PIF_SYSCALL | _PIF_PER_TRAP 5474bfc86ceSHeiko Carstens lpswe __LC_RETURN_PSW # branch to .Lsysc_per and enable irqs 5484bfc86ceSHeiko Carstens 5494bfc86ceSHeiko Carstens/* 5504bfc86ceSHeiko Carstens * IO interrupt handler routine 5514bfc86ceSHeiko Carstens */ 5524bfc86ceSHeiko CarstensENTRY(io_int_handler) 5534bfc86ceSHeiko Carstens STCK __LC_INT_CLOCK 5544bfc86ceSHeiko Carstens stpt __LC_ASYNC_ENTER_TIMER 5554bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_ASYNC 5564bfc86ceSHeiko Carstens lg %r10,__LC_LAST_BREAK 5574bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 5589977e886SHendrik Brueckner larl %r13,cleanup_critical 5594bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_IO_OLD_PSW 5602acb94f4SMartin Schwidefsky SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER 5614bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 5624bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC 5634bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 5644bfc86ceSHeiko Carstens mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID 5654bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 566db7e007fSHeiko Carstens TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ 567db7e007fSHeiko Carstens jo .Lio_restore 5684bfc86ceSHeiko Carstens TRACE_IRQS_OFF 5694bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 5704bfc86ceSHeiko Carstens.Lio_loop: 5714bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 5724bfc86ceSHeiko Carstens lghi %r3,IO_INTERRUPT 5734bfc86ceSHeiko Carstens tm __PT_INT_CODE+8(%r11),0x80 # adapter interrupt ? 5744bfc86ceSHeiko Carstens jz .Lio_call 5754bfc86ceSHeiko Carstens lghi %r3,THIN_INTERRUPT 5764bfc86ceSHeiko Carstens.Lio_call: 5774bfc86ceSHeiko Carstens brasl %r14,do_IRQ 57883abeffbSHendrik Brueckner TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPAR 5794bfc86ceSHeiko Carstens jz .Lio_return 5804bfc86ceSHeiko Carstens tpi 0 5814bfc86ceSHeiko Carstens jz .Lio_return 5824bfc86ceSHeiko Carstens mvc __PT_INT_CODE(12,%r11),__LC_SUBCHANNEL_ID 5834bfc86ceSHeiko Carstens j .Lio_loop 5844bfc86ceSHeiko Carstens.Lio_return: 5854bfc86ceSHeiko Carstens LOCKDEP_SYS_EXIT 5864bfc86ceSHeiko Carstens TRACE_IRQS_ON 5874bfc86ceSHeiko Carstens.Lio_tif: 58883abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_WORK 5894bfc86ceSHeiko Carstens jnz .Lio_work # there is work to do (signals etc.) 59083abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_WORK 5914bfc86ceSHeiko Carstens jnz .Lio_work 5924bfc86ceSHeiko Carstens.Lio_restore: 5934bfc86ceSHeiko Carstens lg %r14,__LC_VDSO_PER_CPU 5944bfc86ceSHeiko Carstens lmg %r0,%r10,__PT_R0(%r11) 5954bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) 5964bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 5974bfc86ceSHeiko Carstens mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER 5984bfc86ceSHeiko Carstens lmg %r11,%r15,__PT_R11(%r11) 5994bfc86ceSHeiko Carstens lpswe __LC_RETURN_PSW 6004bfc86ceSHeiko Carstens.Lio_done: 6014bfc86ceSHeiko Carstens 6024bfc86ceSHeiko Carstens# 6034bfc86ceSHeiko Carstens# There is work todo, find out in which context we have been interrupted: 6044bfc86ceSHeiko Carstens# 1) if we return to user space we can do all _TIF_WORK work 6054bfc86ceSHeiko Carstens# 2) if we return to kernel code and kvm is enabled check if we need to 6064bfc86ceSHeiko Carstens# modify the psw to leave SIE 6074bfc86ceSHeiko Carstens# 3) if we return to kernel code and preemptive scheduling is enabled check 6084bfc86ceSHeiko Carstens# the preemption counter and if it is zero call preempt_schedule_irq 6094bfc86ceSHeiko Carstens# Before any work can be done, a switch to the kernel stack is required. 6104bfc86ceSHeiko Carstens# 6114bfc86ceSHeiko Carstens.Lio_work: 6124bfc86ceSHeiko Carstens tm __PT_PSW+1(%r11),0x01 # returning to user ? 6134bfc86ceSHeiko Carstens jo .Lio_work_user # yes -> do resched & signal 6144bfc86ceSHeiko Carstens#ifdef CONFIG_PREEMPT 6154bfc86ceSHeiko Carstens # check for preemptive scheduling 6164bfc86ceSHeiko Carstens icm %r0,15,__TI_precount(%r12) 6174bfc86ceSHeiko Carstens jnz .Lio_restore # preemption is disabled 61883abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED 6194bfc86ceSHeiko Carstens jno .Lio_restore 6204bfc86ceSHeiko Carstens # switch to kernel stack 6214bfc86ceSHeiko Carstens lg %r1,__PT_R15(%r11) 6224bfc86ceSHeiko Carstens aghi %r1,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 6234bfc86ceSHeiko Carstens mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) 6244bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) 6254bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r1) 6264bfc86ceSHeiko Carstens lgr %r15,%r1 6274bfc86ceSHeiko Carstens # TRACE_IRQS_ON already done at .Lio_return, call 6284bfc86ceSHeiko Carstens # TRACE_IRQS_OFF to keep things symmetrical 6294bfc86ceSHeiko Carstens TRACE_IRQS_OFF 6304bfc86ceSHeiko Carstens brasl %r14,preempt_schedule_irq 6314bfc86ceSHeiko Carstens j .Lio_return 6324bfc86ceSHeiko Carstens#else 6334bfc86ceSHeiko Carstens j .Lio_restore 6344bfc86ceSHeiko Carstens#endif 6354bfc86ceSHeiko Carstens 6364bfc86ceSHeiko Carstens# 6374bfc86ceSHeiko Carstens# Need to do work before returning to userspace, switch to kernel stack 6384bfc86ceSHeiko Carstens# 6394bfc86ceSHeiko Carstens.Lio_work_user: 6404bfc86ceSHeiko Carstens lg %r1,__LC_KERNEL_STACK 6414bfc86ceSHeiko Carstens mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) 6424bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) 6434bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r1) 6444bfc86ceSHeiko Carstens lgr %r15,%r1 6454bfc86ceSHeiko Carstens 6464bfc86ceSHeiko Carstens# 6474bfc86ceSHeiko Carstens# One of the work bits is on. Find out which one. 6484bfc86ceSHeiko Carstens# 6494bfc86ceSHeiko Carstens.Lio_work_tif: 65083abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING 6514bfc86ceSHeiko Carstens jo .Lio_mcck_pending 65283abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_NEED_RESCHED 6534bfc86ceSHeiko Carstens jo .Lio_reschedule 65483abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_SIGPENDING 6554bfc86ceSHeiko Carstens jo .Lio_sigpending 65683abeffbSHendrik Brueckner TSTMSK __TI_flags(%r12),_TIF_NOTIFY_RESUME 6574bfc86ceSHeiko Carstens jo .Lio_notify_resume 65883abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 6599977e886SHendrik Brueckner jo .Lio_vxrs 66083abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_ASCE 6614bfc86ceSHeiko Carstens jo .Lio_uaccess 6624bfc86ceSHeiko Carstens j .Lio_return # beware of critical section cleanup 6634bfc86ceSHeiko Carstens 6644bfc86ceSHeiko Carstens# 6654bfc86ceSHeiko Carstens# _CIF_MCCK_PENDING is set, call handler 6664bfc86ceSHeiko Carstens# 6674bfc86ceSHeiko Carstens.Lio_mcck_pending: 6684bfc86ceSHeiko Carstens # TRACE_IRQS_ON already done at .Lio_return 6694bfc86ceSHeiko Carstens brasl %r14,s390_handle_mcck # TIF bit will be cleared by handler 6704bfc86ceSHeiko Carstens TRACE_IRQS_OFF 6714bfc86ceSHeiko Carstens j .Lio_return 6724bfc86ceSHeiko Carstens 6734bfc86ceSHeiko Carstens# 6744bfc86ceSHeiko Carstens# _CIF_ASCE is set, load user space asce 6754bfc86ceSHeiko Carstens# 6764bfc86ceSHeiko Carstens.Lio_uaccess: 6774bfc86ceSHeiko Carstens ni __LC_CPU_FLAGS+7,255-_CIF_ASCE 6784bfc86ceSHeiko Carstens lctlg %c1,%c1,__LC_USER_ASCE # load primary asce 6794bfc86ceSHeiko Carstens j .Lio_return 6804bfc86ceSHeiko Carstens 6814bfc86ceSHeiko Carstens# 6829977e886SHendrik Brueckner# CIF_FPU is set, restore floating-point controls and floating-point registers. 6839977e886SHendrik Brueckner# 6849977e886SHendrik Brueckner.Lio_vxrs: 6859977e886SHendrik Brueckner larl %r14,.Lio_return 6869977e886SHendrik Brueckner jg load_fpu_regs 6879977e886SHendrik Brueckner 6889977e886SHendrik Brueckner# 6894bfc86ceSHeiko Carstens# _TIF_NEED_RESCHED is set, call schedule 6904bfc86ceSHeiko Carstens# 6914bfc86ceSHeiko Carstens.Lio_reschedule: 6924bfc86ceSHeiko Carstens # TRACE_IRQS_ON already done at .Lio_return 6934bfc86ceSHeiko Carstens ssm __LC_SVC_NEW_PSW # reenable interrupts 6944bfc86ceSHeiko Carstens brasl %r14,schedule # call scheduler 6954bfc86ceSHeiko Carstens ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts 6964bfc86ceSHeiko Carstens TRACE_IRQS_OFF 6974bfc86ceSHeiko Carstens j .Lio_return 6984bfc86ceSHeiko Carstens 6994bfc86ceSHeiko Carstens# 7004bfc86ceSHeiko Carstens# _TIF_SIGPENDING or is set, call do_signal 7014bfc86ceSHeiko Carstens# 7024bfc86ceSHeiko Carstens.Lio_sigpending: 7034bfc86ceSHeiko Carstens # TRACE_IRQS_ON already done at .Lio_return 7044bfc86ceSHeiko Carstens ssm __LC_SVC_NEW_PSW # reenable interrupts 7054bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 7064bfc86ceSHeiko Carstens brasl %r14,do_signal 7074bfc86ceSHeiko Carstens ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts 7084bfc86ceSHeiko Carstens TRACE_IRQS_OFF 7094bfc86ceSHeiko Carstens j .Lio_return 7104bfc86ceSHeiko Carstens 7114bfc86ceSHeiko Carstens# 7124bfc86ceSHeiko Carstens# _TIF_NOTIFY_RESUME or is set, call do_notify_resume 7134bfc86ceSHeiko Carstens# 7144bfc86ceSHeiko Carstens.Lio_notify_resume: 7154bfc86ceSHeiko Carstens # TRACE_IRQS_ON already done at .Lio_return 7164bfc86ceSHeiko Carstens ssm __LC_SVC_NEW_PSW # reenable interrupts 7174bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 7184bfc86ceSHeiko Carstens brasl %r14,do_notify_resume 7194bfc86ceSHeiko Carstens ssm __LC_PGM_NEW_PSW # disable I/O and ext. interrupts 7204bfc86ceSHeiko Carstens TRACE_IRQS_OFF 7214bfc86ceSHeiko Carstens j .Lio_return 7224bfc86ceSHeiko Carstens 7234bfc86ceSHeiko Carstens/* 7244bfc86ceSHeiko Carstens * External interrupt handler routine 7254bfc86ceSHeiko Carstens */ 7264bfc86ceSHeiko CarstensENTRY(ext_int_handler) 7274bfc86ceSHeiko Carstens STCK __LC_INT_CLOCK 7284bfc86ceSHeiko Carstens stpt __LC_ASYNC_ENTER_TIMER 7294bfc86ceSHeiko Carstens stmg %r8,%r15,__LC_SAVE_AREA_ASYNC 7304bfc86ceSHeiko Carstens lg %r10,__LC_LAST_BREAK 7314bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 7329977e886SHendrik Brueckner larl %r13,cleanup_critical 7334bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_EXT_OLD_PSW 7342acb94f4SMartin Schwidefsky SWITCH_ASYNC __LC_SAVE_AREA_ASYNC,__LC_ASYNC_ENTER_TIMER 7354bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 7364bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),__LC_SAVE_AREA_ASYNC 7374bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 7384bfc86ceSHeiko Carstens lghi %r1,__LC_EXT_PARAMS2 7394bfc86ceSHeiko Carstens mvc __PT_INT_CODE(4,%r11),__LC_EXT_CPU_ADDR 7404bfc86ceSHeiko Carstens mvc __PT_INT_PARM(4,%r11),__LC_EXT_PARAMS 7414bfc86ceSHeiko Carstens mvc __PT_INT_PARM_LONG(8,%r11),0(%r1) 7424bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 743db7e007fSHeiko Carstens TSTMSK __LC_CPU_FLAGS,_CIF_IGNORE_IRQ 744db7e007fSHeiko Carstens jo .Lio_restore 7454bfc86ceSHeiko Carstens TRACE_IRQS_OFF 7464bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 7474bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 7484bfc86ceSHeiko Carstens lghi %r3,EXT_INTERRUPT 7494bfc86ceSHeiko Carstens brasl %r14,do_IRQ 7504bfc86ceSHeiko Carstens j .Lio_return 7514bfc86ceSHeiko Carstens 7524bfc86ceSHeiko Carstens/* 7534bfc86ceSHeiko Carstens * Load idle PSW. The second "half" of this function is in .Lcleanup_idle. 7544bfc86ceSHeiko Carstens */ 7554bfc86ceSHeiko CarstensENTRY(psw_idle) 7564bfc86ceSHeiko Carstens stg %r3,__SF_EMPTY(%r15) 7574bfc86ceSHeiko Carstens larl %r1,.Lpsw_idle_lpsw+4 7584bfc86ceSHeiko Carstens stg %r1,__SF_EMPTY+8(%r15) 75972d38b19SMartin Schwidefsky#ifdef CONFIG_SMP 76072d38b19SMartin Schwidefsky larl %r1,smp_cpu_mtid 76172d38b19SMartin Schwidefsky llgf %r1,0(%r1) 76272d38b19SMartin Schwidefsky ltgr %r1,%r1 76372d38b19SMartin Schwidefsky jz .Lpsw_idle_stcctm 76472d38b19SMartin Schwidefsky .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+16(%r15) 76572d38b19SMartin Schwidefsky.Lpsw_idle_stcctm: 76672d38b19SMartin Schwidefsky#endif 767*419123f9SMartin Schwidefsky oi __LC_CPU_FLAGS+7,_CIF_ENABLED_WAIT 7684bfc86ceSHeiko Carstens STCK __CLOCK_IDLE_ENTER(%r2) 7694bfc86ceSHeiko Carstens stpt __TIMER_IDLE_ENTER(%r2) 7704bfc86ceSHeiko Carstens.Lpsw_idle_lpsw: 7714bfc86ceSHeiko Carstens lpswe __SF_EMPTY(%r15) 7724bfc86ceSHeiko Carstens br %r14 7734bfc86ceSHeiko Carstens.Lpsw_idle_end: 7744bfc86ceSHeiko Carstens 775b5510d9bSHendrik Brueckner/* 776b5510d9bSHendrik Brueckner * Store floating-point controls and floating-point or vector register 777b5510d9bSHendrik Brueckner * depending whether the vector facility is available. A critical section 778b5510d9bSHendrik Brueckner * cleanup assures that the registers are stored even if interrupted for 779b5510d9bSHendrik Brueckner * some other work. The CIF_FPU flag is set to trigger a lazy restore 780b5510d9bSHendrik Brueckner * of the register contents at return from io or a system call. 7819977e886SHendrik Brueckner */ 7829977e886SHendrik BruecknerENTRY(save_fpu_regs) 783d0164ee2SHendrik Brueckner lg %r2,__LC_CURRENT 784d0164ee2SHendrik Brueckner aghi %r2,__TASK_thread 78583abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 7869977e886SHendrik Brueckner bor %r14 787d0164ee2SHendrik Brueckner stfpc __THREAD_FPU_fpc(%r2) 7889977e886SHendrik Brueckner.Lsave_fpu_regs_fpc_end: 789d0164ee2SHendrik Brueckner lg %r3,__THREAD_FPU_regs(%r2) 79083abeffbSHendrik Brueckner TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 7919977e886SHendrik Brueckner jz .Lsave_fpu_regs_fp # no -> store FP regs 7929977e886SHendrik Brueckner.Lsave_fpu_regs_vx_low: 7939977e886SHendrik Brueckner VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3) 7949977e886SHendrik Brueckner.Lsave_fpu_regs_vx_high: 7959977e886SHendrik Brueckner VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3) 7969977e886SHendrik Brueckner j .Lsave_fpu_regs_done # -> set CIF_FPU flag 7979977e886SHendrik Brueckner.Lsave_fpu_regs_fp: 7989977e886SHendrik Brueckner std 0,0(%r3) 7999977e886SHendrik Brueckner std 1,8(%r3) 8009977e886SHendrik Brueckner std 2,16(%r3) 8019977e886SHendrik Brueckner std 3,24(%r3) 8029977e886SHendrik Brueckner std 4,32(%r3) 8039977e886SHendrik Brueckner std 5,40(%r3) 8049977e886SHendrik Brueckner std 6,48(%r3) 8059977e886SHendrik Brueckner std 7,56(%r3) 8069977e886SHendrik Brueckner std 8,64(%r3) 8079977e886SHendrik Brueckner std 9,72(%r3) 8089977e886SHendrik Brueckner std 10,80(%r3) 8099977e886SHendrik Brueckner std 11,88(%r3) 8109977e886SHendrik Brueckner std 12,96(%r3) 8119977e886SHendrik Brueckner std 13,104(%r3) 8129977e886SHendrik Brueckner std 14,112(%r3) 8139977e886SHendrik Brueckner std 15,120(%r3) 8149977e886SHendrik Brueckner.Lsave_fpu_regs_done: 8159977e886SHendrik Brueckner oi __LC_CPU_FLAGS+7,_CIF_FPU 8169977e886SHendrik Brueckner br %r14 8179977e886SHendrik Brueckner.Lsave_fpu_regs_end: 8189977e886SHendrik Brueckner 819b5510d9bSHendrik Brueckner/* 820b5510d9bSHendrik Brueckner * Load floating-point controls and floating-point or vector registers. 821b5510d9bSHendrik Brueckner * A critical section cleanup assures that the register contents are 822b5510d9bSHendrik Brueckner * loaded even if interrupted for some other work. 8239977e886SHendrik Brueckner * 8249977e886SHendrik Brueckner * There are special calling conventions to fit into sysc and io return work: 8259977e886SHendrik Brueckner * %r15: <kernel stack> 8269977e886SHendrik Brueckner * The function requires: 827b5510d9bSHendrik Brueckner * %r4 8289977e886SHendrik Brueckner */ 8299977e886SHendrik Bruecknerload_fpu_regs: 830d0164ee2SHendrik Brueckner lg %r4,__LC_CURRENT 831d0164ee2SHendrik Brueckner aghi %r4,__TASK_thread 83283abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 8339977e886SHendrik Brueckner bnor %r14 834d0164ee2SHendrik Brueckner lfpc __THREAD_FPU_fpc(%r4) 83583abeffbSHendrik Brueckner TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 836d0164ee2SHendrik Brueckner lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area 837b5510d9bSHendrik Brueckner jz .Lload_fpu_regs_fp # -> no VX, load FP regs 8389977e886SHendrik Brueckner.Lload_fpu_regs_vx: 8399977e886SHendrik Brueckner VLM %v0,%v15,0,%r4 8409977e886SHendrik Brueckner.Lload_fpu_regs_vx_high: 8419977e886SHendrik Brueckner VLM %v16,%v31,256,%r4 8429977e886SHendrik Brueckner j .Lload_fpu_regs_done 8439977e886SHendrik Brueckner.Lload_fpu_regs_fp: 8449977e886SHendrik Brueckner ld 0,0(%r4) 8459977e886SHendrik Brueckner ld 1,8(%r4) 8469977e886SHendrik Brueckner ld 2,16(%r4) 8479977e886SHendrik Brueckner ld 3,24(%r4) 8489977e886SHendrik Brueckner ld 4,32(%r4) 8499977e886SHendrik Brueckner ld 5,40(%r4) 8509977e886SHendrik Brueckner ld 6,48(%r4) 8519977e886SHendrik Brueckner ld 7,56(%r4) 8529977e886SHendrik Brueckner ld 8,64(%r4) 8539977e886SHendrik Brueckner ld 9,72(%r4) 8549977e886SHendrik Brueckner ld 10,80(%r4) 8559977e886SHendrik Brueckner ld 11,88(%r4) 8569977e886SHendrik Brueckner ld 12,96(%r4) 8579977e886SHendrik Brueckner ld 13,104(%r4) 8589977e886SHendrik Brueckner ld 14,112(%r4) 8599977e886SHendrik Brueckner ld 15,120(%r4) 8609977e886SHendrik Brueckner.Lload_fpu_regs_done: 8619977e886SHendrik Brueckner ni __LC_CPU_FLAGS+7,255-_CIF_FPU 8629977e886SHendrik Brueckner br %r14 8639977e886SHendrik Brueckner.Lload_fpu_regs_end: 8649977e886SHendrik Brueckner 8654bfc86ceSHeiko Carstens.L__critical_end: 8664bfc86ceSHeiko Carstens 8674bfc86ceSHeiko Carstens/* 8684bfc86ceSHeiko Carstens * Machine check handler routines 8694bfc86ceSHeiko Carstens */ 8704bfc86ceSHeiko CarstensENTRY(mcck_int_handler) 8714bfc86ceSHeiko Carstens STCK __LC_MCCK_CLOCK 8724bfc86ceSHeiko Carstens la %r1,4095 # revalidate r1 8734bfc86ceSHeiko Carstens spt __LC_CPU_TIMER_SAVE_AREA-4095(%r1) # revalidate cpu timer 8744bfc86ceSHeiko Carstens lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)# revalidate gprs 8754bfc86ceSHeiko Carstens lg %r10,__LC_LAST_BREAK 8764bfc86ceSHeiko Carstens lg %r12,__LC_THREAD_INFO 8779977e886SHendrik Brueckner larl %r13,cleanup_critical 8784bfc86ceSHeiko Carstens lmg %r8,%r9,__LC_MCK_OLD_PSW 87983abeffbSHendrik Brueckner TSTMSK __LC_MCCK_CODE,MCCK_CODE_SYSTEM_DAMAGE 8804bfc86ceSHeiko Carstens jo .Lmcck_panic # yes -> rest of mcck code invalid 8814bfc86ceSHeiko Carstens lghi %r14,__LC_CPU_TIMER_SAVE_AREA 8824bfc86ceSHeiko Carstens mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) 88383abeffbSHendrik Brueckner TSTMSK __LC_MCCK_CODE,MCCK_CODE_CPU_TIMER_VALID 8844bfc86ceSHeiko Carstens jo 3f 8854bfc86ceSHeiko Carstens la %r14,__LC_SYNC_ENTER_TIMER 8864bfc86ceSHeiko Carstens clc 0(8,%r14),__LC_ASYNC_ENTER_TIMER 8874bfc86ceSHeiko Carstens jl 0f 8884bfc86ceSHeiko Carstens la %r14,__LC_ASYNC_ENTER_TIMER 8894bfc86ceSHeiko Carstens0: clc 0(8,%r14),__LC_EXIT_TIMER 8904bfc86ceSHeiko Carstens jl 1f 8914bfc86ceSHeiko Carstens la %r14,__LC_EXIT_TIMER 8924bfc86ceSHeiko Carstens1: clc 0(8,%r14),__LC_LAST_UPDATE_TIMER 8934bfc86ceSHeiko Carstens jl 2f 8944bfc86ceSHeiko Carstens la %r14,__LC_LAST_UPDATE_TIMER 8954bfc86ceSHeiko Carstens2: spt 0(%r14) 8964bfc86ceSHeiko Carstens mvc __LC_MCCK_ENTER_TIMER(8),0(%r14) 89783abeffbSHendrik Brueckner3: TSTMSK __LC_MCCK_CODE,(MCCK_CODE_PSW_MWP_VALID|MCCK_CODE_PSW_IA_VALID) 8984bfc86ceSHeiko Carstens jno .Lmcck_panic # no -> skip cleanup critical 8992acb94f4SMartin Schwidefsky SWITCH_ASYNC __LC_GPREGS_SAVE_AREA+64,__LC_MCCK_ENTER_TIMER 9004bfc86ceSHeiko Carstens.Lmcck_skip: 9014bfc86ceSHeiko Carstens lghi %r14,__LC_GPREGS_SAVE_AREA+64 9024bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 9034bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),0(%r14) 9044bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 9054bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r11),__PT_FLAGS(%r11) 9064bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 9074bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 9084bfc86ceSHeiko Carstens brasl %r14,s390_do_machine_check 9094bfc86ceSHeiko Carstens tm __PT_PSW+1(%r11),0x01 # returning to user ? 9104bfc86ceSHeiko Carstens jno .Lmcck_return 9114bfc86ceSHeiko Carstens lg %r1,__LC_KERNEL_STACK # switch to kernel stack 9124bfc86ceSHeiko Carstens mvc STACK_FRAME_OVERHEAD(__PT_SIZE,%r1),0(%r11) 9134bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r1),__SF_BACKCHAIN(%r1) 9144bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r1) 9154bfc86ceSHeiko Carstens lgr %r15,%r1 9164bfc86ceSHeiko Carstens ssm __LC_PGM_NEW_PSW # turn dat on, keep irqs off 91783abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_MCCK_PENDING 9184bfc86ceSHeiko Carstens jno .Lmcck_return 9194bfc86ceSHeiko Carstens TRACE_IRQS_OFF 9204bfc86ceSHeiko Carstens brasl %r14,s390_handle_mcck 9214bfc86ceSHeiko Carstens TRACE_IRQS_ON 9224bfc86ceSHeiko Carstens.Lmcck_return: 9234bfc86ceSHeiko Carstens lg %r14,__LC_VDSO_PER_CPU 9244bfc86ceSHeiko Carstens lmg %r0,%r10,__PT_R0(%r11) 9254bfc86ceSHeiko Carstens mvc __LC_RETURN_MCCK_PSW(16),__PT_PSW(%r11) # move return PSW 9264bfc86ceSHeiko Carstens tm __LC_RETURN_MCCK_PSW+1,0x01 # returning to user ? 9274bfc86ceSHeiko Carstens jno 0f 9284bfc86ceSHeiko Carstens stpt __LC_EXIT_TIMER 9294bfc86ceSHeiko Carstens mvc __VDSO_ECTG_BASE(16,%r14),__LC_EXIT_TIMER 9304bfc86ceSHeiko Carstens0: lmg %r11,%r15,__PT_R11(%r11) 9314bfc86ceSHeiko Carstens lpswe __LC_RETURN_MCCK_PSW 9324bfc86ceSHeiko Carstens 9334bfc86ceSHeiko Carstens.Lmcck_panic: 9344bfc86ceSHeiko Carstens lg %r15,__LC_PANIC_STACK 9352acb94f4SMartin Schwidefsky aghi %r15,-(STACK_FRAME_OVERHEAD + __PT_SIZE) 9364bfc86ceSHeiko Carstens j .Lmcck_skip 9374bfc86ceSHeiko Carstens 9384bfc86ceSHeiko Carstens# 9394bfc86ceSHeiko Carstens# PSW restart interrupt handler 9404bfc86ceSHeiko Carstens# 9414bfc86ceSHeiko CarstensENTRY(restart_int_handler) 942e22cf8caSChristian Borntraeger TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_LPP 943e22cf8caSChristian Borntraeger jz 0f 944e22cf8caSChristian Borntraeger .insn s,0xb2800000,__LC_LPP 945e22cf8caSChristian Borntraeger0: stg %r15,__LC_SAVE_AREA_RESTART 9464bfc86ceSHeiko Carstens lg %r15,__LC_RESTART_STACK 9474bfc86ceSHeiko Carstens aghi %r15,-__PT_SIZE # create pt_regs on stack 9484bfc86ceSHeiko Carstens xc 0(__PT_SIZE,%r15),0(%r15) 9494bfc86ceSHeiko Carstens stmg %r0,%r14,__PT_R0(%r15) 9504bfc86ceSHeiko Carstens mvc __PT_R15(8,%r15),__LC_SAVE_AREA_RESTART 9514bfc86ceSHeiko Carstens mvc __PT_PSW(16,%r15),__LC_RST_OLD_PSW # store restart old psw 9524bfc86ceSHeiko Carstens aghi %r15,-STACK_FRAME_OVERHEAD # create stack frame on stack 9534bfc86ceSHeiko Carstens xc 0(STACK_FRAME_OVERHEAD,%r15),0(%r15) 9544bfc86ceSHeiko Carstens lg %r1,__LC_RESTART_FN # load fn, parm & source cpu 9554bfc86ceSHeiko Carstens lg %r2,__LC_RESTART_DATA 9564bfc86ceSHeiko Carstens lg %r3,__LC_RESTART_SOURCE 9574bfc86ceSHeiko Carstens ltgr %r3,%r3 # test source cpu address 9584bfc86ceSHeiko Carstens jm 1f # negative -> skip source stop 9594bfc86ceSHeiko Carstens0: sigp %r4,%r3,SIGP_SENSE # sigp sense to source cpu 9604bfc86ceSHeiko Carstens brc 10,0b # wait for status stored 9614bfc86ceSHeiko Carstens1: basr %r14,%r1 # call function 9624bfc86ceSHeiko Carstens stap __SF_EMPTY(%r15) # store cpu address 9634bfc86ceSHeiko Carstens llgh %r3,__SF_EMPTY(%r15) 9644bfc86ceSHeiko Carstens2: sigp %r4,%r3,SIGP_STOP # sigp stop to current cpu 9654bfc86ceSHeiko Carstens brc 2,2b 9664bfc86ceSHeiko Carstens3: j 3b 9674bfc86ceSHeiko Carstens 9684bfc86ceSHeiko Carstens .section .kprobes.text, "ax" 9694bfc86ceSHeiko Carstens 9704bfc86ceSHeiko Carstens#ifdef CONFIG_CHECK_STACK 9714bfc86ceSHeiko Carstens/* 9724bfc86ceSHeiko Carstens * The synchronous or the asynchronous stack overflowed. We are dead. 9734bfc86ceSHeiko Carstens * No need to properly save the registers, we are going to panic anyway. 9744bfc86ceSHeiko Carstens * Setup a pt_regs so that show_trace can provide a good call trace. 9754bfc86ceSHeiko Carstens */ 9764bfc86ceSHeiko Carstensstack_overflow: 9774bfc86ceSHeiko Carstens lg %r15,__LC_PANIC_STACK # change to panic stack 9784bfc86ceSHeiko Carstens la %r11,STACK_FRAME_OVERHEAD(%r15) 9794bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r11) 9804bfc86ceSHeiko Carstens stmg %r8,%r9,__PT_PSW(%r11) 9814bfc86ceSHeiko Carstens mvc __PT_R8(64,%r11),0(%r14) 9824bfc86ceSHeiko Carstens stg %r10,__PT_ORIG_GPR2(%r11) # store last break to orig_gpr2 9834bfc86ceSHeiko Carstens xc __SF_BACKCHAIN(8,%r15),__SF_BACKCHAIN(%r15) 9844bfc86ceSHeiko Carstens lgr %r2,%r11 # pass pointer to pt_regs 9854bfc86ceSHeiko Carstens jg kernel_stack_overflow 9864bfc86ceSHeiko Carstens#endif 9874bfc86ceSHeiko Carstens 9884bfc86ceSHeiko Carstenscleanup_critical: 989d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 990d0fc4107SMartin Schwidefsky clg %r9,BASED(.Lcleanup_table_sie) # .Lsie_gmap 991d0fc4107SMartin Schwidefsky jl 0f 992d0fc4107SMartin Schwidefsky clg %r9,BASED(.Lcleanup_table_sie+8)# .Lsie_done 993d0fc4107SMartin Schwidefsky jl .Lcleanup_sie 994d0fc4107SMartin Schwidefsky#endif 9954bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table) # system_call 9964bfc86ceSHeiko Carstens jl 0f 9974bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+8) # .Lsysc_do_svc 9984bfc86ceSHeiko Carstens jl .Lcleanup_system_call 9994bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+16) # .Lsysc_tif 10004bfc86ceSHeiko Carstens jl 0f 10014bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+24) # .Lsysc_restore 10024bfc86ceSHeiko Carstens jl .Lcleanup_sysc_tif 10034bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+32) # .Lsysc_done 10044bfc86ceSHeiko Carstens jl .Lcleanup_sysc_restore 10054bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+40) # .Lio_tif 10064bfc86ceSHeiko Carstens jl 0f 10074bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+48) # .Lio_restore 10084bfc86ceSHeiko Carstens jl .Lcleanup_io_tif 10094bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+56) # .Lio_done 10104bfc86ceSHeiko Carstens jl .Lcleanup_io_restore 10114bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+64) # psw_idle 10124bfc86ceSHeiko Carstens jl 0f 10134bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_table+72) # .Lpsw_idle_end 10144bfc86ceSHeiko Carstens jl .Lcleanup_idle 10159977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_table+80) # save_fpu_regs 10169977e886SHendrik Brueckner jl 0f 10179977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_table+88) # .Lsave_fpu_regs_end 10189977e886SHendrik Brueckner jl .Lcleanup_save_fpu_regs 10199977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_table+96) # load_fpu_regs 10209977e886SHendrik Brueckner jl 0f 10219977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_table+104) # .Lload_fpu_regs_end 10229977e886SHendrik Brueckner jl .Lcleanup_load_fpu_regs 10234bfc86ceSHeiko Carstens0: br %r14 10244bfc86ceSHeiko Carstens 1025d0fc4107SMartin Schwidefsky .align 8 1026d0fc4107SMartin Schwidefsky.Lcleanup_table: 1027d0fc4107SMartin Schwidefsky .quad system_call 1028d0fc4107SMartin Schwidefsky .quad .Lsysc_do_svc 1029d0fc4107SMartin Schwidefsky .quad .Lsysc_tif 1030d0fc4107SMartin Schwidefsky .quad .Lsysc_restore 1031d0fc4107SMartin Schwidefsky .quad .Lsysc_done 1032d0fc4107SMartin Schwidefsky .quad .Lio_tif 1033d0fc4107SMartin Schwidefsky .quad .Lio_restore 1034d0fc4107SMartin Schwidefsky .quad .Lio_done 1035d0fc4107SMartin Schwidefsky .quad psw_idle 1036d0fc4107SMartin Schwidefsky .quad .Lpsw_idle_end 1037d0fc4107SMartin Schwidefsky .quad save_fpu_regs 1038d0fc4107SMartin Schwidefsky .quad .Lsave_fpu_regs_end 1039d0fc4107SMartin Schwidefsky .quad load_fpu_regs 1040d0fc4107SMartin Schwidefsky .quad .Lload_fpu_regs_end 1041d0fc4107SMartin Schwidefsky 1042d0fc4107SMartin Schwidefsky#if IS_ENABLED(CONFIG_KVM) 1043d0fc4107SMartin Schwidefsky.Lcleanup_table_sie: 1044d0fc4107SMartin Schwidefsky .quad .Lsie_gmap 1045d0fc4107SMartin Schwidefsky .quad .Lsie_done 1046d0fc4107SMartin Schwidefsky 1047d0fc4107SMartin Schwidefsky.Lcleanup_sie: 1048d0fc4107SMartin Schwidefsky lg %r9,__SF_EMPTY(%r15) # get control block pointer 1049e22cf8caSChristian Borntraeger ni __SIE_PROG0C+3(%r9),0xfe # no longer in SIE 1050d0fc4107SMartin Schwidefsky lctlg %c1,%c1,__LC_USER_ASCE # load primary asce 1051d0fc4107SMartin Schwidefsky larl %r9,sie_exit # skip forward to sie_exit 1052d0fc4107SMartin Schwidefsky br %r14 1053d0fc4107SMartin Schwidefsky#endif 10544bfc86ceSHeiko Carstens 10554bfc86ceSHeiko Carstens.Lcleanup_system_call: 10564bfc86ceSHeiko Carstens # check if stpt has been executed 10574bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_system_call_insn) 10584bfc86ceSHeiko Carstens jh 0f 10594bfc86ceSHeiko Carstens mvc __LC_SYNC_ENTER_TIMER(8),__LC_ASYNC_ENTER_TIMER 10604bfc86ceSHeiko Carstens cghi %r11,__LC_SAVE_AREA_ASYNC 10614bfc86ceSHeiko Carstens je 0f 10624bfc86ceSHeiko Carstens mvc __LC_SYNC_ENTER_TIMER(8),__LC_MCCK_ENTER_TIMER 10634bfc86ceSHeiko Carstens0: # check if stmg has been executed 10644bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_system_call_insn+8) 10654bfc86ceSHeiko Carstens jh 0f 10664bfc86ceSHeiko Carstens mvc __LC_SAVE_AREA_SYNC(64),0(%r11) 10674bfc86ceSHeiko Carstens0: # check if base register setup + TIF bit load has been done 10684bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_system_call_insn+16) 10694bfc86ceSHeiko Carstens jhe 0f 10704bfc86ceSHeiko Carstens # set up saved registers r10 and r12 10714bfc86ceSHeiko Carstens stg %r10,16(%r11) # r10 last break 10724bfc86ceSHeiko Carstens stg %r12,32(%r11) # r12 thread-info pointer 10734bfc86ceSHeiko Carstens0: # check if the user time update has been done 10744bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_system_call_insn+24) 10754bfc86ceSHeiko Carstens jh 0f 10764bfc86ceSHeiko Carstens lg %r15,__LC_EXIT_TIMER 10774bfc86ceSHeiko Carstens slg %r15,__LC_SYNC_ENTER_TIMER 10784bfc86ceSHeiko Carstens alg %r15,__LC_USER_TIMER 10794bfc86ceSHeiko Carstens stg %r15,__LC_USER_TIMER 10804bfc86ceSHeiko Carstens0: # check if the system time update has been done 10814bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_system_call_insn+32) 10824bfc86ceSHeiko Carstens jh 0f 10834bfc86ceSHeiko Carstens lg %r15,__LC_LAST_UPDATE_TIMER 10844bfc86ceSHeiko Carstens slg %r15,__LC_EXIT_TIMER 10854bfc86ceSHeiko Carstens alg %r15,__LC_SYSTEM_TIMER 10864bfc86ceSHeiko Carstens stg %r15,__LC_SYSTEM_TIMER 10874bfc86ceSHeiko Carstens0: # update accounting time stamp 10884bfc86ceSHeiko Carstens mvc __LC_LAST_UPDATE_TIMER(8),__LC_SYNC_ENTER_TIMER 10894bfc86ceSHeiko Carstens # do LAST_BREAK 10904bfc86ceSHeiko Carstens lg %r9,16(%r11) 10914bfc86ceSHeiko Carstens srag %r9,%r9,23 10924bfc86ceSHeiko Carstens jz 0f 10934bfc86ceSHeiko Carstens mvc __TI_last_break(8,%r12),16(%r11) 10944bfc86ceSHeiko Carstens0: # set up saved register r11 10954bfc86ceSHeiko Carstens lg %r15,__LC_KERNEL_STACK 10964bfc86ceSHeiko Carstens la %r9,STACK_FRAME_OVERHEAD(%r15) 10974bfc86ceSHeiko Carstens stg %r9,24(%r11) # r11 pt_regs pointer 10984bfc86ceSHeiko Carstens # fill pt_regs 10994bfc86ceSHeiko Carstens mvc __PT_R8(64,%r9),__LC_SAVE_AREA_SYNC 11004bfc86ceSHeiko Carstens stmg %r0,%r7,__PT_R0(%r9) 11014bfc86ceSHeiko Carstens mvc __PT_PSW(16,%r9),__LC_SVC_OLD_PSW 11024bfc86ceSHeiko Carstens mvc __PT_INT_CODE(4,%r9),__LC_SVC_ILC 11034bfc86ceSHeiko Carstens xc __PT_FLAGS(8,%r9),__PT_FLAGS(%r9) 11044bfc86ceSHeiko Carstens mvi __PT_FLAGS+7(%r9),_PIF_SYSCALL 11054bfc86ceSHeiko Carstens # setup saved register r15 11064bfc86ceSHeiko Carstens stg %r15,56(%r11) # r15 stack pointer 11074bfc86ceSHeiko Carstens # set new psw address and exit 11084bfc86ceSHeiko Carstens larl %r9,.Lsysc_do_svc 11094bfc86ceSHeiko Carstens br %r14 11104bfc86ceSHeiko Carstens.Lcleanup_system_call_insn: 11114bfc86ceSHeiko Carstens .quad system_call 11124bfc86ceSHeiko Carstens .quad .Lsysc_stmg 11134bfc86ceSHeiko Carstens .quad .Lsysc_per 1114a359bb11SMartin Schwidefsky .quad .Lsysc_vtime+36 11154bfc86ceSHeiko Carstens .quad .Lsysc_vtime+42 11164bfc86ceSHeiko Carstens 11174bfc86ceSHeiko Carstens.Lcleanup_sysc_tif: 11184bfc86ceSHeiko Carstens larl %r9,.Lsysc_tif 11194bfc86ceSHeiko Carstens br %r14 11204bfc86ceSHeiko Carstens 11214bfc86ceSHeiko Carstens.Lcleanup_sysc_restore: 11224bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_sysc_restore_insn) 11234bfc86ceSHeiko Carstens je 0f 11244bfc86ceSHeiko Carstens lg %r9,24(%r11) # get saved pointer to pt_regs 11254bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(16),__PT_PSW(%r9) 11264bfc86ceSHeiko Carstens mvc 0(64,%r11),__PT_R8(%r9) 11274bfc86ceSHeiko Carstens lmg %r0,%r7,__PT_R0(%r9) 11284bfc86ceSHeiko Carstens0: lmg %r8,%r9,__LC_RETURN_PSW 11294bfc86ceSHeiko Carstens br %r14 11304bfc86ceSHeiko Carstens.Lcleanup_sysc_restore_insn: 11314bfc86ceSHeiko Carstens .quad .Lsysc_done - 4 11324bfc86ceSHeiko Carstens 11334bfc86ceSHeiko Carstens.Lcleanup_io_tif: 11344bfc86ceSHeiko Carstens larl %r9,.Lio_tif 11354bfc86ceSHeiko Carstens br %r14 11364bfc86ceSHeiko Carstens 11374bfc86ceSHeiko Carstens.Lcleanup_io_restore: 11384bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_io_restore_insn) 11394bfc86ceSHeiko Carstens je 0f 11404bfc86ceSHeiko Carstens lg %r9,24(%r11) # get saved r11 pointer to pt_regs 11414bfc86ceSHeiko Carstens mvc __LC_RETURN_PSW(16),__PT_PSW(%r9) 11424bfc86ceSHeiko Carstens mvc 0(64,%r11),__PT_R8(%r9) 11434bfc86ceSHeiko Carstens lmg %r0,%r7,__PT_R0(%r9) 11444bfc86ceSHeiko Carstens0: lmg %r8,%r9,__LC_RETURN_PSW 11454bfc86ceSHeiko Carstens br %r14 11464bfc86ceSHeiko Carstens.Lcleanup_io_restore_insn: 11474bfc86ceSHeiko Carstens .quad .Lio_done - 4 11484bfc86ceSHeiko Carstens 11494bfc86ceSHeiko Carstens.Lcleanup_idle: 1150*419123f9SMartin Schwidefsky ni __LC_CPU_FLAGS+7,255-_CIF_ENABLED_WAIT 11514bfc86ceSHeiko Carstens # copy interrupt clock & cpu timer 11524bfc86ceSHeiko Carstens mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_INT_CLOCK 11534bfc86ceSHeiko Carstens mvc __TIMER_IDLE_EXIT(8,%r2),__LC_ASYNC_ENTER_TIMER 11544bfc86ceSHeiko Carstens cghi %r11,__LC_SAVE_AREA_ASYNC 11554bfc86ceSHeiko Carstens je 0f 11564bfc86ceSHeiko Carstens mvc __CLOCK_IDLE_EXIT(8,%r2),__LC_MCCK_CLOCK 11574bfc86ceSHeiko Carstens mvc __TIMER_IDLE_EXIT(8,%r2),__LC_MCCK_ENTER_TIMER 11584bfc86ceSHeiko Carstens0: # check if stck & stpt have been executed 11594bfc86ceSHeiko Carstens clg %r9,BASED(.Lcleanup_idle_insn) 11604bfc86ceSHeiko Carstens jhe 1f 11614bfc86ceSHeiko Carstens mvc __CLOCK_IDLE_ENTER(8,%r2),__CLOCK_IDLE_EXIT(%r2) 11624bfc86ceSHeiko Carstens mvc __TIMER_IDLE_ENTER(8,%r2),__TIMER_IDLE_EXIT(%r2) 116372d38b19SMartin Schwidefsky1: # calculate idle cycles 116472d38b19SMartin Schwidefsky#ifdef CONFIG_SMP 116572d38b19SMartin Schwidefsky clg %r9,BASED(.Lcleanup_idle_insn) 116672d38b19SMartin Schwidefsky jl 3f 116772d38b19SMartin Schwidefsky larl %r1,smp_cpu_mtid 116872d38b19SMartin Schwidefsky llgf %r1,0(%r1) 116972d38b19SMartin Schwidefsky ltgr %r1,%r1 117072d38b19SMartin Schwidefsky jz 3f 117172d38b19SMartin Schwidefsky .insn rsy,0xeb0000000017,%r1,5,__SF_EMPTY+80(%r15) 117272d38b19SMartin Schwidefsky larl %r3,mt_cycles 117372d38b19SMartin Schwidefsky ag %r3,__LC_PERCPU_OFFSET 117472d38b19SMartin Schwidefsky la %r4,__SF_EMPTY+16(%r15) 117572d38b19SMartin Schwidefsky2: lg %r0,0(%r3) 117672d38b19SMartin Schwidefsky slg %r0,0(%r4) 117772d38b19SMartin Schwidefsky alg %r0,64(%r4) 117872d38b19SMartin Schwidefsky stg %r0,0(%r3) 117972d38b19SMartin Schwidefsky la %r3,8(%r3) 118072d38b19SMartin Schwidefsky la %r4,8(%r4) 118172d38b19SMartin Schwidefsky brct %r1,2b 118272d38b19SMartin Schwidefsky#endif 118372d38b19SMartin Schwidefsky3: # account system time going idle 11844bfc86ceSHeiko Carstens lg %r9,__LC_STEAL_TIMER 11854bfc86ceSHeiko Carstens alg %r9,__CLOCK_IDLE_ENTER(%r2) 11864bfc86ceSHeiko Carstens slg %r9,__LC_LAST_UPDATE_CLOCK 11874bfc86ceSHeiko Carstens stg %r9,__LC_STEAL_TIMER 11884bfc86ceSHeiko Carstens mvc __LC_LAST_UPDATE_CLOCK(8),__CLOCK_IDLE_EXIT(%r2) 11894bfc86ceSHeiko Carstens lg %r9,__LC_SYSTEM_TIMER 11904bfc86ceSHeiko Carstens alg %r9,__LC_LAST_UPDATE_TIMER 11914bfc86ceSHeiko Carstens slg %r9,__TIMER_IDLE_ENTER(%r2) 11924bfc86ceSHeiko Carstens stg %r9,__LC_SYSTEM_TIMER 11934bfc86ceSHeiko Carstens mvc __LC_LAST_UPDATE_TIMER(8),__TIMER_IDLE_EXIT(%r2) 11944bfc86ceSHeiko Carstens # prepare return psw 11954bfc86ceSHeiko Carstens nihh %r8,0xfcfd # clear irq & wait state bits 11964bfc86ceSHeiko Carstens lg %r9,48(%r11) # return from psw_idle 11974bfc86ceSHeiko Carstens br %r14 11984bfc86ceSHeiko Carstens.Lcleanup_idle_insn: 11994bfc86ceSHeiko Carstens .quad .Lpsw_idle_lpsw 12004bfc86ceSHeiko Carstens 12019977e886SHendrik Brueckner.Lcleanup_save_fpu_regs: 120283abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 12039977e886SHendrik Brueckner bor %r14 12049977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_save_fpu_regs_done) 12059977e886SHendrik Brueckner jhe 5f 12069977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_save_fpu_regs_fp) 12079977e886SHendrik Brueckner jhe 4f 12089977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_high) 12099977e886SHendrik Brueckner jhe 3f 12109977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_low) 12119977e886SHendrik Brueckner jhe 2f 12129977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_save_fpu_fpc_end) 12139977e886SHendrik Brueckner jhe 1f 1214d0164ee2SHendrik Brueckner lg %r2,__LC_CURRENT 12159380cf5aSHeiko Carstens aghi %r2,__TASK_thread 12169977e886SHendrik Brueckner0: # Store floating-point controls 1217d0164ee2SHendrik Brueckner stfpc __THREAD_FPU_fpc(%r2) 12189977e886SHendrik Brueckner1: # Load register save area and check if VX is active 1219d0164ee2SHendrik Brueckner lg %r3,__THREAD_FPU_regs(%r2) 122083abeffbSHendrik Brueckner TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 12219977e886SHendrik Brueckner jz 4f # no VX -> store FP regs 12229977e886SHendrik Brueckner2: # Store vector registers (V0-V15) 12239977e886SHendrik Brueckner VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3) 12249977e886SHendrik Brueckner3: # Store vector registers (V16-V31) 12259977e886SHendrik Brueckner VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3) 12269977e886SHendrik Brueckner j 5f # -> done, set CIF_FPU flag 12279977e886SHendrik Brueckner4: # Store floating-point registers 12289977e886SHendrik Brueckner std 0,0(%r3) 12299977e886SHendrik Brueckner std 1,8(%r3) 12309977e886SHendrik Brueckner std 2,16(%r3) 12319977e886SHendrik Brueckner std 3,24(%r3) 12329977e886SHendrik Brueckner std 4,32(%r3) 12339977e886SHendrik Brueckner std 5,40(%r3) 12349977e886SHendrik Brueckner std 6,48(%r3) 12359977e886SHendrik Brueckner std 7,56(%r3) 12369977e886SHendrik Brueckner std 8,64(%r3) 12379977e886SHendrik Brueckner std 9,72(%r3) 12389977e886SHendrik Brueckner std 10,80(%r3) 12399977e886SHendrik Brueckner std 11,88(%r3) 12409977e886SHendrik Brueckner std 12,96(%r3) 12419977e886SHendrik Brueckner std 13,104(%r3) 12429977e886SHendrik Brueckner std 14,112(%r3) 12439977e886SHendrik Brueckner std 15,120(%r3) 12449977e886SHendrik Brueckner5: # Set CIF_FPU flag 12459977e886SHendrik Brueckner oi __LC_CPU_FLAGS+7,_CIF_FPU 12469977e886SHendrik Brueckner lg %r9,48(%r11) # return from save_fpu_regs 12479977e886SHendrik Brueckner br %r14 12489977e886SHendrik Brueckner.Lcleanup_save_fpu_fpc_end: 12499977e886SHendrik Brueckner .quad .Lsave_fpu_regs_fpc_end 12509977e886SHendrik Brueckner.Lcleanup_save_fpu_regs_vx_low: 12519977e886SHendrik Brueckner .quad .Lsave_fpu_regs_vx_low 12529977e886SHendrik Brueckner.Lcleanup_save_fpu_regs_vx_high: 12539977e886SHendrik Brueckner .quad .Lsave_fpu_regs_vx_high 12549977e886SHendrik Brueckner.Lcleanup_save_fpu_regs_fp: 12559977e886SHendrik Brueckner .quad .Lsave_fpu_regs_fp 12569977e886SHendrik Brueckner.Lcleanup_save_fpu_regs_done: 12579977e886SHendrik Brueckner .quad .Lsave_fpu_regs_done 12589977e886SHendrik Brueckner 12599977e886SHendrik Brueckner.Lcleanup_load_fpu_regs: 126083abeffbSHendrik Brueckner TSTMSK __LC_CPU_FLAGS,_CIF_FPU 12619977e886SHendrik Brueckner bnor %r14 12629977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_load_fpu_regs_done) 12639977e886SHendrik Brueckner jhe 1f 12649977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_load_fpu_regs_fp) 12659977e886SHendrik Brueckner jhe 2f 12669977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_load_fpu_regs_vx_high) 1267b5510d9bSHendrik Brueckner jhe 3f 12689977e886SHendrik Brueckner clg %r9,BASED(.Lcleanup_load_fpu_regs_vx) 1269b5510d9bSHendrik Brueckner jhe 4f 1270d0164ee2SHendrik Brueckner lg %r4,__LC_CURRENT 12719380cf5aSHeiko Carstens aghi %r4,__TASK_thread 1272d0164ee2SHendrik Brueckner lfpc __THREAD_FPU_fpc(%r4) 127383abeffbSHendrik Brueckner TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 1274d0164ee2SHendrik Brueckner lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area 1275b5510d9bSHendrik Brueckner jz 2f # -> no VX, load FP regs 1276b5510d9bSHendrik Brueckner4: # Load V0 ..V15 registers 12779977e886SHendrik Brueckner VLM %v0,%v15,0,%r4 1278b5510d9bSHendrik Brueckner3: # Load V16..V31 registers 12799977e886SHendrik Brueckner VLM %v16,%v31,256,%r4 12809977e886SHendrik Brueckner j 1f 12819977e886SHendrik Brueckner2: # Load floating-point registers 12829977e886SHendrik Brueckner ld 0,0(%r4) 12839977e886SHendrik Brueckner ld 1,8(%r4) 12849977e886SHendrik Brueckner ld 2,16(%r4) 12859977e886SHendrik Brueckner ld 3,24(%r4) 12869977e886SHendrik Brueckner ld 4,32(%r4) 12879977e886SHendrik Brueckner ld 5,40(%r4) 12889977e886SHendrik Brueckner ld 6,48(%r4) 12899977e886SHendrik Brueckner ld 7,56(%r4) 12909977e886SHendrik Brueckner ld 8,64(%r4) 12919977e886SHendrik Brueckner ld 9,72(%r4) 12929977e886SHendrik Brueckner ld 10,80(%r4) 12939977e886SHendrik Brueckner ld 11,88(%r4) 12949977e886SHendrik Brueckner ld 12,96(%r4) 12959977e886SHendrik Brueckner ld 13,104(%r4) 12969977e886SHendrik Brueckner ld 14,112(%r4) 12979977e886SHendrik Brueckner ld 15,120(%r4) 12989977e886SHendrik Brueckner1: # Clear CIF_FPU bit 12999977e886SHendrik Brueckner ni __LC_CPU_FLAGS+7,255-_CIF_FPU 13009977e886SHendrik Brueckner lg %r9,48(%r11) # return from load_fpu_regs 13019977e886SHendrik Brueckner br %r14 13029977e886SHendrik Brueckner.Lcleanup_load_fpu_regs_vx: 13039977e886SHendrik Brueckner .quad .Lload_fpu_regs_vx 13049977e886SHendrik Brueckner.Lcleanup_load_fpu_regs_vx_high: 13059977e886SHendrik Brueckner .quad .Lload_fpu_regs_vx_high 13069977e886SHendrik Brueckner.Lcleanup_load_fpu_regs_fp: 13079977e886SHendrik Brueckner .quad .Lload_fpu_regs_fp 13089977e886SHendrik Brueckner.Lcleanup_load_fpu_regs_done: 13099977e886SHendrik Brueckner .quad .Lload_fpu_regs_done 13109977e886SHendrik Brueckner 13114bfc86ceSHeiko Carstens/* 13124bfc86ceSHeiko Carstens * Integer constants 13134bfc86ceSHeiko Carstens */ 13144bfc86ceSHeiko Carstens .align 8 13154bfc86ceSHeiko Carstens.Lcritical_start: 13164bfc86ceSHeiko Carstens .quad .L__critical_start 13174bfc86ceSHeiko Carstens.Lcritical_length: 13184bfc86ceSHeiko Carstens .quad .L__critical_end - .L__critical_start 13194bfc86ceSHeiko Carstens#if IS_ENABLED(CONFIG_KVM) 1320d0fc4107SMartin Schwidefsky.Lsie_critical_start: 13214bfc86ceSHeiko Carstens .quad .Lsie_gmap 13224bfc86ceSHeiko Carstens.Lsie_critical_length: 13234bfc86ceSHeiko Carstens .quad .Lsie_done - .Lsie_gmap 13244bfc86ceSHeiko Carstens#endif 13254bfc86ceSHeiko Carstens 13264bfc86ceSHeiko Carstens .section .rodata, "a" 1327a876cb3fSHeiko Carstens#define SYSCALL(esame,emu) .long esame 13284bfc86ceSHeiko Carstens .globl sys_call_table 13294bfc86ceSHeiko Carstenssys_call_table: 13304bfc86ceSHeiko Carstens#include "syscalls.S" 13314bfc86ceSHeiko Carstens#undef SYSCALL 13324bfc86ceSHeiko Carstens 13334bfc86ceSHeiko Carstens#ifdef CONFIG_COMPAT 13344bfc86ceSHeiko Carstens 1335a876cb3fSHeiko Carstens#define SYSCALL(esame,emu) .long emu 13364bfc86ceSHeiko Carstens .globl sys_call_table_emu 13374bfc86ceSHeiko Carstenssys_call_table_emu: 13384bfc86ceSHeiko Carstens#include "syscalls.S" 13394bfc86ceSHeiko Carstens#undef SYSCALL 13404bfc86ceSHeiko Carstens#endif 1341