public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Claudio Imbrenda <imbrenda@linux.ibm.com>
To: Janosch Frank <frankja@linux.ibm.com>
Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	thuth@redhat.com, nrb@linux.ibm.com, david@redhat.com
Subject: Re: [kvm-unit-tests PATCH v3 2/7] lib: s390x: uv: Add intercept data check library function
Date: Fri, 21 Apr 2023 16:10:08 +0200	[thread overview]
Message-ID: <20230421161008.529523bc@p-imbrenda> (raw)
In-Reply-To: <20230421113647.134536-3-frankja@linux.ibm.com>

On Fri, 21 Apr 2023 11:36:42 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> When working with guests it's essential to check the SIE intercept
> data for the correct values. Fortunately on PV guests these values are
> constants so we can create check functions which test for the
> constants.
> 
> While we're at it let's make pv-diags.c use this new function.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
>  lib/s390x/pv_icptdata.h | 42 +++++++++++++++++++++++++++++++++++++++++
>  s390x/pv-diags.c        | 14 ++++++--------
>  2 files changed, 48 insertions(+), 8 deletions(-)
>  create mode 100644 lib/s390x/pv_icptdata.h
> 
> diff --git a/lib/s390x/pv_icptdata.h b/lib/s390x/pv_icptdata.h
> new file mode 100644
> index 00000000..4746117e
> --- /dev/null
> +++ b/lib/s390x/pv_icptdata.h
> @@ -0,0 +1,42 @@
> +/* 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>
> + */
> +
> +#ifndef _S390X_PV_ICPTDATA_H_
> +#define _S390X_PV_ICPTDATA_H_
> +
> +#include <sie.h>
> +
> +/*
> + * Checks the diagnose instruction intercept data for consistency with
> + * the constants defined by the PV SIE architecture
> + *
> + * Supports: 0x44, 0x9c, 0x288, 0x308, 0x500
> + */
> +static bool pv_icptdata_check_diag(struct vm *vm, int diag)
> +{
> +	int icptcode;
> +
> +	switch (diag) {
> +	case 0x44:
> +	case 0x9c:
> +	case 0x288:
> +	case 0x308:
> +		icptcode = ICPT_PV_NOTIFY;
> +		break;
> +	case 0x500:
> +		icptcode = ICPT_PV_INSTR;
> +		break;
> +	default:
> +		/* If a new diag is introduced add it to the cases above! */
> +		assert(0);
> +	}
> +
> +	return vm->sblk->icptcode == icptcode && vm->sblk->ipa == 0x8302 &&
> +	       vm->sblk->ipb == 0x50000000 && vm->save_area.guest.grs[5] == diag;
> +}
> +#endif
> diff --git a/s390x/pv-diags.c b/s390x/pv-diags.c
> index 5165937a..096ac61f 100644
> --- a/s390x/pv-diags.c
> +++ b/s390x/pv-diags.c
> @@ -9,6 +9,7 @@
>   */
>  #include <libcflat.h>
>  #include <snippet.h>
> +#include <pv_icptdata.h>
>  #include <sie.h>
>  #include <sclp.h>
>  #include <asm/facility.h>
> @@ -31,8 +32,7 @@ static void test_diag_500(void)
>  			size_gbin, size_hdr, SNIPPET_UNPACK_OFF);
>  
>  	sie(&vm);
> -	report(vm.sblk->icptcode == ICPT_PV_INSTR && vm.sblk->ipa == 0x8302 &&
> -	       vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x500,
> +	report(pv_icptdata_check_diag(&vm, 0x500),
>  	       "intercept values");
>  	report(vm.save_area.guest.grs[1] == 1 &&
>  	       vm.save_area.guest.grs[2] == 2 &&
> @@ -45,9 +45,8 @@ static void test_diag_500(void)
>  	 */
>  	vm.sblk->iictl = IICTL_CODE_OPERAND;
>  	sie(&vm);
> -	report(vm.sblk->icptcode == ICPT_PV_NOTIFY && vm.sblk->ipa == 0x8302 &&
> -	       vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x9c
> -	       && vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND,
> +	report(pv_icptdata_check_diag(&vm, 0x9c) &&
> +	       vm.save_area.guest.grs[0] == PGM_INT_CODE_OPERAND,
>  	       "operand exception");
>  
>  	/*
> @@ -58,9 +57,8 @@ static void test_diag_500(void)
>  	vm.sblk->iictl = IICTL_CODE_SPECIFICATION;
>  	/* Inject PGM, next exit should be 9c */
>  	sie(&vm);
> -	report(vm.sblk->icptcode == ICPT_PV_NOTIFY && vm.sblk->ipa == 0x8302 &&
> -	       vm.sblk->ipb == 0x50000000 && vm.save_area.guest.grs[5] == 0x9c
> -	       && vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION,
> +	report(pv_icptdata_check_diag(&vm, 0x9c) &&
> +	       vm.save_area.guest.grs[0] == PGM_INT_CODE_SPECIFICATION,
>  	       "specification exception");
>  
>  	/* No need for cleanup, just tear down the VM */


  reply	other threads:[~2023-04-21 15:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 11:36 [kvm-unit-tests PATCH v3 0/7] s390x: Add PV SIE intercepts and ipl tests Janosch Frank
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 1/7] lib: s390x: uv: Introduce UV validity function Janosch Frank
2023-05-31 13:36   ` Nico Boehr
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 2/7] lib: s390x: uv: Add intercept data check library function Janosch Frank
2023-04-21 14:10   ` Claudio Imbrenda [this message]
2023-04-26 11:22   ` Nico Boehr
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 3/7] s390x: pv-diags: Drop snippet from snippet names Janosch Frank
2023-04-21 14:10   ` Claudio Imbrenda
2023-04-26 11:24   ` Nico Boehr
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 4/7] lib: s390x: uv: Add pv guest requirement check function Janosch Frank
2023-04-21 14:13   ` Claudio Imbrenda
2023-04-24  8:26     ` Janosch Frank
2023-04-26 11:27   ` Nico Boehr
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 5/7] s390x: pv: Add sie entry intercept and validity test Janosch Frank
2023-04-21 15:23   ` Claudio Imbrenda
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 6/7] s390x: pv: Add IPL reset tests Janosch Frank
2023-04-21 15:32   ` Claudio Imbrenda
2023-04-21 11:36 ` [kvm-unit-tests PATCH v3 7/7] s390x: pv-diags: Add the test to unittests.conf Janosch Frank
2023-04-21 14:10   ` Claudio Imbrenda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230421161008.529523bc@p-imbrenda \
    --to=imbrenda@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox