Re: [kvm-unit-tests PATCH v3 4/7] s390x: Add function for checking diagnose intercepts

Janosch Frank
2024-06-21T07:13:23Z

On 6/20/24 16:16, Nina Schoetterl-Glausch wrote:
> sie_is_diag_icpt() checks if the intercept is due to an expected
> diagnose call and is valid.
> It subsumes pv_icptdata_check_diag.
>
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
> lib/s390x/pv_icptdata.h | 42 --------------------------------
> lib/s390x/sie.h | 12 ++++++++++
> lib/s390x/sie.c | 53 +++++++++++++++++++++++++++++++++++++++++
> s390x/pv-diags.c | 8 +++----
> s390x/pv-icptcode.c | 11 ++++-----
> s390x/pv-ipl.c | 7 +++---
> 6 files changed, 76 insertions(+), 57 deletions(-)
> delete mode 100644 lib/s390x/pv_icptdata.h
>
> diff --git a/lib/s390x/pv_icptdata.h b/lib/s390x/pv_icptdata.h
> deleted file mode 100644
> index 4746117e..00000000
> --- a/lib/s390x/pv_icptdata.h
> +++ /dev/null
> @@ -1,42 +0,0 @@

There's a reason why I didn't put this in sie.c and I'm still torn on
whether this should be in the lib or in s390x. It's not related to
actually running snippets and managing them.

> -/* SPDX-License-Identifier: GPL-2.0-only */
> -/*
> - * Commonly used checks for PV SIE intercept data
> - *
> - * Copyright IBM Corp. 2023
> - * Author: Janosch Frank <frankja@linux.ibm.com>
> - */
[...]
> diff --git a/lib/s390x/sie.h b/lib/s390x/sie.h
> index 53cd767f..6d1a0d6e 100644
> --- a/lib/s390x/sie.h
> +++ b/lib/s390x/sie.h
> @@ -287,6 +287,18 @@ static inline bool sie_is_pv(struct vm *vm)
> return vm->sblk->sdf == 2;
> }
>
> +/**
> + * sie_is_diag_icpt() - Check if intercept is due to diagnose instruction
> + * @vm: the guest
> + * @diag: the expected diagnose code
> + *
> + * Check that the intercept is due to diagnose @diag and valid.
> + * For protected virtualisation, check that the intercept data meets additional

virtualization

> + * constraints.
> + *
> + * Returns: true if intercept is due to a valid and has matching diagnose code
> + */
> +bool sie_is_diag_icpt(struct vm *vm, unsigned int diag);
> 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