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, seiden@linux.ibm.com, nrb@linux.ibm.com,
nsg@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH 3/3] s390x: pv: Add IPL reset tests
Date: Fri, 17 Feb 2023 17:42:19 +0100 [thread overview]
Message-ID: <20230217174219.71163eb5@p-imbrenda> (raw)
In-Reply-To: <20230201084833.39846-4-frankja@linux.ibm.com>
On Wed, 1 Feb 2023 08:48:33 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:
> The diag308 requires extensive cooperation between the hypervisor and
> the Ultravisor so the Ultravisor can make sure all necessary reset
> steps have been done.
>
> Let's check if we get the correct validity errors.
>
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
[...]
> +
> + /*
> + * We need to perform several UV calls to emulate the subcode
> + * 1. Failing to do that should result in a validity
> + *
> + * - Mark all cpus as stopped
> + * - Reset the cpus, calling one gets an initial reset
> + * - Load the reset PSW
> + * - Unshare all
> + * - Load the reset PSW
you forgot to mention prepare the reset, and the list does not reflect
the order things are done in the code
> + */
> + sie_expect_validity(&vm);
> + sie(&vm);
> + report((sie_get_validity(&vm) & 0xff00) == 0x2000, "validity no UVCs");
> +
> + /* Mark the CPU as stopped so we can unshare and reset */
> + cc = uv_set_cpu_state(vm.sblk->pv_handle_cpu, PV_CPU_STATE_STP);
> + report(!cc, "Set cpu stopped");
> +
> + sie_expect_validity(&vm);
> + sie(&vm);
> + report((sie_get_validity(&vm) & 0xff00) == 0x2000, "validity stopped");
> +
> + /* Unshare all memory */
> + cc = uv_cmd_nodata(vm.sblk->pv_handle_config,
> + UVC_CMD_SET_UNSHARED_ALL, &rc, &rrc);
> + report(cc == 0 && rc == 1, "Unshare all");
> +
> + sie_expect_validity(&vm);
> + sie(&vm);
> + report((sie_get_validity(&vm) & 0xff00) == 0x2000,
> + "validity stopped, unshared");
> +
> + /* Prepare the CPU reset */
> + cc = uv_cmd_nodata(vm.sblk->pv_handle_config,
> + UVC_CMD_PREPARE_RESET, &rc, &rrc);
> + report(cc == 0 && rc == 1, "Prepare reset call");
> +
> + sie_expect_validity(&vm);
> + sie(&vm);
> + report((sie_get_validity(&vm) & 0xff00) == 0x2000,
> + "validity stopped, unshared, prepare");
> +
> + /* Do the reset */
> + cc = uv_cmd_nodata(vm.sblk->pv_handle_cpu,
> + UVC_CMD_CPU_RESET_INITIAL, &rc, &rrc);
> + report(cc == 0 && rc == 1, "Clear reset cpu");
> +
> + sie_expect_validity(&vm);
> + sie(&vm);
> + report((sie_get_validity(&vm) & 0xff00) == 0x2000,
> + "validity stopped, unshared, prepare, reset");
> +
> + /* Load the PSW from 0x0 */
> + cc = uv_set_cpu_state(vm.sblk->pv_handle_cpu, PV_CPU_STATE_OPR_LOAD);
> + report(!cc, "Set cpu load");
> +
> + /*
> + * Check if we executed the iaddr of the reset PSW, we should
> + * see a diagnose 0x9c PV instruction notification.
> + */
> + 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] == 42,
> + "intercept values after diag 0x308");
> +
> +
> + uv_destroy_guest(&vm);
> + report_prefix_pop();
> +}
> +
[...]
> diff --git a/s390x/snippets/asm/snippet-pv-diag-308.S b/s390x/snippets/asm/snippet-pv-diag-308.S
> new file mode 100644
> index 00000000..58c96173
> --- /dev/null
> +++ b/s390x/snippets/asm/snippet-pv-diag-308.S
> @@ -0,0 +1,67 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/*
> + * Diagnose 0x308 snippet used for PV IPL and reset testing
> + *
> + * Copyright (c) 2023 IBM Corp
> + *
> + * Authors:
> + * Janosch Frank <frankja@linux.ibm.com>
> + */
> +#include <asm/asm-offsets.h>
> +.section .text
> +
> +/* Sets a reset PSW with the given PSW address */
> +.macro SET_RESET_PSW_ADDR label
> +lgrl %r5, reset_psw
> +larl %r6, \label
> +ogr %r5, %r6
> +stg %r5, 0
> +.endm
> +
> +/* Does a diagnose 308 with the given subcode */
> +.macro DIAG308 subcode
> +xgr %r3, %r3
> +lghi %r3, \subcode
> +diag 1, 3, 0x308
> +.endm
> +
> +sam64
> +
> +/* Execute the diag500 which will set the subcode we execute in gr2 */
> +diag 0, 0, 0x500
> +
> +/*
> + * A valid PGM new PSW can be a real problem since we never fall out
> + * of SIE and therefore effectively loop forever. 0 is a valid PSW
> + * therefore we re-use the reset_psw as this has the short PSW
> + * bit set which is invalid for a long PSW like the exception new
> + * PSWs.
> + *
> + * For subcode 0/1 there are no PGMs to consider.
> + */
> +lgrl %r5, reset_psw
> +stg %r5, GEN_LC_PGM_NEW_PSW
> +
> +/* Clean registers that are used */
> +xgr %r0, %r0
> +xgr %r1, %r1
> +xgr %r3, %r3
> +xgr %r4, %r4
> +xgr %r5, %r5
> +xgr %r6, %r6
> +
> +/* Subcode 0 - Modified Clear */
what about subcode 1?
> +SET_RESET_PSW_ADDR done
> +diag %r0, %r2, 0x308
> +
> +/* Should never be executed because of the reset PSW */
> +diag 0, 0, 0x44
> +
> +done:
> +lghi %r1, 42
> +diag %r1, 0, 0x9c
> +
> +
> + .align 8
> +reset_psw:
> + .quad 0x0008000180000000
next prev parent reply other threads:[~2023-02-17 16:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 8:48 [kvm-unit-tests PATCH 0/3] s390x: Add PV SIE intercepts and ipl tests Janosch Frank
2023-02-01 8:48 ` [kvm-unit-tests PATCH 1/3] lib: s390x: Introduce UV validity function Janosch Frank
2023-02-01 8:48 ` [kvm-unit-tests PATCH 2/3] s390x: pv: Test sie entry intercepts and validities Janosch Frank
2023-02-15 17:06 ` Claudio Imbrenda
2023-02-21 9:22 ` Janosch Frank
2023-02-28 17:19 ` Claudio Imbrenda
2023-02-01 8:48 ` [kvm-unit-tests PATCH 3/3] s390x: pv: Add IPL reset tests Janosch Frank
2023-02-17 16:42 ` Claudio Imbrenda [this message]
2023-02-21 9:26 ` Janosch Frank
2023-02-28 17:20 ` 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=20230217174219.71163eb5@p-imbrenda \
--to=imbrenda@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nrb@linux.ibm.com \
--cc=nsg@linux.ibm.com \
--cc=seiden@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