Skip to contentSkip to conversation

target/riscv/gdbstub: Replace ldtul_p() -> ldn_p(sizeof(target_ulong))

PATCH Applied Philippe Mathieu-Daudé 4 participants 5 messages Mar 25, 2025 – Dec 26, 2025 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target/riscv/gdbstub: Replace ldtul_p() -> ldn_p(sizeof(target_ulong))

Replace the few ldtul_p() calls by a generic ldn_p() ones. No logical change.

---
 target/riscv/gdbstub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
target/riscv/gdbstub.c +5 -3
index 18e88f416af..c1dc54e47d6 100644
@@ -193,7 +193,7 @@ static int riscv_gdb_set_csr(CPUState *cs, uint8_t *mem_buf, int n)
     CPURISCVState *env = &cpu->env;
 
     if (n < CSR_TABLE_SIZE) {
-        target_ulong val = ldtul_p(mem_buf);
+        target_ulong val = ldn_p(mem_buf, sizeof(val));
         int result;
 
         result = riscv_csrrw_debug(env, n, NULL, val, -1);
@@ -229,15 +229,17 @@ static int riscv_gdb_set_virtual(CPUState *cs, uint8_t *mem_buf, int n)
         RISCVCPU *cpu = RISCV_CPU(cs);
         CPURISCVState *env = &cpu->env;
 
-        target_ulong new_priv = ldtul_p(mem_buf) & 0x3;
+        target_ulong new_priv;
+        size_t regsize = sizeof(new_priv);
         bool new_virt = 0;
 
+        new_priv = ldn_p(mem_buf, regsize) & 0x3;
         if (new_priv == PRV_RESERVED) {
             new_priv = PRV_S;
         }
 
         if (new_priv != PRV_M) {
-            new_virt = (ldtul_p(mem_buf) & BIT(2)) >> 2;
+            new_virt = (ldn_p(mem_buf, regsize) & BIT(2)) >> 2;
         }
 
         if (riscv_has_ext(env, RVH) && new_virt != env->virt_enabled) {
Signature · 1 line
2.47.1
Reviewed-by on v2 1/1
#2 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 5 lines · Philippe Mathieu-Daudé

Replace the few ldtul_p() calls by a generic ldn_p() ones. No logical change.

Alistair

Quoted 41 lines
---
 target/riscv/gdbstub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
target/riscv/gdbstub.c +5 -4
index 18e88f416af..c1dc54e47d6 100644
@@ -193,7 +193,7 @@ static int riscv_gdb_set_csr(CPUState *cs, uint8_t *mem_buf, int n)
     CPURISCVState *env = &cpu->env;
 
     if (n < CSR_TABLE_SIZE) {
-        target_ulong val = ldtul_p(mem_buf);
+        target_ulong val = ldn_p(mem_buf, sizeof(val));
         int result;
 
         result = riscv_csrrw_debug(env, n, NULL, val, -1);
@@ -229,15 +229,17 @@ static int riscv_gdb_set_virtual(CPUState *cs, uint8_t *mem_buf, int n)
         RISCVCPU *cpu = RISCV_CPU(cs);
         CPURISCVState *env = &cpu->env;
 
-        target_ulong new_priv = ldtul_p(mem_buf) & 0x3;
+        target_ulong new_priv;
+        size_t regsize = sizeof(new_priv);
         bool new_virt = 0;
 
+        new_priv = ldn_p(mem_buf, regsize) & 0x3;
         if (new_priv == PRV_RESERVED) {
             new_priv = PRV_S;
         }
 
         if (new_priv != PRV_M) {
-            new_virt = (ldtul_p(mem_buf) & BIT(2)) >> 2;
+            new_virt = (ldn_p(mem_buf, regsize) & BIT(2)) >> 2;
         }
 
         if (riscv_has_ext(env, RVH) && new_virt != env->virt_enabled) {
--

2.47.1

Applied
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 2 lines · Philippe Mathieu-Daudé

Replace the few ldtul_p() calls by a generic ldn_p() ones. No logical change.

Queued to gdbstub/next, thanks.
<snip>

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#4 lore raw

Hi,

Quoted 8 lines · Alex Bennée
Quoted 2 lines · Philippe Mathieu-Daudé

Replace the few ldtul_p() calls by a generic ldn_p() ones. No logical change.

Queued to gdbstub/next, thanks.
<snip>

This patch got never merged, is there an issue with it?