aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorAndre Przywara <andre.przywara@arm.com>2014-06-02 10:26:01 -0400
committerChristoffer Dall <christoffer.dall@linaro.org>2015-01-20 12:25:28 -0500
commit3caa2d8c3b2d80f5e342fe8cec07c03c8147dcab (patch)
treea07f89b6bcbd96fa45a65b52591d5fda2490a2f4 /virt
parent4ce7ebdfc69d1d5d166eec103ed2976eb45a6173 (diff)
arm/arm64: KVM: make the maximum number of vCPUs a per-VM value
Currently the maximum number of vCPUs supported is a global value limited by the used GIC model. GICv3 will lift this limit, but we still need to observe it for guests using GICv2. So the maximum number of vCPUs is per-VM value, depending on the GIC model the guest uses. Store and check the value in struct kvm_arch, but keep it down to 8 for now. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic-v2.c1
-rw-r--r--virt/kvm/arm/vgic-v3.c1
-rw-r--r--virt/kvm/arm/vgic.c16
3 files changed, 18 insertions, 0 deletions
diff --git a/virt/kvm/arm/vgic-v2.c b/virt/kvm/arm/vgic-v2.c
index e1cd3cb95903..e8b82b289844 100644
--- a/virt/kvm/arm/vgic-v2.c
+++ b/virt/kvm/arm/vgic-v2.c
@@ -237,6 +237,7 @@ int vgic_v2_probe(struct device_node *vgic_node,
237 vctrl_res.start, vgic->maint_irq); 237 vctrl_res.start, vgic->maint_irq);
238 238
239 vgic->type = VGIC_V2; 239 vgic->type = VGIC_V2;
240 vgic->max_gic_vcpus = VGIC_V2_MAX_CPUS;
240 *ops = &vgic_v2_ops; 241 *ops = &vgic_v2_ops;
241 *params = vgic; 242 *params = vgic;
242 goto out; 243 goto out;
diff --git a/virt/kvm/arm/vgic-v3.c b/virt/kvm/arm/vgic-v3.c
index d14c75f4a33b..ea39bad4b004 100644
--- a/virt/kvm/arm/vgic-v3.c
+++ b/virt/kvm/arm/vgic-v3.c
@@ -235,6 +235,7 @@ int vgic_v3_probe(struct device_node *vgic_node,
235 vgic->vcpu_base = vcpu_res.start; 235 vgic->vcpu_base = vcpu_res.start;
236 vgic->vctrl_base = NULL; 236 vgic->vctrl_base = NULL;
237 vgic->type = VGIC_V3; 237 vgic->type = VGIC_V3;
238 vgic->max_gic_vcpus = KVM_MAX_VCPUS;
238 239
239 kvm_info("%s@%llx IRQ%d\n", vgic_node->name, 240 kvm_info("%s@%llx IRQ%d\n", vgic_node->name,
240 vcpu_res.start, vgic->maint_irq); 241 vcpu_res.start, vgic->maint_irq);
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 1c3b75eb28f0..2126bf5b0035 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1878,6 +1878,17 @@ static int vgic_vcpu_init_maps(struct kvm_vcpu *vcpu, int nr_irqs)
1878 return 0; 1878 return 0;
1879} 1879}
1880 1880
1881/**
1882 * kvm_vgic_get_max_vcpus - Get the maximum number of VCPUs allowed by HW
1883 *
1884 * The host's GIC naturally limits the maximum amount of VCPUs a guest
1885 * can use.
1886 */
1887int kvm_vgic_get_max_vcpus(void)
1888{
1889 return vgic->max_gic_vcpus;
1890}
1891
1881void kvm_vgic_destroy(struct kvm *kvm) 1892void kvm_vgic_destroy(struct kvm *kvm)
1882{ 1893{
1883 struct vgic_dist *dist = &kvm->arch.vgic; 1894 struct vgic_dist *dist = &kvm->arch.vgic;
@@ -2072,6 +2083,8 @@ static void vgic_v2_init_emulation(struct kvm *kvm)
2072 dist->vm_ops.add_sgi_source = vgic_v2_add_sgi_source; 2083 dist->vm_ops.add_sgi_source = vgic_v2_add_sgi_source;
2073 dist->vm_ops.init_model = vgic_v2_init_model; 2084 dist->vm_ops.init_model = vgic_v2_init_model;
2074 dist->vm_ops.map_resources = vgic_v2_map_resources; 2085 dist->vm_ops.map_resources = vgic_v2_map_resources;
2086
2087 kvm->arch.max_vcpus = VGIC_V2_MAX_CPUS;
2075} 2088}
2076 2089
2077static int init_vgic_model(struct kvm *kvm, int type) 2090static int init_vgic_model(struct kvm *kvm, int type)
@@ -2084,6 +2097,9 @@ static int init_vgic_model(struct kvm *kvm, int type)
2084 return -ENODEV; 2097 return -ENODEV;
2085 } 2098 }
2086 2099
2100 if (atomic_read(&kvm->online_vcpus) > kvm->arch.max_vcpus)
2101 return -E2BIG;
2102
2087 return 0; 2103 return 0;
2088} 2104}
2089 2105