This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Enable and disable MMU page table caching in L2

Hello,

I am using a dual core Cortex A9 CPU and I want to enable MMU caching in L2.

By default all the DDR memory region is set as non-cacheable.

But then I want only the DDR regions allocated to the page table to be cacheable. For this purpose I do the following:

1) user the __mmu_tbl_start and __mmu_tbl_end variables from the linker script into my test C script:

extern u32 __mmu_tbl_start;
extern u32 __mmu_tbl_end;

2) Then I set the TTBR0 register so that L2 cache is enabled for MMU page table.

TTBReg = mfcp(XREG_CP15_TTBR0);
mtcp(XREG_CP15_TTBR0, (TTBReg | L2CachingMask));
dsb();
isb();

3) Afterwards I set the memory attributes of the DDR region allocated to the MMU page table (only 16 KB that is contained in a single 1MB section) as follows:


u32 mmu_tbl_start_addr = (u32)&__mmu_tbl_start;
u32 mmu_tbl_end_addr = (u32)&__mmu_tbl_end;
for(u32 pte_address=mmu_tbl_start_addr; pte_address<=mmu_tbl_end_addr;pte_address=pte_address+SECTION_SIZE) {
 Xil_SetTlbAttributes(pte_address, 0x25de2); }

The function Xil_SetTlbAttributes is unmodified from the one provided by Xilinx, and is given below:

void Xil_SetTlbAttributes(INTPTR Addr, u32 attrib)
{
	u32 *ptr;
	u32 section;

	section = Addr / 0x100000U;
	ptr = &MMUTable;
	ptr += section;
	if(ptr != NULL) {
		*ptr = (Addr & 0xFFF00000U) | attrib;
	}

	Xil_DCacheFlush();
	mtcp(XREG_CP15_INVAL_UTLB_UNLOCKED, 0U);
	mtcp(XREG_CP15_INVAL_BRANCH_ARRAY, 0U);

	dsb(); /* ensure completion of the BP and TLB invalidation */
    isb(); /* synchronize context on this processor */
}

4) I try to corrupt the MMU page table as follows:

a) load one PTE in L2 cache (reference to the associated)

b) disable parity check of L2 cache, and modifyto the Page Table Entry memory attributes.

c) Finally enable the L2 cache parity check again, and read the data associated to this PTE.

However as I disable the parity check the CPU raises an Undefined Exception. The exact trigger point is when I write the L2 cache control register to generate a synchronization operation.

An undefined exception is raised by a fetched instruction which can not be decoded by the CPU. 

Q1: I am not sure how to debug this any further... This does not seem as explicit as for Data and Prefetch Aborts...

Q2: Do I need to disable and enable again MMU so that cacheability behavior takes effect?

Thank you.

Florian

Parents Reply Children
No data