Lines Matching +full:ipa +full:- +full:clock +full:- +full:enabled
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()
106 * To set the TOD clock the kvm lock must be taken, but the vcpu lock in handle_set_clock()
109 * cases, for example when the multiple epoch facility or TOD clock in handle_set_clock()
112 * the instruction will be retried via -EAGAIN at a later point in in handle_set_clock()
115 if (!kvm_s390_try_set_tod_clock(vcpu->kvm, >od)) { in handle_set_clock()
117 return -EAGAIN; in handle_set_clock()
131 vcpu->stat.instruction_spx++; in handle_set_prefix()
133 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_set_prefix()
154 if (kvm_is_error_gpa(vcpu->kvm, address)) in handle_set_prefix()
169 vcpu->stat.instruction_stpx++; in handle_store_prefix()
171 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_prefix()
194 u16 vcpu_id = vcpu->vcpu_id; in handle_store_cpu_address()
199 vcpu->stat.instruction_stap++; in handle_store_cpu_address()
201 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_store_cpu_address()
223 /* Already enabled? */ in kvm_s390_skey_check_enable()
224 if (vcpu->arch.skey_enabled) in kvm_s390_skey_check_enable()
234 if (!vcpu->kvm->arch.use_skf) in kvm_s390_skey_check_enable()
235 vcpu->arch.sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE; in kvm_s390_skey_check_enable()
237 vcpu->arch.sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE | ICTL_RRBE); in kvm_s390_skey_check_enable()
238 vcpu->arch.skey_enabled = true; in kvm_s390_skey_check_enable()
249 if (vcpu->kvm->arch.use_skf) { in try_handle_skey()
250 /* with storage-key facility, SIE interprets it for us */ in try_handle_skey()
253 return -EAGAIN; in try_handle_skey()
266 vcpu->stat.instruction_iske++; in handle_iske()
268 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_iske()
273 return rc != -EAGAIN ? rc : 0; in handle_iske()
277 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_iske()
280 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_iske()
285 mmap_read_lock(current->mm); in handle_iske()
286 rc = get_guest_storage_key(current->mm, vmaddr, &key); in handle_iske()
289 rc = fixup_user_fault(current->mm, vmaddr, in handle_iske()
292 mmap_read_unlock(current->mm); in handle_iske()
296 mmap_read_unlock(current->mm); in handle_iske()
297 if (rc == -EFAULT) in handle_iske()
301 vcpu->run->s.regs.gprs[reg1] &= ~0xff; in handle_iske()
302 vcpu->run->s.regs.gprs[reg1] |= key; in handle_iske()
313 vcpu->stat.instruction_rrbe++; in handle_rrbe()
315 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_rrbe()
320 return rc != -EAGAIN ? rc : 0; in handle_rrbe()
324 gaddr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_rrbe()
327 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(gaddr)); in handle_rrbe()
332 mmap_read_lock(current->mm); in handle_rrbe()
333 rc = reset_guest_reference_bit(current->mm, vmaddr); in handle_rrbe()
335 rc = fixup_user_fault(current->mm, vmaddr, in handle_rrbe()
338 mmap_read_unlock(current->mm); in handle_rrbe()
342 mmap_read_unlock(current->mm); in handle_rrbe()
343 if (rc == -EFAULT) in handle_rrbe()
357 unsigned char m3 = vcpu->arch.sie_block->ipb >> 28; in handle_sske()
364 vcpu->stat.instruction_sske++; in handle_sske()
366 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sske()
371 return rc != -EAGAIN ? rc : 0; in handle_sske()
373 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_sske()
375 if (!test_kvm_facility(vcpu->kvm, 10)) in handle_sske()
377 if (!test_kvm_facility(vcpu->kvm, 14)) in handle_sske()
382 key = vcpu->run->s.regs.gprs[reg1] & 0xfe; in handle_sske()
383 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_sske()
387 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_sske()
394 unsigned long vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_sske()
400 mmap_read_lock(current->mm); in handle_sske()
401 rc = cond_set_guest_storage_key(current->mm, vmaddr, key, &oldkey, in handle_sske()
406 rc = fixup_user_fault(current->mm, vmaddr, in handle_sske()
408 rc = !rc ? -EAGAIN : rc; in handle_sske()
410 mmap_read_unlock(current->mm); in handle_sske()
411 if (rc == -EFAULT) in handle_sske()
413 if (rc == -EAGAIN) in handle_sske()
426 vcpu->run->s.regs.gprs[reg1] &= ~0xff00UL; in handle_sske()
427 vcpu->run->s.regs.gprs[reg1] |= (u64) oldkey << 8; in handle_sske()
431 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) in handle_sske()
432 vcpu->run->s.regs.gprs[reg2] &= ~PAGE_MASK; in handle_sske()
434 vcpu->run->s.regs.gprs[reg2] &= ~0xfffff000UL; in handle_sske()
436 vcpu->run->s.regs.gprs[reg2] |= end; in handle_sske()
443 vcpu->stat.instruction_ipte_interlock++; in handle_ipte_interlock()
444 if (psw_bits(vcpu->arch.sie_block->gpsw).pstate) in handle_ipte_interlock()
446 wait_event(vcpu->kvm->arch.ipte_wq, !ipte_lock_held(vcpu)); in handle_ipte_interlock()
457 vcpu->stat.instruction_tb++; in handle_test_block()
459 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_test_block()
463 addr = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_test_block()
466 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_test_block()
469 if (kvm_is_error_gpa(vcpu->kvm, addr)) in handle_test_block()
475 if (kvm_clear_guest(vcpu->kvm, addr, PAGE_SIZE)) in handle_test_block()
476 return -EFAULT; in handle_test_block()
478 vcpu->run->s.regs.gprs[0] = 0; in handle_test_block()
491 vcpu->stat.instruction_tpi++; in handle_tpi()
497 inti = kvm_s390_get_io_int(vcpu->kvm, vcpu->arch.sie_block->gcr[6], 0); in handle_tpi()
503 tpi_data[0] = inti->io.subchannel_id << 16 | inti->io.subchannel_nr; in handle_tpi()
504 tpi_data[1] = inti->io.io_int_parm; in handle_tpi()
505 tpi_data[2] = inti->io.io_int_word; in handle_tpi()
508 * Store the two-word I/O interruption code into the in handle_tpi()
511 len = sizeof(tpi_data) - 4; in handle_tpi()
519 * Store the three-word I/O interruption code into in handle_tpi()
525 rc = -EFAULT; in handle_tpi()
540 if (kvm_s390_reinject_io_int(vcpu->kvm, inti)) { in handle_tpi()
542 rc = -EFAULT; in handle_tpi()
545 return rc ? -EFAULT : 0; in handle_tpi()
553 vcpu->stat.instruction_tsch++; in handle_tsch()
556 if (vcpu->run->s.regs.gprs[1]) in handle_tsch()
557 inti = kvm_s390_get_io_int(vcpu->kvm, isc_mask, in handle_tsch()
558 vcpu->run->s.regs.gprs[1]); in handle_tsch()
563 * so that userspace can re-inject it if the instruction gets in handle_tsch()
564 * a program check. While this may re-order the pending I/O in handle_tsch()
568 vcpu->run->exit_reason = KVM_EXIT_S390_TSCH; in handle_tsch()
569 vcpu->run->s390_tsch.dequeued = !!inti; in handle_tsch()
571 vcpu->run->s390_tsch.subchannel_id = inti->io.subchannel_id; in handle_tsch()
572 vcpu->run->s390_tsch.subchannel_nr = inti->io.subchannel_nr; in handle_tsch()
573 vcpu->run->s390_tsch.io_int_parm = inti->io.io_int_parm; in handle_tsch()
574 vcpu->run->s390_tsch.io_int_word = inti->io.io_int_word; in handle_tsch()
576 vcpu->run->s390_tsch.ipb = vcpu->arch.sie_block->ipb; in handle_tsch()
578 return -EREMOTE; in handle_tsch()
585 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_io_inst()
588 if (vcpu->kvm->arch.css_support) { in handle_io_inst()
593 if (vcpu->arch.sie_block->ipa == 0xb236) in handle_io_inst()
595 if (vcpu->arch.sie_block->ipa == 0xb235) in handle_io_inst()
598 vcpu->stat.instruction_io_other++; in handle_io_inst()
599 return -EOPNOTSUPP; in handle_io_inst()
634 return -EOPNOTSUPP; in handle_pqap()
636 if (!(vcpu->arch.sie_block->eca & ECA_APIE)) in handle_pqap()
637 return -EOPNOTSUPP; in handle_pqap()
646 reg0 = vcpu->run->s.regs.gprs[0]; in handle_pqap()
649 return -EOPNOTSUPP; in handle_pqap()
652 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pqap()
656 /* bits 41-47 must all be zeros */ in handle_pqap()
660 if (!test_kvm_facility(vcpu->kvm, 15) && (reg0 & 0x00800000UL)) in handle_pqap()
663 if (!(vcpu->kvm->arch.crypto.crycbd & 0x02) && (reg0 & 0x0000c0f0UL)) in handle_pqap()
668 if (!test_kvm_facility(vcpu->kvm, 65)) in handle_pqap()
675 if (vcpu->kvm->arch.crypto.pqap_hook) { in handle_pqap()
676 if (!try_module_get(vcpu->kvm->arch.crypto.pqap_hook->owner)) in handle_pqap()
677 return -EOPNOTSUPP; in handle_pqap()
678 ret = vcpu->kvm->arch.crypto.pqap_hook->hook(vcpu); in handle_pqap()
679 module_put(vcpu->kvm->arch.crypto.pqap_hook->owner); in handle_pqap()
680 if (!ret && vcpu->run->s.regs.gprs[1] & 0x00ff0000) in handle_pqap()
690 memcpy(&vcpu->run->s.regs.gprs[1], &status, sizeof(status)); in handle_pqap()
700 vcpu->stat.instruction_stfl++; in handle_stfl()
702 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stfl()
706 * We need to shift the lower 32 facility bits (bit 0-31) from a u64 in handle_stfl()
707 * into a u32 memory representation. They will remain bits 0-31. in handle_stfl()
709 fac = *vcpu->kvm->arch.model.fac_list >> 32; in handle_stfl()
726 if (psw->mask & PSW_MASK_UNASSIGNED) in is_valid_psw()
728 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_BA) { in is_valid_psw()
729 if (psw->addr & ~PSW_ADDR_31) in is_valid_psw()
732 if (!(psw->mask & PSW_MASK_ADDR_MODE) && (psw->addr & ~PSW_ADDR_24)) in is_valid_psw()
734 if ((psw->mask & PSW_MASK_ADDR_MODE) == PSW_MASK_EA) in is_valid_psw()
736 if (psw->addr & 1) in is_valid_psw()
743 psw_t *gpsw = &vcpu->arch.sie_block->gpsw; in kvm_s390_handle_lpsw()
749 vcpu->stat.instruction_lpsw++; in kvm_s390_handle_lpsw()
751 if (gpsw->mask & PSW_MASK_PSTATE) in kvm_s390_handle_lpsw()
763 gpsw->mask = (new_psw.mask & ~PSW32_MASK_BASE) << 32; in kvm_s390_handle_lpsw()
764 gpsw->mask |= new_psw.addr & PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
765 gpsw->addr = new_psw.addr & ~PSW32_ADDR_AMODE; in kvm_s390_handle_lpsw()
778 vcpu->stat.instruction_lpswe++; in handle_lpswe()
780 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lpswe()
789 vcpu->arch.sie_block->gpsw = new_psw; in handle_lpswe()
790 if (!is_valid_psw(&vcpu->arch.sie_block->gpsw)) in handle_lpswe()
797 u64 stidp_data = vcpu->kvm->arch.model.cpuid; in handle_stidp()
802 vcpu->stat.instruction_stidp++; in handle_stidp()
804 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stidp()
825 cpus = atomic_read(&vcpu->kvm->online_vcpus); in handle_stsi_3_2_2()
829 mem->count = 0; in handle_stsi_3_2_2()
830 if (mem->count < 8) in handle_stsi_3_2_2()
831 mem->count++; in handle_stsi_3_2_2()
832 for (n = mem->count - 1; n > 0 ; n--) in handle_stsi_3_2_2()
833 memcpy(&mem->vm[n], &mem->vm[n - 1], sizeof(mem->vm[0])); in handle_stsi_3_2_2()
835 memset(&mem->vm[0], 0, sizeof(mem->vm[0])); in handle_stsi_3_2_2()
836 mem->vm[0].cpus_total = cpus; in handle_stsi_3_2_2()
837 mem->vm[0].cpus_configured = cpus; in handle_stsi_3_2_2()
838 mem->vm[0].cpus_standby = 0; in handle_stsi_3_2_2()
839 mem->vm[0].cpus_reserved = 0; in handle_stsi_3_2_2()
840 mem->vm[0].caf = 1000; in handle_stsi_3_2_2()
841 memcpy(mem->vm[0].name, "KVMguest", 8); in handle_stsi_3_2_2()
842 ASCEBC(mem->vm[0].name, 8); in handle_stsi_3_2_2()
843 memcpy(mem->vm[0].cpi, "KVM/Linux ", 16); in handle_stsi_3_2_2()
844 ASCEBC(mem->vm[0].cpi, 16); in handle_stsi_3_2_2()
850 vcpu->run->exit_reason = KVM_EXIT_S390_STSI; in insert_stsi_usr_data()
851 vcpu->run->s390_stsi.addr = addr; in insert_stsi_usr_data()
852 vcpu->run->s390_stsi.ar = ar; in insert_stsi_usr_data()
853 vcpu->run->s390_stsi.fc = fc; in insert_stsi_usr_data()
854 vcpu->run->s390_stsi.sel1 = sel1; in insert_stsi_usr_data()
855 vcpu->run->s390_stsi.sel2 = sel2; in insert_stsi_usr_data()
860 int fc = (vcpu->run->s.regs.gprs[0] & 0xf0000000) >> 28; in handle_stsi()
861 int sel1 = vcpu->run->s.regs.gprs[0] & 0xff; in handle_stsi()
862 int sel2 = vcpu->run->s.regs.gprs[1] & 0xffff; in handle_stsi()
868 vcpu->stat.instruction_stsi++; in handle_stsi()
871 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stsi()
879 if (vcpu->run->s.regs.gprs[0] & 0x0fffff00 in handle_stsi()
880 || vcpu->run->s.regs.gprs[1] & 0xffff0000) in handle_stsi()
884 vcpu->run->s.regs.gprs[0] = 3 << 28; in handle_stsi()
913 memcpy((void *)sida_origin(vcpu->arch.sie_block), (void *)mem, in handle_stsi()
923 if (vcpu->kvm->arch.user_stsi) { in handle_stsi()
925 rc = -EREMOTE; in handle_stsi()
930 vcpu->run->s.regs.gprs[0] = 0; in handle_stsi()
941 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b2()
993 return -EOPNOTSUPP; in kvm_s390_handle_b2()
1001 vcpu->stat.instruction_epsw++; in handle_epsw()
1006 vcpu->run->s.regs.gprs[reg1] &= 0xffffffff00000000UL; in handle_epsw()
1007 vcpu->run->s.regs.gprs[reg1] |= vcpu->arch.sie_block->gpsw.mask >> 32; in handle_epsw()
1009 vcpu->run->s.regs.gprs[reg2] &= 0xffffffff00000000UL; in handle_epsw()
1010 vcpu->run->s.regs.gprs[reg2] |= in handle_epsw()
1011 vcpu->arch.sie_block->gpsw.mask & 0x00000000ffffffffUL; in handle_epsw()
1033 vcpu->stat.instruction_pfmf++; in handle_pfmf()
1037 if (!test_kvm_facility(vcpu->kvm, 8)) in handle_pfmf()
1040 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_pfmf()
1043 if (vcpu->run->s.regs.gprs[reg1] & PFMF_RESERVED) in handle_pfmf()
1046 /* Only provide non-quiescing support if enabled for the guest */ in handle_pfmf()
1047 if (vcpu->run->s.regs.gprs[reg1] & PFMF_NQ && in handle_pfmf()
1048 !test_kvm_facility(vcpu->kvm, 14)) in handle_pfmf()
1051 /* Only provide conditional-SSKE support if enabled for the guest */ in handle_pfmf()
1052 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK && in handle_pfmf()
1053 test_kvm_facility(vcpu->kvm, 10)) { in handle_pfmf()
1054 mr = vcpu->run->s.regs.gprs[reg1] & PFMF_MR; in handle_pfmf()
1055 mc = vcpu->run->s.regs.gprs[reg1] & PFMF_MC; in handle_pfmf()
1058 nq = vcpu->run->s.regs.gprs[reg1] & PFMF_NQ; in handle_pfmf()
1059 key = vcpu->run->s.regs.gprs[reg1] & PFMF_KEY; in handle_pfmf()
1060 start = vcpu->run->s.regs.gprs[reg2] & PAGE_MASK; in handle_pfmf()
1063 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1065 return kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in handle_pfmf()
1068 switch (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1072 end = (start + PAGE_SIZE) & ~(PAGE_SIZE - 1); in handle_pfmf()
1075 end = (start + _SEGMENT_SIZE) & ~(_SEGMENT_SIZE - 1); in handle_pfmf()
1079 not in 24-bit addressing mode */ in handle_pfmf()
1080 if (!test_kvm_facility(vcpu->kvm, 78) || in handle_pfmf()
1081 psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_24BIT) in handle_pfmf()
1083 end = (start + _REGION3_SIZE) & ~(_REGION3_SIZE - 1); in handle_pfmf()
1094 vmaddr = gfn_to_hva(vcpu->kvm, gpa_to_gfn(start)); in handle_pfmf()
1098 if (vcpu->run->s.regs.gprs[reg1] & PFMF_CF) { in handle_pfmf()
1099 if (kvm_clear_guest(vcpu->kvm, start, PAGE_SIZE)) in handle_pfmf()
1103 if (vcpu->run->s.regs.gprs[reg1] & PFMF_SK) { in handle_pfmf()
1108 mmap_read_lock(current->mm); in handle_pfmf()
1109 rc = cond_set_guest_storage_key(current->mm, vmaddr, in handle_pfmf()
1112 rc = fixup_user_fault(current->mm, vmaddr, in handle_pfmf()
1114 rc = !rc ? -EAGAIN : rc; in handle_pfmf()
1116 mmap_read_unlock(current->mm); in handle_pfmf()
1117 if (rc == -EFAULT) in handle_pfmf()
1119 if (rc == -EAGAIN) in handle_pfmf()
1126 if (vcpu->run->s.regs.gprs[reg1] & PFMF_FSC) { in handle_pfmf()
1127 if (psw_bits(vcpu->arch.sie_block->gpsw).eaba == PSW_BITS_AMODE_64BIT) { in handle_pfmf()
1128 vcpu->run->s.regs.gprs[reg2] = end; in handle_pfmf()
1130 vcpu->run->s.regs.gprs[reg2] &= ~0xffffffffUL; in handle_pfmf()
1132 vcpu->run->s.regs.gprs[reg2] |= end; in handle_pfmf()
1139 * Must be called with relevant read locks held (kvm->mm->mmap_lock, kvm->srcu)
1153 gfn = vcpu->run->s.regs.gprs[r2] >> PAGE_SHIFT; in __do_essa()
1154 hva = gfn_to_hva(vcpu->kvm, gfn); in __do_essa()
1155 entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in __do_essa()
1160 nappended = pgste_perform_essa(vcpu->kvm->mm, hva, orc, &ptev, &pgstev); in __do_essa()
1163 vcpu->run->s.regs.gprs[r1] = res; /* Exception Indication */ in __do_essa()
1168 * Set the block-content state part of the result. 0 means resident, so in __do_essa()
1170 * (non-present and non-zero), and 3 for zero pages (non-present and in __do_essa()
1180 vcpu->run->s.regs.gprs[r1] = res; in __do_essa()
1188 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo & PAGE_MASK); in __do_essa()
1193 struct kvm_memory_slot *ms = gfn_to_memslot(vcpu->kvm, gfn); in __do_essa()
1196 if (ms && !test_and_set_bit(gfn - ms->base_gfn, kvm_second_dirty_bitmap(ms))) in __do_essa()
1197 atomic64_inc(&vcpu->kvm->arch.cmma_dirty_pages); in __do_essa()
1206 int entries = (vcpu->arch.sie_block->cbrlo & ~PAGE_MASK) >> 3; in handle_essa()
1212 gmap = vcpu->arch.gmap; in handle_essa()
1213 vcpu->stat.instruction_essa++; in handle_essa()
1214 if (!vcpu->kvm->arch.use_cmma) in handle_essa()
1217 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_essa()
1220 orc = (vcpu->arch.sie_block->ipb & 0xf0000000) >> 28; in handle_essa()
1221 /* ORCs 0-6 are always valid */ in handle_essa()
1222 if (orc > (test_kvm_facility(vcpu->kvm, 147) ? ESSA_SET_STABLE_NODAT in handle_essa()
1226 if (!vcpu->kvm->arch.migration_mode) { in handle_essa()
1228 * CMMA is enabled in the KVM settings, but is disabled in in handle_essa()
1236 if (vcpu->kvm->mm->context.uses_cmm == 0) { in handle_essa()
1237 mmap_write_lock(vcpu->kvm->mm); in handle_essa()
1238 vcpu->kvm->mm->context.uses_cmm = 1; in handle_essa()
1239 mmap_write_unlock(vcpu->kvm->mm); in handle_essa()
1242 * If we are here, we are supposed to have CMMA enabled in in handle_essa()
1243 * the SIE block. Enabling CMMA works on a per-CPU basis, in handle_essa()
1245 * It's possible that the context flag is enabled and the in handle_essa()
1250 vcpu->arch.sie_block->ecb2 |= ECB2_CMMA; in handle_essa()
1256 mmap_read_lock(vcpu->kvm->mm); in handle_essa()
1257 srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in handle_essa()
1259 srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx); in handle_essa()
1260 mmap_read_unlock(vcpu->kvm->mm); in handle_essa()
1266 vcpu->arch.sie_block->cbrlo &= PAGE_MASK; /* reset nceo */ in handle_essa()
1267 cbrlo = phys_to_virt(vcpu->arch.sie_block->cbrlo); in handle_essa()
1268 mmap_read_lock(gmap->mm); in handle_essa()
1271 mmap_read_unlock(gmap->mm); in handle_essa()
1277 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_b9()
1289 return -EOPNOTSUPP; in kvm_s390_handle_b9()
1295 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_lctl()
1296 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_lctl()
1302 vcpu->stat.instruction_lctl++; in kvm_s390_handle_lctl()
1304 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_lctl()
1315 nr_regs = ((reg3 - reg1) & 0xf) + 1; in kvm_s390_handle_lctl()
1322 vcpu->arch.sie_block->gcr[reg] &= 0xffffffff00000000ul; in kvm_s390_handle_lctl()
1323 vcpu->arch.sie_block->gcr[reg] |= ctl_array[nr_regs++]; in kvm_s390_handle_lctl()
1334 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in kvm_s390_handle_stctl()
1335 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in kvm_s390_handle_stctl()
1341 vcpu->stat.instruction_stctl++; in kvm_s390_handle_stctl()
1343 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_stctl()
1357 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in kvm_s390_handle_stctl()
1368 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_lctlg()
1369 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_lctlg()
1375 vcpu->stat.instruction_lctlg++; in handle_lctlg()
1377 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_lctlg()
1388 nr_regs = ((reg3 - reg1) & 0xf) + 1; in handle_lctlg()
1395 vcpu->arch.sie_block->gcr[reg] = ctl_array[nr_regs++]; in handle_lctlg()
1406 int reg1 = (vcpu->arch.sie_block->ipa & 0x00f0) >> 4; in handle_stctg()
1407 int reg3 = vcpu->arch.sie_block->ipa & 0x000f; in handle_stctg()
1413 vcpu->stat.instruction_stctg++; in handle_stctg()
1415 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_stctg()
1429 ctl_array[nr_regs++] = vcpu->arch.sie_block->gcr[reg]; in handle_stctg()
1440 switch (vcpu->arch.sie_block->ipb & 0x000000ff) { in kvm_s390_handle_eb()
1450 return -EOPNOTSUPP; in kvm_s390_handle_eb()
1462 vcpu->stat.instruction_tprot++; in handle_tprot()
1464 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_tprot()
1473 return -EOPNOTSUPP; in handle_tprot()
1474 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1478 /* Write protected? Try again with read-only... */ in handle_tprot()
1494 hva = gfn_to_hva_prot(vcpu->kvm, gpa_to_gfn(gpa), &writable); in handle_tprot()
1499 cc = 1; /* Write not permitted ==> read-only */ in handle_tprot()
1504 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_DAT) in handle_tprot()
1511 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_e5()
1515 return -EOPNOTSUPP; in kvm_s390_handle_e5()
1523 vcpu->stat.instruction_sckpf++; in handle_sckpf()
1525 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in handle_sckpf()
1528 if (vcpu->run->s.regs.gprs[0] & 0x00000000ffff0000) in handle_sckpf()
1532 value = vcpu->run->s.regs.gprs[0] & 0x000000000000ffff; in handle_sckpf()
1533 vcpu->arch.sie_block->todpr = value; in handle_sckpf()
1540 vcpu->stat.instruction_ptff++; in handle_ptff()
1549 switch (vcpu->arch.sie_block->ipa & 0x00ff) { in kvm_s390_handle_01()
1555 return -EOPNOTSUPP; in kvm_s390_handle_01()