diff mbox series

[kvm-unit-tests,v3] s390x: diag308: Only test subcode 2 under QEMU

Message ID 20220407130252.15603-1-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests,v3] s390x: diag308: Only test subcode 2 under QEMU | expand

Commit Message

Janosch Frank April 7, 2022, 1:02 p.m. UTC
Other hypervisors might implement it and therefore not send a
specification exception.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/diag308.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Claudio Imbrenda April 7, 2022, 1:11 p.m. UTC | #1
On Thu,  7 Apr 2022 13:02:52 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> Other hypervisors might implement it and therefore not send a
> specification exception.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

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

> ---
>  s390x/diag308.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/diag308.c b/s390x/diag308.c
> index c9d6c499..ea41b455 100644
> --- a/s390x/diag308.c
> +++ b/s390x/diag308.c
> @@ -8,6 +8,7 @@
>  #include <libcflat.h>
>  #include <asm/asm-offsets.h>
>  #include <asm/interrupt.h>
> +#include <hardware.h>
>  
>  /* The diagnose calls should be blocked in problem state */
>  static void test_priv(void)
> @@ -75,7 +76,7 @@ static void test_subcode6(void)
>  /* Unsupported subcodes should generate a specification exception */
>  static void test_unsupported_subcode(void)
>  {
> -	int subcodes[] = { 2, 0x101, 0xffff, 0x10001, -1 };
> +	int subcodes[] = { 0x101, 0xffff, 0x10001, -1 };
>  	int idx;
>  
>  	for (idx = 0; idx < ARRAY_SIZE(subcodes); idx++) {
> @@ -85,6 +86,21 @@ static void test_unsupported_subcode(void)
>  		check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
>  		report_prefix_pop();
>  	}
> +
> +	/*
> +	 * Subcode 2 is not available under QEMU but might be on other
> +	 * hypervisors so we only check for the specification
> +	 * exception on QEMU.
> +	 */
> +	report_prefix_pushf("0x%04x", 2);
> +	if (host_is_qemu()) {
> +		expect_pgm_int();
> +		asm volatile ("diag %0,%1,0x308" :: "d"(0), "d"(2));
> +		check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
> +	} else {
> +		report_skip("subcode is supported");
> +	}
> +	report_prefix_pop();
>  }
>  
>  static struct {
Nico Boehr April 11, 2022, 11:46 a.m. UTC | #2
On Thu, 2022-04-07 at 13:02 +0000, Janosch Frank wrote:
> Other hypervisors might implement it and therefore not send a
> specification exception.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

Reviewed-by: Nico Boehr <nrb@linux.ibm.com>
diff mbox series

Patch

diff --git a/s390x/diag308.c b/s390x/diag308.c
index c9d6c499..ea41b455 100644
--- a/s390x/diag308.c
+++ b/s390x/diag308.c
@@ -8,6 +8,7 @@ 
 #include <libcflat.h>
 #include <asm/asm-offsets.h>
 #include <asm/interrupt.h>
+#include <hardware.h>
 
 /* The diagnose calls should be blocked in problem state */
 static void test_priv(void)
@@ -75,7 +76,7 @@  static void test_subcode6(void)
 /* Unsupported subcodes should generate a specification exception */
 static void test_unsupported_subcode(void)
 {
-	int subcodes[] = { 2, 0x101, 0xffff, 0x10001, -1 };
+	int subcodes[] = { 0x101, 0xffff, 0x10001, -1 };
 	int idx;
 
 	for (idx = 0; idx < ARRAY_SIZE(subcodes); idx++) {
@@ -85,6 +86,21 @@  static void test_unsupported_subcode(void)
 		check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
 		report_prefix_pop();
 	}
+
+	/*
+	 * Subcode 2 is not available under QEMU but might be on other
+	 * hypervisors so we only check for the specification
+	 * exception on QEMU.
+	 */
+	report_prefix_pushf("0x%04x", 2);
+	if (host_is_qemu()) {
+		expect_pgm_int();
+		asm volatile ("diag %0,%1,0x308" :: "d"(0), "d"(2));
+		check_pgm_int_code(PGM_INT_CODE_SPECIFICATION);
+	} else {
+		report_skip("subcode is supported");
+	}
+	report_prefix_pop();
 }
 
 static struct {