1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * s390x assembly library 4 * 5 * Copyright (c) 2019 IBM Corp. 6 * 7 * Authors: 8 * Janosch Frank <frankja@linux.ibm.com> 9 */ 10#include <asm/asm-offsets.h> 11#include <asm/sigp.h> 12 13#include "macros.S" 14 15/* 16 * load_reset calling convention: 17 * %r2 subcode (0 or 1) 18 */ 19.globl diag308_load_reset 20diag308_load_reset: 21 SAVE_REGS_STACK 22 /* Backup current PSW mask, as we have to restore it on success */ 23 epsw %r0, %r1 24 st %r0, GEN_LC_SW_INT_PSW 25 st %r1, GEN_LC_SW_INT_PSW + 4 26 /* Load reset psw mask (short psw, 64 bit) */ 27 lg %r0, reset_psw 28 /* Load the success label address */ 29 larl %r1, 0f 30 /* Or it to the mask */ 31 ogr %r0, %r1 32 /* Store it at the reset PSW location (real 0x0) */ 33 stg %r0, 0 34 stg %r15, GEN_LC_SW_INT_GRS + 15 * 8 35 /* Do the reset */ 36 diag %r0,%r2,0x308 37 /* Failure path */ 38 xgr %r2, %r2 39 br %r14 40 /* Success path */ 41 /* load a cr0 that has the AFP control bit which enables all FPRs */ 420: larl %r1, initial_cr0 43 lctlg %c0, %c0, 0(%r1) 44 lg %r15, GEN_LC_SW_INT_GRS + 15 * 8 45 RESTORE_REGS_STACK 46 lhi %r2, 1 47 larl %r0, 1f 48 stg %r0, GEN_LC_SW_INT_PSW + 8 49 lpswe GEN_LC_SW_INT_PSW 501: br %r14 51 52/* Sets up general registers and cr0 when a new cpu is brought online. */ 53.globl smp_cpu_setup_state 54smp_cpu_setup_state: 55 xgr %r1, %r1 56 lmg %r0, %r15, GEN_LC_SW_INT_GRS 57 lctlg %c0, %c0, GEN_LC_SW_INT_CRS 58 /* We should only go once through cpu setup and not for every restart */ 59 stg %r14, GEN_LC_RESTART_NEW_PSW + 8 60 larl %r14, 0f 61 lpswe GEN_LC_SW_INT_PSW 62 /* If the function returns, just loop here */ 630: j 0 64 65/* 66 * sie64a calling convention: 67 * %r2 pointer to sie control block 68 * %r3 guest register save area 69 */ 70.globl sie64a 71sie64a: 72 # Save host grs, fprs, fpc 73 stmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r3) # save kernel registers 74 .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 75 std \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r3) 76 .endr 77 stfpc SIE_SAVEAREA_HOST_FPC(%r3) 78 79 # Store scb and save_area pointer into stack frame 80 stg %r2,__SF_SIE_CONTROL(%r15) # save control block pointer 81 stg %r3,__SF_SIE_SAVEAREA(%r15) # save guest register save area 82 83 # Load guest's gprs, fprs and fpc 84 .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 85 ld \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r3) 86 .endr 87 lfpc SIE_SAVEAREA_GUEST_FPC(%r3) 88 lmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r3) 89 90 # Move scb ptr into r14 for the sie instruction 91 lg %r14,__SF_SIE_CONTROL(%r15) 92 93.globl sie_entry 94sie_entry: 95 sie 0(%r14) 96 nopr 7 97 nopr 7 98 nopr 7 99 100.globl sie_exit 101sie_exit: 102 # Load guest register save area 103 lg %r14,__SF_SIE_SAVEAREA(%r15) 104 105 # Store guest's gprs, fprs and fpc 106 stmg %r0,%r13,SIE_SAVEAREA_GUEST_GRS(%r14) # save guest gprs 0-13 107 .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 108 std \i, \i * 8 + SIE_SAVEAREA_GUEST_FPRS(%r14) 109 .endr 110 stfpc SIE_SAVEAREA_GUEST_FPC(%r14) 111 112 # Restore host's gprs, fprs and fpc 113 .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 114 ld \i, \i * 8 + SIE_SAVEAREA_HOST_FPRS(%r14) 115 .endr 116 lfpc SIE_SAVEAREA_HOST_FPC(%r14) 117 lmg %r0,%r14,SIE_SAVEAREA_HOST_GRS(%r14) # restore kernel registers 118 119 br %r14 120 121 .align 8 122reset_psw: 123 .quad 0x0008000180000000 124