--- a/include/hw/core/cpu.h
+++ b/include/hw/core/cpu.h
@@ -269,6 +269,8 @@ struct CPUTLBEntryFull {
             bool guarded;
         } arm;
     } extra;
+
+    AddressSpace *as;
 };
...
-MemoryRegionSection *iotlb_to_section(CPUState *cpu,
+
+MemoryRegionSection *iotlb_to_section(AddressSpace *as,
                                       hwaddr index, MemTxAttrs attrs)
 {
-    int asidx = cpu_asidx_from_attrs(cpu, attrs);
-    CPUAddressSpace *cpuas = &cpu->cpu_ases[asidx];
-    AddressSpaceDispatch *d = address_space_to_dispatch(cpuas->as);
+    assert(as);
+    AddressSpaceDispatch *d = address_space_to_dispatch(as);
     int section_index = index & ~TARGET_PAGE_MASK;

Adding the as to CPUTLBEntryFull is unnecessary because

(1) Each CPUTLB, and thus each CPUTLBEntryFull, is private to the cpu.
(2) Each CPUTLBEntryFull contains the MemTxAttrs for the access.

Thus the AddressSpace is purely a function of (cpu, attrs).

We can have a conversation about where this lookup happens, and whether or not particular functions should be passed a CPUState, but adding AddressSpace to full tlb is redundant.


r~

Reply via email to