From 32a2cf9dfe251696b1d26b70723c5014e7ecbf45 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Wed, 4 Oct 2017 05:40:12 +0200 Subject: [PATCH 05/34] hw/ppc: clear pending_events on machine reset RH-Author: David Gibson Message-id: <20171004054014.14159-3-dgibson@redhat.com> Patchwork-id: 76803 O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH 2/4] hw/ppc: clear pending_events on machine reset Bugzilla: 1448344 RH-Acked-by: Laurent Vivier RH-Acked-by: Thomas Huth RH-Acked-by: Miroslav Rezanina From: Daniel Henrique Barboza The sPAPR machine isn't clearing up the pending events QTAILQ on machine reboot. This allows for unprocessed hotplug/epow events to persist in the queue after reset and, when reasserting the IRQs in check_exception later on, these will be being processed by the OS. This patch implements a new function called 'spapr_clear_pending_events' that clears up the pending_events QTAILQ. This helper is then called inside ppc_spapr_reset to clear up the events queue, preventing old/deprecated events from persisting after a reset. Signed-off-by: Daniel Henrique Barboza Signed-off-by: David Gibson (cherry picked from commit 56258174238eb25df629a53a96e1ac16a32dc7d4) Signed-off-by: David Gibson Signed-off-by: Miroslav Rezanina --- hw/ppc/spapr.c | 1 + hw/ppc/spapr_events.c | 11 +++++++++++ include/hw/ppc/spapr.h | 1 + 3 files changed, 13 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8d1cfcf..a419aa7 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1393,6 +1393,7 @@ static void ppc_spapr_reset(void) } qemu_devices_reset(); + spapr_clear_pending_events(spapr); /* * We place the device tree and RTAS just below either the top of the RMA, diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index f952b78..66b8164 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -700,6 +700,17 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineState *spapr, rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND); } +void spapr_clear_pending_events(sPAPRMachineState *spapr) +{ + sPAPREventLogEntry *entry = NULL; + + QTAILQ_FOREACH(entry, &spapr->pending_events, next) { + QTAILQ_REMOVE(&spapr->pending_events, entry, next); + g_free(entry->extended_log); + g_free(entry); + } +} + void spapr_events_init(sPAPRMachineState *spapr) { QTAILQ_INIT(&spapr->pending_events); diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2a303a7..5d161ec 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -662,6 +662,7 @@ void spapr_cpu_parse_features(sPAPRMachineState *spapr); int spapr_hpt_shift_for_ramsize(uint64_t ramsize); void spapr_reallocate_hpt(sPAPRMachineState *spapr, int shift, Error **errp); +void spapr_clear_pending_events(sPAPRMachineState *spapr); /* CPU and LMB DRC release callbacks. */ void spapr_core_release(DeviceState *dev); -- 1.8.3.1