mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-10 04:29:11 -04:00
LoongArch: KVM: Implement virtual machine tlb operations
Implement LoongArch virtual machine tlb operations such as flush tlb by specific gpa parameter and flush all of the virtual machine's tlbs. Reviewed-by: Bibo Mao <maobibo@loongson.cn> Tested-by: Huacai Chen <chenhuacai@loongson.cn> Signed-off-by: Tianrui Zhao <zhaotianrui@loongson.cn> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
committed by
Huacai Chen
parent
a5857b9ff6
commit
d7f4ed4b22
32
arch/loongarch/kvm/tlb.c
Normal file
32
arch/loongarch/kvm/tlb.c
Normal file
@@ -0,0 +1,32 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Loongson Technology Corporation Limited
|
||||
*/
|
||||
|
||||
#include <linux/kvm_host.h>
|
||||
#include <asm/tlb.h>
|
||||
#include <asm/kvm_csr.h>
|
||||
|
||||
/*
|
||||
* kvm_flush_tlb_all() - Flush all root TLB entries for guests.
|
||||
*
|
||||
* Invalidate all entries including GVA-->GPA and GPA-->HPA mappings.
|
||||
*/
|
||||
void kvm_flush_tlb_all(void)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
invtlb_all(INVTLB_ALLGID, 0, 0);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
|
||||
void kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
local_irq_save(flags);
|
||||
gpa &= (PAGE_MASK << 1);
|
||||
invtlb(INVTLB_GID_ADDR, read_csr_gstat() & CSR_GSTAT_GID, gpa);
|
||||
local_irq_restore(flags);
|
||||
}
|
||||
Reference in New Issue
Block a user