From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660259; cv=none; d=zohomail.com; s=zohoarc; b=HgRNO0+e/JG9TV9irC14ZOgQf1BhK0VA2T+sNY0pSisGeDRbo/H9c0kzvh37u+rwWAxaR4jGpFggthb4YGiMePAyYCT1FNUmIEoxd93Lb7U2sqeSbWSBxME/i9ywf3tG6pgjMntytibglqEps4USOztz9E3MzzxuD/RUlJeJddE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LrsjIKEMo18Bl4TniGRzfHvIwWJAPROsjQHf7lHb4Hc=; b=m35NpZ7BIt4j7tACQDKPqaWqO8vZjS1c62BNemoCxc42T5aX56lQd4W0oW/A7RoXdcFJeOU9zgy9zApTwaGREjaO/UcJeXH4f1niAe9L/tkf57fMH24l/1XgoCWvbFYfHA2KC1IVu6hmGcmcdriuFC1cJZrXDyS7eu9G9ssd9WQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660258892393.441695867887; Thu, 10 Dec 2020 20:17:38 -0800 (PST) Received: from localhost ([::1]:53352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZs8-0007Yc-Ew for importer@patchew.org; Thu, 10 Dec 2020 23:17:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq3-0005Wf-Cq; Thu, 10 Dec 2020 23:15:27 -0500 Received: from ozlabs.org ([203.11.71.1]:38175) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq0-0000Vr-0l; Thu, 10 Dec 2020 23:15:26 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CscrZ3Pjgz9sVY; Fri, 11 Dec 2020 15:15:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660110; bh=gfeNh3a0FmYAZk7sxGaHo1IQu2z3E9m3i+0g+ViVWlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZzfcGidja2chQ8kpJWJxsyRM4E4tXtSkMOsakB0BVogHINpHn4frfsiOkKIBY1SnW 1e2svEM0r7cZ+0zcoeiAq02jO1k42RNdCtmat0Eu/pvc5wPVSoZ9SVMgu3J7cIoGVn A40CdUAEcUB1ytdvJ56+UV+kd1hYx+En79DdJDOQ= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 01/30] spapr/xive: Turn some sanity checks into assertions Date: Fri, 11 Dec 2020 15:14:38 +1100 Message-Id: <20201211041507.425378-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Greg Kurz The sPAPR XIVE device is created by the machine in spapr_irq_init(). The latter overrides any value provided by the user with -global for the "nr-irqs" and "nr-ends" properties with strictly positive values. It seems reasonable to assume these properties should never be 0, which wouldn't make much sense by the way. Signed-off-by: Greg Kurz Message-Id: <20201120174646.619395-2-groug@kaod.org> Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/spapr_xive.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 1fa09f287a..60e0d5769d 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -296,22 +296,16 @@ static void spapr_xive_realize(DeviceState *dev, Erro= r **errp) XiveENDSource *end_xsrc =3D &xive->end_source; Error *local_err =3D NULL; =20 + /* Set by spapr_irq_init() */ + g_assert(xive->nr_irqs); + g_assert(xive->nr_ends); + sxc->parent_realize(dev, &local_err); if (local_err) { error_propagate(errp, local_err); return; } =20 - if (!xive->nr_irqs) { - error_setg(errp, "Number of interrupt needs to be greater 0"); - return; - } - - if (!xive->nr_ends) { - error_setg(errp, "Number of interrupt needs to be greater 0"); - return; - } - /* * Initialize the internal sources, for IPIs and virtual devices. */ --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660470; cv=none; d=zohomail.com; s=zohoarc; b=UsY4jhNN0MzZyQvMBtXCzrIr2ssfadAL0hUl9TIEEWmWcIv7MOCx6kApmez330bAAQkWZVLsnwwTxKVxrNZ0yoGKJkHTXh0Tct63shydN4mT9v68/HgeMSYAyDPcdDXgC9bM/Z9fnfTNuSTh+ADq0Aqyn7GpfxyrxuEzHNCKF8w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660470; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hn5A5iacXQU+CpkYAr7aZGpxW4klEaHn8GNtf6l39WQ=; b=LpMRaQMRjREHawp5VWT36O7yz6RNI+Q37JNzH2pBhtBILqpu1qz+sGAzTviZcNDDq6HMpgs1YY/AOdbk+Cb/FUBPrlNUl2aHc5GpdPV4+65Ch0Rb+OlF46ofmVm2cwiFQFajEr19G5mOjaM/WKIqEsqu2Nb6WVH/Y3wz0QnWvyQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660470682303.0216053074595; Thu, 10 Dec 2020 20:21:10 -0800 (PST) Received: from localhost ([::1]:33514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZvZ-0002hM-Ef for importer@patchew.org; Thu, 10 Dec 2020 23:21:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33900) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq3-0005Wg-D4; Thu, 10 Dec 2020 23:15:27 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:42299) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq0-0000Uy-0e; Thu, 10 Dec 2020 23:15:26 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CscrZ4f84z9sWV; Fri, 11 Dec 2020 15:15:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660110; bh=30IN9E+iDeGmA9l4nt+SQ3Bx4uYn26iJRk5Uk+ZSwk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AxGFT7LQz2oGNOfugpoGgDtdFdpyHJcvc/J8Qkc1SWOh1D3VWsabt84ldFeemxCmw aNz4sE87ok5uli4ZD6QJjeWR52WbXrKgF+mdnGCxCiOfl2CLMx/NpisdYT9N9O7GT8 46HEgxo8Z5W1Ql1joj7hSPOuSW36FzwI1P7m5psM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 02/30] spapr/xics: Drop unused argument to xics_kvm_has_broken_disconnect() Date: Fri, 11 Dec 2020 15:14:39 +1100 Message-Id: <20201211041507.425378-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Greg Kurz Never used from the start. Signed-off-by: Greg Kurz Message-Id: <20201120174646.619395-6-groug@kaod.org> Reviewed-by: C=C3=A9dric Le Goater Signed-off-by: David Gibson --- hw/intc/xics_kvm.c | 2 +- hw/ppc/spapr_irq.c | 2 +- include/hw/ppc/xics_spapr.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 68bb1914b9..570d635bcc 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -484,7 +484,7 @@ void xics_kvm_disconnect(SpaprInterruptController *intc) * support destruction of a KVM XICS device while the VM is running. * Required to start a spapr machine with ic-mode=3Ddual,kernel-irqchip=3D= on. */ -bool xics_kvm_has_broken_disconnect(SpaprMachineState *spapr) +bool xics_kvm_has_broken_disconnect(void) { int rc; =20 diff --git a/hw/ppc/spapr_irq.c b/hw/ppc/spapr_irq.c index f59960339e..a0d1e1298e 100644 --- a/hw/ppc/spapr_irq.c +++ b/hw/ppc/spapr_irq.c @@ -186,7 +186,7 @@ static int spapr_irq_check(SpaprMachineState *spapr, Er= ror **errp) if (kvm_enabled() && spapr->irq =3D=3D &spapr_irq_dual && kvm_kernel_irqchip_required() && - xics_kvm_has_broken_disconnect(spapr)) { + xics_kvm_has_broken_disconnect()) { error_setg(errp, "KVM is incompatible with ic-mode=3Ddual,kernel-irqchip=3Don"); error_append_hint(errp, diff --git a/include/hw/ppc/xics_spapr.h b/include/hw/ppc/xics_spapr.h index 0b8182e40b..de752c0d2c 100644 --- a/include/hw/ppc/xics_spapr.h +++ b/include/hw/ppc/xics_spapr.h @@ -38,6 +38,6 @@ DECLARE_INSTANCE_CHECKER(ICSState, ICS_SPAPR, int xics_kvm_connect(SpaprInterruptController *intc, uint32_t nr_servers, Error **errp); void xics_kvm_disconnect(SpaprInterruptController *intc); -bool xics_kvm_has_broken_disconnect(SpaprMachineState *spapr); +bool xics_kvm_has_broken_disconnect(void); =20 #endif /* XICS_SPAPR_H */ --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660260; cv=none; d=zohomail.com; s=zohoarc; b=fmTrC+XYBtePcr4nLgogXnll1gUjCHtluCRO5UZ7feUnm3N1z2MVu9SWNsP5b4iH9n8ZxLmYYMIUnr0W4tmrz3oBJU+4Ob15Be5G6pHNDrd33y/7bcrEimBh4QoJgbsYF57+cX3d92TipmHT1ucEM77m/+BbhQMnuNCfQCLocdQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660260; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4MUOmyRrGqmJkh9nhITjMgi/Z8iIwM/X3Ihvvhn7OI4=; b=KbadNBepECzeertz5W0rwYnKGkz8WkEHqPYFf90bxGcKs0ka4TokinleB4bSbJACUmQcp6v41MeEIE8PKTPWjrqcUneFw1C9MQq7f+3gRHdcn0KkvBdB8HoKOORN4sRhrr/aemgg+b1rSaYu7zErCaPVZxLlQq0cBRg3JZMA+ko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660260359453.8741260209773; Thu, 10 Dec 2020 20:17:40 -0800 (PST) Received: from localhost ([::1]:53388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZsA-0007Zd-MQ for importer@patchew.org; Thu, 10 Dec 2020 23:17:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq3-0005X0-Vi; Thu, 10 Dec 2020 23:15:28 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:46059) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq0-0000VV-Nk; Thu, 10 Dec 2020 23:15:27 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CscrZ5fsZz9sWb; Fri, 11 Dec 2020 15:15:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660110; bh=EQ0RM4keCvuyRhFDOSVesL8cPCVi1p1rmqjz0xDso0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hXxDjlMr+CbD68+oYM8plNse6aGh/JosD+rKYAD3sjXnfPjsP7khklBOkri4Nt+PB X2vKFAUamB1FLPNOqqsmVhXzY58a6NaGNSLEkOpYsBoCbfuCoeEDMnSooLqTyA+3E6 4xfpay1pkihhazbPQSAloqipaySZvTAlLN/+qHzA= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 03/30] spapr: Do PCI device hotplug sanity checks at pre-plug only Date: Fri, 11 Dec 2020 15:14:40 +1100 Message-Id: <20201211041507.425378-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz The PHB acts as the hotplug handler for PCI devices. It does some sanity checks on DR enablement, PCI bridge chassis numbers and multifunction. These checks are currently performed at plug time, but they would best sit in a pre-plug handler in order to error out as early as possible. Create a spapr_pci_pre_plug() handler and move all the checking there. Add a check that the associated DRC doesn't already have an attached device. This is equivalent to the slot availability check performed by do_pci_register_device() upon realization of the PCI device. This allows to pass &error_abort to spapr_drc_attach() and to end up with a plug handler that doesn't need to report errors anymore. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-2-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 88ce87f130..2829f298d9 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1532,8 +1532,8 @@ static bool bridge_has_valid_chassis_nr(Object *bridg= e, Error **errp) return true; } =20 -static void spapr_pci_plug(HotplugHandler *plug_handler, - DeviceState *plugged_dev, Error **errp) +static void spapr_pci_pre_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, Error **errp) { SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); @@ -1542,9 +1542,6 @@ static void spapr_pci_plug(HotplugHandler *plug_handl= er, PCIBus *bus =3D PCI_BUS(qdev_get_parent_bus(DEVICE(pdev))); uint32_t slotnr =3D PCI_SLOT(pdev->devfn); =20 - /* if DR is disabled we don't need to do anything in the case of - * hotplug or coldplug callbacks - */ if (!phb->dr_enabled) { /* if this is a hotplug operation initiated by the user * we need to let them know it's not enabled @@ -1552,17 +1549,14 @@ static void spapr_pci_plug(HotplugHandler *plug_han= dler, if (plugged_dev->hotplugged) { error_setg(errp, QERR_BUS_NO_HOTPLUG, object_get_typename(OBJECT(phb))); + return; } - return; } =20 - g_assert(drc); - if (pc->is_bridge) { if (!bridge_has_valid_chassis_nr(OBJECT(plugged_dev), errp)) { return; } - spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev)); } =20 /* Following the QEMU convention used for PCIe multifunction @@ -1574,13 +1568,41 @@ static void spapr_pci_plug(HotplugHandler *plug_han= dler, error_setg(errp, "PCI: slot %d function 0 already occupied by %s," " additional functions can no longer be exposed to gues= t.", slotnr, bus->devices[PCI_DEVFN(slotnr, 0)]->name); + } + + if (drc && drc->dev) { + error_setg(errp, "PCI: slot %d already occupied by %s", slotnr, + pci_get_function_0(PCI_DEVICE(drc->dev))->name); return; } +} + +static void spapr_pci_plug(HotplugHandler *plug_handler, + DeviceState *plugged_dev, Error **errp) +{ + SpaprPhbState *phb =3D SPAPR_PCI_HOST_BRIDGE(DEVICE(plug_handler)); + PCIDevice *pdev =3D PCI_DEVICE(plugged_dev); + PCIDeviceClass *pc =3D PCI_DEVICE_GET_CLASS(plugged_dev); + SpaprDrc *drc =3D drc_from_dev(phb, pdev); + uint32_t slotnr =3D PCI_SLOT(pdev->devfn); =20 - if (!spapr_drc_attach(drc, DEVICE(pdev), errp)) { + /* + * If DR is disabled we don't need to do anything in the case of + * hotplug or coldplug callbacks. + */ + if (!phb->dr_enabled) { return; } =20 + g_assert(drc); + + if (pc->is_bridge) { + spapr_pci_bridge_plug(phb, PCI_BRIDGE(plugged_dev)); + } + + /* spapr_pci_pre_plug() already checked the DRC is attachable */ + spapr_drc_attach(drc, DEVICE(pdev), &error_abort); + /* If this is function 0, signal hotplug for all the device functions. * Otherwise defer sending the hotplug event. */ @@ -2223,6 +2245,7 @@ static void spapr_phb_class_init(ObjectClass *klass, = void *data) /* Supported by TYPE_SPAPR_MACHINE */ dc->user_creatable =3D true; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); + hp->pre_plug =3D spapr_pci_pre_plug; hp->plug =3D spapr_pci_plug; hp->unplug =3D spapr_pci_unplug; hp->unplug_request =3D spapr_pci_unplug_request; --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660313; cv=none; d=zohomail.com; s=zohoarc; b=imISbMFJtpx6KKM1Hz++jE3MILECwcxCkffLtwN/MQzrtNwbzKSv2V8XODusBseOVXAiQ/P4IoU5L6XQdhxP+B2qWfeVwY7joyInS6F+ya7ZZ8WsAks4CMIhDx+rlQlCQU+0/a5V4mz2ziflzjWNfcM/0PaFLBXmCMObdilZF9w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KqyGoBNygeVPHKY2OqVEYuOUF9/14jbPmwmKGMWSZ3Y=; b=ItSxPTegdi2t/WtpG35m0sc7Upps1y4bnmYbHc4KXGrwROywGx8kSiTWPkYtpxsuopYyNu3q+m358tUm6hqfyNfFho0ksx3SSLjgVnAASq91YFnFrZiObEJPk7Til5ZVFkRAKjPMu49hp0s/rdVXySF5JdbaI9JAaCKJLZXeBjI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660313966233.30296025557675; Thu, 10 Dec 2020 20:18:33 -0800 (PST) Received: from localhost ([::1]:55216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZt2-0008J3-Ks for importer@patchew.org; Thu, 10 Dec 2020 23:18:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq3-0005Wz-Uq; Thu, 10 Dec 2020 23:15:28 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:53795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq0-0000Vu-7o; Thu, 10 Dec 2020 23:15:27 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CscrZ67jtz9sWY; Fri, 11 Dec 2020 15:15:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660110; bh=r9GZYOFvPych2CvL1GEjt7EgTnJk/WvnutzNTlPHufw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ORcUPABHwIlWW80vCJ3t1hLFfVlHt6NfS/vX6h9ohdon4NKGGXMyDALxpLhETJN5h sy2dOaK8JpX4LX4jaXDC6AjGl1Y/Buz4bvgbj6aBRqaairmCKMx3kJPllks6TBTBI7 wXrzTm80VqC/oTR3zQYVdFKM8xGSuo/7EaPOFR2Q= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 04/30] spapr: Do NVDIMM/PC-DIMM device hotplug sanity checks at pre-plug only Date: Fri, 11 Dec 2020 15:14:41 +1100 Message-Id: <20201211041507.425378-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz Pre-plug of a memory device, be it an NVDIMM or a PC-DIMM, ensures that the memory slot is available and that addresses don't overlap with existing memory regions. The corresponding DRCs in the LMB and PMEM namespaces are thus necessarily attachable at plug time. Pass &error_abort to spapr_drc_attach() in spapr_add_lmbs() and spapr_add_nvdimm(). This allows to greatly simplify error handling on the plug path. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-3-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 40 ++++++++++++----------------------- hw/ppc/spapr_nvdimm.c | 11 +++++----- include/hw/ppc/spapr_nvdimm.h | 2 +- 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index c060702013..3be27ee2cd 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3382,8 +3382,8 @@ int spapr_lmb_dt_populate(SpaprDrc *drc, SpaprMachine= State *spapr, return 0; } =20 -static bool spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t= size, - bool dedicated_hp_event_source, Error **errp) +static void spapr_add_lmbs(DeviceState *dev, uint64_t addr_start, uint64_t= size, + bool dedicated_hp_event_source) { SpaprDrc *drc; uint32_t nr_lmbs =3D size/SPAPR_MEMORY_BLOCK_SIZE; @@ -3396,15 +3396,12 @@ static bool spapr_add_lmbs(DeviceState *dev, uint64= _t addr_start, uint64_t size, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); =20 - if (!spapr_drc_attach(drc, dev, errp)) { - while (addr > addr_start) { - addr -=3D SPAPR_MEMORY_BLOCK_SIZE; - drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, - addr / SPAPR_MEMORY_BLOCK_SIZE); - spapr_drc_detach(drc); - } - return false; - } + /* + * memory_device_get_free_addr() provided a range of free addresses + * that doesn't overlap with any existing mapping at pre-plug. The + * corresponding LMB DRCs are thus assumed to be all attachable. + */ + spapr_drc_attach(drc, dev, &error_abort); if (!hotplugged) { spapr_drc_reset(drc); } @@ -3425,11 +3422,9 @@ static bool spapr_add_lmbs(DeviceState *dev, uint64_= t addr_start, uint64_t size, nr_lmbs); } } - return true; } =20 -static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, - Error **errp) +static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *de= v) { SpaprMachineState *ms =3D SPAPR_MACHINE(hotplug_dev); PCDIMMDevice *dimm =3D PC_DIMM(dev); @@ -3444,24 +3439,15 @@ static void spapr_memory_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, if (!is_nvdimm) { addr =3D object_property_get_uint(OBJECT(dimm), PC_DIMM_ADDR_PROP, &error_abort); - if (!spapr_add_lmbs(dev, addr, size, - spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT), errp= )) { - goto out_unplug; - } + spapr_add_lmbs(dev, addr, size, + spapr_ovec_test(ms->ov5_cas, OV5_HP_EVT)); } else { slot =3D object_property_get_int(OBJECT(dimm), PC_DIMM_SLOT_PROP, &error_abort); /* We should have valid slot number at this point */ g_assert(slot >=3D 0); - if (!spapr_add_nvdimm(dev, slot, errp)) { - goto out_unplug; - } + spapr_add_nvdimm(dev, slot); } - - return; - -out_unplug: - pc_dimm_unplug(dimm, MACHINE(ms)); } =20 static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, @@ -4009,7 +3995,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, DeviceState *dev, Error **errp) { if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { - spapr_memory_plug(hotplug_dev, dev, errp); + spapr_memory_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index a833a63b5e..2f1c196e1b 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -89,7 +89,7 @@ bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, N= VDIMMDevice *nvdimm, } =20 =20 -bool spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp) +void spapr_add_nvdimm(DeviceState *dev, uint64_t slot) { SpaprDrc *drc; bool hotplugged =3D spapr_drc_hotplugged(dev); @@ -97,14 +97,15 @@ bool spapr_add_nvdimm(DeviceState *dev, uint64_t slot, = Error **errp) drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PMEM, slot); g_assert(drc); =20 - if (!spapr_drc_attach(drc, dev, errp)) { - return false; - } + /* + * pc_dimm_get_free_slot() provided a free slot at pre-plug. The + * corresponding DRC is thus assumed to be attachable. + */ + spapr_drc_attach(drc, dev, &error_abort); =20 if (hotplugged) { spapr_hotplug_req_add_by_index(drc); } - return true; } =20 static int spapr_dt_nvdimm(SpaprMachineState *spapr, void *fdt, diff --git a/include/hw/ppc/spapr_nvdimm.h b/include/hw/ppc/spapr_nvdimm.h index 344582d2f5..73be250e2a 100644 --- a/include/hw/ppc/spapr_nvdimm.h +++ b/include/hw/ppc/spapr_nvdimm.h @@ -30,6 +30,6 @@ int spapr_pmem_dt_populate(SpaprDrc *drc, SpaprMachineSta= te *spapr, void spapr_dt_persistent_memory(SpaprMachineState *spapr, void *fdt); bool spapr_nvdimm_validate(HotplugHandler *hotplug_dev, NVDIMMDevice *nvdi= mm, uint64_t size, Error **errp); -bool spapr_add_nvdimm(DeviceState *dev, uint64_t slot, Error **errp); +void spapr_add_nvdimm(DeviceState *dev, uint64_t slot); =20 #endif --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660313; cv=none; d=zohomail.com; s=zohoarc; b=Y4rYvyun5SSIgOBipdGXQeWSd3f8LMzaX0KmYduotYKAhczTB0APF2re6USWSr41uiQueiJDghOSsfkor5XezBJJN9GuSKIduFNKVjovZqx4Q8n1r0LuuZ9uAXjplfkDU0Tes9OcRWMyEGeiweP6yjwOoUP+7PYqx9OcC19mm08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660313; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jRPJ5o+mwm89KoLDmuGDdCOEvqwfkzGHnN1mOp2fBwg=; b=IeAQ6o24oTq4wQg70QVPJi44yFOefqErXMIKRbESuTcs2oAGxjw8aeLDFProqE1y9gLs5Eb9KpZxLYWF6z31EKx8p7J+GZvDMbX18y1FbWnMWPCwNvH6gqyV/g2Wo7oAz6Vb9n2WhpoNS6giAf3rdnYkZAlQP8tzS0JHwBFjM+0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660313821676.0903562463499; Thu, 10 Dec 2020 20:18:33 -0800 (PST) Received: from localhost ([::1]:55190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZt2-0008IL-Gf for importer@patchew.org; Thu, 10 Dec 2020 23:18:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq7-0005bn-Sw; Thu, 10 Dec 2020 23:15:32 -0500 Received: from ozlabs.org ([203.11.71.1]:56227) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq5-0000ix-Rn; Thu, 10 Dec 2020 23:15:31 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4CscrZ72FFz9sWc; Fri, 11 Dec 2020 15:15:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660110; bh=y3ZYqJOuxDBOt14MWrcs2ZMXCYZC6a8TEZBKCXfJFN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N+qiJhRYTnU5tgcq/zN79fmKrHgtOuxoT9CcKMTOapzZ0YH1Jbs/XRnQeRpgsWIG9 is91CL9IAex4X4ga0vNZF5x2lHtF/bwtZyQr2vyuiTAGsROOf0EMm9PKOfeUEfFjeV JoyZJLGAORUtJ5ULRlKlm8g+G9wVBB+tKnqklJ+A= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 05/30] spapr: Make PHB placement functions and spapr_pre_plug_phb() return status Date: Fri, 11 Dec 2020 15:14:42 +1100 Message-Id: <20201211041507.425378-6-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz Read documentation in "qapi/error.h" and changelog of commit e3fe3988d785 ("error: Document Error API usage rules") for rationale. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-7-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 40 +++++++++++++++++++++++----------------- include/hw/ppc/spapr.h | 2 +- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 3be27ee2cd..90db845cbb 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3882,7 +3882,7 @@ int spapr_phb_dt_populate(SpaprDrc *drc, SpaprMachine= State *spapr, return 0; } =20 -static void spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, +static bool spapr_phb_pre_plug(HotplugHandler *hotplug_dev, DeviceState *d= ev, Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); @@ -3892,24 +3892,25 @@ static void spapr_phb_pre_plug(HotplugHandler *hotp= lug_dev, DeviceState *dev, =20 if (dev->hotplugged && !smc->dr_phb_enabled) { error_setg(errp, "PHB hotplug not supported for this machine"); - return; + return false; } =20 if (sphb->index =3D=3D (uint32_t)-1) { error_setg(errp, "\"index\" for PAPR PHB is mandatory"); - return; + return false; } =20 /* * This will check that sphb->index doesn't exceed the maximum number = of * PHBs for the current machine type. */ - smc->phb_placement(spapr, sphb->index, - &sphb->buid, &sphb->io_win_addr, - &sphb->mem_win_addr, &sphb->mem64_win_addr, - windows_supported, sphb->dma_liobn, - &sphb->nv2_gpa_win_addr, &sphb->nv2_atsd_win_addr, - errp); + return + smc->phb_placement(spapr, sphb->index, + &sphb->buid, &sphb->io_win_addr, + &sphb->mem_win_addr, &sphb->mem64_win_addr, + windows_supported, sphb->dma_liobn, + &sphb->nv2_gpa_win_addr, &sphb->nv2_atsd_win_ad= dr, + errp); } =20 static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev, @@ -4147,7 +4148,7 @@ static const CPUArchIdList *spapr_possible_cpu_arch_i= ds(MachineState *machine) return machine->possible_cpus; } =20 -static void spapr_phb_placement(SpaprMachineState *spapr, uint32_t index, +static bool spapr_phb_placement(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, @@ -4185,7 +4186,7 @@ static void spapr_phb_placement(SpaprMachineState *sp= apr, uint32_t index, if (index >=3D SPAPR_MAX_PHBS) { error_setg(errp, "\"index\" for PAPR PHB is too large (max %llu)", SPAPR_MAX_PHBS - 1); - return; + return false; } =20 *buid =3D base_buid + index; @@ -4199,6 +4200,7 @@ static void spapr_phb_placement(SpaprMachineState *sp= apr, uint32_t index, =20 *nv2gpa =3D SPAPR_PCI_NV2RAM64_WIN_BASE + index * SPAPR_PCI_NV2RAM64_W= IN_SIZE; *nv2atsd =3D SPAPR_PCI_NV2ATSD_WIN_BASE + index * SPAPR_PCI_NV2ATSD_WI= N_SIZE; + return true; } =20 static ICSState *spapr_ics_get(XICSFabric *dev, int irq) @@ -4589,18 +4591,21 @@ DEFINE_SPAPR_MACHINE(4_1, "4.1", false); /* * pseries-4.0 */ -static void phb_placement_4_0(SpaprMachineState *spapr, uint32_t index, +static bool phb_placement_4_0(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, hwaddr *nv2gpa, hwaddr *nv2atsd, Error **err= p) { - spapr_phb_placement(spapr, index, buid, pio, mmio32, mmio64, n_dma, li= obns, - nv2gpa, nv2atsd, errp); + if (!spapr_phb_placement(spapr, index, buid, pio, mmio32, mmio64, n_dm= a, + liobns, nv2gpa, nv2atsd, errp)) { + return false; + } + *nv2gpa =3D 0; *nv2atsd =3D 0; + return true; } - static void spapr_machine_4_0_class_options(MachineClass *mc) { SpaprMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); @@ -4760,7 +4765,7 @@ DEFINE_SPAPR_MACHINE(2_8, "2.8", false); * pseries-2.7 */ =20 -static void phb_placement_2_7(SpaprMachineState *spapr, uint32_t index, +static bool phb_placement_2_7(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio, hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, @@ -4792,7 +4797,7 @@ static void phb_placement_2_7(SpaprMachineState *spap= r, uint32_t index, if (index > max_index) { error_setg(errp, "\"index\" for PAPR PHB is too large (max %u)", max_index); - return; + return false; } =20 *buid =3D base_buid + index; @@ -4811,6 +4816,7 @@ static void phb_placement_2_7(SpaprMachineState *spap= r, uint32_t index, =20 *nv2gpa =3D 0; *nv2atsd =3D 0; + return true; } =20 static void spapr_machine_2_7_class_options(MachineClass *mc) diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index 2e89e36cfb..b7ced9faeb 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -140,7 +140,7 @@ struct SpaprMachineClass { bool pre_5_1_assoc_refpoints; bool pre_5_2_numa_associativity; =20 - void (*phb_placement)(SpaprMachineState *spapr, uint32_t index, + bool (*phb_placement)(SpaprMachineState *spapr, uint32_t index, uint64_t *buid, hwaddr *pio,=20 hwaddr *mmio32, hwaddr *mmio64, unsigned n_dma, uint32_t *liobns, hwaddr *nv2gpa, --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660716; cv=none; d=zohomail.com; s=zohoarc; b=Kc99rITu6YHoORHY0SBottTIB/3PQs57aVezgVLnDoklC9hmmdKUy8wdNFjp/x9pczpg7+PippTgi4crejOHNHA71xQHygG+AMVYEYiYGLaa+v2YuZmWdSjTVx4RWwlJwFZY4nkUFJoMAxNoz1ERQwar4W5LItncaaC8dovMhb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660716; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xQUQdTFvb/ibN93JmFOhV1yORUgdW1ojV6CSSaQf8dw=; b=hg7AUwTXkcAoEVRAeBpZ6PAHWy3GDaZftC0xx+xtnGoiHEd0JWJiKjVSzal7t3BecKMV2glt4LouHn1qU2vqC0G+3HB9aMYToxf+q1DWtWI4if4sU6tQo90aXF9vK89J1wnO1lkrqscTFrfah76mvK2B+mbXurWhhkQgyhtiFtc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660716631733.2633224051523; Thu, 10 Dec 2020 20:25:16 -0800 (PST) Received: from localhost ([::1]:45288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZzW-0007zs-TO for importer@patchew.org; Thu, 10 Dec 2020 23:25:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqA-0005ef-FJ; Thu, 10 Dec 2020 23:15:34 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:45783 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000j1-R8; Thu, 10 Dec 2020 23:15:34 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb0xFwz9sWg; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=OQC8DXtu1Qm/Hn1u4TG7T1Oemxye5jQb1DbAfIzZWW8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hcICFaHUTJjzIeWfQV3QRIm3QOiLEkAlK+M09+r4BuhByrRtgTWN1ljkoeYtnEr7D szjClYncuxW91Qg5WEe+7cUgHfdjE1+Ma8EYGQRM/QcqeD0wO02g76LsFWKj/rt7nz Nfg372b1oIOCnupOAIXzs7aUOhoTqmaAhE39mOyI= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 06/30] spapr: Do PHB hoplug sanity check at pre-plug Date: Fri, 11 Dec 2020 15:14:43 +1100 Message-Id: <20201211041507.425378-7-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz We currently detect that a PHB index is already in use at plug time. But this can be decteted at pre-plug in order to error out earlier. This allows to pass &error_abort to spapr_drc_attach() and to end up with a plug handler that doesn't need to report errors anymore. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-8-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 90db845cbb..b270172369 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3889,6 +3889,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, SpaprPhbState *sphb =3D SPAPR_PCI_HOST_BRIDGE(dev); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); const unsigned windows_supported =3D spapr_phb_windows_supported(sphb); + SpaprDrc *drc; =20 if (dev->hotplugged && !smc->dr_phb_enabled) { error_setg(errp, "PHB hotplug not supported for this machine"); @@ -3900,6 +3901,12 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotpl= ug_dev, DeviceState *dev, return false; } =20 + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_PHB, sphb->index); + if (drc && drc->dev) { + error_setg(errp, "PHB %d already attached", sphb->index); + return false; + } + /* * This will check that sphb->index doesn't exceed the maximum number = of * PHBs for the current machine type. @@ -3913,8 +3920,7 @@ static bool spapr_phb_pre_plug(HotplugHandler *hotplu= g_dev, DeviceState *dev, errp); } =20 -static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +static void spapr_phb_plug(HotplugHandler *hotplug_dev, DeviceState *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); SpaprMachineClass *smc =3D SPAPR_MACHINE_GET_CLASS(spapr); @@ -3930,9 +3936,8 @@ static void spapr_phb_plug(HotplugHandler *hotplug_de= v, DeviceState *dev, /* hotplug hooks should check it's enabled before getting this far */ assert(drc); =20 - if (!spapr_drc_attach(drc, dev, errp)) { - return; - } + /* spapr_phb_pre_plug() already checked the DRC is attachable */ + spapr_drc_attach(drc, dev, &error_abort); =20 if (hotplugged) { spapr_hotplug_req_add_by_index(drc); @@ -4000,7 +4005,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { - spapr_phb_plug(hotplug_dev, dev, errp); + spapr_phb_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) { spapr_tpm_proxy_plug(hotplug_dev, dev, errp); } --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660500; cv=none; d=zohomail.com; s=zohoarc; b=BgzYVwKrPX6FXe9gqZ2HFy1vGKSCDEgXNFnNxu8TUvdzjmoZHKYqcshhlH0Az9XDXtB7vYtRCRMB8vWPDCwjK8w3bgZWNU05RZeVaw1gHGjTtzQh1g8upJAKPqINEcU9A/bG7kSfbmDQ3c/Sa81qITkgxd8/VDsbcWt3u9wHb2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660500; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q/tBEiOMay9ODuWi0z/2H6o7H/HFQN4dN8s10M9eokM=; b=mvdEvNOzpRgQHrpd11qRCLzLbrU1KmMRGUflpO/xS0myfodWwniDG+ojnj0HgZMrMQPa1wo9VCjWNWtdpzsNqzhKl75AtlGk0Y2pqtDWUeJzIqsNyz3oGJDty40v6XdFwq3jFlYL9OiVFftJR4Hrud2x6bilH4NoBm7scn7YcsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660500321916.5343149429531; Thu, 10 Dec 2020 20:21:40 -0800 (PST) Received: from localhost ([::1]:35522 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZw1-0003ae-NX for importer@patchew.org; Thu, 10 Dec 2020 23:21:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq7-0005bj-Qn; Thu, 10 Dec 2020 23:15:32 -0500 Received: from ozlabs.org ([203.11.71.1]:37189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq5-0000iz-U3; Thu, 10 Dec 2020 23:15:31 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb1X3Qz9sWd; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=dfSUJWYE8sTfFwFiC7FMYXVMBsIlriqEh85KB+TT7Xc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Emc9jhJsQfYg9tOiRkl3opE9cqAwvtMjNM3JFkCCinu/NM7PBAkCXTjd9pnJ5xos/ frPdi2MpUwj1VwsZD49lOEUFFHdrRPrk6MKd8FVoeBIkGbYIcNNza9phWHpqufRMcY tqDhaPXqzL3h9AcuBNEbtdQfzo7/puMYP09RS1b0= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 07/30] spapr: Do TPM proxy hotplug sanity checks at pre-plug Date: Fri, 11 Dec 2020 15:14:44 +1100 Message-Id: <20201211041507.425378-8-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz There can be only one TPM proxy at a time. This is currently checked at plug time. But this can be detected at pre-plug in order to error out earlier. This allows to get rid of error handling in the plug handler. Signed-off-by: Greg Kurz Message-Id: <20201120234208.683521-9-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index b270172369..7e954bc84b 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3974,17 +3974,28 @@ static void spapr_phb_unplug_request(HotplugHandler= *hotplug_dev, } } =20 -static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState = *dev, - Error **errp) +static +bool spapr_tpm_proxy_pre_plug(HotplugHandler *hotplug_dev, DeviceState *de= v, + Error **errp) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); - SpaprTpmProxy *tpm_proxy =3D SPAPR_TPM_PROXY(dev); =20 if (spapr->tpm_proxy !=3D NULL) { error_setg(errp, "Only one TPM proxy can be specified for this mac= hine"); - return; + return false; } =20 + return true; +} + +static void spapr_tpm_proxy_plug(HotplugHandler *hotplug_dev, DeviceState = *dev) +{ + SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); + SpaprTpmProxy *tpm_proxy =3D SPAPR_TPM_PROXY(dev); + + /* Already checked in spapr_tpm_proxy_pre_plug() */ + g_assert(spapr->tpm_proxy =3D=3D NULL); + spapr->tpm_proxy =3D tpm_proxy; } =20 @@ -4007,7 +4018,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { spapr_phb_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) { - spapr_tpm_proxy_plug(hotplug_dev, dev, errp); + spapr_tpm_proxy_plug(hotplug_dev, dev); } } =20 @@ -4070,6 +4081,8 @@ static void spapr_machine_device_pre_plug(HotplugHand= ler *hotplug_dev, spapr_core_pre_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { spapr_phb_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) { + spapr_tpm_proxy_pre_plug(hotplug_dev, dev, errp); } } =20 --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660497; cv=none; d=zohomail.com; s=zohoarc; b=e9qSjx//ODD0HNT3WjwByFgYbCclAeO6Yvr7bZyvoPurKO58cxU/zfOd7LayNa8NNs1bq2J5UQhSxTCWi/dRpDPaELaJeMiE7LzU97ugG/uC6LPG1xUFXZJHC6H3iXJFiOH0Bdpan1SctDgNO+DDKk94OI8yhYYN3yx/lj9jIZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660497; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=S5gBd40iOyJ2dfFNyeORlTVPBqGMI/Xji7EEvurjtFM=; b=A3Zx6ANnrm1m7JtsFnCx1EjXjhEaXmJiJkNKO8nJV2B3jJqI4JK7j39y7zGud6NrT0HtNsIaTKo+G9YynkXZ/TjufDyhqNoODhWkzh+bC/0NAUKLL2Dy99zgL6cqm4oWuYALA4fyHbI3b5MpMVb90mIZDT1fvMc9WFZY+3EjVbQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660497276979.4059060553761; Thu, 10 Dec 2020 20:21:37 -0800 (PST) Received: from localhost ([::1]:35538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZvz-0003ay-Vx for importer@patchew.org; Thu, 10 Dec 2020 23:21:36 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq9-0005db-Rl; Thu, 10 Dec 2020 23:15:33 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:45309 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000j0-Qu; Thu, 10 Dec 2020 23:15:33 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb2JBGz9sWk; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=VCi/RL9feCBuXYp0mnHX3j7nsht0uB1kvqEeq6F3O7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hag8G2gjb8e4tLhgMQ0uDaIDWXqZ+Ou4vS8JBu8wO597OV+T+tS70r907mWYBSdqE KkpbZy5KJc+m9B6hopusbjVgSE8aLcu9DI+L6m9/BSaTbLKzx/JjNr9/3YXqg3IHHA NlQs1yVMYCDldZK5aKp1ltpFZgGCwSoWor0JtzdE= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 08/30] target/ppc: replaced the TODO with LOG_UNIMP and add break for silence warnings Date: Fri, 11 Dec 2020 15:14:45 +1100 Message-Id: <20201211041507.425378-9-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, Euler Robot , Chen Qun , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Chen Qun When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warnin= g: target/ppc/mmu_helper.c: In function =E2=80=98dump_mmu=E2=80=99: target/ppc/mmu_helper.c:1351:12: warning: this statement may fall through [= -Wimplicit-fallthrough=3D] 1351 | if (ppc64_v3_radix(env_archcpu(env))) { | ^ target/ppc/mmu_helper.c:1358:5: note: here 1358 | default: | ^~~~~~~ Use "qemu_log_mask(LOG_UNIMP**)" instead of the TODO comment. And add the break statement to fix it. Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Thomas Huth Acked-by: David Gibson Message-Id: <20201116024810.2415819-8-kuhn.chenqun@huawei.com> Signed-off-by: David Gibson --- target/ppc/mmu_helper.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 064d2e8d13..9f22b66ea9 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -1349,11 +1349,12 @@ void dump_mmu(CPUPPCState *env) break; case POWERPC_MMU_3_00: if (ppc64_v3_radix(env_archcpu(env))) { - /* TODO - Unsupported */ + qemu_log_mask(LOG_UNIMP, "%s: the PPC64 MMU is unsupported\n", + __func__); } else { dump_slb(env_archcpu(env)); - break; } + break; #endif default: qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__); --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660651; cv=none; d=zohomail.com; s=zohoarc; b=YQMtebL5zhPq5mY+CMPFznPCoSC8pe+Qe6vszlWuKPEn2V0r1QSY/S1v4aWmkK5QRnBlG2FhKmXVzZSgnnMdaw+xUt9/jfEvxxr9jN9OcmiGmkgUlFPQlMo+BUdK+qUSp0DvxJsuCEbEKAYS5Rz8FBUP1orYVAEy5EvA6m0i4nU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/mJ6njrCjgY0Vwd1jJd4BZTdM2gy1ZSg4hWOAzHEzQs=; b=QHH6DGF0VcVF0qXxN1f7GVZ5YcLMYp+xn3MtMTH7fKbMeOQMwMXS6DGRM5x6bKaFLxaz16DIxDkc+FTmmY2cdVktlh3o5+kWbilI07YuyM4fS4qYnTF8Ew27nmsJTpl48es2/mLYwvrNeCIxAZsZAdJAxDgQRA+IAsw1S/sMuVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660651185621.9366428648386; Thu, 10 Dec 2020 20:24:11 -0800 (PST) Received: from localhost ([::1]:42418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZyT-0006e0-Op for importer@patchew.org; Thu, 10 Dec 2020 23:24:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33986) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq9-0005dQ-7w; Thu, 10 Dec 2020 23:15:33 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:49135) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000k6-Ov; Thu, 10 Dec 2020 23:15:32 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb34p1z9sWp; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=ZKoVALWI63OBSDQ9zFowxkeqhZA/IacSRGnHPYTa1UE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GxSd5cP3b97UOeG7tssNpk9Ak3Dcu6oB0CffL+qNel82kFfRJx7GolQqVfYGMIQPJ o3CP0VG5xYJf+OCEsAg4wG9O26HxfYoIs3NhDCHImXnaqLJoHYhx3s0B86+kJ5fkj1 kz9rFz8c/ud4ABkS0Iq5IkrRDpX1a4gZbtboNYsk= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 09/30] ppc: Add a missing break for PPC6xx_INPUT_TBEN Date: Fri, 11 Dec 2020 15:14:46 +1100 Message-Id: <20201211041507.425378-10-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, Euler Robot , Chen Qun , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Chen Qun When using -Wimplicit-fallthrough in our CFLAGS, the compiler showed warnin= g: hw/ppc/ppc.c: In function =E2=80=98ppc6xx_set_irq=E2=80=99: hw/ppc/ppc.c:118:16: warning: this statement may fall through [-Wimplicit-f= allthrough=3D] 118 | if (level) { | ^ hw/ppc/ppc.c:123:9: note: here 123 | case PPC6xx_INPUT_INT: | ^~~~ According to the discussion, a break statement needs to be added here. Reported-by: Euler Robot Signed-off-by: Chen Qun Reviewed-by: Thomas Huth Acked-by: David Gibson Message-Id: <20201116024810.2415819-7-kuhn.chenqun@huawei.com> Signed-off-by: David Gibson --- hw/ppc/ppc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 4a11fb1640..1b98272076 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -120,6 +120,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int l= evel) } else { cpu_ppc_tb_stop(env); } + break; case PPC6xx_INPUT_INT: /* Level sensitive - active high */ LOG_IRQ("%s: set the external IRQ state to %d\n", --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660704; cv=none; d=zohomail.com; s=zohoarc; b=f3VyRcoFI5NnOMlIezJGW5j2X0hG+fNT1Bosnsi/77XiM7wx7BpDGNf0DyPxjzsPSRKle0N7zlgDpse7/BZwV/CIj3escG9+echm6eH/4C5jHz5YVByrUSdX85vZqANzeFU3hFys0CUdAdnYVCqQQdV9vlMfMa6N+uImGWDw9M8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660704; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=idyhIpy1asn3HELxGcXGXDP4TSbxAVplMsIwuMvOYwo=; b=kmxDqKFTMq8y3yEJrNLzjll40Y5nfgBm2uWKRYL7Rkk7IThrwX1mfvHTPeITp+wF3F6iH16VlY9NKbjRPJqT3NnZ//8hOLAnY8kd+Gfly/KgEdzEttBTaAl8yr7LEDvbRWINkJAWbYsBjv43LBee/m9tSdjHWxx8GZVfLBThH6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160766070454714.800461368224319; Thu, 10 Dec 2020 20:25:04 -0800 (PST) Received: from localhost ([::1]:44414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZzL-0007cq-97 for importer@patchew.org; Thu, 10 Dec 2020 23:25:03 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq9-0005d8-3z; Thu, 10 Dec 2020 23:15:33 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:35153 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000jw-LK; Thu, 10 Dec 2020 23:15:32 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb3szPz9sWm; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=YJ4Jigd9pqVM/AMHgPpnrIhzspdOwtzbr2NR178Pci8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W9rGj2p6Si0IW5H3xpPSDtGnMuWPq/0MxaTwXW2Yytou6ZSRM0Xhh9H9kugPzR+0j 3tt6hLAUVamNTetGjKhJAHRDmu3A0obxuqI9ubaU59i68uxFgaMSdM/IRoAKG7H9CH A/GFEz4KXWbHMgTg2rD18/ulA2DI8bZeVZ9EBIRI= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 10/30] ppc/translate: Fix unordered f64/f128 comparisons Date: Fri, 11 Dec 2020 15:14:47 +1100 Message-Id: <20201211041507.425378-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LemonBoy , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LemonBoy According to the PowerISA v3.1 reference, Table 68 "Actions for xscmpudp - Part 1: Compare Unordered", whenever one of the two operands is a NaN the SO bit is set while the other three bits are cleared. Apply the same change to xscmpuqp. The respective ordered counterparts are unaffected. Signed-off-by: Giuseppe Musacchio Message-Id: <20201112230130.65262-2-thatlemon@gmail.com> Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 32a9a8a0f8..6d3648f5b1 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -2479,13 +2479,11 @@ void helper_##op(CPUPPCState *env, uint32_t opcode,= \ if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) || \ float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) { \ vxsnan_flag =3D true; = \ - cc =3D CRF_SO; = \ if (fpscr_ve =3D=3D 0 && ordered) { = \ vxvc_flag =3D true; = \ } \ } else if (float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) || \ float64_is_quiet_nan(xb->VsrD(0), &env->fp_status)) { \ - cc =3D CRF_SO; = \ if (ordered) { \ vxvc_flag =3D true; = \ } \ @@ -2497,12 +2495,19 @@ void helper_##op(CPUPPCState *env, uint32_t opcode,= \ float_invalid_op_vxvc(env, 0, GETPC()); \ } \ \ - if (float64_lt(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) { \ + switch (float64_compare(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) {\ + case float_relation_less: \ cc |=3D CRF_LT; = \ - } else if (!float64_le(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) { \ - cc |=3D CRF_GT; = \ - } else { \ + break; \ + case float_relation_equal: \ cc |=3D CRF_EQ; = \ + break; \ + case float_relation_greater: \ + cc |=3D CRF_GT; = \ + break; \ + case float_relation_unordered: \ + cc |=3D CRF_SO; = \ + break; \ } \ \ env->fpscr &=3D ~FP_FPCC; = \ @@ -2545,12 +2550,19 @@ void helper_##op(CPUPPCState *env, uint32_t opcode,= \ float_invalid_op_vxvc(env, 0, GETPC()); \ } \ \ - if (float128_lt(xa->f128, xb->f128, &env->fp_status)) { \ + switch (float128_compare(xa->f128, xb->f128, &env->fp_status)) { \ + case float_relation_less: \ cc |=3D CRF_LT; \ - } else if (!float128_le(xa->f128, xb->f128, &env->fp_status)) { \ - cc |=3D CRF_GT; \ - } else { \ + break; \ + case float_relation_equal: \ cc |=3D CRF_EQ; \ + break; \ + case float_relation_greater: \ + cc |=3D CRF_GT; \ + break; \ + case float_relation_unordered: \ + cc |=3D CRF_SO; \ + break; \ } \ \ env->fpscr &=3D ~FP_FPCC; \ --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660661; cv=none; d=zohomail.com; s=zohoarc; b=MHnhuvD59zHrtLizXqoM3gVboDgL4DRi/aqzu9MSLsDroZP6ZO00+SZQSQWm9wcvOstWJoqvq0mGja4UaOYTbnysGg4we6/obVrbcQwi+Er7B8nz549Q8ENn4xZ6YG6fWf2zhqq7Z77ok2b+j3MR8iicEjOK4pffu3FjgvexfGU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660661; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=46WTtW1nOK+MWeySqQHN2zg8KkbumDXYB2L3/t919Ws=; b=K7EmyNavxuomeGNgmwQByVQvjecnnm/XpipAEkbnNs2Ripjq8sl7CKdKd6rVrXFne+qhxIuicgjvKiwXUNx7Lmv6+kodkPPWhez3GHt4I8REv130bb0cM8HRxst7kY0tm0M9UM09QKv+tVImQVcGmUzVi3S2MN5FEXPIq6VPnuY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660661970754.9716305293766; Thu, 10 Dec 2020 20:24:21 -0800 (PST) Received: from localhost ([::1]:42894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knZye-0006s5-LB for importer@patchew.org; Thu, 10 Dec 2020 23:24:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq9-0005dY-RY; Thu, 10 Dec 2020 23:15:33 -0500 Received: from ozlabs.org ([203.11.71.1]:38183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000kB-KN; Thu, 10 Dec 2020 23:15:33 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb4wjYz9sWr; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=17cTpbz/QhNvG4fokN1yrwIa9P/Ftht4ag1uIyHuKAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/2H3BO5l+oQb7X0U2jwnzAjUPnfwGwhvncBU9ZHE02hzHpYr0NdGCOpbmiLg9nzb GfuBGKj3tKlhO4QgPy9agscPFIyVMlcUuHfGTMH4XxcJvC7sHRfR1MDkuz2qIrg7kx DIYW6ExfVlStFCK0nKUYZgh7txLbKeKp0hbZ44mU= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 11/30] ppc/translate: Turn the helper macros into functions Date: Fri, 11 Dec 2020 15:14:48 +1100 Message-Id: <20201211041507.425378-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LemonBoy , Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LemonBoy Suggested-by: Richard Henderson Signed-off-by: Giuseppe Musacchio Reviewed-by: Richard Henderson Message-Id: <20201112230130.65262-3-thatlemon@gmail.com> Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 228 ++++++++++++++++++++++------------------ 1 file changed, 123 insertions(+), 105 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 6d3648f5b1..34f5bc1f3c 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -2467,113 +2467,131 @@ void helper_xscmpexpqp(CPUPPCState *env, uint32_t= opcode, do_float_check_status(env, GETPC()); } =20 -#define VSX_SCALAR_CMP(op, ordered) \ -void helper_##op(CPUPPCState *env, uint32_t opcode, \ - ppc_vsr_t *xa, ppc_vsr_t *xb) \ -{ \ - uint32_t cc =3D 0; = \ - bool vxsnan_flag =3D false, vxvc_flag =3D false; = \ - \ - helper_reset_fpstatus(env); \ - \ - if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) || \ - float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) { \ - vxsnan_flag =3D true; = \ - if (fpscr_ve =3D=3D 0 && ordered) { = \ - vxvc_flag =3D true; = \ - } \ - } else if (float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) || \ - float64_is_quiet_nan(xb->VsrD(0), &env->fp_status)) { \ - if (ordered) { \ - vxvc_flag =3D true; = \ - } \ - } \ - if (vxsnan_flag) { \ - float_invalid_op_vxsnan(env, GETPC()); \ - } \ - if (vxvc_flag) { \ - float_invalid_op_vxvc(env, 0, GETPC()); \ - } \ - \ - switch (float64_compare(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) {\ - case float_relation_less: \ - cc |=3D CRF_LT; = \ - break; \ - case float_relation_equal: \ - cc |=3D CRF_EQ; = \ - break; \ - case float_relation_greater: \ - cc |=3D CRF_GT; = \ - break; \ - case float_relation_unordered: \ - cc |=3D CRF_SO; = \ - break; \ - } \ - \ - env->fpscr &=3D ~FP_FPCC; = \ - env->fpscr |=3D cc << FPSCR_FPCC; = \ - env->crf[BF(opcode)] =3D cc; = \ - \ - do_float_check_status(env, GETPC()); \ -} - -VSX_SCALAR_CMP(xscmpodp, 1) -VSX_SCALAR_CMP(xscmpudp, 0) - -#define VSX_SCALAR_CMPQ(op, ordered) \ -void helper_##op(CPUPPCState *env, uint32_t opcode, \ - ppc_vsr_t *xa, ppc_vsr_t *xb) \ -{ \ - uint32_t cc =3D 0; \ - bool vxsnan_flag =3D false, vxvc_flag =3D false; = \ - \ - helper_reset_fpstatus(env); \ - \ - if (float128_is_signaling_nan(xa->f128, &env->fp_status) || \ - float128_is_signaling_nan(xb->f128, &env->fp_status)) { \ - vxsnan_flag =3D true; \ - cc =3D CRF_SO; \ - if (fpscr_ve =3D=3D 0 && ordered) { = \ - vxvc_flag =3D true; \ - } \ - } else if (float128_is_quiet_nan(xa->f128, &env->fp_status) || \ - float128_is_quiet_nan(xb->f128, &env->fp_status)) { \ - cc =3D CRF_SO; \ - if (ordered) { \ - vxvc_flag =3D true; \ - } \ - } \ - if (vxsnan_flag) { \ - float_invalid_op_vxsnan(env, GETPC()); \ - } \ - if (vxvc_flag) { \ - float_invalid_op_vxvc(env, 0, GETPC()); \ - } \ - \ - switch (float128_compare(xa->f128, xb->f128, &env->fp_status)) { \ - case float_relation_less: \ - cc |=3D CRF_LT; \ - break; \ - case float_relation_equal: \ - cc |=3D CRF_EQ; \ - break; \ - case float_relation_greater: \ - cc |=3D CRF_GT; \ - break; \ - case float_relation_unordered: \ - cc |=3D CRF_SO; \ - break; \ - } \ - \ - env->fpscr &=3D ~FP_FPCC; \ - env->fpscr |=3D cc << FPSCR_FPCC; \ - env->crf[BF(opcode)] =3D cc; \ - \ - do_float_check_status(env, GETPC()); \ +static inline void do_scalar_cmp(CPUPPCState *env, ppc_vsr_t *xa, ppc_vsr_= t *xb, + int crf_idx, bool ordered) +{ + uint32_t cc; + bool vxsnan_flag =3D false, vxvc_flag =3D false; + + helper_reset_fpstatus(env); + + if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) || + float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) { + vxsnan_flag =3D true; + if (fpscr_ve =3D=3D 0 && ordered) { + vxvc_flag =3D true; + } + } else if (float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) || + float64_is_quiet_nan(xb->VsrD(0), &env->fp_status)) { + if (ordered) { + vxvc_flag =3D true; + } + } + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + + switch (float64_compare(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) { + case float_relation_less: + cc =3D CRF_LT; + break; + case float_relation_equal: + cc =3D CRF_EQ; + break; + case float_relation_greater: + cc =3D CRF_GT; + break; + case float_relation_unordered: + cc =3D CRF_SO; + break; + default: + g_assert_not_reached(); + } + + env->fpscr &=3D ~FP_FPCC; + env->fpscr |=3D cc << FPSCR_FPCC; + env->crf[crf_idx] =3D cc; + + do_float_check_status(env, GETPC()); +} + +void helper_xscmpodp(CPUPPCState *env, uint32_t opcode, ppc_vsr_t *xa, + ppc_vsr_t *xb) +{ + do_scalar_cmp(env, xa, xb, BF(opcode), true); +} + +void helper_xscmpudp(CPUPPCState *env, uint32_t opcode, ppc_vsr_t *xa, + ppc_vsr_t *xb) +{ + do_scalar_cmp(env, xa, xb, BF(opcode), false); +} + +static inline void do_scalar_cmpq(CPUPPCState *env, ppc_vsr_t *xa, + ppc_vsr_t *xb, int crf_idx, bool ordered) +{ + uint32_t cc; + bool vxsnan_flag =3D false, vxvc_flag =3D false; + + helper_reset_fpstatus(env); + + if (float128_is_signaling_nan(xa->f128, &env->fp_status) || + float128_is_signaling_nan(xb->f128, &env->fp_status)) { + vxsnan_flag =3D true; + if (fpscr_ve =3D=3D 0 && ordered) { + vxvc_flag =3D true; + } + } else if (float128_is_quiet_nan(xa->f128, &env->fp_status) || + float128_is_quiet_nan(xb->f128, &env->fp_status)) { + if (ordered) { + vxvc_flag =3D true; + } + } + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + + switch (float128_compare(xa->f128, xb->f128, &env->fp_status)) { + case float_relation_less: + cc =3D CRF_LT; + break; + case float_relation_equal: + cc =3D CRF_EQ; + break; + case float_relation_greater: + cc =3D CRF_GT; + break; + case float_relation_unordered: + cc =3D CRF_SO; + break; + default: + g_assert_not_reached(); + } + + env->fpscr &=3D ~FP_FPCC; + env->fpscr |=3D cc << FPSCR_FPCC; + env->crf[crf_idx] =3D cc; + + do_float_check_status(env, GETPC()); } =20 -VSX_SCALAR_CMPQ(xscmpoqp, 1) -VSX_SCALAR_CMPQ(xscmpuqp, 0) +void helper_xscmpoqp(CPUPPCState *env, uint32_t opcode, ppc_vsr_t *xa, + ppc_vsr_t *xb) +{ + do_scalar_cmpq(env, xa, xb, BF(opcode), true); +} + +void helper_xscmpuqp(CPUPPCState *env, uint32_t opcode, ppc_vsr_t *xa, + ppc_vsr_t *xb) +{ + do_scalar_cmpq(env, xa, xb, BF(opcode), false); +} =20 /* * VSX_MAX_MIN - VSX floating point maximum/minimum --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660842; cv=none; d=zohomail.com; s=zohoarc; b=jBSYeBcKYk9tluD7UyrtKFQdGc0tqLrpR2THnYQ3YaZe46bUo64mF5BsE2sypG9NQcksMcn4f1goV8+LruuM8JH8ULXjTJ3kvx6Iq6vj2ckgK71OgnAZMwIFuoBLWid/kjpCB8MMf8xOmK8cAqRnYMqI+ezayoDiVvGM5IiKHxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660842; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cV7mgyRLxAmAHNb4NoodJNt4qvWL3A0XwYczox00vrE=; b=iYH9diS2Oal1Du/oVOvvycY3TsmnMPBHvaPaonMk/ltCzFcqDPPZ7oPMq+FPtYsRYVmjhFJ//t7DTkH55IdAa8347sq2/hu4Yn8WeTj27RhVmkDV6tLOedkJZH8mC6e4SIB8ounbdzCCnZfw3qWGREDv2YGCe5NT+nsGvtqkDCM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16076608421761000.9402448634942; Thu, 10 Dec 2020 20:27:22 -0800 (PST) Received: from localhost ([::1]:50674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna1Y-00020b-OR for importer@patchew.org; Thu, 10 Dec 2020 23:27:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:33998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq9-0005da-S4; Thu, 10 Dec 2020 23:15:33 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:33781 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZq6-0000kG-Qf; Thu, 10 Dec 2020 23:15:33 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrb6qccz9sWw; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660111; bh=O7Iod8ha/UKbiX0jn4dxF+eTwrAB9Z9FYv3hOWjC50A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DYpyzEWqnAv5HO8+Jda/h3PLyW0r5Zc4hWk3OlB4/eES93iQfU6RskC51KzRrjnbP 9w2Mh/neYzpOxZD9wbJZyqa8G9aDQ0rfQC1Sb9x51lnz1qLCvNRc+wLwjkA4PWP4Po jKPsZIJrBO8ebSTZW1mzXbON1pjb1wmFXPxbxFxg= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 12/30] ppc/translate: Delay NaN checking after comparison Date: Fri, 11 Dec 2020 15:14:49 +1100 Message-Id: <20201211041507.425378-13-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LemonBoy , Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LemonBoy Since we always perform a comparison between the two operands avoid checking for NaN unless the result states they're unordered. Suggested-by: Richard Henderson Signed-off-by: Giuseppe Musacchio Reviewed-by: Richard Henderson Message-Id: <20201112230130.65262-4-thatlemon@gmail.com> Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 80 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 34f5bc1f3c..f5a4be595a 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -2475,25 +2475,6 @@ static inline void do_scalar_cmp(CPUPPCState *env, p= pc_vsr_t *xa, ppc_vsr_t *xb, =20 helper_reset_fpstatus(env); =20 - if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) || - float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) { - vxsnan_flag =3D true; - if (fpscr_ve =3D=3D 0 && ordered) { - vxvc_flag =3D true; - } - } else if (float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) || - float64_is_quiet_nan(xb->VsrD(0), &env->fp_status)) { - if (ordered) { - vxvc_flag =3D true; - } - } - if (vxsnan_flag) { - float_invalid_op_vxsnan(env, GETPC()); - } - if (vxvc_flag) { - float_invalid_op_vxvc(env, 0, GETPC()); - } - switch (float64_compare(xa->VsrD(0), xb->VsrD(0), &env->fp_status)) { case float_relation_less: cc =3D CRF_LT; @@ -2506,6 +2487,27 @@ static inline void do_scalar_cmp(CPUPPCState *env, p= pc_vsr_t *xa, ppc_vsr_t *xb, break; case float_relation_unordered: cc =3D CRF_SO; + + if (float64_is_signaling_nan(xa->VsrD(0), &env->fp_status) || + float64_is_signaling_nan(xb->VsrD(0), &env->fp_status)) { + vxsnan_flag =3D true; + if (fpscr_ve =3D=3D 0 && ordered) { + vxvc_flag =3D true; + } + } else if (float64_is_quiet_nan(xa->VsrD(0), &env->fp_status) || + float64_is_quiet_nan(xb->VsrD(0), &env->fp_status)) { + if (ordered) { + vxvc_flag =3D true; + } + } + + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + break; default: g_assert_not_reached(); @@ -2538,25 +2540,6 @@ static inline void do_scalar_cmpq(CPUPPCState *env, = ppc_vsr_t *xa, =20 helper_reset_fpstatus(env); =20 - if (float128_is_signaling_nan(xa->f128, &env->fp_status) || - float128_is_signaling_nan(xb->f128, &env->fp_status)) { - vxsnan_flag =3D true; - if (fpscr_ve =3D=3D 0 && ordered) { - vxvc_flag =3D true; - } - } else if (float128_is_quiet_nan(xa->f128, &env->fp_status) || - float128_is_quiet_nan(xb->f128, &env->fp_status)) { - if (ordered) { - vxvc_flag =3D true; - } - } - if (vxsnan_flag) { - float_invalid_op_vxsnan(env, GETPC()); - } - if (vxvc_flag) { - float_invalid_op_vxvc(env, 0, GETPC()); - } - switch (float128_compare(xa->f128, xb->f128, &env->fp_status)) { case float_relation_less: cc =3D CRF_LT; @@ -2569,6 +2552,27 @@ static inline void do_scalar_cmpq(CPUPPCState *env, = ppc_vsr_t *xa, break; case float_relation_unordered: cc =3D CRF_SO; + + if (float128_is_signaling_nan(xa->f128, &env->fp_status) || + float128_is_signaling_nan(xb->f128, &env->fp_status)) { + vxsnan_flag =3D true; + if (fpscr_ve =3D=3D 0 && ordered) { + vxvc_flag =3D true; + } + } else if (float128_is_quiet_nan(xa->f128, &env->fp_status) || + float128_is_quiet_nan(xb->f128, &env->fp_status)) { + if (ordered) { + vxvc_flag =3D true; + } + } + + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + break; default: g_assert_not_reached(); --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660942; cv=none; d=zohomail.com; s=zohoarc; b=DzbuIvLeF7R9EHYVfkwd3TvknM0Tk1aA+vqf4Vmt4eGfkj1NOEibUihjAGt3TN6j2dKHrSHd9kj8XUVu3GK8dpBk+88Yo5HbA+5BjdlEDJMoaM/8eMxUG83M9luO+kPFh2RRyoiI2QFBx3bAbuWNk/X0zJYPa6nEYMqAPeQZDqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660942; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vFLAfxXJC8VH3joAXXNixT60bDcNyvp5Ys86cYJ6gmE=; b=a4YSAWL0AEzfz7P5/nygjHj6dqUah3pX2v6Cwo53S8qQhuqTW4TSxj4Zq9qKhwH3dqn3S/SNLhnTeywYKjOecpbzgVM++F6C8DJvnic3lJGCnadm/hQW+QEk2wrOx9JPuAxA4iH84pHX6WALbtNsLPveVy8B/xIDm3koPFlUmLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160766094204353.436035593159545; Thu, 10 Dec 2020 20:29:02 -0800 (PST) Received: from localhost ([::1]:53282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna3A-00038e-FC for importer@patchew.org; Thu, 10 Dec 2020 23:29:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqB-0005gE-Rl; Thu, 10 Dec 2020 23:15:36 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:35219 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqA-0000ni-5N; Thu, 10 Dec 2020 23:15:35 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc0V7Cz9sWt; Fri, 11 Dec 2020 15:15:11 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=PY63Yfb95gZfHPkDRqTgk6oSSfAef8g/nYcMHoJai1Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GbhimUGJZcIHHKtJatoe/CLXtmDA3cIaNcQaIK9kHuXMACNWYyg1IpEEHLZqFaFSH 8gb8qwWxUTkDTeWVs2AS1V8PHhk4lkiiwwDiWMPkqWh5f4Z1VMusQqQ9i7ObrgeJqi FCkF3PtjInDJnYDUxuf/r11l2POPjKhSJQihhB20= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 13/30] ppc/translate: Raise exceptions after setting the cc Date: Fri, 11 Dec 2020 15:14:50 +1100 Message-Id: <20201211041507.425378-14-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LemonBoy , Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LemonBoy The PowerISA reference states that the comparison operators update the FPCC, CR and FPSCR and, if VE=3D1, jump to the exception handler. Moving the exception-triggering code after the CC update sequence solves the problem. Signed-off-by: Giuseppe Musacchio Reviewed-by: Richard Henderson Message-Id: <20201112230130.65262-5-thatlemon@gmail.com> Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index f5a4be595a..44315fca0b 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -2501,13 +2501,6 @@ static inline void do_scalar_cmp(CPUPPCState *env, p= pc_vsr_t *xa, ppc_vsr_t *xb, } } =20 - if (vxsnan_flag) { - float_invalid_op_vxsnan(env, GETPC()); - } - if (vxvc_flag) { - float_invalid_op_vxvc(env, 0, GETPC()); - } - break; default: g_assert_not_reached(); @@ -2517,6 +2510,13 @@ static inline void do_scalar_cmp(CPUPPCState *env, p= pc_vsr_t *xa, ppc_vsr_t *xb, env->fpscr |=3D cc << FPSCR_FPCC; env->crf[crf_idx] =3D cc; =20 + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + do_float_check_status(env, GETPC()); } =20 @@ -2566,13 +2566,6 @@ static inline void do_scalar_cmpq(CPUPPCState *env, = ppc_vsr_t *xa, } } =20 - if (vxsnan_flag) { - float_invalid_op_vxsnan(env, GETPC()); - } - if (vxvc_flag) { - float_invalid_op_vxvc(env, 0, GETPC()); - } - break; default: g_assert_not_reached(); @@ -2582,6 +2575,13 @@ static inline void do_scalar_cmpq(CPUPPCState *env, = ppc_vsr_t *xa, env->fpscr |=3D cc << FPSCR_FPCC; env->crf[crf_idx] =3D cc; =20 + if (vxsnan_flag) { + float_invalid_op_vxsnan(env, GETPC()); + } + if (vxvc_flag) { + float_invalid_op_vxvc(env, 0, GETPC()); + } + do_float_check_status(env, GETPC()); } =20 --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660950; cv=none; d=zohomail.com; s=zohoarc; b=Qd4elCSt+zGq9lX6thT5ORpXDGibVd+q9Fjlo5Sp7BtBcC71ySytstD+JyI3ohEvMkH9scaw710mhMk4c512/j1504BHlY9XIJbDe9QBY1wJDkkzNVDJQgo3vO9gVYc6sprDsh0gImEaWqsnVv47BJqGnD1KLeMTmb2ZZIDY/vA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660950; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q1KaQSlGpxY4sRpD+MvzJuhiB4AwWuQjfS7vzAZ+6rU=; b=KTLMGq+avcLeKZXMyjCjT/hP28yXoHuwQwudL6POOgWgg9XTknzZd1OnEnDsIRjTexR/qbdxOaTAuKGXXfv/q2N+BDsE/G5t9coaIovJCoL2Lu5Ss/2kw+ZWtVWoG9t/1TK6SLuOhv/R8HVKePvDBGz/tJR8LkHTQWlr7Jp2aJ4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660950553825.1678434723555; Thu, 10 Dec 2020 20:29:10 -0800 (PST) Received: from localhost ([::1]:54106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna3J-0003X9-1A for importer@patchew.org; Thu, 10 Dec 2020 23:29:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqC-0005gK-4C; Thu, 10 Dec 2020 23:15:36 -0500 Received: from ozlabs.org ([203.11.71.1]:35405) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqA-0000no-DI; Thu, 10 Dec 2020 23:15:35 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc0z0Wz9sWx; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=sdlVB+emes7vJuse7GtNvJdXbpvkFx/28Hlg5MBiQf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AhJWCRUnKEieEZVuTORwHan4OAEf5rgpmgBS8iQISgTI07wEBpPIBzRaFh0D2brPY Mc1sOasnxqcEjFEfxz4CKrNx/50vTs1mgpofeETy4BpIo7qCCyUH1lsxXyJX0w/4Hk Sc8kSXRUPloTHCaAiwCbuHvbRddb1JsIZ0GtO4dY= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 14/30] ppc/translate: Rewrite gen_lxvdsx to use gvec primitives Date: Fri, 11 Dec 2020 15:14:51 +1100 Message-Id: <20201211041507.425378-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: LemonBoy , Richard Henderson , qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: LemonBoy Make the implementation match the lxvwsx one. The code is now shorter smaller and potentially faster as the translation will use the host SIMD capabilities if available. No functional change. Signed-off-by: Giuseppe Musacchio Message-Id: Reviewed-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/translate/vsx-impl.c.inc | 46 ++++++++++++++--------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/target/ppc/translate/vsx-impl.c.inc b/target/ppc/translate/vsx= -impl.c.inc index 075f063e98..b817d31260 100644 --- a/target/ppc/translate/vsx-impl.c.inc +++ b/target/ppc/translate/vsx-impl.c.inc @@ -75,29 +75,6 @@ static void gen_lxvd2x(DisasContext *ctx) tcg_temp_free_i64(t0); } =20 -static void gen_lxvdsx(DisasContext *ctx) -{ - TCGv EA; - TCGv_i64 t0; - TCGv_i64 t1; - if (unlikely(!ctx->vsx_enabled)) { - gen_exception(ctx, POWERPC_EXCP_VSXU); - return; - } - t0 =3D tcg_temp_new_i64(); - t1 =3D tcg_temp_new_i64(); - gen_set_access_type(ctx, ACCESS_INT); - EA =3D tcg_temp_new(); - gen_addr_reg_index(ctx, EA); - gen_qemu_ld64_i64(ctx, t0, EA); - set_cpu_vsrh(xT(ctx->opcode), t0); - tcg_gen_mov_i64(t1, t0); - set_cpu_vsrl(xT(ctx->opcode), t1); - tcg_temp_free(EA); - tcg_temp_free_i64(t0); - tcg_temp_free_i64(t1); -} - static void gen_lxvw4x(DisasContext *ctx) { TCGv EA; @@ -169,6 +146,29 @@ static void gen_lxvwsx(DisasContext *ctx) tcg_temp_free_i32(data); } =20 +static void gen_lxvdsx(DisasContext *ctx) +{ + TCGv EA; + TCGv_i64 data; + + if (unlikely(!ctx->vsx_enabled)) { + gen_exception(ctx, POWERPC_EXCP_VSXU); + return; + } + + gen_set_access_type(ctx, ACCESS_INT); + EA =3D tcg_temp_new(); + + gen_addr_reg_index(ctx, EA); + + data =3D tcg_temp_new_i64(); + tcg_gen_qemu_ld_i64(data, EA, ctx->mem_idx, MO_TEQ); + tcg_gen_gvec_dup_i64(MO_Q, vsr_full_offset(xT(ctx->opcode)), 16, 16, d= ata); + + tcg_temp_free(EA); + tcg_temp_free_i64(data); +} + static void gen_bswap16x8(TCGv_i64 outh, TCGv_i64 outl, TCGv_i64 inh, TCGv_i64 inl) { --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661109; cv=none; d=zohomail.com; s=zohoarc; b=apBLeS2k4Afd08FCTjONCqVDqcYXgriFbyiYz3StXPKD/fiziMuxgY0yjtRYTwp8e550oZYWtD7U5N53GwRbXT2IO0XUnBalDpMTVe+kAzlNdIj5fDJYWJUv8Qhf6L+Ts++/Z7FMki0Ue1X7hcLKZy0+goeJz1ms2sD6rPXXA44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661109; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t+lkfAGyKiaXsjijXbYWQDFZe9owm/s6SRQsMbvcXUI=; b=LuFfwAvGl8r7cY0AP2EpWZztquLe32dmFps07J8uQzaCKPt9FpaqZnB+Ddedu0gbsFDIc4d8ID8PyBLihCbENSUwRoqAWJlPBisGj6/V9zZ066iyME7IvsxXEX9p/T4NDUlcSd4+MnWEn9U7LF97nugtK6iSh2QrZME5+I9oofA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661109880592.0852065799378; Thu, 10 Dec 2020 20:31:49 -0800 (PST) Received: from localhost ([::1]:58946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna5s-0005gb-EY for importer@patchew.org; Thu, 10 Dec 2020 23:31:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqD-0005iH-GB; Thu, 10 Dec 2020 23:15:37 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:52461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqB-0000pP-Ot; Thu, 10 Dec 2020 23:15:37 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc2fVyz9sX3; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=uVIRb7hIYJHDnKhaMscExvDEx5rkEohyvyF3nRN8iYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oUcAnMfkhIXRNwEk2uJt3EK+px3Pqr0Xp777XGk2p1qlFjEW7JTLFBpBXdGqEKbh/ TpvH8OM34yBdXD3f8CHvGW86v2mq1zg/axcK9v2wTqwNyUgEwrivdv608KOtIeYiZI 80DRUQ8mt6DsuHce0L6TuEFQbh5VvATmkAAYQ1bw= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 15/30] hw/ppc/spapr_tpm_proxy: Fix hexadecimal format string specifier Date: Fri, 11 Dec 2020 15:14:52 +1100 Message-Id: <20201211041507.425378-16-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, groug@kaod.org, Dov Murik , qemu-ppc@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 The '%u' conversion specifier is for decimal notation. When prefixing a format with '0x', we want the hexadecimal specifier ('%x'). Inspired-by: Dov Murik Signed-off-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20201103112558.2554390-4-philmd@redhat.com> Reviewed-by: Greg Kurz Signed-off-by: David Gibson --- hw/ppc/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/trace-events b/hw/ppc/trace-events index dcc06d49b5..6d8d095aa2 100644 --- a/hw/ppc/trace-events +++ b/hw/ppc/trace-events @@ -19,7 +19,7 @@ spapr_update_dt_failed_size(unsigned cbold, unsigned cbne= w, unsigned magic) "Old spapr_update_dt_failed_check(unsigned cbold, unsigned cbnew, unsigned magi= c) "Old blob %u bytes, new blob %u bytes, magic 0x%x" =20 # spapr_tpm_proxy.c -spapr_h_tpm_comm(const char *device_path, uint64_t operation) "tpm_device_= path=3D%s operation=3D0x%"PRIu64 +spapr_h_tpm_comm(const char *device_path, uint64_t operation) "tpm_device_= path=3D%s operation=3D0x%"PRIx64 spapr_tpm_execute(uint64_t data_in, uint64_t data_in_sz, uint64_t data_out= , uint64_t data_out_sz) "data_in=3D0x%"PRIx64", data_in_sz=3D%"PRIu64", dat= a_out=3D0x%"PRIx64", data_out_sz=3D%"PRIu64 =20 # spapr_iommu.c --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607660946; cv=none; d=zohomail.com; s=zohoarc; b=CBRvray7z3k5AOiZUuDBJ4tEepHvDALj0ulRloxH0CdfKCkLbx31gG8VpLjII60l5doUrct/l01LOJ8kae5lar0UCpSxYVmH2BpNTExCPq7yI7iYLTJX3b3aWQ9sZcDW5JcXbx24QJn1ba8yMSU8b/YDVh1M9Jv24QOr89HRfeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607660946; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1968ahsAuSe1S0AfzWXjQ+VHM/LnKAnlnGaR6vQNBcc=; b=KxSFifepUIWHhjmGln0rRqo/naKe0Qv5vB3Ugak1DxRJZu0WDvg03wMOusbgnTtYkxTODRcelzZAOzQAoFdL+ipluI3h53GPSpd0KhN8NDAE2noWugeOmeTLDWQhRJoIYq/8RzWIv9v12x72Kz+MzWEfD42xnVQkFtkA/wng2bs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607660946197588.3174337360753; Thu, 10 Dec 2020 20:29:06 -0800 (PST) Received: from localhost ([::1]:53666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna3E-0003Ix-Oo for importer@patchew.org; Thu, 10 Dec 2020 23:29:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34068) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqF-0005lu-1k; Thu, 10 Dec 2020 23:15:39 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:56599 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqB-0000pj-SV; Thu, 10 Dec 2020 23:15:38 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc3Lh0z9sWy; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=IXziBW6A0+bXO+pr1Qs2Pbi1BTgRioKNIyBix/3OlWU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A/T2deZtkOD2HJhO/Wf6rKaNyjrbyLCG/77ilx+Z4kJS11bN4+RdsG/VRBTHdHgUt zpEajKM1EFuIdyT5BGwcJ0zm8cuELlG2LSJDvrFPrSY4plnnsVIGrRFvtHh3+Kc31u aC2gkR7u+2exCvzgiK82GUDGX0UVPnNeM2VjU7GE= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 16/30] xive: Add trace events Date: Fri, 11 Dec 2020 15:14:53 +1100 Message-Id: <20201211041507.425378-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: C=C3=A9dric Le Goater I have been keeping those logging messages in an ugly form for while. Make them clean ! Beware not to activate all of them, this is really verbose. Signed-off-by: C=C3=A9dric Le Goater Message-Id: <20201123163717.1368450-1-clg@kaod.org> Signed-off-by: David Gibson --- hw/intc/spapr_xive.c | 33 +++++++++++++++++++++++++++++++++ hw/intc/spapr_xive_kvm.c | 5 +++++ hw/intc/trace-events | 33 +++++++++++++++++++++++++++++++++ hw/intc/xive.c | 40 +++++++++++++++++++++++++++++++++++++--- 4 files changed, 108 insertions(+), 3 deletions(-) diff --git a/hw/intc/spapr_xive.c b/hw/intc/spapr_xive.c index 60e0d5769d..caedd312d7 100644 --- a/hw/intc/spapr_xive.c +++ b/hw/intc/spapr_xive.c @@ -24,6 +24,7 @@ #include "hw/ppc/xive.h" #include "hw/ppc/xive_regs.h" #include "hw/qdev-properties.h" +#include "trace.h" =20 /* * XIVE Virtualization Controller BAR and Thread Managment BAR that we @@ -556,6 +557,8 @@ static int spapr_xive_claim_irq(SpaprInterruptControlle= r *intc, int lisn, =20 assert(lisn < xive->nr_irqs); =20 + trace_spapr_xive_claim_irq(lisn, lsi); + if (xive_eas_is_valid(&xive->eat[lisn])) { error_setg(errp, "IRQ %d is not free", lisn); return -EBUSY; @@ -581,6 +584,8 @@ static void spapr_xive_free_irq(SpaprInterruptControlle= r *intc, int lisn) SpaprXive *xive =3D SPAPR_XIVE(intc); assert(lisn < xive->nr_irqs); =20 + trace_spapr_xive_free_irq(lisn); + xive->eat[lisn].w &=3D cpu_to_be64(~EAS_VALID); } =20 @@ -647,6 +652,8 @@ static void spapr_xive_set_irq(SpaprInterruptController= *intc, int irq, int val) { SpaprXive *xive =3D SPAPR_XIVE(intc); =20 + trace_spapr_xive_set_irq(irq, val); + if (spapr_xive_in_kernel(xive)) { kvmppc_xive_source_set_irq(&xive->source, irq, val); } else { @@ -894,6 +901,8 @@ static target_ulong h_int_get_source_info(PowerPCCPU *c= pu, target_ulong flags =3D args[0]; target_ulong lisn =3D args[1]; =20 + trace_spapr_xive_get_source_info(flags, lisn); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1009,6 +1018,8 @@ static target_ulong h_int_set_source_config(PowerPCCP= U *cpu, uint8_t end_blk; uint32_t end_idx; =20 + trace_spapr_xive_set_source_config(flags, lisn, target, priority, eisn= ); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1114,6 +1125,8 @@ static target_ulong h_int_get_source_config(PowerPCCP= U *cpu, uint8_t nvt_blk; uint32_t end_idx, nvt_idx; =20 + trace_spapr_xive_get_source_config(flags, lisn); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1188,6 +1201,8 @@ static target_ulong h_int_get_queue_info(PowerPCCPU *= cpu, uint8_t end_blk; uint32_t end_idx; =20 + trace_spapr_xive_get_queue_info(flags, target, priority); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1275,6 +1290,8 @@ static target_ulong h_int_set_queue_config(PowerPCCPU= *cpu, uint8_t end_blk, nvt_blk; uint32_t end_idx, nvt_idx; =20 + trace_spapr_xive_set_queue_config(flags, target, priority, qpage, qsiz= e); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1442,6 +1459,8 @@ static target_ulong h_int_get_queue_config(PowerPCCPU= *cpu, uint8_t end_blk; uint32_t end_idx; =20 + trace_spapr_xive_get_queue_config(flags, target, priority); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1535,6 +1554,10 @@ static target_ulong h_int_set_os_reporting_line(Powe= rPCCPU *cpu, target_ulong opcode, target_ulong *args) { + target_ulong flags =3D args[0]; + + trace_spapr_xive_set_os_reporting_line(flags); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1571,6 +1594,10 @@ static target_ulong h_int_get_os_reporting_line(Powe= rPCCPU *cpu, target_ulong opcode, target_ulong *args) { + target_ulong flags =3D args[0]; + + trace_spapr_xive_get_os_reporting_line(flags); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1623,6 +1650,8 @@ static target_ulong h_int_esb(PowerPCCPU *cpu, hwaddr mmio_addr; XiveSource *xsrc =3D &xive->source; =20 + trace_spapr_xive_esb(flags, lisn, offset, data); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1692,6 +1721,8 @@ static target_ulong h_int_sync(PowerPCCPU *cpu, target_ulong flags =3D args[0]; target_ulong lisn =3D args[1]; =20 + trace_spapr_xive_sync(flags, lisn); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } @@ -1757,6 +1788,8 @@ static target_ulong h_int_reset(PowerPCCPU *cpu, SpaprXive *xive =3D spapr->xive; target_ulong flags =3D args[0]; =20 + trace_spapr_xive_reset(flags); + if (!spapr_ovec_test(spapr->ov5_cas, OV5_XIVE_EXPLOIT)) { return H_FUNCTION; } diff --git a/hw/intc/spapr_xive_kvm.c b/hw/intc/spapr_xive_kvm.c index e8667ce5f6..acc8c3650c 100644 --- a/hw/intc/spapr_xive_kvm.c +++ b/hw/intc/spapr_xive_kvm.c @@ -20,6 +20,7 @@ #include "hw/ppc/spapr_xive.h" #include "hw/ppc/xive.h" #include "kvm_ppc.h" +#include "trace.h" =20 #include =20 @@ -163,6 +164,8 @@ int kvmppc_xive_cpu_connect(XiveTCTX *tctx, Error **err= p) =20 vcpu_id =3D kvm_arch_vcpu_id(tctx->cs); =20 + trace_kvm_xive_cpu_connect(vcpu_id); + ret =3D kvm_vcpu_enable_cap(tctx->cs, KVM_CAP_PPC_IRQ_XIVE, 0, xive->f= d, vcpu_id, 0); if (ret < 0) { @@ -308,6 +311,8 @@ uint64_t kvmppc_xive_esb_rw(XiveSource *xsrc, int srcno= , uint32_t offset, return xive_esb_rw(xsrc, srcno, offset, data, 1); } =20 + trace_kvm_xive_source_reset(srcno); + /* * Special Load EOI handling for LSI sources. Q bit is never set * and the interrupt should be re-triggered if the level is still diff --git a/hw/intc/trace-events b/hw/intc/trace-events index 22782b3f08..8ed397a0d5 100644 --- a/hw/intc/trace-events +++ b/hw/intc/trace-events @@ -203,3 +203,36 @@ heathrow_set_irq(int num, int level) "set_irq: num=3D0= x%02x level=3D%d" # bcm2835_ic.c bcm2835_ic_set_gpu_irq(int irq, int level) "GPU irq #%d level %d" bcm2835_ic_set_cpu_irq(int irq, int level) "CPU irq #%d level %d" + +# spapr_xive.c +spapr_xive_claim_irq(uint32_t lisn, bool lsi) "lisn=3D0x%x lsi=3D%d" +spapr_xive_free_irq(uint32_t lisn) "lisn=3D0x%x" +spapr_xive_set_irq(uint32_t lisn, uint32_t val) "lisn=3D0x%x val=3D%d" +spapr_xive_get_source_info(uint64_t flags, uint64_t lisn) "flags=3D0x%"PRI= x64" lisn=3D0x%"PRIx64 +spapr_xive_set_source_config(uint64_t flags, uint64_t lisn, uint64_t targe= t, uint64_t priority, uint64_t eisn) "flags=3D0x%"PRIx64" lisn=3D0x%"PRIx64= " target=3D0x%"PRIx64" priority=3D0x%"PRIx64" eisn=3D0x%"PRIx64 +spapr_xive_get_source_config(uint64_t flags, uint64_t lisn) "flags=3D0x%"P= RIx64" lisn=3D0x%"PRIx64 +spapr_xive_get_queue_info(uint64_t flags, uint64_t target, uint64_t priori= ty) "flags=3D0x%"PRIx64" target=3D0x%"PRIx64" priority=3D0x%"PRIx64 +spapr_xive_set_queue_config(uint64_t flags, uint64_t target, uint64_t prio= rity, uint64_t qpage, uint64_t qsize) "flags=3D0x%"PRIx64" target=3D0x%"PRI= x64" priority=3D0x%"PRIx64" qpage=3D0x%"PRIx64" qsize=3D0x%"PRIx64 +spapr_xive_get_queue_config(uint64_t flags, uint64_t target, uint64_t prio= rity) "flags=3D0x%"PRIx64" target=3D0x%"PRIx64" priority=3D0x%"PRIx64 +spapr_xive_set_os_reporting_line(uint64_t flags) "flags=3D0x%"PRIx64 +spapr_xive_get_os_reporting_line(uint64_t flags) "flags=3D0x%"PRIx64 +spapr_xive_esb(uint64_t flags, uint64_t lisn, uint64_t offset, uint64_t da= ta) "flags=3D0x%"PRIx64" lisn=3D0x%"PRIx64" offset=3D0x%"PRIx64" data=3D0x%= "PRIx64 +spapr_xive_sync(uint64_t flags, uint64_t lisn) "flags=3D0x%"PRIx64" lisn= =3D0x%"PRIx64 +spapr_xive_reset(uint64_t flags) "flags=3D0x%"PRIx64 + +# spapr_xive_kvm.c +kvm_xive_cpu_connect(uint32_t id) "connect CPU%d to KVM device" +kvm_xive_source_reset(uint32_t srcno) "IRQ 0x%x" + +# xive.c +xive_tctx_accept(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr, = uint8_t cppr, uint8_t nsr) "target=3D%d ring=3D0x%x IBP=3D0x%02x PIPR=3D0x%= 02x CPPR=3D0x%02x NSR=3D0x%02x ACK" +xive_tctx_notify(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr, = uint8_t cppr, uint8_t nsr) "target=3D%d ring=3D0x%x IBP=3D0x%02x PIPR=3D0x%= 02x CPPR=3D0x%02x NSR=3D0x%02x raise !" +xive_tctx_set_cppr(uint32_t index, uint8_t ring, uint8_t ipb, uint8_t pipr= , uint8_t cppr, uint8_t nsr) "target=3D%d ring=3D0x%x IBP=3D0x%02x PIPR=3D0= x%02x new CPPR=3D0x%02x NSR=3D0x%02x" +xive_source_esb_read(uint64_t addr, uint32_t srcno, uint64_t value) "@0x0x= %"PRIx64" IRQ 0x%x val=3D0x0x%"PRIx64 +xive_source_esb_write(uint64_t addr, uint32_t srcno, uint64_t value) "@0x0= x%"PRIx64" IRQ 0x%x val=3D0x0x%"PRIx64 +xive_router_end_notify(uint8_t end_blk, uint32_t end_idx, uint32_t end_dat= a) "END 0x%02x/0x%04x -> enqueue 0x%08x" +xive_router_end_escalate(uint8_t end_blk, uint32_t end_idx, uint8_t esc_bl= k, uint32_t esc_idx, uint32_t end_data) "END 0x%02x/0x%04x -> escalate END = 0x%02x/0x%04x data 0x%08x" +xive_tctx_tm_write(uint64_t offset, unsigned int size, uint64_t value) "@0= x0x%"PRIx64" sz=3D%d val=3D0x%" PRIx64 +xive_tctx_tm_read(uint64_t offset, unsigned int size, uint64_t value) "@0x= 0x%"PRIx64" sz=3D%d val=3D0x%" PRIx64 +xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring) "fo= und NVT 0x%x/0x%x ring=3D0x%x" +xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "EN= D 0x%x/0x%x @0x0x%"PRIx64 diff --git a/hw/intc/xive.c b/hw/intc/xive.c index 489e6256ef..fa8c3d8287 100644 --- a/hw/intc/xive.c +++ b/hw/intc/xive.c @@ -21,6 +21,7 @@ #include "hw/irq.h" #include "hw/ppc/xive.h" #include "hw/ppc/xive_regs.h" +#include "trace.h" =20 /* * XIVE Thread Interrupt Management context @@ -93,6 +94,10 @@ static uint64_t xive_tctx_accept(XiveTCTX *tctx, uint8_t= ring) =20 /* Drop Exception bit */ regs[TM_NSR] &=3D ~mask; + + trace_xive_tctx_accept(tctx->cs->cpu_index, ring, + regs[TM_IPB], regs[TM_PIPR], + regs[TM_CPPR], regs[TM_NSR]); } =20 return (nsr << 8) | regs[TM_CPPR]; @@ -113,12 +118,21 @@ static void xive_tctx_notify(XiveTCTX *tctx, uint8_t = ring) default: g_assert_not_reached(); } + trace_xive_tctx_notify(tctx->cs->cpu_index, ring, + regs[TM_IPB], regs[TM_PIPR], + regs[TM_CPPR], regs[TM_NSR]); qemu_irq_raise(xive_tctx_output(tctx, ring)); } } =20 static void xive_tctx_set_cppr(XiveTCTX *tctx, uint8_t ring, uint8_t cppr) { + uint8_t *regs =3D &tctx->regs[ring]; + + trace_xive_tctx_set_cppr(tctx->cs->cpu_index, ring, + regs[TM_IPB], regs[TM_PIPR], + cppr, regs[TM_NSR]); + if (cppr > XIVE_PRIORITY_MAX) { cppr =3D 0xff; } @@ -508,6 +522,8 @@ void xive_tctx_tm_write(XivePresenter *xptr, XiveTCTX *= tctx, hwaddr offset, { const XiveTmOp *xto; =20 + trace_xive_tctx_tm_write(offset, size, value); + /* * TODO: check V bit in Q[0-3]W2 */ @@ -545,6 +561,7 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCT= X *tctx, hwaddr offset, unsigned size) { const XiveTmOp *xto; + uint64_t ret; =20 /* * TODO: check V bit in Q[0-3]W2 @@ -560,7 +577,8 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveTCT= X *tctx, hwaddr offset, "@%"HWADDR_PRIx"\n", offset); return -1; } - return xto->read_handler(xptr, tctx, offset, size); + ret =3D xto->read_handler(xptr, tctx, offset, size); + goto out; } =20 /* @@ -568,13 +586,17 @@ uint64_t xive_tctx_tm_read(XivePresenter *xptr, XiveT= CTX *tctx, hwaddr offset, */ xto =3D xive_tm_find_op(offset, size, false); if (xto) { - return xto->read_handler(xptr, tctx, offset, size); + ret =3D xto->read_handler(xptr, tctx, offset, size); + goto out; } =20 /* * Finish with raw access to the register values */ - return xive_tm_raw_read(tctx, offset, size); + ret =3D xive_tm_raw_read(tctx, offset, size); +out: + trace_xive_tctx_tm_read(offset, size, ret); + return ret; } =20 static char *xive_tctx_ring_print(uint8_t *ring) @@ -1005,6 +1027,8 @@ static uint64_t xive_source_esb_read(void *opaque, hw= addr addr, unsigned size) offset); } =20 + trace_xive_source_esb_read(addr, srcno, ret); + return ret; } =20 @@ -1030,6 +1054,8 @@ static void xive_source_esb_write(void *opaque, hwadd= r addr, uint32_t srcno =3D addr >> xsrc->esb_shift; bool notify =3D false; =20 + trace_xive_source_esb_write(addr, srcno, value); + /* In a two pages ESB MMIO setting, trigger page only triggers */ if (xive_source_is_trigger_page(xsrc, addr)) { notify =3D xive_source_esb_trigger(xsrc, srcno); @@ -1507,6 +1533,7 @@ static bool xive_presenter_notify(XiveFabric *xfb, ui= nt8_t format, =20 /* handle CPU exception delivery */ if (count) { + trace_xive_presenter_notify(nvt_blk, nvt_idx, match.ring); xive_tctx_ipb_update(match.tctx, match.ring, priority_to_ipb(prior= ity)); } =20 @@ -1558,6 +1585,7 @@ static void xive_router_end_notify(XiveRouter *xrtr, = uint8_t end_blk, } =20 if (!xive_end_is_valid(&end)) { + trace_xive_router_end_notify(end_blk, end_idx, end_data); qemu_log_mask(LOG_GUEST_ERROR, "XIVE: END %x/%x is invalid\n", end_blk, end_idx); return; @@ -1683,6 +1711,10 @@ do_escalation: } } =20 + trace_xive_router_end_escalate(end_blk, end_idx, + (uint8_t) xive_get_field32(END_W4_ESC_END_BLOCK, end.w4), + (uint32_t) xive_get_field32(END_W4_ESC_END_INDEX, end.w4), + (uint32_t) xive_get_field32(END_W5_ESC_END_DATA, end.w5)); /* * The END trigger becomes an Escalation trigger */ @@ -1796,6 +1828,8 @@ static uint64_t xive_end_source_read(void *opaque, hw= addr addr, unsigned size) end_blk =3D xive_router_get_block_id(xsrc->xrtr); end_idx =3D addr >> (xsrc->esb_shift + 1); =20 + trace_xive_end_source_read(end_blk, end_idx, addr); + if (xive_router_get_end(xsrc->xrtr, end_blk, end_idx, &end)) { qemu_log_mask(LOG_GUEST_ERROR, "XIVE: No END %x/%x\n", end_blk, end_idx); --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661286; cv=none; d=zohomail.com; s=zohoarc; b=SmVMGO6KngVDTLoN7rTWZdy1OS9kJwR3FR8MqpJvkEJOSTnxsUdd2ppnsIFInlutY0KjCOCwn73P1Gl0LiFiypoFJXM5D9xTGC0PZ6OL+lSu+ArN4c+0494aZHyqgNpoLoYFbmiTT0dtkjzasJFcfyX1Ca/X6qn72CSXS8vAeNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661286; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rdBEg2cOH2NVlRTp2etDw7WWasyRvbBKMdW8See6Lng=; b=FcbWF8mUYSIoIQDzn2Am4J1Tv34F8Jsl7BACTaYZQ6US3HQr2pgg9KdirqPeLW/OzqplwhjNGqF5cTNyiDoECd9w9rddzxqlf+knS/1iUSGvEVUnPLFCTBxZGF16IgIScpnwvNVEgYYBw9MtgJNsMiKL6TZUQ/DMJDZx0Bu4GD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661286499888.1759115860777; Thu, 10 Dec 2020 20:34:46 -0800 (PST) Received: from localhost ([::1]:39040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna8j-0000vz-4A for importer@patchew.org; Thu, 10 Dec 2020 23:34:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqG-0005ob-GF; Thu, 10 Dec 2020 23:15:40 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:47889 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqD-0000q1-5n; Thu, 10 Dec 2020 23:15:40 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc3tZrz9sX4; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=0Oo7om3cMnnKyb+bgKj3Jxupc0Ter85I2IrQ9mmZOgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XSfXdAB04w50K6XJ6A+vL3nBtTTpbAWba17UGgZAkze+jXo997pbfOlGcsAASxsAh uue5UC/hiJFzGZ35qifXrGYHbGw3pkYUJVYaWMUST2zHIX+D+d9XRXlNV2yPUxQFAq 7AuqNupV07G7+HadexE5mB8OgJ5YlTLTmSGCYLIM= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 17/30] spapr: Fix pre-2.10 dummy ICP hack Date: Fri, 11 Dec 2020 15:14:54 +1100 Message-Id: <20201211041507.425378-18-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz This hack registers dummy VMState entries of ICPs in order to support migration of old pseries machine types that used to create all smp.max_cpus possible ICPs at machine init. Part of the work is to unregister the dummy entries when plugging an actual vCPU core, and to register them back when unplugging the core. The code that unregisters the dummy ICPs in spapr_core_plug() is misplaced: if ppc_set_compat() fails afterwards, the hotplug operation will be cancelled and the dummy ICPs won't be registered back since the unplug handler isn't called. Unregister the dummy ICPs at the end of spapr_core_plug(). Signed-off-by: Greg Kurz Message-Id: <20201201113728.885700-2-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 7e954bc84b..9be019e35f 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3785,13 +3785,6 @@ static void spapr_core_plug(HotplugHandler *hotplug_= dev, DeviceState *dev, =20 core_slot->cpu =3D OBJECT(dev); =20 - if (smc->pre_2_10_has_unused_icps) { - for (i =3D 0; i < cc->nr_threads; i++) { - cs =3D CPU(core->threads[i]); - pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index); - } - } - /* * Set compatibility mode to match the boot CPU, which was either set * by the machine reset code or by CAS. @@ -3805,6 +3798,13 @@ static void spapr_core_plug(HotplugHandler *hotplug_= dev, DeviceState *dev, } } } + + if (smc->pre_2_10_has_unused_icps) { + for (i =3D 0; i < cc->nr_threads; i++) { + cs =3D CPU(core->threads[i]); + pre_2_10_vmstate_unregister_dummy_icp(cs->cpu_index); + } + } } =20 static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *= dev, --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661202; cv=none; d=zohomail.com; s=zohoarc; b=Uw/mkhES1hjnGiqa83EhmpbgLqwZxEosJK+XFldlQEdtNsA5IE9nBsHxlJYhu9HdBFRcGP+X+CGD/p4IVtCKYckdMjaId7+Iqtc5lwFoL8DIIxFw8xJczI8YMPOUPjGZLhIlrM3qA/tn4y7sdoWVsnj3+t3DhF/rwhj2crGMbR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661202; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rj3/LpiHR1KFnexZY/MowgmxwVNwZPrZVqUNuDI5z5c=; b=ISVr8QsMtvck671JJxLycfzv7wBZvq3+VnC80WRaAkqVNDGN/rD1n/sJTI2M54CUmsJ/deWRK+T4naNPKYH9iahF7M91wKwnz44iLHvmsnwBRipwEDz+3fn5z91FDX+anmFw9E14rGAtdU/UjjnOgO2T032vwvcrUbNj3NYbjOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661201913680.4638321081889; Thu, 10 Dec 2020 20:33:21 -0800 (PST) Received: from localhost ([::1]:35800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna7M-0007yj-NI for importer@patchew.org; Thu, 10 Dec 2020 23:33:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqG-0005oF-A3; Thu, 10 Dec 2020 23:15:40 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:42561) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqD-0000q4-4L; Thu, 10 Dec 2020 23:15:40 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc6KHPz9sX6; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=jrHKasJCK9wGHz48vbWl9VVfI/OexiiOgNrjtOKaynM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T9iMl6vhtru5mheMAlmGIxrfsYZL2IHXfoj2c/rxrrqqxdgv3HsKXN3OSfBWwsWKR 3fihhHsdSjEB1jnPNAR6dbCZtTcRNoAuQ6C3YoWIEmKY1CsleeiWkfJ4cP3FBjwSAw 4iffvpWWcXN76OfUmT3/3BX2Lxwkg6IlkW+w912Y= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 18/30] spapr: Abort if ppc_set_compat() fails for hot-plugged CPUs Date: Fri, 11 Dec 2020 15:14:55 +1100 Message-Id: <20201211041507.425378-19-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz When a CPU is hot-plugged, we set its compat mode to match the boot CPU, which was either set by machine reset or by CAS. This is currently handled in the plug handler after the core got realized. Potential errors of ppc_set_compat() are propagated to the hot-plug logic. Handling errors this late in the hot-plug sequence is generally frown upon. Ideally, we should do sanity checks in a pre-plug handler and pass &error_abort to ppc_set_compat() in the plug handler. We can filter out some error cases of ppc_set_compat() by calling ppc_check_compat() at pre-plug. But ppc_set_compat() also sets the compat register in KVM, and KVM doesn't provide any API that would allow to check valid compat mode settings beforehand. However, at this point we know that the compat mode was already successfully set for the boot CPU. Since this all boils down to setting a register with the very same value that was valid for the boot CPU, it should definitely not fail for hot-plugged CPUS. Pass &error_abort to ppc_set_compat(). Signed-off-by: Greg Kurz Message-Id: <20201201113728.885700-3-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9be019e35f..583ec93e83 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3787,15 +3787,13 @@ static void spapr_core_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, =20 /* * Set compatibility mode to match the boot CPU, which was either set - * by the machine reset code or by CAS. + * by the machine reset code or by CAS. This really shouldn't fail at + * this point. */ if (hotplugged) { for (i =3D 0; i < cc->nr_threads; i++) { - if (ppc_set_compat(core->threads[i], - POWERPC_CPU(first_cpu)->compat_pvr, - errp) < 0) { - return; - } + ppc_set_compat(core->threads[i], POWERPC_CPU(first_cpu)->compa= t_pvr, + &error_abort); } } =20 --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661153; cv=none; d=zohomail.com; s=zohoarc; b=SOiqoKRSczikhYs6dHUOcQM05aLJsicTe345mcl/obogGXnRIAUK/u6jk1eTQmlN09xzMBufSNDR1PNoar+92uFcBJp2wGzu2IANQCdFSkKlsLApwOUizQ4A+HHiRIJt+EJgGSJn3r0zWH3pdG2K4O1/OLiOV3c0kR68c7kbm5o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661153; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=s+1RB9j8+TNLwpE20qBQtEa9+m+Auq913RskXLDEwa0=; b=h3Ib7/gkUwgKtZGXLxO02ft3f9qNj9/pb7Rg7I+dnHfqmZ9X7wXXVRz6sYM8ScDlT09fDUIIBKcpSJcMLSIa0i8WIif0s0KY+g+heCpN0j6XFLie7HFDsDaSBfRC+572C7cj1S582pOrf4/heimZNJYRJZNN6RUAn8Nqx6DDoJI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661153914977.3754467574208; Thu, 10 Dec 2020 20:32:33 -0800 (PST) Received: from localhost ([::1]:33098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna6a-0006py-Hi for importer@patchew.org; Thu, 10 Dec 2020 23:32:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqE-0005lt-V4; Thu, 10 Dec 2020 23:15:39 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:53689) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqD-0000q3-2m; Thu, 10 Dec 2020 23:15:38 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrc73zWz9sX5; Fri, 11 Dec 2020 15:15:12 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660112; bh=+pRH2BRS5qBt8DjkVPHhlul0PKqAcpuqENEinF00XmU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Khs4mxMuoBGEH9Dp6wuH0XaqxS4AIsoojq290TZPZ9lu6zAWNOI6BhtsC0Vm0ImUv BsJ6cRPeIW1FJqwzIZHH3HTCwzs3kqLto2iLSPW1qUCUfKgrcXolSPXM7MNi24D7ts NFnDz6PGsDCf/qQHsDj0bGHX8jXXt1HD8Yl9TGqU= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 19/30] spapr: Simplify error path of spapr_core_plug() Date: Fri, 11 Dec 2020 15:14:56 +1100 Message-Id: <20201211041507.425378-20-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz spapr_core_pre_plug() already guarantees that the slot for the given core ID is available. It is thus safe to assume that spapr_find_cpu_slot() returns a slot during plug. Turn the error path into an assertion. It is also safe to assume that no device is attached to the corresponding DRC and that spapr_drc_attach() shouldn't fail. Pass &error_abort to spapr_drc_attach() and simplify error handling. Signed-off-by: Greg Kurz Message-Id: <20201201113728.885700-4-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 583ec93e83..9dd8deb8c8 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3741,8 +3741,7 @@ int spapr_core_dt_populate(SpaprDrc *drc, SpaprMachin= eState *spapr, return 0; } =20 -static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev, - Error **errp) +static void spapr_core_plug(HotplugHandler *hotplug_dev, DeviceState *dev) { SpaprMachineState *spapr =3D SPAPR_MACHINE(OBJECT(hotplug_dev)); MachineClass *mc =3D MACHINE_GET_CLASS(spapr); @@ -3757,20 +3756,20 @@ static void spapr_core_plug(HotplugHandler *hotplug= _dev, DeviceState *dev, int i; =20 core_slot =3D spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &= index); - if (!core_slot) { - error_setg(errp, "Unable to find CPU core with core-id: %d", - cc->core_id); - return; - } + g_assert(core_slot); /* Already checked in spapr_core_pre_plug() */ + drc =3D spapr_drc_by_id(TYPE_SPAPR_DRC_CPU, spapr_vcpu_id(spapr, cc->core_id)); =20 g_assert(drc || !mc->has_hotpluggable_cpus); =20 if (drc) { - if (!spapr_drc_attach(drc, dev, errp)) { - return; - } + /* + * spapr_core_pre_plug() already buys us this is a brand new + * core being plugged into a free slot. Nothing should already + * be attached to the corresponding DRC. + */ + spapr_drc_attach(drc, dev, &error_abort); =20 if (hotplugged) { /* @@ -4012,7 +4011,7 @@ static void spapr_machine_device_plug(HotplugHandler = *hotplug_dev, if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { spapr_memory_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { - spapr_core_plug(hotplug_dev, dev, errp); + spapr_core_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_PCI_HOST_BRIDGE= )) { spapr_phb_plug(hotplug_dev, dev); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_TPM_PROXY)) { --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661353; cv=none; d=zohomail.com; s=zohoarc; b=TfWEUtB7pAcOe1wLgxb/iLPK5BEbeGWi1v0y3l5OLbesqtgmRtharky2pU7AoZeFRIPZ0XKO65Ht+oIkHh6k+zxb68JgiAlC6PH5gD/VMAAiM1Ax51HX6TT0vYY/FPiMp0+bg+1n1c5jlEYdt1lsLQWXDB4BcHvfVLx5hBySdqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661353; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mGL/nK+msHLFB5H7HTst3i573WHzPPmNaWjyLAqXt00=; b=EWzENnZtRuWq9UvOO8mLmzfFU8lrPmDpI8DtUhBz/9wWii4Wwu7jfZXNkc2xzLFsMVh6qAlFAtYzjzU8j+AQHOdmqjsSrF8SEjiijSTgOKidaqpU7jybZEcAGEvaFNjeRmbEoZ+KmMvvEVjxHsesTD5KnRmmaPu2k/+11DEXbmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661353350775.4628831814653; Thu, 10 Dec 2020 20:35:53 -0800 (PST) Received: from localhost ([::1]:41310 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna9n-0001wM-E5 for importer@patchew.org; Thu, 10 Dec 2020 23:35:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqG-0005pC-KR; Thu, 10 Dec 2020 23:15:42 -0500 Received: from ozlabs.org ([203.11.71.1]:41121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqD-0000qB-8z; Thu, 10 Dec 2020 23:15:40 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrd1pxtz9sX9; Fri, 11 Dec 2020 15:15:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660113; bh=tMTOBLzZS+CQh5KVzMvnScmt3J3fqHLqrstCFIQilBo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nyQj0Qo2gWAPwoSVmDOOyeYlJGLnUC6AN+VCX/77OIsXds7pouWdWte2keEMnTxRO XkLnPV9UjxSqL+xBmQ9Yvkrd2tn/8CLj6J9BnJkLd+EV9IGsbpA8pg6vUj/qefUt2W iH9YkipOPRF41paEVKUKuSZFv1gohGJF+VlJfY2I= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 20/30] spapr: spapr_drc_attach() cannot fail Date: Fri, 11 Dec 2020 15:14:57 +1100 Message-Id: <20201211041507.425378-21-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz All users are passing &error_abort already. Document the fact that spapr_drc_attach() should only be passed a free DRC, which is supposedly the case if appropriate checking is done earlier. Signed-off-by: Greg Kurz Message-Id: <20201201113728.885700-5-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr.c | 6 +++--- hw/ppc/spapr_drc.c | 8 ++------ hw/ppc/spapr_nvdimm.c | 2 +- hw/ppc/spapr_pci.c | 2 +- include/hw/ppc/spapr_drc.h | 8 +++++++- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 9dd8deb8c8..d6ab40f321 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3401,7 +3401,7 @@ static void spapr_add_lmbs(DeviceState *dev, uint64_t= addr_start, uint64_t size, * that doesn't overlap with any existing mapping at pre-plug. The * corresponding LMB DRCs are thus assumed to be all attachable. */ - spapr_drc_attach(drc, dev, &error_abort); + spapr_drc_attach(drc, dev); if (!hotplugged) { spapr_drc_reset(drc); } @@ -3769,7 +3769,7 @@ static void spapr_core_plug(HotplugHandler *hotplug_d= ev, DeviceState *dev) * core being plugged into a free slot. Nothing should already * be attached to the corresponding DRC. */ - spapr_drc_attach(drc, dev, &error_abort); + spapr_drc_attach(drc, dev); =20 if (hotplugged) { /* @@ -3934,7 +3934,7 @@ static void spapr_phb_plug(HotplugHandler *hotplug_de= v, DeviceState *dev) assert(drc); =20 /* spapr_phb_pre_plug() already checked the DRC is attachable */ - spapr_drc_attach(drc, dev, &error_abort); + spapr_drc_attach(drc, dev); =20 if (hotplugged) { spapr_hotplug_req_add_by_index(drc); diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c index 77718cde1f..f991cf89a0 100644 --- a/hw/ppc/spapr_drc.c +++ b/hw/ppc/spapr_drc.c @@ -369,14 +369,11 @@ static void prop_get_fdt(Object *obj, Visitor *v, con= st char *name, } while (fdt_depth !=3D 0); } =20 -bool spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp) +void spapr_drc_attach(SpaprDrc *drc, DeviceState *d) { trace_spapr_drc_attach(spapr_drc_index(drc)); =20 - if (drc->dev) { - error_setg(errp, "an attached device is still awaiting release"); - return false; - } + g_assert(!drc->dev); g_assert((drc->state =3D=3D SPAPR_DRC_STATE_LOGICAL_UNUSABLE) || (drc->state =3D=3D SPAPR_DRC_STATE_PHYSICAL_POWERON)); =20 @@ -386,7 +383,6 @@ bool spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Er= ror **errp) object_get_typename(OBJECT(drc->dev)), (Object **)(&drc->dev), NULL, 0); - return true; } =20 static void spapr_drc_release(SpaprDrc *drc) diff --git a/hw/ppc/spapr_nvdimm.c b/hw/ppc/spapr_nvdimm.c index 2f1c196e1b..73ee006541 100644 --- a/hw/ppc/spapr_nvdimm.c +++ b/hw/ppc/spapr_nvdimm.c @@ -101,7 +101,7 @@ void spapr_add_nvdimm(DeviceState *dev, uint64_t slot) * pc_dimm_get_free_slot() provided a free slot at pre-plug. The * corresponding DRC is thus assumed to be attachable. */ - spapr_drc_attach(drc, dev, &error_abort); + spapr_drc_attach(drc, dev); =20 if (hotplugged) { spapr_hotplug_req_add_by_index(drc); diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 2829f298d9..e946bd5055 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1601,7 +1601,7 @@ static void spapr_pci_plug(HotplugHandler *plug_handl= er, } =20 /* spapr_pci_pre_plug() already checked the DRC is attachable */ - spapr_drc_attach(drc, DEVICE(pdev), &error_abort); + spapr_drc_attach(drc, DEVICE(pdev)); =20 /* If this is function 0, signal hotplug for all the device functions. * Otherwise defer sending the hotplug event. diff --git a/include/hw/ppc/spapr_drc.h b/include/hw/ppc/spapr_drc.h index 165b281496..def3593adc 100644 --- a/include/hw/ppc/spapr_drc.h +++ b/include/hw/ppc/spapr_drc.h @@ -235,7 +235,13 @@ SpaprDrc *spapr_drc_by_index(uint32_t index); SpaprDrc *spapr_drc_by_id(const char *type, uint32_t id); int spapr_dt_drc(void *fdt, int offset, Object *owner, uint32_t drc_type_m= ask); =20 -bool spapr_drc_attach(SpaprDrc *drc, DeviceState *d, Error **errp); +/* + * These functions respectively abort if called with a device already + * attached or no device attached. In the case of spapr_drc_attach(), + * this means that the attachability of the DRC *must* be checked + * beforehand (eg. check drc->dev at pre-plug). + */ +void spapr_drc_attach(SpaprDrc *drc, DeviceState *d); void spapr_drc_detach(SpaprDrc *drc); =20 /* Returns true if a hot plug/unplug request is pending */ --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661727; cv=none; d=zohomail.com; s=zohoarc; b=PZdxM5CEAhw8PaW2uV1uOdF2t3Y9OdD7cDXdRdFSaLa7iRWpUnqwjCsfQX4Boz3J4QY0Jx5ChjFpYrsr3IUWQ0qF3R0oUK3BpXm8yMnJieZhHZJ7eaO1freh6ZckCX9jPWSDUG5zbiUh8fgah/HXnV+3SH4kkJwkfJEuU8r9PXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661727; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RLFBdcWzuCyyxThEB7XXzZtB89qDlP4BS9gtLlqDIoY=; b=XeVKAXED/PvLwC2M4aickqG5mzFZhf0Dsu6hsUo8JZYTEGfZVxwxRz3I2T2GNrsdmXvCJkGMMM2REYBGXntLPO4gQXtDFWqHt3jpfobMvyMIPO2XQjDE7/R2+JBP/YDuCGez84UiYZE3X0lwiKIz1ztFRFoRiuRtraRRET0i5rA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661727067677.8426851200173; Thu, 10 Dec 2020 20:42:07 -0800 (PST) Received: from localhost ([::1]:55328 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaFi-0007z4-Vj for importer@patchew.org; Thu, 10 Dec 2020 23:42:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqc-0005vL-Qg; Thu, 10 Dec 2020 23:16:03 -0500 Received: from ozlabs.org ([203.11.71.1]:54025) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqY-0000r7-He; Thu, 10 Dec 2020 23:16:01 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrd3kGRz9sXJ; Fri, 11 Dec 2020 15:15:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660113; bh=tvLvZbPS4B+j9KrzKvfJ/AHDko2QUtZv+6SzqvCnXnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vy7xLO4nWULShX0h/dww/vuXsR8QyZyhrrXnCJc4pGgRyrRxjw8dQ9sCzYgQXY9Jf SKlj6zlRr9wLnkRFP7oGU6DpyoFh66nby4IW3SUCzkS/8MILXNdS6c3SsD63rrzD/M sCIJ5vQCy33VXQeyHi+7/0KrCFRhyvmqW9Cfw8Wg= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 21/30] target/ppc: Remove "compat" property of server class POWER CPUs Date: Fri, 11 Dec 2020 15:14:58 +1100 Message-Id: <20201211041507.425378-22-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?J=C3=A1n=20Tomko?= , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Greg Kurz This property has been deprecated since QEMU 5.0 by commit 22062e54bb68. We only kept a legacy hack that internally converts "compat" into the official "max-cpu-compat" property of the pseries machine type. According to our deprecation policy, we could have removed it for QEMU 5.2 already. Do it now ; since ppc_cpu_parse_featurestr() now just calls the generic parent_parse_features handler, drop it as well. Users are supposed to use the "max-cpu-compat" property of the pseries machine type instead. Signed-off-by: Greg Kurz Message-Id: <20201201131103.897430-1-groug@kaod.org> Reviewed-by: J=C3=A1n Tomko Signed-off-by: David Gibson --- docs/system/deprecated.rst | 7 ---- target/ppc/translate_init.c.inc | 59 --------------------------------- 2 files changed, 66 deletions(-) diff --git a/docs/system/deprecated.rst b/docs/system/deprecated.rst index 565389697e..09c8f380bc 100644 --- a/docs/system/deprecated.rst +++ b/docs/system/deprecated.rst @@ -281,13 +281,6 @@ a future version of QEMU. It's unclear whether anybody= is still using CPU emulation in QEMU, and there are no test images available to make sure that the code is still working. =20 -``compat`` property of server class POWER CPUs (since 5.0) -'''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -The ``compat`` property used to set backwards compatibility modes for -the processor has been deprecated. The ``max-cpu-compat`` property of -the ``pseries`` machine type should be used instead. - ``lm32`` CPUs (since 5.2.0) ''''''''''''''''''''''''''' =20 diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index 78cc8f043b..e4082cfde7 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10470,63 +10470,6 @@ static ObjectClass *ppc_cpu_class_by_name(const ch= ar *name) return oc; } =20 -static void ppc_cpu_parse_featurestr(const char *type, char *features, - Error **errp) -{ - Object *machine =3D qdev_get_machine(); - const PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(object_class_by_name(= type)); - - if (!features) { - return; - } - - if (object_property_find(machine, "max-cpu-compat")) { - int i; - char **inpieces; - char *s =3D features; - Error *local_err =3D NULL; - char *compat_str =3D NULL; - - /* - * Backwards compatibility hack: - * - * CPUs had a "compat=3D" property which didn't make sense for - * anything except pseries. It was replaced by "max-cpu-compat" - * machine option. This supports old command lines like - * -cpu POWER8,compat=3Dpower7 - * By stripping the compat option and applying it to the machine - * before passing it on to the cpu level parser. - */ - inpieces =3D g_strsplit(features, ",", 0); - *s =3D '\0'; - for (i =3D 0; inpieces[i]; i++) { - if (g_str_has_prefix(inpieces[i], "compat=3D")) { - warn_report_once("CPU 'compat' property is deprecated; " - "use max-cpu-compat machine property instead"); - compat_str =3D inpieces[i]; - continue; - } - if ((i !=3D 0) && (s !=3D features)) { - s =3D g_stpcpy(s, ","); - } - s =3D g_stpcpy(s, inpieces[i]); - } - - if (compat_str) { - char *v =3D compat_str + strlen("compat=3D"); - object_property_set_str(machine, "max-cpu-compat", v, &local_e= rr); - } - g_strfreev(inpieces); - if (local_err) { - error_propagate(errp, local_err); - return; - } - } - - /* do property processing with generic handler */ - pcc->parent_parse_features(type, features, errp); -} - PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) { ObjectClass *oc =3D OBJECT_CLASS(pcc); @@ -10905,8 +10848,6 @@ static void ppc_cpu_class_init(ObjectClass *oc, voi= d *data) device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset); =20 cc->class_by_name =3D ppc_cpu_class_by_name; - pcc->parent_parse_features =3D cc->parse_features; - cc->parse_features =3D ppc_cpu_parse_featurestr; cc->has_work =3D ppc_cpu_has_work; cc->do_interrupt =3D ppc_cpu_do_interrupt; cc->cpu_exec_interrupt =3D ppc_cpu_exec_interrupt; --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661212; cv=none; d=zohomail.com; s=zohoarc; b=DdHs17Ze2/huEakgjddkO/ij+k8gGmgsgRLHl83v5gBnVx5ORwow1ACMZewpIAdSSIJHRx9DmGdCERbGd7B5sE/+rBh7PrW8GGEOqbYtu/q69stAFHD7Q6KIsgEkjN6f8ibgFcVFhBwLi7KtPK2e7i2UskTvAJqSD90HIcbVUQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661212; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+6AFJB8DmfHr7i+iFzSgyff7b8bYrwNLZi+9rHJdrDU=; b=bB/uu+Bmy8MD0otJ3RVJV8+ipndxT3YfDqwPEJHbTFXTNbzdF44wutOUObuf3pOErOToJcmAVtOQw4cXPJOyM+Kn2ytd7m5MuJiFz51Q6iCrRloYtjYLJfnvfO18tj39N834/HSTWz4bRlPkjW0zufYewMrB54a+x5xVyd7t3SA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661212216937.3005681564516; Thu, 10 Dec 2020 20:33:32 -0800 (PST) Received: from localhost ([::1]:36074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kna7W-00085e-T0 for importer@patchew.org; Thu, 10 Dec 2020 23:33:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqG-0005pZ-Nv; Thu, 10 Dec 2020 23:15:42 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:51253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqE-0000rA-SB; Thu, 10 Dec 2020 23:15:40 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrd4VTpz9sXF; Fri, 11 Dec 2020 15:15:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660113; bh=HrvpZ1c3QUmnLSSVUYMtaks8Ufho2sdvGBWv6odl8B0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eKmNUHfS7KVweXFo9l2JfdgCLGu0Vll2fbYo0TOLr0/69CXIX90AwWxVBT2Zxjc3S V1vpZpyu9yEFbLIvtery4FE7oGMEM977eTlnXXj6Cb3faTgmxk0CHvmieNacNtPf33 hCiLvSfMlkwWSBZwTfrdHkGF5fO8JxZxvX0xJY74= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 22/30] hw/ppc: Do not re-read the clock on pre_save if doing savevm Date: Fri, 11 Dec 2020 15:14:59 +1100 Message-Id: <20201211041507.425378-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz A guest with enough RAM, eg. 128G, is likely to detect savevm downtime and to complain about stalled CPUs. This happens because we re-read the timebase just before migrating it and we thus don't account for all the time between VM stop and pre-save. A very similar situation was already addressed for live migration of paused guests (commit d14f33976282). Extend the logic to do the same with savevm. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1893787 Signed-off-by: Greg Kurz Message-Id: <160693010619.1111945.632640981169395440.stgit@bahia.lan> Signed-off-by: David Gibson --- hw/ppc/ppc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c index 1b98272076..5cbbff1f8d 100644 --- a/hw/ppc/ppc.c +++ b/hw/ppc/ppc.c @@ -1027,7 +1027,8 @@ static void timebase_save(PPCTimebase *tb) */ tb->guest_timebase =3D ticks + first_ppc_cpu->env.tb_env->tb_offset; =20 - tb->runstate_paused =3D runstate_check(RUN_STATE_PAUSED); + tb->runstate_paused =3D + runstate_check(RUN_STATE_PAUSED) || runstate_check(RUN_STATE_SAVE_= VM); } =20 static void timebase_load(PPCTimebase *tb) @@ -1088,7 +1089,7 @@ static int timebase_pre_save(void *opaque) { PPCTimebase *tb =3D opaque; =20 - /* guest_timebase won't be overridden in case of paused guest */ + /* guest_timebase won't be overridden in case of paused guest or savev= m */ if (!tb->runstate_paused) { timebase_save(tb); } --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661445; cv=none; d=zohomail.com; s=zohoarc; b=lX78+8p2eC4SiGoyXEJ74rcJHVCtPDJW1okXwL/iMuhYNhwX49YhmTsfMse1fAzzxtlghNfQgUWsIfwn9wFZLYEWZ0NyHiVPKd+1eJeJ6k+ohtYCfrMmGbTgs0gO8/+nM642/iSRR9yY6cfhiQnY8GiBhoXLgQVylgJlWso0Gy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=I89c1hirZoIjnwgCObUq2mOrYP7+PMJxz2sb0MEgC3c=; b=KXA2s6/gp8VXRCSlESahhO4d27V4i1cWOSlMG+6TM5G1ctWQ8WUBEojbGQvRMmIQn5kKEwBH5WmdwpLF6mkT3zb+mdsZbLNeoTi2vbIE8KP+AgEWVkvAggyPHju/xZ+I++Z5NfdrQw6L9THIe26oKRKrcxLJ9/xmSUw7Yw7RX2Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661445219647.0498431644722; Thu, 10 Dec 2020 20:37:25 -0800 (PST) Received: from localhost ([::1]:44258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaBH-0003J2-QT for importer@patchew.org; Thu, 10 Dec 2020 23:37:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqI-0005qW-Ll; Thu, 10 Dec 2020 23:15:44 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:44207 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqG-0000s2-64; Thu, 10 Dec 2020 23:15:41 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrd5SX5z9sXN; Fri, 11 Dec 2020 15:15:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660113; bh=am8+Q5EjqgTiZJyNMdcpi4NmDz7+8UAnqfg16vigV6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S9Mva/RPec2VPFxbQ1tKNEDmOL3nHCzbgjJhdds1ZNcQWRTCR98jwuyookOJh45rA sdIS+EuxaDIUovvtgUaYyjoDoHS6Px0kOMcgsqmBvSHlW66p2DT3qE1QEz+OIaaNsl tCcvdDRUhKf73g1zvA9RuLIvxdp3fosDAnNFjbFs= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 23/30] MAINTAINERS: Add Greg Kurz as co-maintainer for ppc Date: Fri, 11 Dec 2020 15:15:00 +1100 Message-Id: <20201211041507.425378-24-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Greg has agreed to be co-maintainer of the ppc target and machines. This should avoid repeats of the problem we had in qemu-5.2 where a last minute fix was needed while I was on holiday. Signed-off-by: David Gibson Acked-by: Greg Kurz --- MAINTAINERS | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index a83416d54c..1cfc9dbab7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -272,6 +272,7 @@ F: tests/tcg/openrisc/ =20 PowerPC TCG CPUs M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Maintained F: target/ppc/ @@ -394,6 +395,7 @@ F: target/mips/kvm.c =20 PPC KVM CPUs M: David Gibson +M: Greg Kurz S: Maintained F: target/ppc/kvm.c =20 @@ -1183,18 +1185,21 @@ PowerPC Machines ---------------- 405 M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/ppc405_boards.c =20 Bamboo M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/ppc440_bamboo.c =20 e500 M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/e500* @@ -1208,6 +1213,7 @@ F: pc-bios/u-boot.e500 =20 mpc8544ds M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/mpc8544ds.c @@ -1216,6 +1222,7 @@ F: hw/ppc/mpc8544_guts.c New World (mac99) M: Mark Cave-Ayland R: David Gibson +R: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/mac_newworld.c @@ -1235,6 +1242,7 @@ F: pc-bios/qemu_vga.ndrv Old World (g3beige) M: Mark Cave-Ayland R: David Gibson +R: Greg Kurz L: qemu-ppc@nongnu.org S: Odd Fixes F: hw/ppc/mac_oldworld.c @@ -1248,6 +1256,8 @@ F: pc-bios/qemu_vga.ndrv =20 PReP M: Herv=C3=A9 Poussineau +R: David Gibson +R: Greg Kurz L: qemu-ppc@nongnu.org S: Maintained F: hw/ppc/prep.c @@ -1264,6 +1274,7 @@ F: tests/acceptance/ppc_prep_40p.py =20 sPAPR M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Supported F: hw/*/spapr* @@ -1281,6 +1292,7 @@ F: tests/qtest/libqos/rtas* PowerNV (Non-Virtualized) M: C=C3=A9dric Le Goater M: David Gibson +M: Greg Kurz L: qemu-ppc@nongnu.org S: Maintained F: hw/ppc/pnv* @@ -1300,6 +1312,8 @@ F: hw/ppc/virtex_ml507.c =20 sam460ex M: BALATON Zoltan +R: David Gibson +R: Greg Kurz L: qemu-ppc@nongnu.org S: Maintained F: hw/ppc/sam460ex.c @@ -2086,8 +2100,9 @@ F: tests/qtest/fw_cfg-test.c T: git https://github.com/philmd/qemu.git fw_cfg-next =20 XIVE -M: David Gibson M: C=C3=A9dric Le Goater +R: David Gibson +R: Greg Kurz L: qemu-ppc@nongnu.org S: Supported F: hw/*/*xive* --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661482; cv=none; d=zohomail.com; s=zohoarc; b=DQwZQo/T/ydsCtFZVZAIJFhuJyN5C6XuimUykFg0KV3Fu5xEe+DjK1M25PlPbfjWS9JJVZH9dukvd1aN9jEVh3SL48TPbvQp4iFQum/hUMZxVyj3IaCvu3szsjzToNtysQLUIBstpAapx83TD+iCoR5pBvC0QWtXk6Q7DbvugKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661482; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A++NEZ7e1k0vL7Q+sGb7ltyh0I6PCERwW+DO4amORVs=; b=d1tY5j402iRzPWke1XKx+tQzfQ27UG5lfz3w1GlDRV2Jv1793sKznpy0Gxv4yYor8TOnQijqtBjW0mO9TQC9cUv0aE+oDLgOqh6/Scp0uM1BIfQBKq20zu/cl5P905Q5vUZnKszjwzAkWjf5ggswcJ/VXr9jmUmtbDF3UkT5o1I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661482281750.841979050862; Thu, 10 Dec 2020 20:38:02 -0800 (PST) Received: from localhost ([::1]:47216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaBs-0004Y4-Sk for importer@patchew.org; Thu, 10 Dec 2020 23:38:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqe-0005x0-LF; Thu, 10 Dec 2020 23:16:07 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:54007 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqb-0000sv-Hf; Thu, 10 Dec 2020 23:16:03 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrf2Z72z9sXW; Fri, 11 Dec 2020 15:15:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660114; bh=OSAOjeV6FcST2uRqHajM9Kcs4IwieLnB+OS8vy1e6O4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GN3ODtej/IFpfcIzKaI3O07Uyow/4pIGfcTop5NxFzUI60fzOwbRGXe8BfuBzLwly /zny9K1R4J9pF7mE+v4ZcB643D5qk6bHLhBturlCHQcfCO47Q2Lo1dy6q5BQMvlOH8 Wji5rthxWe5r1aehWCrHt0gJF+GeeKOASMDeWjW8= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 24/30] ppc/e500: Free irqs array to avoid memleak Date: Fri, 11 Dec 2020 15:15:01 +1100 Message-Id: <20201211041507.425378-25-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, Gan Qixin , Euler Robot , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Gan Qixin When running qom-test, a memory leak occurred in the ppce500_init function, this patch free irqs array to fix it. ASAN shows memory leak stack: Direct leak of 40 byte(s) in 1 object(s) allocated from: #0 0xfffc5ceee1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0) #1 0xfffc5c806800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800) #2 0xaaacf9999244 in ppce500_init qemu/hw/ppc/e500.c:859 #3 0xaaacf97434e8 in machine_run_board_init qemu/hw/core/machine.c:1134 #4 0xaaacf9c9475c in qemu_init qemu/softmmu/vl.c:4369 #5 0xaaacf94785a0 in main qemu/softmmu/main.c:49 Reported-by: Euler Robot Signed-off-by: Gan Qixin Message-Id: <20201204075822.359832-1-ganqixin@huawei.com> Signed-off-by: David Gibson --- hw/ppc/e500.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index ae39b9358e..74f33af88e 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -925,6 +925,7 @@ void ppce500_init(MachineState *machine) ccsr_addr_space); =20 mpicdev =3D ppce500_init_mpic(pms, ccsr_addr_space, irqs); + g_free(irqs); =20 /* Serial */ if (serial_hd(0)) { --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661938; cv=none; d=zohomail.com; s=zohoarc; b=BvLT47X27O2M9m0v5sr02znY0LnDYxbqMEJ8mY6LsqKiteLs3UedQ93W7lCzd6uz6khqsG/Rx//azlGQa8nqtdp5lE7UCUCht4ltfCGygpf0lkurvFj6daosU+Z28bFK1nw841RdGjpdhh1zCNXQxcPOgpQBHocVNUIIVXEdzdU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661938; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VEGKgyEKkDq/5c9sh/qD3zRfMOhuLCHg6Y3DBcKc4EY=; b=TJKmJolufVnGD3QfiK2CWEhkBcxQaV7XhxALfZMKPuYP579sWcYYh97vwmEPu5I8sv7X1mM05wHzcRRsCcE2AA7ummVMsJ8yBnpTsL7sP+peKt7SyPTLUZv89EFc47MOdTpUYT0Bg4Q2OGFfmyjzVQ2Xhky5RcovCFNbs+fWWUc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661938988535.3516607668433; Thu, 10 Dec 2020 20:45:38 -0800 (PST) Received: from localhost ([::1]:36320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaJF-0003WZ-FK for importer@patchew.org; Thu, 10 Dec 2020 23:45:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqe-0005x1-MD; Thu, 10 Dec 2020 23:16:07 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:59545 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqb-0000sx-FZ; Thu, 10 Dec 2020 23:16:03 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrf5MYQz9sXV; Fri, 11 Dec 2020 15:15:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660114; bh=KXt5m26LRHcKPaeVzJr7A69rPQVXxzcMgxfXZnq3Izs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XKWfkikiOLEVdxN6mefuzdI0kCGQy3oeE8zohOifqX/N/7RH830iSqwp5ps/Cbpl0 9pXVwUuNVNfn/lmOvjv3TwRUZ7Hhxx8hV2rcxhM+/5JdoSkXmCPKIGztFQajjWK0NJ qAVvzVxgmUwyt/DvU3p4cm6ukoZayWFh6pKRwsDw= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 25/30] ppc/translate: Use POWERPC_MMU_64 to detect 64-bit MMU models Date: Fri, 11 Dec 2020 15:15:02 +1100 Message-Id: <20201211041507.425378-26-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephane Duverger , David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Stephane Duverger The ppc_tr_init_disas_context() function currently checks whether the MMU is 64-bit by ANDing its model type with POWERPC_MMU_64B. This is wrong : POWERPC_MMU_64B isn't a mask, it is the generic MMU model for pre-PowerISA-2.03 64-bit CPUs (ie. PowerPC 970 in QEMU). Use POWERPC_MMU_64 instead of POWERPC_MMU_64B. This should fix a potential bug with some 32-bit CPUs for which 'need_access_type' was mis-computed because (POWERPC_MMU_32B & POWERPC_MMU_64B) happens to be equal to 1. The end result being a crash in ppc_hash32_direct_store() because the access type isn't set: cpu_abort(cs, "ERROR: instruction should not need " "address translation\n"); This doesn't change anything for 'lazy_tlb_flush' since POWERPC_MMU_32B is checked first. Fixes: 5f2a6254522b ("ppc: Don't set access_type on all load/stores on hash= 64") Signed-off-by: Stephane Duverger [groug: - extended patch to address another misuse of POWERPC_MMU_64B - updated title and changelog accordingly] Signed-off-by: Greg Kurz Message-Id: <20201209173536.1437351-2-groug@kaod.org> Signed-off-by: David Gibson --- target/ppc/translate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 54cac0e6a7..e68dd65ad3 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7892,7 +7892,7 @@ static void ppc_tr_init_disas_context(DisasContextBas= e *dcbase, CPUState *cs) ctx->insns_flags =3D env->insns_flags; ctx->insns_flags2 =3D env->insns_flags2; ctx->access_type =3D -1; - ctx->need_access_type =3D !(env->mmu_model & POWERPC_MMU_64B); + ctx->need_access_type =3D !(env->mmu_model & POWERPC_MMU_64); ctx->le_mode =3D !!(env->hflags & (1 << MSR_LE)); ctx->default_tcg_memop_mask =3D ctx->le_mode ? MO_LE : MO_BE; ctx->flags =3D env->flags; @@ -7902,7 +7902,7 @@ static void ppc_tr_init_disas_context(DisasContextBas= e *dcbase, CPUState *cs) #endif ctx->lazy_tlb_flush =3D env->mmu_model =3D=3D POWERPC_MMU_32B || env->mmu_model =3D=3D POWERPC_MMU_601 - || (env->mmu_model & POWERPC_MMU_64B); + || env->mmu_model & POWERPC_MMU_64; =20 ctx->fpu_enabled =3D !!msr_fp; if ((env->flags & POWERPC_FLAG_SPE) && msr_spe) { --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661628; cv=none; d=zohomail.com; s=zohoarc; b=dGsR7JLveqmxOpSrofvh872ddJ+7pNia37DFggOaaWCsgUX0/YRa7S3TXa4ueFZuU5NTzfwQUIc0qSMNTeRc83HDCSTbaOsJocZA2/JL2P1NBnvn2o3YTnxn+jDcZi7SPOwHE3yjxrn9JflhuRLLD99eVRd31+WCOxb3HyxIEZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661628; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mYhCxaMGofGH0wWnHYDp6Leka7FWi++Y/UGkFm356U4=; b=PbntNoW0twVCYzEv8sUwlWn+z8d6tHH4cstMIKNT7h/WvfdzKapNSQ3D4ZjMEN1G6/HWDc4KjeRuYYyO5I9+d/jFRLpfHmXy25HYTogorw92gh6gDcd1AEPfVyKSMlFPt/MMaA+JVDn5A8bfF99AavmVWLP+SNyMKPMQawaTV+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661628356652.9942725560554; Thu, 10 Dec 2020 20:40:28 -0800 (PST) Received: from localhost ([::1]:52712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaEB-0006tC-OG for importer@patchew.org; Thu, 10 Dec 2020 23:40:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqi-0005yo-BC; Thu, 10 Dec 2020 23:16:09 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:35545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqc-0000uQ-UL; Thu, 10 Dec 2020 23:16:05 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrf6YDkz9sXX; Fri, 11 Dec 2020 15:15:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660114; bh=fi1OCAmD51L422wOA0Op4lrQhSY509yAY53QJkTV0ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jnC+jm/BAqQmVMW2XHT3cwgjOUzRfpKlpRDx+SbxafoW6sWZkSBcbaVLwaqYyu7Vh KbLFVscTm40LWQBEG1zDhSR5UjjBktL8gbruatwh703EwzUAZipe1txmTe7dTCx4SE ypQFj09qdNOHn6WBapFadv8ku3JjNnMicPxt0GvQ= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 26/30] target/ppc: Introduce an mmu_is_64bit() helper Date: Fri, 11 Dec 2020 15:15:03 +1100 Message-Id: <20201211041507.425378-27-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz Callers don't really need to know how 64-bit MMU model enums are computed. Hide this in a helper. Signed-off-by: Greg Kurz Message-Id: <20201209173536.1437351-3-groug@kaod.org> Signed-off-by: David Gibson --- target/ppc/cpu-qom.h | 5 +++++ target/ppc/excp_helper.c | 4 ++-- target/ppc/machine.c | 4 ++-- target/ppc/mmu-hash64.c | 2 +- target/ppc/mmu_helper.c | 10 +++++----- target/ppc/translate.c | 2 +- target/ppc/translate_init.c.inc | 2 +- 7 files changed, 17 insertions(+), 12 deletions(-) diff --git a/target/ppc/cpu-qom.h b/target/ppc/cpu-qom.h index 5fdb96f04d..63b9e8632c 100644 --- a/target/ppc/cpu-qom.h +++ b/target/ppc/cpu-qom.h @@ -74,6 +74,11 @@ enum powerpc_mmu_t { POWERPC_MMU_3_00 =3D POWERPC_MMU_64 | 0x00000005, }; =20 +static inline bool mmu_is_64bit(powerpc_mmu_t mmu_model) +{ + return mmu_model & POWERPC_MMU_64; +} + /*************************************************************************= ****/ /* Exception model = */ typedef enum powerpc_excp_t powerpc_excp_t; diff --git a/target/ppc/excp_helper.c b/target/ppc/excp_helper.c index 74f987080f..85de7e6c90 100644 --- a/target/ppc/excp_helper.c +++ b/target/ppc/excp_helper.c @@ -266,7 +266,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) */ if (excp =3D=3D POWERPC_EXCP_HV_EMU #if defined(TARGET_PPC64) - && !((env->mmu_model & POWERPC_MMU_64) && (env->msr_mask & MSR_HVB= )) + && !(mmu_is_64bit(env->mmu_model) && (env->msr_mask & MSR_HVB)) #endif /* defined(TARGET_PPC64) */ =20 ) { @@ -824,7 +824,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int ex= cp_model, int excp) vector =3D (uint32_t)vector; } } else { - if (!msr_isf && !(env->mmu_model & POWERPC_MMU_64)) { + if (!msr_isf && !mmu_is_64bit(env->mmu_model)) { vector =3D (uint32_t)vector; } else { new_msr |=3D (target_ulong)1 << MSR_SF; diff --git a/target/ppc/machine.c b/target/ppc/machine.c index c38e7b1268..d9d911b9b1 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -550,7 +550,7 @@ static bool sr_needed(void *opaque) #ifdef TARGET_PPC64 PowerPCCPU *cpu =3D opaque; =20 - return !(cpu->env.mmu_model & POWERPC_MMU_64); + return !mmu_is_64bit(cpu->env.mmu_model); #else return true; #endif @@ -606,7 +606,7 @@ static bool slb_needed(void *opaque) PowerPCCPU *cpu =3D opaque; =20 /* We don't support any of the old segment table based 64-bit CPUs */ - return cpu->env.mmu_model & POWERPC_MMU_64; + return mmu_is_64bit(cpu->env.mmu_model); } =20 static int slb_post_load(void *opaque, int version_id) diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index 1b1248fc90..0fabc10302 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -1140,7 +1140,7 @@ void ppc_hash64_init(PowerPCCPU *cpu) PowerPCCPUClass *pcc =3D POWERPC_CPU_GET_CLASS(cpu); =20 if (!pcc->hash64_opts) { - assert(!(env->mmu_model & POWERPC_MMU_64)); + assert(!mmu_is_64bit(env->mmu_model)); return; } =20 diff --git a/target/ppc/mmu_helper.c b/target/ppc/mmu_helper.c index 9f22b66ea9..ca88658cba 100644 --- a/target/ppc/mmu_helper.c +++ b/target/ppc/mmu_helper.c @@ -2002,7 +2002,7 @@ void helper_store_601_batl(CPUPPCState *env, uint32_t= nr, target_ulong value) void ppc_tlb_invalidate_all(CPUPPCState *env) { #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { env->tlb_need_flush =3D 0; tlb_flush(env_cpu(env)); } else @@ -2046,7 +2046,7 @@ void ppc_tlb_invalidate_one(CPUPPCState *env, target_= ulong addr) #if !defined(FLUSH_ALL_TLBS) addr &=3D TARGET_PAGE_MASK; #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { /* tlbie invalidate TLBs for all segments */ /* * XXX: given the fact that there are too many segments to invalid= ate, @@ -2091,7 +2091,7 @@ void ppc_store_sdr1(CPUPPCState *env, target_ulong va= lue) qemu_log_mask(CPU_LOG_MMU, "%s: " TARGET_FMT_lx "\n", __func__, value); assert(!cpu->vhyp); #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { target_ulong sdr_mask =3D SDR_64_HTABORG | SDR_64_HTABSIZE; target_ulong htabsize =3D value & SDR_64_HTABSIZE; =20 @@ -2144,7 +2144,7 @@ void ppc_store_ptcr(CPUPPCState *env, target_ulong va= lue) target_ulong helper_load_sr(CPUPPCState *env, target_ulong sr_num) { #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { /* XXX */ return 0; } @@ -2158,7 +2158,7 @@ void helper_store_sr(CPUPPCState *env, target_ulong s= rnum, target_ulong value) "%s: reg=3D%d " TARGET_FMT_lx " " TARGET_FMT_lx "\n", __func__, (int)srnum, value, env->sr[srnum]); #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { PowerPCCPU *cpu =3D env_archcpu(env); uint64_t esid, vsid; =20 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index e68dd65ad3..0984ce637b 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -7892,7 +7892,7 @@ static void ppc_tr_init_disas_context(DisasContextBas= e *dcbase, CPUState *cs) ctx->insns_flags =3D env->insns_flags; ctx->insns_flags2 =3D env->insns_flags2; ctx->access_type =3D -1; - ctx->need_access_type =3D !(env->mmu_model & POWERPC_MMU_64); + ctx->need_access_type =3D !mmu_is_64bit(env->mmu_model); ctx->le_mode =3D !!(env->hflags & (1 << MSR_LE)); ctx->default_tcg_memop_mask =3D ctx->le_mode ? MO_LE : MO_BE; ctx->flags =3D env->flags; diff --git a/target/ppc/translate_init.c.inc b/target/ppc/translate_init.c.= inc index e4082cfde7..a4d0038828 100644 --- a/target/ppc/translate_init.c.inc +++ b/target/ppc/translate_init.c.inc @@ -10671,7 +10671,7 @@ static void ppc_cpu_reset(DeviceState *dev) #endif =20 #if defined(TARGET_PPC64) - if (env->mmu_model & POWERPC_MMU_64) { + if (mmu_is_64bit(env->mmu_model)) { msr |=3D (1ULL << MSR_SF); } #endif --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607662078; cv=none; d=zohomail.com; s=zohoarc; b=J060gF9p5Bp0XvBcRduca/kDKEP22/Jgt61kS2eQOmmcOytfNJmwxr++3ap5trGa0e31/RWFD/mCK8L+5tB0EYghLJ4KLs3rkcJTZmB/bYMSlcvOmT6WumUAlB4iVSVUJ5W2AjVsvhZlo8F6lZAtjqPm7rtJCefCddTaSbXxWd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607662078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FXk/SKfbuFeQyIPc6deXL9KoyReQW9WqkFmGbKQcMWs=; b=YE+DGQfHcZYi0DGGFK/8W+KcCSU0wHV6TSpP++jRBcV8QGogiuVe52Plah0RVQ2OW8tdiyVEaivJ6bW7VIUSCAWW3JD/sk8x6DEASWTIuVq/T8CKoOu4LxlEs0MIww3HBk9waTiCiYuiYC6xbeuw3WtstiswwCdngg2miwTBaro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160766207896254.68698273898815; Thu, 10 Dec 2020 20:47:58 -0800 (PST) Received: from localhost ([::1]:43342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaLU-0006YC-Im for importer@patchew.org; Thu, 10 Dec 2020 23:47:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqi-0005yl-At; Thu, 10 Dec 2020 23:16:09 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:48227 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqd-0000uk-3D; Thu, 10 Dec 2020 23:16:05 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrg2Ljlz9sXZ; Fri, 11 Dec 2020 15:15:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660115; bh=pcjBBUPDwioP0908GC4CNJoGjgvaGxW2KTfiNcpWvwc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BgxkI0Sxdp2ZpOowMEaK1mnl2AdxIZ0MoHJfmQl5b1HTRX2XdlfY7AeBCgS7Oh50W 2kwYe1VT9cWCDektaBB4G5inKoJ2EqRnpmpBQXNkc/5AXXPoqmUpQafq24PsKCNwjz 5JT294Tsb0mnkl9JEet59fOU352A0aBBqYePTFF8= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 27/30] spapr: Pass sPAPR machine state down to spapr_pci_switch_vga() Date: Fri, 11 Dec 2020 15:15:04 +1100 Message-Id: <20201211041507.425378-28-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz This allows to drop a user of qdev_get_machine(). Signed-off-by: Greg Kurz Message-Id: <20201209170052.1431440-4-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr_hcall.c | 7 ++++--- hw/ppc/spapr_pci.c | 3 +-- include/hw/ppc/spapr.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 1d8e8e6a88..c0ea0bd579 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1351,6 +1351,7 @@ static target_ulong h_logical_dcbf(PowerPCCPU *cpu, S= paprMachineState *spapr, } =20 static target_ulong h_set_mode_resource_le(PowerPCCPU *cpu, + SpaprMachineState *spapr, target_ulong mflags, target_ulong value1, target_ulong value2) @@ -1365,12 +1366,12 @@ static target_ulong h_set_mode_resource_le(PowerPCC= PU *cpu, switch (mflags) { case H_SET_MODE_ENDIAN_BIG: spapr_set_all_lpcrs(0, LPCR_ILE); - spapr_pci_switch_vga(true); + spapr_pci_switch_vga(spapr, true); return H_SUCCESS; =20 case H_SET_MODE_ENDIAN_LITTLE: spapr_set_all_lpcrs(LPCR_ILE, LPCR_ILE); - spapr_pci_switch_vga(false); + spapr_pci_switch_vga(spapr, false); return H_SUCCESS; } =20 @@ -1411,7 +1412,7 @@ static target_ulong h_set_mode(PowerPCCPU *cpu, Spapr= MachineState *spapr, =20 switch (resource) { case H_SET_MODE_RESOURCE_LE: - ret =3D h_set_mode_resource_le(cpu, args[0], args[2], args[3]); + ret =3D h_set_mode_resource_le(cpu, spapr, args[0], args[2], args[= 3]); break; case H_SET_MODE_RESOURCE_ADDR_TRANS_MODE: ret =3D h_set_mode_resource_addr_trans_mode(cpu, args[0], diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index e946bd5055..cff76479c7 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -2493,9 +2493,8 @@ static int spapr_switch_one_vga(DeviceState *dev, voi= d *opaque) return 0; } =20 -void spapr_pci_switch_vga(bool big_endian) +void spapr_pci_switch_vga(SpaprMachineState *spapr, bool big_endian) { - SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); SpaprPhbState *sphb; =20 /* diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h index b7ced9faeb..e0f10f252c 100644 --- a/include/hw/ppc/spapr.h +++ b/include/hw/ppc/spapr.h @@ -834,7 +834,7 @@ int spapr_dma_dt(void *fdt, int node_off, const char *p= ropname, uint32_t liobn, uint64_t window, uint32_t size); int spapr_tcet_dma_dt(void *fdt, int node_off, const char *propname, SpaprTceTable *tcet); -void spapr_pci_switch_vga(bool big_endian); +void spapr_pci_switch_vga(SpaprMachineState *spapr, bool big_endian); void spapr_hotplug_req_add_by_index(SpaprDrc *drc); void spapr_hotplug_req_remove_by_index(SpaprDrc *drc); void spapr_hotplug_req_add_by_count(SpaprDrcType drc_type, --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661741; cv=none; d=zohomail.com; s=zohoarc; b=GH5zio4FQqWYigg1NxUVREwRUCpyys8RY/6k288coh7gB2tC0PwQZ+MB9vW2Zrlfx3F9bdjlZZrtpPo+pUxwTpwAITd7F4/uQejP1kD0g/+cs/7HC+G37Y/QCd3+DtVgO9tGMOAEECpPgxy03q4ysRGdxIoYLX59KHwVhP+8Pjg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661741; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EkLljm5Uo7gdqTpKUxRuwDXApigKsT0/EwNM8xPYHhk=; b=B/QgnkwcHvvNSVrFrtAJwlXmfc/xjjLjfc/OmlOgcSsqcKNNHj3oLkohD0ytvHdljar3j2tbohZM0KHvA62M4h2BliOgxwDRlztOsCEFt7VhmzDE2/B8Vwg4HNUCsGdMqi+Hg9S9agnelyx3LW1uD2BGx0k2uEaAX8cwdreTSak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661741717964.842101165732; Thu, 10 Dec 2020 20:42:21 -0800 (PST) Received: from localhost ([::1]:55646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaG4-00088Y-GS for importer@patchew.org; Thu, 10 Dec 2020 23:42:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqi-0005ym-Ay; Thu, 10 Dec 2020 23:16:09 -0500 Received: from ozlabs.org ([203.11.71.1]:57039) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqc-0000un-Vl; Thu, 10 Dec 2020 23:16:06 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrg3PwYz9sXY; Fri, 11 Dec 2020 15:15:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660115; bh=GANHHFYVShuhZdNxXbeviRaQLeLYW3TTRD3WfP4D4Nw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGGxhjJTtZg7p9cCtQoUGZIQ0CmKFI6kEOjPdqYPygUVqkuaKemVgAeJ4sswVShmM oS4zC1dmK06hdU1hMaXRIZ+gksGzIw757wDgrGCKX7pDaNzhn8iVTe//jUcr3DNycw SOJNV5Mu7IspqcfGwnnySHzVQFDAcqIiaYd2f6ro= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 28/30] spapr: Don't use qdev_get_machine() in spapr_msi_write() Date: Fri, 11 Dec 2020 15:15:05 +1100 Message-Id: <20201211041507.425378-29-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz spapr_phb_realize() passes the sPAPR machine state as opaque data for the I/O callbacks: memory_region_init_io(&sphb->msiwindow, OBJECT(sphb), &spapr_msi_ops, spapr, ^^^^^ "msi", msi_window_size); Signed-off-by: Greg Kurz Message-Id: <20201209170052.1431440-5-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr_pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index cff76479c7..76d7c91e9c 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -747,7 +747,7 @@ static PCIINTxRoute spapr_route_intx_pin_to_irq(void *o= paque, int pin) static void spapr_msi_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { - SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); + SpaprMachineState *spapr =3D opaque; uint32_t irq =3D data; =20 trace_spapr_pci_msi_write(addr, data, irq); --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661451; cv=none; d=zohomail.com; s=zohoarc; b=Phkx4gkNi0OxjM7Qj7YpNJdBeTDo4Rzte05/Fgow7qrNdQdZ4E9TnXX0e/rPDisfbw9GSMSGPQ/UND8ywAVWOxRSmE+PHYyjP+kqiQRkXrB1vJqCz7YZbMoXUG/5EFomY+mY+tjVX0496t9TB2FUmUv//d3VoQ4aElarUBQJFqg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661451; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jGroJ2DmQAremtlSEBacruQSPXkruLFy6WC/YnUfOYk=; b=brYoi7sEo6oZBA8FwpPbPrvKsA+qTxHzXpRZb3W12/NEmxwcJhy85zI6qVZvMvoGTI6S152YyMMafMTx5qPN5EDqbvxlWq2MvugUaVhZ84GL6L9r21uiTTfVFo4yOf+hlWxmkcaJDNQr+ZpqQRKDTxRWpDqc/HBvCRfh8EFQuTY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661451435165.97765121476698; Thu, 10 Dec 2020 20:37:31 -0800 (PST) Received: from localhost ([::1]:44978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaBO-0003be-3f for importer@patchew.org; Thu, 10 Dec 2020 23:37:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqi-0005yn-BC; Thu, 10 Dec 2020 23:16:09 -0500 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:42249 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqd-0000v9-B1; Thu, 10 Dec 2020 23:16:07 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrg5gJ4z9sXc; Fri, 11 Dec 2020 15:15:15 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660115; bh=DrMnRyJ9M8U0u6yno73lo3uVCJa/SpyEJKsDuEcTiA4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G8eHxEQlLvDEBBFjKGxACtjJ6ut8a9PhJp+vxdnFh4v1HTWGJnmmXBHi4vO++kche agaTsRxrgQXBUkIOCZfAYWmVElGlkfpXdB1no3rXUk93ziM5Y13dJnTF4UKiqWJoRY nLQhi+VLDM89jH+DFQqm1iUJiRnQ6fvNYYgZSOfU= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 29/30] spapr: Pass sPAPR machine state to some RTAS events handling functions Date: Fri, 11 Dec 2020 15:15:06 +1100 Message-Id: <20201211041507.425378-30-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Greg Kurz Some functions in hw/ppc/spapr_events.c get a pointer to the machine state using qdev_get_machine(). Convert them to get it from their caller when possible. Signed-off-by: Greg Kurz Message-Id: <20201209170052.1431440-6-groug@kaod.org> Signed-off-by: David Gibson --- hw/ppc/spapr_events.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/hw/ppc/spapr_events.c b/hw/ppc/spapr_events.c index 1add53547e..3f37b49fd8 100644 --- a/hw/ppc/spapr_events.c +++ b/hw/ppc/spapr_events.c @@ -480,9 +480,8 @@ static SpaprEventLogEntry *rtas_event_log_dequeue(Spapr= MachineState *spapr, return entry; } =20 -static bool rtas_event_log_contains(uint32_t event_mask) +static bool rtas_event_log_contains(SpaprMachineState *spapr, uint32_t eve= nt_mask) { - SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); SpaprEventLogEntry *entry =3D NULL; =20 QTAILQ_FOREACH(entry, &spapr->pending_events, next) { @@ -509,10 +508,10 @@ static void spapr_init_v6hdr(struct rtas_event_log_v6= *v6hdr) v6hdr->company =3D cpu_to_be32(RTAS_LOG_V6_COMPANY_IBM); } =20 -static void spapr_init_maina(struct rtas_event_log_v6_maina *maina, +static void spapr_init_maina(SpaprMachineState *spapr, + struct rtas_event_log_v6_maina *maina, int section_count) { - SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); struct tm tm; int year; =20 @@ -560,7 +559,7 @@ static void spapr_powerdown_req(Notifier *n, void *opaq= ue) entry->extended_length =3D sizeof(*new_epow); =20 spapr_init_v6hdr(v6hdr); - spapr_init_maina(maina, 3 /* Main-A, Main-B and EPOW */); + spapr_init_maina(spapr, maina, 3 /* Main-A, Main-B and EPOW */); =20 mainb->hdr.section_id =3D cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB); mainb->hdr.section_length =3D cpu_to_be16(sizeof(*mainb)); @@ -613,7 +612,7 @@ static void spapr_hotplug_req_event(uint8_t hp_id, uint= 8_t hp_action, entry->extended_length =3D sizeof(*new_hp); =20 spapr_init_v6hdr(v6hdr); - spapr_init_maina(maina, 3 /* Main-A, Main-B, HP */); + spapr_init_maina(spapr, maina, 3 /* Main-A, Main-B, HP */); =20 mainb->hdr.section_id =3D cpu_to_be16(RTAS_LOG_V6_SECTION_ID_MAINB); mainb->hdr.section_length =3D cpu_to_be16(sizeof(*mainb)); @@ -808,9 +807,9 @@ static uint32_t spapr_mce_get_elog_type(PowerPCCPU *cpu= , bool recovered, return summary; } =20 -static void spapr_mce_dispatch_elog(PowerPCCPU *cpu, bool recovered) +static void spapr_mce_dispatch_elog(SpaprMachineState *spapr, PowerPCCPU *= cpu, + bool recovered) { - SpaprMachineState *spapr =3D SPAPR_MACHINE(qdev_get_machine()); CPUState *cs =3D CPU(cpu); CPUPPCState *env =3D &cpu->env; uint64_t rtas_addr; @@ -927,7 +926,7 @@ void spapr_mce_req_event(PowerPCCPU *cpu, bool recovere= d) warn_report("Received a fwnmi while migration was in progress"); } =20 - spapr_mce_dispatch_elog(cpu, recovered); + spapr_mce_dispatch_elog(spapr, cpu, recovered); } =20 static void check_exception(PowerPCCPU *cpu, SpaprMachineState *spapr, @@ -980,7 +979,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))) { + if (rtas_event_log_contains(spapr, EVENT_CLASS_MASK(i))) { const SpaprEventSource *source =3D spapr_event_sources_get_source(spapr->event_sources, i); =20 @@ -1007,7 +1006,7 @@ static void event_scan(PowerPCCPU *cpu, SpaprMachineS= tate *spapr, } =20 for (i =3D 0; i < EVENT_CLASS_MAX; i++) { - if (rtas_event_log_contains(EVENT_CLASS_MASK(i))) { + if (rtas_event_log_contains(spapr, EVENT_CLASS_MASK(i))) { const SpaprEventSource *source =3D spapr_event_sources_get_source(spapr->event_sources, i); =20 --=20 2.29.2 From nobody Fri May 17 07:56:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1607661936; cv=none; d=zohomail.com; s=zohoarc; b=ZfUdBjxB52OpVsChrDZ2RTNsFAOdslb3IM+wBbG7tobO7g4WPAdHnw4Ua1ro0v3DG74ESPohtRtPOSRM35mTXgftH7K782rd8W6GwEqoqcWOT4Stq/mMjThDhVgtdL23lkjs4cRUtsnS6B5w7XtOXDIjVDHtUUndBA3+Kf8Y6FE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607661936; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L2Q9yybX5N9Sq3xN7Bs7DPaFiW9mjYc94QNnoXMTzfg=; b=RuA9EqIwk7VDefo8+eGaOcNAR8nG5ulc2LPDcOYOpf790EnnOWgJjwK3YTRDQqNemZEEnDn/wtYzYKRfk1XXJEfxOJFC1DJmELlxrmu8AaPTD/HNvTHRSbPALDWRD+3JJwWi6hAEAIOQB6G+vSzhMO8RuefPndj0zCG360mr5b4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1607661936202277.15829486841915; Thu, 10 Dec 2020 20:45:36 -0800 (PST) Received: from localhost ([::1]:35984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1knaJB-0003OI-Tl for importer@patchew.org; Thu, 10 Dec 2020 23:45:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:34254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqj-0005zU-RC; Thu, 10 Dec 2020 23:16:12 -0500 Received: from bilbo.ozlabs.org ([203.11.71.1]:38843 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1knZqf-0000vd-BR; Thu, 10 Dec 2020 23:16:09 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 4Cscrh1qwSz9sXf; Fri, 11 Dec 2020 15:15:16 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1607660116; bh=YxkZyI5fOmjkXtZwU5K0Lrtk/HUunHAwZHFCDbTMEJQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PSAOmHCA6wpVoOtJhyOwYlSk7mc3b1njL8N+3heX/1bEQbbP19vKQyrTAe7vQVzrC nP4zwf2AKAbnP1M+a54j7/M5iWzMAd3qCqdNuCxqv7niwhErkXJnn82x92uvT3orFp 9Zl06o8yDu/OxNUq6p5e5/4HFh/T1Sb09gqOn2k4= From: David Gibson To: peter.maydell@linaro.org Subject: [PULL 30/30] spapr.c: set a 'kvm-type' default value instead of relying on NULL Date: Fri, 11 Dec 2020 15:15:07 +1100 Message-Id: <20201211041507.425378-31-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201211041507.425378-1-david@gibson.dropbear.id.au> References: <20201211041507.425378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Henrique Barboza , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, David Gibson , groug@kaod.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Daniel Henrique Barboza spapr_kvm_type() is considering 'vm_type=3DNULL' as a valid input, where the function returns 0. This is relying on the current QEMU machine options handling logic, where the absence of the 'kvm-type' option will be reflected as 'vm_type=3DNULL' in this function. This is not robust, and will break if QEMU options code decides to propagate something else in the case mentioned above (e.g. an empty string instead of NULL). Let's avoid this entirely by setting a non-NULL default value in case of no user input for 'kvm-type'. spapr_kvm_type() was changed to handle 3 fixed values of kvm-type: "auto", "hv", and "pr", with "auto" being the default if no kvm-type was set by the user. This allows us to always be predictable regardless of any enhancements/changes made in QEMU options mechanics. While we're at it, let's also document in 'kvm-type' description the already existing default mode, now named 'auto'. The information provided about it is based on how the pseries kernel handles the KVM_CREATE_VM ioctl(), where the default value '0' makes the kernel choose an available KVM module to use, giving precedence to kvm_hv. This logic is described in the kernel source file arch/powerpc/kvm/powerpc.c, function kvm_arch_init_v= m(). Signed-off-by: Daniel Henrique Barboza Message-Id: <20201210145517.1532269-2-danielhb413@gmail.com> Signed-off-by: David Gibson Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index d6ab40f321..16d42ba7a9 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -3024,17 +3024,25 @@ static void spapr_machine_init(MachineState *machin= e) qemu_cond_init(&spapr->fwnmi_machine_check_interlock_cond); } =20 +#define DEFAULT_KVM_TYPE "auto" static int spapr_kvm_type(MachineState *machine, const char *vm_type) { - if (!vm_type) { + /* + * The use of g_ascii_strcasecmp() for 'hv' and 'pr' is to + * accomodate the 'HV' and 'PV' formats that exists in the + * wild. The 'auto' mode is being introduced already as + * lower-case, thus we don't need to bother checking for + * "AUTO". + */ + if (!vm_type || !strcmp(vm_type, DEFAULT_KVM_TYPE)) { return 0; } =20 - if (!strcmp(vm_type, "HV")) { + if (!g_ascii_strcasecmp(vm_type, "hv")) { return 1; } =20 - if (!strcmp(vm_type, "PR")) { + if (!g_ascii_strcasecmp(vm_type, "pr")) { return 2; } =20 @@ -3273,10 +3281,15 @@ static void spapr_instance_init(Object *obj) =20 spapr->htab_fd =3D -1; spapr->use_hotplug_event_source =3D true; + spapr->kvm_type =3D g_strdup(DEFAULT_KVM_TYPE); object_property_add_str(obj, "kvm-type", spapr_get_kvm_type, spapr_set_kvm_type); object_property_set_description(obj, "kvm-type", - "Specifies the KVM virtualization mode= (HV, PR)"); + "Specifies the KVM virtualization mode= (auto," + " hv, pr). Defaults to 'auto'. This mo= de will use" + " any available KVM module loaded in t= he host," + " where kvm_hv takes precedence if bot= h kvm_hv and" + " kvm_pr are loaded."); object_property_add_bool(obj, "modern-hotplug-events", spapr_get_modern_hotplug_events, spapr_set_modern_hotplug_events); --=20 2.29.2