qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 08/18] target/loongarch: Truncate high 32 bits of address


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v3 08/18] target/loongarch: Truncate high 32 bits of address in VA32 mode
Date: Fri, 18 Aug 2023 11:41:50 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0

On 17/8/23 11:31, Song Gao wrote:
From: Jiajie Chen <c@jia.je>

When running in VA32 mode(!LA64 or VA32L[1-3] matching PLV), virtual
address is truncated to 32 bits before address mapping.

Signed-off-by: Jiajie Chen <c@jia.je>
Co-authored-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
---
  target/loongarch/cpu.c                        | 16 ++++----
  target/loongarch/cpu.h                        |  9 +++++
  target/loongarch/gdbstub.c                    |  2 +-
  .../loongarch/insn_trans/trans_atomic.c.inc   |  5 ++-
  .../loongarch/insn_trans/trans_branch.c.inc   |  3 +-
  .../loongarch/insn_trans/trans_fmemory.c.inc  | 30 ++++-----------
  target/loongarch/insn_trans/trans_lsx.c.inc   | 38 +++++--------------
  .../loongarch/insn_trans/trans_memory.c.inc   | 34 +++++------------
  target/loongarch/op_helper.c                  |  4 +-
  target/loongarch/translate.c                  | 32 ++++++++++++++++
  10 files changed, 85 insertions(+), 88 deletions(-)

diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 30dd70571a..bd980790f2 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -81,7 +81,7 @@ static void loongarch_cpu_set_pc(CPUState *cs, vaddr value)
      LoongArchCPU *cpu = LOONGARCH_CPU(cs);
      CPULoongArchState *env = &cpu->env;
- env->pc = value;
+    set_pc(env, value);

Shouldn't we use CPUClass::set_pc() instead?

  }


diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 0e02257f91..9f550793ca 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -442,6 +442,15 @@ static inline bool is_va32(CPULoongArchState *env)
      return va32;
  }
+static inline void set_pc(CPULoongArchState *env, uint64_t value)
+{
+    if (is_va32(env)) {
+        env->pc = (uint32_t)value;

That would become loongarch32_cpu_set_pc().

+    } else {
+        env->pc = value;

This is the current loongarch_cpu_set_pc().

+    }
+}





reply via email to

[Prev in Thread] Current Thread [Next in Thread]