public inbox for kvm@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, thuth@redhat.com, david@redhat.com,
	borntraeger@de.ibm.com, cohuck@redhat.com,
	linux-s390@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH v3 6/8] s390x: sie: Add first SIE test
Date: Thu, 17 Dec 2020 15:48:15 +0100	[thread overview]
Message-ID: <20201217154815.2b961dc9@ibm-vm> (raw)
In-Reply-To: <20201211100039.63597-7-frankja@linux.ibm.com>

On Fri, 11 Dec 2020 05:00:37 -0500
Janosch Frank <frankja@linux.ibm.com> wrote:

> Let's check if we get the correct interception data on a few
> diags. This commit is more of an addition of boilerplate code than a
> real test.

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

> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/Makefile      |   1 +
>  s390x/sie.c         | 113
> ++++++++++++++++++++++++++++++++++++++++++++ s390x/unittests.cfg |
> 3 ++ 3 files changed, 117 insertions(+)
>  create mode 100644 s390x/sie.c
> 
> diff --git a/s390x/Makefile b/s390x/Makefile
> index fb62e87..8e1b4e9 100644
> --- a/s390x/Makefile
> +++ b/s390x/Makefile
> @@ -19,6 +19,7 @@ tests += $(TEST_DIR)/smp.elf
>  tests += $(TEST_DIR)/sclp.elf
>  tests += $(TEST_DIR)/css.elf
>  tests += $(TEST_DIR)/uv-guest.elf
> +tests += $(TEST_DIR)/sie.elf
>  
>  tests_binary = $(patsubst %.elf,%.bin,$(tests))
>  ifneq ($(HOST_KEY_DOCUMENT),)
> diff --git a/s390x/sie.c b/s390x/sie.c
> new file mode 100644
> index 0000000..cfc746f
> --- /dev/null
> +++ b/s390x/sie.c
> @@ -0,0 +1,113 @@
> +#include <libcflat.h>
> +#include <asm/asm-offsets.h>
> +#include <asm/arch_def.h>
> +#include <asm/interrupt.h>
> +#include <asm/page.h>
> +#include <alloc_page.h>
> +#include <vmalloc.h>
> +#include <asm/facility.h>
> +#include <mmu.h>
> +#include <sclp.h>
> +#include <sie.h>
> +
> +static u8 *guest;
> +static u8 *guest_instr;
> +static struct vm vm;
> +
> +static void handle_validity(struct vm *vm)
> +{
> +	report(0, "VALIDITY: %x", vm->sblk->ipb >> 16);
> +}
> +
> +static void sie(struct vm *vm)
> +{
> +	while (vm->sblk->icptcode == 0) {
> +		sie64a(vm->sblk, &vm->save_area);
> +		if (vm->sblk->icptcode == ICPT_VALIDITY)
> +			handle_validity(vm);
> +	}
> +	vm->save_area.guest.grs[14] = vm->sblk->gg14;
> +	vm->save_area.guest.grs[15] = vm->sblk->gg15;
> +}
> +
> +static void sblk_cleanup(struct vm *vm)
> +{
> +	vm->sblk->icptcode = 0;
> +}
> +
> +static void test_diag(u32 instr)
> +{
> +	vm.sblk->gpsw.addr = PAGE_SIZE * 2;
> +	vm.sblk->gpsw.mask = 0x0000000180000000ULL;
> +
> +	memset(guest_instr, 0, PAGE_SIZE);
> +	memcpy(guest_instr, &instr, 4);
> +	sie(&vm);
> +	report(vm.sblk->icptcode == ICPT_INST &&
> +	       vm.sblk->ipa == instr >> 16 && vm.sblk->ipb == instr
> << 16,
> +	       "Intercept data");
> +	sblk_cleanup(&vm);
> +}
> +
> +static struct {
> +	const char *name;
> +	u32 instr;
> +} tests[] = {
> +	{ "10", 0x83020010 },
> +	{ "44", 0x83020044 },
> +	{ "9c", 0x8302009c },
> +	{ NULL, 0 }
> +};
> +
> +static void test_diags(void)
> +{
> +	int i;
> +
> +	for (i = 0; tests[i].name; i++) {
> +		report_prefix_push(tests[i].name);
> +		test_diag(tests[i].instr);
> +		report_prefix_pop();
> +	}
> +}
> +
> +static void setup_guest(void)
> +{
> +	setup_vm();
> +
> +	/* Allocate 1MB as guest memory */
> +	guest = alloc_pages(8);
> +	/* The first two pages are the lowcore */
> +	guest_instr = guest + PAGE_SIZE * 2;
> +
> +	vm.sblk = alloc_page();
> +
> +	vm.sblk->cpuflags = CPUSTAT_ZARCH | CPUSTAT_RUNNING;
> +	vm.sblk->prefix = 0;
> +	/*
> +	 * Pageable guest with the same ASCE as the test programm,
> but
> +	 * the guest memory 0x0 is offset to start at the allocated
> +	 * guest pages and end after 1MB.
> +	 *
> +	 * It's not pretty but faster and easier than managing guest
> ASCEs.
> +	 */
> +	vm.sblk->mso = (u64)guest;
> +	vm.sblk->msl = (u64)guest;
> +	vm.sblk->ihcpu = 0xffff;
> +
> +	vm.sblk->crycbd = (uint64_t)alloc_page();
> +}
> +
> +int main(void)
> +{
> +	report_prefix_push("sie");
> +	if (!sclp_facilities.has_sief2) {
> +		report_skip("SIEF2 facility unavailable");
> +		goto done;
> +	}
> +
> +	setup_guest();
> +	test_diags();
> +done:
> +	report_prefix_pop();
> +	return report_summary();
> +}
> diff --git a/s390x/unittests.cfg b/s390x/unittests.cfg
> index 3feb8bc..2298be6 100644
> --- a/s390x/unittests.cfg
> +++ b/s390x/unittests.cfg
> @@ -96,3 +96,6 @@ smp = 2
>  
>  [uv-guest]
>  file = uv-guest.elf
> +
> +[sie]
> +file = sie.elf


  parent reply	other threads:[~2020-12-17 15:02 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-11 10:00 [kvm-unit-tests PATCH v3 0/8] s390x: Add SIE library and simple test Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 1/8] s390x: Add test_bit to library Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 2/8] s390x: Consolidate sclp read info Janosch Frank
2020-12-11 12:06   ` Thomas Huth
2020-12-17 11:47   ` Claudio Imbrenda
2020-12-17 14:48     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 3/8] s390x: SCLP feature checking Janosch Frank
2020-12-17 12:18   ` Claudio Imbrenda
2020-12-17 15:21     ` Janosch Frank
2020-12-17 15:24       ` Thomas Huth
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 4/8] s390x: Split assembly and move to s390x/asm/ Janosch Frank
2020-12-11 12:18   ` Thomas Huth
2020-12-14 10:34     ` Janosch Frank
2020-12-17 12:54   ` Claudio Imbrenda
2020-12-17 13:14   ` Claudio Imbrenda
2020-12-17 15:22     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 5/8] s390x: sie: Add SIE to lib Janosch Frank
2020-12-17  9:37   ` Thomas Huth
2020-12-17 15:45     ` Janosch Frank
2020-12-17 14:42   ` Claudio Imbrenda
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 6/8] s390x: sie: Add first SIE test Janosch Frank
2020-12-17  9:41   ` Thomas Huth
2020-12-17 14:48   ` Claudio Imbrenda [this message]
2020-12-18 11:17   ` Cornelia Huck
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 7/8] s390x: Add diag318 intercept test Janosch Frank
2020-12-17  9:53   ` Thomas Huth
2020-12-17  9:59     ` Christian Borntraeger
2020-12-17 10:34       ` Thomas Huth
2020-12-17 14:31         ` Janosch Frank
2020-12-17 15:31           ` Janosch Frank
2020-12-17 15:36             ` Thomas Huth
2020-12-17 14:58   ` Claudio Imbrenda
2020-12-17 15:25     ` Janosch Frank
2020-12-11 10:00 ` [kvm-unit-tests PATCH v3 8/8] s390x: Fix sclp.h style issues Janosch Frank
2020-12-17 14:55   ` 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=20201217154815.2b961dc9@ibm-vm \
    --to=imbrenda@linux.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --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