[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] ppc/pnv: Exit gracefully if CPU topology doesn't match the m
From: |
Greg Kurz |
Subject: |
[PATCH 1/2] ppc/pnv: Exit gracefully if CPU topology doesn't match the machine capacities |
Date: |
Fri, 20 Dec 2019 17:51:42 +0100 |
User-agent: |
StGit/unknown-version |
QEMU crashes when started with:
-machine powernv,num-chips=2 -smp cores=2 -accel tcg,thread=multi
ERROR:
tcg/tcg.c:789:tcg_register_thread: assertion failed: (n < ms->smp.max_cpus)
Aborted (core dumped)
This happens because the powernv machine creates num-chips * smp.cores
CPUs, which might exceed the maximum number of CPUs of the CPU topology
as computed by smp_parse().
Check the CPU topology in pnv_set_num_chips().
Signed-off-by: Greg Kurz <address@hidden>
---
hw/ppc/pnv.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index f77e7ca84ede..f8cf2b6d760f 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1706,7 +1706,8 @@ static void pnv_set_num_chips(Object *obj, Visitor *v,
const char *name,
void *opaque, Error **errp)
{
PnvMachineState *pnv = PNV_MACHINE(obj);
- uint32_t num_chips;
+ MachineState *ms = MACHINE(pnv);
+ uint32_t num_chips, num_cpus;
Error *local_err = NULL;
visit_type_uint32(v, name, &num_chips, &local_err);
@@ -1724,6 +1725,13 @@ static void pnv_set_num_chips(Object *obj, Visitor *v,
const char *name,
return;
}
+ num_cpus = num_chips * ms->smp.cores * ms->smp.threads;
+ if (num_cpus > ms->smp.max_cpus) {
+ error_setg(errp, "%d chips don't fit in the CPU topology", num_chips);
+ error_append_hint(errp, "Try -smp sockets=%d.\n", num_chips);
+ return;
+ }
+
pnv->num_chips = num_chips;
}