blob: b54dfa9eef4ec14c18940f09223bb25c3d733073 [file] [log] [blame]
From 2bc188ad2caa6c3174e193f8a83e64b819fd2617 Mon Sep 17 00:00:00 2001
From: Xing Li <>
Date: Sat, 23 May 2020 15:56:29 +0800
Subject: [PATCH] KVM: MIPS: Fix VPN2_MASK definition for variable cpu_vmbits
commit 5816c76dea116a458f1932eefe064e35403248eb upstream.
If a CPU support more than 32bit vmbits (which is true for 64bit CPUs),
VPN2_MASK set to fixed 0xffffe000 will lead to a wrong EntryHi in some
functions such as _kvm_mips_host_tlb_inv().
The cpu_vmbits definition of 32bit CPU in cpu-features.h is 31, so we
still use the old definition.
Cc: Stable <>
Reviewed-by: Aleksandar Markovic <>
Signed-off-by: Xing Li <>
[Huacai: Improve commit messages]
Signed-off-by: Huacai Chen <>
Message-Id: <>
Signed-off-by: Paolo Bonzini <>
Signed-off-by: Paul Gortmaker <>
diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
index 579458444401..7b47a323dc23 100644
--- a/arch/mips/include/asm/kvm_host.h
+++ b/arch/mips/include/asm/kvm_host.h
@@ -274,7 +274,11 @@ enum emulation_result {
#define MIPS3_PG_SHIFT 6
#define MIPS3_PG_FRAME 0x3fffffc0
+#if defined(CONFIG_64BIT)
+#define VPN2_MASK GENMASK(cpu_vmbits - 1, 13)
#define VPN2_MASK 0xffffe000
#define KVM_ENTRYHI_ASID cpu_asid_mask(&boot_cpu_data)
#define TLB_IS_GLOBAL(x) ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G)
#define TLB_VPN2(x) ((x).tlb_hi & VPN2_MASK)