Skip to contentSkip to conversation

tests/tcg: fix semihosting SYS_EXIT for aarch64 in boot.S

RFC PATCH In review Alex Bennée 2 participants 2 messages Apr 4, 2025

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 tests/tcg: fix semihosting SYS_EXIT for aarch64 in boot.S

We don't expect to hit exceptions in our testing so currently all the vectors report an un-expected exception and then attempt to exit. However for aarch64 we should always use the extended information block as we do in _exit. Rather than duplicate the code on the error handler just branch to the _exit handler with a failing status code.

---
 tests/tcg/aarch64/system/boot.S | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tests/tcg/aarch64/system/boot.S +2 -3
index 8fbcba757e..81a60b9c43 100644
@@ -73,9 +73,8 @@ lower_a32_serror:
 	mov	x0, SYS_WRITE0
 	adr	x1, .error
 	semihosting_call
-	mov	x0, SYS_EXIT
-	mov	x1, 1
-	semihosting_call
+	mov	x0, -1
+	bl 	_exit
 	/* never returns */
 
 	.section .rodata
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Alex Bennée

We don't expect to hit exceptions in our testing so currently all the vectors report an un-expected exception and then attempt to exit. However for aarch64 we should always use the extended information block as we do in _exit. Rather than duplicate the code on the error handler just branch to the _exit handler with a failing status code.

---
  tests/tcg/aarch64/system/boot.S | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
tests/tcg/aarch64/system/boot.S +0 -0
index 8fbcba757e..81a60b9c43 100644

tests/tcg/aarch64/system/boot.S lower_a32_serror: · line 77

Quoted 8 lines
tests/tcg/aarch64/system/boot.S +2 -3
@@ -73,9 +73,8 @@ lower_a32_serror:
  	mov	x0, SYS_WRITE0
  	adr	x1, .error
  	semihosting_call
-	mov	x0, SYS_EXIT
-	mov	x1, 1
-	semihosting_call
+	mov	x0, -1
+	bl 	_exit

1 would be EXIT_FAILURE. Otherwise,

r~