Skip to content

Commit 95e3de3

Browse files
Marc Zyngierctmarinas
authored andcommitted
arm64: Move post_ttbr_update_workaround to C code
We will soon need to invoke a CPU-specific function pointer after changing page tables, so move post_ttbr_update_workaround out into C code to make this possible. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Will Deacon <will.deacon@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent d68e3ba commit 95e3de3

4 files changed

Lines changed: 11 additions & 16 deletions

File tree

‎arch/arm64/include/asm/assembler.h‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -492,19 +492,6 @@ alternative_endif
492492
mrs \rd, sp_el0
493493
.endm
494494

495-
/*
496-
* Errata workaround post TTBRx_EL1 update.
497-
*/
498-
.macro post_ttbr_update_workaround
499-
#ifdef CONFIG_CAVIUM_ERRATUM_27456
500-
alternative_if ARM64_WORKAROUND_CAVIUM_27456
501-
ic iallu
502-
dsb nsh
503-
isb
504-
alternative_else_nop_endif
505-
#endif
506-
.endm
507-
508495
/*
509496
* Arrange a physical address in a TTBR register, taking care of 52-bit
510497
* addresses.

‎arch/arm64/kernel/entry.S‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ alternative_else_nop_endif
277277
* Cavium erratum 27456 (broadcast TLBI instructions may cause I-cache
278278
* corruption).
279279
*/
280-
post_ttbr_update_workaround
280+
bl post_ttbr_update_workaround
281281
.endif
282282
1:
283283
.if \el != 0

‎arch/arm64/mm/context.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,15 @@ void check_and_switch_context(struct mm_struct *mm, unsigned int cpu)
242242
cpu_switch_mm(mm->pgd, mm);
243243
}
244244

245+
/* Errata workaround post TTBRx_EL1 update. */
246+
asmlinkage void post_ttbr_update_workaround(void)
247+
{
248+
asm(ALTERNATIVE("nop; nop; nop",
249+
"ic iallu; dsb nsh; isb",
250+
ARM64_WORKAROUND_CAVIUM_27456,
251+
CONFIG_CAVIUM_ERRATUM_27456));
252+
}
253+
245254
static int asids_init(void)
246255
{
247256
asid_bits = get_cpu_asid_bits();

‎arch/arm64/mm/proc.S‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ ENTRY(cpu_do_switch_mm)
146146
phys_to_ttbr x0, x2
147147
msr ttbr0_el1, x2 // now update TTBR0
148148
isb
149-
post_ttbr_update_workaround
150-
ret
149+
b post_ttbr_update_workaround // Back to C code...
151150
ENDPROC(cpu_do_switch_mm)
152151

153152
.pushsection ".idmap.text", "ax"

0 commit comments

Comments
 (0)