Skip to content

Commit 7b7293a

Browse files
glevandwildea01
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>
1 parent 6a1f547 commit 7b7293a

File tree

4 files changed

+81
-104
lines changed

4 files changed

+81
-104
lines changed

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

@@ -199,6 +201,84 @@ lr .req x30 // link register
199201
add \reg, \reg, \tmp
200202
.endm
201203

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