@@ -326,6 +326,8 @@
#define CSR_GTLBC_TGID_WIDTH 8
#define CSR_GTLBC_TGID_SHIFT_END (CSR_GTLBC_TGID_SHIFT + CSR_GTLBC_TGID_WIDTH - 1)
#define CSR_GTLBC_TGID (_ULCAST_(0xff) << CSR_GTLBC_TGID_SHIFT)
+#define CSR_GTLBC_USEVMID_SHIFT 14
+#define CSR_GTLBC_USEVMID (_ULCAST_(0x1) << CSR_GTLBC_USEVMID_SHIFT)
#define CSR_GTLBC_TOTI_SHIFT 13
#define CSR_GTLBC_TOTI (_ULCAST_(0x1) << CSR_GTLBC_TOTI_SHIFT)
#define CSR_GTLBC_USETGID_SHIFT 12
@@ -336,7 +336,7 @@ int kvm_arch_enable_virtualization_cpu(void)
write_csr_gcfg(0);
write_csr_gstat(0);
write_csr_gintc(0);
- clear_csr_gtlbc(CSR_GTLBC_USETGID | CSR_GTLBC_TOTI);
+ clear_csr_gtlbc(CSR_GTLBC_USETGID | CSR_GTLBC_TOTI | CSR_GTLBC_USEVMID);
/*
* Enable virtualization features granting guest direct control of
@@ -359,6 +359,8 @@ int kvm_arch_enable_virtualization_cpu(void)
/* Enable using TGID */
set_csr_gtlbc(CSR_GTLBC_USETGID);
+ if (cpu_has_guestid)
+ set_csr_gtlbc(CSR_GTLBC_USEVMID);
kvm_debug("GCFG:%lx GSTAT:%lx GINTC:%lx GTLBC:%lx",
read_csr_gcfg(), read_csr_gstat(), read_csr_gintc(), read_csr_gtlbc());
With CSR GTLBC shortname for Guest TLB Control Register, separate vmid feature will be enabled if bit 14 CSR_GTLBC_USEVMID is set. Enable this feature if cpu_has_guestid is true when KVM module is loaded. Signed-off-by: Bibo Mao <maobibo@loongson.cn> --- arch/loongarch/include/asm/loongarch.h | 2 ++ arch/loongarch/kvm/main.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-)