]> git.dujemihanovic.xyz Git - linux.git/commitdiff
RISC-V: KVM: Fix incorrect KVM_MAX_VCPUS value
authorAnup Patel <anup.patel@wdc.com>
Wed, 17 Nov 2021 05:00:29 +0000 (10:30 +0530)
committerAnup Patel <anup@brainfault.org>
Mon, 22 Nov 2021 05:06:19 +0000 (10:36 +0530)
The KVM_MAX_VCPUS value is supposed to be aligned with number of
VMID bits in the hgatp CSR but the current KVM_MAX_VCPUS value
is aligned with number of ASID bits in the satp CSR.

Fixes: 99cdc6c18c2d ("RISC-V: Add initial skeletal KVM support")
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
arch/riscv/include/asm/kvm_host.h

index 25ba21f98504120d8a723c13655d5bd583d35b4f..2639b9ee48f97d0b69c72177d55eb2dd1e9be1d2 100644 (file)
 #include <linux/types.h>
 #include <linux/kvm.h>
 #include <linux/kvm_types.h>
+#include <asm/csr.h>
 #include <asm/kvm_vcpu_fp.h>
 #include <asm/kvm_vcpu_timer.h>
 
-#ifdef CONFIG_64BIT
-#define KVM_MAX_VCPUS                  (1U << 16)
-#else
-#define KVM_MAX_VCPUS                  (1U << 9)
-#endif
+#define KVM_MAX_VCPUS                  \
+       ((HGATP_VMID_MASK >> HGATP_VMID_SHIFT) + 1)
 
 #define KVM_HALT_POLL_NS_DEFAULT       500000