From nobody Thu Nov 14 17:08:06 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+70377+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+70377+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1610696750; cv=none; d=zohomail.com; s=zohoarc; b=naTUYVkZZl7wGd/BPIpqmcS1axIBDFBQlybEX6USLVdkk9VXXpVdtx0INb6ADaot8+KIkXfEA+WgbE9uPYSDgU6wNGo3b1QuynpCPp2fSecuxLHOMlSbmX1knBCpB/MMW+cjo9XRj5KXxsaE4Dk/qjDbcHwIw80RqBMMh5u1+8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1610696750; 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=brkNF/dJSxwoikXtCsPkXStKTaBvx/G4f2UPJMBfIEA=; b=KOGSa/z7WFu7+PtDdCvAodXdRynDztMBwXKzwxBW/R6NycDEG0dhI40+bqfAb12RkB6+tZ/x3YMRlSbLelU/rqMpYwOnjzLqgOCOeOR7QOVn/Q4bsp0XeS5t51WSZueI5dH93ZVJrEHh3TxQTZoTKPS/81ZH3PYwPqCt8K/PhPQ= 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+70377+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 1610696750804639.8030308708677; Thu, 14 Jan 2021 23:45:50 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zVL9YY1788612x5dyMwsp10q; Thu, 14 Jan 2021 23:45:50 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.976.1610696749786138966 for ; Thu, 14 Jan 2021 23:45:50 -0800 X-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10F7jaB9124772; Fri, 15 Jan 2021 07:45:46 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 360kvkbnhm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jan 2021 07:45:46 +0000 X-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10F7dkjH132042; Fri, 15 Jan 2021 07:45:46 GMT X-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 360keavre8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Jan 2021 07:45:45 +0000 X-Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 10F7jjx9008882; Fri, 15 Jan 2021 07:45:45 GMT X-Received: from localhost.localdomain (/70.36.60.91) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 14 Jan 2021 23:45:45 -0800 From: "Ankur Arora" To: devel@edk2.groups.io Cc: imammedo@redhat.com, lersek@redhat.com, Ankur Arora , Jordan Justen , Ard Biesheuvel , Boris Ostrovsky , Aaron Young Subject: [edk2-devel] [PATCH v3 06/10] OvmfPkg/CpuHotplugSmm: support CPU eject Date: Thu, 14 Jan 2021 23:45:29 -0800 Message-Id: <20210115074533.277448-7-ankur.a.arora@oracle.com> In-Reply-To: <20210115074533.277448-1-ankur.a.arora@oracle.com> References: <20210115074533.277448-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: s1f0thqczD8PU445FfgNqnn0x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1610696750; bh=vR0kVq+GHnI3dk34w/zAOnkevFNXmQVFzLIq9cq58uc=; h=Cc:Date:From:Reply-To:Subject:To; b=xTh5yrBRseISM5DBeL8ef8C9D4IGHuDzhPpn+/gbTcZqzSopfl2QfnjgBDyj4nnDnUY NLrPO98/wz4D/efnt1QtkWB59gQQCGkms5q0F/w+N0UWXJO+D34GzohoMCQFWm2zfTEwN WHvd5AKeRhoRMNxO18UM0i1D+VkU09ipaMk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" PiSmmCpuDxeSmm exposes CPU_HOT_EJECT_DATA in SMRAM which we use as a communication channel between the two CPU hot-unplug phases. The first phase, unplug, happens by way of CpuHotplugMmi() where we collect CPUs that need to be unplugged and mark them for removal in SMM data structures. The second phase, eject, via SmmCpuFeaturesRendezvousExit() does the actual ejection once the CPU to be ejected is in the tail end of its SMI handling. This commit does not contain any of the ejection machinery, only sets up state to enable us to do that. 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 | 49 +++++++++++++++++++++++++++++= ++-- OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf | 1 + 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 38c71bc11864..f088049c7aef 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -32,11 +32,12 @@ STATIC EFI_MM_CPU_IO_PROTOCOL *mMmCpuIo; // STATIC EFI_SMM_CPU_SERVICE_PROTOCOL *mMmCpuService; // -// This structure is a communication side-channel between the +// These structures are communication side-channels between the // EFI_SMM_CPU_SERVICE_PROTOCOL consumer (i.e., this driver) and provider // (i.e., PiSmmCpuDxeSmm). // STATIC CPU_HOT_PLUG_DATA *mCpuHotPlugData; +STATIC CPU_HOT_EJECT_DATA *mCpuHotEjectData; // // SMRAM arrays for fetching the APIC IDs of processors with pending event= s (of // known event types), for the time of just one MMI. @@ -317,6 +318,23 @@ Fatal: return EFI_INTERRUPT_PENDING; } =20 +VOID +EFIAPI +CpuEject( + IN UINTN ProcessorNum + ) +{ + // + // APIC ID is UINT32, but mCpuHotEjectData->ApicIdMap[] is UINT64 + // so use UINT64 throughout. + // + UINT64 ApicId; + + ApicId =3D mCpuHotEjectData->ApicIdMap[ProcessorNum]; + if (ApicId =3D=3D CPU_EJECT_INVALID) { + return; + } +} =20 // // Entry point function of this driver. @@ -368,8 +386,14 @@ CpuHotplugEntry ( // Our DEPEX on EFI_SMM_CPU_SERVICE_PROTOCOL guarantees that PiSmmCpuDxe= Smm // has pointed PcdCpuHotPlugDataAddress to CPU_HOT_PLUG_DATA in SMRAM. // + // Additionally, CPU HotUnplug is available only if CPU HotPlug is, so t= he + // same DEPEX also guarantees that PcdCpuHotEjectDataAddress points + // to CPU_HOT_EJECT_DATA in SMRAM. + // mCpuHotPlugData =3D (VOID *)(UINTN)PcdGet64 (PcdCpuHotPlugDataAddress); - if (mCpuHotPlugData =3D=3D NULL) { + mCpuHotEjectData =3D (VOID *)(UINTN)PcdGet64 (PcdCpuHotEjectDataAddress); + + if (mCpuHotPlugData =3D=3D NULL) { Status =3D EFI_NOT_FOUND; DEBUG ((DEBUG_ERROR, "%a: CPU_HOT_PLUG_DATA: %r\n", __FUNCTION__, Stat= us)); goto Fatal; @@ -380,6 +404,9 @@ CpuHotplugEntry ( if (mCpuHotPlugData->ArrayLength =3D=3D 1) { return EFI_UNSUPPORTED; } + ASSERT (mCpuHotEjectData && + (mCpuHotPlugData->ArrayLength =3D=3D mCpuHotEjectData->ArrayLeng= th)); + // // Allocate the data structures that depend on the possible CPU count. // @@ -462,6 +489,24 @@ CpuHotplugEntry ( // SmbaseInstallFirstSmiHandler (); =20 + if (mCpuHotEjectData) { + UINT32 Idx; + // + // To do CPU eject we need to map ProcessorNum -> APIC_ID. However, by= the + // time CpuEject() is called (via SmmCpuFeaturesRendezvousExit()), we'= ve + // already called RemoveProcessor() and so the APIC ID cannot be looke= d up + // from SMM data structures. + // + // So use mCpuHotEjectData->ApicIdMap to map from ProcessorNum -> APIC= _ID. + // + // Initialize to known invalid values before installing the handler. + // + for (Idx =3D 0; Idx < mCpuHotEjectData->ArrayLength; Idx++) { + mCpuHotEjectData->ApicIdMap[Idx] =3D CPU_EJECT_INVALID; + } + mCpuHotEjectData->Handler =3D CpuEject; + } + return EFI_SUCCESS; =20 ReleasePostSmmPen: diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf b/OvmfPkg/CpuHotplugSm= m/CpuHotplugSmm.inf index 04322b0d7855..51d022e10416 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf @@ -54,6 +54,7 @@ =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CON= SUMES + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CON= SUMES gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase ## CON= SUMES =20 [FeaturePcd] --=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 (#70377): https://edk2.groups.io/g/devel/message/70377 Mute This Topic: https://groups.io/mt/79697148/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-