diff options
Diffstat (limited to 'virt')
| -rw-r--r-- | virt/kvm/arm/vgic-v2.c | 1 | ||||
| -rw-r--r-- | virt/kvm/arm/vgic-v3.c | 1 | ||||
| -rw-r--r-- | virt/kvm/arm/vgic.c | 16 |
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 | */ | ||
| 1887 | int kvm_vgic_get_max_vcpus(void) | ||
| 1888 | { | ||
| 1889 | return vgic->max_gic_vcpus; | ||
| 1890 | } | ||
| 1891 | |||
| 1881 | void kvm_vgic_destroy(struct kvm *kvm) | 1892 | void 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 | ||
| 2077 | static int init_vgic_model(struct kvm *kvm, int type) | 2090 | static 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 | ||
