public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions
@ 2021-09-03 16:25 David Hildenbrand
  2021-09-06 11:53 ` Janosch Frank
  2021-09-06 12:02 ` Claudio Imbrenda
  0 siblings, 2 replies; 3+ messages in thread
From: David Hildenbrand @ 2021-09-03 16:25 UTC (permalink / raw)
  To: kvm
  Cc: Thomas Huth, Janosch Frank, Christian Borntraeger, Cornelia Huck,
	Claudio Imbrenda, linux-s390, David Hildenbrand

... used to be broken in TCG, so let's add a very simple test for SSKE
and ISKE. In order to test RRBE as well, introduce a helper to call the
machine instruction.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 lib/s390x/asm/mem.h | 12 ++++++++++++
 s390x/skey.c        | 28 ++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h
index 40b22b6..845c00c 100644
--- a/lib/s390x/asm/mem.h
+++ b/lib/s390x/asm/mem.h
@@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)
 	return skey;
 }
 
+static inline unsigned char reset_reference_bit(void *addr)
+{
+	int cc;
+
+	asm volatile(
+		"rrbe	0,%1\n"
+		"ipm	%0\n"
+		"srl	%0,28\n"
+		: "=d" (cc) : "a" (addr) : "cc");
+	return cc;
+}
+
 #define PFMF_FSC_4K 0
 #define PFMF_FSC_1M 1
 #define PFMF_FSC_2G 2
diff --git a/s390x/skey.c b/s390x/skey.c
index 2539944..58a5543 100644
--- a/s390x/skey.c
+++ b/s390x/skey.c
@@ -120,6 +120,33 @@ static void test_priv(void)
 	report_prefix_pop();
 }
 
+static void test_invalid_address(void)
+{
+	void *inv_addr = (void *)-1ull;
+
+	report_prefix_push("invalid address");
+
+	report_prefix_push("sske");
+	expect_pgm_int();
+	set_storage_key(inv_addr, 0, 0);
+	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+	report_prefix_pop();
+
+	report_prefix_push("iske");
+	expect_pgm_int();
+	get_storage_key(inv_addr);
+	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+	report_prefix_pop();
+
+	report_prefix_push("rrbe");
+	expect_pgm_int();
+	reset_reference_bit(inv_addr);
+	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+	report_prefix_pop();
+
+	report_prefix_pop();
+}
+
 int main(void)
 {
 	report_prefix_push("skey");
@@ -128,6 +155,7 @@ int main(void)
 		goto done;
 	}
 	test_priv();
+	test_invalid_address();
 	test_set();
 	test_set_mb();
 	test_chg();
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions
  2021-09-03 16:25 [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions David Hildenbrand
@ 2021-09-06 11:53 ` Janosch Frank
  2021-09-06 12:02 ` Claudio Imbrenda
  1 sibling, 0 replies; 3+ messages in thread
From: Janosch Frank @ 2021-09-06 11:53 UTC (permalink / raw)
  To: David Hildenbrand, kvm
  Cc: Thomas Huth, Christian Borntraeger, Cornelia Huck,
	Claudio Imbrenda, linux-s390

On 9/3/21 6:25 PM, David Hildenbrand wrote:
> ... used to be broken in TCG, so let's add a very simple test for SSKE
> and ISKE. In order to test RRBE as well, introduce a helper to call the
> machine instruction.

Reviewed-by: Janosch Frank <frankja@linux.ibm.com>

> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  lib/s390x/asm/mem.h | 12 ++++++++++++
>  s390x/skey.c        | 28 ++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h
> index 40b22b6..845c00c 100644
> --- a/lib/s390x/asm/mem.h
> +++ b/lib/s390x/asm/mem.h
> @@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)
>  	return skey;
>  }
>  
> +static inline unsigned char reset_reference_bit(void *addr)
> +{
> +	int cc;
> +
> +	asm volatile(
> +		"rrbe	0,%1\n"
> +		"ipm	%0\n"
> +		"srl	%0,28\n"
> +		: "=d" (cc) : "a" (addr) : "cc");
> +	return cc;
> +}
> +
>  #define PFMF_FSC_4K 0
>  #define PFMF_FSC_1M 1
>  #define PFMF_FSC_2G 2
> diff --git a/s390x/skey.c b/s390x/skey.c
> index 2539944..58a5543 100644
> --- a/s390x/skey.c
> +++ b/s390x/skey.c
> @@ -120,6 +120,33 @@ static void test_priv(void)
>  	report_prefix_pop();
>  }
>  
> +static void test_invalid_address(void)
> +{
> +	void *inv_addr = (void *)-1ull;
> +
> +	report_prefix_push("invalid address");
> +
> +	report_prefix_push("sske");
> +	expect_pgm_int();
> +	set_storage_key(inv_addr, 0, 0);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_push("iske");
> +	expect_pgm_int();
> +	get_storage_key(inv_addr);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_push("rrbe");
> +	expect_pgm_int();
> +	reset_reference_bit(inv_addr);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_pop();
> +}
> +
>  int main(void)
>  {
>  	report_prefix_push("skey");
> @@ -128,6 +155,7 @@ int main(void)
>  		goto done;
>  	}
>  	test_priv();
> +	test_invalid_address();
>  	test_set();
>  	test_set_mb();
>  	test_chg();
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions
  2021-09-03 16:25 [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions David Hildenbrand
  2021-09-06 11:53 ` Janosch Frank
@ 2021-09-06 12:02 ` Claudio Imbrenda
  1 sibling, 0 replies; 3+ messages in thread
From: Claudio Imbrenda @ 2021-09-06 12:02 UTC (permalink / raw)
  To: David Hildenbrand
  Cc: kvm, Thomas Huth, Janosch Frank, Christian Borntraeger,
	Cornelia Huck, linux-s390

On Fri,  3 Sep 2021 18:25:37 +0200
David Hildenbrand <david@redhat.com> wrote:

> ... used to be broken in TCG, so let's add a very simple test for SSKE
> and ISKE. In order to test RRBE as well, introduce a helper to call the
> machine instruction.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>

Maybe consider testing rrbm too, but anyway:

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

> ---
>  lib/s390x/asm/mem.h | 12 ++++++++++++
>  s390x/skey.c        | 28 ++++++++++++++++++++++++++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/lib/s390x/asm/mem.h b/lib/s390x/asm/mem.h
> index 40b22b6..845c00c 100644
> --- a/lib/s390x/asm/mem.h
> +++ b/lib/s390x/asm/mem.h
> @@ -50,6 +50,18 @@ static inline unsigned char get_storage_key(void *addr)
>  	return skey;
>  }
>  
> +static inline unsigned char reset_reference_bit(void *addr)
> +{
> +	int cc;
> +
> +	asm volatile(
> +		"rrbe	0,%1\n"
> +		"ipm	%0\n"
> +		"srl	%0,28\n"
> +		: "=d" (cc) : "a" (addr) : "cc");
> +	return cc;
> +}
> +
>  #define PFMF_FSC_4K 0
>  #define PFMF_FSC_1M 1
>  #define PFMF_FSC_2G 2
> diff --git a/s390x/skey.c b/s390x/skey.c
> index 2539944..58a5543 100644
> --- a/s390x/skey.c
> +++ b/s390x/skey.c
> @@ -120,6 +120,33 @@ static void test_priv(void)
>  	report_prefix_pop();
>  }
>  
> +static void test_invalid_address(void)
> +{
> +	void *inv_addr = (void *)-1ull;
> +
> +	report_prefix_push("invalid address");
> +
> +	report_prefix_push("sske");
> +	expect_pgm_int();
> +	set_storage_key(inv_addr, 0, 0);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_push("iske");
> +	expect_pgm_int();
> +	get_storage_key(inv_addr);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_push("rrbe");
> +	expect_pgm_int();
> +	reset_reference_bit(inv_addr);
> +	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +	report_prefix_pop();
> +
> +	report_prefix_pop();
> +}
> +
>  int main(void)
>  {
>  	report_prefix_push("skey");
> @@ -128,6 +155,7 @@ int main(void)
>  		goto done;
>  	}
>  	test_priv();
> +	test_invalid_address();
>  	test_set();
>  	test_set_mb();
>  	test_chg();


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-06 12:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-03 16:25 [kvm-unit-tests PATCH v1] s390x/skey: Test for ADDRESSING exceptions David Hildenbrand
2021-09-06 11:53 ` Janosch Frank
2021-09-06 12:02 ` Claudio Imbrenda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox