Lines Matching +full:ipa +full:- +full:clock +full:- +full:enabled +full:- +full:valid

1 // SPDX-License-Identifier: GPL-2.0
18 #include <asm/asm-offsets.h>
24 #include <asm/page-states.h>
31 #include "kvm-s390.h"
36 vcpu->stat.instruction_ri++; in handle_ri()
38 if (test_kvm_facility(vcpu->kvm, 64)) { in handle_ri()
40 vcpu->arch.sie_block->ecb3 |= ECB3_RI; in handle_ri()
49 if ((vcpu->arch.sie_block->ipa & 0xf) <= 4) in kvm_s390_handle_aa()
52 return -EOPNOTSUPP; in kvm_s390_handle_aa()
57 vcpu->stat.instruction_gs++; in handle_gs()
59 if (test_kvm_facility(vcpu->kvm, 133)) { in handle_gs()
63 current->thread.gs_cb = (struct gs_cb *)&vcpu->run->s.regs.gscb; in handle_gs()
64 restore_gs_cb(current->thread.gs_cb); in handle_gs()
66 vcpu->arch.sie_block->ecb |= ECB_GS; in handle_gs()
67 vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT; in handle_gs()
68 vcpu->arch.gs_enabled = 1; in handle_gs()
77 int code = vcpu->arch.sie_block->ipb & 0xff; in kvm_s390_handle_e3()
82 return -EOPNOTSUPP; in kvm_s390_handle_e3()
84 /* Handle SCK (SET CLOCK) interception */
92 vcpu->stat.instruction_sck++; in handle_set_clock()
94 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_set_clock()
105 kvm_s390_set_tod_clock(vcpu->kvm, &gtod); in handle_set_clock()
118 vcpu->stat.instruction_spx++; in handle_set_prefix()
120 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_set_prefix()
137 * Make sure the new value is valid memory. We only need to check the in handle_set_prefix()
141 if (kvm_is_error_gpa(vcpu->kvm, address)) in handle_set_prefix()
156 vcpu->stat.instruction_stpx++; in handle_store_prefix()
158 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_prefix()
181 u16 vcpu_id = vcpu->vcpu_id; in handle_store_cpu_address()
186 vcpu->stat.instruction_stap++; in handle_store_cpu_address()
188 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_cpu_address()
210 /* Already enabled? */ in kvm_s390_skey_check_enable()
211 if (vcpu->arch.skey_enabled) in kvm_s390_skey_check_enable()
221 if (!vcpu->kvm->arch.use_skf) in kvm_s390_skey_check_enable()
222 vcpu->arch.sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE; in kvm_s390_skey_check_enable()
224 vcpu->arch.sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE | ICTL_RRBE); in kvm_s390_skey_check_enable()
225 vcpu->arch.skey_enabled = true; in kvm_s390_skey_check_enable()
236 if (vcpu->kvm->arch.use_skf) { in try_handle_skey()
237 /* with storage-key facility, SIE interprets it for us */ in try_handle_skey()
240 return -EAGAIN; in try_handle_skey()
253 vcpu->stat.instruction_iske++; in handle_iske()
255 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_iske()
260 return rc != -EAGAIN ? rc : 0; in handle_iske()
264 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_iske()
267 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_iske()
272 mmap_read_lock(current->mm); in handle_iske()
273 rc = get_guest_storage_key(current->mm, vmaddr, &key); in handle_iske()
276 rc = fixup_user_fault(current->mm, vmaddr, in handle_iske()
279 mmap_read_unlock(current->mm); in handle_iske()
283 mmap_read_unlock(current->mm); in handle_iske()
284 if (rc == -EFAULT) in handle_iske()
288 vcpu->run->s.regs.gprs[reg1] &= ~0xff; in handle_iske()
289 vcpu->run->s.regs.gprs[reg1] |= key; in handle_iske()
300 vcpu->stat.instruction_rrbe++; in handle_rrbe()
302 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_rrbe()
307 return rc != -EAGAIN ? rc : 0; in handle_rrbe()
311 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_rrbe()
314 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_rrbe()
319 mmap_read_lock(current->mm); in handle_rrbe()
320 rc = reset_guest_reference_bit(current->mm, vmaddr); in handle_rrbe()
322 rc = fixup_user_fault(current->mm, vmaddr, in handle_rrbe()
325 mmap_read_unlock(current->mm); in handle_rrbe()
329 mmap_read_unlock(current->mm); in handle_rrbe()
330 if (rc == -EFAULT) in handle_rrbe()
344 unsigned char m3 = vcpu->arch.sie_block->ipb >> 28; in handle_sske()
351 vcpu->stat.instruction_sske++; in handle_sske()
353 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sske()
358 return rc != -EAGAIN ? rc : 0; in handle_sske()
360 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_sske()
362 if (!test_kvm_facility(vcpu->kvm, 10)) in handle_sske()
364 if (!test_kvm_facility(vcpu->kvm, 14)) in handle_sske()
369 key = vcpu->run->s.regs.gprs[reg1] & 0xfe; in handle_sske()
370 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_sske()
374 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_sske()
381 unsigned long vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_sske()
387 mmap_read_lock(current->mm); in handle_sske()
388 rc = cond_set_guest_storage_key(current->mm, vmaddr, key, &oldkey, in handle_sske()
393 rc = fixup_user_fault(current->mm, vmaddr, in handle_sske()
395 rc = !rc ? -EAGAIN : rc; in handle_sske()
397 mmap_read_unlock(current->mm); in handle_sske()
398 if (rc == -EFAULT) in handle_sske()
411 vcpu->run->s.regs.gprs[reg1] &= ~0xff00UL; in handle_sske()
412 vcpu->run->s.regs.gprs[reg1] |= (u64) oldkey << 8; in handle_sske()
416 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) in handle_sske()
417 vcpu->run->s.regs.gprs[reg2] &= ~PAGE_MASK; in handle_sske()
419 vcpu->run->s.regs.gprs[reg2] &= ~0xfffff000UL; in handle_sske()
421 vcpu->run->s.regs.gprs[reg2] |= end; in handle_sske()
428 vcpu->stat.instruction_ipte_interlock++; in handle_ipte_interlock()
429 if (psw_bits(vcpu->arch.sie_block->gpsw).pstate) in handle_ipte_interlock()
431 wait_event(vcpu->kvm->arch.ipte_wq, !ipte_lock_held(vcpu)); in handle_ipte_interlock()
442 vcpu->stat.instruction_tb++; in handle_test_block()
444 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_test_block()
448 addr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_test_block()
451 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_test_block()
454 if (kvm_is_error_gpa(vcpu->kvm, addr)) in handle_test_block()
460 if (kvm_clear_guest(vcpu->kvm, addr, PAGE_SIZE)) in handle_test_block()
461 return -EFAULT; in handle_test_block()
463 vcpu->run->s.regs.gprs[0] = 0; in handle_test_block()
476 vcpu->stat.instruction_tpi++; in handle_tpi()
482 inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0); in handle_tpi()
488 tpi_data[0] = inti->io.subchannel_id << 16 | inti->io.subchannel_nr; in handle_tpi()
489 tpi_data[1] = inti->io.io_int_parm; in handle_tpi()
490 tpi_data[2] = inti->io.io_int_word; in handle_tpi()
493 * Store the two-word I/O interruption code into the in handle_tpi()
496 len = sizeof(tpi_data) - 4; in handle_tpi()
504 * Store the three-word I/O interruption code into in handle_tpi()
510 rc = -EFAULT; in handle_tpi()
525 if (kvm_s390_reinject_io_int(vcpu->kvm, inti)) { in handle_tpi()
527 rc = -EFAULT; in handle_tpi()
530 return rc ? -EFAULT : 0; in handle_tpi()
538 vcpu->stat.instruction_tsch++; in handle_tsch()
540 /* a valid schid has at least one bit set */ in handle_tsch()
541 if (vcpu->run->s.regs.gprs[1]) in handle_tsch()
542 inti = kvm_s390_get_io_int(vcpu->kvm, isc_mask, in handle_tsch()
543 vcpu->run->s.regs.gprs[1]); in handle_tsch()
548 * so that userspace can re-inject it if the instruction gets in handle_tsch()
549 * a program check. While this may re-order the pending I/O in handle_tsch()
553 vcpu->run->exit_reason = KVM_EXIT_S390_TSCH; in handle_tsch()
554 vcpu->run->s390_tsch.dequeued = !!inti; in handle_tsch()
556 vcpu->run->s390_tsch.subchannel_id = inti->io.subchannel_id; in handle_tsch()
557 vcpu->run->s390_tsch.subchannel_nr = inti->io.subchannel_nr; in handle_tsch()
558 vcpu->run->s390_tsch.io_int_parm = inti->io.io_int_parm; in handle_tsch()
559 vcpu->run->s390_tsch.io_int_word = inti->io.io_int_word; in handle_tsch()
561 vcpu->run->s390_tsch.ipb = vcpu->arch.sie_block->ipb; in handle_tsch()
563 return -EREMOTE; in handle_tsch()
570 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_io_inst()
573 if (vcpu->kvm->arch.css_support) { in handle_io_inst()
578 if (vcpu->arch.sie_block->ipa == 0xb236) in handle_io_inst()
580 if (vcpu->arch.sie_block->ipa == 0xb235) in handle_io_inst()
583 vcpu->stat.instruction_io_other++; in handle_io_inst()
584 return -EOPNOTSUPP; in handle_io_inst()
619 return -EOPNOTSUPP; in handle_pqap()
621 if (!(vcpu->arch.sie_block->eca & ECA_APIE)) in handle_pqap()
622 return -EOPNOTSUPP; in handle_pqap()
631 reg0 = vcpu->run->s.regs.gprs[0]; in handle_pqap()
634 return -EOPNOTSUPP; in handle_pqap()
637 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pqap()
641 /* bits 41-47 must all be zeros */ in handle_pqap()
645 if (!test_kvm_facility(vcpu->kvm, 15) && (reg0 & 0x00800000UL)) in handle_pqap()
648 if (!(vcpu->kvm->arch.crypto.crycbd & 0x02) && (reg0 & 0x0000c0f0UL)) in handle_pqap()
653 if (!test_kvm_facility(vcpu->kvm, 65)) in handle_pqap()
660 if (vcpu->kvm->arch.crypto.pqap_hook) { in handle_pqap()
661 if (!try_module_get(vcpu->kvm->arch.crypto.pqap_hook->owner)) in handle_pqap()
662 return -EOPNOTSUPP; in handle_pqap()
663 ret = vcpu->kvm->arch.crypto.pqap_hook->hook(vcpu); in handle_pqap()
664 module_put(vcpu->kvm->arch.crypto.pqap_hook->owner); in handle_pqap()
665 if (!ret && vcpu->run->s.regs.gprs[1] & 0x00ff0000) in handle_pqap()
675 memcpy(&vcpu->run->s.regs.gprs[1], &status, sizeof(status)); in handle_pqap()
685 vcpu->stat.instruction_stfl++; in handle_stfl()
687 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stfl()
691 * We need to shift the lower 32 facility bits (bit 0-31) from a u64 in handle_stfl()
692 * into a u32 memory representation. They will remain bits 0-31. in handle_stfl()
694 fac = *vcpu->kvm->arch.model.fac_list >> 32; in handle_stfl()
711 if (psw->mask & PSW_MASK_UNASSIGNED) in is_valid_psw()
713 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_BA) { in is_valid_psw()
714 if (psw->addr & ~PSW_ADDR_31) in is_valid_psw()
717 if (!(psw->mask & PSW_MASK_ADDR_MODE) && (psw->addr & ~PSW_ADDR_24)) in is_valid_psw()
719 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_EA) in is_valid_psw()
721 if (psw->addr & 1) in is_valid_psw()
728 psw_t *gpsw = &vcpu->arch.sie_block->gpsw; in kvm_s390_handle_lpsw()
734 vcpu->stat.instruction_lpsw++; in kvm_s390_handle_lpsw()
736 if (gpsw->mask & PSW_MASK_PSTATE) in kvm_s390_handle_lpsw()
748 gpsw->mask = (new_psw.mask & ~PSW32_MASK_BASE) << 32; in kvm_s390_handle_lpsw()
749 gpsw->mask |= new_psw.addr & PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
750 gpsw->addr = new_psw.addr & ~PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
763 vcpu->stat.instruction_lpswe++; in handle_lpswe()
765 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lpswe()
774 vcpu->arch.sie_block->gpsw = new_psw; in handle_lpswe()
775 if (!is_valid_psw(&vcpu->arch.sie_block->gpsw)) in handle_lpswe()
782 u64 stidp_data = vcpu->kvm->arch.model.cpuid; in handle_stidp()
787 vcpu->stat.instruction_stidp++; in handle_stidp()
789 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stidp()
810 cpus = atomic_read(&vcpu->kvm->online_vcpus); in handle_stsi_3_2_2()
814 mem->count = 0; in handle_stsi_3_2_2()
815 if (mem->count < 8) in handle_stsi_3_2_2()
816 mem->count++; in handle_stsi_3_2_2()
817 for (n = mem->count - 1; n > 0 ; n--) in handle_stsi_3_2_2()
818 memcpy(&mem->vm[n], &mem->vm[n - 1], sizeof(mem->vm[0])); in handle_stsi_3_2_2()
820 memset(&mem->vm[0], 0, sizeof(mem->vm[0])); in handle_stsi_3_2_2()
821 mem->vm[0].cpus_total = cpus; in handle_stsi_3_2_2()
822 mem->vm[0].cpus_configured = cpus; in handle_stsi_3_2_2()
823 mem->vm[0].cpus_standby = 0; in handle_stsi_3_2_2()
824 mem->vm[0].cpus_reserved = 0; in handle_stsi_3_2_2()
825 mem->vm[0].caf = 1000; in handle_stsi_3_2_2()
826 memcpy(mem->vm[0].name, "KVMguest", 8); in handle_stsi_3_2_2()
827 ASCEBC(mem->vm[0].name, 8); in handle_stsi_3_2_2()
828 memcpy(mem->vm[0].cpi, "KVM/Linux ", 16); in handle_stsi_3_2_2()
829 ASCEBC(mem->vm[0].cpi, 16); in handle_stsi_3_2_2()
835 vcpu->run->exit_reason = KVM_EXIT_S390_STSI; in insert_stsi_usr_data()
836 vcpu->run->s390_stsi.addr = addr; in insert_stsi_usr_data()
837 vcpu->run->s390_stsi.ar = ar; in insert_stsi_usr_data()
838 vcpu->run->s390_stsi.fc = fc; in insert_stsi_usr_data()
839 vcpu->run->s390_stsi.sel1 = sel1; in insert_stsi_usr_data()
840 vcpu->run->s390_stsi.sel2 = sel2; in insert_stsi_usr_data()
845 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28; in handle_stsi()
846 int sel1 = vcpu->run->s.regs.gprs[0] & 0xff; in handle_stsi()
847 int sel2 = vcpu->run->s.regs.gprs[1] & 0xffff; in handle_stsi()
853 vcpu->stat.instruction_stsi++; in handle_stsi()
856 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stsi()
864 if (vcpu->run->s.regs.gprs[0] & 0x0fffff00 in handle_stsi()
865 || vcpu->run->s.regs.gprs[1] & 0xffff0000) in handle_stsi()
869 vcpu->run->s.regs.gprs[0] = 3 << 28; in handle_stsi()
898 memcpy((void *)sida_origin(vcpu->arch.sie_block), (void *)mem, in handle_stsi()
908 if (vcpu->kvm->arch.user_stsi) { in handle_stsi()
910 rc = -EREMOTE; in handle_stsi()
915 vcpu->run->s.regs.gprs[0] = 0; in handle_stsi()
926 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b2()
978 return -EOPNOTSUPP; in kvm_s390_handle_b2()
986 vcpu->stat.instruction_epsw++; in handle_epsw()
991 vcpu->run->s.regs.gprs[reg1] &= 0xffffffff00000000UL; in handle_epsw()
992 vcpu->run->s.regs.gprs[reg1] |= vcpu->arch.sie_block->gpsw.mask >> 32; in handle_epsw()
994 vcpu->run->s.regs.gprs[reg2] &= 0xffffffff00000000UL; in handle_epsw()
995 vcpu->run->s.regs.gprs[reg2] |= in handle_epsw()
996 vcpu->arch.sie_block->gpsw.mask & 0x00000000ffffffffUL; in handle_epsw()
1018 vcpu->stat.instruction_pfmf++; in handle_pfmf()
1022 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_pfmf()
1025 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pfmf()
1028 if (vcpu->run->s.regs.gprs[reg1] & PFMF_RESERVED) in handle_pfmf()
1031 /* Only provide non-quiescing support if enabled for the guest */ in handle_pfmf()
1032 if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && in handle_pfmf()
1033 !test_kvm_facility(vcpu->kvm, 14)) in handle_pfmf()
1036 /* Only provide conditional-SSKE support if enabled for the guest */ in handle_pfmf()
1037 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK && in handle_pfmf()
1038 test_kvm_facility(vcpu->kvm, 10)) { in handle_pfmf()
1039 mr = vcpu->run->s.regs.gprs[reg1] & PFMF_MR; in handle_pfmf()
1040 mc = vcpu->run->s.regs.gprs[reg1] & PFMF_MC; in handle_pfmf()
1043 nq = vcpu->run->s.regs.gprs[reg1] & PFMF_NQ; in handle_pfmf()
1044 key = vcpu->run->s.regs.gprs[reg1] & PFMF_KEY; in handle_pfmf()
1045 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_pfmf()
1048 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1050 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_pfmf()
1053 switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1057 end = (start + PAGE_SIZE) & ~(PAGE_SIZE - 1); in handle_pfmf()
1060 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_pfmf()
1064 not in 24-bit addressing mode */ in handle_pfmf()
1065 if (!test_kvm_facility(vcpu->kvm, 78) || in handle_pfmf()
1066 psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_24BIT) in handle_pfmf()
1068 end = (start + _REGION3_SIZE) & ~(_REGION3_SIZE - 1); in handle_pfmf()
1079 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_pfmf()
1083 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1084 if (kvm_clear_guest(vcpu->kvm, start, PAGE_SIZE)) in handle_pfmf()
1088 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) { in handle_pfmf()
1093 mmap_read_lock(current->mm); in handle_pfmf()
1094 rc = cond_set_guest_storage_key(current->mm, vmaddr, in handle_pfmf()
1097 rc = fixup_user_fault(current->mm, vmaddr, in handle_pfmf()
1099 rc = !rc ? -EAGAIN : rc; in handle_pfmf()
1101 mmap_read_unlock(current->mm); in handle_pfmf()
1102 if (rc == -EFAULT) in handle_pfmf()
1104 if (rc == -EAGAIN) in handle_pfmf()
1111 if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1112 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) { in handle_pfmf()
1113 vcpu->run->s.regs.gprs[reg2] = end; in handle_pfmf()
1115 vcpu->run->s.regs.gprs[reg2] &= ~0xffffffffUL; in handle_pfmf()
1117 vcpu->run->s.regs.gprs[reg2] |= end; in handle_pfmf()
1124 * Must be called with relevant read locks held (kvm->mm->mmap_lock, kvm->srcu)
1138 gfn = vcpu->run->s.regs.gprs[r2] >> PAGE_SHIFT; in __do_essa()
1139 hva = gfn_to_hva(vcpu->kvm, gfn); in __do_essa()
1140 entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in __do_essa()
1145 nappended = pgste_perform_essa(vcpu->kvm->mm, hva, orc, &ptev, &pgstev); in __do_essa()
1148 vcpu->run->s.regs.gprs[r1] = res; /* Exception Indication */ in __do_essa()
1153 * Set the block-content state part of the result. 0 means resident, so in __do_essa()
1154 * nothing to do if the page is valid. 2 is for preserved pages in __do_essa()
1155 * (non-present and non-zero), and 3 for zero pages (non-present and in __do_essa()
1165 vcpu->run->s.regs.gprs[r1] = res; in __do_essa()
1173 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo & PAGE_MASK); in __do_essa()
1178 struct kvm_memory_slot *ms = gfn_to_memslot(vcpu->kvm, gfn); in __do_essa()
1181 if (ms && !test_and_set_bit(gfn - ms->base_gfn, kvm_second_dirty_bitmap(ms))) in __do_essa()
1182 atomic64_inc(&vcpu->kvm->arch.cmma_dirty_pages); in __do_essa()
1191 int entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in handle_essa()
1197 gmap = vcpu->arch.gmap; in handle_essa()
1198 vcpu->stat.instruction_essa++; in handle_essa()
1199 if (!vcpu->kvm->arch.use_cmma) in handle_essa()
1202 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_essa()
1205 orc = (vcpu->arch.sie_block->ipb & 0xf0000000) >> 28; in handle_essa()
1206 /* ORCs 0-6 are always valid */ in handle_essa()
1207 if (orc > (test_kvm_facility(vcpu->kvm, 147) ? ESSA_SET_STABLE_NODAT in handle_essa()
1211 if (!vcpu->kvm->arch.migration_mode) { in handle_essa()
1213 * CMMA is enabled in the KVM settings, but is disabled in in handle_essa()
1221 if (vcpu->kvm->mm->context.uses_cmm == 0) { in handle_essa()
1222 mmap_write_lock(vcpu->kvm->mm); in handle_essa()
1223 vcpu->kvm->mm->context.uses_cmm = 1; in handle_essa()
1224 mmap_write_unlock(vcpu->kvm->mm); in handle_essa()
1227 * If we are here, we are supposed to have CMMA enabled in in handle_essa()
1228 * the SIE block. Enabling CMMA works on a per-CPU basis, in handle_essa()
1230 * It's possible that the context flag is enabled and the in handle_essa()
1235 vcpu->arch.sie_block->ecb2 |= ECB2_CMMA; in handle_essa()
1241 mmap_read_lock(vcpu->kvm->mm); in handle_essa()
1242 srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in handle_essa()
1244 srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); in handle_essa()
1245 mmap_read_unlock(vcpu->kvm->mm); in handle_essa()
1251 vcpu->arch.sie_block->cbrlo &= PAGE_MASK; /* reset nceo */ in handle_essa()
1252 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo); in handle_essa()
1253 mmap_read_lock(gmap->mm); in handle_essa()
1256 mmap_read_unlock(gmap->mm); in handle_essa()
1262 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b9()
1274 return -EOPNOTSUPP; in kvm_s390_handle_b9()
1280 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_lctl()
1281 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_lctl()
1287 vcpu->stat.instruction_lctl++; in kvm_s390_handle_lctl()
1289 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_lctl()
1300 nr_regs = ((reg3 - reg1) & 0xf) + 1; in kvm_s390_handle_lctl()
1307 vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul; in kvm_s390_handle_lctl()
1308 vcpu->arch.sie_block->gcr[reg] |= ctl_array[nr_regs++]; in kvm_s390_handle_lctl()
1319 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_stctl()
1320 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_stctl()
1326 vcpu->stat.instruction_stctl++; in kvm_s390_handle_stctl()
1328 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_stctl()
1342 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in kvm_s390_handle_stctl()
1353 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_lctlg()
1354 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_lctlg()
1360 vcpu->stat.instruction_lctlg++; in handle_lctlg()
1362 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lctlg()
1373 nr_regs = ((reg3 - reg1) & 0xf) + 1; in handle_lctlg()
1380 vcpu->arch.sie_block->gcr[reg] = ctl_array[nr_regs++]; in handle_lctlg()
1391 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_stctg()
1392 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_stctg()
1398 vcpu->stat.instruction_stctg++; in handle_stctg()
1400 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stctg()
1414 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in handle_stctg()
1425 switch (vcpu->arch.sie_block->ipb & 0x000000ff) { in kvm_s390_handle_eb()
1435 return -EOPNOTSUPP; in kvm_s390_handle_eb()
1447 vcpu->stat.instruction_tprot++; in handle_tprot()
1449 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_tprot()
1458 return -EOPNOTSUPP; in handle_tprot()
1459 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1463 /* Write protected? Try again with read-only... */ in handle_tprot()
1479 hva = gfn_to_hva_prot(vcpu->kvm, gpa_to_gfn(gpa), &writable); in handle_tprot()
1484 cc = 1; /* Write not permitted ==> read-only */ in handle_tprot()
1489 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1496 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_e5()
1500 return -EOPNOTSUPP; in kvm_s390_handle_e5()
1508 vcpu->stat.instruction_sckpf++; in handle_sckpf()
1510 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sckpf()
1513 if (vcpu->run->s.regs.gprs[0] & 0x00000000ffff0000) in handle_sckpf()
1517 value = vcpu->run->s.regs.gprs[0] & 0x000000000000ffff; in handle_sckpf()
1518 vcpu->arch.sie_block->todpr = value; in handle_sckpf()
1525 vcpu->stat.instruction_ptff++; in handle_ptff()
1534 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_01()
1540 return -EOPNOTSUPP; in kvm_s390_handle_01()