Skip to content

Commit e3ec658

Browse files
samitolvanenwilldeacon
authored andcommitted
arm64: mm: avoid x18 in idmap_kpti_install_ng_mappings
idmap_kpti_install_ng_mappings uses x18 as a temporary register, which will result in a conflict when x18 is reserved. Use x16 and x17 instead where needed. Signed-off-by: Sami Tolvanen <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Mark Rutland <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent c54f90c commit e3ec658

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

arch/arm64/mm/proc.S

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -250,15 +250,15 @@ ENTRY(idmap_kpti_install_ng_mappings)
250250
/* We're the boot CPU. Wait for the others to catch up */
251251
sevl
252252
1: wfe
253-
ldaxr w18, [flag_ptr]
254-
eor w18, w18, num_cpus
255-
cbnz w18, 1b
253+
ldaxr w17, [flag_ptr]
254+
eor w17, w17, num_cpus
255+
cbnz w17, 1b
256256

257257
/* We need to walk swapper, so turn off the MMU. */
258258
pre_disable_mmu_workaround
259-
mrs x18, sctlr_el1
260-
bic x18, x18, #SCTLR_ELx_M
261-
msr sctlr_el1, x18
259+
mrs x17, sctlr_el1
260+
bic x17, x17, #SCTLR_ELx_M
261+
msr sctlr_el1, x17
262262
isb
263263

264264
/* Everybody is enjoying the idmap, so we can rewrite swapper. */
@@ -281,9 +281,9 @@ skip_pgd:
281281
isb
282282

283283
/* We're done: fire up the MMU again */
284-
mrs x18, sctlr_el1
285-
orr x18, x18, #SCTLR_ELx_M
286-
msr sctlr_el1, x18
284+
mrs x17, sctlr_el1
285+
orr x17, x17, #SCTLR_ELx_M
286+
msr sctlr_el1, x17
287287
isb
288288

289289
/*
@@ -353,46 +353,47 @@ skip_pte:
353353
b.ne do_pte
354354
b next_pmd
355355

356+
.unreq cpu
357+
.unreq num_cpus
358+
.unreq swapper_pa
359+
.unreq cur_pgdp
360+
.unreq end_pgdp
361+
.unreq pgd
362+
.unreq cur_pudp
363+
.unreq end_pudp
364+
.unreq pud
365+
.unreq cur_pmdp
366+
.unreq end_pmdp
367+
.unreq pmd
368+
.unreq cur_ptep
369+
.unreq end_ptep
370+
.unreq pte
371+
356372
/* Secondary CPUs end up here */
357373
__idmap_kpti_secondary:
358374
/* Uninstall swapper before surgery begins */
359-
__idmap_cpu_set_reserved_ttbr1 x18, x17
375+
__idmap_cpu_set_reserved_ttbr1 x16, x17
360376

361377
/* Increment the flag to let the boot CPU we're ready */
362-
1: ldxr w18, [flag_ptr]
363-
add w18, w18, #1
364-
stxr w17, w18, [flag_ptr]
378+
1: ldxr w16, [flag_ptr]
379+
add w16, w16, #1
380+
stxr w17, w16, [flag_ptr]
365381
cbnz w17, 1b
366382

367383
/* Wait for the boot CPU to finish messing around with swapper */
368384
sevl
369385
1: wfe
370-
ldxr w18, [flag_ptr]
371-
cbnz w18, 1b
386+
ldxr w16, [flag_ptr]
387+
cbnz w16, 1b
372388

373389
/* All done, act like nothing happened */
374-
offset_ttbr1 swapper_ttb, x18
390+
offset_ttbr1 swapper_ttb, x16
375391
msr ttbr1_el1, swapper_ttb
376392
isb
377393
ret
378394

379-
.unreq cpu
380-
.unreq num_cpus
381-
.unreq swapper_pa
382395
.unreq swapper_ttb
383396
.unreq flag_ptr
384-
.unreq cur_pgdp
385-
.unreq end_pgdp
386-
.unreq pgd
387-
.unreq cur_pudp
388-
.unreq end_pudp
389-
.unreq pud
390-
.unreq cur_pmdp
391-
.unreq end_pmdp
392-
.unreq pmd
393-
.unreq cur_ptep
394-
.unreq end_ptep
395-
.unreq pte
396397
ENDPROC(idmap_kpti_install_ng_mappings)
397398
.popsection
398399
#endif

0 commit comments

Comments
 (0)