Lines Matching full:arch
305 kvm_clock_sync_scb(vcpu->arch.sie_block, *delta); in kvm_clock_sync()
307 kvm->arch.epoch = vcpu->arch.sie_block->epoch; in kvm_clock_sync()
308 kvm->arch.epdx = vcpu->arch.sie_block->epdx; in kvm_clock_sync()
310 if (vcpu->arch.cputm_enabled) in kvm_clock_sync()
311 vcpu->arch.cputm_start += *delta; in kvm_clock_sync()
312 if (vcpu->arch.vsie_block) in kvm_clock_sync()
313 kvm_clock_sync_scb(vcpu->arch.vsie_block, in kvm_clock_sync()
659 struct gmap *gmap = kvm->arch.gmap; in kvm_arch_sync_dirty_log()
742 kvm->arch.use_irqchip = 1; in kvm_vm_ioctl_enable_cap()
747 kvm->arch.user_sigp = 1; in kvm_vm_ioctl_enable_cap()
755 set_kvm_facility(kvm->arch.model.fac_mask, 129); in kvm_vm_ioctl_enable_cap()
756 set_kvm_facility(kvm->arch.model.fac_list, 129); in kvm_vm_ioctl_enable_cap()
758 set_kvm_facility(kvm->arch.model.fac_mask, 134); in kvm_vm_ioctl_enable_cap()
759 set_kvm_facility(kvm->arch.model.fac_list, 134); in kvm_vm_ioctl_enable_cap()
762 set_kvm_facility(kvm->arch.model.fac_mask, 135); in kvm_vm_ioctl_enable_cap()
763 set_kvm_facility(kvm->arch.model.fac_list, 135); in kvm_vm_ioctl_enable_cap()
766 set_kvm_facility(kvm->arch.model.fac_mask, 148); in kvm_vm_ioctl_enable_cap()
767 set_kvm_facility(kvm->arch.model.fac_list, 148); in kvm_vm_ioctl_enable_cap()
770 set_kvm_facility(kvm->arch.model.fac_mask, 152); in kvm_vm_ioctl_enable_cap()
771 set_kvm_facility(kvm->arch.model.fac_list, 152); in kvm_vm_ioctl_enable_cap()
774 set_kvm_facility(kvm->arch.model.fac_mask, 192); in kvm_vm_ioctl_enable_cap()
775 set_kvm_facility(kvm->arch.model.fac_list, 192); in kvm_vm_ioctl_enable_cap()
790 set_kvm_facility(kvm->arch.model.fac_mask, 64); in kvm_vm_ioctl_enable_cap()
791 set_kvm_facility(kvm->arch.model.fac_list, 64); in kvm_vm_ioctl_enable_cap()
803 set_kvm_facility(kvm->arch.model.fac_mask, 72); in kvm_vm_ioctl_enable_cap()
804 set_kvm_facility(kvm->arch.model.fac_list, 72); in kvm_vm_ioctl_enable_cap()
817 set_kvm_facility(kvm->arch.model.fac_mask, 133); in kvm_vm_ioctl_enable_cap()
818 set_kvm_facility(kvm->arch.model.fac_list, 133); in kvm_vm_ioctl_enable_cap()
829 else if (!hpage || kvm->arch.use_cmma || kvm_is_ucontrol(kvm)) in kvm_vm_ioctl_enable_cap()
841 kvm->arch.use_skf = 0; in kvm_vm_ioctl_enable_cap()
842 kvm->arch.use_pfmfi = 0; in kvm_vm_ioctl_enable_cap()
850 kvm->arch.user_stsi = 1; in kvm_vm_ioctl_enable_cap()
855 kvm->arch.user_instr0 = 1; in kvm_vm_ioctl_enable_cap()
865 set_kvm_facility(kvm->arch.model.fac_mask, 11); in kvm_vm_ioctl_enable_cap()
866 set_kvm_facility(kvm->arch.model.fac_list, 11); in kvm_vm_ioctl_enable_cap()
888 kvm->arch.mem_limit); in kvm_s390_get_mem_control()
889 if (put_user(kvm->arch.mem_limit, (u64 __user *)attr->addr)) in kvm_s390_get_mem_control()
916 kvm->arch.use_cmma = 1; in kvm_s390_set_mem_control()
918 kvm->arch.use_pfmfi = 0; in kvm_s390_set_mem_control()
928 if (!kvm->arch.use_cmma) in kvm_s390_set_mem_control()
934 s390_reset_cmma(kvm->arch.gmap->mm); in kvm_s390_set_mem_control()
948 if (kvm->arch.mem_limit != KVM_S390_NO_MEM_LIMIT && in kvm_s390_set_mem_control()
949 new_limit > kvm->arch.mem_limit) in kvm_s390_set_mem_control()
968 gmap_remove(kvm->arch.gmap); in kvm_s390_set_mem_control()
970 kvm->arch.gmap = new; in kvm_s390_set_mem_control()
977 (void *) kvm->arch.gmap->asce); in kvm_s390_set_mem_control()
1015 kvm->arch.crypto.crycb->aes_wrapping_key_mask, in kvm_s390_vm_set_crypto()
1016 sizeof(kvm->arch.crypto.crycb->aes_wrapping_key_mask)); in kvm_s390_vm_set_crypto()
1017 kvm->arch.crypto.aes_kw = 1; in kvm_s390_vm_set_crypto()
1026 kvm->arch.crypto.crycb->dea_wrapping_key_mask, in kvm_s390_vm_set_crypto()
1027 sizeof(kvm->arch.crypto.crycb->dea_wrapping_key_mask)); in kvm_s390_vm_set_crypto()
1028 kvm->arch.crypto.dea_kw = 1; in kvm_s390_vm_set_crypto()
1036 kvm->arch.crypto.aes_kw = 0; in kvm_s390_vm_set_crypto()
1037 memset(kvm->arch.crypto.crycb->aes_wrapping_key_mask, 0, in kvm_s390_vm_set_crypto()
1038 sizeof(kvm->arch.crypto.crycb->aes_wrapping_key_mask)); in kvm_s390_vm_set_crypto()
1046 kvm->arch.crypto.dea_kw = 0; in kvm_s390_vm_set_crypto()
1047 memset(kvm->arch.crypto.crycb->dea_wrapping_key_mask, 0, in kvm_s390_vm_set_crypto()
1048 sizeof(kvm->arch.crypto.crycb->dea_wrapping_key_mask)); in kvm_s390_vm_set_crypto()
1056 kvm->arch.crypto.apie = 1; in kvm_s390_vm_set_crypto()
1063 kvm->arch.crypto.apie = 0; in kvm_s390_vm_set_crypto()
1078 if (!vcpu->kvm->arch.use_zpci_interp) in kvm_s390_vcpu_pci_setup()
1081 vcpu->arch.sie_block->ecb2 |= ECB2_ZPCI_LSI; in kvm_s390_vcpu_pci_setup()
1082 vcpu->arch.sie_block->ecb3 |= ECB3_AISII + ECB3_AISI; in kvm_s390_vcpu_pci_setup()
1099 kvm->arch.use_zpci_interp = 1; in kvm_s390_vcpu_pci_enable_interp()
1132 if (kvm->arch.migration_mode) in kvm_s390_vm_start_migration()
1138 if (!kvm->arch.use_cmma) { in kvm_s390_vm_start_migration()
1139 kvm->arch.migration_mode = 1; in kvm_s390_vm_start_migration()
1155 atomic64_set(&kvm->arch.cmma_dirty_pages, ram_pages); in kvm_s390_vm_start_migration()
1156 kvm->arch.migration_mode = 1; in kvm_s390_vm_start_migration()
1168 if (!kvm->arch.migration_mode) in kvm_s390_vm_stop_migration()
1170 kvm->arch.migration_mode = 0; in kvm_s390_vm_stop_migration()
1171 if (kvm->arch.use_cmma) in kvm_s390_vm_stop_migration()
1200 u64 mig = kvm->arch.migration_mode; in kvm_s390_vm_get_migration()
1303 gtod->tod = clk.tod + kvm->arch.epoch; in kvm_s390_get_tod_clock()
1306 gtod->epoch_idx = clk.ei + kvm->arch.epdx; in kvm_s390_get_tod_clock()
1394 kvm->arch.model.cpuid = proc->cpuid; in kvm_s390_set_processor()
1399 kvm->arch.model.ibc = unblocked_ibc; in kvm_s390_set_processor()
1401 kvm->arch.model.ibc = lowest_ibc; in kvm_s390_set_processor()
1403 kvm->arch.model.ibc = proc->ibc; in kvm_s390_set_processor()
1405 memcpy(kvm->arch.model.fac_list, proc->fac_list, in kvm_s390_set_processor()
1408 kvm->arch.model.ibc, in kvm_s390_set_processor()
1409 kvm->arch.model.cpuid); in kvm_s390_set_processor()
1411 kvm->arch.model.fac_list[0], in kvm_s390_set_processor()
1412 kvm->arch.model.fac_list[1], in kvm_s390_set_processor()
1413 kvm->arch.model.fac_list[2]); in kvm_s390_set_processor()
1439 bitmap_from_arr64(kvm->arch.cpu_feat, data.feat, KVM_S390_VM_CPU_FEAT_NR_BITS); in kvm_s390_set_processor_feat()
1457 if (copy_from_user(&kvm->arch.model.subfuncs, (void __user *)attr->addr, in kvm_s390_set_processor_subfunc()
1465 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[0], in kvm_s390_set_processor_subfunc()
1466 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[1], in kvm_s390_set_processor_subfunc()
1467 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[2], in kvm_s390_set_processor_subfunc()
1468 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[3]); in kvm_s390_set_processor_subfunc()
1470 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[0], in kvm_s390_set_processor_subfunc()
1471 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[1]); in kvm_s390_set_processor_subfunc()
1473 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[0], in kvm_s390_set_processor_subfunc()
1474 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[1]); in kvm_s390_set_processor_subfunc()
1476 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[0], in kvm_s390_set_processor_subfunc()
1477 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[1]); in kvm_s390_set_processor_subfunc()
1479 ((unsigned long *) &kvm->arch.model.subfuncs.km)[0], in kvm_s390_set_processor_subfunc()
1480 ((unsigned long *) &kvm->arch.model.subfuncs.km)[1]); in kvm_s390_set_processor_subfunc()
1482 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[0], in kvm_s390_set_processor_subfunc()
1483 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[1]); in kvm_s390_set_processor_subfunc()
1485 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[0], in kvm_s390_set_processor_subfunc()
1486 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[1]); in kvm_s390_set_processor_subfunc()
1488 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[0], in kvm_s390_set_processor_subfunc()
1489 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[1]); in kvm_s390_set_processor_subfunc()
1491 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[0], in kvm_s390_set_processor_subfunc()
1492 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[1]); in kvm_s390_set_processor_subfunc()
1494 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[0], in kvm_s390_set_processor_subfunc()
1495 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[1]); in kvm_s390_set_processor_subfunc()
1497 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[0], in kvm_s390_set_processor_subfunc()
1498 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[1]); in kvm_s390_set_processor_subfunc()
1500 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[0], in kvm_s390_set_processor_subfunc()
1501 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[1]); in kvm_s390_set_processor_subfunc()
1503 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[0], in kvm_s390_set_processor_subfunc()
1504 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[1]); in kvm_s390_set_processor_subfunc()
1506 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0], in kvm_s390_set_processor_subfunc()
1507 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]); in kvm_s390_set_processor_subfunc()
1509 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0], in kvm_s390_set_processor_subfunc()
1510 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]); in kvm_s390_set_processor_subfunc()
1512 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[0], in kvm_s390_set_processor_subfunc()
1513 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1], in kvm_s390_set_processor_subfunc()
1514 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2], in kvm_s390_set_processor_subfunc()
1515 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]); in kvm_s390_set_processor_subfunc()
1517 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0], in kvm_s390_set_processor_subfunc()
1518 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], in kvm_s390_set_processor_subfunc()
1519 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], in kvm_s390_set_processor_subfunc()
1520 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); in kvm_s390_set_processor_subfunc()
1553 proc->cpuid = kvm->arch.model.cpuid; in kvm_s390_get_processor()
1554 proc->ibc = kvm->arch.model.ibc; in kvm_s390_get_processor()
1555 memcpy(&proc->fac_list, kvm->arch.model.fac_list, in kvm_s390_get_processor()
1558 kvm->arch.model.ibc, in kvm_s390_get_processor()
1559 kvm->arch.model.cpuid); in kvm_s390_get_processor()
1561 kvm->arch.model.fac_list[0], in kvm_s390_get_processor()
1562 kvm->arch.model.fac_list[1], in kvm_s390_get_processor()
1563 kvm->arch.model.fac_list[2]); in kvm_s390_get_processor()
1583 memcpy(&mach->fac_mask, kvm->arch.model.fac_mask, in kvm_s390_get_machine()
1588 kvm->arch.model.ibc, in kvm_s390_get_machine()
1589 kvm->arch.model.cpuid); in kvm_s390_get_machine()
1610 bitmap_to_arr64(data.feat, kvm->arch.cpu_feat, KVM_S390_VM_CPU_FEAT_NR_BITS); in kvm_s390_get_processor_feat()
1638 if (copy_to_user((void __user *)attr->addr, &kvm->arch.model.subfuncs, in kvm_s390_get_processor_subfunc()
1643 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[0], in kvm_s390_get_processor_subfunc()
1644 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[1], in kvm_s390_get_processor_subfunc()
1645 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[2], in kvm_s390_get_processor_subfunc()
1646 ((unsigned long *) &kvm->arch.model.subfuncs.plo)[3]); in kvm_s390_get_processor_subfunc()
1648 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[0], in kvm_s390_get_processor_subfunc()
1649 ((unsigned long *) &kvm->arch.model.subfuncs.ptff)[1]); in kvm_s390_get_processor_subfunc()
1651 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[0], in kvm_s390_get_processor_subfunc()
1652 ((unsigned long *) &kvm->arch.model.subfuncs.kmac)[1]); in kvm_s390_get_processor_subfunc()
1654 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[0], in kvm_s390_get_processor_subfunc()
1655 ((unsigned long *) &kvm->arch.model.subfuncs.kmc)[1]); in kvm_s390_get_processor_subfunc()
1657 ((unsigned long *) &kvm->arch.model.subfuncs.km)[0], in kvm_s390_get_processor_subfunc()
1658 ((unsigned long *) &kvm->arch.model.subfuncs.km)[1]); in kvm_s390_get_processor_subfunc()
1660 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[0], in kvm_s390_get_processor_subfunc()
1661 ((unsigned long *) &kvm->arch.model.subfuncs.kimd)[1]); in kvm_s390_get_processor_subfunc()
1663 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[0], in kvm_s390_get_processor_subfunc()
1664 ((unsigned long *) &kvm->arch.model.subfuncs.klmd)[1]); in kvm_s390_get_processor_subfunc()
1666 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[0], in kvm_s390_get_processor_subfunc()
1667 ((unsigned long *) &kvm->arch.model.subfuncs.pckmo)[1]); in kvm_s390_get_processor_subfunc()
1669 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[0], in kvm_s390_get_processor_subfunc()
1670 ((unsigned long *) &kvm->arch.model.subfuncs.kmctr)[1]); in kvm_s390_get_processor_subfunc()
1672 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[0], in kvm_s390_get_processor_subfunc()
1673 ((unsigned long *) &kvm->arch.model.subfuncs.kmf)[1]); in kvm_s390_get_processor_subfunc()
1675 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[0], in kvm_s390_get_processor_subfunc()
1676 ((unsigned long *) &kvm->arch.model.subfuncs.kmo)[1]); in kvm_s390_get_processor_subfunc()
1678 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[0], in kvm_s390_get_processor_subfunc()
1679 ((unsigned long *) &kvm->arch.model.subfuncs.pcc)[1]); in kvm_s390_get_processor_subfunc()
1681 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[0], in kvm_s390_get_processor_subfunc()
1682 ((unsigned long *) &kvm->arch.model.subfuncs.ppno)[1]); in kvm_s390_get_processor_subfunc()
1684 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[0], in kvm_s390_get_processor_subfunc()
1685 ((unsigned long *) &kvm->arch.model.subfuncs.kma)[1]); in kvm_s390_get_processor_subfunc()
1687 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[0], in kvm_s390_get_processor_subfunc()
1688 ((unsigned long *) &kvm->arch.model.subfuncs.kdsa)[1]); in kvm_s390_get_processor_subfunc()
1690 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[0], in kvm_s390_get_processor_subfunc()
1691 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[1], in kvm_s390_get_processor_subfunc()
1692 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[2], in kvm_s390_get_processor_subfunc()
1693 ((unsigned long *) &kvm->arch.model.subfuncs.sortl)[3]); in kvm_s390_get_processor_subfunc()
1695 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[0], in kvm_s390_get_processor_subfunc()
1696 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], in kvm_s390_get_processor_subfunc()
1697 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], in kvm_s390_get_processor_subfunc()
1698 ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); in kvm_s390_get_processor_subfunc()
1814 read_lock(&kvm->arch.sca_lock); in kvm_s390_update_topology_change_report()
1815 sca = kvm->arch.sca; in kvm_s390_update_topology_change_report()
1821 read_unlock(&kvm->arch.sca_lock); in kvm_s390_update_topology_change_report()
1842 read_lock(&kvm->arch.sca_lock); in kvm_s390_get_topo_change_indication()
1843 topo = ((struct bsca_block *)kvm->arch.sca)->utility.mtcr; in kvm_s390_get_topo_change_indication()
1844 read_unlock(&kvm->arch.sca_lock); in kvm_s390_get_topo_change_indication()
2183 atomic64_dec(&kvm->arch.cmma_dirty_pages); in kvm_s390_get_cmma()
2224 if (!kvm->arch.use_cmma) in kvm_s390_get_cmma_bits()
2231 if (!peek && !kvm->arch.migration_mode) in kvm_s390_get_cmma_bits()
2240 if (!peek && !atomic64_read(&kvm->arch.cmma_dirty_pages)) { in kvm_s390_get_cmma_bits()
2258 if (kvm->arch.migration_mode) in kvm_s390_get_cmma_bits()
2259 args->remaining = atomic64_read(&kvm->arch.cmma_dirty_pages); in kvm_s390_get_cmma_bits()
2284 if (!kvm->arch.use_cmma) in kvm_s390_set_cmma_bits()
2466 if (kvm->arch.pv.dumping) in kvm_s390_pv_dmp()
2480 kvm->arch.pv.dumping = true; in kvm_s390_pv_dmp()
2488 if (!kvm->arch.pv.dumping) in kvm_s390_pv_dmp()
2501 if (!kvm->arch.pv.dumping) in kvm_s390_pv_dmp()
2555 set_bit(IRQ_PEND_EXT_SERVICE, &kvm->arch.float_int.masked_irqs); in kvm_s390_handle_pv()
2574 clear_bit(IRQ_PEND_EXT_SERVICE, &kvm->arch.float_int.masked_irqs); in kvm_s390_handle_pv()
2832 if (kvm->arch.use_irqchip) { in kvm_arch_vm_ioctl()
2985 kvm->arch.crypto.crycbd = (__u32)(unsigned long) kvm->arch.crypto.crycb; in kvm_s390_set_crycb_format()
2988 kvm->arch.crypto.crycbd &= ~(CRYCB_FORMAT_MASK); in kvm_s390_set_crycb_format()
2995 kvm->arch.crypto.crycbd |= CRYCB_FORMAT2; in kvm_s390_set_crycb_format()
2997 kvm->arch.crypto.crycbd |= CRYCB_FORMAT1; in kvm_s390_set_crycb_format()
3018 struct kvm_s390_crypto_cb *crycb = kvm->arch.crypto.crycb; in kvm_arch_crypto_set_masks()
3022 switch (kvm->arch.crypto.crycbd & CRYCB_FORMAT_MASK) { in kvm_arch_crypto_set_masks()
3069 memset(&kvm->arch.crypto.crycb->apcb0, 0, in kvm_arch_crypto_clear_masks()
3070 sizeof(kvm->arch.crypto.crycb->apcb0)); in kvm_arch_crypto_clear_masks()
3071 memset(&kvm->arch.crypto.crycb->apcb1, 0, in kvm_arch_crypto_clear_masks()
3072 sizeof(kvm->arch.crypto.crycb->apcb1)); in kvm_arch_crypto_clear_masks()
3092 kvm->arch.crypto.crycb = &kvm->arch.sie_page2->crycb; in kvm_s390_crypto_init()
3094 init_rwsem(&kvm->arch.crypto.pqap_hook_rwsem); in kvm_s390_crypto_init()
3100 kvm->arch.crypto.aes_kw = 1; in kvm_s390_crypto_init()
3101 kvm->arch.crypto.dea_kw = 1; in kvm_s390_crypto_init()
3102 get_random_bytes(kvm->arch.crypto.crycb->aes_wrapping_key_mask, in kvm_s390_crypto_init()
3103 sizeof(kvm->arch.crypto.crycb->aes_wrapping_key_mask)); in kvm_s390_crypto_init()
3104 get_random_bytes(kvm->arch.crypto.crycb->dea_wrapping_key_mask, in kvm_s390_crypto_init()
3105 sizeof(kvm->arch.crypto.crycb->dea_wrapping_key_mask)); in kvm_s390_crypto_init()
3110 if (kvm->arch.use_esca) in sca_dispose()
3111 free_pages_exact(kvm->arch.sca, sizeof(struct esca_block)); in sca_dispose()
3113 free_page((unsigned long)(kvm->arch.sca)); in sca_dispose()
3114 kvm->arch.sca = NULL; in sca_dispose()
3151 rwlock_init(&kvm->arch.sca_lock); in kvm_arch_init_vm()
3153 kvm->arch.sca = (struct bsca_block *) get_zeroed_page(alloc_flags); in kvm_arch_init_vm()
3154 if (!kvm->arch.sca) in kvm_arch_init_vm()
3160 kvm->arch.sca = (struct bsca_block *) in kvm_arch_init_vm()
3161 ((char *) kvm->arch.sca + sca_offset); in kvm_arch_init_vm()
3166 kvm->arch.dbf = debug_register(debug_name, 32, 1, 7 * sizeof(long)); in kvm_arch_init_vm()
3167 if (!kvm->arch.dbf) in kvm_arch_init_vm()
3171 kvm->arch.sie_page2 = in kvm_arch_init_vm()
3173 if (!kvm->arch.sie_page2) in kvm_arch_init_vm()
3176 kvm->arch.sie_page2->kvm = kvm; in kvm_arch_init_vm()
3177 kvm->arch.model.fac_list = kvm->arch.sie_page2->fac_list; in kvm_arch_init_vm()
3180 kvm->arch.model.fac_mask[i] = stfle_fac_list[i] & in kvm_arch_init_vm()
3183 kvm->arch.model.fac_list[i] = stfle_fac_list[i] & in kvm_arch_init_vm()
3186 kvm->arch.model.subfuncs = kvm_s390_available_subfunc; in kvm_arch_init_vm()
3189 set_kvm_facility(kvm->arch.model.fac_mask, 138); in kvm_arch_init_vm()
3190 set_kvm_facility(kvm->arch.model.fac_list, 138); in kvm_arch_init_vm()
3192 set_kvm_facility(kvm->arch.model.fac_mask, 74); in kvm_arch_init_vm()
3193 set_kvm_facility(kvm->arch.model.fac_list, 74); in kvm_arch_init_vm()
3195 set_kvm_facility(kvm->arch.model.fac_mask, 147); in kvm_arch_init_vm()
3196 set_kvm_facility(kvm->arch.model.fac_list, 147); in kvm_arch_init_vm()
3200 set_kvm_facility(kvm->arch.model.fac_mask, 65); in kvm_arch_init_vm()
3202 kvm->arch.model.cpuid = kvm_s390_get_initial_cpuid(); in kvm_arch_init_vm()
3203 kvm->arch.model.ibc = sclp.ibc & 0x0fff; in kvm_arch_init_vm()
3214 mutex_init(&kvm->arch.float_int.ais_lock); in kvm_arch_init_vm()
3215 spin_lock_init(&kvm->arch.float_int.lock); in kvm_arch_init_vm()
3217 INIT_LIST_HEAD(&kvm->arch.float_int.lists[i]); in kvm_arch_init_vm()
3218 init_waitqueue_head(&kvm->arch.ipte_wq); in kvm_arch_init_vm()
3219 mutex_init(&kvm->arch.ipte_mutex); in kvm_arch_init_vm()
3221 debug_register_view(kvm->arch.dbf, &debug_sprintf_view); in kvm_arch_init_vm()
3225 kvm->arch.gmap = NULL; in kvm_arch_init_vm()
3226 kvm->arch.mem_limit = KVM_S390_NO_MEM_LIMIT; in kvm_arch_init_vm()
3229 kvm->arch.mem_limit = TASK_SIZE_MAX; in kvm_arch_init_vm()
3231 kvm->arch.mem_limit = min_t(unsigned long, TASK_SIZE_MAX, in kvm_arch_init_vm()
3233 kvm->arch.gmap = gmap_create(current->mm, kvm->arch.mem_limit - 1); in kvm_arch_init_vm()
3234 if (!kvm->arch.gmap) in kvm_arch_init_vm()
3236 kvm->arch.gmap->private = kvm; in kvm_arch_init_vm()
3237 kvm->arch.gmap->pfault_enabled = 0; in kvm_arch_init_vm()
3240 kvm->arch.use_pfmfi = sclp.has_pfmfi; in kvm_arch_init_vm()
3241 kvm->arch.use_skf = sclp.has_skey; in kvm_arch_init_vm()
3242 spin_lock_init(&kvm->arch.start_stop_lock); in kvm_arch_init_vm()
3250 free_page((unsigned long)kvm->arch.sie_page2); in kvm_arch_init_vm()
3251 debug_unregister(kvm->arch.dbf); in kvm_arch_init_vm()
3270 gmap_remove(vcpu->arch.gmap); in kvm_arch_vcpu_destroy()
3272 if (vcpu->kvm->arch.use_cmma) in kvm_arch_vcpu_destroy()
3277 free_page((unsigned long)(vcpu->arch.sie_block)); in kvm_arch_vcpu_destroy()
3301 if (kvm->arch.pv.mmu_notifier.ops) in kvm_arch_destroy_vm()
3302 mmu_notifier_unregister(&kvm->arch.pv.mmu_notifier, kvm->mm); in kvm_arch_destroy_vm()
3304 debug_unregister(kvm->arch.dbf); in kvm_arch_destroy_vm()
3305 free_page((unsigned long)kvm->arch.sie_page2); in kvm_arch_destroy_vm()
3307 gmap_remove(kvm->arch.gmap); in kvm_arch_destroy_vm()
3317 vcpu->arch.gmap = gmap_create(current->mm, -1UL); in __kvm_ucontrol_vcpu_init()
3318 if (!vcpu->arch.gmap) in __kvm_ucontrol_vcpu_init()
3320 vcpu->arch.gmap->private = vcpu->kvm; in __kvm_ucontrol_vcpu_init()
3329 read_lock(&vcpu->kvm->arch.sca_lock); in sca_del_vcpu()
3330 if (vcpu->kvm->arch.use_esca) { in sca_del_vcpu()
3331 struct esca_block *sca = vcpu->kvm->arch.sca; in sca_del_vcpu()
3336 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_del_vcpu()
3341 read_unlock(&vcpu->kvm->arch.sca_lock); in sca_del_vcpu()
3347 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_add_vcpu()
3350 vcpu->arch.sie_block->scaoh = (__u32)(((__u64)sca) >> 32); in sca_add_vcpu()
3351 vcpu->arch.sie_block->scaol = (__u32)(__u64)sca; in sca_add_vcpu()
3354 read_lock(&vcpu->kvm->arch.sca_lock); in sca_add_vcpu()
3355 if (vcpu->kvm->arch.use_esca) { in sca_add_vcpu()
3356 struct esca_block *sca = vcpu->kvm->arch.sca; in sca_add_vcpu()
3358 sca->cpu[vcpu->vcpu_id].sda = (__u64) vcpu->arch.sie_block; in sca_add_vcpu()
3359 vcpu->arch.sie_block->scaoh = (__u32)(((__u64)sca) >> 32); in sca_add_vcpu()
3360 vcpu->arch.sie_block->scaol = (__u32)(__u64)sca & ~0x3fU; in sca_add_vcpu()
3361 vcpu->arch.sie_block->ecb2 |= ECB2_ESCA; in sca_add_vcpu()
3364 struct bsca_block *sca = vcpu->kvm->arch.sca; in sca_add_vcpu()
3366 sca->cpu[vcpu->vcpu_id].sda = (__u64) vcpu->arch.sie_block; in sca_add_vcpu()
3367 vcpu->arch.sie_block->scaoh = (__u32)(((__u64)sca) >> 32); in sca_add_vcpu()
3368 vcpu->arch.sie_block->scaol = (__u32)(__u64)sca; in sca_add_vcpu()
3371 read_unlock(&vcpu->kvm->arch.sca_lock); in sca_add_vcpu()
3394 struct bsca_block *old_sca = kvm->arch.sca; in sca_switch_to_extended()
3400 if (kvm->arch.use_esca) in sca_switch_to_extended()
3411 write_lock(&kvm->arch.sca_lock); in sca_switch_to_extended()
3416 vcpu->arch.sie_block->scaoh = scaoh; in sca_switch_to_extended()
3417 vcpu->arch.sie_block->scaol = scaol; in sca_switch_to_extended()
3418 vcpu->arch.sie_block->ecb2 |= ECB2_ESCA; in sca_switch_to_extended()
3420 kvm->arch.sca = new_sca; in sca_switch_to_extended()
3421 kvm->arch.use_esca = 1; in sca_switch_to_extended()
3423 write_unlock(&kvm->arch.sca_lock); in sca_switch_to_extended()
3429 old_sca, kvm->arch.sca); in sca_switch_to_extended()
3447 rc = kvm->arch.use_esca ? 0 : sca_switch_to_extended(kvm); in sca_can_add_vcpu()
3455 WARN_ON_ONCE(vcpu->arch.cputm_start != 0); in __start_cpu_timer_accounting()
3456 raw_write_seqcount_begin(&vcpu->arch.cputm_seqcount); in __start_cpu_timer_accounting()
3457 vcpu->arch.cputm_start = get_tod_clock_fast(); in __start_cpu_timer_accounting()
3458 raw_write_seqcount_end(&vcpu->arch.cputm_seqcount); in __start_cpu_timer_accounting()
3464 WARN_ON_ONCE(vcpu->arch.cputm_start == 0); in __stop_cpu_timer_accounting()
3465 raw_write_seqcount_begin(&vcpu->arch.cputm_seqcount); in __stop_cpu_timer_accounting()
3466 vcpu->arch.sie_block->cputm -= get_tod_clock_fast() - vcpu->arch.cputm_start; in __stop_cpu_timer_accounting()
3467 vcpu->arch.cputm_start = 0; in __stop_cpu_timer_accounting()
3468 raw_write_seqcount_end(&vcpu->arch.cputm_seqcount); in __stop_cpu_timer_accounting()
3474 WARN_ON_ONCE(vcpu->arch.cputm_enabled); in __enable_cpu_timer_accounting()
3475 vcpu->arch.cputm_enabled = true; in __enable_cpu_timer_accounting()
3482 WARN_ON_ONCE(!vcpu->arch.cputm_enabled); in __disable_cpu_timer_accounting()
3484 vcpu->arch.cputm_enabled = false; in __disable_cpu_timer_accounting()
3505 raw_write_seqcount_begin(&vcpu->arch.cputm_seqcount); in kvm_s390_set_cpu_timer()
3506 if (vcpu->arch.cputm_enabled) in kvm_s390_set_cpu_timer()
3507 vcpu->arch.cputm_start = get_tod_clock_fast(); in kvm_s390_set_cpu_timer()
3508 vcpu->arch.sie_block->cputm = cputm; in kvm_s390_set_cpu_timer()
3509 raw_write_seqcount_end(&vcpu->arch.cputm_seqcount); in kvm_s390_set_cpu_timer()
3519 if (unlikely(!vcpu->arch.cputm_enabled)) in kvm_s390_get_cpu_timer()
3520 return vcpu->arch.sie_block->cputm; in kvm_s390_get_cpu_timer()
3524 seq = raw_read_seqcount(&vcpu->arch.cputm_seqcount); in kvm_s390_get_cpu_timer()
3530 value = vcpu->arch.sie_block->cputm; in kvm_s390_get_cpu_timer()
3532 if (likely(vcpu->arch.cputm_start)) in kvm_s390_get_cpu_timer()
3533 value -= get_tod_clock_fast() - vcpu->arch.cputm_start; in kvm_s390_get_cpu_timer()
3534 } while (read_seqcount_retry(&vcpu->arch.cputm_seqcount, seq & ~1)); in kvm_s390_get_cpu_timer()
3542 gmap_enable(vcpu->arch.enabled_gmap); in kvm_arch_vcpu_load()
3544 if (vcpu->arch.cputm_enabled && !is_vcpu_idle(vcpu)) in kvm_arch_vcpu_load()
3552 if (vcpu->arch.cputm_enabled && !is_vcpu_idle(vcpu)) in kvm_arch_vcpu_put()
3555 vcpu->arch.enabled_gmap = gmap_get_enabled(); in kvm_arch_vcpu_put()
3556 gmap_disable(vcpu->arch.enabled_gmap); in kvm_arch_vcpu_put()
3564 vcpu->arch.sie_block->epoch = vcpu->kvm->arch.epoch; in kvm_arch_vcpu_postcreate()
3565 vcpu->arch.sie_block->epdx = vcpu->kvm->arch.epdx; in kvm_arch_vcpu_postcreate()
3569 vcpu->arch.gmap = vcpu->kvm->arch.gmap; in kvm_arch_vcpu_postcreate()
3572 if (test_kvm_facility(vcpu->kvm, 74) || vcpu->kvm->arch.user_instr0) in kvm_arch_vcpu_postcreate()
3573 vcpu->arch.sie_block->ictl |= ICTL_OPEREXC; in kvm_arch_vcpu_postcreate()
3575 vcpu->arch.enabled_gmap = vcpu->arch.gmap; in kvm_arch_vcpu_postcreate()
3580 if (test_bit_inv(nr, (unsigned long *)&kvm->arch.model.subfuncs.pckmo) && in kvm_has_pckmo_subfunc()
3603 if (!vcpu->kvm->arch.crypto.apie && !test_kvm_facility(vcpu->kvm, 76)) in kvm_s390_vcpu_crypto_setup()
3606 vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd; in kvm_s390_vcpu_crypto_setup()
3607 vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA); in kvm_s390_vcpu_crypto_setup()
3608 vcpu->arch.sie_block->eca &= ~ECA_APIE; in kvm_s390_vcpu_crypto_setup()
3609 vcpu->arch.sie_block->ecd &= ~ECD_ECC; in kvm_s390_vcpu_crypto_setup()
3611 if (vcpu->kvm->arch.crypto.apie) in kvm_s390_vcpu_crypto_setup()
3612 vcpu->arch.sie_block->eca |= ECA_APIE; in kvm_s390_vcpu_crypto_setup()
3615 if (vcpu->kvm->arch.crypto.aes_kw) { in kvm_s390_vcpu_crypto_setup()
3616 vcpu->arch.sie_block->ecb3 |= ECB3_AES; in kvm_s390_vcpu_crypto_setup()
3619 vcpu->arch.sie_block->ecd |= ECD_ECC; in kvm_s390_vcpu_crypto_setup()
3622 if (vcpu->kvm->arch.crypto.dea_kw) in kvm_s390_vcpu_crypto_setup()
3623 vcpu->arch.sie_block->ecb3 |= ECB3_DEA; in kvm_s390_vcpu_crypto_setup()
3628 free_page(vcpu->arch.sie_block->cbrlo); in kvm_s390_vcpu_unsetup_cmma()
3629 vcpu->arch.sie_block->cbrlo = 0; in kvm_s390_vcpu_unsetup_cmma()
3634 vcpu->arch.sie_block->cbrlo = get_zeroed_page(GFP_KERNEL_ACCOUNT); in kvm_s390_vcpu_setup_cmma()
3635 if (!vcpu->arch.sie_block->cbrlo) in kvm_s390_vcpu_setup_cmma()
3642 struct kvm_s390_cpu_model *model = &vcpu->kvm->arch.model; in kvm_s390_vcpu_setup_model()
3644 vcpu->arch.sie_block->ibc = model->ibc; in kvm_s390_vcpu_setup_model()
3646 vcpu->arch.sie_block->fac = (u32)(u64) model->fac_list; in kvm_s390_vcpu_setup_model()
3654 atomic_set(&vcpu->arch.sie_block->cpuflags, CPUSTAT_ZARCH | in kvm_s390_vcpu_setup()
3667 vcpu->arch.sie_block->ecb |= ECB_HOSTPROTINT; in kvm_s390_vcpu_setup()
3669 vcpu->arch.sie_block->ecb |= ECB_SRSI; in kvm_s390_vcpu_setup()
3671 vcpu->arch.sie_block->ecb |= ECB_PTF; in kvm_s390_vcpu_setup()
3673 vcpu->arch.sie_block->ecb |= ECB_TE; in kvm_s390_vcpu_setup()
3675 vcpu->arch.sie_block->ecb |= ECB_SPECI; in kvm_s390_vcpu_setup()
3677 if (test_kvm_facility(vcpu->kvm, 8) && vcpu->kvm->arch.use_pfmfi) in kvm_s390_vcpu_setup()
3678 vcpu->arch.sie_block->ecb2 |= ECB2_PFMFI; in kvm_s390_vcpu_setup()
3680 vcpu->arch.sie_block->ecb2 |= ECB2_IEP; in kvm_s390_vcpu_setup()
3681 vcpu->arch.sie_block->eca = ECA_MVPGI | ECA_PROTEXCI; in kvm_s390_vcpu_setup()
3683 vcpu->arch.sie_block->eca |= ECA_CEI; in kvm_s390_vcpu_setup()
3685 vcpu->arch.sie_block->eca |= ECA_IB; in kvm_s390_vcpu_setup()
3687 vcpu->arch.sie_block->eca |= ECA_SII; in kvm_s390_vcpu_setup()
3689 vcpu->arch.sie_block->eca |= ECA_SIGPI; in kvm_s390_vcpu_setup()
3691 vcpu->arch.sie_block->eca |= ECA_VX; in kvm_s390_vcpu_setup()
3692 vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT; in kvm_s390_vcpu_setup()
3695 vcpu->arch.sie_block->ecd |= ECD_MEF; in kvm_s390_vcpu_setup()
3697 vcpu->arch.sie_block->ecd |= ECD_ETOKENF; in kvm_s390_vcpu_setup()
3698 if (vcpu->arch.sie_block->gd) { in kvm_s390_vcpu_setup()
3699 vcpu->arch.sie_block->eca |= ECA_AIV; in kvm_s390_vcpu_setup()
3701 vcpu->arch.sie_block->gd & 0x3, vcpu->vcpu_id); in kvm_s390_vcpu_setup()
3703 vcpu->arch.sie_block->sdnxo = ((unsigned long) &vcpu->run->s.regs.sdnx) in kvm_s390_vcpu_setup()
3705 vcpu->arch.sie_block->riccbd = (unsigned long) &vcpu->run->s.regs.riccb; in kvm_s390_vcpu_setup()
3710 vcpu->arch.sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE; in kvm_s390_vcpu_setup()
3712 if (vcpu->kvm->arch.use_cmma) { in kvm_s390_vcpu_setup()
3717 hrtimer_init(&vcpu->arch.ckc_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in kvm_s390_vcpu_setup()
3718 vcpu->arch.ckc_timer.function = kvm_s390_idle_wakeup; in kvm_s390_vcpu_setup()
3720 vcpu->arch.sie_block->hpid = HPID_KVM; in kvm_s390_vcpu_setup()
3754 vcpu->arch.sie_block = &sie_page->sie_block; in kvm_arch_vcpu_create()
3755 vcpu->arch.sie_block->itdba = (unsigned long) &sie_page->itdb; in kvm_arch_vcpu_create()
3758 vcpu->arch.sie_block->mso = 0; in kvm_arch_vcpu_create()
3759 vcpu->arch.sie_block->msl = sclp.hamax; in kvm_arch_vcpu_create()
3761 vcpu->arch.sie_block->icpua = vcpu->vcpu_id; in kvm_arch_vcpu_create()
3762 spin_lock_init(&vcpu->arch.local_int.lock); in kvm_arch_vcpu_create()
3763 vcpu->arch.sie_block->gd = kvm_s390_get_gisa_desc(vcpu->kvm); in kvm_arch_vcpu_create()
3764 seqcount_init(&vcpu->arch.cputm_seqcount); in kvm_arch_vcpu_create()
3766 vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; in kvm_arch_vcpu_create()
3799 vcpu->vcpu_id, vcpu, vcpu->arch.sie_block); in kvm_arch_vcpu_create()
3800 trace_kvm_s390_create_vcpu(vcpu->vcpu_id, vcpu, vcpu->arch.sie_block); in kvm_arch_vcpu_create()
3811 gmap_remove(vcpu->arch.gmap); in kvm_arch_vcpu_create()
3813 free_page((unsigned long)(vcpu->arch.sie_block)); in kvm_arch_vcpu_create()
3819 clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask); in kvm_arch_vcpu_runnable()
3825 return !(vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE); in kvm_arch_vcpu_in_kernel()
3830 atomic_or(PROG_BLOCK_SIE, &vcpu->arch.sie_block->prog20); in kvm_s390_vcpu_block()
3836 atomic_andnot(PROG_BLOCK_SIE, &vcpu->arch.sie_block->prog20); in kvm_s390_vcpu_unblock()
3841 atomic_or(PROG_REQUEST, &vcpu->arch.sie_block->prog20); in kvm_s390_vcpu_request()
3847 return atomic_read(&vcpu->arch.sie_block->prog20) & in kvm_s390_vcpu_sie_inhibited()
3853 atomic_andnot(PROG_REQUEST, &vcpu->arch.sie_block->prog20); in kvm_s390_vcpu_request_handled()
3864 while (vcpu->arch.sie_block->prog0c & PROG_IN_SIE) in exit_sie()
3924 r = put_user(vcpu->arch.sie_block->todpr, in kvm_arch_vcpu_ioctl_get_one_reg()
3928 r = put_user(vcpu->arch.sie_block->epoch, in kvm_arch_vcpu_ioctl_get_one_reg()
3936 r = put_user(vcpu->arch.sie_block->ckc, in kvm_arch_vcpu_ioctl_get_one_reg()
3940 r = put_user(vcpu->arch.pfault_token, in kvm_arch_vcpu_ioctl_get_one_reg()
3944 r = put_user(vcpu->arch.pfault_compare, in kvm_arch_vcpu_ioctl_get_one_reg()
3948 r = put_user(vcpu->arch.pfault_select, in kvm_arch_vcpu_ioctl_get_one_reg()
3952 r = put_user(vcpu->arch.sie_block->pp, in kvm_arch_vcpu_ioctl_get_one_reg()
3956 r = put_user(vcpu->arch.sie_block->gbea, in kvm_arch_vcpu_ioctl_get_one_reg()
3974 r = get_user(vcpu->arch.sie_block->todpr, in kvm_arch_vcpu_ioctl_set_one_reg()
3978 r = get_user(vcpu->arch.sie_block->epoch, in kvm_arch_vcpu_ioctl_set_one_reg()
3987 r = get_user(vcpu->arch.sie_block->ckc, in kvm_arch_vcpu_ioctl_set_one_reg()
3991 r = get_user(vcpu->arch.pfault_token, in kvm_arch_vcpu_ioctl_set_one_reg()
3993 if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID) in kvm_arch_vcpu_ioctl_set_one_reg()
3997 r = get_user(vcpu->arch.pfault_compare, in kvm_arch_vcpu_ioctl_set_one_reg()
4001 r = get_user(vcpu->arch.pfault_select, in kvm_arch_vcpu_ioctl_set_one_reg()
4005 r = get_user(vcpu->arch.sie_block->pp, in kvm_arch_vcpu_ioctl_set_one_reg()
4009 r = get_user(vcpu->arch.sie_block->gbea, in kvm_arch_vcpu_ioctl_set_one_reg()
4021 vcpu->arch.sie_block->gpsw.mask &= ~PSW_MASK_RI; in kvm_arch_vcpu_ioctl_normal_reset()
4022 vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; in kvm_arch_vcpu_ioctl_normal_reset()
4040 vcpu->arch.sie_block->gpsw.mask = 0; in kvm_arch_vcpu_ioctl_initial_reset()
4041 vcpu->arch.sie_block->gpsw.addr = 0; in kvm_arch_vcpu_ioctl_initial_reset()
4044 vcpu->arch.sie_block->ckc = 0; in kvm_arch_vcpu_ioctl_initial_reset()
4045 memset(vcpu->arch.sie_block->gcr, 0, sizeof(vcpu->arch.sie_block->gcr)); in kvm_arch_vcpu_ioctl_initial_reset()
4046 vcpu->arch.sie_block->gcr[0] = CR0_INITIAL_MASK; in kvm_arch_vcpu_ioctl_initial_reset()
4047 vcpu->arch.sie_block->gcr[14] = CR14_INITIAL_MASK; in kvm_arch_vcpu_ioctl_initial_reset()
4068 vcpu->arch.sie_block->gbea = 1; in kvm_arch_vcpu_ioctl_initial_reset()
4069 vcpu->arch.sie_block->pp = 0; in kvm_arch_vcpu_ioctl_initial_reset()
4070 vcpu->arch.sie_block->fpf &= ~FPF_BPBC; in kvm_arch_vcpu_ioctl_initial_reset()
4071 vcpu->arch.sie_block->todpr = 0; in kvm_arch_vcpu_ioctl_initial_reset()
4113 memcpy(&vcpu->arch.sie_block->gcr, &sregs->crs, sizeof(sregs->crs)); in kvm_arch_vcpu_ioctl_set_sregs()
4125 memcpy(&sregs->crs, &vcpu->arch.sie_block->gcr, sizeof(sregs->crs)); in kvm_arch_vcpu_ioctl_get_sregs()
4221 vcpu->arch.guestdbg.last_bp = 0; in kvm_arch_vcpu_ioctl_set_guest_debug()
4304 rc = gmap_mprotect_notify(vcpu->arch.gmap, in kvm_s390_handle_requests()
4315 vcpu->arch.sie_block->ihcpu = 0xffff; in kvm_s390_handle_requests()
4336 vcpu->arch.sie_block->ictl |= ICTL_OPEREXC; in kvm_s390_handle_requests()
4346 vcpu->arch.sie_block->ecb2 &= ~ECB2_CMMA; in kvm_s390_handle_requests()
4355 if ((vcpu->kvm->arch.use_cmma) && in kvm_s390_handle_requests()
4357 vcpu->arch.sie_block->ecb2 |= ECB2_CMMA; in kvm_s390_handle_requests()
4377 kvm->arch.epoch = gtod->tod - clk.tod; in __kvm_s390_set_tod_clock()
4378 kvm->arch.epdx = 0; in __kvm_s390_set_tod_clock()
4380 kvm->arch.epdx = gtod->epoch_idx - clk.ei; in __kvm_s390_set_tod_clock()
4381 if (kvm->arch.epoch > gtod->tod) in __kvm_s390_set_tod_clock()
4382 kvm->arch.epdx -= 1; in __kvm_s390_set_tod_clock()
4387 vcpu->arch.sie_block->epoch = kvm->arch.epoch; in __kvm_s390_set_tod_clock()
4388 vcpu->arch.sie_block->epdx = kvm->arch.epdx; in __kvm_s390_set_tod_clock()
4416 return gmap_fault(vcpu->arch.gmap, gpa, in kvm_arch_fault_in_page()
4440 trace_kvm_s390_pfault_init(vcpu, work->arch.pfault_token); in kvm_arch_async_page_not_present()
4441 __kvm_inject_pfault_token(vcpu, true, work->arch.pfault_token); in kvm_arch_async_page_not_present()
4449 trace_kvm_s390_pfault_done(vcpu, work->arch.pfault_token); in kvm_arch_async_page_present()
4450 __kvm_inject_pfault_token(vcpu, false, work->arch.pfault_token); in kvm_arch_async_page_present()
4471 struct kvm_arch_async_pf arch; in kvm_arch_setup_async_pf() local
4473 if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID) in kvm_arch_setup_async_pf()
4475 if ((vcpu->arch.sie_block->gpsw.mask & vcpu->arch.pfault_select) != in kvm_arch_setup_async_pf()
4476 vcpu->arch.pfault_compare) in kvm_arch_setup_async_pf()
4482 if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK)) in kvm_arch_setup_async_pf()
4484 if (!vcpu->arch.gmap->pfault_enabled) in kvm_arch_setup_async_pf()
4489 if (read_guest_real(vcpu, vcpu->arch.pfault_token, &arch.pfault_token, 8)) in kvm_arch_setup_async_pf()
4492 return kvm_setup_async_pf(vcpu, current->thread.gmap_addr, hva, &arch); in kvm_arch_setup_async_pf()
4506 vcpu->arch.sie_block->gg14 = vcpu->run->s.regs.gprs[14]; in vcpu_pre_run()
4507 vcpu->arch.sie_block->gg15 = vcpu->run->s.regs.gprs[15]; in vcpu_pre_run()
4527 clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.gisa_int.kicked_mask); in vcpu_pre_run()
4529 vcpu->arch.sie_block->icptcode = 0; in vcpu_pre_run()
4530 cpuflags = atomic_read(&vcpu->arch.sie_block->cpuflags); in vcpu_pre_run()
4556 rc = read_guest_instr(vcpu, vcpu->arch.sie_block->gpsw.addr, &opcode, 1); in vcpu_post_run_fault_in_sie()
4565 pgm_info = vcpu->arch.pgm; in vcpu_post_run_fault_in_sie()
4579 vcpu->arch.sie_block->icptcode); in vcpu_post_run()
4580 trace_kvm_s390_sie_exit(vcpu, vcpu->arch.sie_block->icptcode); in vcpu_post_run()
4585 vcpu->run->s.regs.gprs[14] = vcpu->arch.sie_block->gg14; in vcpu_post_run()
4586 vcpu->run->s.regs.gprs[15] = vcpu->arch.sie_block->gg15; in vcpu_post_run()
4590 sie_page = container_of(vcpu->arch.sie_block, in vcpu_post_run()
4597 if (vcpu->arch.sie_block->icptcode > 0) { in vcpu_post_run()
4603 vcpu->run->s390_sieic.icptcode = vcpu->arch.sie_block->icptcode; in vcpu_post_run()
4604 vcpu->run->s390_sieic.ipa = vcpu->arch.sie_block->ipa; in vcpu_post_run()
4605 vcpu->run->s390_sieic.ipb = vcpu->arch.sie_block->ipb; in vcpu_post_run()
4631 struct sie_page *sie_page = (struct sie_page *)vcpu->arch.sie_block; in __vcpu_run()
4660 exit_reason = sie64a(vcpu->arch.sie_block, in __vcpu_run()
4672 if (vcpu->arch.sie_block->icptcode == ICPT_PV_INSTR || in __vcpu_run()
4673 vcpu->arch.sie_block->icptcode == ICPT_PV_PREF) { in __vcpu_run()
4674 vcpu->arch.sie_block->gpsw.mask &= ~PSW_INT_MASK; in __vcpu_run()
4698 vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask; in sync_regs_fmt2()
4699 vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr; in sync_regs_fmt2()
4701 vcpu->arch.sie_block->todpr = kvm_run->s.regs.todpr; in sync_regs_fmt2()
4702 vcpu->arch.sie_block->pp = kvm_run->s.regs.pp; in sync_regs_fmt2()
4703 vcpu->arch.sie_block->gbea = kvm_run->s.regs.gbea; in sync_regs_fmt2()
4706 vcpu->arch.pfault_token = kvm_run->s.regs.pft; in sync_regs_fmt2()
4707 vcpu->arch.pfault_select = kvm_run->s.regs.pfs; in sync_regs_fmt2()
4708 vcpu->arch.pfault_compare = kvm_run->s.regs.pfc; in sync_regs_fmt2()
4709 if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID) in sync_regs_fmt2()
4713 vcpu->arch.diag318_info.val = kvm_run->s.regs.diag318; in sync_regs_fmt2()
4714 vcpu->arch.sie_block->cpnc = vcpu->arch.diag318_info.cpnc; in sync_regs_fmt2()
4715 VCPU_EVENT(vcpu, 3, "setting cpnc to %d", vcpu->arch.diag318_info.cpnc); in sync_regs_fmt2()
4724 !(vcpu->arch.sie_block->ecb3 & ECB3_RI)) { in sync_regs_fmt2()
4726 vcpu->arch.sie_block->ecb3 |= ECB3_RI; in sync_regs_fmt2()
4735 !vcpu->arch.gs_enabled) { in sync_regs_fmt2()
4737 vcpu->arch.sie_block->ecb |= ECB_GS; in sync_regs_fmt2()
4738 vcpu->arch.sie_block->ecd |= ECD_HOSTREGMGMT; in sync_regs_fmt2()
4739 vcpu->arch.gs_enabled = 1; in sync_regs_fmt2()
4743 vcpu->arch.sie_block->fpf &= ~FPF_BPBC; in sync_regs_fmt2()
4744 vcpu->arch.sie_block->fpf |= kvm_run->s.regs.bpbc ? FPF_BPBC : 0; in sync_regs_fmt2()
4750 vcpu->arch.host_gscb = current->thread.gs_cb; in sync_regs_fmt2()
4751 save_gs_cb(vcpu->arch.host_gscb); in sync_regs_fmt2()
4753 if (vcpu->arch.gs_enabled) { in sync_regs_fmt2()
4770 memcpy(&vcpu->arch.sie_block->gcr, &kvm_run->s.regs.crs, 128); in sync_regs()
4776 vcpu->arch.sie_block->ckc = kvm_run->s.regs.ckc; in sync_regs()
4778 save_access_regs(vcpu->arch.host_acrs); in sync_regs()
4782 vcpu->arch.host_fpregs.fpc = current->thread.fpu.fpc; in sync_regs()
4783 vcpu->arch.host_fpregs.regs = current->thread.fpu.regs; in sync_regs()
4806 vcpu->arch.sie_block->gpsw.mask &= ~PSW_MASK_CC; in sync_regs()
4807 vcpu->arch.sie_block->gpsw.mask |= kvm_run->psw_mask & in sync_regs()
4818 kvm_run->s.regs.todpr = vcpu->arch.sie_block->todpr; in store_regs_fmt2()
4819 kvm_run->s.regs.pp = vcpu->arch.sie_block->pp; in store_regs_fmt2()
4820 kvm_run->s.regs.gbea = vcpu->arch.sie_block->gbea; in store_regs_fmt2()
4821 kvm_run->s.regs.bpbc = (vcpu->arch.sie_block->fpf & FPF_BPBC) == FPF_BPBC; in store_regs_fmt2()
4822 kvm_run->s.regs.diag318 = vcpu->arch.diag318_info.val; in store_regs_fmt2()
4826 if (vcpu->arch.gs_enabled) in store_regs_fmt2()
4828 current->thread.gs_cb = vcpu->arch.host_gscb; in store_regs_fmt2()
4829 restore_gs_cb(vcpu->arch.host_gscb); in store_regs_fmt2()
4830 if (!vcpu->arch.host_gscb) in store_regs_fmt2()
4832 vcpu->arch.host_gscb = NULL; in store_regs_fmt2()
4842 kvm_run->psw_mask = vcpu->arch.sie_block->gpsw.mask; in store_regs()
4843 kvm_run->psw_addr = vcpu->arch.sie_block->gpsw.addr; in store_regs()
4845 memcpy(&kvm_run->s.regs.crs, &vcpu->arch.sie_block->gcr, 128); in store_regs()
4847 kvm_run->s.regs.ckc = vcpu->arch.sie_block->ckc; in store_regs()
4848 kvm_run->s.regs.pft = vcpu->arch.pfault_token; in store_regs()
4849 kvm_run->s.regs.pfs = vcpu->arch.pfault_select; in store_regs()
4850 kvm_run->s.regs.pfc = vcpu->arch.pfault_compare; in store_regs()
4852 restore_access_regs(vcpu->arch.host_acrs); in store_regs()
4857 current->thread.fpu.fpc = vcpu->arch.host_fpregs.fpc; in store_regs()
4858 current->thread.fpu.regs = vcpu->arch.host_fpregs.regs; in store_regs()
4874 if (vcpu->kvm->arch.pv.dumping) in kvm_arch_vcpu_ioctl_run()
4977 &vcpu->arch.sie_block->gpsw, 16); in kvm_s390_store_status_unloaded()
4983 &vcpu->arch.sie_block->todpr, 4); in kvm_s390_store_status_unloaded()
4987 clkcomp = vcpu->arch.sie_block->ckc >> 8; in kvm_s390_store_status_unloaded()
4993 &vcpu->arch.sie_block->gcr, 128); in kvm_s390_store_status_unloaded()
5044 spin_lock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_start()
5051 spin_unlock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_start()
5080 vcpu->arch.sie_block->gpsw.mask &= ~PSW_INT_MASK; in kvm_s390_vcpu_start()
5086 spin_unlock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_start()
5100 spin_lock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_stop()
5107 spin_unlock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_stop()
5140 spin_unlock(&vcpu->kvm->arch.start_stop_lock); in kvm_s390_vcpu_stop()
5154 if (!vcpu->kvm->arch.css_support) { in kvm_vcpu_ioctl_enable_cap()
5155 vcpu->kvm->arch.css_support = 1; in kvm_vcpu_ioctl_enable_cap()
5178 if (mop->size + mop->sida_offset > sida_size(vcpu->arch.sie_block)) in kvm_s390_vcpu_sida_op()
5185 if (copy_to_user(uaddr, (void *)(sida_origin(vcpu->arch.sie_block) + in kvm_s390_vcpu_sida_op()
5191 if (copy_from_user((void *)(sida_origin(vcpu->arch.sie_block) + in kvm_s390_vcpu_sida_op()
5257 kvm_s390_inject_prog_irq(vcpu, &vcpu->arch.pgm); in kvm_s390_vcpu_mem_op()
5324 if (!vcpu->kvm->arch.pv.dumping) in kvm_s390_handle_pv_vcpu_dump()
5444 r = gmap_map_segment(vcpu->arch.gmap, ucasmap.user_addr, in kvm_arch_vcpu_ioctl()
5461 r = gmap_unmap_segment(vcpu->arch.gmap, ucasmap.vcpu_addr, in kvm_arch_vcpu_ioctl()
5467 r = gmap_fault(vcpu->arch.gmap, arg, 0); in kvm_arch_vcpu_ioctl()
5562 vmf->page = virt_to_page(vcpu->arch.sie_block); in kvm_arch_vcpu_fault()
5597 if ((new->base_gfn * PAGE_SIZE) + size > kvm->arch.mem_limit) in kvm_arch_prepare_memory_region()
5612 rc = gmap_unmap_segment(kvm->arch.gmap, old->base_gfn * PAGE_SIZE, in kvm_arch_commit_memory_region()
5616 rc = gmap_unmap_segment(kvm->arch.gmap, old->base_gfn * PAGE_SIZE, in kvm_arch_commit_memory_region()
5622 rc = gmap_map_segment(kvm->arch.gmap, new->userspace_addr, in kvm_arch_commit_memory_region()