2 * Copyright (C) 2015 Russell King
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * This assembly is required to safely remap the physical address space
11 #include <linux/linkage.h>
12 #include <asm/asm-offsets.h>
14 #include <asm/memory.h>
15 #include <asm/pgtable.h>
17 .section ".idmap.text", "ax"
22 ENTRY(lpae_pgtables_remap_asm)
23 stmfd sp!, {r4-r8, lr}
25 mrc p15, 0, r8, c1, c0, 0 @ read control reg
26 bic ip, r8, #CR_M @ disable caches and MMU
27 mcr p15, 0, ip, c1, c0, 0
31 /* Update level 2 entries covering the kernel */
34 add r6, r7, r6, lsr #SECTION_SHIFT - L2_ORDER
35 add r7, r7, #PAGE_OFFSET >> (SECTION_SHIFT - L2_ORDER)
39 strd r4, [r7], #1 << L2_ORDER
43 /* Update level 2 entries for the boot data */
45 add r7, r7, r3, lsr #SECTION_SHIFT - L2_ORDER
46 bic r7, r7, #(1 << L2_ORDER) - 1
50 strd r4, [r7], #1 << L2_ORDER
56 /* Update level 1 entries */
62 strd r4, [r7], #1 << L1_ORDER
66 mrrc p15, 0, r4, r5, c2 @ read TTBR0
67 adds r4, r4, r0 @ update physical address
69 mcrr p15, 0, r4, r5, c2 @ write back TTBR0
70 mrrc p15, 1, r4, r5, c2 @ read TTBR1
71 adds r4, r4, r0 @ update physical address
73 mcrr p15, 1, r4, r5, c2 @ write back TTBR1
78 mcr p15, 0, ip, c7, c5, 0 @ I+BTB cache invalidate
79 mcr p15, 0, ip, c8, c7, 0 @ local_flush_tlb_all()
83 mcr p15, 0, r8, c1, c0, 0 @ re-enable MMU
87 ldmfd sp!, {r4-r8, pc}
88 ENDPROC(lpae_pgtables_remap_asm)