hw/ppc/pnv: Avoid dynamic stack allocation
Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Message-id: 20220819153931.3147384-7-peter.maydell@linaro.org
This commit is contained in:
parent
c140a69055
commit
a580fdcd60
@ -138,7 +138,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
|
|||||||
int smt_threads = CPU_CORE(pc)->nr_threads;
|
int smt_threads = CPU_CORE(pc)->nr_threads;
|
||||||
CPUPPCState *env = &cpu->env;
|
CPUPPCState *env = &cpu->env;
|
||||||
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
|
PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cs);
|
||||||
uint32_t servers_prop[smt_threads];
|
g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
|
||||||
int i;
|
int i;
|
||||||
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
|
uint32_t segs[] = {cpu_to_be32(28), cpu_to_be32(40),
|
||||||
0xffffffff, 0xffffffff};
|
0xffffffff, 0xffffffff};
|
||||||
@ -241,7 +241,7 @@ static void pnv_dt_core(PnvChip *chip, PnvCore *pc, void *fdt)
|
|||||||
servers_prop[i] = cpu_to_be32(pc->pir + i);
|
servers_prop[i] = cpu_to_be32(pc->pir + i);
|
||||||
}
|
}
|
||||||
_FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
|
_FDT((fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
|
||||||
servers_prop, sizeof(servers_prop))));
|
servers_prop, sizeof(*servers_prop) * smt_threads)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
|
static void pnv_dt_icp(PnvChip *chip, void *fdt, uint32_t pir,
|
||||||
|
@ -177,8 +177,8 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
|
|||||||
int smt_threads)
|
int smt_threads)
|
||||||
{
|
{
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
uint32_t servers_prop[smt_threads];
|
g_autofree uint32_t *servers_prop = g_new(uint32_t, smt_threads);
|
||||||
uint32_t gservers_prop[smt_threads * 2];
|
g_autofree uint32_t *gservers_prop = g_new(uint32_t, smt_threads * 2);
|
||||||
int index = spapr_get_vcpu_id(cpu);
|
int index = spapr_get_vcpu_id(cpu);
|
||||||
|
|
||||||
if (cpu->compat_pvr) {
|
if (cpu->compat_pvr) {
|
||||||
@ -196,12 +196,12 @@ static int spapr_fixup_cpu_smt_dt(void *fdt, int offset, PowerPCCPU *cpu,
|
|||||||
gservers_prop[i*2 + 1] = 0;
|
gservers_prop[i*2 + 1] = 0;
|
||||||
}
|
}
|
||||||
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
|
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-server#s",
|
||||||
servers_prop, sizeof(servers_prop));
|
servers_prop, sizeof(*servers_prop) * smt_threads);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s",
|
ret = fdt_setprop(fdt, offset, "ibm,ppc-interrupt-gserver#s",
|
||||||
gservers_prop, sizeof(gservers_prop));
|
gservers_prop, sizeof(*gservers_prop) * smt_threads * 2);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ void spapr_phb_nvgpu_populate_pcidev_dt(PCIDevice *dev, void *fdt, int offset,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (dev == nvslot->gpdev) {
|
if (dev == nvslot->gpdev) {
|
||||||
uint32_t npus[nvslot->linknum];
|
g_autofree uint32_t *npus = g_new(uint32_t, nvslot->linknum);
|
||||||
|
|
||||||
for (j = 0; j < nvslot->linknum; ++j) {
|
for (j = 0; j < nvslot->linknum; ++j) {
|
||||||
PCIDevice *npdev = nvslot->links[j].npdev;
|
PCIDevice *npdev = nvslot->links[j].npdev;
|
||||||
|
Loading…
Reference in New Issue
Block a user