On Fri Jun 21, 2024 at 12:16 AM AEST, Nina Schoetterl-Glausch wrote: > Add a function to check if a guest VM is currently running protected. > > Signed-off-by: Nina Schoetterl-Glausch <nsg@xxxxxxxxxxxxx> Reviewed-by: Nicholas Piggin <npiggin@xxxxxxxxx> > --- > lib/s390x/sie.h | 6 ++++++ > lib/s390x/sie.c | 4 ++-- > 2 files changed, 8 insertions(+), 2 deletions(-) > > diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h > index c1724cf2..53cd767f 100644 > --- a/lib/s390x/sie.h > +++ b/lib/s390x/sie.h > @@ -281,6 +281,12 @@ void sie_expect_validity(struct vm *vm); > uint16_t sie_get_validity(struct vm *vm); > void sie_check_validity(struct vm *vm, uint16_t vir_exp); > void sie_handle_validity(struct vm *vm); > + > +static inline bool sie_is_pv(struct vm *vm) > +{ > + return vm->sblk->sdf == 2; > +} > + > 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); > diff --git a/lib/s390x/sie.c b/lib/s390x/sie.c > index 40936bd2..0fa915cf 100644 > --- a/lib/s390x/sie.c > +++ b/lib/s390x/sie.c > @@ -59,7 +59,7 @@ void sie(struct vm *vm) > /* When a pgm int code is set, we'll never enter SIE below. */ > assert(!read_pgm_int_code()); > > - if (vm->sblk->sdf == 2) > + if (sie_is_pv(vm)) > memcpy(vm->sblk->pv_grregs, vm->save_area.guest.grs, > sizeof(vm->save_area.guest.grs)); > > @@ -98,7 +98,7 @@ void sie(struct vm *vm) > /* restore the old CR 13 */ > lctlg(13, old_cr13); > > - if (vm->sblk->sdf == 2) > + if (sie_is_pv(vm)) > memcpy(vm->save_area.guest.grs, vm->sblk->pv_grregs, > sizeof(vm->save_area.guest.grs)); > }