qemu-e2k/hw/ppc
Daniel Henrique Barboza ef95a24494 hw/ppc: free env->tb_env in spapr_unrealize_vcpu()
The timebase is allocated during spapr_realize_vcpu() and it's not
freed. This results in memory leaks when doing vcpu unplugs:

==636935==
==636935== 144 (96 direct, 48 indirect) bytes in 1 blocks are definitely lost in loss record 6
,461 of 8,135
==636935==    at 0x4897468: calloc (vg_replace_malloc.c:760)
==636935==    by 0x5077213: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6400.4)
==636935==    by 0x507757F: g_malloc0_n (in /usr/lib64/libglib-2.0.so.0.6400.4)
==636935==    by 0x93C3FB: cpu_ppc_tb_init (ppc.c:1066)
==636935==    by 0x97BC2B: spapr_realize_vcpu (spapr_cpu_core.c:268)
==636935==    by 0x97C01F: spapr_cpu_core_realize (spapr_cpu_core.c:337)
==636935==    by 0xD4626F: device_set_realized (qdev.c:531)
==636935==    by 0xD55273: property_set_bool (object.c:2273)
==636935==    by 0xD523DF: object_property_set (object.c:1408)
==636935==    by 0xD588B7: object_property_set_qobject (qom-qobject.c:28)
==636935==    by 0xD52897: object_property_set_bool (object.c:1477)
==636935==    by 0xD4579B: qdev_realize (qdev.c:333)
==636935==

This patch adds a cpu_ppc_tb_free() helper in hw/ppc/ppc.c to allow us
to free the timebase. This leak is then solved by calling
cpu_ppc_tb_free() in spapr_unrealize_vcpu().

Fixes: 6f4b5c3ec5 ("spapr: CPU hot unplug support")
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Message-Id: <20220329124545.529145-2-danielhb413@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
2022-04-04 08:49:06 +02:00
..
Kconfig hw/ppc/Kconfig: Add dependency PEGASOS2 -> ATI_VGA 2021-07-20 20:10:20 +02:00
e500-ccsr.h Use OBJECT_DECLARE_SIMPLE_TYPE when possible 2020-09-18 14:12:32 -04:00
e500.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
e500.h Use OBJECT_DECLARE_TYPE when possible 2020-09-18 14:12:32 -04:00
e500plat.c hw/ppc/e500plat: Only try to add valid dynamic sysbus devices to platform bus 2021-04-06 11:49:14 +01:00
fdt.c target/ppc: Split page size information into a separate allocation 2018-04-27 18:05:22 +10:00
fw_cfg.c hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
mac.h hw/ppc/mac.h: Remove MAX_CPUS macro 2021-12-17 17:57:12 +01:00
mac_newworld.c hw/ppc/mac.h: Remove MAX_CPUS macro 2021-12-17 17:57:12 +01:00
mac_oldworld.c hw/ppc/mac.h: Remove MAX_CPUS macro 2021-12-17 17:57:12 +01:00
meson.build spapr: Implement Open Firmware client interface 2021-07-09 10:38:19 +10:00
mpc8544_guts.c ppc/ppc4xx: Convert printfs() 2022-01-04 07:55:34 +01:00
mpc8544ds.c ppc/e500: use memdev for RAM 2020-02-19 16:50:00 +00:00
pef.c ppc/pef.c: initialize cgs->ready in kvmppc_svm_init() 2021-06-03 18:10:31 +10:00
pegasos2.c target/ppc: Introduce a vhyp framework for nested HV support 2022-02-18 08:34:14 +01:00
pnv.c ppc/pnv: Remove user-created PHB{3,4,5} devices 2022-03-14 15:57:17 +01:00
pnv_bmc.c Various spelling fixes 2021-03-09 21:19:10 +01:00
pnv_core.c ppc/pnv: Rename "id" to "quad-id" in PnvQuad 2021-09-29 19:37:38 +10:00
pnv_homer.c ppc/pnv: Add a HOMER model to POWER10 2022-03-02 06:51:39 +01:00
pnv_lpc.c ppc/pnv: Introduce a LPC FW memory region attribute to map the PNOR 2021-02-10 10:43:50 +11:00
pnv_occ.c ppc/pnv: Add a OCC model for POWER10 2022-03-02 06:51:39 +01:00
pnv_pnor.c ppc/pnv: Fix check on block device before updating drive contents 2021-11-09 10:32:52 +11:00
pnv_psi.c ppc/xive: Add support for PQ state bits offload 2022-03-02 06:51:39 +01:00
pnv_xscom.c ppc/pnv: Add a comment on the "primary-topology-index" property 2021-09-29 19:37:38 +10:00
ppc.c hw/ppc: free env->tb_env in spapr_unrealize_vcpu() 2022-04-04 08:49:06 +02:00
ppc4xx_devs.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
ppc4xx_pci.c ppc/ppc4xx: Convert printfs() 2022-01-04 07:55:34 +01:00
ppc405.h ppc/ppc405: Fix bi_pci_enetaddr2 field in U-Boot board information 2021-12-17 17:57:17 +01:00
ppc405_boards.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
ppc405_uc.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
ppc440.h ppc440_uc: Basic emulation of PPC440 DMA controller 2018-07-03 09:56:52 +10:00
ppc440_bamboo.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
ppc440_pcix.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
ppc440_uc.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
ppc_booke.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
ppce500_spin.c powerpc tcg: Fix Lesser GPL version number 2020-11-15 16:38:50 +01:00
prep.c target/ppc: Remove PowerPC 601 CPUs 2022-02-09 09:08:55 +01:00
prep_systemio.c Mark remaining global TypeInfo instances as const 2022-02-21 13:30:20 +00:00
rs6000_mc.c Do not include hw/boards.h if it's not really necessary 2021-05-02 17:24:51 +02:00
sam460ex.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
spapr.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
spapr_caps.c hw/ppc/spapr_caps.c: use g_autofree in spapr_caps_add_properties() 2022-03-02 06:51:39 +01:00
spapr_cpu_core.c hw/ppc: free env->tb_env in spapr_unrealize_vcpu() 2022-04-04 08:49:06 +02:00
spapr_drc.c hw/ppc/spapr_drc.c: use g_autofree in spapr_drc_by_index() 2022-03-02 06:51:40 +01:00
spapr_events.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
spapr_hcall.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
spapr_iommu.c Mark remaining global TypeInfo instances as const 2022-02-21 13:30:20 +00:00
spapr_irq.c spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect() 2020-12-14 15:50:55 +11:00
spapr_numa.c Use g_new() & friends where that makes obvious sense 2022-03-21 15:44:44 +01:00
spapr_nvdimm.c spapr: nvdimm: Introduce spapr-nvdimm device 2022-02-18 08:34:14 +01:00
spapr_ovec.c spapr: Improve handling of memory unplug with old guests 2021-01-19 10:20:29 +11:00
spapr_pci.c pci: Export pci_for_each_device_under_bus*() 2021-11-01 19:36:11 -04:00
spapr_pci_nvlink2.c spapr_pci_nvlink2.c: use g_autofree in spapr_phb_nvgpu_ram_populate_dt() 2022-03-02 06:51:40 +01:00
spapr_pci_vfio.c pci: Export pci_for_each_device_under_bus*() 2021-11-01 19:36:11 -04:00
spapr_rng.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
spapr_rtas.c hw/ppc/spapr_rtas.c: use g_autofree in rtas_ibm_get_system_parameter() 2022-03-02 06:51:40 +01:00
spapr_rtas_ddw.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
spapr_rtc.c rtc: Have event RTC_CHANGE identify the RTC by QOM path 2022-02-28 11:39:35 +01:00
spapr_softmmu.c osdep: Move memalign-related functions to their own header 2022-03-07 13:16:49 +00:00
spapr_tpm_proxy.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
spapr_vio.c hw/ppc/spapr_vio.c: use g_autofree in spapr_dt_vdevice() 2022-03-02 06:51:40 +01:00
spapr_vof.c spapr: Force 32bit when resetting a core 2022-01-28 13:15:01 +01:00
trace-events ppc/ppc405: Restore TCR and STR write handlers 2022-01-04 07:55:34 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00
virtex_ml507.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
vof.c hw/ppc/vof: Add missing includes 2022-01-28 13:15:03 +01:00