Skip to contentSkip to conversation

riscv: Fix argc

PATCH In review Andrew Jones 1 participant 2 messages Aug 30, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Fix argc

__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")
---
 riscv/cstart.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
riscv/cstart.S +1 -1
index d5d8ad253748..a9ac72df4dd2 100644
@@ -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
Signature · 1 line
2.45.2
#1 lore raw
Quoted 27 lines · Andrew Jones

__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")
---
 riscv/cstart.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
riscv/cstart.S +1 -1
index d5d8ad253748..a9ac72df4dd2 100644
@@ -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
Signature · 1 line
2.45.2

Merged.

Thanks,
drew