diff mbox series

[PATCH-for-10.1,v2] target/riscv/gdbstub: Replace ldtul_p() -> ldn_p(sizeof(target_ulong))

Message ID 20250325154913.95283-1-philmd@linaro.org
State New
Headers show
Series [PATCH-for-10.1,v2] target/riscv/gdbstub: Replace ldtul_p() -> ldn_p(sizeof(target_ulong)) | expand

Commit Message

Philippe Mathieu-Daudé March 25, 2025, 3:49 p.m. UTC
Replace the few ldtul_p() calls by a generic ldn_p() ones.
No logical change.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/riscv/gdbstub.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Richard Henderson March 25, 2025, 6:43 p.m. UTC | #1
On 3/25/25 08:49, Philippe Mathieu-Daudé wrote:
> Replace the few ldtul_p() calls by a generic ldn_p() ones.
> No logical change.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/riscv/gdbstub.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
Alistair Francis March 26, 2025, 4:29 a.m. UTC | #2
On Wed, Mar 26, 2025 at 1:50 AM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> Replace the few ldtul_p() calls by a generic ldn_p() ones.
> No logical change.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  target/riscv/gdbstub.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
> index 18e88f416af..c1dc54e47d6 100644
> --- a/target/riscv/gdbstub.c
> +++ b/target/riscv/gdbstub.c
> @@ -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
>
>
Alex Bennée March 26, 2025, 11:26 a.m. UTC | #3
Philippe Mathieu-Daudé <philmd@linaro.org> writes:

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

Queued to gdbstub/next, thanks.
<snip>
diff mbox series

Patch

diff --git a/target/riscv/gdbstub.c b/target/riscv/gdbstub.c
index 18e88f416af..c1dc54e47d6 100644
--- a/target/riscv/gdbstub.c
+++ b/target/riscv/gdbstub.c
@@ -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) {