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