History

KVM: s390: enable MSA9 keywrapping functions depending on cpu model

Instead of adding a new machine option to disable/enable the keywrapping options of pckmo (like for AES and DEA) we can now use the CPU model to decide. As ECC is also wrapped with the AES key we need that to be enabled.

Christian Borntraeger committed 7 years ago

Commit 8ec2fa51 parent 4f45b903 files · +31 −2Browse files

Unified · Split

3 files
  1. arch/s390/include/asm/kvm_host.h +1 −0
  2. arch/s390/kvm/kvm-s390.c +26 −1
  3. arch/s390/kvm/vsie.c +4 −1
arch/s390/include/asm/kvm_host.h+1−0
@@ -278,6 +278,7 @@ struct kvm_s390_sie_block { · 277 unmodified lines
278#define ECD_HOSTREGMGMT 0x20000000278#define ECD_HOSTREGMGMT 0x20000000
279#define ECD_MEF 0x08000000279#define ECD_MEF 0x08000000
280#define ECD_ETOKENF 0x02000000280#define ECD_ETOKENF 0x02000000
281#define ECD_ECC 0x00200000
281 __u32 ecd; /* 0x01c8 */282 __u32 ecd; /* 0x01c8 */
282 __u8 reserved1cc[18]; /* 0x01cc */283 __u8 reserved1cc[18]; /* 0x01cc */
283 __u64 pp; /* 0x01de */284 __u64 pp; /* 0x01de */
arch/s390/kvm/kvm-s390.c+26−1
@@ -2890,6 +2890,25 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu) · 2889 unmodified lines
2890 vcpu->arch.enabled_gmap = vcpu->arch.gmap;2890 vcpu->arch.enabled_gmap = vcpu->arch.gmap;
2891}2891}
2892 2892
2893static bool kvm_has_pckmo_subfunc(struct kvm *kvm, unsigned long nr)
2894{
2895 if (test_bit_inv(nr, (unsigned long *)&kvm->arch.model.subfuncs.pckmo) &&
2896 test_bit_inv(nr, (unsigned long *)&kvm_s390_available_subfunc.pckmo))
2897 return true;
2898 return false;
2899}
2900
2901static bool kvm_has_pckmo_ecc(struct kvm *kvm)
2902{
2903 /* At least one ECC subfunction must be present */
2904 return kvm_has_pckmo_subfunc(kvm, 32) ||
2905 kvm_has_pckmo_subfunc(kvm, 33) ||
2906 kvm_has_pckmo_subfunc(kvm, 34) ||
2907 kvm_has_pckmo_subfunc(kvm, 40) ||
2908 kvm_has_pckmo_subfunc(kvm, 41);
2909
2910}
2911
2893static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)2912static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
2894{2913{
2895 /*2914 /*
@@ -2902,13 +2921,19 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu) · 6 unmodified lines
2902 vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd;2921 vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd;
2903 vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA);2922 vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA);
2904 vcpu->arch.sie_block->eca &= ~ECA_APIE;2923 vcpu->arch.sie_block->eca &= ~ECA_APIE;
2924 vcpu->arch.sie_block->ecd &= ~ECD_ECC;
2905 2925
2906 if (vcpu->kvm->arch.crypto.apie)2926 if (vcpu->kvm->arch.crypto.apie)
2907 vcpu->arch.sie_block->eca |= ECA_APIE;2927 vcpu->arch.sie_block->eca |= ECA_APIE;
2908 2928
2909 /* Set up protected key support */2929 /* Set up protected key support */
2910 if (vcpu->kvm->arch.crypto.aes_kw)2930 if (vcpu->kvm->arch.crypto.aes_kw) {
2911 vcpu->arch.sie_block->ecb3 |= ECB3_AES;2931 vcpu->arch.sie_block->ecb3 |= ECB3_AES;
2932 /* ecc is also wrapped with AES key */
2933 if (kvm_has_pckmo_ecc(vcpu->kvm))
2934 vcpu->arch.sie_block->ecd |= ECD_ECC;
2935 }
2936
2912 if (vcpu->kvm->arch.crypto.dea_kw)2937 if (vcpu->kvm->arch.crypto.dea_kw)
2913 vcpu->arch.sie_block->ecb3 |= ECB3_DEA;2938 vcpu->arch.sie_block->ecb3 |= ECB3_DEA;
2914}2939}
arch/s390/kvm/vsie.c+4−1
@@ -288,6 +288,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · 287 unmodified lines
288 const u32 crycb_addr = crycbd_o & 0x7ffffff8U;288 const u32 crycb_addr = crycbd_o & 0x7ffffff8U;
289 unsigned long *b1, *b2;289 unsigned long *b1, *b2;
290 u8 ecb3_flags;290 u8 ecb3_flags;
291 u32 ecd_flags;
291 int apie_h;292 int apie_h;
292 int key_msk = test_kvm_facility(vcpu->kvm, 76);293 int key_msk = test_kvm_facility(vcpu->kvm, 76);
293 int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;294 int fmt_o = crycbd_o & CRYCB_FORMAT_MASK;
@@ -320,7 +321,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · 26 unmodified lines
320 /* we may only allow it if enabled for guest 2 */321 /* we may only allow it if enabled for guest 2 */
321 ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 &322 ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 &
322 (ECB3_AES | ECB3_DEA);323 (ECB3_AES | ECB3_DEA);
323 if (!ecb3_flags)324 ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC;
325 if (!ecb3_flags && !ecd_flags)
324 goto end;326 goto end;
325 327
326 /* copy only the wrapping keys */328 /* copy only the wrapping keys */
@@ -329,6 +331,7 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page) · 2 unmodified lines
329 return set_validity_icpt(scb_s, 0x0035U);331 return set_validity_icpt(scb_s, 0x0035U);
330 332
331 scb_s->ecb3 |= ecb3_flags;333 scb_s->ecb3 |= ecb3_flags;
334 scb_s->ecd |= ecd_flags;
332 335
333 /* xor both blocks in one run */336 /* xor both blocks in one run */
334 b1 = (unsigned long *) vsie_page->crycb.dea_wrapping_key_mask;337 b1 = (unsigned long *) vsie_page->crycb.dea_wrapping_key_mask;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t