2 * Copyright (C) 2015 - ARM Ltd
3 * Author: Marc Zyngier <marc.zyngier@arm.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 static void __hyp_text __tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
24 /* Switch to requested VMID */
25 kvm = kern_hyp_va(kvm);
26 write_sysreg(kvm->arch.vttbr, vttbr_el2);
30 * We could do so much better if we had the VA as well.
31 * Instead, we invalidate Stage-2 for this IPA, and the
32 * whole of Stage-1. Weep...
35 asm volatile("tlbi ipas2e1is, %0" : : "r" (ipa));
38 * We have to ensure completion of the invalidation at Stage-2,
39 * since a table walk on another CPU could refill a TLB with a
40 * complete (S1 + S2) walk based on the old Stage-2 mapping if
41 * the Stage-1 invalidation happened first.
44 asm volatile("tlbi vmalle1is" : : );
48 write_sysreg(0, vttbr_el2);
51 __alias(__tlb_flush_vmid_ipa) void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm,
54 static void __hyp_text __tlb_flush_vmid(struct kvm *kvm)
58 /* Switch to requested VMID */
59 kvm = kern_hyp_va(kvm);
60 write_sysreg(kvm->arch.vttbr, vttbr_el2);
63 asm volatile("tlbi vmalls12e1is" : : );
67 write_sysreg(0, vttbr_el2);
70 __alias(__tlb_flush_vmid) void __kvm_tlb_flush_vmid(struct kvm *kvm);
72 static void __hyp_text __tlb_flush_vm_context(void)
75 asm volatile("tlbi alle1is \n"
80 __alias(__tlb_flush_vm_context) void __kvm_flush_vm_context(void);