18f2abe6aSChristian Borntraeger /* 2a53c8fabSHeiko Carstens * in-kernel handling for sie intercepts 38f2abe6aSChristian Borntraeger * 49a558ee3SThomas Huth * Copyright IBM Corp. 2008, 2014 58f2abe6aSChristian Borntraeger * 68f2abe6aSChristian Borntraeger * This program is free software; you can redistribute it and/or modify 78f2abe6aSChristian Borntraeger * it under the terms of the GNU General Public License (version 2 only) 88f2abe6aSChristian Borntraeger * as published by the Free Software Foundation. 98f2abe6aSChristian Borntraeger * 108f2abe6aSChristian Borntraeger * Author(s): Carsten Otte <cotte@de.ibm.com> 118f2abe6aSChristian Borntraeger * Christian Borntraeger <borntraeger@de.ibm.com> 128f2abe6aSChristian Borntraeger */ 138f2abe6aSChristian Borntraeger 148f2abe6aSChristian Borntraeger #include <linux/kvm_host.h> 158f2abe6aSChristian Borntraeger #include <linux/errno.h> 168f2abe6aSChristian Borntraeger #include <linux/pagemap.h> 178f2abe6aSChristian Borntraeger 188f2abe6aSChristian Borntraeger #include <asm/kvm_host.h> 19a86dcc24SMichael Mueller #include <asm/asm-offsets.h> 20f14d82e0SThomas Huth #include <asm/irq.h> 218f2abe6aSChristian Borntraeger 228f2abe6aSChristian Borntraeger #include "kvm-s390.h" 23ba5c1e9bSCarsten Otte #include "gaccess.h" 245786fffaSCornelia Huck #include "trace.h" 25ade38c31SCornelia Huck #include "trace-s390.h" 26ba5c1e9bSCarsten Otte 27f379aae5SCornelia Huck 2877975357SCornelia Huck static const intercept_handler_t instruction_handlers[256] = { 298c3f61e2SCornelia Huck [0x01] = kvm_s390_handle_01, 3048a3e950SCornelia Huck [0x82] = kvm_s390_handle_lpsw, 31e28acfeaSChristian Borntraeger [0x83] = kvm_s390_handle_diag, 325288fbf0SChristian Borntraeger [0xae] = kvm_s390_handle_sigp, 3370455a36SChristian Borntraeger [0xb2] = kvm_s390_handle_b2, 34aba07508SDavid Hildenbrand [0xb6] = kvm_s390_handle_stctl, 35953ed88dSThomas Huth [0xb7] = kvm_s390_handle_lctl, 3648a3e950SCornelia Huck [0xb9] = kvm_s390_handle_b9, 37bb25b9baSChristian Borntraeger [0xe5] = kvm_s390_handle_e5, 38953ed88dSThomas Huth [0xeb] = kvm_s390_handle_eb, 39ba5c1e9bSCarsten Otte }; 408f2abe6aSChristian Borntraeger 41*04b41acdSThomas Huth void kvm_s390_rewind_psw(struct kvm_vcpu *vcpu, int ilc) 42*04b41acdSThomas Huth { 43*04b41acdSThomas Huth struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block; 44*04b41acdSThomas Huth 45*04b41acdSThomas Huth /* Use the length of the EXECUTE instruction if necessary */ 46*04b41acdSThomas Huth if (sie_block->icptstatus & 1) { 47*04b41acdSThomas Huth ilc = (sie_block->icptstatus >> 4) & 0x6; 48*04b41acdSThomas Huth if (!ilc) 49*04b41acdSThomas Huth ilc = 4; 50*04b41acdSThomas Huth } 51*04b41acdSThomas Huth sie_block->gpsw.addr = __rewind_psw(sie_block->gpsw, ilc); 52*04b41acdSThomas Huth } 53*04b41acdSThomas Huth 548f2abe6aSChristian Borntraeger static int handle_noop(struct kvm_vcpu *vcpu) 558f2abe6aSChristian Borntraeger { 568f2abe6aSChristian Borntraeger switch (vcpu->arch.sie_block->icptcode) { 570eaeafa1SChristian Borntraeger case 0x0: 580eaeafa1SChristian Borntraeger vcpu->stat.exit_null++; 590eaeafa1SChristian Borntraeger break; 608f2abe6aSChristian Borntraeger case 0x10: 618f2abe6aSChristian Borntraeger vcpu->stat.exit_external_request++; 628f2abe6aSChristian Borntraeger break; 638f2abe6aSChristian Borntraeger default: 648f2abe6aSChristian Borntraeger break; /* nothing */ 658f2abe6aSChristian Borntraeger } 668f2abe6aSChristian Borntraeger return 0; 678f2abe6aSChristian Borntraeger } 688f2abe6aSChristian Borntraeger 698f2abe6aSChristian Borntraeger static int handle_stop(struct kvm_vcpu *vcpu) 708f2abe6aSChristian Borntraeger { 719ace903dSChristian Ehrhardt int rc = 0; 7232f5ff63SDavid Hildenbrand unsigned int action_bits; 735288fbf0SChristian Borntraeger 748f2abe6aSChristian Borntraeger vcpu->stat.exit_stop_request++; 75ade38c31SCornelia Huck trace_kvm_s390_stop_request(vcpu->arch.local_int.action_bits); 76ade38c31SCornelia Huck 7732f5ff63SDavid Hildenbrand action_bits = vcpu->arch.local_int.action_bits; 789ace903dSChristian Ehrhardt 7932f5ff63SDavid Hildenbrand if (!(action_bits & ACTION_STOP_ON_STOP)) 8032f5ff63SDavid Hildenbrand return 0; 8132f5ff63SDavid Hildenbrand 8232f5ff63SDavid Hildenbrand if (action_bits & ACTION_STORE_ON_STOP) { 839e0d5473SJens Freimann rc = kvm_s390_vcpu_store_status(vcpu, 849e0d5473SJens Freimann KVM_S390_STORE_STATUS_NOADDR); 8532f5ff63SDavid Hildenbrand if (rc) 865288fbf0SChristian Borntraeger return rc; 878f2abe6aSChristian Borntraeger } 888f2abe6aSChristian Borntraeger 896352e4d2SDavid Hildenbrand if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) 9032f5ff63SDavid Hildenbrand kvm_s390_vcpu_stop(vcpu); 9132f5ff63SDavid Hildenbrand return -EOPNOTSUPP; 9232f5ff63SDavid Hildenbrand } 9332f5ff63SDavid Hildenbrand 948f2abe6aSChristian Borntraeger static int handle_validity(struct kvm_vcpu *vcpu) 958f2abe6aSChristian Borntraeger { 968f2abe6aSChristian Borntraeger int viwhy = vcpu->arch.sie_block->ipb >> 16; 973edbcff9SCarsten Otte 988f2abe6aSChristian Borntraeger vcpu->stat.exit_validity++; 995786fffaSCornelia Huck trace_kvm_s390_intercept_validity(vcpu, viwhy); 1002c70fe44SChristian Borntraeger WARN_ONCE(true, "kvm: unhandled validity intercept 0x%x\n", viwhy); 1012c70fe44SChristian Borntraeger return -EOPNOTSUPP; 1028f2abe6aSChristian Borntraeger } 1038f2abe6aSChristian Borntraeger 104ba5c1e9bSCarsten Otte static int handle_instruction(struct kvm_vcpu *vcpu) 105ba5c1e9bSCarsten Otte { 106ba5c1e9bSCarsten Otte intercept_handler_t handler; 107ba5c1e9bSCarsten Otte 108ba5c1e9bSCarsten Otte vcpu->stat.exit_instruction++; 1095786fffaSCornelia Huck trace_kvm_s390_intercept_instruction(vcpu, 1105786fffaSCornelia Huck vcpu->arch.sie_block->ipa, 1115786fffaSCornelia Huck vcpu->arch.sie_block->ipb); 112ba5c1e9bSCarsten Otte handler = instruction_handlers[vcpu->arch.sie_block->ipa >> 8]; 113ba5c1e9bSCarsten Otte if (handler) 114ba5c1e9bSCarsten Otte return handler(vcpu); 115b8e660b8SHeiko Carstens return -EOPNOTSUPP; 116ba5c1e9bSCarsten Otte } 117ba5c1e9bSCarsten Otte 118439716a5SDavid Hildenbrand static void __extract_prog_irq(struct kvm_vcpu *vcpu, 119439716a5SDavid Hildenbrand struct kvm_s390_pgm_info *pgm_info) 120439716a5SDavid Hildenbrand { 121439716a5SDavid Hildenbrand memset(pgm_info, 0, sizeof(struct kvm_s390_pgm_info)); 122439716a5SDavid Hildenbrand pgm_info->code = vcpu->arch.sie_block->iprcc; 123439716a5SDavid Hildenbrand 124439716a5SDavid Hildenbrand switch (vcpu->arch.sie_block->iprcc & ~PGM_PER) { 125439716a5SDavid Hildenbrand case PGM_AFX_TRANSLATION: 126439716a5SDavid Hildenbrand case PGM_ASX_TRANSLATION: 127439716a5SDavid Hildenbrand case PGM_EX_TRANSLATION: 128439716a5SDavid Hildenbrand case PGM_LFX_TRANSLATION: 129439716a5SDavid Hildenbrand case PGM_LSTE_SEQUENCE: 130439716a5SDavid Hildenbrand case PGM_LSX_TRANSLATION: 131439716a5SDavid Hildenbrand case PGM_LX_TRANSLATION: 132439716a5SDavid Hildenbrand case PGM_PRIMARY_AUTHORITY: 133439716a5SDavid Hildenbrand case PGM_SECONDARY_AUTHORITY: 134439716a5SDavid Hildenbrand case PGM_SPACE_SWITCH: 135439716a5SDavid Hildenbrand pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc; 136439716a5SDavid Hildenbrand break; 137439716a5SDavid Hildenbrand case PGM_ALEN_TRANSLATION: 138439716a5SDavid Hildenbrand case PGM_ALE_SEQUENCE: 139439716a5SDavid Hildenbrand case PGM_ASTE_INSTANCE: 140439716a5SDavid Hildenbrand case PGM_ASTE_SEQUENCE: 141439716a5SDavid Hildenbrand case PGM_ASTE_VALIDITY: 142439716a5SDavid Hildenbrand case PGM_EXTENDED_AUTHORITY: 143439716a5SDavid Hildenbrand pgm_info->exc_access_id = vcpu->arch.sie_block->eai; 144439716a5SDavid Hildenbrand break; 145439716a5SDavid Hildenbrand case PGM_ASCE_TYPE: 146439716a5SDavid Hildenbrand case PGM_PAGE_TRANSLATION: 147439716a5SDavid Hildenbrand case PGM_REGION_FIRST_TRANS: 148439716a5SDavid Hildenbrand case PGM_REGION_SECOND_TRANS: 149439716a5SDavid Hildenbrand case PGM_REGION_THIRD_TRANS: 150439716a5SDavid Hildenbrand case PGM_SEGMENT_TRANSLATION: 151439716a5SDavid Hildenbrand pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc; 152439716a5SDavid Hildenbrand pgm_info->exc_access_id = vcpu->arch.sie_block->eai; 153439716a5SDavid Hildenbrand pgm_info->op_access_id = vcpu->arch.sie_block->oai; 154439716a5SDavid Hildenbrand break; 155439716a5SDavid Hildenbrand case PGM_MONITOR: 156439716a5SDavid Hildenbrand pgm_info->mon_class_nr = vcpu->arch.sie_block->mcn; 157439716a5SDavid Hildenbrand pgm_info->mon_code = vcpu->arch.sie_block->tecmc; 158439716a5SDavid Hildenbrand break; 159439716a5SDavid Hildenbrand case PGM_DATA: 160439716a5SDavid Hildenbrand pgm_info->data_exc_code = vcpu->arch.sie_block->dxc; 161439716a5SDavid Hildenbrand break; 162439716a5SDavid Hildenbrand case PGM_PROTECTION: 163439716a5SDavid Hildenbrand pgm_info->trans_exc_code = vcpu->arch.sie_block->tecmc; 164439716a5SDavid Hildenbrand pgm_info->exc_access_id = vcpu->arch.sie_block->eai; 165439716a5SDavid Hildenbrand break; 166439716a5SDavid Hildenbrand default: 167439716a5SDavid Hildenbrand break; 168439716a5SDavid Hildenbrand } 169439716a5SDavid Hildenbrand 170439716a5SDavid Hildenbrand if (vcpu->arch.sie_block->iprcc & PGM_PER) { 171439716a5SDavid Hildenbrand pgm_info->per_code = vcpu->arch.sie_block->perc; 172439716a5SDavid Hildenbrand pgm_info->per_atmid = vcpu->arch.sie_block->peratmid; 173439716a5SDavid Hildenbrand pgm_info->per_address = vcpu->arch.sie_block->peraddr; 174439716a5SDavid Hildenbrand pgm_info->per_access_id = vcpu->arch.sie_block->peraid; 175439716a5SDavid Hildenbrand } 176439716a5SDavid Hildenbrand } 177439716a5SDavid Hildenbrand 178e325fe69SMichael Mueller /* 179e325fe69SMichael Mueller * restore ITDB to program-interruption TDB in guest lowcore 180e325fe69SMichael Mueller * and set TX abort indication if required 181e325fe69SMichael Mueller */ 182e325fe69SMichael Mueller static int handle_itdb(struct kvm_vcpu *vcpu) 183e325fe69SMichael Mueller { 184e325fe69SMichael Mueller struct kvm_s390_itdb *itdb; 185e325fe69SMichael Mueller int rc; 186e325fe69SMichael Mueller 187e325fe69SMichael Mueller if (!IS_TE_ENABLED(vcpu) || !IS_ITDB_VALID(vcpu)) 188e325fe69SMichael Mueller return 0; 189e325fe69SMichael Mueller if (current->thread.per_flags & PER_FLAG_NO_TE) 190e325fe69SMichael Mueller return 0; 191e325fe69SMichael Mueller itdb = (struct kvm_s390_itdb *)vcpu->arch.sie_block->itdba; 192e325fe69SMichael Mueller rc = write_guest_lc(vcpu, __LC_PGM_TDB, itdb, sizeof(*itdb)); 193e325fe69SMichael Mueller if (rc) 194e325fe69SMichael Mueller return rc; 195e325fe69SMichael Mueller memset(itdb, 0, sizeof(*itdb)); 196e325fe69SMichael Mueller 197e325fe69SMichael Mueller return 0; 198e325fe69SMichael Mueller } 199e325fe69SMichael Mueller 20027291e21SDavid Hildenbrand #define per_event(vcpu) (vcpu->arch.sie_block->iprcc & PGM_PER) 20127291e21SDavid Hildenbrand 202ba5c1e9bSCarsten Otte static int handle_prog(struct kvm_vcpu *vcpu) 203ba5c1e9bSCarsten Otte { 204439716a5SDavid Hildenbrand struct kvm_s390_pgm_info pgm_info; 205684135e0SThomas Huth psw_t psw; 2060040e7d2SHeiko Carstens int rc; 2070040e7d2SHeiko Carstens 208ba5c1e9bSCarsten Otte vcpu->stat.exit_program_interruption++; 2097feb6bb8SMichael Mueller 21027291e21SDavid Hildenbrand if (guestdbg_enabled(vcpu) && per_event(vcpu)) { 21127291e21SDavid Hildenbrand kvm_s390_handle_per_event(vcpu); 21227291e21SDavid Hildenbrand /* the interrupt might have been filtered out completely */ 21327291e21SDavid Hildenbrand if (vcpu->arch.sie_block->iprcc == 0) 21427291e21SDavid Hildenbrand return 0; 21527291e21SDavid Hildenbrand } 21627291e21SDavid Hildenbrand 217e325fe69SMichael Mueller trace_kvm_s390_intercept_prog(vcpu, vcpu->arch.sie_block->iprcc); 218684135e0SThomas Huth if (vcpu->arch.sie_block->iprcc == PGM_SPECIFICATION) { 219684135e0SThomas Huth rc = read_guest_lc(vcpu, __LC_PGM_NEW_PSW, &psw, sizeof(psw_t)); 220684135e0SThomas Huth if (rc) 221684135e0SThomas Huth return rc; 222684135e0SThomas Huth /* Avoid endless loops of specification exceptions */ 223684135e0SThomas Huth if (!is_valid_psw(&psw)) 224684135e0SThomas Huth return -EOPNOTSUPP; 225684135e0SThomas Huth } 226e325fe69SMichael Mueller rc = handle_itdb(vcpu); 2270040e7d2SHeiko Carstens if (rc) 2280040e7d2SHeiko Carstens return rc; 229439716a5SDavid Hildenbrand 230e325fe69SMichael Mueller __extract_prog_irq(vcpu, &pgm_info); 231439716a5SDavid Hildenbrand return kvm_s390_inject_prog_irq(vcpu, &pgm_info); 232ba5c1e9bSCarsten Otte } 233ba5c1e9bSCarsten Otte 234ba5c1e9bSCarsten Otte static int handle_instruction_and_prog(struct kvm_vcpu *vcpu) 235ba5c1e9bSCarsten Otte { 236ba5c1e9bSCarsten Otte int rc, rc2; 237ba5c1e9bSCarsten Otte 238ba5c1e9bSCarsten Otte vcpu->stat.exit_instr_and_program++; 239ba5c1e9bSCarsten Otte rc = handle_instruction(vcpu); 240ba5c1e9bSCarsten Otte rc2 = handle_prog(vcpu); 241ba5c1e9bSCarsten Otte 242b8e660b8SHeiko Carstens if (rc == -EOPNOTSUPP) 243ba5c1e9bSCarsten Otte vcpu->arch.sie_block->icptcode = 0x04; 244ba5c1e9bSCarsten Otte if (rc) 245ba5c1e9bSCarsten Otte return rc; 246ba5c1e9bSCarsten Otte return rc2; 247ba5c1e9bSCarsten Otte } 248ba5c1e9bSCarsten Otte 2499a558ee3SThomas Huth /** 250f14d82e0SThomas Huth * handle_external_interrupt - used for external interruption interceptions 251f14d82e0SThomas Huth * 252f14d82e0SThomas Huth * This interception only occurs if the CPUSTAT_EXT_INT bit was set, or if 253f14d82e0SThomas Huth * the new PSW does not have external interrupts disabled. In the first case, 254f14d82e0SThomas Huth * we've got to deliver the interrupt manually, and in the second case, we 255f14d82e0SThomas Huth * drop to userspace to handle the situation there. 256f14d82e0SThomas Huth */ 257f14d82e0SThomas Huth static int handle_external_interrupt(struct kvm_vcpu *vcpu) 258f14d82e0SThomas Huth { 259f14d82e0SThomas Huth u16 eic = vcpu->arch.sie_block->eic; 260f14d82e0SThomas Huth struct kvm_s390_interrupt irq; 261f14d82e0SThomas Huth psw_t newpsw; 262f14d82e0SThomas Huth int rc; 263f14d82e0SThomas Huth 264f14d82e0SThomas Huth vcpu->stat.exit_external_interrupt++; 265f14d82e0SThomas Huth 266f14d82e0SThomas Huth rc = read_guest_lc(vcpu, __LC_EXT_NEW_PSW, &newpsw, sizeof(psw_t)); 267f14d82e0SThomas Huth if (rc) 268f14d82e0SThomas Huth return rc; 269f14d82e0SThomas Huth /* We can not handle clock comparator or timer interrupt with bad PSW */ 270f14d82e0SThomas Huth if ((eic == EXT_IRQ_CLK_COMP || eic == EXT_IRQ_CPU_TIMER) && 271f14d82e0SThomas Huth (newpsw.mask & PSW_MASK_EXT)) 272f14d82e0SThomas Huth return -EOPNOTSUPP; 273f14d82e0SThomas Huth 274f14d82e0SThomas Huth switch (eic) { 275f14d82e0SThomas Huth case EXT_IRQ_CLK_COMP: 276f14d82e0SThomas Huth irq.type = KVM_S390_INT_CLOCK_COMP; 277f14d82e0SThomas Huth break; 278f14d82e0SThomas Huth case EXT_IRQ_CPU_TIMER: 279f14d82e0SThomas Huth irq.type = KVM_S390_INT_CPU_TIMER; 280f14d82e0SThomas Huth break; 281f14d82e0SThomas Huth case EXT_IRQ_EXTERNAL_CALL: 2824953919fSDavid Hildenbrand if (kvm_s390_si_ext_call_pending(vcpu)) 2834953919fSDavid Hildenbrand return 0; 284f14d82e0SThomas Huth irq.type = KVM_S390_INT_EXTERNAL_CALL; 285f14d82e0SThomas Huth irq.parm = vcpu->arch.sie_block->extcpuaddr; 286f14d82e0SThomas Huth break; 287f14d82e0SThomas Huth default: 288f14d82e0SThomas Huth return -EOPNOTSUPP; 289f14d82e0SThomas Huth } 290f14d82e0SThomas Huth 291f14d82e0SThomas Huth return kvm_s390_inject_vcpu(vcpu, &irq); 292f14d82e0SThomas Huth } 293f14d82e0SThomas Huth 294f14d82e0SThomas Huth /** 2959a558ee3SThomas Huth * Handle MOVE PAGE partial execution interception. 2969a558ee3SThomas Huth * 2979a558ee3SThomas Huth * This interception can only happen for guests with DAT disabled and 2989a558ee3SThomas Huth * addresses that are currently not mapped in the host. Thus we try to 2999a558ee3SThomas Huth * set up the mappings for the corresponding user pages here (or throw 3009a558ee3SThomas Huth * addressing exceptions in case of illegal guest addresses). 3019a558ee3SThomas Huth */ 3029a558ee3SThomas Huth static int handle_mvpg_pei(struct kvm_vcpu *vcpu) 3039a558ee3SThomas Huth { 304f22166dcSThomas Huth unsigned long srcaddr, dstaddr; 3059a558ee3SThomas Huth int reg1, reg2, rc; 3069a558ee3SThomas Huth 3079a558ee3SThomas Huth kvm_s390_get_regs_rre(vcpu, ®1, ®2); 3089a558ee3SThomas Huth 3099a558ee3SThomas Huth /* Make sure that the source is paged-in */ 310f22166dcSThomas Huth srcaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg2]); 311f22166dcSThomas Huth if (kvm_is_error_gpa(vcpu->kvm, srcaddr)) 3129a558ee3SThomas Huth return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 313f22166dcSThomas Huth rc = kvm_arch_fault_in_page(vcpu, srcaddr, 0); 314f22166dcSThomas Huth if (rc != 0) 3159a558ee3SThomas Huth return rc; 3169a558ee3SThomas Huth 3179a558ee3SThomas Huth /* Make sure that the destination is paged-in */ 318f22166dcSThomas Huth dstaddr = kvm_s390_real_to_abs(vcpu, vcpu->run->s.regs.gprs[reg1]); 319f22166dcSThomas Huth if (kvm_is_error_gpa(vcpu->kvm, dstaddr)) 3209a558ee3SThomas Huth return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 321f22166dcSThomas Huth rc = kvm_arch_fault_in_page(vcpu, dstaddr, 1); 322f22166dcSThomas Huth if (rc != 0) 3239a558ee3SThomas Huth return rc; 3249a558ee3SThomas Huth 325*04b41acdSThomas Huth kvm_s390_rewind_psw(vcpu, 4); 3269a558ee3SThomas Huth 3279a558ee3SThomas Huth return 0; 3289a558ee3SThomas Huth } 3299a558ee3SThomas Huth 3309a558ee3SThomas Huth static int handle_partial_execution(struct kvm_vcpu *vcpu) 3319a558ee3SThomas Huth { 3329a558ee3SThomas Huth if (vcpu->arch.sie_block->ipa == 0xb254) /* MVPG */ 3339a558ee3SThomas Huth return handle_mvpg_pei(vcpu); 3344953919fSDavid Hildenbrand if (vcpu->arch.sie_block->ipa >> 8 == 0xae) /* SIGP */ 3354953919fSDavid Hildenbrand return kvm_s390_handle_sigp_pei(vcpu); 3369a558ee3SThomas Huth 3379a558ee3SThomas Huth return -EOPNOTSUPP; 3389a558ee3SThomas Huth } 3399a558ee3SThomas Huth 340062d5e9bSChristian Borntraeger static const intercept_handler_t intercept_funcs[] = { 3418f2abe6aSChristian Borntraeger [0x00 >> 2] = handle_noop, 342ba5c1e9bSCarsten Otte [0x04 >> 2] = handle_instruction, 343ba5c1e9bSCarsten Otte [0x08 >> 2] = handle_prog, 344ba5c1e9bSCarsten Otte [0x0C >> 2] = handle_instruction_and_prog, 3458f2abe6aSChristian Borntraeger [0x10 >> 2] = handle_noop, 346f14d82e0SThomas Huth [0x14 >> 2] = handle_external_interrupt, 347fa6b7fe9SCornelia Huck [0x18 >> 2] = handle_noop, 348ba5c1e9bSCarsten Otte [0x1C >> 2] = kvm_s390_handle_wait, 3498f2abe6aSChristian Borntraeger [0x20 >> 2] = handle_validity, 3508f2abe6aSChristian Borntraeger [0x28 >> 2] = handle_stop, 3519a558ee3SThomas Huth [0x38 >> 2] = handle_partial_execution, 3528f2abe6aSChristian Borntraeger }; 3538f2abe6aSChristian Borntraeger 3548f2abe6aSChristian Borntraeger int kvm_handle_sie_intercept(struct kvm_vcpu *vcpu) 3558f2abe6aSChristian Borntraeger { 3568f2abe6aSChristian Borntraeger intercept_handler_t func; 3578f2abe6aSChristian Borntraeger u8 code = vcpu->arch.sie_block->icptcode; 3588f2abe6aSChristian Borntraeger 359062d5e9bSChristian Borntraeger if (code & 3 || (code >> 2) >= ARRAY_SIZE(intercept_funcs)) 360b8e660b8SHeiko Carstens return -EOPNOTSUPP; 3618f2abe6aSChristian Borntraeger func = intercept_funcs[code >> 2]; 3628f2abe6aSChristian Borntraeger if (func) 3638f2abe6aSChristian Borntraeger return func(vcpu); 364b8e660b8SHeiko Carstens return -EOPNOTSUPP; 3658f2abe6aSChristian Borntraeger } 366