2019-06-04 16:11:33 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2015-04-04 23:58:38 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Russell King
|
|
|
|
*
|
|
|
|
* This assembly is required to safely remap the physical address space
|
|
|
|
* for Keystone 2
|
|
|
|
*/
|
|
|
|
#include <linux/linkage.h>
|
2020-06-09 12:32:42 +08:00
|
|
|
#include <linux/pgtable.h>
|
2015-04-04 23:58:38 +08:00
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/cp15.h>
|
|
|
|
#include <asm/memory.h>
|
|
|
|
|
|
|
|
.section ".idmap.text", "ax"
|
|
|
|
|
|
|
|
#define L1_ORDER 3
|
|
|
|
#define L2_ORDER 3
|
|
|
|
|
|
|
|
ENTRY(lpae_pgtables_remap_asm)
|
|
|
|
stmfd sp!, {r4-r8, lr}
|
|
|
|
|
|
|
|
mrc p15, 0, r8, c1, c0, 0 @ read control reg
|
|
|
|
bic ip, r8, #CR_M @ disable caches and MMU
|
|
|
|
mcr p15, 0, ip, c1, c0, 0
|
|
|
|
dsb
|
|
|
|
isb
|
|
|
|
|
|
|
|
/* Update level 2 entries covering the kernel */
|
|
|
|
ldr r6, =(_end - 1)
|
|
|
|
add r7, r2, #0x1000
|
|
|
|
add r6, r7, r6, lsr #SECTION_SHIFT - L2_ORDER
|
|
|
|
add r7, r7, #PAGE_OFFSET >> (SECTION_SHIFT - L2_ORDER)
|
2018-11-09 11:26:39 +08:00
|
|
|
1: ldrd r4, r5, [r7]
|
2015-04-04 23:58:38 +08:00
|
|
|
adds r4, r4, r0
|
|
|
|
adc r5, r5, r1
|
2018-11-09 11:26:39 +08:00
|
|
|
strd r4, r5, [r7], #1 << L2_ORDER
|
2015-04-04 23:58:38 +08:00
|
|
|
cmp r7, r6
|
|
|
|
bls 1b
|
|
|
|
|
|
|
|
/* Update level 2 entries for the boot data */
|
|
|
|
add r7, r2, #0x1000
|
ARM: 9012/1: move device tree mapping out of linear region
On ARM, setting up the linear region is tricky, given the constraints
around placement and alignment of the memblocks, and how the kernel
itself as well as the DT are placed in physical memory.
Let's simplify matters a bit, by moving the device tree mapping to the
top of the address space, right between the end of the vmalloc region
and the start of the the fixmap region, and create a read-only mapping
for it that is independent of the size of the linear region, and how it
is organized.
Since this region was formerly used as a guard region, which will now be
populated fully on LPAE builds by this read-only mapping (which will
still be able to function as a guard region for stray writes), bump the
start of the [underutilized] fixmap region by 512 KB as well, to ensure
that there is always a proper guard region here. Doing so still leaves
ample room for the fixmap space, even with NR_CPUS set to its maximum
value of 32.
Tested-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
2020-10-11 17:21:37 +08:00
|
|
|
movw r3, #FDT_FIXED_BASE >> (SECTION_SHIFT - L2_ORDER)
|
|
|
|
add r7, r7, r3
|
2018-11-09 11:26:39 +08:00
|
|
|
ldrd r4, r5, [r7]
|
2015-04-04 23:58:38 +08:00
|
|
|
adds r4, r4, r0
|
|
|
|
adc r5, r5, r1
|
2018-11-09 11:26:39 +08:00
|
|
|
strd r4, r5, [r7], #1 << L2_ORDER
|
|
|
|
ldrd r4, r5, [r7]
|
2015-04-04 23:58:38 +08:00
|
|
|
adds r4, r4, r0
|
|
|
|
adc r5, r5, r1
|
2018-11-09 11:26:39 +08:00
|
|
|
strd r4, r5, [r7]
|
2015-04-04 23:58:38 +08:00
|
|
|
|
|
|
|
/* Update level 1 entries */
|
|
|
|
mov r6, #4
|
|
|
|
mov r7, r2
|
2018-11-09 11:26:39 +08:00
|
|
|
2: ldrd r4, r5, [r7]
|
2015-04-04 23:58:38 +08:00
|
|
|
adds r4, r4, r0
|
|
|
|
adc r5, r5, r1
|
2018-11-09 11:26:39 +08:00
|
|
|
strd r4, r5, [r7], #1 << L1_ORDER
|
2015-04-04 23:58:38 +08:00
|
|
|
subs r6, r6, #1
|
|
|
|
bne 2b
|
|
|
|
|
|
|
|
mrrc p15, 0, r4, r5, c2 @ read TTBR0
|
|
|
|
adds r4, r4, r0 @ update physical address
|
|
|
|
adc r5, r5, r1
|
|
|
|
mcrr p15, 0, r4, r5, c2 @ write back TTBR0
|
|
|
|
mrrc p15, 1, r4, r5, c2 @ read TTBR1
|
|
|
|
adds r4, r4, r0 @ update physical address
|
|
|
|
adc r5, r5, r1
|
|
|
|
mcrr p15, 1, r4, r5, c2 @ write back TTBR1
|
|
|
|
|
|
|
|
dsb
|
|
|
|
|
|
|
|
mov ip, #0
|
|
|
|
mcr p15, 0, ip, c7, c5, 0 @ I+BTB cache invalidate
|
|
|
|
mcr p15, 0, ip, c8, c7, 0 @ local_flush_tlb_all()
|
|
|
|
dsb
|
|
|
|
isb
|
|
|
|
|
|
|
|
mcr p15, 0, r8, c1, c0, 0 @ re-enable MMU
|
|
|
|
dsb
|
|
|
|
isb
|
|
|
|
|
|
|
|
ldmfd sp!, {r4-r8, pc}
|
|
|
|
ENDPROC(lpae_pgtables_remap_asm)
|