Skip to contentSkip to conversation

target/riscv: Align the data type of reset vector address

PATCH Superseded Dylan Jhong 3 participants 5 messages Mar 23, 2021 – Mar 25, 2021 RISC-V

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/riscv: Align the data type of reset vector address

Although the AE350 has not been upstream (preparing for v2), the reset vector of the AE350 is known to be at the 2G position, so this patch is corrected in advance.

---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +1 -1
index 2a990f6253..0236abf169 100644
@@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature)
     env->features |= (1ULL << feature);
 }
 
-static void set_resetvec(CPURISCVState *env, int resetvec)
+static void set_resetvec(CPURISCVState *env, uint64_t resetvec)
 {
 #ifndef CONFIG_USER_ONLY
     env->resetvec = resetvec;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · Dylan Jhong

Although the AE350 has not been upstream (preparing for v2), the reset vector of the AE350 is known to be at the 2G position, so this patch is corrected in advance.

---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +0 -0
index 2a990f6253..0236abf169 100644

target/riscv/cpu.c static void set_feature(CPURISCVState *env, int feature) · line 140

Quoted 5 lines
target/riscv/cpu.c +1 -1
@@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature)
     env->features |= (1ULL << feature);
 }
 
-static void set_resetvec(CPURISCVState *env, int resetvec)
+static void set_resetvec(CPURISCVState *env, uint64_t resetvec)

resetvec in env is a target_ulong so this should be as well (instead of a uint64_t).

Alistair

Quoted 7 lines
target/riscv/cpu.c +0 -1
 {
 #ifndef CONFIG_USER_ONLY
     env->resetvec = resetvec;
--

2.17.1

#2 lore raw
Quoted 20 lines · Alistair Francis
Quoted 19 lines · Dylan Jhong

Although the AE350 has not been upstream (preparing for v2), the reset vector of the AE350 is known to be at the 2G position, so this patch is corrected in advance.

---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +0 -0
index 2a990f6253..0236abf169 100644
@@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature)
     env->features |= (1ULL << feature);
 }
 
Quoted 8 lines

target/riscv/cpu.c static void set_feature(CPURISCVState *env, int feature) · line 140

Quoted 2 lines
target/riscv/cpu.c +1 -1
-static void set_resetvec(CPURISCVState *env, int resetvec)
+static void set_resetvec(CPURISCVState *env, uint64_t resetvec)

resetvec in env is a target_ulong so this should be as well (instead of a uint64_t).

Alistair

Hi Alistar,

Thanks for your comments.

Indeed resetvec should use target_ulong instead of uint64_t.
But in target/riscv/cpu.h:306, there is also a resetvec in struct RISCVCPU but it is defined as uint64_t. Do you think I should change it to target_ulong together?

ref:
commit 9b4c9b2b2a50fe4eb90d0ac2d8723b46ecb42511
https://www.mail-archive.com/[email protected]/msg730077.html

Quoted 7 lines
Quoted 7 lines
target/riscv/cpu.c +0 -1
 {
 #ifndef CONFIG_USER_ONLY
     env->resetvec = resetvec;
--

2.17.1

#3 lore raw
Quoted 28 lines · Dylan Jhong
Quoted 26 lines · Alistair Francis
Quoted 16 lines · Dylan Jhong

Although the AE350 has not been upstream (preparing for v2), the reset vector of the AE350 is known to be at the 2G position, so this patch is corrected in advance.

---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +0 -0
index 2a990f6253..0236abf169 100644

target/riscv/cpu.c static void set_feature(CPURISCVState *env, int feature) · line 140

Quoted 5 lines
target/riscv/cpu.c +1 -1
@@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature)
     env->features |= (1ULL << feature);
 }
 
-static void set_resetvec(CPURISCVState *env, int resetvec)
+static void set_resetvec(CPURISCVState *env, uint64_t resetvec)

resetvec in env is a target_ulong so this should be as well (instead of a uint64_t).

Quoted 8 lines
Quoted 2 lines

Alistair

Hi Alistar,

Thanks for your comments.

Indeed resetvec should use target_ulong instead of uint64_t.

resetvec being target_ulong means that rv32 cannot have a reset vector beyond 4GiB. I don't think the spec disallow this.

Quoted 6 lines

But in target/riscv/cpu.h:306, there is also a resetvec in struct RISCVCPU but it is defined as uint64_t. Do you think I should change it to target_ulong together?

ref:
commit 9b4c9b2b2a50fe4eb90d0ac2d8723b46ecb42511
https://www.mail-archive.com/[email protected]/msg730077.html

Regards,
Bin

#4 lore raw
Quoted 33 lines · Bin Meng
Quoted 31 lines · Dylan Jhong
Quoted 28 lines · Alistair Francis
Quoted 16 lines · Dylan Jhong

Although the AE350 has not been upstream (preparing for v2), the reset vector of the AE350 is known to be at the 2G position, so this patch is corrected in advance.

---
 target/riscv/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/cpu.c +0 -0
index 2a990f6253..0236abf169 100644

target/riscv/cpu.c static void set_feature(CPURISCVState *env, int feature) · line 140

Quoted 5 lines
target/riscv/cpu.c +1 -1
@@ -137,7 +137,7 @@ static void set_feature(CPURISCVState *env, int feature)
     env->features |= (1ULL << feature);
 }
 
-static void set_resetvec(CPURISCVState *env, int resetvec)
+static void set_resetvec(CPURISCVState *env, uint64_t resetvec)

resetvec in env is a target_ulong so this should be as well (instead of a uint64_t).

Alistair

Quoted 8 lines
Quoted 5 lines

Hi Alistar,

Thanks for your comments.

Indeed resetvec should use target_ulong instead of uint64_t.

resetvec being target_ulong means that rv32 cannot have a reset vector beyond 4GiB. I don't think the spec disallow this.

Ah, I was wrong. The spec says: "the pc is set to an implementation-de ned reset vector" and pc is XLEN wide.

So for rv32 the reset vector cannot beyond 4GiB. We should change it to target_ulong.

Regards,
Bin