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 the TLBs 36 .if \el == 1 37 tlbi vmalle1 38 .else 39 tlbi alle\el 40 .endif 41 dsb sy 42 43 // re-enable the MMU 44 msr sctlr_el\el, x8 45 isb 46 .endm 47 48//VOID 49//ArmReplaceLiveTranslationEntry ( 50// IN UINT64 *Entry, 51// IN UINT64 Value 52// ) 53ASM_FUNC(ArmReplaceLiveTranslationEntry) 54 55 // disable interrupts 56 mrs x2, daif 57 msr daifset, #0xf 58 isb 59 60 // clean and invalidate first so that we don't clobber 61 // adjacent entries that are dirty in the caches 62 dc civac, x0 63 dsb ish 64 65 EL1_OR_EL2_OR_EL3(x3) 661:__replace_entry 1 67 b 4f 682:__replace_entry 2 69 b 4f 703:__replace_entry 3 71 724:msr daif, x2 73 ret 74 75ASM_GLOBAL ASM_PFX(ArmReplaceLiveTranslationEntrySize) 76 77ASM_PFX(ArmReplaceLiveTranslationEntrySize): 78 .long . - ArmReplaceLiveTranslationEntry 79