diff mbox series

[kvm-unit-tests] riscv: Fix argc

Message ID 20240830102007.2206384-2-andrew.jones@linux.dev (mailing list archive)
State New
Headers show
Series [kvm-unit-tests] riscv: Fix argc | expand

Commit Message

Andrew Jones Aug. 30, 2024, 10:20 a.m. UTC
__argc is 32 bits so even rv64 should load it with lw, not just rv32.
This fixes odd behavior such as getting false when testing argc < 2
even though we know argc should be 1. argc < 2 being false comes from
the register comparison using the full register width and the upper
32 bits being loaded with junk.

Fixes: bd744d465910 ("riscv: Initial port, hello world")
Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
---
 riscv/cstart.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Jones Aug. 30, 2024, 10:42 a.m. UTC | #1
On Fri, Aug 30, 2024 at 12:20:08PM GMT, Andrew Jones wrote:
> __argc is 32 bits so even rv64 should load it with lw, not just rv32.
> This fixes odd behavior such as getting false when testing argc < 2
> even though we know argc should be 1. argc < 2 being false comes from
> the register comparison using the full register width and the upper
> 32 bits being loaded with junk.
> 
> Fixes: bd744d465910 ("riscv: Initial port, hello world")
> Signed-off-by: Andrew Jones <andrew.jones@linux.dev>
> ---
>  riscv/cstart.S | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/riscv/cstart.S b/riscv/cstart.S
> index d5d8ad253748..a9ac72df4dd2 100644
> --- a/riscv/cstart.S
> +++ b/riscv/cstart.S
> @@ -93,7 +93,7 @@ start:
>  
>  	/* run the test */
>  	la	a0, __argc
> -	REG_L	a0, 0(a0)
> +	lw	a0, 0(a0)
>  	la	a1, __argv
>  	la	a2, __environ
>  	call	main
> -- 
> 2.45.2

Merged.

Thanks,
drew
diff mbox series

Patch

diff --git a/riscv/cstart.S b/riscv/cstart.S
index d5d8ad253748..a9ac72df4dd2 100644
--- a/riscv/cstart.S
+++ b/riscv/cstart.S
@@ -93,7 +93,7 @@  start:
 
 	/* run the test */
 	la	a0, __argc
-	REG_L	a0, 0(a0)
+	lw	a0, 0(a0)
 	la	a1, __argv
 	la	a2, __environ
 	call	main