Convert loongarch to providing the translate_for_debug method rather
than the deprecated get_phys_addr_debug method.

Signed-off-by: Peter Maydell <[email protected]>
---
 target/loongarch/cpu-mmu.h    |  3 ++-
 target/loongarch/cpu.c        |  2 +-
 target/loongarch/cpu_helper.c | 12 +++++++++---
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/target/loongarch/cpu-mmu.h b/target/loongarch/cpu-mmu.h
index 54fb732d62d..491eb514d9d 100644
--- a/target/loongarch/cpu-mmu.h
+++ b/target/loongarch/cpu-mmu.h
@@ -99,7 +99,8 @@ TLBRet loongarch_ptw(CPULoongArchState *env, MMUContext 
*context,
                      int access_type, int mmu_idx, int debug);
 void get_dir_base_width(CPULoongArchState *env, uint64_t *dir_base,
                         uint64_t *dir_width, unsigned int level);
-hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool loongarch_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                       TranslateForDebugResult *result);
 uint64_t loongarch_palen_mask(CPULoongArchState *env);
 
 #endif  /* LOONGARCH_CPU_MMU_H */
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 54c26998979..69d9658f8ce 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -841,7 +841,7 @@ static void loongarch_cpu_dump_state(CPUState *cs, FILE *f, 
int flags)
 static const struct SysemuCPUOps loongarch_sysemu_ops = {
     .has_work = loongarch_cpu_has_work,
     .write_elf64_note = loongarch_cpu_write_elf64_note,
-    .get_phys_addr_debug = loongarch_cpu_get_phys_addr_debug,
+    .translate_for_debug = loongarch_cpu_translate_for_debug,
 };
 
 static int64_t loongarch_cpu_get_arch_id(CPUState *cs)
diff --git a/target/loongarch/cpu_helper.c b/target/loongarch/cpu_helper.c
index 123cad3d930..270917184a6 100644
--- a/target/loongarch/cpu_helper.c
+++ b/target/loongarch/cpu_helper.c
@@ -363,7 +363,8 @@ TLBRet get_physical_address(CPULoongArchState *env, 
MMUContext *context,
     return loongarch_map_address(env, context, access_type, mmu_idx, is_debug);
 }
 
-hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool loongarch_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                       TranslateForDebugResult *result)
 {
     CPULoongArchState *env = cpu_env(cs);
     MMUContext context;
@@ -371,9 +372,14 @@ hwaddr loongarch_cpu_get_phys_addr_debug(CPUState *cs, 
vaddr addr)
     context.addr = addr;
     if (get_physical_address(env, &context, MMU_DATA_LOAD,
                              cpu_mmu_index(cs, false), 1) != TLBRET_MATCH) {
-        return -1;
+        return false;
     }
-    return context.physical;
+    *result = (TranslateForDebugResult) {
+        .physaddr = context.physical,
+        .attrs.debug = 1,
+        .lg_page_size = TARGET_PAGE_BITS,
+    };
+    return true;
 }
 
 uint64_t loongarch_palen_mask(CPULoongArchState *env)
-- 
2.43.0


Reply via email to