On 22/10/26 14:58, Peter Maydell wrote:
Convert hexagon to providing the translate_for_debug method rather
than the deprecated get_phys_addr_debug method.

Signed-off-by: Peter Maydell <[email protected]>
---
  target/hexagon/cpu.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c
index f20d6de6f63..5e99e84b075 100644
--- a/target/hexagon/cpu.c
+++ b/target/hexagon/cpu.c
@@ -612,7 +612,8 @@ static void find_qemu_subpage(vaddr *addr, hwaddr *phys, 
uint64_t page_size)
      *phys += offset;
  }
-static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState *cs, vaddr addr)
+static bool hexagon_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                            TranslateForDebugResult *result)
  {
      CPUHexagonState *env = cpu_env(cs);
      hwaddr phys_addr;
@@ -626,10 +627,16 @@ static hwaddr hexagon_cpu_get_phys_addr_debug(CPUState 
*cs, vaddr addr)
          vaddr page_offset = addr & (TARGET_PAGE_SIZE - 1);
          find_qemu_subpage(&addr, &phys_addr, page_size);
          phys_addr += hexagon_cpu_mmu_enabled(env) ? page_offset : 0;

Faithful conversion, so:
Reviewed-by: Philippe Mathieu-Daudé <[email protected]>

Hexagon MMU supports large TLB pages, and IIUC we clamp at
TARGET_PAGE_SIZE via find_qemu_subpage(). We already have
the page_size (as power of 2) so using it is cheap (and
simplifies the code):

      if (hexagon_cpu_mmu_enabled(env)) {
           phys_addr += addr & (page_size - 1);
     }

and return with .lg_page_size = ctz64(page_size).

I doubt this improve much the debug path, except being a more
correct implementation.

-        return phys_addr;
+
+        *result = (TranslateForDebugResult) {
+            .physaddr = phys_addr,
+            .lg_page_size = TARGET_PAGE_BITS,
+            .attrs.debug = 1,
+        };
+        return true;
      }
- return -1;
+    return false;
  }

Actually the same can be used in hexagon_tlb_fill(), the other
user of find_qemu_subpage() -- which could then be removed:

-- >8 --
@@ -774,8 +765,11 @@ static bool hexagon_tlb_fill(CPUState *cs, vaddr address, int size,
                                access_type, mmu_idx);
     if (ret) {
         if (!excp) {
-            find_qemu_subpage(&address, &phys, page_size);
- tlb_set_page(cs, address, phys, prot, mmu_idx, TARGET_PAGE_SIZE);
+            if (hexagon_cpu_mmu_enabled(env)) {
+                phys += address & (page_size - 1);
+            }
+            tlb_set_page(cs, address, phys, prot, mmu_idx, page_size);
             return ret;
         }
---

Brian, WDYT?

Reply via email to