From nobody Mon Apr 29 09:52:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502829045322692.4318524471905; Tue, 15 Aug 2017 13:30:45 -0700 (PDT) Received: from localhost ([::1]:36283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhiU6-0004aD-Lb for importer@patchew.org; Tue, 15 Aug 2017 16:30:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41924) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dhiSc-0003Ur-Sz for qemu-devel@nongnu.org; Tue, 15 Aug 2017 16:29:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dhiSY-0003M9-Po for qemu-devel@nongnu.org; Tue, 15 Aug 2017 16:29:10 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dhiSY-0003Ln-H8 for qemu-devel@nongnu.org; Tue, 15 Aug 2017 16:29:06 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7FKSqcb134616 for ; Tue, 15 Aug 2017 16:29:05 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cc6f3c2jy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 15 Aug 2017 16:29:04 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Aug 2017 16:29:01 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 15 Aug 2017 16:28:57 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7FKSvef22479054; Tue, 15 Aug 2017 20:28:57 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87D1BAC041; Tue, 15 Aug 2017 16:29:16 -0400 (EDT) Received: from localhost.localdomain (unknown [9.85.130.61]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id EC05FAC03A; Tue, 15 Aug 2017 16:29:14 -0400 (EDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Date: Tue, 15 Aug 2017 17:28:46 -0300 X-Mailer: git-send-email 2.9.4 X-TM-AS-GCONF: 00 x-cbid: 17081520-0036-0000-0000-00000259495C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007551; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000221; SDB=6.00902814; UDB=6.00452202; IPR=6.00683029; BA=6.00005534; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016710; XFM=3.00000015; UTC=2017-08-15 20:28:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17081520-0037-0000-0000-0000417361A6 Message-Id: <20170815202846.24749-1-danielhb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-15_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708150339 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] hw/ppc: disable hotplug before CAS is completed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, qemu-ppc@nongnu.org, mdroth@linux.vnet.ibm.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch is a follow up on the discussions that started with Laurent's patch series "spapr: disable hotplugging without OS" [1] and discussions made at patch "spapr: reset DRCs on migration pre_load" [2]. At this moment, we do not support CPU/memory hotplug in early boot stages, before CAS. The reason is that the hotplug event can't be handled at SLOF level (or even in PRELAUNCH runstate) and at the same time can't be canceled. This leads to devices being unable to be hot unplugged and, in some cases, guest kernel Ooops. After CAS, with the FDT in place, the guest can handle the hotplug events and everything works as usual. An attempt to try to support hotplug before CAS was made, but not successful. The key difference in the current code flow between a coldplugged and a hotplugged device, in the PRELAUNCH state, is that the coldplugged device is registered at the base FDT, allowing its DRC to go straight to CONFIGURED state. In theory, this can also be done with a hotplugged device if we can add it to the base of the existing FDT. However, tampering with the FDT after writing in the guest memory, besides being a dubitable idea, is also not possible. The FDT is written in ppc_spapr_reset and there is no way to retrieve it - we can calculate the fdt_address but the fdt_size isn't stored. Storing the fdt_size to allow for later retrieval is yet another state that would need to be migrated. In short, it is not worth the trouble. All this said, this patch opted to disable CPU/mem hotplug at early boot stages. CAS detection is made by checking if there are any bits set in ov5_cas to avoid adding an extra state that would need tracking/migration. The patch also makes sure that it doesn't interfere with hotplug in the INMIGRATE state. [1] https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg05226.html [2] https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg01989.html Signed-off-by: Daniel Henrique Barboza --- hw/ppc/spapr.c | 26 ++++++++++++++++++++++++++ hw/ppc/spapr_ovec.c | 7 +++++++ include/hw/ppc/spapr_ovec.h | 1 + 3 files changed, 34 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index f7a1972..bdcc813 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2803,6 +2803,19 @@ out: error_propagate(errp, local_err); } =20 +/* + * 'h_client_architecture_support' will set at least OV5_FORM1_AFFINITY + * in ov5_cas when intersecting it with spapr->ov5 and ov5_guest. It's safe + * then to assume that CAS ov5_cas will have something set after CAS. + */ +static bool spapr_cas_completed(sPAPRMachineState *spapr) +{ + if (spapr->ov5_cas =3D=3D NULL) { + return false; + } + return !spapr_ovec_is_unset(spapr->ov5_cas); +} + static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState= *dev, Error **errp) { @@ -3256,6 +3269,19 @@ static void spapr_machine_device_unplug_request(Hotp= lugHandler *hotplug_dev, static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { + sPAPRMachineState *spapr; + Error *local_err =3D NULL; + + if (dev->hotplugged && !runstate_check(RUN_STATE_INMIGRATE)) { + spapr =3D SPAPR_MACHINE(hotplug_dev); + if (!spapr_cas_completed(spapr)) { + error_setg(&local_err, + "CPU/memory hotplug not supported at early boot"); + error_propagate(errp, local_err); + return; + } + } + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { spapr_memory_pre_plug(hotplug_dev, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { diff --git a/hw/ppc/spapr_ovec.c b/hw/ppc/spapr_ovec.c index 41df4c3..fe7bc85 100644 --- a/hw/ppc/spapr_ovec.c +++ b/hw/ppc/spapr_ovec.c @@ -134,6 +134,13 @@ bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr) return test_bit(bitnr, ov->bitmap) ? true : false; } =20 +bool spapr_ovec_is_unset(sPAPROptionVector *ov) +{ + unsigned long lastbit; + lastbit =3D find_last_bit(ov->bitmap, OV_MAXBITS); + return (lastbit =3D=3D OV_MAXBITS); +} + static void guest_byte_to_bitmap(uint8_t entry, unsigned long *bitmap, long bitmap_offset) { diff --git a/include/hw/ppc/spapr_ovec.h b/include/hw/ppc/spapr_ovec.h index 9edfa5f..8126374 100644 --- a/include/hw/ppc/spapr_ovec.h +++ b/include/hw/ppc/spapr_ovec.h @@ -71,6 +71,7 @@ void spapr_ovec_cleanup(sPAPROptionVector *ov); void spapr_ovec_set(sPAPROptionVector *ov, long bitnr); void spapr_ovec_clear(sPAPROptionVector *ov, long bitnr); bool spapr_ovec_test(sPAPROptionVector *ov, long bitnr); +bool spapr_ovec_is_unset(sPAPROptionVector *ov); sPAPROptionVector *spapr_ovec_parse_vector(target_ulong table_addr, int ve= ctor); int spapr_ovec_populate_dt(void *fdt, int fdt_offset, sPAPROptionVector *ov, const char *name); --=20 2.9.4