From nobody Thu May 2 09:30:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495204240965551.7698451433536; Fri, 19 May 2017 07:30:40 -0700 (PDT) Received: from localhost ([::1]:59055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBivO-0007kW-7V for importer@patchew.org; Fri, 19 May 2017 10:30:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42839) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBitX-0006V5-RR for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBitU-0004Pz-L5 for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:43 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49745) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBitU-0004OS-CV for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:40 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JELqMv004629 for ; Fri, 19 May 2017 10:28:39 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ahrwn9uu9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 May 2017 10:28:39 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 May 2017 11:28:36 -0300 Received: from d24relay04.br.ibm.com (9.18.232.146) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 May 2017 11:28:33 -0300 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by d24relay04.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4JESSmq1835506; Fri, 19 May 2017 11:28:33 -0300 Received: from d24av02.br.ibm.com (localhost [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4JESDEM024001; Fri, 19 May 2017 11:28:13 -0300 Received: from arthas.ibm.com ([9.85.192.116]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4JES7jp023696; Fri, 19 May 2017 11:28:11 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 11:27:49 -0300 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170519142750.18437-1-danielhb@linux.vnet.ibm.com> References: <20170519142750.18437-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17051914-0032-0000-0000-000005603C0E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051914-0033-0000-0000-000011E59D2C Message-Id: <20170519142750.18437-2-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190091 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v12 1/2] hw/ppc/spapr_events.c: removing 'exception' from sPAPREventLogEntry 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-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Currenty we do not have any RTAS event that is reported by the event-scan interface. The existing events, RTAS_LOG_TYPE_EPOW and RTAS_LOG_TYPE_HOTPLUG, are being reported by the check-exception interface and, as such, marked as 'exception=3Dtrue'. Commit 79853e18d9, 'spapr_events: event-scan RTAS interface', added the event_scan interface because the guest kernel requires it to initialize other required interfaces. It is acting since then as a stub because no events that would be reported by it were added since then. However, the existence of the 'exception' boolean adds an unnecessary load in the future migration of the pending_events, sPAPREventLogEntry QTAILQ that hosts the pending RTAS events. To make the code cleaner and ease the future migration changes, this patch makes the following changes: - remove the 'exception' boolean that filter these events. There is nothing to filter since all events are reported by check-exception; - functions rtas_event_log_queue, rtas_event_log_dequeue and rtas_event_log_contains don't receive the 'exception' boolean as parameter; - event_scan function was simplified. It was calling 'rtas_event_log_dequeue(mask, false)' that was always returning 'NULL' because we have no events that are created with exception=3Dfalse, thus in the end it would execute a jump to 'out_no_events' all the time. The function now assumes that this will always be the case and all the remaining logic were deleted. In the future, when or if we add new RTAS events that should be reported with the event_scan interface, we can refer to the changes made in this patch to add the event_scan logic back. Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr_events.c | 52 +++++++---------------------------------------= ---- include/hw/ppc/spapr.h | 1 - 2 files changed, 7 insertions(+), 46 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index f0b28d8..73e2a18 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -342,20 +342,18 @@ static int rtas_event_log_to_irq(sPAPRMachineState *s= papr, int log_type) return source->irq; } =20 -static void rtas_event_log_queue(int log_type, void *data, bool exception) +static void rtas_event_log_queue(int log_type, void *data) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry =3D g_new(sPAPREventLogEntry, 1); =20 g_assert(data); entry->log_type =3D log_type; - entry->exception =3D exception; entry->data =3D data; QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next); } =20 -static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask, - bool exception) +static sPAPREventLogEntry *rtas_event_log_dequeue(uint32_t event_mask) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry =3D NULL; @@ -364,10 +362,6 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint= 32_t event_mask, const sPAPREventSource *source =3D rtas_event_log_to_source(spapr, entry->log_type); =20 - if (entry->exception !=3D exception) { - continue; - } - if (source->mask & event_mask) { break; } @@ -380,7 +374,7 @@ static sPAPREventLogEntry *rtas_event_log_dequeue(uint3= 2_t event_mask, return entry; } =20 -static bool rtas_event_log_contains(uint32_t event_mask, bool exception) +static bool rtas_event_log_contains(uint32_t event_mask) { sPAPRMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); sPAPREventLogEntry *entry =3D NULL; @@ -389,10 +383,6 @@ static bool rtas_event_log_contains(uint32_t event_mas= k, bool exception) const sPAPREventSource *source =3D rtas_event_log_to_source(spapr, entry->log_type); =20 - if (entry->exception !=3D exception) { - continue; - } - if (source->mask & event_mask) { return true; } @@ -479,7 +469,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaq= ue) epow->event_modifier =3D RTAS_LOG_V6_EPOW_MODIFIER_NORMAL; epow->extended_modifier =3D RTAS_LOG_V6_EPOW_XMODIFIER_PARTITION_SPECI= FIC; =20 - rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow, true); + rtas_event_log_queue(RTAS_LOG_TYPE_EPOW, new_epow); =20 qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), rtas_event_log_to_irq(spapr, @@ -572,7 +562,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, cpu_to_be32(drc_id->count_indexed.index); } =20 - rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp, true); + rtas_event_log_queue(RTAS_LOG_TYPE_HOTPLUG, new_hp); =20 qemu_irq_pulse(xics_get_qirq(XICS_FABRIC(spapr), rtas_event_log_to_irq(spapr, @@ -667,7 +657,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, xinfo |=3D (uint64_t)rtas_ld(args, 6) << 32; } =20 - event =3D rtas_event_log_dequeue(mask, true); + event =3D rtas_event_log_dequeue(mask); if (!event) { goto out_no_events; } @@ -690,7 +680,7 @@ static void check_exception(PowerPCCPU *cpu, sPAPRMachi= neState *spapr, * interrupts. */ for (i =3D 0; i < EVENT_CLASS_MAX; i++) { - if (rtas_event_log_contains(EVENT_CLASS_MASK(i), true)) { + if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) { const sPAPREventSource *source =3D spapr_event_sources_get_source(spapr->event_sources, i); =20 @@ -710,38 +700,10 @@ static void event_scan(PowerPCCPU *cpu, sPAPRMachineS= tate *spapr, target_ulong args, uint32_t nret, target_ulong rets) { - uint32_t mask, buf, len, event_len; - sPAPREventLogEntry *event; - struct rtas_error_log *hdr; - if (nargs !=3D 4 || nret !=3D 1) { rtas_st(rets, 0, RTAS_OUT_PARAM_ERROR); return; } - - mask =3D rtas_ld(args, 0); - buf =3D rtas_ld(args, 2); - len =3D rtas_ld(args, 3); - - event =3D rtas_event_log_dequeue(mask, false); - if (!event) { - goto out_no_events; - } - - hdr =3D event->data; - event_len =3D be32_to_cpu(hdr->extended_length) + sizeof(*hdr); - - if (event_len < len) { - len =3D event_len; - } - - cpu_physical_memory_write(buf, event->data, len); - rtas_st(rets, 0, RTAS_OUT_SUCCESS); - g_free(event->data); - g_free(event); - return; - -out_no_events: rtas_st(rets, 0, RTAS_OUT_NO_ERRORS_FOUND); } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 5802f88..02239a5 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -598,7 +598,6 @@ sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong lio= bn); =20 struct sPAPREventLogEntry { int log_type; - bool exception; void *data; QTAILQ_ENTRY(sPAPREventLogEntry) next; }; --=20 2.9.4 From nobody Thu May 2 09:30:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495204244903579.7886735991892; Fri, 19 May 2017 07:30:44 -0700 (PDT) Received: from localhost ([::1]:59056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBivT-0007rh-Kz for importer@patchew.org; Fri, 19 May 2017 10:30:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dBitY-0006V7-9g for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dBitW-0004Ql-T6 for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53257) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dBitW-0004QU-JO for qemu-devel@nongnu.org; Fri, 19 May 2017 10:28:42 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v4JER9wU046000 for ; Fri, 19 May 2017 10:28:40 -0400 Received: from e24smtp05.br.ibm.com (e24smtp05.br.ibm.com [32.104.18.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ahvrsgu9t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Fri, 19 May 2017 10:28:40 -0400 Received: from localhost by e24smtp05.br.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 19 May 2017 11:28:37 -0300 Received: from d24relay03.br.ibm.com (9.18.232.225) by e24smtp05.br.ibm.com (10.172.0.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 19 May 2017 11:28:36 -0300 Received: from d24av02.br.ibm.com (d24av02.br.ibm.com [9.8.31.93]) by d24relay03.br.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v4JESUKk27918514; Fri, 19 May 2017 11:28:35 -0300 Received: from d24av02.br.ibm.com (localhost [127.0.0.1]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v4JESFG4024060; Fri, 19 May 2017 11:28:16 -0300 Received: from arthas.ibm.com ([9.85.192.116]) by d24av02.br.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v4JES7jq023696; Fri, 19 May 2017 11:28:13 -0300 From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Fri, 19 May 2017 11:27:50 -0300 X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170519142750.18437-1-danielhb@linux.vnet.ibm.com> References: <20170519142750.18437-1-danielhb@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 17051914-0032-0000-0000-000005603C10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17051914-0033-0000-0000-000011E59D2F Message-Id: <20170519142750.18437-3-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-05-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1705190091 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v12 2/2] migration: spapr: migrate pending_events of spapr state 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-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Jianjun Duan In racing situations between hotplug events and migration operation, a rtas hotplug event could have not yet be delivered to the source guest when migration is started. In this case the pending_events of spapr state need be transmitted to the target so that the hotplug event can be finished on the target. All the different fields of the events are encoded as defined by PAPR. We can migrate them as a binary stream inside VBUFFER without any concerns about data padding or endianess. pending_events is put in a subsection in the spapr state VMSD to make sure migration across different versions is not broken. Signed-off-by: Jianjun Duan Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michael Roth --- hw/ppc/spapr.c | 32 ++++++++++++++++++++++++++++++++ hw/ppc/spapr_events.c | 12 ++++++++++++ include/hw/ppc/spapr.h | 3 ++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 0980d73..5afd328 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1444,6 +1444,37 @@ static bool version_before_3(void *opaque, int versi= on_id) return version_id < 3; } =20 +static bool spapr_pending_events_needed(void *opaque) +{ + sPAPRMachineState *spapr =3D (sPAPRMachineState *)opaque; + return !QTAILQ_EMPTY(&spapr->pending_events); +} + +static const VMStateDescription vmstate_spapr_event_entry =3D { + .name =3D "spapr_event_log_entry", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_INT32(log_type, sPAPREventLogEntry), + VMSTATE_UINT32(data_size, sPAPREventLogEntry), + VMSTATE_VBUFFER_ALLOC_UINT32(data, sPAPREventLogEntry, 0, + NULL, data_size), + VMSTATE_END_OF_LIST() + }, +}; + +static const VMStateDescription vmstate_spapr_pending_events =3D { + .name =3D "spapr_pending_events", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D spapr_pending_events_needed, + .fields =3D (VMStateField[]) { + VMSTATE_QTAILQ_V(pending_events, sPAPRMachineState, 1, + vmstate_spapr_event_entry, sPAPREventLogEntry, ne= xt), + VMSTATE_END_OF_LIST() + }, +}; + static bool spapr_ov5_cas_needed(void *opaque) { sPAPRMachineState *spapr =3D opaque; @@ -1542,6 +1573,7 @@ static const VMStateDescription vmstate_spapr =3D { .subsections =3D (const VMStateDescription*[]) { &vmstate_spapr_ov5_cas, &vmstate_spapr_patb_entry, + &vmstate_spapr_pending_events, NULL } }; diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 73e2a18..a509c46 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -350,6 +350,18 @@ static void rtas_event_log_queue(int log_type, void *d= ata) g_assert(data); entry->log_type =3D log_type; entry->data =3D data; + + switch (log_type) { + case RTAS_LOG_TYPE_EPOW: + entry->data_size =3D sizeof(struct epow_log_full); + break; + case RTAS_LOG_TYPE_HOTPLUG: + entry->data_size =3D sizeof(struct hp_log_full); + break; + default: + g_assert(false); + } + QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next); } =20 diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 02239a5..0554e11 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -597,8 +597,9 @@ struct sPAPRTCETable { sPAPRTCETable *spapr_tce_find_by_liobn(target_ulong liobn); =20 struct sPAPREventLogEntry { - int log_type; + int32_t log_type; void *data; + uint32_t data_size; QTAILQ_ENTRY(sPAPREventLogEntry) next; }; =20 --=20 2.9.4