Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm/s390 bugfixes from Marcelo Tosatti.

* git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: s390: non-LPAR case obsolete during facilities mask init
KVM: s390: include guest facilities in kvm facility test
KVM: s390: fix in memory copy of facility lists
KVM: s390/cpacf: Fix kernel bug under z/VM
KVM: s390/cpacf: Enable key wrapping by default

+40 -45
+6 -6
arch/s390/include/asm/kvm_host.h
··· 515 515 #define S390_ARCH_FAC_MASK_SIZE_U64 \ 516 516 (S390_ARCH_FAC_MASK_SIZE_BYTE / sizeof(u64)) 517 517 518 - struct s390_model_fac { 519 - /* facilities used in SIE context */ 520 - __u64 sie[S390_ARCH_FAC_LIST_SIZE_U64]; 521 - /* subset enabled by kvm */ 522 - __u64 kvm[S390_ARCH_FAC_LIST_SIZE_U64]; 518 + struct kvm_s390_fac { 519 + /* facility list requested by guest */ 520 + __u64 list[S390_ARCH_FAC_LIST_SIZE_U64]; 521 + /* facility mask supported by kvm & hosting machine */ 522 + __u64 mask[S390_ARCH_FAC_LIST_SIZE_U64]; 523 523 }; 524 524 525 525 struct kvm_s390_cpu_model { 526 - struct s390_model_fac *fac; 526 + struct kvm_s390_fac *fac; 527 527 struct cpuid cpu_id; 528 528 unsigned short ibc; 529 529 };
+31 -37
arch/s390/kvm/kvm-s390.c
··· 522 522 memcpy(&kvm->arch.model.cpu_id, &proc->cpuid, 523 523 sizeof(struct cpuid)); 524 524 kvm->arch.model.ibc = proc->ibc; 525 - memcpy(kvm->arch.model.fac->kvm, proc->fac_list, 525 + memcpy(kvm->arch.model.fac->list, proc->fac_list, 526 526 S390_ARCH_FAC_LIST_SIZE_BYTE); 527 527 } else 528 528 ret = -EFAULT; ··· 556 556 } 557 557 memcpy(&proc->cpuid, &kvm->arch.model.cpu_id, sizeof(struct cpuid)); 558 558 proc->ibc = kvm->arch.model.ibc; 559 - memcpy(&proc->fac_list, kvm->arch.model.fac->kvm, S390_ARCH_FAC_LIST_SIZE_BYTE); 559 + memcpy(&proc->fac_list, kvm->arch.model.fac->list, S390_ARCH_FAC_LIST_SIZE_BYTE); 560 560 if (copy_to_user((void __user *)attr->addr, proc, sizeof(*proc))) 561 561 ret = -EFAULT; 562 562 kfree(proc); ··· 576 576 } 577 577 get_cpu_id((struct cpuid *) &mach->cpuid); 578 578 mach->ibc = sclp_get_ibc(); 579 - memcpy(&mach->fac_mask, kvm_s390_fac_list_mask, 580 - kvm_s390_fac_list_mask_size() * sizeof(u64)); 579 + memcpy(&mach->fac_mask, kvm->arch.model.fac->mask, 580 + S390_ARCH_FAC_LIST_SIZE_BYTE); 581 581 memcpy((unsigned long *)&mach->fac_list, S390_lowcore.stfle_fac_list, 582 - S390_ARCH_FAC_LIST_SIZE_U64); 582 + S390_ARCH_FAC_LIST_SIZE_BYTE); 583 583 if (copy_to_user((void __user *)attr->addr, mach, sizeof(*mach))) 584 584 ret = -EFAULT; 585 585 kfree(mach); ··· 778 778 static int kvm_s390_query_ap_config(u8 *config) 779 779 { 780 780 u32 fcn_code = 0x04000000UL; 781 - u32 cc; 781 + u32 cc = 0; 782 782 783 + memset(config, 0, 128); 783 784 asm volatile( 784 785 "lgr 0,%1\n" 785 786 "lgr 2,%2\n" 786 787 ".long 0xb2af0000\n" /* PQAP(QCI) */ 787 - "ipm %0\n" 788 + "0: ipm %0\n" 788 789 "srl %0,28\n" 789 - : "=r" (cc) 790 + "1:\n" 791 + EX_TABLE(0b, 1b) 792 + : "+r" (cc) 790 793 : "r" (fcn_code), "r" (config) 791 794 : "cc", "0", "2", "memory" 792 795 ); ··· 842 839 843 840 kvm_s390_set_crycb_format(kvm); 844 841 845 - /* Disable AES/DEA protected key functions by default */ 846 - kvm->arch.crypto.aes_kw = 0; 847 - kvm->arch.crypto.dea_kw = 0; 842 + /* Enable AES/DEA protected key functions by default */ 843 + kvm->arch.crypto.aes_kw = 1; 844 + kvm->arch.crypto.dea_kw = 1; 845 + get_random_bytes(kvm->arch.crypto.crycb->aes_wrapping_key_mask, 846 + sizeof(kvm->arch.crypto.crycb->aes_wrapping_key_mask)); 847 + get_random_bytes(kvm->arch.crypto.crycb->dea_wrapping_key_mask, 848 + sizeof(kvm->arch.crypto.crycb->dea_wrapping_key_mask)); 848 849 849 850 return 0; 850 851 } ··· 893 886 /* 894 887 * The architectural maximum amount of facilities is 16 kbit. To store 895 888 * this amount, 2 kbyte of memory is required. Thus we need a full 896 - * page to hold the active copy (arch.model.fac->sie) and the current 897 - * facilities set (arch.model.fac->kvm). Its address size has to be 889 + * page to hold the guest facility list (arch.model.fac->list) and the 890 + * facility mask (arch.model.fac->mask). Its address size has to be 898 891 * 31 bits and word aligned. 899 892 */ 900 893 kvm->arch.model.fac = 901 - (struct s390_model_fac *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 894 + (struct kvm_s390_fac *) get_zeroed_page(GFP_KERNEL | GFP_DMA); 902 895 if (!kvm->arch.model.fac) 903 896 goto out_nofac; 904 897 905 - memcpy(kvm->arch.model.fac->kvm, S390_lowcore.stfle_fac_list, 906 - S390_ARCH_FAC_LIST_SIZE_U64); 907 - 908 - /* 909 - * If this KVM host runs *not* in a LPAR, relax the facility bits 910 - * of the kvm facility mask by all missing facilities. This will allow 911 - * to determine the right CPU model by means of the remaining facilities. 912 - * Live guest migration must prohibit the migration of KVMs running in 913 - * a LPAR to non LPAR hosts. 914 - */ 915 - if (!MACHINE_IS_LPAR) 916 - for (i = 0; i < kvm_s390_fac_list_mask_size(); i++) 917 - kvm_s390_fac_list_mask[i] &= kvm->arch.model.fac->kvm[i]; 918 - 919 - /* 920 - * Apply the kvm facility mask to limit the kvm supported/tolerated 921 - * facility list. 922 - */ 898 + /* Populate the facility mask initially. */ 899 + memcpy(kvm->arch.model.fac->mask, S390_lowcore.stfle_fac_list, 900 + S390_ARCH_FAC_LIST_SIZE_BYTE); 923 901 for (i = 0; i < S390_ARCH_FAC_LIST_SIZE_U64; i++) { 924 902 if (i < kvm_s390_fac_list_mask_size()) 925 - kvm->arch.model.fac->kvm[i] &= kvm_s390_fac_list_mask[i]; 903 + kvm->arch.model.fac->mask[i] &= kvm_s390_fac_list_mask[i]; 926 904 else 927 - kvm->arch.model.fac->kvm[i] = 0UL; 905 + kvm->arch.model.fac->mask[i] = 0UL; 928 906 } 907 + 908 + /* Populate the facility list initially. */ 909 + memcpy(kvm->arch.model.fac->list, kvm->arch.model.fac->mask, 910 + S390_ARCH_FAC_LIST_SIZE_BYTE); 929 911 930 912 kvm_s390_get_cpu_id(&kvm->arch.model.cpu_id); 931 913 kvm->arch.model.ibc = sclp_get_ibc() & 0x0fff; ··· 1161 1165 1162 1166 mutex_lock(&vcpu->kvm->lock); 1163 1167 vcpu->arch.cpu_id = vcpu->kvm->arch.model.cpu_id; 1164 - memcpy(vcpu->kvm->arch.model.fac->sie, vcpu->kvm->arch.model.fac->kvm, 1165 - S390_ARCH_FAC_LIST_SIZE_BYTE); 1166 1168 vcpu->arch.sie_block->ibc = vcpu->kvm->arch.model.ibc; 1167 1169 mutex_unlock(&vcpu->kvm->lock); 1168 1170 ··· 1206 1212 vcpu->arch.sie_block->scaol = (__u32)(__u64)kvm->arch.sca; 1207 1213 set_bit(63 - id, (unsigned long *) &kvm->arch.sca->mcn); 1208 1214 } 1209 - vcpu->arch.sie_block->fac = (int) (long) kvm->arch.model.fac->sie; 1215 + vcpu->arch.sie_block->fac = (int) (long) kvm->arch.model.fac->list; 1210 1216 1211 1217 spin_lock_init(&vcpu->arch.local_int.lock); 1212 1218 vcpu->arch.local_int.float_int = &kvm->arch.float_int;
+2 -1
arch/s390/kvm/kvm-s390.h
··· 128 128 /* test availability of facility in a kvm intance */ 129 129 static inline int test_kvm_facility(struct kvm *kvm, unsigned long nr) 130 130 { 131 - return __test_facility(nr, kvm->arch.model.fac->kvm); 131 + return __test_facility(nr, kvm->arch.model.fac->mask) && 132 + __test_facility(nr, kvm->arch.model.fac->list); 132 133 } 133 134 134 135 /* are cpu states controlled by user space */
+1 -1
arch/s390/kvm/priv.c
··· 348 348 * We need to shift the lower 32 facility bits (bit 0-31) from a u64 349 349 * into a u32 memory representation. They will remain bits 0-31. 350 350 */ 351 - fac = *vcpu->kvm->arch.model.fac->sie >> 32; 351 + fac = *vcpu->kvm->arch.model.fac->list >> 32; 352 352 rc = write_guest_lc(vcpu, offsetof(struct _lowcore, stfl_fac_list), 353 353 &fac, sizeof(fac)); 354 354 if (rc)