On Tue, 23 Nov 2021 10:39:49 +0000 Janosch Frank <frankja@xxxxxxxxxxxxx> wrote: > For protected guests we always need a ESCA so let's add functions to > create and destroy SCAs on demand. We don't have scheduling and I > don't expect multiple VCPU SIE in the next few months so SCA content > handling is not added. > > Signed-off-by: Janosch Frank <frankja@xxxxxxxxxxxxx> Reviewed-by: Claudio Imbrenda <imbrenda@xxxxxxxxxxxxx> > --- > lib/s390x/sie.c | 12 ++++++++++++ > lib/s390x/sie.h | 2 ++ > 2 files changed, 14 insertions(+) > > diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c > index b965b314..51d3b94e 100644 > --- a/lib/s390x/sie.c > +++ b/lib/s390x/sie.c > @@ -55,6 +55,16 @@ void sie(struct vm *vm) > vm->save_area.guest.grs[15] = vm->sblk->gg15; > } > > +void sie_guest_sca_create(struct vm *vm) > +{ > + vm->sca = (struct esca_block *)alloc_page(); > + > + /* Let's start out with one page of ESCA for now */ > + vm->sblk->scaoh = ((uint64_t)vm->sca >> 32); > + vm->sblk->scaol = (uint64_t)vm->sca & ~0x3fU; > + vm->sblk->ecb2 |= ECB2_ESCA; > +} > + > /* Initializes the struct vm members like the SIE control block. */ > void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len) > { > @@ -80,4 +90,6 @@ void sie_guest_destroy(struct vm *vm) > { > free_page(vm->crycb); > free_page(vm->sblk); > + if (vm->sblk->ecb2 & ECB2_ESCA) > + free_page(vm->sca); > } > diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h > index 7ef7251b..f34e3c80 100644 > --- a/lib/s390x/sie.h > +++ b/lib/s390x/sie.h > @@ -191,6 +191,7 @@ struct vm_save_area { > struct vm { > struct kvm_s390_sie_block *sblk; > struct vm_save_area save_area; > + void *sca; /* System Control Area */ > uint8_t *crycb; /* Crypto Control Block */ > /* Ptr to first guest page */ > uint8_t *guest_mem; > @@ -203,6 +204,7 @@ void sie(struct vm *vm); > void sie_expect_validity(void); > void sie_check_validity(uint16_t vir_exp); > void sie_handle_validity(struct vm *vm); > +void sie_guest_sca_create(struct vm *vm); > void sie_guest_create(struct vm *vm, uint64_t guest_mem, uint64_t guest_mem_len); > void sie_guest_destroy(struct vm *vm); >