Loading arch/s390/include/asm/kvm_host.h +1 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,7 @@ struct kvm_s390_sie_block { #define ECD_MEF 0x08000000 #define ECD_ETOKENF 0x02000000 #define ECD_ECC 0x00200000 #define ECD_HMAC 0x00004000 __u32 ecd; /* 0x01c8 */ __u8 reserved1cc[18]; /* 0x01cc */ __u64 pp; /* 0x01de */ Loading arch/s390/include/uapi/asm/kvm.h +2 −1 Original line number Diff line number Diff line Loading @@ -469,7 +469,8 @@ struct kvm_s390_vm_cpu_subfunc { __u8 kdsa[16]; /* with MSA9 */ __u8 sortl[32]; /* with STFLE.150 */ __u8 dfltcc[32]; /* with STFLE.151 */ __u8 reserved[1728]; __u8 pfcr[16]; /* with STFLE.201 */ __u8 reserved[1712]; }; #define KVM_S390_VM_CPU_PROCESSOR_UV_FEAT_GUEST 6 Loading arch/s390/kvm/kvm-s390.c +41 −2 Original line number Diff line number Diff line Loading @@ -348,6 +348,16 @@ static inline int plo_test_bit(unsigned char nr) return cc == 0; } static __always_inline void pfcr_query(u8 (*query)[16]) { asm volatile( " lghi 0,0\n" " .insn rsy,0xeb0000000016,0,0,%[query]\n" : [query] "=QS" (*query) : : "cc", "0"); } static __always_inline void __sortl_query(u8 (*query)[32]) { asm volatile( Loading Loading @@ -429,6 +439,9 @@ static void __init kvm_s390_cpu_feat_init(void) if (test_facility(151)) /* DFLTCC */ __dfltcc_query(&kvm_s390_available_subfunc.dfltcc); if (test_facility(201)) /* PFCR */ pfcr_query(&kvm_s390_available_subfunc.pfcr); if (MACHINE_HAS_ESOP) allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP); /* Loading Loading @@ -799,6 +812,14 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap) set_kvm_facility(kvm->arch.model.fac_mask, 192); set_kvm_facility(kvm->arch.model.fac_list, 192); } if (test_facility(198)) { set_kvm_facility(kvm->arch.model.fac_mask, 198); set_kvm_facility(kvm->arch.model.fac_list, 198); } if (test_facility(199)) { set_kvm_facility(kvm->arch.model.fac_mask, 199); set_kvm_facility(kvm->arch.model.fac_list, 199); } r = 0; } else r = -EINVAL; Loading Loading @@ -1543,6 +1564,9 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm, ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: guest PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -1757,6 +1781,9 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm, ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: guest PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -1825,6 +1852,9 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm, ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[1], ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[2], ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: host PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -3774,6 +3804,13 @@ static bool kvm_has_pckmo_ecc(struct kvm *kvm) } static bool kvm_has_pckmo_hmac(struct kvm *kvm) { /* At least one HMAC subfunction must be present */ return kvm_has_pckmo_subfunc(kvm, 118) || kvm_has_pckmo_subfunc(kvm, 122); } static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) { /* Loading @@ -3786,7 +3823,7 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd; vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA); vcpu->arch.sie_block->eca &= ~ECA_APIE; vcpu->arch.sie_block->ecd &= ~ECD_ECC; vcpu->arch.sie_block->ecd &= ~(ECD_ECC | ECD_HMAC); if (vcpu->kvm->arch.crypto.apie) vcpu->arch.sie_block->eca |= ECA_APIE; Loading @@ -3794,9 +3831,11 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) /* Set up protected key support */ if (vcpu->kvm->arch.crypto.aes_kw) { vcpu->arch.sie_block->ecb3 |= ECB3_AES; /* ecc is also wrapped with AES key */ /* ecc/hmac is also wrapped with AES key */ if (kvm_has_pckmo_ecc(vcpu->kvm)) vcpu->arch.sie_block->ecd |= ECD_ECC; if (kvm_has_pckmo_hmac(vcpu->kvm)) vcpu->arch.sie_block->ecd |= ECD_HMAC; } if (vcpu->kvm->arch.crypto.dea_kw) Loading arch/s390/kvm/vsie.c +2 −1 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) /* we may only allow it if enabled for guest 2 */ ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 & (ECB3_AES | ECB3_DEA); ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC; ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & (ECD_ECC | ECD_HMAC); if (!ecb3_flags && !ecd_flags) goto end; Loading arch/s390/tools/gen_facilities.c +2 −0 Original line number Diff line number Diff line Loading @@ -109,10 +109,12 @@ static struct facility_def facility_defs[] = { 15, /* AP Facilities Test */ 156, /* etoken facility */ 165, /* nnpa facility */ 170, /* ineffective-nonconstrained-transaction facility */ 193, /* bear enhancement facility */ 194, /* rdp enhancement facility */ 196, /* processor activity instrumentation facility */ 197, /* processor activity instrumentation extension 1 */ 201, /* concurrent-functions facility */ -1 /* END */ } }, Loading Loading
arch/s390/include/asm/kvm_host.h +1 −0 Original line number Diff line number Diff line Loading @@ -356,6 +356,7 @@ struct kvm_s390_sie_block { #define ECD_MEF 0x08000000 #define ECD_ETOKENF 0x02000000 #define ECD_ECC 0x00200000 #define ECD_HMAC 0x00004000 __u32 ecd; /* 0x01c8 */ __u8 reserved1cc[18]; /* 0x01cc */ __u64 pp; /* 0x01de */ Loading
arch/s390/include/uapi/asm/kvm.h +2 −1 Original line number Diff line number Diff line Loading @@ -469,7 +469,8 @@ struct kvm_s390_vm_cpu_subfunc { __u8 kdsa[16]; /* with MSA9 */ __u8 sortl[32]; /* with STFLE.150 */ __u8 dfltcc[32]; /* with STFLE.151 */ __u8 reserved[1728]; __u8 pfcr[16]; /* with STFLE.201 */ __u8 reserved[1712]; }; #define KVM_S390_VM_CPU_PROCESSOR_UV_FEAT_GUEST 6 Loading
arch/s390/kvm/kvm-s390.c +41 −2 Original line number Diff line number Diff line Loading @@ -348,6 +348,16 @@ static inline int plo_test_bit(unsigned char nr) return cc == 0; } static __always_inline void pfcr_query(u8 (*query)[16]) { asm volatile( " lghi 0,0\n" " .insn rsy,0xeb0000000016,0,0,%[query]\n" : [query] "=QS" (*query) : : "cc", "0"); } static __always_inline void __sortl_query(u8 (*query)[32]) { asm volatile( Loading Loading @@ -429,6 +439,9 @@ static void __init kvm_s390_cpu_feat_init(void) if (test_facility(151)) /* DFLTCC */ __dfltcc_query(&kvm_s390_available_subfunc.dfltcc); if (test_facility(201)) /* PFCR */ pfcr_query(&kvm_s390_available_subfunc.pfcr); if (MACHINE_HAS_ESOP) allow_cpu_feat(KVM_S390_VM_CPU_FEAT_ESOP); /* Loading Loading @@ -799,6 +812,14 @@ int kvm_vm_ioctl_enable_cap(struct kvm *kvm, struct kvm_enable_cap *cap) set_kvm_facility(kvm->arch.model.fac_mask, 192); set_kvm_facility(kvm->arch.model.fac_list, 192); } if (test_facility(198)) { set_kvm_facility(kvm->arch.model.fac_mask, 198); set_kvm_facility(kvm->arch.model.fac_list, 198); } if (test_facility(199)) { set_kvm_facility(kvm->arch.model.fac_mask, 199); set_kvm_facility(kvm->arch.model.fac_list, 199); } r = 0; } else r = -EINVAL; Loading Loading @@ -1543,6 +1564,9 @@ static int kvm_s390_set_processor_subfunc(struct kvm *kvm, ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: guest PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -1757,6 +1781,9 @@ static int kvm_s390_get_processor_subfunc(struct kvm *kvm, ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[1], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[2], ((unsigned long *) &kvm->arch.model.subfuncs.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: guest PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -1825,6 +1852,9 @@ static int kvm_s390_get_machine_subfunc(struct kvm *kvm, ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[1], ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[2], ((unsigned long *) &kvm_s390_available_subfunc.dfltcc)[3]); VM_EVENT(kvm, 3, "GET: host PFCR subfunc 0x%16.16lx.%16.16lx", ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[0], ((unsigned long *) &kvm_s390_available_subfunc.pfcr)[1]); return 0; } Loading Loading @@ -3774,6 +3804,13 @@ static bool kvm_has_pckmo_ecc(struct kvm *kvm) } static bool kvm_has_pckmo_hmac(struct kvm *kvm) { /* At least one HMAC subfunction must be present */ return kvm_has_pckmo_subfunc(kvm, 118) || kvm_has_pckmo_subfunc(kvm, 122); } static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) { /* Loading @@ -3786,7 +3823,7 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd; vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA); vcpu->arch.sie_block->eca &= ~ECA_APIE; vcpu->arch.sie_block->ecd &= ~ECD_ECC; vcpu->arch.sie_block->ecd &= ~(ECD_ECC | ECD_HMAC); if (vcpu->kvm->arch.crypto.apie) vcpu->arch.sie_block->eca |= ECA_APIE; Loading @@ -3794,9 +3831,11 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) /* Set up protected key support */ if (vcpu->kvm->arch.crypto.aes_kw) { vcpu->arch.sie_block->ecb3 |= ECB3_AES; /* ecc is also wrapped with AES key */ /* ecc/hmac is also wrapped with AES key */ if (kvm_has_pckmo_ecc(vcpu->kvm)) vcpu->arch.sie_block->ecd |= ECD_ECC; if (kvm_has_pckmo_hmac(vcpu->kvm)) vcpu->arch.sie_block->ecd |= ECD_HMAC; } if (vcpu->kvm->arch.crypto.dea_kw) Loading
arch/s390/kvm/vsie.c +2 −1 Original line number Diff line number Diff line Loading @@ -335,7 +335,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) /* we may only allow it if enabled for guest 2 */ ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 & (ECB3_AES | ECB3_DEA); ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC; ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & (ECD_ECC | ECD_HMAC); if (!ecb3_flags && !ecd_flags) goto end; Loading
arch/s390/tools/gen_facilities.c +2 −0 Original line number Diff line number Diff line Loading @@ -109,10 +109,12 @@ static struct facility_def facility_defs[] = { 15, /* AP Facilities Test */ 156, /* etoken facility */ 165, /* nnpa facility */ 170, /* ineffective-nonconstrained-transaction facility */ 193, /* bear enhancement facility */ 194, /* rdp enhancement facility */ 196, /* processor activity instrumentation facility */ 197, /* processor activity instrumentation extension 1 */ 201, /* concurrent-functions facility */ -1 /* END */ } }, Loading