Skip to content

Commit

Permalink
numa: Reject CPU indexes > max_cpus
Browse files Browse the repository at this point in the history
CPU index is always less than max_cpus, as documented at sysemu.h:

> The following shall be true for all CPUs:
>   cpu->cpu_index < max_cpus <= MAX_CPUMASK_BITS

Reject configuration which uses invalid CPU indexes.

Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
  • Loading branch information
ehabkost committed Mar 19, 2015
1 parent ed26b92 commit 8979c94
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions numa.c
Expand Up @@ -76,9 +76,11 @@ static void numa_node_parse(NumaNodeOptions *node, QemuOpts *opts, Error **errp)
}

for (cpus = node->cpus; cpus; cpus = cpus->next) {
if (cpus->value >= MAX_CPUMASK_BITS) {
error_setg(errp, "CPU number %" PRIu16 " is bigger than %d",
cpus->value, MAX_CPUMASK_BITS - 1);
if (cpus->value >= max_cpus) {
error_setg(errp,
"CPU index (%" PRIu16 ")"
" should be smaller than maxcpus (%d)",
cpus->value, max_cpus);
return;
}
bitmap_set(numa_info[nodenr].node_cpu, cpus->value, 1);
Expand Down

0 comments on commit 8979c94

Please sign in to comment.