Skip to contentSkip to conversation

s390x: two small fixes

PATCH In review David Hildenbrand 3 participants 6 messages Jun 26, 2017 – Jun 27, 2017 KVM

lore
Share & tools
lore
#0 lore raw

cover s390x: two small fixes

Two minor things. Make sure we only have one store when testing for an addressing exception and use the same invalid opcode as QEMU actually does.

David Hildenbrand (2):
s390x: use instruction 0x0000 to test for operation exceptions
s390x: use inline assembly to test for addressing exceptions

 s390x/selftest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.9.4
#1 lore raw

PATCH 1/2 s390x: use instruction 0x0000 to test for operation exceptions

QEMU uses 0x0000 for KVM, not 0x0001. Doesn't really matter (both are invalid), but now it matches the comment.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +1 -1
index ca94158..87eb934 100644
@@ -29,7 +29,7 @@ static void test_fp(void)
 static void test_pgm_int(void)
 {
 	expect_pgm_int();
-	asm volatile("	.insn e,0x0001"); /* used for SW breakpoints in QEMU */
+	asm volatile("	.insn e,0x0000"); /* used for SW breakpoints in QEMU */
 	check_pgm_int_code(PGM_INT_CODE_OPERATION);
 
 	expect_pgm_int();
Signature · 1 line
2.9.4
Reviewed-by on v1 1/2
#2 lore raw

Re: [kvm-unit-tests PATCH v1 1/2] s390x: use instruction 0x0000 to test for operation exceptions

Quoted 14 lines · David Hildenbrand

QEMU uses 0x0000 for KVM, not 0x0001. Doesn't really matter (both are invalid), but now it matches the comment.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +0 -0
index ca94158..87eb934 100644

s390x/selftest.c static void test_fp(void) · line 35

Quoted 8 lines
s390x/selftest.c +1 -1
@@ -29,7 +29,7 @@ static void test_fp(void)
 static void test_pgm_int(void)
 {
 	expect_pgm_int();
-	asm volatile("	.insn e,0x0001"); /* used for SW breakpoints in QEMU */
+	asm volatile("	.insn e,0x0000"); /* used for SW breakpoints in QEMU */
 	check_pgm_int_code(PGM_INT_CODE_OPERATION);
 
 	expect_pgm_int();
#3 lore raw

PATCH 2/2 s390x: use inline assembly to test for addressing exceptions

In reply to David Hildenbrand

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.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +1 -1
index 87eb934..1c8d16a 100644
@@ -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);
 }
 
Signature · 1 line
2.9.4
Reviewed-by on v1 2/2
#4 lore raw

Re: [kvm-unit-tests PATCH v1 2/2] s390x: use inline assembly to test for addressing exceptions

Quoted 15 lines · David Hildenbrand

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.

---
 s390x/selftest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
s390x/selftest.c +0 -0
index 87eb934..1c8d16a 100644

s390x/selftest.c static void test_pgm_int(void) · line 38

Quoted 7 lines
s390x/selftest.c +1 -1
@@ -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: