2019-06-04 01:11:33 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-11-22 10:30:28 -07:00
|
|
|
/*
|
|
|
|
* arch/arm/mm/proc-v7-2level.S
|
|
|
|
*
|
|
|
|
* Copyright (C) 2001 Deep Blue Solutions Ltd.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define TTB_S (1 << 1)
|
|
|
|
#define TTB_RGN_NC (0 << 3)
|
|
|
|
#define TTB_RGN_OC_WBWA (1 << 3)
|
|
|
|
#define TTB_RGN_OC_WT (2 << 3)
|
|
|
|
#define TTB_RGN_OC_WB (3 << 3)
|
|
|
|
#define TTB_NOS (1 << 5)
|
|
|
|
#define TTB_IRGN_NC ((0 << 0) | (0 << 6))
|
|
|
|
#define TTB_IRGN_WBWA ((0 << 0) | (1 << 6))
|
|
|
|
#define TTB_IRGN_WT ((1 << 0) | (0 << 6))
|
|
|
|
#define TTB_IRGN_WB ((1 << 0) | (1 << 6))
|
|
|
|
|
|
|
|
/* PTWs cacheable, inner WB not shareable, outer WB not shareable */
|
|
|
|
#define TTB_FLAGS_UP TTB_IRGN_WB|TTB_RGN_OC_WB
|
|
|
|
#define PMD_FLAGS_UP PMD_SECT_WB
|
|
|
|
|
|
|
|
/* PTWs cacheable, inner WBWA shareable, outer WBWA not shareable */
|
|
|
|
#define TTB_FLAGS_SMP TTB_IRGN_WBWA|TTB_S|TTB_NOS|TTB_RGN_OC_WBWA
|
|
|
|
#define PMD_FLAGS_SMP PMD_SECT_WBWA|PMD_SECT_S
|
|
|
|
|
ARM: 9263/1: use .arch directives instead of assembler command line flags
Similar to commit a6c30873ee4a ("ARM: 8989/1: use .fpu assembler
directives instead of assembler arguments").
GCC and GNU binutils support setting the "sub arch" via -march=,
-Wa,-march, target function attribute, and .arch assembler directive.
Clang was missing support for -Wa,-march=, but this was implemented in
clang-13.
The behavior of both GCC and Clang is to
prefer -Wa,-march= over -march= for assembler and assembler-with-cpp
sources, but Clang will warn about the -march= being unused.
clang: warning: argument unused during compilation: '-march=armv6k'
[-Wunused-command-line-argument]
Since most assembler is non-conditionally assembled with one sub arch
(modulo arch/arm/delay-loop.S which conditionally is assembled as armv4
based on CONFIG_ARCH_RPC, and arch/arm/mach-at91/pm-suspend.S which is
conditionally assembled as armv7-a based on CONFIG_CPU_V7), prefer the
.arch assembler directive.
Add a few more instances found in compile testing as found by Arnd and
Nathan.
Link: https://github.com/llvm/llvm-project/commit/1d51c699b9e2ebc5bcfdbe85c74cc871426333d4
Link: https://bugs.llvm.org/show_bug.cgi?id=48894
Link: https://github.com/ClangBuiltLinux/linux/issues/1195
Link: https://github.com/ClangBuiltLinux/linux/issues/1315
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Tested-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2022-10-24 12:44:41 -07:00
|
|
|
.arch armv7-a
|
|
|
|
|
2011-11-22 10:30:28 -07:00
|
|
|
/*
|
|
|
|
* cpu_v7_switch_mm(pgd_phys, tsk)
|
|
|
|
*
|
|
|
|
* Set the translation table base pointer to be pgd_phys
|
|
|
|
*
|
|
|
|
* - pgd_phys - physical address of new TTB
|
|
|
|
*
|
|
|
|
* It is assumed that:
|
|
|
|
* - we are not using split page tables
|
2015-05-04 07:22:41 -07:00
|
|
|
*
|
|
|
|
* Note that we always need to flush BTAC/BTB if IBE is set
|
|
|
|
* even on Cortex-A8 revisions not affected by 430973.
|
|
|
|
* If IBE is not set, the flush BTAC/BTB won't do anything.
|
2011-11-22 10:30:28 -07:00
|
|
|
*/
|
2024-04-23 00:45:47 -07:00
|
|
|
SYM_TYPED_FUNC_START(cpu_v7_switch_mm)
|
2015-04-07 07:35:24 -07:00
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
mmid r1, r1 @ get mm->context.id
|
|
|
|
ALT_SMP(orr r0, r0, #TTB_FLAGS_SMP)
|
|
|
|
ALT_UP(orr r0, r0, #TTB_FLAGS_UP)
|
2012-07-06 07:43:03 -07:00
|
|
|
#ifdef CONFIG_PID_IN_CONTEXTIDR
|
|
|
|
mrc p15, 0, r2, c13, c0, 1 @ read current context ID
|
|
|
|
lsr r2, r2, #8 @ extract the PID
|
|
|
|
bfi r1, r2, #8, #24 @ insert into new context ID
|
|
|
|
#endif
|
2011-11-22 10:30:28 -07:00
|
|
|
#ifdef CONFIG_ARM_ERRATA_754322
|
|
|
|
dsb
|
|
|
|
#endif
|
|
|
|
mcr p15, 0, r1, c13, c0, 1 @ set context ID
|
|
|
|
isb
|
2011-05-31 07:38:43 -07:00
|
|
|
mcr p15, 0, r0, c2, c0, 0 @ set TTB 0
|
|
|
|
isb
|
2011-11-22 10:30:28 -07:00
|
|
|
#endif
|
2014-06-30 08:29:12 -07:00
|
|
|
bx lr
|
2024-04-23 00:45:47 -07:00
|
|
|
SYM_FUNC_END(cpu_v7_switch_mm)
|
2011-11-22 10:30:28 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* cpu_v7_set_pte_ext(ptep, pte)
|
|
|
|
*
|
|
|
|
* Set a level 2 translation table entry.
|
|
|
|
*
|
|
|
|
* - ptep - pointer to level 2 translation table entry
|
|
|
|
* (hardware version is stored at +2048 bytes)
|
|
|
|
* - pte - PTE value to store
|
|
|
|
* - ext - value for extended PTE bits
|
|
|
|
*/
|
2024-04-23 00:45:47 -07:00
|
|
|
SYM_TYPED_FUNC_START(cpu_v7_set_pte_ext)
|
2011-11-22 10:30:28 -07:00
|
|
|
#ifdef CONFIG_MMU
|
|
|
|
str r1, [r0] @ linux version
|
|
|
|
|
|
|
|
bic r3, r1, #0x000003f0
|
|
|
|
bic r3, r3, #PTE_TYPE_MASK
|
|
|
|
orr r3, r3, r2
|
|
|
|
orr r3, r3, #PTE_EXT_AP0 | 2
|
|
|
|
|
|
|
|
tst r1, #1 << 4
|
|
|
|
orrne r3, r3, #PTE_EXT_TEX(1)
|
|
|
|
|
|
|
|
eor r1, r1, #L_PTE_DIRTY
|
|
|
|
tst r1, #L_PTE_RDONLY | L_PTE_DIRTY
|
|
|
|
orrne r3, r3, #PTE_EXT_APX
|
|
|
|
|
|
|
|
tst r1, #L_PTE_USER
|
|
|
|
orrne r3, r3, #PTE_EXT_AP1
|
|
|
|
|
|
|
|
tst r1, #L_PTE_XN
|
|
|
|
orrne r3, r3, #PTE_EXT_XN
|
|
|
|
|
|
|
|
tst r1, #L_PTE_YOUNG
|
2012-07-19 03:51:05 -07:00
|
|
|
tstne r1, #L_PTE_VALID
|
2012-08-31 21:22:12 -07:00
|
|
|
eorne r1, r1, #L_PTE_NONE
|
|
|
|
tstne r1, #L_PTE_NONE
|
2011-11-22 10:30:28 -07:00
|
|
|
moveq r3, #0
|
|
|
|
|
|
|
|
ARM( str r3, [r0, #2048]! )
|
|
|
|
THUMB( add r0, r0, #2048 )
|
|
|
|
THUMB( str r3, [r0] )
|
2013-07-15 06:26:19 -07:00
|
|
|
ALT_SMP(W(nop))
|
2013-04-03 09:16:57 -07:00
|
|
|
ALT_UP (mcr p15, 0, r0, c7, c10, 1) @ flush_pte
|
2011-11-22 10:30:28 -07:00
|
|
|
#endif
|
2014-06-30 08:29:12 -07:00
|
|
|
bx lr
|
2024-04-23 00:45:47 -07:00
|
|
|
SYM_FUNC_END(cpu_v7_set_pte_ext)
|
2011-11-22 10:30:28 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Memory region attributes with SCTLR.TRE=1
|
|
|
|
*
|
|
|
|
* n = TEX[0],C,B
|
|
|
|
* TR = PRRR[2n+1:2n] - memory type
|
|
|
|
* IR = NMRR[2n+1:2n] - inner cacheable property
|
|
|
|
* OR = NMRR[2n+17:2n+16] - outer cacheable property
|
|
|
|
*
|
|
|
|
* n TR IR OR
|
|
|
|
* UNCACHED 000 00
|
|
|
|
* BUFFERABLE 001 10 00 00
|
|
|
|
* WRITETHROUGH 010 10 10 10
|
|
|
|
* WRITEBACK 011 10 11 11
|
|
|
|
* reserved 110
|
|
|
|
* WRITEALLOC 111 10 01 01
|
|
|
|
* DEV_SHARED 100 01
|
|
|
|
* DEV_NONSHARED 100 01
|
|
|
|
* DEV_WC 001 10
|
|
|
|
* DEV_CACHED 011 10
|
|
|
|
*
|
|
|
|
* Other attributes:
|
|
|
|
*
|
|
|
|
* DS0 = PRRR[16] = 0 - device shareable property
|
|
|
|
* DS1 = PRRR[17] = 1 - device shareable property
|
|
|
|
* NS0 = PRRR[18] = 0 - normal shareable property
|
|
|
|
* NS1 = PRRR[19] = 1 - normal shareable property
|
|
|
|
* NOS = PRRR[24+n] = 1 - not outer shareable
|
|
|
|
*/
|
|
|
|
.equ PRRR, 0xff0a81a8
|
|
|
|
.equ NMRR, 0x40e040e0
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro for setting up the TTBRx and TTBCR registers.
|
|
|
|
* - \ttb0 and \ttb1 updated with the corresponding flags.
|
|
|
|
*/
|
2015-04-04 12:09:46 -07:00
|
|
|
.macro v7_ttb_setup, zero, ttbr0l, ttbr0h, ttbr1, tmp
|
2011-11-22 10:30:28 -07:00
|
|
|
mcr p15, 0, \zero, c2, c0, 2 @ TTB control register
|
2015-04-04 12:09:46 -07:00
|
|
|
ALT_SMP(orr \ttbr0l, \ttbr0l, #TTB_FLAGS_SMP)
|
|
|
|
ALT_UP(orr \ttbr0l, \ttbr0l, #TTB_FLAGS_UP)
|
2011-11-22 10:30:28 -07:00
|
|
|
ALT_SMP(orr \ttbr1, \ttbr1, #TTB_FLAGS_SMP)
|
|
|
|
ALT_UP(orr \ttbr1, \ttbr1, #TTB_FLAGS_UP)
|
|
|
|
mcr p15, 0, \ttbr1, c2, c0, 1 @ load TTB1
|
|
|
|
.endm
|
|
|
|
|
|
|
|
/* AT
|
|
|
|
* TFR EV X F I D LR S
|
|
|
|
* .EEE ..EE PUI. .T.T 4RVI ZWRS BLDP WCAM
|
|
|
|
* rxxx rrxx xxx0 0101 xxxx xxxx x111 xxxx < forced
|
2012-08-30 16:57:03 -07:00
|
|
|
* 01 0 110 0011 1100 .111 1101 < we want
|
2011-11-22 10:30:28 -07:00
|
|
|
*/
|
|
|
|
.align 2
|
|
|
|
.type v7_crval, #object
|
|
|
|
v7_crval:
|
2012-08-30 16:57:03 -07:00
|
|
|
crval clear=0x2120c302, mmuset=0x10c03c7d, ucset=0x00c01c7c
|