Skip to content

Commit d7f4ed4

Browse files
zhaotianrui-loongsonchenhuacai
authored andcommitted
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 <[email protected]> Tested-by: Huacai Chen <[email protected]> Signed-off-by: Tianrui Zhao <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent a5857b9 commit d7f4ed4

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

arch/loongarch/kvm/tlb.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Copyright (C) 2020-2023 Loongson Technology Corporation Limited
4+
*/
5+
6+
#include <linux/kvm_host.h>
7+
#include <asm/tlb.h>
8+
#include <asm/kvm_csr.h>
9+
10+
/*
11+
* kvm_flush_tlb_all() - Flush all root TLB entries for guests.
12+
*
13+
* Invalidate all entries including GVA-->GPA and GPA-->HPA mappings.
14+
*/
15+
void kvm_flush_tlb_all(void)
16+
{
17+
unsigned long flags;
18+
19+
local_irq_save(flags);
20+
invtlb_all(INVTLB_ALLGID, 0, 0);
21+
local_irq_restore(flags);
22+
}
23+
24+
void kvm_flush_tlb_gpa(struct kvm_vcpu *vcpu, unsigned long gpa)
25+
{
26+
unsigned long flags;
27+
28+
local_irq_save(flags);
29+
gpa &= (PAGE_MASK << 1);
30+
invtlb(INVTLB_GID_ADDR, read_csr_gstat() & CSR_GSTAT_GID, gpa);
31+
local_irq_restore(flags);
32+
}

0 commit comments

Comments
 (0)