]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S
ArmPkg/ArmMmuLib AARCH64: get rid of needless TLB invalidation
[mirror_edk2.git] / ArmPkg / Library / ArmMmuLib / AArch64 / ArmMmuLibReplaceEntry.S
1 #------------------------------------------------------------------------------
2 #
3 # Copyright (c) 2016, Linaro Limited. All rights reserved.
4 #
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13 #------------------------------------------------------------------------------
14
15 #include <AsmMacroIoLibV8.h>
16
17 .set CTRL_M_BIT, (1 << 0)
18
19 .macro __replace_entry, el
20
21 // disable the MMU
22 mrs x8, sctlr_el\el
23 bic x9, x8, #CTRL_M_BIT
24 msr sctlr_el\el, x9
25 isb
26
27 // write updated entry
28 str x1, [x0]
29
30 // invalidate again to get rid of stale clean cachelines that may
31 // have been filled speculatively since the last invalidate
32 dmb sy
33 dc ivac, x0
34
35 // flush translations for the target address from the TLBs
36 lsr x2, x2, #12
37 .if \el == 1
38 tlbi vaae1, x2
39 .else
40 tlbi vae\el, x2
41 .endif
42 dsb nsh
43
44 // re-enable the MMU
45 msr sctlr_el\el, x8
46 isb
47 .endm
48
49 //VOID
50 //ArmReplaceLiveTranslationEntry (
51 // IN UINT64 *Entry,
52 // IN UINT64 Value,
53 // IN UINT64 Address
54 // )
55 ASM_FUNC(ArmReplaceLiveTranslationEntry)
56
57 // disable interrupts
58 mrs x4, daif
59 msr daifset, #0xf
60 isb
61
62 // clean and invalidate first so that we don't clobber
63 // adjacent entries that are dirty in the caches
64 dc civac, x0
65 dsb nsh
66
67 EL1_OR_EL2_OR_EL3(x3)
68 1:__replace_entry 1
69 b 4f
70 2:__replace_entry 2
71 b 4f
72 3:__replace_entry 3
73
74 4:msr daif, x4
75 ret
76
77 ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize)
78
79 ASM_PFX(ArmReplaceLiveTranslationEntrySize):
80 .long . - ArmReplaceLiveTranslationEntry