Skip to content

Commit a7ba39d

Browse files
glevandAlex Shi
authored andcommitted
arm64: Fold proc-macros.S into assembler.h
To allow the assembler macros defined in arch/arm64/mm/proc-macros.S to be used outside the mm code move the contents of proc-macros.S to asm/assembler.h. Also, delete proc-macros.S, and fix up all references to proc-macros.S. Signed-off-by: Geoff Levand <geoff@infradead.org> Acked-by: Pavel Machek <pavel@ucw.cz> [rebased, included dcache_by_line_op] Signed-off-by: James Morse <james.morse@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> (cherry picked from commit 7b7293ae3dbd0a1965bf310b77fed5f9bb37bb93) Signed-off-by: Alex Shi <alex.shi@linaro.org> Conflicts: remove obsolete arch/arm64/mm/proc-macros.S
1 parent 9502888 commit a7ba39d

4 files changed

Lines changed: 81 additions & 103 deletions

File tree

arch/arm64/include/asm/assembler.h

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Based on arch/arm/include/asm/assembler.h
2+
* Based on arch/arm/include/asm/assembler.h, arch/arm/mm/proc-macros.S
33
*
44
* Copyright (C) 1996-2000 Russell King
55
* Copyright (C) 2012 ARM Ltd.
@@ -23,6 +23,8 @@
2323
#ifndef __ASM_ASSEMBLER_H
2424
#define __ASM_ASSEMBLER_H
2525

26+
#include <asm/asm-offsets.h>
27+
#include <asm/pgtable-hwdef.h>
2628
#include <asm/ptrace.h>
2729
#include <asm/thread_info.h>
2830

@@ -193,6 +195,84 @@ lr .req x30 // link register
193195
str \src, [\tmp, :lo12:\sym]
194196
.endm
195197

198+
/*
199+
* vma_vm_mm - get mm pointer from vma pointer (vma->vm_mm)
200+
*/
201+
.macro vma_vm_mm, rd, rn
202+
ldr \rd, [\rn, #VMA_VM_MM]
203+
.endm
204+
205+
/*
206+
* mmid - get context id from mm pointer (mm->context.id)
207+
*/
208+
.macro mmid, rd, rn
209+
ldr \rd, [\rn, #MM_CONTEXT_ID]
210+
.endm
211+
212+
/*
213+
* dcache_line_size - get the minimum D-cache line size from the CTR register.
214+
*/
215+
.macro dcache_line_size, reg, tmp
216+
mrs \tmp, ctr_el0 // read CTR
217+
ubfm \tmp, \tmp, #16, #19 // cache line size encoding
218+
mov \reg, #4 // bytes per word
219+
lsl \reg, \reg, \tmp // actual cache line size
220+
.endm
221+
222+
/*
223+
* icache_line_size - get the minimum I-cache line size from the CTR register.
224+
*/
225+
.macro icache_line_size, reg, tmp
226+
mrs \tmp, ctr_el0 // read CTR
227+
and \tmp, \tmp, #0xf // cache line size encoding
228+
mov \reg, #4 // bytes per word
229+
lsl \reg, \reg, \tmp // actual cache line size
230+
.endm
231+
232+
/*
233+
* tcr_set_idmap_t0sz - update TCR.T0SZ so that we can load the ID map
234+
*/
235+
.macro tcr_set_idmap_t0sz, valreg, tmpreg
236+
#ifndef CONFIG_ARM64_VA_BITS_48
237+
ldr_l \tmpreg, idmap_t0sz
238+
bfi \valreg, \tmpreg, #TCR_T0SZ_OFFSET, #TCR_TxSZ_WIDTH
239+
#endif
240+
.endm
241+
242+
/*
243+
* Macro to perform a data cache maintenance for the interval
244+
* [kaddr, kaddr + size)
245+
*
246+
* op: operation passed to dc instruction
247+
* domain: domain used in dsb instruciton
248+
* kaddr: starting virtual address of the region
249+
* size: size of the region
250+
* Corrupts: kaddr, size, tmp1, tmp2
251+
*/
252+
.macro dcache_by_line_op op, domain, kaddr, size, tmp1, tmp2
253+
dcache_line_size \tmp1, \tmp2
254+
add \size, \kaddr, \size
255+
sub \tmp2, \tmp1, #1
256+
bic \kaddr, \kaddr, \tmp2
257+
9998: dc \op, \kaddr
258+
add \kaddr, \kaddr, \tmp1
259+
cmp \kaddr, \size
260+
b.lo 9998b
261+
dsb \domain
262+
.endm
263+
264+
/*
265+
* reset_pmuserenr_el0 - reset PMUSERENR_EL0 if PMUv3 present
266+
*/
267+
.macro reset_pmuserenr_el0, tmpreg
268+
mrs \tmpreg, id_aa64dfr0_el1 // Check ID_AA64DFR0_EL1 PMUVer
269+
sbfx \tmpreg, \tmpreg, #8, #4
270+
cmp \tmpreg, #1 // Skip if no PMU present
271+
b.lt 9000f
272+
msr pmuserenr_el0, xzr // Disable PMU access from EL0
273+
9000:
274+
.endm
275+
196276
/*
197277
* Annotate a function as position independent, i.e., safe to be called before
198278
* the kernel virtual mapping is activated.

arch/arm64/mm/cache.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
#include <asm/cpufeature.h>
2525
#include <asm/alternative.h>
2626

27-
#include "proc-macros.S"
28-
2927
/*
3028
* flush_icache_range(start,end)
3129
*

arch/arm64/mm/proc-macros.S

Lines changed: 0 additions & 97 deletions
This file was deleted.

arch/arm64/mm/proc.S

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,10 @@
2323
#include <asm/assembler.h>
2424
#include <asm/asm-offsets.h>
2525
#include <asm/hwcap.h>
26-
#include <asm/pgtable-hwdef.h>
2726
#include <asm/pgtable.h>
2827
#include <asm/cpufeature.h>
2928
#include <asm/alternative.h>
3029

31-
#include "proc-macros.S"
32-
3330
#ifdef CONFIG_ARM64_64K_PAGES
3431
#define TCR_TG_FLAGS TCR_TG0_64K | TCR_TG1_64K
3532
#elif defined(CONFIG_ARM64_16K_PAGES)

0 commit comments

Comments
 (0)