All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Janis Schoetterl-Glausch <scgl@linux.ibm.com>,
	Janosch Frank <frankja@linux.ibm.com>,
	Claudio Imbrenda <imbrenda@linux.ibm.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	Shuah Khan <shuah@kernel.org>
Cc: David Hildenbrand <david@redhat.com>,
	kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] KVM: s390: selftest: Test suppression indication on key prot exception
Date: Tue, 17 May 2022 14:26:19 +0200	[thread overview]
Message-ID: <975ba61e-b0ba-b5a8-8e71-2833b95fb638@linux.ibm.com> (raw)
In-Reply-To: <20220512131019.2594948-3-scgl@linux.ibm.com>



Am 12.05.22 um 15:10 schrieb Janis Schoetterl-Glausch:
> 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@linux.ibm.com>

Reviewed-by: Christian Borntraeger <borntraeger@linux.ibm.com>

> ---
>   tools/testing/selftests/kvm/s390x/memop.c | 46 ++++++++++++++++++++++-
>   1 file changed, 45 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/kvm/s390x/memop.c b/tools/testing/selftests/kvm/s390x/memop.c
> index b04c2c1b3c30..49f26f544127 100644
> --- a/tools/testing/selftests/kvm/s390x/memop.c
> +++ b/tools/testing/selftests/kvm/s390x/memop.c
> @@ -10,6 +10,8 @@
>   #include <string.h>
>   #include <sys/ioctl.h>
>   
> +#include <linux/bits.h>
> +
>   #include "test_util.h"
>   #include "kvm_util.h"
>   
> @@ -194,6 +196,7 @@ static int err_memop_ioctl(struct test_vcpu vcpu, struct kvm_s390_mem_op *ksmo)
>   #define SIDA_OFFSET(o) ._sida_offset = 1, .sida_offset = (o)
>   #define AR(a) ._ar = 1, .ar = (a)
>   #define KEY(a) .f_key = 1, .key = (a)
> +#define INJECT .f_inject = 1
>   
>   #define CHECK_N_DO(f, ...) ({ f(__VA_ARGS__, CHECK_ONLY); f(__VA_ARGS__); })
>   
> @@ -430,9 +433,18 @@ static void test_copy_key_fetch_prot(void)
>   	TEST_ASSERT(rv == 4, "Should result in protection exception");		\
>   })
>   
> +static void guest_error_key(void)
> +{
> +	GUEST_SYNC(STAGE_INITED);
> +	set_storage_key_range(mem1, PAGE_SIZE, 0x18);
> +	set_storage_key_range(mem1 + PAGE_SIZE, sizeof(mem1) - PAGE_SIZE, 0x98);
> +	GUEST_SYNC(STAGE_SKEYS_SET);
> +	GUEST_SYNC(STAGE_IDLED);
> +}
> +
>   static void test_errors_key(void)
>   {
> -	struct test_default t = test_default_init(guest_copy_key_fetch_prot);
> +	struct test_default t = test_default_init(guest_error_key);
>   
>   	HOST_SYNC(t.vcpu, STAGE_INITED);
>   	HOST_SYNC(t.vcpu, STAGE_SKEYS_SET);
> @@ -446,6 +458,37 @@ static void test_errors_key(void)
>   	kvm_vm_free(t.kvm_vm);
>   }
>   
> +static void test_termination(void)
> +{
> +	struct test_default t = test_default_init(guest_error_key);
> +	uint64_t prefix;
> +	uint64_t teid;
> +	uint64_t teid_mask = BIT(63 - 56) | BIT(63 - 60) | BIT(63 - 61);
> +	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 & teid_mask, 0);
> +
> +	kvm_vm_free(t.kvm_vm);
> +}
> +
>   static void test_errors_key_storage_prot_override(void)
>   {
>   	struct test_default t = test_default_init(guest_copy_key_fetch_prot);
> @@ -668,6 +711,7 @@ int main(int argc, char *argv[])
>   		test_copy_key_fetch_prot();
>   		test_copy_key_fetch_prot_override();
>   		test_errors_key();
> +		test_termination();
>   		test_errors_key_storage_prot_override();
>   		test_errors_key_fetch_prot_override_not_enabled();
>   		test_errors_key_fetch_prot_override_enabled();

  reply	other threads:[~2022-05-17 12:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 13:10 [PATCH v3 0/2] Dirtying, failing memop: don't indicate suppression Janis Schoetterl-Glausch
2022-05-12 13:10 ` [PATCH v3 1/2] KVM: s390: Don't indicate suppression on dirtying, failing memop Janis Schoetterl-Glausch
2022-05-12 13:22   ` David Hildenbrand
2022-05-12 13:51     ` Christian Borntraeger
2022-05-12 15:50       ` David Hildenbrand
2022-05-12 16:26         ` Christian Borntraeger
2022-05-12 16:40           ` David Hildenbrand
2022-05-17 12:25   ` Christian Borntraeger
2022-05-17 14:45   ` Claudio Imbrenda
2022-05-12 13:10 ` [PATCH v3 2/2] KVM: s390: selftest: Test suppression indication on key prot exception Janis Schoetterl-Glausch
2022-05-17 12:26   ` Christian Borntraeger [this message]
2022-05-17 12:28 ` [PATCH v3 0/2] Dirtying, failing memop: don't indicate suppression Christian Borntraeger

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=975ba61e-b0ba-b5a8-8e71-2833b95fb638@linux.ibm.com \
    --to=borntraeger@linux.ibm.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=scgl@linux.ibm.com \
    --cc=shuah@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.