]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/kvm-s390-do-not-report-unusabled-ids-via-kvm_cap_max_vcpu_id.patch
fixes for 4.19
[thirdparty/kernel/stable-queue.git] / queue-4.19 / kvm-s390-do-not-report-unusabled-ids-via-kvm_cap_max_vcpu_id.patch
1 From a86cb413f4bf273a9d341a3ab2c2ca44e12eb317 Mon Sep 17 00:00:00 2001
2 From: Thomas Huth <thuth@redhat.com>
3 Date: Thu, 23 May 2019 18:43:08 +0200
4 Subject: KVM: s390: Do not report unusabled IDs via KVM_CAP_MAX_VCPU_ID
5
6 From: Thomas Huth <thuth@redhat.com>
7
8 commit a86cb413f4bf273a9d341a3ab2c2ca44e12eb317 upstream.
9
10 KVM_CAP_MAX_VCPU_ID is currently always reporting KVM_MAX_VCPU_ID on all
11 architectures. However, on s390x, the amount of usable CPUs is determined
12 during runtime - it is depending on the features of the machine the code
13 is running on. Since we are using the vcpu_id as an index into the SCA
14 structures that are defined by the hardware (see e.g. the sca_add_vcpu()
15 function), it is not only the amount of CPUs that is limited by the hard-
16 ware, but also the range of IDs that we can use.
17 Thus KVM_CAP_MAX_VCPU_ID must be determined during runtime on s390x, too.
18 So the handling of KVM_CAP_MAX_VCPU_ID has to be moved from the common
19 code into the architecture specific code, and on s390x we have to return
20 the same value here as for KVM_CAP_MAX_VCPUS.
21 This problem has been discovered with the kvm_create_max_vcpus selftest.
22 With this change applied, the selftest now passes on s390x, too.
23
24 Reviewed-by: Andrew Jones <drjones@redhat.com>
25 Reviewed-by: Cornelia Huck <cohuck@redhat.com>
26 Reviewed-by: David Hildenbrand <david@redhat.com>
27 Signed-off-by: Thomas Huth <thuth@redhat.com>
28 Message-Id: <20190523164309.13345-9-thuth@redhat.com>
29 Cc: stable@vger.kernel.org
30 Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
31 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32
33
34 ---
35 arch/mips/kvm/mips.c | 3 +++
36 arch/powerpc/kvm/powerpc.c | 3 +++
37 arch/s390/kvm/kvm-s390.c | 1 +
38 arch/x86/kvm/x86.c | 3 +++
39 virt/kvm/arm/arm.c | 3 +++
40 virt/kvm/kvm_main.c | 2 --
41 6 files changed, 13 insertions(+), 2 deletions(-)
42
43 --- a/arch/mips/kvm/mips.c
44 +++ b/arch/mips/kvm/mips.c
45 @@ -1099,6 +1099,9 @@ int kvm_vm_ioctl_check_extension(struct
46 case KVM_CAP_MAX_VCPUS:
47 r = KVM_MAX_VCPUS;
48 break;
49 + case KVM_CAP_MAX_VCPU_ID:
50 + r = KVM_MAX_VCPU_ID;
51 + break;
52 case KVM_CAP_MIPS_FPU:
53 /* We don't handle systems with inconsistent cpu_has_fpu */
54 r = !!raw_cpu_has_fpu;
55 --- a/arch/powerpc/kvm/powerpc.c
56 +++ b/arch/powerpc/kvm/powerpc.c
57 @@ -632,6 +632,9 @@ int kvm_vm_ioctl_check_extension(struct
58 case KVM_CAP_MAX_VCPUS:
59 r = KVM_MAX_VCPUS;
60 break;
61 + case KVM_CAP_MAX_VCPU_ID:
62 + r = KVM_MAX_VCPU_ID;
63 + break;
64 #ifdef CONFIG_PPC_BOOK3S_64
65 case KVM_CAP_PPC_GET_SMMU_INFO:
66 r = 1;
67 --- a/arch/s390/kvm/kvm-s390.c
68 +++ b/arch/s390/kvm/kvm-s390.c
69 @@ -489,6 +489,7 @@ int kvm_vm_ioctl_check_extension(struct
70 break;
71 case KVM_CAP_NR_VCPUS:
72 case KVM_CAP_MAX_VCPUS:
73 + case KVM_CAP_MAX_VCPU_ID:
74 r = KVM_S390_BSCA_CPU_SLOTS;
75 if (!kvm_s390_use_sca_entries())
76 r = KVM_MAX_VCPUS;
77 --- a/arch/x86/kvm/x86.c
78 +++ b/arch/x86/kvm/x86.c
79 @@ -2987,6 +2987,9 @@ int kvm_vm_ioctl_check_extension(struct
80 case KVM_CAP_MAX_VCPUS:
81 r = KVM_MAX_VCPUS;
82 break;
83 + case KVM_CAP_MAX_VCPU_ID:
84 + r = KVM_MAX_VCPU_ID;
85 + break;
86 case KVM_CAP_NR_MEMSLOTS:
87 r = KVM_USER_MEM_SLOTS;
88 break;
89 --- a/virt/kvm/arm/arm.c
90 +++ b/virt/kvm/arm/arm.c
91 @@ -223,6 +223,9 @@ int kvm_vm_ioctl_check_extension(struct
92 case KVM_CAP_MAX_VCPUS:
93 r = KVM_MAX_VCPUS;
94 break;
95 + case KVM_CAP_MAX_VCPU_ID:
96 + r = KVM_MAX_VCPU_ID;
97 + break;
98 case KVM_CAP_NR_MEMSLOTS:
99 r = KVM_USER_MEM_SLOTS;
100 break;
101 --- a/virt/kvm/kvm_main.c
102 +++ b/virt/kvm/kvm_main.c
103 @@ -2965,8 +2965,6 @@ static long kvm_vm_ioctl_check_extension
104 case KVM_CAP_MULTI_ADDRESS_SPACE:
105 return KVM_ADDRESS_SPACE_NUM;
106 #endif
107 - case KVM_CAP_MAX_VCPU_ID:
108 - return KVM_MAX_VCPU_ID;
109 default:
110 break;
111 }