From nobody Thu Nov 14 16:57:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70486+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70486+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1610951831; cv=none; d=zohomail.com; s=zohoarc; b=CPsHpQ+LZyjS+B0u2D8qn/w5jnNnL6YmigjW7MYggOsseGzWffQ7ENXBz3QJWf2becLbALt+/bxPvT/zBywD9nDFvaUZehJYETiHr7S+GyxQegutY8h4mNY+rgWym6sY/8olf3b68lHohRF7bfBoC0L56RGwBv4g7lqEaXTep00= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610951831; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=lK5YQQWg9Tq42W3tbbrrHp14A/kLbADFb6ZjEhGAL3Q=; b=GaJLJr+loPfOCVKKapp0NlhIFoIMwuG5501kpCxk1WCbluxMPH+dlwQKtJx8MEWlh3E2cZTkSkt6msgsVkSMunBxZEe8CJ1O+HlFXJfqvWlsbcieRi5LtUNswAD1uP5cOn2i08/sJxhlDnzGbuQKIvAH6K8u0jQEy/JWaxvT9/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70486+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1610951831316830.0087416966304; Sun, 17 Jan 2021 22:37:11 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id GESmYY1788612xRwqzIeVonF; Sun, 17 Jan 2021 22:37:11 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web10.30155.1610951830471775831 for ; Sun, 17 Jan 2021 22:37:10 -0800 X-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10I6YIRo093345; Mon, 18 Jan 2021 06:37:07 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 363r3kkm9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jan 2021 06:37:07 +0000 X-Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10I6VLBE051431; Mon, 18 Jan 2021 06:35:06 GMT X-Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 364a2uj8qx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Jan 2021 06:35:06 +0000 X-Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 10I6Z5ru011771; Mon, 18 Jan 2021 06:35:05 GMT X-Received: from prion.us.oracle.com (/10.159.226.191) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 17 Jan 2021 22:35:04 -0800 From: "Ankur Arora" To: devel@edk2.groups.io Cc: lersek@redhat.com, imammedo@redhat.com, boris.ostrovsky@oracle.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Aaron Young Subject: [edk2-devel] [PATCH v4 4/9] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Sun, 17 Jan 2021 22:34:52 -0800 Message-Id: <20210118063457.358581-5-ankur.a.arora@oracle.com> In-Reply-To: <20210118063457.358581-1-ankur.a.arora@oracle.com> References: <20210118063457.358581-1-ankur.a.arora@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ankur.a.arora@oracle.com X-Gm-Message-State: f3PneULgZdFUfEflGxe1NOOEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610951831; bh=LOuXQtgWl8VbHxk3EBbRzmmcbtQ8prVpNXYppF3NS+w=; h=Cc:Date:From:Reply-To:Subject:To; b=KUFlMAtKlvZMFx6m6hgGJS7iFCxCd4VWXc9ea6bYzjhvLY7kS1q5w5kGYgPOHTIRzJU HqwVMboBtS9i8iGLfBM4/rFtG0gKGBIsDFLmpET2eU/FE0kBa64HBqwRRIf1xdbEfev/k T3KNk0sU8z0AcE1mBkpo1ZyZJgPZxScD+B4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Introduce UnplugCpus() which maps each APIC ID being unplugged onto the hardware ID of the processor and informs PiSmmCpuDxeSmm of removal by calling EFI_SMM_CPU_SERVICE_PROTOCOL.RemoveProcessor(). With this change we handle the first phase of unplug where we collect the CPUs that need to be unplugged and mark them for removal in SMM data structures. Cc: Laszlo Ersek Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Igor Mammedov Cc: Boris Ostrovsky Cc: Aaron Young Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3132 Signed-off-by: Ankur Arora --- OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 77 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 77 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 38c71bc11864..ccd5787b7327 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -182,6 +182,81 @@ Fatal: } =20 /** + CPU Hot-unplug MMI handler function. + + @param[in] mUnplugApicIds List of APIC IDs to be unplugged. + + @param[in] ToUnplugCount Count of APIC IDs to be unplugged. + + @retval EFI_SUCCESS Some of the requested APIC IDs will be ho= t-unplugged. + + @retval EFI_INTERRUPT_PENDING Fatal error while hot-plugging. + +**/ +STATIC +EFI_STATUS +EFIAPI +UnplugCpus( + IN APIC_ID *mUnplugApicIds, + IN UINT32 ToUnplugCount + ) +{ + EFI_STATUS Status =3D EFI_SUCCESS; + UINT32 ToUnplugIdx; + UINTN ProcessorNum; + + ToUnplugIdx =3D 0; + while (ToUnplugIdx < ToUnplugCount) { + APIC_ID RemoveApicId; + + RemoveApicId =3D mUnplugApicIds[ToUnplugIdx]; + + // + // mCpuHotPlugData->ApicId maps ProcessorNum -> ApicId. Use it to find + // the ProcessorNum for the APIC ID to be removed. + // + for (ProcessorNum =3D 0; + ProcessorNum < mCpuHotPlugData->ArrayLength; + ProcessorNum++) { + if (mCpuHotPlugData->ApicId[ProcessorNum] =3D=3D RemoveApicId) { + break; + } + } + + // + // Ignore the unplug if APIC ID not found + // + if (ProcessorNum =3D=3D mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_INFO, "%a: did not find APIC ID " FMT_APIC_ID " to unp= lug\n", + __FUNCTION__, RemoveApicId)); + ToUnplugIdx++; + continue; + } + + // + // Mark ProcessorNum for removal from SMM data structures + // + Status =3D mMmCpuService->RemoveProcessor (mMmCpuService, ProcessorNum= ); + + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, RemoveApicId, Status)); + goto Fatal; + } + + ToUnplugIdx++; + } + + // + // We've handled this unplug. + // + return EFI_SUCCESS; + +Fatal: + return EFI_INTERRUPT_PENDING; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -297,6 +372,8 @@ CpuHotplugMmi ( =20 if (PluggedCount > 0) { Status =3D PlugCpus(mPluggedApicIds, PluggedCount); + } else if (ToUnplugCount > 0) { + Status =3D UnplugCpus(mToUnplugApicIds, ToUnplugCount); } =20 if (EFI_ERROR(Status)) { --=20 2.9.3 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70486): https://edk2.groups.io/g/devel/message/70486 Mute This Topic: https://groups.io/mt/79917605/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-