On 5/15/26 05:57, Peter Maydell wrote:
-hwaddr mb_cpu_get_phys_addr_attrs_debug(CPUState *cs, vaddr addr,
-                                        MemTxAttrs *attrs)
+bool mb_cpu_translate_for_debug(CPUState *cs, vaddr addr,
+                                TranslateForDebugResult *result)
  {
      MicroBlazeCPU *cpu = MICROBLAZE_CPU(cs);
-    hwaddr paddr = 0;
      MicroBlazeMMULookup lu;
      int mmu_idx = cpu_mmu_index(cs, false);
      unsigned int hit;
- /* Caller doesn't initialize */
-    *attrs = (MemTxAttrs) {};
-    attrs->secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD);
+    result->attrs = (MemTxAttrs) {
+        .secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD),
+        .debug = 1,
+    };
+
+    result->lg_page_size = TARGET_PAGE_SIZE;

TARGET_PAGE_BITS.

if (mmu_idx != MMU_NOMMU_IDX) {
          hit = mmu_translate(cpu, &lu, addr, 0, 0);
          if (hit) {
-            paddr = lu.paddr + addr - lu.vaddr;
-        } else
-            paddr = 0; /* ???.  */
+            result->physaddr = lu.paddr + addr - lu.vaddr;
+        } else {
+            result->physaddr = 0; /* ???.  */
+        }

Surely this is the "return false" case.
Fixing an existing bug, obviously.

      } else {
-        paddr = addr;
+        result->physaddr = addr;
      }
- return paddr;
+    return true;

Perhaps cleaner to finish with

    *result = (TranslateForDebugResult){
        .physaddr = paddr,
        .lg_page_size = TARGET_PAGE_SIZE,
        .attrs.secure = mb_cpu_access_is_secure(cpu, MMU_DATA_LOAD),
        .attrs.debug = true,
    };
    return true;

?


r~

Reply via email to