From nobody Sun Nov 24 00:38:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1728444464; cv=none; d=zohomail.com; s=zohoarc; b=bR6rsQizAkH4dTW5JTRUM2EKZ5B2ehIdKohLT2HTF4HDcwjwTe3fQnhvQl5V0bhMoCgCFZKEtj5C+aZsgKfiYiznuzI6ChFvZVE48eGkZPASgGAju4UwEtc53Ec6KmvVL46DZh4bA8ySk4YIl7V2gYBO99Ld8vGQmHARYYY3ClQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1728444464; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=arhogGnJ6dNB0KkQoAHHR/oqGsMimf1KO6moCN5zM64=; b=ktpoU+OPgTZHjBa79dVFDztYcocUR6Mif/onWBu6/ZYXwM9YP5R9jKL+wEf1U9NUVVPt5JyuAda/tvc7ru7goeHfaUxNxCzKxc6ATEavPjNda3ryKmXxS3zVPF+XWDs34vnBhca1HGWM5HTMSEJJEb3XUKBaO6HJjcuabqYDx0w= ARC-Authentication-Results: i=1; mx.zohomail.com; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1728444464683402.4881076942098; Tue, 8 Oct 2024 20:27:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1syNMN-0001t9-7I; Tue, 08 Oct 2024 23:27:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1syNMK-0001fz-B1; Tue, 08 Oct 2024 23:27:32 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1syNMI-00051c-Hx; Tue, 08 Oct 2024 23:27:32 -0400 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4XNdWJ5BvHz6LDCR; Wed, 9 Oct 2024 11:23:08 +0800 (CST) Received: from frapeml500007.china.huawei.com (unknown [7.182.85.172]) by mail.maildlp.com (Postfix) with ESMTPS id 6F6A2140114; Wed, 9 Oct 2024 11:27:27 +0800 (CST) Received: from 00293818-MRGF.huawei.com (10.126.173.89) by frapeml500007.china.huawei.com (7.182.85.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 9 Oct 2024 05:27:08 +0200 To: , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH RFC V4 24/33] arm/virt: Update the guest(via GED) about vCPU hot-(un)plug events Date: Wed, 9 Oct 2024 04:18:06 +0100 Message-ID: <20241009031815.250096-25-salil.mehta@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241009031815.250096-1-salil.mehta@huawei.com> References: <20241009031815.250096-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.126.173.89] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To frapeml500007.china.huawei.com (7.182.85.172) 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=185.176.79.56; envelope-from=salil.mehta@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Salil Mehta From: Salil Mehta via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1728444465072116600 Content-Type: text/plain; charset="utf-8" During any vCPU hot-(un)plug operation, the running guest VM must be notifi= ed about the addition of a new vCPU or the removal of an existing vCPU. This notification is handled via an ACPI GED event, which is eventually demultip= lexed into a vCPU hotplug event, and then further into a specific hot-(un)plug ev= ent for the *targeted* vCPU. Introduce the required ACPI calls into the existing hot-(un)plug hooks, all= owing ACPI GED events to be triggered from QEMU to the guest VM. Co-developed-by: Keqian Zhu Signed-off-by: Keqian Zhu Signed-off-by: Salil Mehta --- hw/arm/virt.c | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 8cb66c11a1..5d440f9121 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3183,6 +3183,7 @@ static void virt_cpu_plug(HotplugHandler *hotplug_dev= , DeviceState *dev, { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); CPUState *cs =3D CPU(dev); + Error *local_err =3D NULL; CPUArchId *cpu_slot; =20 /* insert the cold/hot-plugged vcpu in the slot */ @@ -3220,8 +3221,18 @@ static void virt_cpu_plug(HotplugHandler *hotplug_de= v, DeviceState *dev, * hot-plugged, the guest is also notified. */ if (vms->acpi_dev) { - /* TODO: update acpi hotplug state. Send cpu hotplug event to gues= t */ + HotplugHandlerClass *hhc; + /* update acpi hotplug state and send cpu hotplug event to guest */ + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->plug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); + if (local_err) { + goto fail; + } } + + return; +fail: + error_propagate(errp, local_err); } =20 static void virt_cpu_unplug_request(HotplugHandler *hotplug_dev, @@ -3230,7 +3241,9 @@ static void virt_cpu_unplug_request(HotplugHandler *h= otplug_dev, MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); ARMCPU *cpu =3D ARM_CPU(dev); + HotplugHandlerClass *hhc; CPUState *cs =3D CPU(dev); + Error *local_err =3D NULL; =20 if (!vms->acpi_dev) { error_setg(errp, "GED does not exists or device is not realized!"); @@ -3249,14 +3262,25 @@ static void virt_cpu_unplug_request(HotplugHandler = *hotplug_dev, return; } =20 - /* TODO: request cpu hotplug from guest */ + /* request cpu hotplug from guest */ + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->unplug_request(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); + if (local_err) { + goto fail; + } + + return; +fail: + error_propagate(errp, local_err); } =20 static void virt_cpu_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + HotplugHandlerClass *hhc; CPUState *cs =3D CPU(dev); + Error *local_err =3D NULL; CPUArchId *cpu_slot; =20 if (!vms->acpi_dev) { @@ -3266,7 +3290,12 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_= dev, DeviceState *dev, =20 cpu_slot =3D virt_find_cpu_slot(cs); =20 - /* TODO: update the acpi cpu hotplug state for cpu hot-unplug */ + /* update the acpi cpu hotplug state for cpu hot-unplug */ + hhc =3D HOTPLUG_HANDLER_GET_CLASS(vms->acpi_dev); + hhc->unplug(HOTPLUG_HANDLER(vms->acpi_dev), dev, &local_err); + if (local_err) { + goto fail; + } =20 unwire_gic_cpu_irqs(vms, cs); virt_update_gic(vms, cs, false); @@ -3282,6 +3311,10 @@ static void virt_cpu_unplug(HotplugHandler *hotplug_= dev, DeviceState *dev, =20 cpu_slot->cpu =3D NULL; cs->disabled =3D true; + + return; +fail: + error_propagate(errp, local_err); } =20 static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, --=20 2.34.1