Skip to content

Commit 9511ee4

Browse files
chenhuacaiSomasundaram Krishnasamy
authored andcommitted
KVM: MIPS: Change the definition of kvm type
[ Upstream commit 15e9e35 ] MIPS defines two kvm types: #define KVM_VM_MIPS_TE 0 #define KVM_VM_MIPS_VZ 1 In Documentation/virt/kvm/api.rst it is said that "You probably want to use 0 as machine type", which implies that type 0 be the "automatic" or "default" type. And, in user-space libvirt use the null-machine (with type 0) to detect the kvm capability, which returns "KVM not supported" on a VZ platform. I try to fix it in QEMU but it is ugly: https://lists.nongnu.org/archive/html/qemu-devel/2020-08/msg05629.html And Thomas Huth suggests me to change the definition of kvm type: https://lists.nongnu.org/archive/html/qemu-devel/2020-09/msg03281.html So I define like this: #define KVM_VM_MIPS_AUTO 0 #define KVM_VM_MIPS_VZ 1 #define KVM_VM_MIPS_TE 2 Since VZ and TE cannot co-exists, using type 0 on a TE platform will still return success (so old user-space tools have no problems on new kernels); the advantage is that using type 0 on a VZ platform will not return failure. So, the only problem is "new user-space tools use type 2 on old kernels", but if we treat this as a kernel bug, we can backport this patch to old stable kernels. Signed-off-by: Huacai Chen <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 09d69bfda62ee278b4dccd4c2e756acf6325c717)
1 parent e32475c commit 9511ee4

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

arch/mips/kvm/mips.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ void kvm_arch_check_processor_compat(void *rtn)
131131
int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
132132
{
133133
switch (type) {
134+
case KVM_VM_MIPS_AUTO:
135+
break;
134136
#ifdef CONFIG_KVM_MIPS_VZ
135137
case KVM_VM_MIPS_VZ:
136138
#else

include/uapi/linux/kvm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,10 @@ struct kvm_ppc_resize_hpt {
763763
#define KVM_VM_PPC_HV 1
764764
#define KVM_VM_PPC_PR 2
765765

766-
/* on MIPS, 0 forces trap & emulate, 1 forces VZ ASE */
767-
#define KVM_VM_MIPS_TE 0
766+
/* on MIPS, 0 indicates auto, 1 forces VZ ASE, 2 forces trap & emulate */
767+
#define KVM_VM_MIPS_AUTO 0
768768
#define KVM_VM_MIPS_VZ 1
769+
#define KVM_VM_MIPS_TE 2
769770

770771
#define KVM_S390_SIE_PAGE_OFFSET 1
771772

0 commit comments

Comments
 (0)