isb
.endm
+/*
+ * Enforce Xen page-tables do not contain mapping that are both
+ * Writable and eXecutables.
+ *
+ * This should be called on each secondary CPU.
+ */
+.macro pt_enforce_wxn tmp
+ mrc CP32(\tmp, HSCTLR)
+ orr \tmp, \tmp, #SCTLR_Axx_ELx_WXN
+ dsb
+ mcr CP32(\tmp, HSCTLR)
+ /*
+ * The TLBs may cache SCTLR_EL2.WXN. So ensure it is synchronized
+ * before flushing the TLBs.
+ */
+ isb
+ flush_xen_tlb_local \tmp
+.endm
+
/*
* Common register usage in this file:
* r0 -
dsb
isb
flush_xen_tlb_local r0
+ pt_enforce_wxn r0
#ifdef CONFIG_EARLY_PRINTK
/* Use a virtual address to access the UART. */
*
* Inputs:
* x0 : Physical address of the page tables.
+ * x1 : Extra flags of the SCTLR.
*
- * Clobbers x0 - x4
+ * Clobbers x0 - x5
*/
enable_mmu:
mov x4, x0
+ mov x5, x1
PRINT("- Turning on paging -\r\n")
/*
mrs x0, SCTLR_EL2
orr x0, x0, #SCTLR_Axx_ELx_M /* Enable MMU */
orr x0, x0, #SCTLR_Axx_ELx_C /* Enable D-cache */
+ orr x0, x0, x5 /* Enable extra flags */
dsb sy /* Flush PTE writes and finish reads */
msr SCTLR_EL2, x0 /* now paging is enabled */
isb /* Now, flush the icache */
* Inputs:
* lr : Virtual address to return to.
*
- * Clobbers x0 - x5
+ * Clobbers x0 - x6
*/
ENTRY(enable_secondary_cpu_mm)
- mov x5, lr
+ mov x6, lr
load_paddr x0, init_ttbr
ldr x0, [x0]
+ mov x1, #SCTLR_Axx_ELx_WXN /* Enable WxN from the start */
bl enable_mmu
- mov lr, x5
+ mov lr, x6
/* Return to the virtual address requested by the caller. */
ret
* Inputs:
* lr : Virtual address to return to.
*
- * Clobbers x0 - x5
+ * Clobbers x0 - x6
*/
ENTRY(enable_boot_cpu_mm)
- mov x5, lr
+ mov x6, lr
bl create_page_tables
load_paddr x0, boot_pgtable
+ mov x1, #0 /* No extra SCTLR flags */
bl enable_mmu
/*
ldr x0, =1f
br x0
1:
- mov lr, x5
+ mov lr, x6
/*
* The 1:1 map may clash with other parts of the Xen virtual memory
* layout. As it is not used anymore, remove it completely to
/* Allocate and initialise pagetables for a secondary CPU. Sets init_ttbr to the
* new page table */
extern int init_secondary_pagetables(int cpu);
-/* Switch secondary CPUS to its own pagetables and finalise MMU setup */
-extern void mmu_init_secondary_cpu(void);
/*
* For Arm32, set up the direct-mapped xenheap: up to 1GB of contiguous,
* always-mapped memory. Base must be 32MB aligned and size a multiple of 32MB.