提交 5ec83c73 编写于 作者: B Bharata B Rao 提交者: Andreas Färber

target-ppc: Force CPU threads count to be a power of 2

PowerPC kernel expects the number of SMT threads in a core to be a power
of 2. Since QEMU doesn't enforce this, it leads to an early guest kernel
crash if invalid threads count is specified.

Prevent this crash and make it a graceful exit from QEMU itself by
validating the user-supplied threads count.
Signed-off-by: NBharata B Rao <bharata@linux.vnet.ibm.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Reviewed-by: NStewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: NAndreas Färber <afaerber@suse.de>
上级 a80172a4
......@@ -7848,6 +7848,12 @@ static void ppc_cpu_realizefn(DeviceState *dev, Error **errp)
max_smt, kvm_enabled() ? "KVM" : "TCG");
return;
}
if (!is_power_of_2(smp_threads)) {
error_setg(errp, "Cannot support %d threads on PPC with %s, "
"threads count must be a power of 2.",
smp_threads, kvm_enabled() ? "KVM" : "TCG");
return;
}
cpu->cpu_dt_id = (cs->cpu_index / smp_threads) * max_smt
+ (cs->cpu_index % smp_threads);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册