Skip to content

Commit 6ee7409

Browse files
Pierre Morelborntraeger
authored andcommitted
KVM: s390: vsie: allow CRYCB FORMAT-0
When the host and the guest both use a FORMAT-0 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-21-akrowiak@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
1 parent 19fd83a commit 6ee7409

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

arch/s390/kvm/vsie.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,15 @@ 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 */
139+
/**
140+
* setup_apcb00 - Copy to APCB FORMAT0 from APCB FORMAT0
141+
* @vcpu: pointer to the virtual CPU
142+
* @apcb_s: pointer to start of apcb in the shadow crycb
143+
* @apcb_o: pointer to start of original apcb in the guest2
144+
* @apcb_h: pointer to start of apcb in the guest1
145+
*
146+
* Returns 0 and -EFAULT on error reading guest apcb
147+
*/
140148
static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s,
141149
unsigned long apcb_o, unsigned long *apcb_h)
142150
{
@@ -209,6 +217,14 @@ static int setup_apcb(struct kvm_vcpu *vcpu, struct kvm_s390_crypto_cb *crycb_s,
209217
return setup_apcb00(vcpu, (unsigned long *) &crycb_s->apcb0,
210218
(unsigned long) &crycb->apcb0,
211219
(unsigned long *) &crycb_h->apcb0);
220+
case CRYCB_FORMAT0:
221+
if ((crycb_o & PAGE_MASK) != ((crycb_o + 32) & PAGE_MASK))
222+
return -EACCES;
223+
if (fmt_h != CRYCB_FORMAT0)
224+
return -EINVAL;
225+
return setup_apcb00(vcpu, (unsigned long *) &crycb_s->apcb0,
226+
(unsigned long) &crycb->apcb0,
227+
(unsigned long *) &crycb_h->apcb0);
212228
}
213229
return -EINVAL;
214230
}
@@ -248,8 +264,6 @@ static int shadow_crycb(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
248264
int ret = 0;
249265

250266
scb_s->crycbd = 0;
251-
if (!(crycbd_o & vcpu->arch.sie_block->crycbd & CRYCB_FORMAT1))
252-
return 0;
253267

254268
apie_h = vcpu->arch.sie_block->eca & ECA_APIE;
255269
if (!apie_h && !key_msk)

0 commit comments

Comments
 (0)