Lines Matching +full:ipa +full:- +full:clock +full:- +full:enabled
1 // SPDX-License-Identifier: GPL-2.0
17 #include <asm/asm-offsets.h>
23 #include <asm/page-states.h>
29 #include "kvm-s390.h"
34 vcpu->stat.instruction_ri++; in handle_ri()
36 if (test_kvm_facility(vcpu->kvm, 64)) { in handle_ri()
38 vcpu->arch.sie_block->ecb3 |= ECB3_RI; in handle_ri()
47 if ((vcpu->arch.sie_block->ipa & 0xf) <= 4) in kvm_s390_handle_aa()
50 return -EOPNOTSUPP; in kvm_s390_handle_aa()
55 vcpu->stat.instruction_gs++; in handle_gs()
57 if (test_kvm_facility(vcpu->kvm, 133)) { in handle_gs()
61 current->thread.gs_cb = (struct gs_cb *)&vcpu->run->s.regs.gscb; in handle_gs()
62 restore_gs_cb(current->thread.gs_cb); in handle_gs()
64 vcpu->arch.sie_block->ecb |= ECB_GS; in handle_gs()
65 vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT; in handle_gs()
66 vcpu->arch.gs_enabled = 1; in handle_gs()
75 int code = vcpu->arch.sie_block->ipb & 0xff; in kvm_s390_handle_e3()
80 return -EOPNOTSUPP; in kvm_s390_handle_e3()
82 /* Handle SCK (SET CLOCK) interception */
90 vcpu->stat.instruction_sck++; in handle_set_clock()
92 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_set_clock()
104 * To set the TOD clock the kvm lock must be taken, but the vcpu lock in handle_set_clock()
107 * cases, for example when the multiple epoch facility or TOD clock in handle_set_clock()
110 * the instruction will be retried via -EAGAIN at a later point in in handle_set_clock()
113 if (!kvm_s390_try_set_tod_clock(vcpu->kvm, >od)) { in handle_set_clock()
115 return -EAGAIN; in handle_set_clock()
129 vcpu->stat.instruction_spx++; in handle_set_prefix()
131 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_set_prefix()
152 if (kvm_is_error_gpa(vcpu->kvm, address)) in handle_set_prefix()
167 vcpu->stat.instruction_stpx++; in handle_store_prefix()
169 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_prefix()
192 u16 vcpu_id = vcpu->vcpu_id; in handle_store_cpu_address()
197 vcpu->stat.instruction_stap++; in handle_store_cpu_address()
199 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_cpu_address()
221 /* Already enabled? */ in kvm_s390_skey_check_enable()
222 if (vcpu->arch.skey_enabled) in kvm_s390_skey_check_enable()
232 if (!vcpu->kvm->arch.use_skf) in kvm_s390_skey_check_enable()
233 vcpu->arch.sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE; in kvm_s390_skey_check_enable()
235 vcpu->arch.sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE | ICTL_RRBE); in kvm_s390_skey_check_enable()
236 vcpu->arch.skey_enabled = true; in kvm_s390_skey_check_enable()
247 if (vcpu->kvm->arch.use_skf) { in try_handle_skey()
248 /* with storage-key facility, SIE interprets it for us */ in try_handle_skey()
251 return -EAGAIN; in try_handle_skey()
264 vcpu->stat.instruction_iske++; in handle_iske()
266 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_iske()
271 return rc != -EAGAIN ? rc : 0; in handle_iske()
275 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_iske()
278 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_iske()
283 mmap_read_lock(current->mm); in handle_iske()
284 rc = get_guest_storage_key(current->mm, vmaddr, &key); in handle_iske()
287 rc = fixup_user_fault(current->mm, vmaddr, in handle_iske()
290 mmap_read_unlock(current->mm); in handle_iske()
294 mmap_read_unlock(current->mm); in handle_iske()
295 if (rc == -EFAULT) in handle_iske()
299 vcpu->run->s.regs.gprs[reg1] &= ~0xff; in handle_iske()
300 vcpu->run->s.regs.gprs[reg1] |= key; in handle_iske()
311 vcpu->stat.instruction_rrbe++; in handle_rrbe()
313 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_rrbe()
318 return rc != -EAGAIN ? rc : 0; in handle_rrbe()
322 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_rrbe()
325 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_rrbe()
330 mmap_read_lock(current->mm); in handle_rrbe()
331 rc = reset_guest_reference_bit(current->mm, vmaddr); in handle_rrbe()
333 rc = fixup_user_fault(current->mm, vmaddr, in handle_rrbe()
336 mmap_read_unlock(current->mm); in handle_rrbe()
340 mmap_read_unlock(current->mm); in handle_rrbe()
341 if (rc == -EFAULT) in handle_rrbe()
355 unsigned char m3 = vcpu->arch.sie_block->ipb >> 28; in handle_sske()
362 vcpu->stat.instruction_sske++; in handle_sske()
364 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sske()
369 return rc != -EAGAIN ? rc : 0; in handle_sske()
371 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_sske()
373 if (!test_kvm_facility(vcpu->kvm, 10)) in handle_sske()
375 if (!test_kvm_facility(vcpu->kvm, 14)) in handle_sske()
380 key = vcpu->run->s.regs.gprs[reg1] & 0xfe; in handle_sske()
381 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_sske()
385 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_sske()
392 unsigned long vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_sske()
398 mmap_read_lock(current->mm); in handle_sske()
399 rc = cond_set_guest_storage_key(current->mm, vmaddr, key, &oldkey, in handle_sske()
404 rc = fixup_user_fault(current->mm, vmaddr, in handle_sske()
406 rc = !rc ? -EAGAIN : rc; in handle_sske()
408 mmap_read_unlock(current->mm); in handle_sske()
409 if (rc == -EFAULT) in handle_sske()
411 if (rc == -EAGAIN) in handle_sske()
424 vcpu->run->s.regs.gprs[reg1] &= ~0xff00UL; in handle_sske()
425 vcpu->run->s.regs.gprs[reg1] |= (u64) oldkey << 8; in handle_sske()
429 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) in handle_sske()
430 vcpu->run->s.regs.gprs[reg2] &= ~PAGE_MASK; in handle_sske()
432 vcpu->run->s.regs.gprs[reg2] &= ~0xfffff000UL; in handle_sske()
434 vcpu->run->s.regs.gprs[reg2] |= end; in handle_sske()
441 vcpu->stat.instruction_ipte_interlock++; in handle_ipte_interlock()
442 if (psw_bits(vcpu->arch.sie_block->gpsw).pstate) in handle_ipte_interlock()
444 wait_event(vcpu->kvm->arch.ipte_wq, !ipte_lock_held(vcpu->kvm)); in handle_ipte_interlock()
455 vcpu->stat.instruction_tb++; in handle_test_block()
457 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_test_block()
461 addr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_test_block()
464 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_test_block()
467 if (kvm_is_error_gpa(vcpu->kvm, addr)) in handle_test_block()
473 if (kvm_clear_guest(vcpu->kvm, addr, PAGE_SIZE)) in handle_test_block()
474 return -EFAULT; in handle_test_block()
476 vcpu->run->s.regs.gprs[0] = 0; in handle_test_block()
489 vcpu->stat.instruction_tpi++; in handle_tpi()
495 inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0); in handle_tpi()
501 tpi_data[0] = inti->io.subchannel_id << 16 | inti->io.subchannel_nr; in handle_tpi()
502 tpi_data[1] = inti->io.io_int_parm; in handle_tpi()
503 tpi_data[2] = inti->io.io_int_word; in handle_tpi()
506 * Store the two-word I/O interruption code into the in handle_tpi()
509 len = sizeof(tpi_data) - 4; in handle_tpi()
517 * Store the three-word I/O interruption code into in handle_tpi()
523 rc = -EFAULT; in handle_tpi()
538 if (kvm_s390_reinject_io_int(vcpu->kvm, inti)) { in handle_tpi()
540 rc = -EFAULT; in handle_tpi()
543 return rc ? -EFAULT : 0; in handle_tpi()
551 vcpu->stat.instruction_tsch++; in handle_tsch()
554 if (vcpu->run->s.regs.gprs[1]) in handle_tsch()
555 inti = kvm_s390_get_io_int(vcpu->kvm, isc_mask, in handle_tsch()
556 vcpu->run->s.regs.gprs[1]); in handle_tsch()
561 * so that userspace can re-inject it if the instruction gets in handle_tsch()
562 * a program check. While this may re-order the pending I/O in handle_tsch()
566 vcpu->run->exit_reason = KVM_EXIT_S390_TSCH; in handle_tsch()
567 vcpu->run->s390_tsch.dequeued = !!inti; in handle_tsch()
569 vcpu->run->s390_tsch.subchannel_id = inti->io.subchannel_id; in handle_tsch()
570 vcpu->run->s390_tsch.subchannel_nr = inti->io.subchannel_nr; in handle_tsch()
571 vcpu->run->s390_tsch.io_int_parm = inti->io.io_int_parm; in handle_tsch()
572 vcpu->run->s390_tsch.io_int_word = inti->io.io_int_word; in handle_tsch()
574 vcpu->run->s390_tsch.ipb = vcpu->arch.sie_block->ipb; in handle_tsch()
576 return -EREMOTE; in handle_tsch()
583 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_io_inst()
586 if (vcpu->kvm->arch.css_support) { in handle_io_inst()
591 if (vcpu->arch.sie_block->ipa == 0xb236) in handle_io_inst()
593 if (vcpu->arch.sie_block->ipa == 0xb235) in handle_io_inst()
596 vcpu->stat.instruction_io_other++; in handle_io_inst()
597 return -EOPNOTSUPP; in handle_io_inst()
633 return -EOPNOTSUPP; in handle_pqap()
635 if (!(vcpu->arch.sie_block->eca & ECA_APIE)) in handle_pqap()
636 return -EOPNOTSUPP; in handle_pqap()
645 reg0 = vcpu->run->s.regs.gprs[0]; in handle_pqap()
648 return -EOPNOTSUPP; in handle_pqap()
651 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pqap()
655 /* bits 41-47 must all be zeros */ in handle_pqap()
659 if (!test_kvm_facility(vcpu->kvm, 15) && (reg0 & 0x00800000UL)) in handle_pqap()
662 if (!(vcpu->kvm->arch.crypto.crycbd & 0x02) && (reg0 & 0x0000c0f0UL)) in handle_pqap()
667 if (!test_kvm_facility(vcpu->kvm, 65)) in handle_pqap()
675 down_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem); in handle_pqap()
676 if (vcpu->kvm->arch.crypto.pqap_hook) { in handle_pqap()
677 pqap_hook = *vcpu->kvm->arch.crypto.pqap_hook; in handle_pqap()
679 if (!ret && vcpu->run->s.regs.gprs[1] & 0x00ff0000) in handle_pqap()
681 up_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem); in handle_pqap()
684 up_read(&vcpu->kvm->arch.crypto.pqap_hook_rwsem); in handle_pqap()
691 memcpy(&vcpu->run->s.regs.gprs[1], &status, sizeof(status)); in handle_pqap()
701 vcpu->stat.instruction_stfl++; in handle_stfl()
703 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stfl()
707 * We need to shift the lower 32 facility bits (bit 0-31) from a u64 in handle_stfl()
708 * into a u32 memory representation. They will remain bits 0-31. in handle_stfl()
710 fac = *vcpu->kvm->arch.model.fac_list >> 32; in handle_stfl()
727 if (psw->mask & PSW_MASK_UNASSIGNED) in is_valid_psw()
729 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_BA) { in is_valid_psw()
730 if (psw->addr & ~PSW_ADDR_31) in is_valid_psw()
733 if (!(psw->mask & PSW_MASK_ADDR_MODE) && (psw->addr & ~PSW_ADDR_24)) in is_valid_psw()
735 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_EA) in is_valid_psw()
737 if (psw->addr & 1) in is_valid_psw()
744 psw_t *gpsw = &vcpu->arch.sie_block->gpsw; in kvm_s390_handle_lpsw()
750 vcpu->stat.instruction_lpsw++; in kvm_s390_handle_lpsw()
752 if (gpsw->mask & PSW_MASK_PSTATE) in kvm_s390_handle_lpsw()
764 gpsw->mask = (new_psw.mask & ~PSW32_MASK_BASE) << 32; in kvm_s390_handle_lpsw()
765 gpsw->mask |= new_psw.addr & PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
766 gpsw->addr = new_psw.addr & ~PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
779 vcpu->stat.instruction_lpswe++; in handle_lpswe()
781 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lpswe()
790 vcpu->arch.sie_block->gpsw = new_psw; in handle_lpswe()
791 if (!is_valid_psw(&vcpu->arch.sie_block->gpsw)) in handle_lpswe()
803 vcpu->stat.instruction_lpswey++; in handle_lpswey()
805 if (!test_kvm_facility(vcpu->kvm, 193)) in handle_lpswey()
808 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lpswey()
819 vcpu->arch.sie_block->gpsw = new_psw; in handle_lpswey()
820 if (!is_valid_psw(&vcpu->arch.sie_block->gpsw)) in handle_lpswey()
828 u64 stidp_data = vcpu->kvm->arch.model.cpuid; in handle_stidp()
833 vcpu->stat.instruction_stidp++; in handle_stidp()
835 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stidp()
856 cpus = atomic_read(&vcpu->kvm->online_vcpus); in handle_stsi_3_2_2()
860 mem->count = 0; in handle_stsi_3_2_2()
861 if (mem->count < 8) in handle_stsi_3_2_2()
862 mem->count++; in handle_stsi_3_2_2()
863 for (n = mem->count - 1; n > 0 ; n--) in handle_stsi_3_2_2()
864 memcpy(&mem->vm[n], &mem->vm[n - 1], sizeof(mem->vm[0])); in handle_stsi_3_2_2()
866 memset(&mem->vm[0], 0, sizeof(mem->vm[0])); in handle_stsi_3_2_2()
867 mem->vm[0].cpus_total = cpus; in handle_stsi_3_2_2()
868 mem->vm[0].cpus_configured = cpus; in handle_stsi_3_2_2()
869 mem->vm[0].cpus_standby = 0; in handle_stsi_3_2_2()
870 mem->vm[0].cpus_reserved = 0; in handle_stsi_3_2_2()
871 mem->vm[0].caf = 1000; in handle_stsi_3_2_2()
872 memcpy(mem->vm[0].name, "KVMguest", 8); in handle_stsi_3_2_2()
873 ASCEBC(mem->vm[0].name, 8); in handle_stsi_3_2_2()
874 memcpy(mem->vm[0].cpi, "KVM/Linux ", 16); in handle_stsi_3_2_2()
875 ASCEBC(mem->vm[0].cpi, 16); in handle_stsi_3_2_2()
881 vcpu->run->exit_reason = KVM_EXIT_S390_STSI; in insert_stsi_usr_data()
882 vcpu->run->s390_stsi.addr = addr; in insert_stsi_usr_data()
883 vcpu->run->s390_stsi.ar = ar; in insert_stsi_usr_data()
884 vcpu->run->s390_stsi.fc = fc; in insert_stsi_usr_data()
885 vcpu->run->s390_stsi.sel1 = sel1; in insert_stsi_usr_data()
886 vcpu->run->s390_stsi.sel2 = sel2; in insert_stsi_usr_data()
891 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28; in handle_stsi()
892 int sel1 = vcpu->run->s.regs.gprs[0] & 0xff; in handle_stsi()
893 int sel2 = vcpu->run->s.regs.gprs[1] & 0xffff; in handle_stsi()
899 vcpu->stat.instruction_stsi++; in handle_stsi()
902 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stsi()
911 * - PTF/CPU topology support through facility 15 in handle_stsi()
912 * - KVM_CAP_S390_USER_STSI in handle_stsi()
914 if (fc == 15 && (!test_kvm_facility(vcpu->kvm, 11) || in handle_stsi()
915 !vcpu->kvm->arch.user_stsi)) in handle_stsi()
918 if (vcpu->run->s.regs.gprs[0] & 0x0fffff00 in handle_stsi()
919 || vcpu->run->s.regs.gprs[1] & 0xffff0000) in handle_stsi()
923 vcpu->run->s.regs.gprs[0] = 3 << 28; in handle_stsi()
953 return -EREMOTE; in handle_stsi()
956 memcpy(sida_addr(vcpu->arch.sie_block), (void *)mem, PAGE_SIZE); in handle_stsi()
965 if (vcpu->kvm->arch.user_stsi) { in handle_stsi()
967 rc = -EREMOTE; in handle_stsi()
972 vcpu->run->s.regs.gprs[0] = 0; in handle_stsi()
983 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b2()
1035 return -EOPNOTSUPP; in kvm_s390_handle_b2()
1043 vcpu->stat.instruction_epsw++; in handle_epsw()
1048 vcpu->run->s.regs.gprs[reg1] &= 0xffffffff00000000UL; in handle_epsw()
1049 vcpu->run->s.regs.gprs[reg1] |= vcpu->arch.sie_block->gpsw.mask >> 32; in handle_epsw()
1051 vcpu->run->s.regs.gprs[reg2] &= 0xffffffff00000000UL; in handle_epsw()
1052 vcpu->run->s.regs.gprs[reg2] |= in handle_epsw()
1053 vcpu->arch.sie_block->gpsw.mask & 0x00000000ffffffffUL; in handle_epsw()
1075 vcpu->stat.instruction_pfmf++; in handle_pfmf()
1079 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_pfmf()
1082 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pfmf()
1085 if (vcpu->run->s.regs.gprs[reg1] & PFMF_RESERVED) in handle_pfmf()
1088 /* Only provide non-quiescing support if enabled for the guest */ in handle_pfmf()
1089 if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && in handle_pfmf()
1090 !test_kvm_facility(vcpu->kvm, 14)) in handle_pfmf()
1093 /* Only provide conditional-SSKE support if enabled for the guest */ in handle_pfmf()
1094 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK && in handle_pfmf()
1095 test_kvm_facility(vcpu->kvm, 10)) { in handle_pfmf()
1096 mr = vcpu->run->s.regs.gprs[reg1] & PFMF_MR; in handle_pfmf()
1097 mc = vcpu->run->s.regs.gprs[reg1] & PFMF_MC; in handle_pfmf()
1100 nq = vcpu->run->s.regs.gprs[reg1] & PFMF_NQ; in handle_pfmf()
1101 key = vcpu->run->s.regs.gprs[reg1] & PFMF_KEY; in handle_pfmf()
1102 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_pfmf()
1105 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1107 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_pfmf()
1110 switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1114 end = (start + PAGE_SIZE) & ~(PAGE_SIZE - 1); in handle_pfmf()
1117 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_pfmf()
1121 not in 24-bit addressing mode */ in handle_pfmf()
1122 if (!test_kvm_facility(vcpu->kvm, 78) || in handle_pfmf()
1123 psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_24BIT) in handle_pfmf()
1125 end = (start + _REGION3_SIZE) & ~(_REGION3_SIZE - 1); in handle_pfmf()
1136 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_pfmf()
1140 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1141 if (kvm_clear_guest(vcpu->kvm, start, PAGE_SIZE)) in handle_pfmf()
1145 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) { in handle_pfmf()
1150 mmap_read_lock(current->mm); in handle_pfmf()
1151 rc = cond_set_guest_storage_key(current->mm, vmaddr, in handle_pfmf()
1154 rc = fixup_user_fault(current->mm, vmaddr, in handle_pfmf()
1156 rc = !rc ? -EAGAIN : rc; in handle_pfmf()
1158 mmap_read_unlock(current->mm); in handle_pfmf()
1159 if (rc == -EFAULT) in handle_pfmf()
1161 if (rc == -EAGAIN) in handle_pfmf()
1168 if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1169 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) { in handle_pfmf()
1170 vcpu->run->s.regs.gprs[reg2] = end; in handle_pfmf()
1172 vcpu->run->s.regs.gprs[reg2] &= ~0xffffffffUL; in handle_pfmf()
1174 vcpu->run->s.regs.gprs[reg2] |= end; in handle_pfmf()
1181 * Must be called with relevant read locks held (kvm->mm->mmap_lock, kvm->srcu)
1195 gfn = vcpu->run->s.regs.gprs[r2] >> PAGE_SHIFT; in __do_essa()
1196 hva = gfn_to_hva(vcpu->kvm, gfn); in __do_essa()
1197 entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in __do_essa()
1202 nappended = pgste_perform_essa(vcpu->kvm->mm, hva, orc, &ptev, &pgstev); in __do_essa()
1205 vcpu->run->s.regs.gprs[r1] = res; /* Exception Indication */ in __do_essa()
1210 * Set the block-content state part of the result. 0 means resident, so in __do_essa()
1212 * (non-present and non-zero), and 3 for zero pages (non-present and in __do_essa()
1222 vcpu->run->s.regs.gprs[r1] = res; in __do_essa()
1230 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo & PAGE_MASK); in __do_essa()
1235 struct kvm_memory_slot *ms = gfn_to_memslot(vcpu->kvm, gfn); in __do_essa()
1238 if (ms && !test_and_set_bit(gfn - ms->base_gfn, kvm_second_dirty_bitmap(ms))) in __do_essa()
1239 atomic64_inc(&vcpu->kvm->arch.cmma_dirty_pages); in __do_essa()
1248 int entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in handle_essa()
1254 gmap = vcpu->arch.gmap; in handle_essa()
1255 vcpu->stat.instruction_essa++; in handle_essa()
1256 if (!vcpu->kvm->arch.use_cmma) in handle_essa()
1259 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_essa()
1262 orc = (vcpu->arch.sie_block->ipb & 0xf0000000) >> 28; in handle_essa()
1263 /* ORCs 0-6 are always valid */ in handle_essa()
1264 if (orc > (test_kvm_facility(vcpu->kvm, 147) ? ESSA_SET_STABLE_NODAT in handle_essa()
1268 if (!vcpu->kvm->arch.migration_mode) { in handle_essa()
1270 * CMMA is enabled in the KVM settings, but is disabled in in handle_essa()
1278 if (vcpu->kvm->mm->context.uses_cmm == 0) { in handle_essa()
1279 mmap_write_lock(vcpu->kvm->mm); in handle_essa()
1280 vcpu->kvm->mm->context.uses_cmm = 1; in handle_essa()
1281 mmap_write_unlock(vcpu->kvm->mm); in handle_essa()
1284 * If we are here, we are supposed to have CMMA enabled in in handle_essa()
1285 * the SIE block. Enabling CMMA works on a per-CPU basis, in handle_essa()
1287 * It's possible that the context flag is enabled and the in handle_essa()
1292 vcpu->arch.sie_block->ecb2 |= ECB2_CMMA; in handle_essa()
1298 mmap_read_lock(vcpu->kvm->mm); in handle_essa()
1299 srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in handle_essa()
1301 srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); in handle_essa()
1302 mmap_read_unlock(vcpu->kvm->mm); in handle_essa()
1308 vcpu->arch.sie_block->cbrlo &= PAGE_MASK; /* reset nceo */ in handle_essa()
1309 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo); in handle_essa()
1310 mmap_read_lock(gmap->mm); in handle_essa()
1313 mmap_read_unlock(gmap->mm); in handle_essa()
1319 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b9()
1331 return -EOPNOTSUPP; in kvm_s390_handle_b9()
1337 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_lctl()
1338 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_lctl()
1344 vcpu->stat.instruction_lctl++; in kvm_s390_handle_lctl()
1346 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_lctl()
1357 nr_regs = ((reg3 - reg1) & 0xf) + 1; in kvm_s390_handle_lctl()
1364 vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul; in kvm_s390_handle_lctl()
1365 vcpu->arch.sie_block->gcr[reg] |= ctl_array[nr_regs++]; in kvm_s390_handle_lctl()
1376 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_stctl()
1377 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_stctl()
1383 vcpu->stat.instruction_stctl++; in kvm_s390_handle_stctl()
1385 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_stctl()
1399 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in kvm_s390_handle_stctl()
1410 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_lctlg()
1411 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_lctlg()
1417 vcpu->stat.instruction_lctlg++; in handle_lctlg()
1419 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lctlg()
1430 nr_regs = ((reg3 - reg1) & 0xf) + 1; in handle_lctlg()
1437 vcpu->arch.sie_block->gcr[reg] = ctl_array[nr_regs++]; in handle_lctlg()
1448 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_stctg()
1449 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_stctg()
1455 vcpu->stat.instruction_stctg++; in handle_stctg()
1457 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stctg()
1471 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in handle_stctg()
1482 switch (vcpu->arch.sie_block->ipb & 0x000000ff) { in kvm_s390_handle_eb()
1494 return -EOPNOTSUPP; in kvm_s390_handle_eb()
1507 vcpu->stat.instruction_tprot++; in handle_tprot()
1509 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_tprot()
1515 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1516 ipte_lock(vcpu->kvm); in handle_tprot()
1521 gfn_to_hva_prot(vcpu->kvm, gpa_to_gfn(gpa), &writable); in handle_tprot()
1524 /* Write protected? Try again with read-only... */ in handle_tprot()
1529 cc = -1; in handle_tprot()
1544 if (cc != -1) { in handle_tprot()
1552 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1553 ipte_unlock(vcpu->kvm); in handle_tprot()
1559 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_e5()
1563 return -EOPNOTSUPP; in kvm_s390_handle_e5()
1571 vcpu->stat.instruction_sckpf++; in handle_sckpf()
1573 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sckpf()
1576 if (vcpu->run->s.regs.gprs[0] & 0x00000000ffff0000) in handle_sckpf()
1580 value = vcpu->run->s.regs.gprs[0] & 0x000000000000ffff; in handle_sckpf()
1581 vcpu->arch.sie_block->todpr = value; in handle_sckpf()
1588 vcpu->stat.instruction_ptff++; in handle_ptff()
1597 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_01()
1603 return -EOPNOTSUPP; in kvm_s390_handle_01()