From patchwork Fri Sep 8 10:35:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 811495 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="P+qB8esv"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpYfj51Xfz9s7h for ; Fri, 8 Sep 2017 20:37:15 +1000 (AEST) Received: from localhost ([::1]:44449 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGev-00029k-B9 for incoming@patchwork.ozlabs.org; Fri, 08 Sep 2017 06:37:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58538) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dqGdz-00023n-DV for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dqGdu-00037r-PS for qemu-devel@nongnu.org; Fri, 08 Sep 2017 06:36:15 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:41095) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dqGdu-00032U-EK; Fri, 08 Sep 2017 06:36:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3xpYdH5zbvz9sDB; Fri, 8 Sep 2017 20:36:03 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1504866963; bh=4LczZrC0MKA8gAOHw3qOXkmnI+EKMsDsizkD1S2qerw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+qB8esvrTzwimSngxfrdQhE40gd/1balwPR7MWagjG1AHOOWkM0mZPy8YkQt3+GH u3eoiO3jWa/1m+IJ8sF42cuz05o7BefnhvgKRI0K4Nxl9Oa9s5V62NZ58dUgj9Y47L mThYzrubEbAUuzvOsQiZ0ekbLITkDXGwKuSlD2Yk= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 8 Sep 2017 20:35:20 +1000 Message-Id: <20170908103558.31632-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170908103558.31632-1-david@gibson.dropbear.id.au> References: <20170908103558.31632-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 02/40] hw/ppc: clear pending_events on machine reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, aik@ozlabs.ru, agraf@suse.de, mdroth@linux.vnet.ibm.com, qemu-ppc@nongnu.org, imammedo@redhat.com, Daniel Henrique Barboza , sam.bobroff@au1.ibm.com, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 cec441cbf4..0e5f29d348 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1392,6 +1392,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 f952b78237..66b8164f30 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 2a303a705c..5d161ec580 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);