1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 #ifndef _S390X_SIE_H_ 3 #define _S390X_SIE_H_ 4 5 #define CPUSTAT_STOPPED 0x80000000 6 #define CPUSTAT_WAIT 0x10000000 7 #define CPUSTAT_ECALL_PEND 0x08000000 8 #define CPUSTAT_STOP_INT 0x04000000 9 #define CPUSTAT_IO_INT 0x02000000 10 #define CPUSTAT_EXT_INT 0x01000000 11 #define CPUSTAT_RUNNING 0x00800000 12 #define CPUSTAT_RETAINED 0x00400000 13 #define CPUSTAT_TIMING_SUB 0x00020000 14 #define CPUSTAT_SIE_SUB 0x00010000 15 #define CPUSTAT_RRF 0x00008000 16 #define CPUSTAT_SLSV 0x00004000 17 #define CPUSTAT_SLSR 0x00002000 18 #define CPUSTAT_ZARCH 0x00000800 19 #define CPUSTAT_MCDS 0x00000100 20 #define CPUSTAT_KSS 0x00000200 21 #define CPUSTAT_SM 0x00000080 22 #define CPUSTAT_IBS 0x00000040 23 #define CPUSTAT_GED2 0x00000010 24 #define CPUSTAT_G 0x00000008 25 #define CPUSTAT_GED 0x00000004 26 #define CPUSTAT_J 0x00000002 27 #define CPUSTAT_P 0x00000001 28 29 struct kvm_s390_sie_block { 30 uint32_t cpuflags; /* 0x0000 */ 31 uint32_t : 1; /* 0x0004 */ 32 uint32_t prefix : 18; 33 uint32_t : 1; 34 uint32_t ibc : 12; 35 uint8_t reserved08[4]; /* 0x0008 */ 36 #define PROG_IN_SIE (1<<0) 37 uint32_t prog0c; /* 0x000c */ 38 uint8_t reserved10[16]; /* 0x0010 */ 39 #define PROG_BLOCK_SIE (1<<0) 40 #define PROG_REQUEST (1<<1) 41 uint32_t prog20; /* 0x0020 */ 42 uint8_t reserved24[4]; /* 0x0024 */ 43 uint64_t cputm; /* 0x0028 */ 44 uint64_t ckc; /* 0x0030 */ 45 uint64_t epoch; /* 0x0038 */ 46 uint32_t svcc; /* 0x0040 */ 47 #define LCTL_CR0 0x8000 48 #define LCTL_CR6 0x0200 49 #define LCTL_CR9 0x0040 50 #define LCTL_CR10 0x0020 51 #define LCTL_CR11 0x0010 52 #define LCTL_CR14 0x0002 53 uint16_t lctl; /* 0x0044 */ 54 int16_t icpua; /* 0x0046 */ 55 #define ICTL_OPEREXC 0x80000000 56 #define ICTL_PINT 0x20000000 57 #define ICTL_LPSW 0x00400000 58 #define ICTL_STCTL 0x00040000 59 #define ICTL_ISKE 0x00004000 60 #define ICTL_SSKE 0x00002000 61 #define ICTL_RRBE 0x00001000 62 #define ICTL_TPROT 0x00000200 63 uint32_t ictl; /* 0x0048 */ 64 #define ECA_CEI 0x80000000 65 #define ECA_IB 0x40000000 66 #define ECA_SIGPI 0x10000000 67 #define ECA_MVPGI 0x01000000 68 #define ECA_AIV 0x00200000 69 #define ECA_VX 0x00020000 70 #define ECA_PROTEXCI 0x00002000 71 #define ECA_APIE 0x00000008 72 #define ECA_SII 0x00000001 73 uint32_t eca; /* 0x004c */ 74 #define ICPT_INST 0x04 75 #define ICPT_PROGI 0x08 76 #define ICPT_INSTPROGI 0x0C 77 #define ICPT_EXTREQ 0x10 78 #define ICPT_EXTINT 0x14 79 #define ICPT_IOREQ 0x18 80 #define ICPT_WAIT 0x1c 81 #define ICPT_VALIDITY 0x20 82 #define ICPT_STOP 0x28 83 #define ICPT_OPEREXC 0x2C 84 #define ICPT_PARTEXEC 0x38 85 #define ICPT_IOINST 0x40 86 #define ICPT_KSS 0x5c 87 uint8_t icptcode; /* 0x0050 */ 88 uint8_t icptstatus; /* 0x0051 */ 89 uint16_t ihcpu; /* 0x0052 */ 90 uint8_t reserved54[2]; /* 0x0054 */ 91 uint16_t ipa; /* 0x0056 */ 92 uint32_t ipb; /* 0x0058 */ 93 uint32_t scaoh; /* 0x005c */ 94 #define FPF_BPBC 0x20 95 uint8_t fpf; /* 0x0060 */ 96 #define ECB_GS 0x40 97 #define ECB_TE 0x10 98 #define ECB_SRSI 0x04 99 #define ECB_HOSTPROTINT 0x02 100 uint8_t ecb; /* 0x0061 */ 101 #define ECB2_CMMA 0x80 102 #define ECB2_IEP 0x20 103 #define ECB2_PFMFI 0x08 104 #define ECB2_ESCA 0x04 105 uint8_t ecb2; /* 0x0062 */ 106 #define ECB3_DEA 0x08 107 #define ECB3_AES 0x04 108 #define ECB3_RI 0x01 109 uint8_t ecb3; /* 0x0063 */ 110 uint32_t scaol; /* 0x0064 */ 111 uint8_t reserved68; /* 0x0068 */ 112 uint8_t epdx; /* 0x0069 */ 113 uint8_t reserved6a[2]; /* 0x006a */ 114 uint32_t todpr; /* 0x006c */ 115 #define GISA_FORMAT1 0x00000001 116 uint32_t gd; /* 0x0070 */ 117 uint8_t reserved74[12]; /* 0x0074 */ 118 uint64_t mso; /* 0x0080 */ 119 uint64_t msl; /* 0x0088 */ 120 struct psw gpsw; /* 0x0090 */ 121 uint64_t gg14; /* 0x00a0 */ 122 uint64_t gg15; /* 0x00a8 */ 123 uint8_t reservedb0[8]; /* 0x00b0 */ 124 #define HPID_KVM 0x4 125 #define HPID_VSIE 0x5 126 uint8_t hpid; /* 0x00b8 */ 127 uint8_t reservedb9[11]; /* 0x00b9 */ 128 uint16_t extcpuaddr; /* 0x00c4 */ 129 uint16_t eic; /* 0x00c6 */ 130 uint32_t reservedc8; /* 0x00c8 */ 131 uint16_t pgmilc; /* 0x00cc */ 132 uint16_t iprcc; /* 0x00ce */ 133 uint32_t dxc; /* 0x00d0 */ 134 uint16_t mcn; /* 0x00d4 */ 135 uint8_t perc; /* 0x00d6 */ 136 uint8_t peratmid; /* 0x00d7 */ 137 uint64_t peraddr; /* 0x00d8 */ 138 uint8_t eai; /* 0x00e0 */ 139 uint8_t peraid; /* 0x00e1 */ 140 uint8_t oai; /* 0x00e2 */ 141 uint8_t armid; /* 0x00e3 */ 142 uint8_t reservede4[4]; /* 0x00e4 */ 143 uint64_t tecmc; /* 0x00e8 */ 144 uint8_t reservedf0[12]; /* 0x00f0 */ 145 #define CRYCB_FORMAT_MASK 0x00000003 146 #define CRYCB_FORMAT0 0x00000000 147 #define CRYCB_FORMAT1 0x00000001 148 #define CRYCB_FORMAT2 0x00000003 149 uint32_t crycbd; /* 0x00fc */ 150 uint64_t gcr[16]; /* 0x0100 */ 151 uint64_t gbea; /* 0x0180 */ 152 uint8_t reserved188[8]; /* 0x0188 */ 153 uint64_t sdnxo; /* 0x0190 */ 154 uint8_t reserved198[8]; /* 0x0198 */ 155 uint32_t fac; /* 0x01a0 */ 156 uint8_t reserved1a4[20]; /* 0x01a4 */ 157 uint64_t cbrlo; /* 0x01b8 */ 158 uint8_t reserved1c0[8]; /* 0x01c0 */ 159 #define ECD_HOSTREGMGMT 0x20000000 160 #define ECD_MEF 0x08000000 161 #define ECD_ETOKENF 0x02000000 162 #define ECD_ECC 0x00200000 163 uint32_t ecd; /* 0x01c8 */ 164 uint8_t reserved1cc[18]; /* 0x01cc */ 165 uint64_t pp; /* 0x01de */ 166 uint8_t reserved1e6[2]; /* 0x01e6 */ 167 uint64_t itdba; /* 0x01e8 */ 168 uint64_t riccbd; /* 0x01f0 */ 169 uint64_t gvrd; /* 0x01f8 */ 170 } __attribute__((packed)); 171 172 struct vm_save_regs { 173 u64 grs[16]; 174 u64 fprs[16]; 175 u32 fpc; 176 }; 177 178 /* We might be able to nestle all of this into the stack frame. But 179 * having a dedicated save area that saves more than the s390 ELF ABI 180 * defines leaves us more freedom in the implementation. 181 */ 182 struct vm_save_area { 183 struct vm_save_regs guest; 184 struct vm_save_regs host; 185 }; 186 187 struct vm { 188 struct kvm_s390_sie_block *sblk; 189 struct vm_save_area save_area; 190 /* Ptr to first guest page */ 191 u8 *guest_mem; 192 }; 193 194 extern void sie_entry(void); 195 extern void sie_exit(void); 196 extern void sie64a(struct kvm_s390_sie_block *sblk, struct vm_save_area *save_area); 197 198 #endif /* _S390X_SIE_H_ */ 199