On Wed, Mar 26, 2025 at 1:50 AM Philippe Mathieu-Daudé
<phi...@linaro.org> wrote:
>
> Replace the few ldtul_p() calls by a generic ldn_p() ones.
> No logical change.
>
> Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>

Reviewed-by: Alistair Francis <alistair.fran...@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
>
>

Reply via email to