[kvm-unit-tests,v1,2/2] s390x: use inline assembly to test for addressing exceptions
diff mbox

Message ID 20170626161509.18873-3-david@redhat.com
State New
Headers show

Commit Message

David Hildenbrand June 26, 2017, 4:15 p.m. UTC
GCC is free to generate multiple stores instead of just one (e.g.
observed by switching to -O0), making the test fail.

Make sure we really only have one store.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Huth June 27, 2017, 3:45 a.m. UTC | #1
On 26.06.2017 18:15, David Hildenbrand wrote:
> GCC is free to generate multiple stores instead of just one (e.g.
> observed by switching to -O0), making the test fail.
> 
> Make sure we really only have one store.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  s390x/selftest.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/s390x/selftest.c b/s390x/selftest.c
> index 87eb934..1c8d16a 100644
> --- a/s390x/selftest.c
> +++ b/s390x/selftest.c
> @@ -33,7 +33,7 @@ static void test_pgm_int(void)
>  	check_pgm_int_code(PGM_INT_CODE_OPERATION);
>  
>  	expect_pgm_int();
> -	*((unsigned int*)-1) = 1;
> +	asm volatile("	stg %0,0(%0)\n" : : "r"(-1));
>  	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
>  }

I guess using a volatile pointer would work, too? Anyway, the inline
assembly looks certainly also fine here, so:

Reviewed-by: Thomas Huth <thuth@redhat.com>
Paolo Bonzini June 27, 2017, 12:31 p.m. UTC | #2
On 27/06/2017 05:45, Thomas Huth wrote:
> Reviewed-by: Thomas Huth <thuth@redhat.com>

Thanks David and Thomas, queued.

Patch
diff mbox

diff --git a/s390x/selftest.c b/s390x/selftest.c
index 87eb934..1c8d16a 100644
--- a/s390x/selftest.c
+++ b/s390x/selftest.c
@@ -33,7 +33,7 @@  static void test_pgm_int(void)
 	check_pgm_int_code(PGM_INT_CODE_OPERATION);
 
 	expect_pgm_int();
-	*((unsigned int*)-1) = 1;
+	asm volatile("	stg %0,0(%0)\n" : : "r"(-1));
 	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
 }