2019-06-03 13:44:50 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2016-01-02 23:09:54 +08:00
|
|
|
/*
|
|
|
|
* Original code:
|
|
|
|
* Copyright (C) 2012 - Virtual Open Systems and Columbia University
|
|
|
|
* Author: Christoffer Dall <c.dall@virtualopensystems.com>
|
|
|
|
*
|
|
|
|
* Mostly rewritten in C by Marc Zyngier <marc.zyngier@arm.com>
|
|
|
|
*/
|
|
|
|
|
2016-01-28 22:31:37 +08:00
|
|
|
#include <asm/kvm_hyp.h>
|
2017-10-24 00:11:14 +08:00
|
|
|
#include <asm/kvm_mmu.h>
|
2016-01-02 23:09:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush per-VMID TLBs
|
|
|
|
*
|
|
|
|
* __kvm_tlb_flush_vmid(struct kvm *kvm);
|
|
|
|
*
|
|
|
|
* We rely on the hardware to broadcast the TLB invalidation to all CPUs
|
|
|
|
* inside the inner-shareable domain (which is the case for all v7
|
|
|
|
* implementations). If we come across a non-IS SMP implementation, we'll
|
|
|
|
* have to use an IPI based mechanism. Until then, we stick to the simple
|
|
|
|
* hardware assisted version.
|
|
|
|
*
|
|
|
|
* As v7 does not support flushing per IPA, just nuke the whole TLB
|
|
|
|
* instead, ignoring the ipa value.
|
|
|
|
*/
|
2016-09-01 19:16:03 +08:00
|
|
|
void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm)
|
2016-01-02 23:09:54 +08:00
|
|
|
{
|
|
|
|
dsb(ishst);
|
|
|
|
|
|
|
|
/* Switch to requested VMID */
|
|
|
|
kvm = kern_hyp_va(kvm);
|
2018-12-11 22:26:31 +08:00
|
|
|
write_sysreg(kvm_get_vttbr(kvm), VTTBR);
|
2016-01-02 23:09:54 +08:00
|
|
|
isb();
|
|
|
|
|
|
|
|
write_sysreg(0, TLBIALLIS);
|
|
|
|
dsb(ish);
|
|
|
|
isb();
|
|
|
|
|
|
|
|
write_sysreg(0, VTTBR);
|
|
|
|
}
|
|
|
|
|
2016-09-01 19:16:03 +08:00
|
|
|
void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa)
|
2016-01-02 23:09:54 +08:00
|
|
|
{
|
2016-09-01 19:16:03 +08:00
|
|
|
__kvm_tlb_flush_vmid(kvm);
|
2016-01-02 23:09:54 +08:00
|
|
|
}
|
|
|
|
|
2024-06-11 20:26:44 +08:00
|
|
|
void __hyp_text __kvm_flush_cpu_context(struct kvm_vcpu *vcpu)
|
2016-10-19 01:37:49 +08:00
|
|
|
{
|
|
|
|
struct kvm *kvm = kern_hyp_va(kern_hyp_va(vcpu)->kvm);
|
|
|
|
|
|
|
|
/* Switch to requested VMID */
|
2018-12-11 22:26:31 +08:00
|
|
|
write_sysreg(kvm_get_vttbr(kvm), VTTBR);
|
2016-10-19 01:37:49 +08:00
|
|
|
isb();
|
|
|
|
|
|
|
|
write_sysreg(0, TLBIALL);
|
2024-06-11 20:26:44 +08:00
|
|
|
write_sysreg(0, ICIALLU);
|
2016-10-19 01:37:49 +08:00
|
|
|
dsb(nsh);
|
|
|
|
isb();
|
|
|
|
|
|
|
|
write_sysreg(0, VTTBR);
|
|
|
|
}
|
|
|
|
|
2016-09-01 19:16:03 +08:00
|
|
|
void __hyp_text __kvm_flush_vm_context(void)
|
2016-01-02 23:09:54 +08:00
|
|
|
{
|
|
|
|
write_sysreg(0, TLBIALLNSNHIS);
|
|
|
|
write_sysreg(0, ICIALLUIS);
|
|
|
|
dsb(ish);
|
|
|
|
}
|