@@ -3259,6 +3259,7 @@ static void tlbi_aa64_vae1is_write(CPUARMState *env, const ARMCPRegInfo *ri,
32593259 ARMMMUIdxBit_S1SE1 |
32603260 ARMMMUIdxBit_S1SE0 );
32613261 } else {
3262+ fprintf (stderr , "Vae1is_write: pc=0x%" PRIx64 "\n" , env -> pc );
32623263 tlb_flush_page_by_mmuidx_all_cpus_synced (cs , pageaddr ,
32633264 ARMMMUIdxBit_S12NSE1 |
32643265 ARMMMUIdxBit_S12NSE0 );
@@ -9245,7 +9246,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address,
92459246 }
92469247 tbi *= 8 ;
92479248
9248- /* If we are in 64-bit EL2 or EL3 then there is no TTBR1 , so mark it
9249+ /* If we are in 64-bit EL2 or EL3 then there is no 1 , so mark it
92499250 * invalid.
92509251 */
92519252 if (el > 1 ) {
@@ -10316,7 +10317,7 @@ static ARMCacheAttrs combine_cacheattrs(ARMCacheAttrs s1, ARMCacheAttrs s2)
1031610317 * @fi: set to fault info if the translation fails
1031710318 * @cacheattrs: (if non-NULL) set to the cacheability/shareability attributes
1031810319 */
10319- static bool get_phys_addr (CPUARMState * env , target_ulong address ,
10320+ static bool get_phys_addr_real (CPUARMState * env , target_ulong address ,
1032010321 MMUAccessType access_type , ARMMMUIdx mmu_idx ,
1032110322 hwaddr * phys_ptr , MemTxAttrs * attrs , int * prot ,
1032210323 target_ulong * page_size ,
@@ -10437,6 +10438,25 @@ static bool get_phys_addr(CPUARMState *env, target_ulong address,
1043710438 }
1043810439}
1043910440
10441+ static bool chatty = true;
10442+
10443+ static bool get_phys_addr (CPUARMState * env , target_ulong address ,
10444+ MMUAccessType access_type , ARMMMUIdx mmu_idx ,
10445+ hwaddr * phys_ptr , MemTxAttrs * attrs , int * prot ,
10446+ target_ulong * page_size ,
10447+ ARMMMUFaultInfo * fi , ARMCacheAttrs * cacheattrs )
10448+ {
10449+ if (chatty ) {
10450+ fprintf (stderr , "Get phys addr: 0x%" PRIx64 " %x %x\n" , address , access_type , mmu_idx );
10451+ }
10452+ bool retval = get_phys_addr_real (env , address , access_type , mmu_idx , phys_ptr ,
10453+ attrs , prot , page_size , fi , cacheattrs );
10454+ if (chatty ) {
10455+ fprintf (stderr , "Retval: %s phys 0x%" PRIx64 " prot %x type %x\n" , retval ? "true" : "false" , * phys_ptr , * prot , fi -> type );
10456+ }
10457+ return retval ;
10458+ }
10459+
1044010460/* Walk the page table and (if the mapping exists) add the page
1044110461 * to the TLB. Return false on success, or true on failure. Populate
1044210462 * fsr with ARM DFSR/IFSR fault register format value on failure.
@@ -12430,3 +12450,79 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc,
1243012450 * pflags = flags ;
1243112451 * cs_base = 0 ;
1243212452}
12453+
12454+ #ifndef CONFIG_USER_ONLY
12455+
12456+ static void dump_mmu_lpae (FILE * f , fprintf_function cpu_fprintf , CPUARMState * env , ARMMMUIdx mmu_idx ) {
12457+ //uint64_t ttbr = regime_ttbr(env, mmu_idx, 1);
12458+ //hwaddr descaddr = extract64(ttbr, 0, 48);
12459+ // https://developer.arm.com/products/architecture/a-profile/docs/100940/latest/translation-tables-in-armv8-a
12460+ //cpu_physical_memory_read()
12461+ }
12462+
12463+ hwaddr arm_cpu_get_phys_page_attrs_memdump (CPUState * cs , vaddr addr ,
12464+ MemTxAttrs * attrs , int * protOut , ARMCacheAttrs * cacheAttrsOut )
12465+ {
12466+ ARMCPU * cpu = ARM_CPU (cs );
12467+ CPUARMState * env = & cpu -> env ;
12468+ hwaddr phys_addr ;
12469+ target_ulong page_size ;
12470+ int prot ;
12471+ bool ret ;
12472+ ARMMMUFaultInfo fi = {};
12473+ ARMMMUIdx mmu_idx = core_to_arm_mmu_idx (env , cpu_mmu_index (env , false));
12474+
12475+ * attrs = (MemTxAttrs ) {};
12476+
12477+ ret = get_phys_addr (env , addr , 0 , mmu_idx , & phys_addr ,
12478+ attrs , & prot , & page_size , & fi , cacheAttrsOut );
12479+
12480+ if (ret ) {
12481+ return -1 ;
12482+ }
12483+ * protOut = prot ;
12484+ return phys_addr ;
12485+ }
12486+
12487+ void dump_mmu (FILE * f , fprintf_function cpu_fprintf , CPUARMState * env ) {
12488+ /*ARMMMUIdx mmu_idx = core_to_arm_mmu_idx(env, cpu_mmu_index(env, false));
12489+ if (regime_translation_disabled(env, mmu_idx)) {
12490+ cpu_fprintf(f, "MMU disabled\n");
12491+ return;
12492+ }
12493+ if (!regime_using_lpae_format(env, mmu_idx)) {
12494+ cpu_fprintf(f, "MMU not in LPAE mode; printing mappings not implemented");
12495+ return;
12496+ }
12497+ dump_mmu_lpae(f, cpu_fprintf, env, mmu_idx);*/
12498+ chatty = false;
12499+ cpu_fprintf (f , "what\n" );
12500+ uint64_t lastPhysAddr = 0x1 ;
12501+ uint64_t lastVirtAddr = 0x0 ;
12502+ int lastProt = 0 ;
12503+ uint64_t addr ;
12504+ CPUState * cs = ENV_GET_CPU (env );
12505+ ARMCacheAttrs lastCacheAttrs = {};
12506+ for (addr = 0xffffffe000000000ull ; addr < 0xffffffff00000000ull ; addr += 0x10000 ) {
12507+ MemTxAttrs attrs = {};
12508+ int prot = lastProt ;
12509+ ARMCacheAttrs cacheAttrs = lastCacheAttrs ;
12510+ hwaddr phys_addr = arm_cpu_get_phys_page_attrs_memdump (cs , addr , & attrs , & prot , & cacheAttrs );
12511+ if (phys_addr != lastPhysAddr + 0x10000 || prot != lastProt || cacheAttrs .attrs != lastCacheAttrs .attrs || cacheAttrs .shareability != lastCacheAttrs .shareability ) {
12512+ if (lastPhysAddr != ~0 ) {
12513+ cpu_fprintf (f , "0x%" PRIx64 "-0x%" PRIx64 ": 0x%" PRIx64 " %x %x %x\n" ,
12514+ lastVirtAddr , addr , lastPhysAddr , lastProt , lastCacheAttrs .attrs , lastCacheAttrs .shareability );
12515+ }
12516+ lastVirtAddr = addr ;
12517+ lastPhysAddr = phys_addr ;
12518+ lastProt = prot ;
12519+ lastCacheAttrs = cacheAttrs ;
12520+ }
12521+ }
12522+ if (lastPhysAddr != ~0 ) {
12523+ cpu_fprintf (f , "0x%" PRIx64 "-0x%" PRIx64 ": 0x%" PRIx64 " %x %x %x\n" ,
12524+ lastVirtAddr , addr , lastPhysAddr , lastProt , lastCacheAttrs .attrs , lastCacheAttrs .shareability );
12525+ }
12526+ chatty = true;
12527+ }
12528+ #endif
0 commit comments