Skip to content

Commit 2c2cc82

Browse files
hbruecknerfrankjaa
authored andcommitted
KVM: s390: add msa11 to cpu model
Message-security-assist 11 introduces pckmo subfunctions to encrypt hmac keys. Signed-off-by: Hendrik Brueckner <[email protected]> Reviewed-by: Janosch Frank <[email protected]> Reviewed-by: Christian Borntraeger <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Janosch Frank <[email protected]> Message-ID: <[email protected]>
1 parent 66ff6bf commit 2c2cc82

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

arch/s390/include/asm/kvm_host.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ struct kvm_s390_sie_block {
356356
#define ECD_MEF 0x08000000
357357
#define ECD_ETOKENF 0x02000000
358358
#define ECD_ECC 0x00200000
359+
#define ECD_HMAC 0x00004000
359360
__u32 ecd; /* 0x01c8 */
360361
__u8 reserved1cc[18]; /* 0x01cc */
361362
__u64 pp; /* 0x01de */

arch/s390/kvm/kvm-s390.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,6 +3796,13 @@ static bool kvm_has_pckmo_ecc(struct kvm *kvm)
37963796

37973797
}
37983798

3799+
static bool kvm_has_pckmo_hmac(struct kvm *kvm)
3800+
{
3801+
/* At least one HMAC subfunction must be present */
3802+
return kvm_has_pckmo_subfunc(kvm, 118) ||
3803+
kvm_has_pckmo_subfunc(kvm, 122);
3804+
}
3805+
37993806
static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
38003807
{
38013808
/*
@@ -3808,17 +3815,19 @@ static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu)
38083815
vcpu->arch.sie_block->crycbd = vcpu->kvm->arch.crypto.crycbd;
38093816
vcpu->arch.sie_block->ecb3 &= ~(ECB3_AES | ECB3_DEA);
38103817
vcpu->arch.sie_block->eca &= ~ECA_APIE;
3811-
vcpu->arch.sie_block->ecd &= ~ECD_ECC;
3818+
vcpu->arch.sie_block->ecd &= ~(ECD_ECC | ECD_HMAC);
38123819

38133820
if (vcpu->kvm->arch.crypto.apie)
38143821
vcpu->arch.sie_block->eca |= ECA_APIE;
38153822

38163823
/* Set up protected key support */
38173824
if (vcpu->kvm->arch.crypto.aes_kw) {
38183825
vcpu->arch.sie_block->ecb3 |= ECB3_AES;
3819-
/* ecc is also wrapped with AES key */
3826+
/* ecc/hmac is also wrapped with AES key */
38203827
if (kvm_has_pckmo_ecc(vcpu->kvm))
38213828
vcpu->arch.sie_block->ecd |= ECD_ECC;
3829+
if (kvm_has_pckmo_hmac(vcpu->kvm))
3830+
vcpu->arch.sie_block->ecd |= ECD_HMAC;
38223831
}
38233832

38243833
if (vcpu->kvm->arch.crypto.dea_kw)

arch/s390/kvm/vsie.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
335335
/* we may only allow it if enabled for guest 2 */
336336
ecb3_flags = scb_o->ecb3 & vcpu->arch.sie_block->ecb3 &
337337
(ECB3_AES | ECB3_DEA);
338-
ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd & ECD_ECC;
338+
ecd_flags = scb_o->ecd & vcpu->arch.sie_block->ecd &
339+
(ECD_ECC | ECD_HMAC);
339340
if (!ecb3_flags && !ecd_flags)
340341
goto end;
341342

0 commit comments

Comments
 (0)