Skip to content

Commit 19fd83a

Browse files
Pierre Morelborntraeger
authored andcommitted
KVM: s390: vsie: allow CRYCB FORMAT-1
When the host and guest both use a FORMAT-1 CRYCB, we copy the guest's FORMAT-0 APCB to a shadow CRYCB for use by vSIE. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com> Message-Id: <20180925231641.4954-20-akrowiak@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent 56019f9 commit 19fd83a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

arch/s390/kvm/vsie.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ static int prepare_cpuflags(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
136136
return 0;
137137
}
138138

139+
/* Copy to APCB FORMAT0 from APCB FORMAT0 */
140+
static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
141+
unsigned long apcb_o, unsigned long *apcb_h)
142+
{
143+
if (read_guest_real(vcpu, apcb_o, apcb_s,
144+
sizeof(struct kvm_s390_apcb0)))
145+
return -EFAULT;
146+
147+
bitmap_and(apcb_s, apcb_s, apcb_h, sizeof(struct kvm_s390_apcb0));
148+
149+
return 0;
150+
}
151+
139152
/**
140153
* setup_apcb11 - Copy the FORMAT1 APCB from the guest to the shadow CRYCB
141154
* @vcpu: pointer to the virtual CPU
@@ -190,6 +203,12 @@ static int setup_apcb(struct kvm_vcpu *vcpu, struct kvm_s390_crypto_cb *crycb_s,
190203
return setup_apcb11(vcpu, (unsigned long *)&crycb_s->apcb1,
191204
(unsigned long) &crycb->apcb1,
192205
(unsigned long *)&crycb_h->apcb1);
206+
case CRYCB_FORMAT1:
207+
if (fmt_h != CRYCB_FORMAT1)
208+
return -EINVAL;
209+
return setup_apcb00(vcpu, (unsigned long *) &crycb_s->apcb0,
210+
(unsigned long) &crycb->apcb0,
211+
(unsigned long *) &crycb_h->apcb0);
193212
}
194213
return -EINVAL;
195214
}

0 commit comments

Comments
 (0)