]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
ArmPkg/ArmMmuLib AARCH64: preserve attributes when replacing a table entry
[mirror_edk2.git] / ArmPkg / Library / ArmMmuLib / AArch64 / ArmMmuLibReplaceEntry.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2016, Linaro Limited. All rights reserved.
4 #
5 # SPDX-License-Identifier: BSD-2-Clause-Patent
6 #
7 #------------------------------------------------------------------------------
8
9 #include <AsmMacroIoLibV8.h>
10
11 .set CTRL_M_BIT, (1 << 0)
12
13 .macro __replace_entry, el
14
15 // disable the MMU
16 mrs x8, sctlr_el\el
17 bic x9, x8, #CTRL_M_BIT
18 msr sctlr_el\el, x9
19 isb
20
21 // write updated entry
22 str x1, [x0]
23
24 // invalidate again to get rid of stale clean cachelines that may
25 // have been filled speculatively since the last invalidate
26 dmb sy
27 dc ivac, x0
28
29 // flush translations for the target address from the TLBs
30 lsr x2, x2, #12
31 .if \el == 1
32 tlbi vaae1, x2
33 .else
34 tlbi vae\el, x2
35 .endif
36 dsb nsh
37
38 // re-enable the MMU
39 msr sctlr_el\el, x8
40 isb
41 .endm
42
43 //VOID
44 //ArmReplaceLiveTranslationEntry (
45 // IN UINT64 *Entry,
46 // IN UINT64 Value,
47 // IN UINT64 Address
48 // )
49 ASM_FUNC(ArmReplaceLiveTranslationEntry)
50
51 // disable interrupts
52 mrs x4, daif
53 msr daifset, #0xf
54 isb
55
56 // clean and invalidate first so that we don't clobber
57 // adjacent entries that are dirty in the caches
58 dc civac, x0
59 dsb nsh
60
61 EL1_OR_EL2_OR_EL3(x3)
62 1:__replace_entry 1
63 b 4f
64 2:__replace_entry 2
65 b 4f
66 3:__replace_entry 3
67
68 4:msr daif, x4
69 ret
70
71 ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
72
73 ASM_PFX(ArmReplaceLiveTranslationEntrySize):
74 .long . - ArmReplaceLiveTranslationEntry