Skip to contentSkip to conversation

alpha, avr, or1k, rx, tricore: Convert to translate_for_debug

PATCH Applied Peter Maydell 4 participants 18 messages Oct 20 – Oct 29

lore
Share & tools
lore
#0 lore raw

cover alpha, avr, or1k, rx, tricore: Convert to translate_for_debug

Earlier this year I did some work on the API that target CPUs use to provide "translate this virtual address to physical for a debug access". We now have a new method, translate_for_debug, but still support the old get_phys_addr_debug method as well.

This series does a bit of cleanup by converting five target architectures from the legacy method to the new one. Conversion is straightforward.

I have opted to follow the riscv translate_for_debug implementation in having the returned attrs set .debug and not also .unspecified (via MEMTXATTRS_UNSPECIFIED or otherwise), since on a per-architecture basis we can see that we don't want to set any of the other attributes in MemTxAttrs. This is a minor behaviour change from using the fallback codepath in cpu_translate_for_debug(), which starts with MEMTXATTRS_UNSPECIFIED and adds .debug, since it can't know whether the target architecture makes use of the various attribute fields. The only thing that we use the .unspecified field for is that the IOMMUs check it to see if they can look at attrs.requester_id etc, and debug accesses aren't going to be going through an IOMMU anyway, so this isn't a behaviour change in practice.

(There are another 10 archs still to convert, but I figured I'd just start with these five and see if there were review comments before doing the rest of them.)

thanks
--PMM

Peter Maydell (5):
target/alpha: Convert to translate_for_debug
target/avr: Convert to translate_for_debug
target/or1k: Convert to translate_for_debug
target/rx: Convert to translate_for_debug
target/tricore: Convert to translate_for_debug

 target/alpha/cpu.h      |  3 ++-
 target/avr/cpu.h        |  3 ++-
 target/or1k/cpu.h       |  3 ++-
 target/rx/cpu.h         |  3 ++-
 target/tricore/cpu.h    |  3 ++-
 target/alpha/cpu.c      |  2 +-
 target/alpha/helper.c   | 15 +++++++++++++--
 target/avr/cpu.c        |  2 +-
 target/avr/helper.c     | 11 +++++++++--
 target/or1k/cpu.c       |  2 +-
 target/or1k/mmu.c       | 21 ++++++++++++++++-----
 target/rx/cpu.c         |  2 +-
 target/rx/helper.c      | 10 ++++++++--
 target/tricore/cpu.c    |  2 +-
 target/tricore/helper.c | 13 ++++++++++---
 15 files changed, 71 insertions(+), 24 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/5 target/alpha: Convert to translate_for_debug

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

---
 target/alpha/cpu.h    |  3 ++-
 target/alpha/cpu.c    |  2 +-
 target/alpha/helper.c | 15 +++++++++++++--
 3 files changed, 16 insertions(+), 4 deletions(-)
target/alpha/cpu.h +2 -1
index 378bd96d941..32f53453d72 100644
@@ -282,7 +282,8 @@ extern const VMStateDescription vmstate_alpha_cpu;
 
 void alpha_cpu_do_interrupt(CPUState *cpu);
 bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool alpha_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                   TranslateForDebugResult *result);
 #endif /* !CONFIG_USER_ONLY */
 void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags);
 int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
target/alpha/cpu.c +1 -1
index 12e86021663..dca25456e78 100644
@@ -242,7 +242,7 @@ static void alpha_cpu_initfn(Object *obj)
 
 static const struct SysemuCPUOps alpha_sysemu_ops = {
     .has_work = alpha_cpu_has_work,
-    .get_phys_addr_debug = alpha_cpu_get_phys_addr_debug,
+    .translate_for_debug = alpha_cpu_translate_for_debug,
 };
 #endif
 
target/alpha/helper.c +13 -2
index c3614ecafda..ccf1994b31b 100644
@@ -297,14 +297,25 @@ static int get_physical_address(CPUAlphaState *env, vaddr addr,
     return ret;
 }
 
-hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool alpha_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                   TranslateForDebugResult *result)
 {
     hwaddr phys;
     int prot, fail;
 
     fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot);
+    if (fail >= 0) {
+        return false;
+    }
+
     phys |= addr & ~TARGET_PAGE_MASK;
-    return (fail >= 0 ? -1 : phys);
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
Signature · 1 line
2.43.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] target/alpha: Convert to translate_for_debug

Quoted 9 lines · Peter Maydell

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

---
  target/alpha/cpu.h    |  3 ++-
  target/alpha/cpu.c    |  2 +-
  target/alpha/helper.c | 15 +++++++++++++--
  3 files changed, 16 insertions(+), 4 deletions(-)

r~

Reviewed-by on v1 1/5
#3 lore raw

Re: [PATCH 1/5] target/alpha: Convert to translate_for_debug

In reply to Peter Maydell

Hi,

Quoted 11 lines · Peter Maydell

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

---
  target/alpha/cpu.h    |  3 ++-
  target/alpha/cpu.c    |  2 +-
  target/alpha/helper.c | 15 +++++++++++++--
  3 files changed, 16 insertions(+), 4 deletions(-)

target/alpha/helper.c static int get_physical_address(CPUAlphaState *env, vaddr addr, · line 307

Quoted 9 lines
target/alpha/helper.c +3 -1
-hwaddr alpha_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool alpha_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                   TranslateForDebugResult *result)
  {
      hwaddr phys;
      int prot, fail;
 
      fail = get_physical_address(cpu_env(cs), addr, 0, 0, &phys, &prot);
+    if (fail >= 0) {

Pre-existing, @fail is mis-named, it is the target @excp (or -1 on failure).

target/alpha/helper.c static int get_physical_address(CPUAlphaState *env, vaddr addr, · line 311

Quoted 4 lines
target/alpha/helper.c +3 -0
+        return false;
+    }
+
      phys |= addr & ~TARGET_PAGE_MASK;

Clearer, we don't update @phys and discard it on failure.

Quoted 11 lines
target/alpha/helper.c +7 -1
-    return (fail >= 0 ? -1 : phys);
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
  }
 
  bool alpha_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
#4 lore raw

PATCH 2/5 target/avr: Convert to translate_for_debug

In reply to Peter Maydell

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

---
 target/avr/cpu.h    |  3 ++-
 target/avr/cpu.c    |  2 +-
 target/avr/helper.c | 11 +++++++++--
 3 files changed, 12 insertions(+), 4 deletions(-)
target/avr/cpu.h +2 -1
index 1e4e839bd83..4e2372a6801 100644
@@ -177,7 +177,8 @@ extern const struct VMStateDescription vms_avr_cpu;
 
 void avr_cpu_do_interrupt(CPUState *cpu);
 bool avr_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr avr_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool avr_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                 TranslateForDebugResult *result);
 int avr_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int avr_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
 int avr_print_insn(bfd_vma addr, disassemble_info *info);
target/avr/cpu.c +1 -1
index f8409f32ab9..9476bd87276 100644
@@ -233,7 +233,7 @@ static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags)
 
 static const struct SysemuCPUOps avr_sysemu_ops = {
     .has_work = avr_cpu_has_work,
-    .get_phys_addr_debug = avr_cpu_get_phys_addr_debug,
+    .translate_for_debug = avr_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps avr_tcg_ops = {
target/avr/helper.c +9 -2
index f452c9d9040..8f90b8d9a45 100644
@@ -108,9 +108,16 @@ void avr_cpu_do_interrupt(CPUState *cs)
     qemu_plugin_vcpu_interrupt_cb(cs, ret);
 }
 
-hwaddr avr_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool avr_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                 TranslateForDebugResult *result)
 {
-    return addr; /* I assume 1:1 address correspondence */
+    /* I assume 1:1 address correspondence */
+    *result = (TranslateForDebugResult) {
+        .physaddr = addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 bool avr_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
Signature · 1 line
2.43.0
Reviewed-by on v1 2/5
#5 lore raw

Re: [PATCH 2/5] target/avr: Convert to translate_for_debug

Quoted 9 lines · Peter Maydell

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

---
  target/avr/cpu.h    |  3 ++-
  target/avr/cpu.c    |  2 +-
  target/avr/helper.c | 11 +++++++++--
  3 files changed, 12 insertions(+), 4 deletions(-)

r~

Reviewed-by on v1 2/5
#6 lore raw

Re: [PATCH 2/5] target/avr: Convert to translate_for_debug

In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

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

---
  target/avr/cpu.h    |  3 ++-
  target/avr/cpu.c    |  2 +-
  target/avr/helper.c | 11 +++++++++--
  3 files changed, 12 insertions(+), 4 deletions(-)

No MMU,

#7 lore raw

PATCH 3/5 target/or1k: Convert to translate_for_debug

In reply to Peter Maydell

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

---
 target/or1k/cpu.h |  3 ++-
 target/or1k/cpu.c |  2 +-
 target/or1k/mmu.c | 21 ++++++++++++++++-----
 3 files changed, 19 insertions(+), 7 deletions(-)
target/or1k/cpu.h +2 -1
index fc4387ce7ae..99b65ae4b97 100644
@@ -296,7 +296,8 @@ void openrisc_translate_code(CPUState *cs, TranslationBlock *tb,
 int print_insn_or1k(bfd_vma addr, disassemble_info *info);
 
 #ifndef CONFIG_USER_ONLY
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool openrisc_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                      TranslateForDebugResult *result);
 
 bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                            MMUAccessType access_type, int mmu_idx,
target/or1k/cpu.c +1 -1
index 66c00c0930c..d5415f0e567 100644
@@ -247,7 +247,7 @@ static void openrisc_any_initfn(Object *obj)
 
 static const struct SysemuCPUOps openrisc_sysemu_ops = {
     .has_work = openrisc_cpu_has_work,
-    .get_phys_addr_debug = openrisc_cpu_get_phys_addr_debug,
+    .translate_for_debug = openrisc_cpu_translate_for_debug,
 };
 #endif
 
target/or1k/mmu.c +16 -5
index 3fc56e1b771..a78e8c8ca2e 100644
@@ -139,7 +139,8 @@ bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
     cpu_loop_exit_restore(cs, retaddr);
 }
 
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool openrisc_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                      TranslateForDebugResult *result)
 {
     OpenRISCCPU *cpu = OPENRISC_CPU(cs);
     int prot, excp, sr = cpu->env.sr;
@@ -152,12 +153,15 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                             PAGE_READ,
                             (sr & SR_SM) != 0);
         if (!excp) {
-            return phys_addr;
+            break;
         }
         excp = get_phys_mmu(cpu, &phys_addr, &prot, addr,
                             PAGE_EXEC,
                             (sr & SR_SM) != 0);
-        return excp ? -1 : phys_addr;
+        if (excp) {
+            return false;
+        }
+        break;
 
     default:
         /* The mmu is partially enabled, and we don't really have
@@ -167,13 +171,20 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                             PAGE_EXEC | PAGE_READ | PAGE_WRITE,
                             (sr & SR_SM) != 0);
         if (!excp) {
-            return phys_addr;
+            break;
         }
         /* fallthru */
 
     case 0:
         /* The mmu is definitely disabled; lookups never fail.  */
         get_phys_nommu(&phys_addr, &prot, addr);
-        return phys_addr;
+        break;
     }
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 3/5
#8 lore raw

Re: [PATCH 3/5] target/or1k: Convert to translate_for_debug

Quoted 9 lines · Peter Maydell

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

---
  target/or1k/cpu.h |  3 ++-
  target/or1k/cpu.c |  2 +-
  target/or1k/mmu.c | 21 ++++++++++++++++-----
  3 files changed, 19 insertions(+), 7 deletions(-)

r~

Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] target/or1k: Convert to translate_for_debug

In reply to Peter Maydell

Hi,

Quoted 52 lines · Peter Maydell

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

---
  target/or1k/cpu.h |  3 ++-
  target/or1k/cpu.c |  2 +-
  target/or1k/mmu.c | 21 ++++++++++++++++-----
  3 files changed, 19 insertions(+), 7 deletions(-)
target/or1k/cpu.h +2 -1
index fc4387ce7ae..99b65ae4b97 100644
@@ -296,7 +296,8 @@ void openrisc_translate_code(CPUState *cs, TranslationBlock *tb,
  int print_insn_or1k(bfd_vma addr, disassemble_info *info);
 
  #ifndef CONFIG_USER_ONLY
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool openrisc_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                      TranslateForDebugResult *result);
 
  bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
                             MMUAccessType access_type, int mmu_idx,
target/or1k/cpu.c +1 -1
index 66c00c0930c..d5415f0e567 100644
@@ -247,7 +247,7 @@ static void openrisc_any_initfn(Object *obj)
 
  static const struct SysemuCPUOps openrisc_sysemu_ops = {
      .has_work = openrisc_cpu_has_work,
-    .get_phys_addr_debug = openrisc_cpu_get_phys_addr_debug,
+    .translate_for_debug = openrisc_cpu_translate_for_debug,
  };
  #endif
 
target/or1k/mmu.c +2 -1
index 3fc56e1b771..a78e8c8ca2e 100644
@@ -139,7 +139,8 @@ bool openrisc_cpu_tlb_fill(CPUState *cs, vaddr addr, int size,
      cpu_loop_exit_restore(cs, retaddr);
  }
 
-hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool openrisc_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                      TranslateForDebugResult *result)
  {
      OpenRISCCPU *cpu = OPENRISC_CPU(cs);
      int prot, excp, sr = cpu->env.sr;

target/or1k/mmu.c hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr) · line 157

Quoted 6 lines
target/or1k/mmu.c +1 -1
@@ -152,12 +153,15 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                              PAGE_READ,
                              (sr & SR_SM) != 0);
          if (!excp) {
-            return phys_addr;
+            break;
          }

Faithful conversion, so:

Data lookup failed, we don't discriminate DTLB and directly check ITLB. We can have:

[EXCP_DPF] = "DFP (data protection fault)",
[EXCP_DTLBMISS] = "DTLBMISS (data tlb miss)",

EXCP_DPF could happen when accessing exec-only kernel .text; shouldn't we return to gdb here for "valid DTLB but read denied", and keep checking the ITLB for the EXCP_DTLBMISS case where no data mapping? As:

            if (excp == EXCP_DPF) { break; }
Quoted 34 lines
target/or1k/mmu.c +13 -3
          excp = get_phys_mmu(cpu, &phys_addr, &prot, addr,
                              PAGE_EXEC,
                              (sr & SR_SM) != 0);
-        return excp ? -1 : phys_addr;
+        if (excp) {
+            return false;
+        }
+        break;
 
      default:
          /* The mmu is partially enabled, and we don't really have
@@ -167,13 +171,20 @@ hwaddr openrisc_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
                              PAGE_EXEC | PAGE_READ | PAGE_WRITE,
                              (sr & SR_SM) != 0);
          if (!excp) {
-            return phys_addr;
+            break;
          }
          /* fallthru */
 
      case 0:
          /* The mmu is definitely disabled; lookups never fail.  */
          get_phys_nommu(&phys_addr, &prot, addr);
-        return phys_addr;
+        break;
      }
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
  }
#10 lore raw

PATCH 4/5 target/rx: Convert to translate_for_debug

In reply to Peter Maydell

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

---
 target/rx/cpu.h    |  3 ++-
 target/rx/cpu.c    |  2 +-
 target/rx/helper.c | 10 ++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)
target/rx/cpu.h +2 -1
index 64ba48a7329..8ec704a9f72 100644
@@ -136,7 +136,8 @@ struct RXCPUClass {
 const char *rx_crname(uint8_t cr);
 void rx_cpu_do_interrupt(CPUState *cpu);
 bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool rx_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                TranslateForDebugResult *result);
 void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/rx/cpu.c +1 -1
index 9b8473d71cf..0bcfec1d7c0 100644
@@ -209,7 +209,7 @@ static void rx_cpu_init(Object *obj)
 
 static const struct SysemuCPUOps rx_sysemu_ops = {
     .has_work = rx_cpu_has_work,
-    .get_phys_addr_debug = rx_cpu_get_phys_addr_debug,
+    .translate_for_debug = rx_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps rx_tcg_ops = {
target/rx/helper.c +8 -2
index 0f99279bbaa..1f73fed6efd 100644
@@ -147,7 +147,13 @@ bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     return false;
 }
 
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool rx_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                TranslateForDebugResult *result)
 {
-    return addr;
+    *result = (TranslateForDebugResult) {
+        .physaddr = addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 4/5
#11 lore raw

Re: [PATCH 4/5] target/rx: Convert to translate_for_debug

Quoted 9 lines · Peter Maydell

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

---
  target/rx/cpu.h    |  3 ++-
  target/rx/cpu.c    |  2 +-
  target/rx/helper.c | 10 ++++++++--
  3 files changed, 11 insertions(+), 4 deletions(-)

r~

Reviewed-by on v1 4/5
#12 lore raw

Re: [PATCH 4/5] target/rx: Convert to translate_for_debug

In reply to Peter Maydell
Quoted 9 lines · Peter Maydell

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

---
  target/rx/cpu.h    |  3 ++-
  target/rx/cpu.c    |  2 +-
  target/rx/helper.c | 10 ++++++++--
  3 files changed, 11 insertions(+), 4 deletions(-)

No MMU, easy :)

Reviewed-by on v1 4/5
#13 lore raw

Re: [PATCH 4/5] target/rx: Convert to translate_for_debug

In reply to Peter Maydell
Quoted 61 lines · Peter Maydell

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

---
 target/rx/cpu.h    |  3 ++-
 target/rx/cpu.c    |  2 +-
 target/rx/helper.c | 10 ++++++++--
 3 files changed, 11 insertions(+), 4 deletions(-)
target/rx/cpu.h +2 -1
index 64ba48a7329..8ec704a9f72 100644
@@ -136,7 +136,8 @@ struct RXCPUClass {
 const char *rx_crname(uint8_t cr);
 void rx_cpu_do_interrupt(CPUState *cpu);
 bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req);
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool rx_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                TranslateForDebugResult *result);
 void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg);
 int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
target/rx/cpu.c +1 -1
index 9b8473d71cf..0bcfec1d7c0 100644
@@ -209,7 +209,7 @@ static void rx_cpu_init(Object *obj)
 
 static const struct SysemuCPUOps rx_sysemu_ops = {
     .has_work = rx_cpu_has_work,
-    .get_phys_addr_debug = rx_cpu_get_phys_addr_debug,
+    .translate_for_debug = rx_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps rx_tcg_ops = {
target/rx/helper.c +8 -2
index 0f99279bbaa..1f73fed6efd 100644
@@ -147,7 +147,13 @@ bool rx_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
     return false;
 }
 
-hwaddr rx_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool rx_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                TranslateForDebugResult *result)
 {
-    return addr;
+    *result = (TranslateForDebugResult) {
+        .physaddr = addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
Signature · 1 line
2.43.0
Signature · 1 line
Yosinori Sato
#14 lore raw

PATCH 5/5 target/tricore: Convert to translate_for_debug

In reply to Peter Maydell

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

---
 target/tricore/cpu.h    |  3 ++-
 target/tricore/cpu.c    |  2 +-
 target/tricore/helper.c | 13 ++++++++++---
 3 files changed, 13 insertions(+), 5 deletions(-)
target/tricore/cpu.h +2 -1
index 12e497d2a7a..17e3d1fe804 100644
@@ -79,7 +79,8 @@ struct TriCoreCPUClass {
     ResettablePhases parent_phases;
 };
 
-hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cpu, vaddr addr);
+bool tricore_cpu_translate_for_debug(CPUState *cpu, vaddr addr,
+                                     TranslateForDebugResult *result);
 void tricore_cpu_dump_state(CPUState *cpu, FILE *f, int flags);
 
 FIELD(PCXI, PCPN_13, 24, 8)
target/tricore/cpu.c +1 -1
index 84a05e3d363..deca702cc6d 100644
@@ -207,7 +207,7 @@ static bool tricore_cpu_exec_interrupt(CPUState *cs, int interrupt_request)
 
 static const struct SysemuCPUOps tricore_sysemu_ops = {
     .has_work = tricore_cpu_has_work,
-    .get_phys_addr_debug = tricore_cpu_get_phys_addr_debug,
+    .translate_for_debug = tricore_cpu_translate_for_debug,
 };
 
 static const TCGCPUOps tricore_tcg_ops = {
target/tricore/helper.c +10 -3
index 273713a1473..9cc80b14c8c 100644
@@ -47,7 +47,8 @@ static int get_physical_address(CPUTriCoreState *env, hwaddr *physical,
     return ret;
 }
 
-hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool tricore_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                     TranslateForDebugResult *result)
 {
     TriCoreCPU *cpu = TRICORE_CPU(cs);
     hwaddr phys_addr;
@@ -56,9 +57,15 @@ hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
     if (get_physical_address(&cpu->env, &phys_addr, &prot, addr,
                              MMU_DATA_LOAD, mmu_idx)) {
-        return -1;
+        return false;
     }
-    return phys_addr;
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
 }
 
 /* TODO: Add exception support */
Signature · 1 line
2.43.0
Reviewed-by on v1 5/5
#15 lore raw

Re: [PATCH 5/5] target/tricore: Convert to translate_for_debug

Quoted 9 lines · Peter Maydell

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

---
  target/tricore/cpu.h    |  3 ++-
  target/tricore/cpu.c    |  2 +-
  target/tricore/helper.c | 13 ++++++++++---
  3 files changed, 13 insertions(+), 5 deletions(-)

r~

Reviewed-by on v1 5/5
#16 lore raw

Re: [PATCH 5/5] target/tricore: Convert to translate_for_debug

In reply to Peter Maydell
Quoted 26 lines · Peter Maydell

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

---
  target/tricore/cpu.h    |  3 ++-
  target/tricore/cpu.c    |  2 +-
  target/tricore/helper.c | 13 ++++++++++---
  3 files changed, 13 insertions(+), 5 deletions(-)
target/tricore/helper.c +2 -1
index 273713a1473..9cc80b14c8c 100644
@@ -47,7 +47,8 @@ static int get_physical_address(CPUTriCoreState *env, hwaddr *physical,
      return ret;
  }
 
-hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+bool tricore_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                     TranslateForDebugResult *result)
  {
      TriCoreCPU *cpu = TRICORE_CPU(cs);
      hwaddr phys_addr;

target/tricore/helper.c hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr) · line 60

Quoted 5 lines
target/tricore/helper.c +1 -1
@@ -56,9 +57,15 @@ hwaddr tricore_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
 
      if (get_physical_address(&cpu->env, &phys_addr, &prot, addr,
                               MMU_DATA_LOAD, mmu_idx)) {
-        return -1;
+        return false;

pre-existing, get_physical_address() always returns TLBRET_MATCH (0) so this part is dead code, but better keep the same pattern between targets.

Quoted 12 lines
target/tricore/helper.c +7 -1
      }
-    return phys_addr;
+
+    *result = (TranslateForDebugResult) {
+        .physaddr = phys_addr,
+        .lg_page_size = TARGET_PAGE_BITS,
+        .attrs.debug = 1,
+    };
+    return true;
  }
 
  /* TODO: Add exception support */
#17 lore raw
In reply to Peter Maydell
Quoted 6 lines · Peter Maydell

Peter Maydell (5):
target/alpha: Convert to translate_for_debug
target/avr: Convert to translate_for_debug
target/or1k: Convert to translate_for_debug
target/rx: Convert to translate_for_debug
target/tricore: Convert to translate_for_debug

Queued, thanks.