Re: [PATCH v2 2/2] KVM: s390: selftest: Test suppression indication on key prot exception

From: Janis Schoetterl-Glausch
Date: Thu Apr 28 2022 - 12:49:13 EST


On 4/25/22 12:01, Janis Schoetterl-Glausch wrote:
> Check that suppression is not indicated on injection of a key checked
> protection exception caused by a memop after it already modified guest
> memory, as that violates the definition of suppression.
>
> Signed-off-by: Janis Schoetterl-Glausch <scgl@xxxxxxxxxxxxx>
> ---
> tools/testing/selftests/kvm/s390x/memop.c | 43 ++++++++++++++++++++++-
> 1 file changed, 42 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index b04c2c1b3c30..ce176ad9f216 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c

[...]

> +static void test_termination(void)
> +{
> + struct test_default t = test_default_init(guest_error_key);
> + uint64_t prefix;
> + uint64_t teid;
> + uint64_t psw[2];
> +
> + HOST_SYNC(t.vcpu, STAGE_INITED);
> + HOST_SYNC(t.vcpu, STAGE_SKEYS_SET);
> +
> + /* vcpu, mismatching keys after first page */
> + ERR_PROT_MOP(t.vcpu, LOGICAL, WRITE, mem1, t.size, GADDR_V(mem1), KEY(1), INJECT);
> + /*
> + * The memop injected a program exception and the test needs to check the
> + * Translation-Exception Identification (TEID). It is necessary to run
> + * the guest in order to be able to read the TEID from guest memory.
> + * Set the guest program new PSW, so the guest state is not clobbered.
> + */
> + prefix = t.run->s.regs.prefix;
> + psw[0] = t.run->psw_mask;
> + psw[1] = t.run->psw_addr;
> + MOP(t.vm, ABSOLUTE, WRITE, psw, sizeof(psw), GADDR(prefix + 464));
> + HOST_SYNC(t.vcpu, STAGE_IDLED);
> + MOP(t.vm, ABSOLUTE, READ, &teid, sizeof(teid), GADDR(prefix + 168));
> + /* Bits 56, 60, 61 form a code, 0 being the only one allowing for termination */
> + ASSERT_EQ(teid & 0x4c, 0);

The constant is wrong, should be 0x8c instead, or better, a more straight forward
expression that evaluates to it.

[...]