From nobody Thu Nov 14 04:58:38 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+70869+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+70869+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882008349600.0522122241207; Thu, 28 Jan 2021 17:00:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id jUefYY1788612xelItrOrCGu; Thu, 28 Jan 2021 17:00:07 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web11.3118.1611882007258327765 for ; Thu, 28 Jan 2021 17:00:07 -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 10T0eiEb064360; Fri, 29 Jan 2021 01:00:03 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkxs2x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:03 +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 10T0eGVE081743; Fri, 29 Jan 2021 01:00:02 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by userp3030.oracle.com with ESMTP id 368wr13e5c-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzZy+CLqVnw8wc2I359COi06FtUXZZ+e3yAbI5IVlNCwNFp/czT+KRO3IuG7il04ehavPtOTWbH5FoKw7535q8QNW+Ir0JBLlpYsfIlxShPwSqpL7VNl7eydgDMZ2yKVaPpRhRrK3SIHZdT4tSBT3SQ42DZjBrhicdSwLYCZm3mJsGFpQadHjDKCNIeAt4AVlS1BHgMqD9C2owyI56bq4R/krXqP7delX7c4EPM6hDlbQg9442P53uo7rCH6zfQAoC1fEwWyQZKU+WVpVH0qgIgCGHWOpeJWwt0CmxuMTSYjcv6bf+sdJjbbN7uMns8WwdWnf7hDBOFSeoYP1ppGoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Hufg5L/JF8z4aY4/F926/QJQgWmg4i5ZA1TQCxd4MIg=; b=TkNqpLYFpnTRmVUQ62zSCo2rkIZ8dyCvDN2qzX7pff/CFQEHZ8Urz3Rnqia6CbHkND4M0LoIAo5mZsV6/amOSZga7VUnQR4/hPwrHcXBbyn99BjIu4W34o1ButzBg/iRx65YakGMXPjBL2rlBNyHetLRYOyGztW6GfoQhkqp4zSDbvQksXl6u06e9O5L0ioOe4Vva39i2PDzlu//Adbgc6pU+47oThPkv2wUqOhxAFks/bY+eZPObnfFWozdT6lFrTrQUjZS4njwHnXQsPq73ZuQN9hEMs485KBT/Waqto2Ncz3wdG5PXorpFRIE5zRmT1POf+rmKVVGTalwMQwJPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 00:59:59 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 00:59:59 +0000 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 v6 1/9] OvmfPkg/CpuHotplugSmm: refactor hotplug logic Date: Thu, 28 Jan 2021 16:59:42 -0800 Message-Id: <20210129005950.467638-2-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 00:59:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5a112c4-8594-4afe-b320-08d8c3f13346 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: 3EqZRgG3dTTcUGiZ2SvPXMW4H3o2g9vzDV4cfwmbOnAVf+TB6CBIb0yipmHlOXfo6k/66Luu+pfcAxTRSw16A9f0YDfgPDugWrGNr7sQX+kljE47LjB+qLduZ7ACWZSNGjL51vGCfKFgY8J3HVylsKhxSMoGADfIBtQWesHXOlG3iFI/RkTfiIcQB8Psl/Nj7NG4QQhneYIgkmfQvdCSXa0fjKbXsYbkdolGu9B/DoLdm2jTGDJCKHv3aE4VxWTAmKrzak0GgtrVL0hOTjLtVRmWelQUtqze1nDgdA+LZilffxK5kq2DcQDzPPfhSQZYv1Xtns7EgtRA5jOdYY/5vaVUQZEuGFWBSuYGxtFczEWzVoVH03LLw4tU2w36v4ilFdyDlTwhfYmxGkWvqTxouniDQLa+aoDAJj0MkJ6aVXAoDOgTJgeIoBu0ZPhkgaorfRpF5hy9pEtvC31lNJTqeOPDbOiMaOMcVeM5f6dpbGvbF/ccFTeJUkFpoOR68SK78xWwmHLh8QyyAhBf4aD7lYt0G+djwRFP5ybY+K6vxgGS5AKNyBQDIgHuLuxDeVfwT+1Vdqqh11+Kr8xlFdhVBBVtQSa1JYeIGNHa1DgjtQA= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?h1TAsnOGSiM42u1pyzpzccfPW7WrrJHldyUOAGDSB+t0+ydJz8BqqHtbqTw2?= =?us-ascii?Q?fQR9ylj0P953s21AsuW5G/zLNxudfgrQd9v2s3gz8jVwdMc0bPprGaLb0LZ8?= =?us-ascii?Q?uml5sS1boUgmbEoteTMZzCd1EGlCxq3XNBTDpeMIZiyXr55AZOcXiJasAr6e?= =?us-ascii?Q?Cb5uYXbVvCJnwEvp+Xd13Grd0Ud5jzJLbNcwd1m0Di1Qh6/XJXtxm3Ym6ACb?= =?us-ascii?Q?B3/vBnr7vTvLiEKeC/ec/1UgaL5qKtvPTSaCFvm5KsNYFROD4wn2a1y/E8gp?= =?us-ascii?Q?6twnA5y4zd/aMw/xT0eO8h6DatKDXtEaiFx/eV4QSzFSdxoodJqepy9kRZpw?= =?us-ascii?Q?s6plgMcnSK722khyIuXsIDpBiy9GWfWOLPFAAI9NhXY6WIW/qNX+atNvylRN?= =?us-ascii?Q?0f1grPms9WR7PldQx/DIbkeNUYqERSC89+0fnCdQ7QEAz6w794bolRvH3sHc?= =?us-ascii?Q?nRvxrIM8GDLa2s4cfymUidAx3ZBMI30wiiA/QKwvmW6YJw5pkNPEnOz/TVu9?= =?us-ascii?Q?EcbzMH5tcf0EG75degdtS1y1Vsd3XdtUZGMRYZ8O6odwqrLVyrTjEB45a08B?= =?us-ascii?Q?QQhE5zJdVrSXLK8QM85TFLX04TT93ACKWekRdilyY2UsejcYnA6ExXvwRJ0E?= =?us-ascii?Q?Kxj/5Jc2sy7+HHuHrIEjmAXnP/CDQaGyBG7TVgDnaHdBGAQY0e1wGnTtp/dn?= =?us-ascii?Q?ShBMOrZgL7pefmml4zAhO1aP7QoF8kwv78+DCsdN4IBqBFVtAaprcduyW+RW?= =?us-ascii?Q?YMPIB+gH8QwehuSTbT/iGdu/lm27co8evwAGJzdHdDy/r1jJ11vvk3QFs9rN?= =?us-ascii?Q?wf8V8kB4Umm4gh3LXxYttqmfQeLotj8NOvKy0NNJCR06uG+y8DmXBDL5AfDL?= =?us-ascii?Q?5hvIXLpiZEvER26k6u6GIokOQa5JMQZ+wTeJMKerjsS3lZWM0HTB7D7fIjkV?= =?us-ascii?Q?05FyuX9cqq65S6HJweU67GpVSps8nffvrDAwTLZbv6wLq5vX7ztOvdW0n4eb?= =?us-ascii?Q?K61pEkCTTQQ94jdx6Y6ZJT749yv39YpnoUq+TpVOTKwTl4fda7MShbmAA9iG?= =?us-ascii?Q?CvlCqXJ6?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c5a112c4-8594-4afe-b320-08d8c3f13346 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 00:59:59.0090 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QnWupg6F2dW/u36jvwcc6cwKQmt2mIn4K+qX8NzYQEG8CJghwfsPqeG0yJQpWVPNBn8h3p66QLYvwppbOyALHcHrFvD2Ns6Oe+eoDJ0Txl0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: ZQHoMAGDe8ohCCA1fPZsSFjLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882007; bh=Faxq+3Ot7ppI1Mrw693uaA7okS0ok9efLmMX0Vle8D4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Z9ZwFeZA3E3y2exP1+gBg0NelKSYuRKjXs76nc5YdLhFhvlY1R/dNJWNCN3T4cSgpvg AIYRsUxUIH+kdY7NWMLrzwCX768yicgvQEtu77T9N8RbQ7NFZFjNhJ+wWSKs1WkHYlZve xMh7prmfXW6WBsAclBJYZqYUg1aX9hxzfu0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Refactor CpuHotplugMmi() to pull out the CPU hotplug logic into ProcessHotAddedCpus(). This is in preparation for supporting CPU hot-unplug. 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 Reviewed-by: Laszlo Ersek --- Notes: > + if (EFI_ERROR(Status)) { > + goto Fatal; > } =20 (13) Without having seen the rest of the patches, I think this error check should be nested under the same (PluggedCount > 0) condition; in other words, I think it only makes sense to check Status after we actually call ProcessHotAddedCpus(). =20 Addresses all comments from v5, except for this one, since the (lack) of nesting makes more sense after patch 4, "OvmfPkg/CpuHotplugSmm: introdu= ce UnplugCpus()". OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 214 ++++++++++++++++++++++-----------= ---- 1 file changed, 129 insertions(+), 85 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index cfe698ed2b5e..05b1f8cb63a6 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -62,6 +62,130 @@ STATIC UINT32 mPostSmmPenAddress; // STATIC EFI_HANDLE mDispatchHandle; =20 +/** + Process CPUs that have been hot-added, per QemuCpuhpCollectApicIds(). + + For each such CPU, relocate the SMBASE, and report the CPU to PiSmmCpuDx= eSmm + via EFI_SMM_CPU_SERVICE_PROTOCOL. If the supposedly hot-added CPU is alr= eady + known, skip it silently. + + @param[in] PluggedApicIds The APIC IDs of the CPUs that have been + hot-plugged. + + @param[in] PluggedCount The number of filled-in APIC IDs in + PluggedApicIds. + + @retval EFI_SUCCESS CPUs corresponding to all the APIC IDs are + populated. + + @retval EFI_OUT_OF_RESOURCES Out of APIC ID space in "mCpuHotPlugData". + + @return Error codes propagated from SmbaseRelocate() + and mMmCpuService->AddProcessor(). + +**/ +STATIC +EFI_STATUS +ProcessHotAddedCpus ( + IN APIC_ID *PluggedApicIds, + IN UINT32 PluggedCount + ) +{ + EFI_STATUS Status; + UINT32 PluggedIdx; + UINT32 NewSlot; + + // + // The Post-SMM Pen need not be reinstalled multiple times within a sing= le + // root MMI handling. Even reinstalling once per root MMI is only pruden= ce; + // in theory installing the pen in the driver's entry point function sho= uld + // suffice. + // + SmbaseReinstallPostSmmPen (mPostSmmPenAddress); + + PluggedIdx =3D 0; + NewSlot =3D 0; + while (PluggedIdx < PluggedCount) { + APIC_ID NewApicId; + UINT32 CheckSlot; + UINTN NewProcessorNumberByProtocol; + + NewApicId =3D PluggedApicIds[PluggedIdx]; + + // + // Check if the supposedly hot-added CPU is already known to us. + // + for (CheckSlot =3D 0; + CheckSlot < mCpuHotPlugData->ArrayLength; + CheckSlot++) { + if (mCpuHotPlugData->ApicId[CheckSlot] =3D=3D NewApicId) { + break; + } + } + if (CheckSlot < mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " + "before; ignoring it\n", __FUNCTION__, NewApicId)); + PluggedIdx++; + continue; + } + + // + // Find the first empty slot in CPU_HOT_PLUG_DATA. + // + while (NewSlot < mCpuHotPlugData->ArrayLength && + mCpuHotPlugData->ApicId[NewSlot] !=3D MAX_UINT64) { + NewSlot++; + } + if (NewSlot =3D=3D mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", + __FUNCTION__, NewApicId)); + return EFI_OUT_OF_RESOURCES; + } + + // + // Store the APIC ID of the new processor to the slot. + // + mCpuHotPlugData->ApicId[NewSlot] =3D NewApicId; + + // + // Relocate the SMBASE of the new CPU. + // + Status =3D SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], + mPostSmmPenAddress); + if (EFI_ERROR (Status)) { + goto RevokeNewSlot; + } + + // + // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. + // + Status =3D mMmCpuService->AddProcessor (mMmCpuService, NewApicId, + &NewProcessorNumberByProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, NewApicId, Status)); + goto RevokeNewSlot; + } + + DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%= Lx, " + "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, + NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], + (UINT64)NewProcessorNumberByProtocol)); + + NewSlot++; + PluggedIdx++; + } + + // + // We've processed this batch of hot-added CPUs. + // + return EFI_SUCCESS; + +RevokeNewSlot: + mCpuHotPlugData->ApicId[NewSlot] =3D MAX_UINT64; + + return Status; +} =20 /** CPU Hotplug MMI handler function. @@ -122,8 +246,6 @@ CpuHotplugMmi ( UINT8 ApmControl; UINT32 PluggedCount; UINT32 ToUnplugCount; - UINT32 PluggedIdx; - UINT32 NewSlot; =20 // // Assert that we are entering this function due to our root MMI handler @@ -179,87 +301,12 @@ CpuHotplugMmi ( goto Fatal; } =20 - // - // Process hot-added CPUs. - // - // The Post-SMM Pen need not be reinstalled multiple times within a sing= le - // root MMI handling. Even reinstalling once per root MMI is only pruden= ce; - // in theory installing the pen in the driver's entry point function sho= uld - // suffice. - // - SmbaseReinstallPostSmmPen (mPostSmmPenAddress); + if (PluggedCount > 0) { + Status =3D ProcessHotAddedCpus (mPluggedApicIds, PluggedCount); + } =20 - PluggedIdx =3D 0; - NewSlot =3D 0; - while (PluggedIdx < PluggedCount) { - APIC_ID NewApicId; - UINT32 CheckSlot; - UINTN NewProcessorNumberByProtocol; - - NewApicId =3D mPluggedApicIds[PluggedIdx]; - - // - // Check if the supposedly hot-added CPU is already known to us. - // - for (CheckSlot =3D 0; - CheckSlot < mCpuHotPlugData->ArrayLength; - CheckSlot++) { - if (mCpuHotPlugData->ApicId[CheckSlot] =3D=3D NewApicId) { - break; - } - } - if (CheckSlot < mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " - "before; ignoring it\n", __FUNCTION__, NewApicId)); - PluggedIdx++; - continue; - } - - // - // Find the first empty slot in CPU_HOT_PLUG_DATA. - // - while (NewSlot < mCpuHotPlugData->ArrayLength && - mCpuHotPlugData->ApicId[NewSlot] !=3D MAX_UINT64) { - NewSlot++; - } - if (NewSlot =3D=3D mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", - __FUNCTION__, NewApicId)); - goto Fatal; - } - - // - // Store the APIC ID of the new processor to the slot. - // - mCpuHotPlugData->ApicId[NewSlot] =3D NewApicId; - - // - // Relocate the SMBASE of the new CPU. - // - Status =3D SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], - mPostSmmPenAddress); - if (EFI_ERROR (Status)) { - goto RevokeNewSlot; - } - - // - // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. - // - Status =3D mMmCpuService->AddProcessor (mMmCpuService, NewApicId, - &NewProcessorNumberByProtocol); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", - __FUNCTION__, NewApicId, Status)); - goto RevokeNewSlot; - } - - DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%= Lx, " - "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, - NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], - (UINT64)NewProcessorNumberByProtocol)); - - NewSlot++; - PluggedIdx++; + if (EFI_ERROR(Status)) { + goto Fatal; } =20 // @@ -267,9 +314,6 @@ CpuHotplugMmi ( // return EFI_SUCCESS; =20 -RevokeNewSlot: - mCpuHotPlugData->ApicId[NewSlot] =3D MAX_UINT64; - Fatal: ASSERT (FALSE); CpuDeadLoop (); --=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 (#70869): https://edk2.groups.io/g/devel/message/70869 Mute This Topic: https://groups.io/mt/80199901/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- From nobody Thu Nov 14 04:58:38 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+70876+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+70876+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882127587305.14983033577926; Thu, 28 Jan 2021 17:02:07 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id ntWnYY1788612xggl8k2MIFa; Thu, 28 Jan 2021 17:02:07 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.3211.1611882126714735838 for ; Thu, 28 Jan 2021 17:02:06 -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 10T0gDlp065042; Fri, 29 Jan 2021 01:02:04 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkxsbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:02:03 +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 10T0eGVF081743; Fri, 29 Jan 2021 01:00:03 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by userp3030.oracle.com with ESMTP id 368wr13e5c-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iBpJyE2cQ731ZWCWY29AyFPQJnKR3YDc6iknz1qA6sXolGUzSaeeEQGWSFerVyb7Fic+WhYYZFrNzYUKjwGsysbC55i2lLgerUSxPjrVnq41aI+L5u4v+cT3buYRX1eV5tTclwoFPRWdXKC75rXgDW+m7DxMXEAx6oF1Xdt8Djcv88Ui8ZVRvhyVtNDnqGkJqv6e2U3CRDXP6OptcIKtsotDqWZSAdr1y4T5bw+WxIU4GHMedv0biRl73kXHiIJB8H+GAqH+PyhgIYd10oz9Pwbf3saDpU38zFsO5OKpCuG0GkpQ4sZr4VPwpimn1LCddZKQyDLN0PKAc1PPHLiELg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Guq00U15YcGAAy1mDO2Rk+JcBjl0zhlnNSefjcd/tks=; b=aQP6JBBhJi0AMX+g6JVJ1KyU+FHA7l/FDbGfQHBUNcQWfiK8x6sMloosLDKVZMwUJgOD5u9rbWsqbKzWOe/dX8ni7TOJ1KiU3aN0paScJz5roQYghB64NhZeCkbeu72xy/pvQDJKHktAZXA3U3fD6hV4v8Bl1ElTaKKlcRPA1TT2gDJwz28eLlnoqKy+oS5hTiHrbc+sP7lu+RihmzuaeEM7lbN+f1Cub16RzTQYaPl6HJnyOGM31hBm2uh60/3O51CfL/gxmKo8qMA5ZmXmB4PHeHfhjPMkwqG5SbKwoHWJsN4mHv19xw1tiGfoOemKfhDi2rPctFr973pHEf4EIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:00 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:00 +0000 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 v6 2/9] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Thu, 28 Jan 2021 16:59:43 -0800 Message-Id: <20210129005950.467638-3-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 00:59:59 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 147cf1a0-c8a9-41b0-dfef-08d8c3f1340f X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: ZESUD/2pirqdloXZwLMQqBpelaqOPkOYof9Lryin43f0hjm1nk82Aw3+fOnlxZ28JwNBzT//K2H+9OHgSdsGvZoQZf7CCkLPd5+vXaiXKQ7twIKRQuu9hoOHPnt35YZfdVqImXYutMxMKWbTrjRNKH8NOf8zFdwx/OQveG2s3RqzyUksSBKPmGJvBMYaEl1kpzAEFRKIcbbtZYdBWZzYjkC744AMXYQQ0LseB9mSdjcD7ZUlFIjwhzebH8v5ejEeVTBv9QfGzUQw6MEUB9tdGKdq+TgAKoCXJxJM28ingmKj0PzrtQzniLqWAcc+uiWyrfLk74nzwIU21VvaR64jjH6IqwbBj/S7Grv7ZCjlVCNkJS1ThquBxlcK7jljmA21CFS2lAdINdNj2FIxt5Bq2fmPDp0EStEdVVEyfz7FYqK2DH5OOOkRVIPdw3iXGm/nl4fylxEdYfQ1uBZUI0V0YKKBxNgBiDsrPOv16rUfTDSjpywMAj0NmJFTme2hXfC+jLS9r47LQpsFRv8FVcjWiDw6p6sxbk8wqu3sHROPOxsl0wCUeJxnI+RtJjehsXBAsOGzGo+5RKQZm8dDfNHF8qHPSOCGKgvRR8uycZZcR6M= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?RFFDeLOV4N9AhB575GQDPng/Zp79FCiXvUuawAD8wVVthYPo/a98SQzaGZ5b?= =?us-ascii?Q?Cr+dYjZeZ3hywUvfoxIh6z+z9LOYBmtRN2hSxnINjuXCzd7Z6I84CS22irMW?= =?us-ascii?Q?KDq/A+ymOyHFuCpcYkqO8+vztoSmBgk3UoAxu5fqlOV9VuECEhoTU0M4BuoA?= =?us-ascii?Q?X92QQhgKHO1FF/nKeaAUhf0uNHr9o+cUTOfAGG9RP6C7CUNFpmta56j1FtJH?= =?us-ascii?Q?HgHf3BBac4p5MDhWmBGc2Fa4kRXKmC1VQsOJjJizvaYOmv3sorbZ4ankv4X2?= =?us-ascii?Q?78VzjywRyelTpsap0rOsVQODnKIBB93z2GcxyUZiNLKrtED8BISM7D5F/nJ3?= =?us-ascii?Q?XPrEayXfSWWpkkH4g/WStQDnCMHQlZSc5e/cvLAmhOwwSQsV4yiyeO6jcwk5?= =?us-ascii?Q?aZcNqnzFrW0g8k3TCJVunLovJvqiXl4/uzGm1AsJiyXrW7C4OK7LC88omMyk?= =?us-ascii?Q?XE4ksF1705hnVQxTUFK9m1YC6p7iOTA7rxNfX/a9n4As2i27PCDfdhY8lur1?= =?us-ascii?Q?gB7Z+osUqQmK+IX9GrcbL6QJV/Pssi8pONbNOHlU4ceGeI4+UR+dSGu1J/nC?= =?us-ascii?Q?0u8TZKP/UmbmSpKVULpqrngDluKPyl+6sRibNspSBsKqJpGFa2Ek3ducqq9T?= =?us-ascii?Q?5PSD7kRPN4g1zWNNI0bOho3wjRi6oktH0YPzKoyko7wcJ4CBg5BGlglyfEdu?= =?us-ascii?Q?0GOR1dMIMm9i7LCUGyvu8L7FVl1jFECeArxunHNDe3s+42jry3Di5euvv05N?= =?us-ascii?Q?nFb2rl/1LBsUHIOs3r5Aq3RLa3iDnuD8ASXcCqtWxbofHQzblwq942y2whiD?= =?us-ascii?Q?U37IzeZNSYkEZdRtYkAKQquAe9qTSAjSCC9V7idlapJXWimeTxYIqkZxay7e?= =?us-ascii?Q?zpSN+87VNOsHPV9fO+Uz43FWgUK+w62NuXqV+y2WTkYXwb1X1JQ2v+gusf5k?= =?us-ascii?Q?OQs6MyBa9uXc/uabhWgSoB+9cRfXglnZHibsAe438cP4yErP8ZEYiEEdXN1z?= =?us-ascii?Q?2XLYkpThh1N5ZMmUgbdQPwOh4+geppfPJZtubMeLGFDWp9th0zf/t0TbP/Up?= =?us-ascii?Q?4R2k6NsC?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 147cf1a0-c8a9-41b0-dfef-08d8c3f1340f X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:00.4583 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F7Ek/8iKEJY/Fxlze3OKy/feHWWIYLc8gXn26CmzTf8Q3HQWGyOUslCiQlt8D8VCymoE861X/NbThs626TCGpuAkbVC9jg9pKz6tjGBsCEo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: LbIs4DPnnmvSn2n1JQlezhj8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882127; bh=iINmjKMImoXOMlIxmoLGWarJzfwRYKPzvFbvGHmCoPk=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=HM31M1/QlBrihiDh+EeNQ9EqAVwFQbUPprij7RY7s7DdtiO/GWKRKTqmD0Kpo8PR4d0 BXiTm/k+1MluZ5RFC6Ytz+XE8I3xhN6E4o+NlfvHCvCU2+83f73EVdECmseJppTVJsU9t eg8WEZ0ZjBp8z2Sn0gpt4P1/kddA4sEsqBE= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Process fw_remove events in QemuCpuhpCollectApicIds() and collect corresponding APIC IDs for CPUs that are being hot-unplugged. In addition, we now ignore CPUs which only have remove set. These CPUs haven't been processed by OSPM yet. This is based on the QEMU hot-unplug protocol documented here: https://lore.kernel.org/qemu-devel/20201204170939.1815522-3-imammedo@redh= at.com/ Also define QEMU_CPUHP_STAT_EJECTED while we are at it. 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 --- Notes: I'm treating events (insert=3D1, fw_remove=3D1) below as invalid (return EFI_PROTOCOL_ERROR, which ends up as an assert), but I'm not sure that is correct: =20 if ((CpuStatus & QEMU_CPUHP_STAT_INSERT) !=3D 0) { // // The "insert" event guarantees the "enabled" status; plus it e= xcludes - // the "remove" event. + // the "fw_remove" event. // if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0 || - (CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + (CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%= x: " "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, CpuStatus)); =20 QEMU's handling in cpu_hotplug_rd() can return both of these: =20 cpu_hotplug_rd() { ... case ACPI_CPU_FLAGS_OFFSET_RW: /* pack and return is_* fields */ val |=3D cdev->cpu ? 1 : 0; val |=3D cdev->is_inserting ? 2 : 0; val |=3D cdev->is_removing ? 4 : 0; val |=3D cdev->fw_remove ? 16 : 0; ... } and I don't see any code that treats is_inserting and is_removing as exclusive. One specific case where this looks it might be a problem is if the user unplugs a CPU and right after that plugs it. =20 As part of the unplug handling, the ACPI AML would, in the scan loop, asynchronously trigger the notify, which would do the OS unplug, set "fw_remove" and then call the SMI_CMD. =20 The subsequent plug could then come and set the "insert" bit. =20 Assuming what I'm describing could happen, I'm not sure what's the right handling: QEMU could treat these bits as exclusive and then OVMF could justifiably treat it as a protocol error? OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h | 2 ++ OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 29 +++++++++++++++++++= ---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index a34a6d3fae61..692e3072598c 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,8 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_EJECTED BIT3 +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 =20 diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8d4a6693c8d6..f871e50c377b 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -245,10 +245,10 @@ QemuCpuhpCollectApicIds ( if ((CpuStatus & QEMU_CPUHP_STAT_INSERT) !=3D 0) { // // The "insert" event guarantees the "enabled" status; plus it exclu= des - // the "remove" event. + // the "fw_remove" event. // if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0 || - (CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + (CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, CpuStatus)); @@ -260,12 +260,31 @@ QemuCpuhpCollectApicIds ( =20 ExtendIds =3D PluggedApicIds; ExtendCount =3D PluggedCount; - } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { - DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove\n", __FUNCT= ION__, - CurrentSelector)); + } else if ((CpuStatus & QEMU_CPUHP_STAT_FW_REMOVE) !=3D 0) { + // + // "fw_remove" event guarantees "enabled". + // + if ((CpuStatus & QEMU_CPUHP_STAT_ENABLED) =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "%a: CurrentSelector=3D%u CpuStatus=3D0x%x: " + "inconsistent CPU status\n", __FUNCTION__, CurrentSelector, + CpuStatus)); + return EFI_PROTOCOL_ERROR; + } + + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: fw_remove\n", + __FUNCTION__, CurrentSelector)); =20 ExtendIds =3D ToUnplugApicIds; ExtendCount =3D ToUnplugCount; + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + // + // Let the OSPM deal with the "remove" event. + // + DEBUG ((DEBUG_INFO, "%a: CurrentSelector=3D%u: remove (ignored)\n", + __FUNCTION__, CurrentSelector)); + + CurrentSelector++; + continue; } else { DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n", __FUNCTION__, CurrentSelector)); --=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 (#70876): https://edk2.groups.io/g/devel/message/70876 Mute This Topic: https://groups.io/mt/80199952/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- From nobody Thu Nov 14 04:58:38 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+70870+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+70870+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882014151537.4347496761987; Thu, 28 Jan 2021 17:00:14 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2vwJYY1788612xmnh43Jc09K; Thu, 28 Jan 2021 17:00:13 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web08.3357.1611882008266317122 for ; Thu, 28 Jan 2021 17:00:08 -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 10T0eJ8e041428; Fri, 29 Jan 2021 01:00:04 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7r6uw8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:04 +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 10T0eGVG081743; Fri, 29 Jan 2021 01:00:03 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by userp3030.oracle.com with ESMTP id 368wr13e5c-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L/1NoALG9E+igW1GsKZ632Jc7jTNnRKYJ6ioLfLYrt//cyripSX6CA65cwFos9bc5ViisjgNbNFt5q/F5JnKA1Ui890zkhO9R1PPisqb9FDNgMQPB3DENS6fMKVsULXXvu8s/28DPNw6yEuO/6PPQrDUejIGDdIAenDjeo60syyYZm8Pgjci3y/BK9nP3HIlqr1G0Q61zUTo6Tr9gKpgUsPeVbiKLReKdulotMwhnQH77EMdOl0l5/CGdTGuRKMT3tkIGWIBSFaMc2AdUPYyrbUGkEc4UYMPaJu1LA8aaHyOnI5C2BTWG7iZsSnjRgKuGEtNyt3XP0xEHd1z6ePOjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7DyDBLKrhQWru9roBkQCWe9/RsVfjy9XMv9V9+fWzjc=; b=dj/hFTJNJ1pDvrNBzQhUidLn7EAn2YIjs4K2uFOHlG6nc5iWU/wU4UZlemjb2AVyN+NuXacaQcFTh/AS5ayKPlvtyrkC7TaxLiHyLq7IMU17RdQmC612It0GXA0Jq5dj0dCEGCVza3+pTTcVYOES7OzRhYJE+ZfseF/oPBRbI/JwGFp6W6MtVG+MKwktrzCI1jMfX2MHfcRutpPw8y+ZsY4t1f1j1TTDZ3FAN8R0DLK92ZUm96X3UNo/bvAcvD1VHHT8zAWaYTAd+lAEwGvpzdfD/5O/pYTVOxeFs1nbq5m39GktKRF1YTJDtBCn5Jvu+d7JtaBnBeTD+iqsvxvGhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:01 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:01 +0000 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 v6 3/9] OvmfPkg/CpuHotplugSmm: add Qemu Cpu Status helper Date: Thu, 28 Jan 2021 16:59:44 -0800 Message-Id: <20210129005950.467638-4-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 35e69161-59b5-4322-c676-08d8c3f134ef X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: qmS1sWuju/7DNizXLrhkXVf5TTt3x8UByK3ZVz+z/hdnmaPHekEB582m8qLyypt9YIWpJpPOOL5nSHrRvpRF3C5Er55czEa3OyRvRgXOC9vkvtKGY9eN5ern7ggjGoGZHH+uLAsCAFSm6U8qQeneEA5INNh2AzHYfya7FDS5PiZ3YEQOikm0tgDtla2WGKu9lH+dD8DJ4UfDpLErVqYaGHRi+sDe4H7w/XsVlsFJdP3r8IWiWF/pg+mnJzRo5X16ayC8O4ngnJ+1NWflJ9WsukTA7af555t+nIIa/cqi/PGPq3us/DlGk+WP1Haj9WBDy/0ShOcBOO6st9QotMHHcIjd8uIKlHSgubrxhrQZ2nefLuuD45IKDR7+gUQndnwKCpJbFgZYtTXfU6L8iVTxjY+8g1yWhralPfMf8Fl5jgXX8+u0rKczMBAaa8w76G7/1abWfpuUVM1KjdSPnq2o2gRNFcFnH3C/Xhk4iu0vBPIWfAuTeYtVywFp/hzsMnE/N4z9raKFPx/be3gBaEW7pt1PuUHa2uwUV/74w0qLRRQUclGZDdmde0IYNKNdh0BY4fYIXXU4C6m5nK8LONIUDdBGBm+pQksF9ONVijXrsiQ= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?8yj7nbecUWZ1P+7nxXi+/2FulZBDnG6dlNQSoXQC42b5PmexG1vB71FirPlf?= =?us-ascii?Q?J/ZrH46fqSPVn8n3pfLqBwWneuVKIPd3Qv/izT5CIAIKF44fK9IS8wXWLeXy?= =?us-ascii?Q?xO9Kxu1pfayaUCVq6OgjpPmbpYhL3AnYR9zDhCIhtS9yRONZ+tSt/36z6sLl?= =?us-ascii?Q?gb8G53gojsSYZNoj+tmcGULSavLZXU9xxxqNPkhmAObk2XtREf7YW3C7ZmFI?= =?us-ascii?Q?88BZd+ZW8f2F/KDgHsy0LgNSIEhEHt+enx35t6l3y7GIlWKXJw0k4Y0jvdB5?= =?us-ascii?Q?G5yJoZRj5MAqr/OYhq5HZkv+7CfcsDiiaKtaNHfFhZs169tlhmZEstgwWIr2?= =?us-ascii?Q?r2U22lZQWX59Vf9eGrwGbRm7YxSdv0CCJ/Fbk1DPcrzRFf2quKJH3V3I8B6E?= =?us-ascii?Q?mCQEo7lVoIDnj4ovYfGf1aJGoHvPW6GypZURh5F1v0ZMf+w4YirGyZiCtR9p?= =?us-ascii?Q?HPY0M9NysFDNc3VQw9EQ3kdmzTeclninIyAN9S0LNLOSQ/P2qWNGRwYv7sTZ?= =?us-ascii?Q?wv0urFeBcbw/IByPAONd/Bpz5bHZJo/XW4KIrJzT5jfu3jMWigSqjD2Vf74k?= =?us-ascii?Q?5wzYF/ujwzILk9fC+bWnvg7t4MpjVoqgTd1kQhMvUtv+oqTw2AH9QhEr/dNV?= =?us-ascii?Q?X+ZpmldYteS3tUejdx9HXAYR73mOlxpncV2jHRy3t4IGPDu2Oenf51tZf6MT?= =?us-ascii?Q?KzbKFu7a5RNCDx5rcyEG5VY4bTMYZ2zIuP1oMsAHLxRYLwGxwMjoelq1jbDa?= =?us-ascii?Q?Cvgi+fVn3+33GVVJgV8ahwtcys0gCmuNRHMSwpRanj06N/ypAfgu/hd5GEYw?= =?us-ascii?Q?XcqNxohC7HCSe3arp5fRPmVJD3Fb+mHVjo2ls8SxH0XLxpl8Zcx4BvlNuwyj?= =?us-ascii?Q?Fih+foTsDj+s+5fKSGeAja5t9OxWcWgxkR7F2NI6lc6iZdVr5RbGa/mUn9mH?= =?us-ascii?Q?JPeED/qgguJJjRA9hq8d211tKZfj1z/rvMQcMR+thRCcZP4aUJZtPDG/ZGAW?= =?us-ascii?Q?63AZnuw4SDdu8XntUsnKN6TFxyaAIc4Q3uCUoMLwO2I59k2hNdRiV0T7lKu4?= =?us-ascii?Q?oUF4cXuA?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 35e69161-59b5-4322-c676-08d8c3f134ef X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:01.7448 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BLr9UIwstrlQqPAaKJEgTYqiNL87H8hqkpo/PlMAdynRVkpJ5DIwxDZlA2lTSZ2S60wo0g0fDF/DWuclXFmlUU1WYKj1vkWxo0c/npl1L40= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: dsV1kebXsQRKXWy2KIREROsAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882013; bh=TFkIoml6MLHv+QdmATNzFWxVepxDBwO0N8xPse/ZgeU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=YhKjjLI17zFHAe6ddFN5L+kmtwMeTy73cTorjYCQKJqyvr3IVgV3x/jXWWH/NDs+R4C STq02z/gqFHtq0MSa1OXFXgUAZ4mUIhBT05Uj4xpypkVHsZXDkyqcl52EFL4t8ypx/YyY jNtEvwnJhOXfplxolzkyAhlU6IVyoUrfkhI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add QemuCpuhpWriteCpuStatus() which will be used to update the QEMU CPU status register. On error, it hangs in a similar fashion as other helper functions. 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/QemuCpuhp.h | 6 ++++++ OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.h index 8adaa0ad91f0..804809846890 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h @@ -30,6 +30,12 @@ QemuCpuhpReadCpuStatus ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo ); =20 +VOID +QemuCpuhpWriteCpuStatus ( + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, + IN UINT8 CpuStatus + ); + UINT32 QemuCpuhpReadCommandData ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index f871e50c377b..ed44264de934 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -67,6 +67,28 @@ QemuCpuhpReadCpuStatus ( return CpuStatus; } =20 +VOID +QemuCpuhpWriteCpuStatus ( + IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo, + IN UINT8 CpuStatus + ) +{ + EFI_STATUS Status; + + Status =3D MmCpuIo->Io.Write ( + MmCpuIo, + MM_IO_UINT8, + ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_R_CPU_STAT, + 1, + &CpuStatus + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: %r\n", __FUNCTION__, Status)); + ASSERT (FALSE); + CpuDeadLoop (); + } +} + UINT32 QemuCpuhpReadCommandData ( IN CONST EFI_MM_CPU_IO_PROTOCOL *MmCpuIo --=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 (#70870): https://edk2.groups.io/g/devel/message/70870 Mute This Topic: https://groups.io/mt/80199903/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- From nobody Thu Nov 14 04:58:38 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+70877+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+70877+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882184382263.99187722458737; Thu, 28 Jan 2021 17:03:04 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id TYKYYY1788612x2jkwkrgBRd; Thu, 28 Jan 2021 17:03:03 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.3217.1611882168345181138 for ; Thu, 28 Jan 2021 17:02:48 -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 10T0f7T2064508; Fri, 29 Jan 2021 01:02:45 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkxsda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:02:45 +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 10T0eG4O081854; Fri, 29 Jan 2021 01:00:44 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3030.oracle.com with ESMTP id 368wr13fqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ad8lKitAkP3rl9yj2GsQxc1+EiNcbPKQWrX557om1HLKA2YCypRG/ACTb/2HChxA3ZqABg2reixXHMcfljq7tuHit/Em52hFEKDa4TfoKsFD8UcpMZ13FeFAd/kOahpuSG5K4akxsE25oRZyJHb/8DWWWfal8SIAyQZBWrm4vpoRdHeYWfslNXyGTJ52bkVAaGJ9ARs9+3Ip5obUrmnPqUOXVykRVPX8pNbT7Fz3zOddVaG2JHIwpsyTux3Q+tDrGrlvGJGG8BhFaFjRdyqYyld943iWQkaafdrdBdN3WdsTFBA0njNb+XP4FdkUVRd2o92hCynydym/d1azghxc/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rgPTXAvtTPqel57nufZeHYm4FztS/OLvF3zj0LifChc=; b=Y/O07WcA8X3q3LW13c1u5/NXMHz03oNoCx/4uW7YuU4zYJW6GMi1quUcXh2YMEVJTIEa3Gv5c4BpSd9HUx0tk4wALFi7zV1j2ZB6kAS/6bYZpRFr/lYb5HoqQqmssp3sUzDZJNP3RUBjQ6Vedl6hNaSBqvyn1Hn56jJhoGZxe/Pz8OaPvSGJFPrDvUqswAiW+bp3TZ/W5FESXd8Ni3ZeNyzRK8p/fGYL18jd+gfI6RiP5xqhcCkMIvJFZoTLZHrrizl/KrOrWrKPz245GZq6vnyG+cnEmU/DtznRSiF4C64RbleD0HQtqC9zbLN15SJL8Nv7yP557edTPz/W4X7I6g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:03 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:03 +0000 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 v6 4/9] OvmfPkg/CpuHotplugSmm: introduce UnplugCpus() Date: Thu, 28 Jan 2021 16:59:45 -0800 Message-Id: <20210129005950.467638-5-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 11f5ab6d-172c-4a65-5bd1-08d8c3f135ad X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: NLTm34f33PT1tlSUD0+ddGV1X4N4GfciMpp6aXmET9qBG8n22/+3R1IejxUTmhRwfDpg5LG2Xmik+URCOUPm6Tc6JiU8xCmOh0igpjySX0UvIqYh2bY5qK0x0rZ6FKip3XsC9sUWUm+HeagtwvKaO2BCiaiAT6dFCvyHvHILhEFeHWPpEGlK6uX69xI3ltEGAm/yXJaAQeeEPuoBSIZ2/GiX3PgJUBBD9Yov7XvHLS8SiBIiSlAzVqTzHELd3GgxDdgNsg5SQOr+Y+kt18dURcY3GV29zH1aaaI9fXn9dJ3rTjfrryuw/en4I0y/c8oTmq+WF2sObkGoQgNwp9HuZGBFrORjkHMbrcqKdlv7PovD/7Nk60Yq2mfoWmmHB4EW61cFKp2/0FQ/2/U671aFdPFiwfzzNT8CdhVraG3rxZmOJGXWNBKXhSpeEviO/YzlrBCTyNlo3OzKCH9XtxlHqCWQAQmEvY/up3ysSxt0dKUAMvUOGseMte05wJ5ffnTzKYhM1VXeIhG1VG0n7S2j2sWnyH+uaDtZDhLId4KUqjFBlzvfQ90Sow5w8eYYb/59N4eXJYtJuWGTuvQBbFaaPEJnYuccdO1n/tOGh7Y904o= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?uM/bfRqK0Zzk93B99vjrAbi7LegciKBKbVPFOMNjGi7KcrIz5BLvJvVCW89v?= =?us-ascii?Q?EyLSMVahvRvb9puUmI2YHbLDRntyDq/nMt5bFWyjhkxX2e4RxbDUDDl3UyjA?= =?us-ascii?Q?XrPcIgHblrtkuJ1dA83yHQNbKjrVloPzuaYnx3nR8V60+D6V/fN5hNF2NByP?= =?us-ascii?Q?3Pwdqva6SdnBDaFNFuYRgjSScWn7Ph9YTd5CM00WBE+3roMWH3faKg7qSsyd?= =?us-ascii?Q?ZyFrYdjTf2k6855yvkALxPDZISXdBbFoSDc5nK67boNIT/2IbPvlm+f47H1m?= =?us-ascii?Q?OxvWIoRyXuuCo6lBErCOikuk896k6FRkHFapLrlDpdK0lFL4+UeeNQfnOFkS?= =?us-ascii?Q?iT56yCOgYly4D9I+Fq2uT9LXDwt5WuByd7y9JQl3/AQBQguhMdwGN8PszGAS?= =?us-ascii?Q?wZI7eVjNNKQ9OJcUxM7Y2ZVeWKGK5vTWXMeJm1X7+Ac1SQN4ym8PoDhXjh08?= =?us-ascii?Q?kbk7BGNtEaHK11l5dCK7UOVfm6UGRcE/1i5QhK6Q/CdSBzmAHF9Pt78DMz21?= =?us-ascii?Q?OgTZwh0gK9GGakCTpOApkT75W5dZ39T9AQ88UWvGXv2FKb7AIqSy9rDZBNX1?= =?us-ascii?Q?ev7j3XCiXWzbiUj8N+801m7uKM/YromWVwCvEmRfuPvhdlYBA4FBh9ZLpXVf?= =?us-ascii?Q?PeTDKZju88fV3ZadEGeQOERNPmHkYXL1vB3yXUzKnxUvLR5I23cSPYB4XenB?= =?us-ascii?Q?GDLE9pHImJd2Lab1fyw40DVWlYDvJYwnicTP4YOEwdfYtpxOc0/cHsob88Wf?= =?us-ascii?Q?NtImhlJoZD0rhjn1mhVyRl1z04Pg49LtJn1G03UyNdBxmREmvtFH65RZY05u?= =?us-ascii?Q?1ZujwSWTQypTYr7FqpYCOXZgxZdLSotpUHIlC/5pupr7sdlriUOY3kSpijBh?= =?us-ascii?Q?+uqegdagzx9et2FjH2kr6uJo6IHf2/Gz5FYDk9jt6F2GSJE9m5ei3UnP4Pbf?= =?us-ascii?Q?+Dqlol+xLjffZuxLEipfGiJ3X59uZi+sxLMO7SveoRGe8G/CpuyZ0faVTwHd?= =?us-ascii?Q?yx2CmecT5umHrNcyxVqA83lslxtgIzod7Snptg4N7EwvnYcLbmtFO2ZOTpT/?= =?us-ascii?Q?utuuN3Is?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11f5ab6d-172c-4a65-5bd1-08d8c3f135ad X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:03.0222 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: rga/amoKbgTsDAXa4HM8H/pAYiKbwQ1uWI141JaIEC2NmuZQB/1LeP9inldO2jDy3l0LpOhuntoV8XZftmeik582lAbkHSP5ohWqca+SyNw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: gkEk1MfEsvvQzPdDmdTCveBgx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882183; bh=CXNalx704ijWd1zkS4RWYk8Bt7MoYFDrXZdPH3dvkfw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=LUgDHMb7laXh+n982O1tF+H80poG8Pkbpnn+m5u0JyBYzZYb/Rek+W/UUqFyHoiu5mp l03VOmlHqK0FmJgDH3hX8RWZN1K1S4mugjKF1KbwtWrvqRK0J+Q+EgVK/ha6B2qECQveJ b6aKqX3VRVycly33pRs5zxvBwpL9PS1XlLI= 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 | 84 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 84 insertions(+) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 05b1f8cb63a6..70d69f6ed65b 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -188,6 +188,88 @@ RevokeNewSlot: } =20 /** + Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds(). + + For each such CPU, report the CPU to PiSmmCpuDxeSmm via + EFI_SMM_CPU_SERVICE_PROTOCOL. If the to be hot-unplugged CPU is + unknown, skip it silently. + + @param[in] ToUnplugApicIds The APIC IDs of the CPUs that are about to= be + hot-unplugged. + + @param[in] ToUnplugCount The number of filled-in APIC IDs in + ToUnplugApicIds. + + @retval EFI_SUCCESS Known APIC IDs have been removed from SMM = data + structures. + + @return Error codes propagated from + mMmCpuService->RemoveProcessor(). + +**/ +STATIC +EFI_STATUS +UnplugCpus ( + IN APIC_ID *ToUnplugApicIds, + IN UINT32 ToUnplugCount + ) +{ + EFI_STATUS Status; + UINT32 ToUnplugIdx; + UINTN ProcessorNum; + + ToUnplugIdx =3D 0; + while (ToUnplugIdx < ToUnplugCount) { + APIC_ID RemoveApicId; + + RemoveApicId =3D ToUnplugApicIds[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 unplug\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 removed this set of APIC IDs from SMM data structures. + // + return EFI_SUCCESS; + +Fatal: + return Status; +} + +/** CPU Hotplug MMI handler function. =20 This is a root MMI handler. @@ -303,6 +385,8 @@ CpuHotplugMmi ( =20 if (PluggedCount > 0) { Status =3D ProcessHotAddedCpus (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 (#70877): https://edk2.groups.io/g/devel/message/70877 Mute This Topic: https://groups.io/mt/80199964/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- From nobody Thu Nov 14 04:58:38 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+70871+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+70871+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882062501152.07724438977607; Thu, 28 Jan 2021 17:01:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id hC2iYY1788612xCanhjvJ0JF; Thu, 28 Jan 2021 17:01:02 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.3194.1611882056694231295 for ; Thu, 28 Jan 2021 17:00:56 -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 10T0egxf064300; Fri, 29 Jan 2021 01:00:53 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 368brkxs6d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:53 +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 10T0eFuq081627; Fri, 29 Jan 2021 01:00:52 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by userp3030.oracle.com with ESMTP id 368wr13fw5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:52 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3fQyxt8ZNoEFFwF0DqZo637Twx0U3dreWXA15DvdQ+Mx8gpXU2nVv9SNfAYGWUYms2bRXuvexBwxeR02h777LjS0rI8TErmUeczMK6yaipRMhXT+VIlzoj5E08k7BEwB3RtZ3UFl9Vh12ygT8oGqC+OkBdRLM+tyW61Hb7ANxtOEyRFbO0SdhLS+mPuJNMt+8/hRBKOK+VlJS5KQSZi9sX+xWN4f0bDXAvUzc9mjsaeqJqE7oZumCCZ6mM3CZkhwFzwBWCUMVMD2wv8xo3a5LCkt/jY5/YsNOVIZVxJE9lHXmUrr5d7ETeMmpk6TYxAaMEv23fFcrUHgUTrsTcsVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GxZXnl/5yHh91kgNlVOCw1FXKO4AEcmuOkvEp2YhLlw=; b=VddyZdHQYQdsr+dv6dDcqBvq0K27es8N+zNV5MoTK/vDZm8Bfua1KSGfV6jHeWrvLzhDU94ADl902wpqVZxq18+CMRz19mUplEIUrqRe7e2mN1oN6aK9Giq3PbGsAKfXqtCHvcOdotIfGnhLOQs+/+06QmUnfkVuPLT3rVDFHQ+cSxvL9Qpm/rDuBoWXlq0kopS2rBEYjtbojnuax5pNalpQxjjOMrl0juPkV4lure6g36xqo6ocdbXr78A1DvLqSefij3JcURqmA4uqnSdEK+h/qI6D6YmUe0K1XNvFO8Wyre2WXQdZGh68tHTZemIVYsC8UwRSGBF3v4Ibx2JzgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:38 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:38 +0000 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 v6 5/9] OvmfPkg/CpuHotplugSmm: define CPU_HOT_EJECT_DATA Date: Thu, 28 Jan 2021 16:59:46 -0800 Message-Id: <20210129005950.467638-6-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b241f9a-0d69-45da-f54b-08d8c3f13671 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: Q6X/ltX8rSlpKR8qRbsHRO7ipqLf3tbQOrTkpM48RMpuIuqepXC7FeDfNoFrhVVfE1WMxqmXNrzqDWpc7keKyiELGLHXwEp8R1cbxuBrgF1w1Y+kJslTwR8Tmw3mhhIrgN0fd+hMfkr/j5588XLNWDXXe5T32DbwzuLJJJE+RLYscMyXo5zNxFAftqe9YxuoKhlWLGd+FX2/NokUbq/xhMm581B8viSKl9GrbLlWWuXarFCb/7nCBf/Ext5zfWKm6lNSfaB7nnHRe198xn1SwHGvqYz9JxEqki4S0QWOeqviUXbOtPPojEh5FiioPfcJQ0DNX+scg4FHSh+B9MlBBPHxkVDFnLkxBaC/u9V6vfab4bm/yX3VrCoOmLjy+5fTbH+r5KmLlofog+YtRONOGpjsF/+TnA7SVtlwFAmOCMh4ulMMwsU7GjGTT9L4JYg/BSAKiVo2rjpm1bi+spN76BLUnw8oQV90BT/upI1NPSExoBFQBv6FCWKQrh4X6a7y58xq/b0NUUb5iMwIjWBmw9IExIVeam3uvnkGv6t/9wIuu5/ga9r/7z5FgaYx53ph/glzUN3p9yICLT9lCo/VeAh4dPoJu21DnKokZApEniY= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?UKfqXpd/DqlCp8y0vV0MoNSU+RYLRFFQh2n9YV2ALT4QkCd6xOvdEWbcjJ4p?= =?us-ascii?Q?PdORlf1iA4OCAHU7AypwDN/2TLxX6cwWb4isdY3n7Ch3FGSyyTxYatFu7F4J?= =?us-ascii?Q?5T+l0It2fQGSQtW0vSS6bFCZoU219qhD8fVCI/XEtcWre9f8moccrGoQ7LRT?= =?us-ascii?Q?DW3N4BE5vCECbZcs4EejlD7UPkjzzJZPsxPzLV2nbQuBXe0qAzC3M+TYhStt?= =?us-ascii?Q?gE1z0tdo4mYS0NUmry7aIrO3++eM9cUW2xrBOL/tJSXo2iAE/djRyQwplRyL?= =?us-ascii?Q?357CZpopZZeALJjF3a+5/w1oYIfAF36OE5QqXemPJfNEMiiqDitCXT15tWbq?= =?us-ascii?Q?pzw90PUO/uUyP0LrIBczUB94x7uP/Zb6qBsW92nCVPGkvmX8ZTtSZ6SGTphX?= =?us-ascii?Q?S+/+tyiLRuf+FFdLwI/ccLzjycKSqQ6VokFW/KV9nzdSFRW7L1EMSRAr9zOH?= =?us-ascii?Q?gjmRSFv0VepoGuT8P7lRWO06qhVoePHrFm0Yur0aUa/penK2qZEL7XMw70I7?= =?us-ascii?Q?++ClkLlXWwkaMNuT2zYDTPTir/aG0OQe2ywSNCReaAc1wadwR0a1oQdwEgl+?= =?us-ascii?Q?f8qyBk62gFgteNwySe+mGLk4lGCErh+Vqt5SsTllbhT4W5GkN7ErvhrVd3Pz?= =?us-ascii?Q?G5s8iL2XKhfYRPe6ty/nQlWT7lB5WqiBxGI2QFVNHOVcRfVSMVGhCHOVqvoY?= =?us-ascii?Q?gEXxB+sm9n+6keYifXw45G+C+vhijauGRiq30zTI8lhNM1cWQmY3PwPfiUJR?= =?us-ascii?Q?E3Z8saRMmdz2PvyNI1tRQW0qAyxk/8+FIalqSLwyQra0CPseeK0KpZQEYE8z?= =?us-ascii?Q?SHoEut7M/+ceIES8Y9MBzG2TCj9FAWQPDbIRjr6wnh2CCi1hDy+GjO1AF/fm?= =?us-ascii?Q?/W5HYnGTeI/jYmoHk1LRTj+3KXQIJfE80KNCmHRg4wtTv8L8u+jN8mHcx4+n?= =?us-ascii?Q?VvSeo4KH0+sciGli+G1HvHWVzi6WXdX08L3TEM5G+XiMzWjtSXOFPUT4olLn?= =?us-ascii?Q?yqPgu03gca1olLojsCgqaUonFYwOB1yt0zlHxzOj4hzVT7n0A6Lykp1xe8tu?= =?us-ascii?Q?rvYI9ELf?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b241f9a-0d69-45da-f54b-08d8c3f13671 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:04.3066 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: URunm0U9TxvAc67yIbrT15M29NlHaCNO6kJql0/83F2YpdjGm6Lwi4ApstSkg5aBgjNJnLzg68GtP+28Grs1vpy/uK/qv/nEENbv86lkLXM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: TDmMOl3oxQz7RfPxUDyFFvsKx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882062; bh=2fXIbhxi+IbHYRA9ZlbAmvU6duKz2AJAv6aMhFP3VH8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=NVjlBomB7inv7OIdCIbqsGFy19Af5Q6YKKROmcmksFX2KZ0GiWrfQIpXKfwgDT5Urj3 iE1hSBmmEvsa/uNID10qzWRfmdO74XBG976yiv1RhnFPU5T3HvPbeZcNNq3/4xjwyvK+2 GsuHMXNBQdHXgtnLB02POjth+NUMFBkbqqk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Define CPU_HOT_EJECT_DATA and add PCD PcdCpuHotEjectDataAddress, which will be used to share CPU ejection state between OvmfPkg/CpuHotPlugSmm and PiSmmCpuDxeSmm. 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/OvmfPkg.dec | 10 +++++++++ OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf | 1 + OvmfPkg/Include/Library/CpuHotEjectData.h | 35 +++++++++++++++++++++++++++= ++++ 3 files changed, 46 insertions(+) create mode 100644 OvmfPkg/Include/Library/CpuHotEjectData.h diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 4348bb45c64a..1a2debb821d7 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -106,6 +106,10 @@ [LibraryClasses] # XenPlatformLib|Include/Library/XenPlatformLib.h =20 + ## @libraryclass Share CPU hot-eject state + # + CpuHotEjectData|Include/Library/CpuHotEjectData.h + [Guids] gUefiOvmfPkgTokenSpaceGuid =3D {0x93bb96af, 0xb9f2, 0x4eb8, {= 0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}} gEfiXenInfoGuid =3D {0xd3b46f3b, 0xd441, 0x1244, {= 0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}} @@ -352,6 +356,12 @@ [PcdsDynamic, PcdsDynamicEx] # This PCD is only accessed if PcdSmmSmramRequire is TRUE (see below). gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase|FALSE|BOOLEAN|0x34 =20 + ## This PCD adds a communication channel between PiSmmCpuDxeSmm and + # CpuHotplugSmm. + # + # Only accessed if PcdCpuHotPlugSupport is TRUE + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress|0|UINT64|0x46 + [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderPciTranslation|TRUE|BOOLEAN|0= x1c gUefiOvmfPkgTokenSpaceGuid.PcdQemuBootOrderMmioTranslation|FALSE|BOOLEAN= |0x1d diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf b/OvmfPkg/CpuHotplugSm= m/CpuHotplugSmm.inf index 04322b0d7855..e08b572ef169 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplugSmm.inf @@ -54,6 +54,7 @@ [Protocols] =20 [Pcd] gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugDataAddress ## CON= SUMES + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress ## CON= SUMES gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase ## CON= SUMES =20 [FeaturePcd] diff --git a/OvmfPkg/Include/Library/CpuHotEjectData.h b/OvmfPkg/Include/Li= brary/CpuHotEjectData.h new file mode 100644 index 000000000000..b6fb629a1283 --- /dev/null +++ b/OvmfPkg/Include/Library/CpuHotEjectData.h @@ -0,0 +1,35 @@ +/** @file + Definition for a CPU hot-eject state sharing structure. + + Copyright (C) 2021, Oracle Corporation. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef _CPU_HOT_EJECT_DATA_H_ +#define _CPU_HOT_EJECT_DATA_H_ + +typedef +VOID +(EFIAPI *CPU_HOT_EJECT_FN)( + IN UINTN ProcessorNum + ); + +#define CPU_EJECT_INVALID (MAX_UINT64) +#define CPU_EJECT_WORKER (MAX_UINT64-1) + +#define CPU_HOT_EJECT_DATA_REVISION_1 0x00000001 + +typedef struct { + UINT32 Revision; // Used for version identification of + // this structure + UINT32 ArrayLength; // Entries in the ApicIdMap array + + UINT64 *ApicIdMap; // Pointer to CpuIndex->ApicId map f= or + // pending hot-ejects + CPU_HOT_EJECT_FN Handler; // Handler to do the CPU ejection + + UINT64 Reserved; +} CPU_HOT_EJECT_DATA; + +#endif /* _CPU_HOT_EJECT_DATA_H_ */ --=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 (#70871): https://edk2.groups.io/g/devel/message/70871 Mute This Topic: https://groups.io/mt/80199916/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- From nobody Thu Nov 14 04:58:38 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+70872+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+70872+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882068321429.07238107713204; Thu, 28 Jan 2021 17:01:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id kZmeYY1788612xuixnP4OQ29; Thu, 28 Jan 2021 17:01:07 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.3131.1611882062548779392 for ; Thu, 28 Jan 2021 17:01:02 -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 10T0dwij041194; Fri, 29 Jan 2021 01:00:59 GMT X-Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 368b7r6v0q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:58 +0000 X-Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10T0fEJn009347; Fri, 29 Jan 2021 01:00:58 GMT X-Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by aserp3030.oracle.com with ESMTP id 368wcrdqbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:00:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VsgC+NuH0vOzE7FydLHYVHIQKXjEALmgcynFcnchsRuqlQ8t7HAjEKRJkPQHsAVuaFluvegLz+ZYkIi01Z8Py8b2R9aKLjXldrRldmBmeNEI7ZUqQ1VBBjplijy0fKRmsHsqwMyvUzi9qq76cixsZa6BbLdsYGMs/1LruhP6LQcNRn3hPFJJ0WuTIA36Uk/ayHMeuIZtW4xDIaMfSaTdhOZccHK5ViAxr0hpVufVwd4YCjXVFor1UEXyET4w3O2KYrFbsrQDhQvshIvU5BnrlrtLpuLGkfKUb4YsbQEZuVkq4iGqz91gqyvxkvmkJv/884mRWvku6ndJUgoXuH4ieg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pa0IlAsqvnRJnCylfnjszdcEQRDLDeEKbDPIH/o8FMk=; b=K7u1xVnNf7a7wVGBroV+Ie/PByArraawbQHfqy2j35cMjBOr4nuV6Mar+bYDLvuClNhjyP4sVIqGmxwTp5h4VQ6E4QrrsiaOKtQKV6zCfpUZuh6Vqt43mIzuNBsn6zgSkiZjlzuwsyW6StTp1Y0lYQ9zLjLLoayD+I7KcxhquQ2SGhBYKmeBVjGaxh8h4A0T8vN65Ia5p1T+I7hLfE1TcTXdGfa72zTnLADAnPLBBMTBkGpzhBk8GzvX+JlXdqEFDqaXZW0Lpuuk3hOK3nxoN6yAP0iqxA4F+DvksYFutvzxvTUTQY3agfpn3DgtfdsBsqub6+BPQEf3c8kDDXwmfQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:50 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:50 +0000 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 v6 6/9] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Thu, 28 Jan 2021 16:59:47 -0800 Message-Id: <20210129005950.467638-7-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 454a726a-cb87-46d7-ba28-08d8c3f13734 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: lrZWVWUpJMqg46kaSpxdRS8BI/roIFGu5thyAwJRqe8fiitGE4Lu4LiSkZPG6Og6D16q5D9+0YaCUSU0wc90aOfv+YmxMJS/k/x8DQcEmfe9y3H9ksP54ScDE0p74XYwqfYlEQzCgS1F7oPZX/HGao62mk7tZbQyAZtyA1k9SQ0ggWkbLqXlJzwf5OJKYWXsYlJr6dfHWDbqzuE/9uzM3R4mB/WGmb6yhbdlPz2CAfLANG+6XJFxMGzVuIpgN5ToPU4sR9/poYpH8bIHHO00FeqX+j0JEDFQA9JtT2cy8cxVKtiMobBmfpGM6xk+mRVAZuyps35nv7Ma/kHoNe/c7k05GDFP5hMeSf0aaOdWQIbSoTGoC81JQj3nRQklduAp9VV8v8qHdm5YWxf97x0GFONYR4BrFtcMSkMXZcKUgCwhcKlpqidvvQ+GHo9KM1F0+Jfyw3S3JVhC+BKqla5rjycHTeD92HjSnWH0YKUxK0icVO9x+d0qZHfgaceB3B7oH51hGJWjkK+8v1UPZ1itm2uDTPPU6AspiSUc/sv2jmJLu8CVCeUBdoDASspxuEEsW8yJact0xcy5Vd2Ihhr0bJ7oavnDcgWstmO0WHohLbE= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?vdoBV4J8ei85gOrhScMvlIBU3SpKbb8HisVyyh4u6QIiYxUBWQRFEepv7dG0?= =?us-ascii?Q?o5fQ2zqK06xhRPP64Dz/dgk8ESngGShv1TjZzua4Jo6ze8yvCfi4Simg9Jf7?= =?us-ascii?Q?lyFrQnJQioEk8U2SKJi6fVns39VZKdBqb8mxjZmeqO1d08G6GoxO48sksLWb?= =?us-ascii?Q?kAuEe0Dxz6WoCVDhndj9gYI4qlz9MGpi198Yohnn9DDw2aQ5GLvt27MiCHRK?= =?us-ascii?Q?kxTsnm6ik6woWUPFoF51MGv46WIygW2QgAxi3xFwqw1luiwVreDgy+6dr2YA?= =?us-ascii?Q?ipx9H7o8mw8gEsubRkjCg4UYoQp51TtDeBF9zEikU5kfqhBaQq9fUWjiUuIi?= =?us-ascii?Q?dVR+jDzAJ8Dx2Hw1SYbSpUDuYcMKPpnjXXnWKaFUy9KdBABwsiE/l+pbxL6g?= =?us-ascii?Q?XLjZMShxDRDZ2PKZlIKfMSVTWPBktSOKJGorwH6MVFF7AktxLU0UM4EykYRZ?= =?us-ascii?Q?DDBINXVTaUfK9myO2LnwmDLEj56behGjKBaq2dLanP7ThxoAFtFQgx/NPcMA?= =?us-ascii?Q?MTViivQTHpPkKfsePahAm+/89ubRkMa0pox3zbzMfe9HVq4iOyhI912yDtgR?= =?us-ascii?Q?d2F07yyu7jotTLxi1pMLcHP2rblVRhxOCBPB5TNGM/KoIIO8VDX2cQiWabBs?= =?us-ascii?Q?Fnj61Latgh29iLB6HFZ1UpX/KzKbOaczouKXMproQgYgJiBz+Jl9wI8LRtf+?= =?us-ascii?Q?k0Qbqy14Exy2aOlFUJR6OIrLrpQr8WSWRjL4pZoc2a6QvzdFtPVJ65UU262I?= =?us-ascii?Q?XPFodsNmVfdu7s22flLPpMCk18eHshmU6RnnS5y35nl3HsFGkvoN1H68LmHm?= =?us-ascii?Q?5Z71kM8d8r1jmpR5fmmrUH0ZHfUN7TUfPKPhOp5dZDEEJbx13C91G0F5fJYI?= =?us-ascii?Q?9VjRUvolxkov/kmDoxzh3tAz1FiVhuoC3YIkUc/45rcgWzLzwsrHkZoQ+Jvj?= =?us-ascii?Q?75zo98ZbvqvPEeVNfG759LoxJX1bKaqu0IesBE+mMhL1PZhHzhrGedYw5D7J?= =?us-ascii?Q?59htwJopjkZuDnvSmMpX/3mXDAUEoJ4EREUQKYQr1+O5pQrKkS2fgIgfPmGl?= =?us-ascii?Q?4WDSgoR2?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 454a726a-cb87-46d7-ba28-08d8c3f13734 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:05.5941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xUhKmccOG5T2cXzPfW441jODflQyQD04RrkiSsRcrcaSCxyJSNi+fwwUbGZL0WifmsEDqMABJ2eRySqyRbwPW7HsImjB+Ny8ojhEEjBcfRo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: AhJD59MPDLr56jDDceYqQ8RYx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882067; bh=hucSqba68nwZuqUxQULVZ+QuOZ0d3NdqiJl1jC78VO4=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=Ek1P+HrcErKwIONNh4AD+4bW5GYZru1Cp9vIP9pD69K/4UxpSyU2/Z4aEYc/zEDld8D M6p8YxXzcB0KR2nFuH8VfKHxn8LXZg6ruIzYpwxCTyvrKDjnoaR7gX3u0tLUiFrFFloR2 js18ir3SsDT9s6+tINK9KyAJn5RgJi5yU6Q= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Init CPU_HOT_EJECT_DATA, which will be used to share CPU ejection state between SmmCpuFeaturesLib (via PiSmmCpuDxeSmm) and CpuHotPlugSmm. CpuHotplugSmm also sets up the CPU ejection mechanism via CPU_HOT_EJECT_DATA->Handler. Additionally, expose CPU_HOT_EJECT_DATA via PcdCpuHotEjectDataAddress. 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 --- .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 3 + .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 78 ++++++++++++++++++= ++++ 2 files changed, 81 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/Ovmf= Pkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 97a10afb6e27..32c63722ee62 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -35,4 +35,7 @@ [LibraryClasses] UefiBootServicesTableLib =20 [Pcd] + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..33dd5da92432 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -14,7 +14,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -171,6 +173,70 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer; } =20 +GLOBAL_REMOVE_IF_UNREFERENCED +CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL; + +/** + Initialize CpuHotEjectData if PcdCpuHotPlugSupport is enabled + and, if more than 1 CPU is configured. + + Also sets up the corresponding PcdCpuHotEjectDataAddress. +**/ +STATIC +VOID +SmmCpuFeaturesSmmInitHotEject ( + VOID + ) +{ + UINT32 mMaxNumberOfCpus; + EFI_STATUS Status; + + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) { + return; + } + + // PcdCpuHotPlugSupport =3D> PcdCpuMaxLogicalProcessorNumber + mMaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber); + + // No spare CPUs to hot-eject + if (mMaxNumberOfCpus =3D=3D 1) { + return; + } + + mCpuHotEjectData =3D + (CPU_HOT_EJECT_DATA *)AllocatePool (sizeof (*mCpuHotEjectData)); + ASSERT (mCpuHotEjectData !=3D NULL); + + // + // Allocate buffer for pointers to array in CPU_HOT_EJECT_DATA. + // + + // Revision + mCpuHotEjectData->Revision =3D CPU_HOT_EJECT_DATA_REVISION_1; + + // Array Length of APIC ID + mCpuHotEjectData->ArrayLength =3D mMaxNumberOfCpus; + + // CpuIndex -> APIC ID map + mCpuHotEjectData->ApicIdMap =3D (UINT64 *)AllocatePool + (sizeof (*mCpuHotEjectData->ApicIdMap) * mCpuHotEjectData->ArrayLeng= th); + + // Hot-eject handler + mCpuHotEjectData->Handler =3D NULL; + + // Reserved + mCpuHotEjectData->Reserved =3D 0; + + ASSERT (mCpuHotEjectData->ApicIdMap !=3D NULL); + + // + // Expose address of CPU Hot eject Data structure + // + Status =3D PcdSet64S (PcdCpuHotEjectDataAddress, + (UINT64)(VOID *)mCpuHotEjectData); + ASSERT_EFI_ERROR (Status); +} + /** Hook point in normal execution mode that allows the one CPU that was ele= cted as monarch during System Management Mode initialization to perform addit= ional @@ -188,6 +254,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase; UINTN MapPagesCount; =20 + + SmmCpuFeaturesSmmInitHotEject (); + if (!MemEncryptSevIsEnabled ()) { return; } @@ -375,6 +444,15 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex ) { + // + // CPU Hot-eject not enabled. + // + if (mCpuHotEjectData =3D=3D NULL || + mCpuHotEjectData->Handler =3D=3D NULL) { + return; + } + + mCpuHotEjectData->Handler (CpuIndex); } =20 /** --=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 (#70872): https://edk2.groups.io/g/devel/message/70872 Mute This Topic: https://groups.io/mt/80199922/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- From nobody Thu Nov 14 04:58:38 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+70873+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+70873+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882075748595.891435363371; Thu, 28 Jan 2021 17:01:15 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SOvZYY1788612xrhgn86rUGD; Thu, 28 Jan 2021 17:01:15 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web09.3201.1611882069925198477 for ; Thu, 28 Jan 2021 17:01:10 -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 10T0dwYl041203; Fri, 29 Jan 2021 01:01:07 GMT X-Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2130.oracle.com with ESMTP id 368b7r6v3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:01:06 +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 10T0eFsm081629; Fri, 29 Jan 2021 01:01:06 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by userp3030.oracle.com with ESMTP id 368wr13gd2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:01:06 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AF3/6VG7E43wTCRLT5SV8aAndBifGBIlTfBAjdgaxCgN0YvtcaqsElKel81y7GENRPtUXiTKUEdOSIp4Kd+HRjTLbw0/7SW3o4Y7UFmS9unUoyWa0hlXbFnCCh7xux+6osmllLIi2VwvOrvUJzm2/W0A/amNyFmcpvpcsb1Pb1Pv+qjBMKQ7KVLFeNXBxtPa6dEOWsnf2rjAy/bz4rawT9sqnX2Ury/k4zhNU2omPWNNioH4iJzEGBj1LhCEv0JtJ+HW3xvQcSVUrIx+mOvIVL2ff9CTO4OpfCT7Qya+GVpAtjAf8g6C6k3b+7wGYfDN/r/PqhU+ahwppzUZvhQ/Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Cas9E3Jz2zOrncuZdVvfzFahgTeS8mCUq401jOp9ndU=; b=mrHqEscHOPKBLMeEE8qMenoUbVbH9sr0y/eCPUt3WJ6B8YffZlsCaUxf3W1x4wnGJUT+Fgbt8OuJepiKjFzoNqQIct+78hDNQwCnp5VqHsPz7/ODyCmbe4FPt4n6pVy/qBq59rboPg2t4iiUMuzVuuPx4X4hvXFky5WA4iMJrMTD9kRVBfgZ1o2yJLr46KGrYSXyLr0If1vJUZ4rhlWkatSrTYszUZuIRDbYFrr0pbPKmF2bYeiYYDm99nDoxzk48nvV+hCAUlMI8Qm4ee5SdphHnQtVAY2e0AuIT3nV7CdSSP7T2NBfMiw/OC4IOWmEp6wE1+sADjdhBnTHUmVVHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:00:55 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:00:55 +0000 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 v6 7/9] OvmfPkg/CpuHotplugSmm: add CpuEject() Date: Thu, 28 Jan 2021 16:59:48 -0800 Message-Id: <20210129005950.467638-8-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fbc69340-ae6a-4d3d-5758-08d8c3f13809 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: rq5PwNupKrFG4myNxQzrfYwWPEgpeeuYVbOqkzQ5FK60xwTH71H/swzk/qak8MQgk83gaTr6ri8aNn+UojlrPPoNp6ik/8aFFvzxpieq3Q2tsOIgdwHbc9or2bWW+uT01/doO1s2iYleHiYAlib3oLjMN/ihkKsO6uvOLWIDI9agTeUzTi3xV1it+223ES+1gyceg4nNg3NMhpuO6HptPvW0Gn4LTVrOWvfNwgkIqf9RuSYAMzMEkNi3ak5zKPnP6YU6q2UZ29LIGU1iu3HU+hvB2pk2W/QdYP8ufLgLgWbqb3pRhKT7y5WbKJNwQGmhUfBN0ODAd5zI7Mv6es0SwYA2sZASutmgffIlFh6lHrglMOX5yR9VsI4Zf4vnKvLZPBqP3FdkMF6pOvoFHY0mrblJRIletOOIagYBTZ6mYtVbdbikZW8kqg/yROmJld0/vDGFXZVKcRNHW6iQR+WxgPb05KfPRxAmqDNgrlVGFtkHqq+5BkPStbJYPg/MpCncWFrRXJpPo5BMfoBMYuSg8jiFCpoS90v6fE7KM+82hgGCKynM71VRJYI8IqbNUTMv/Fojm6VAxZn0E1iyHOtTodxoEYyml3ni3uLuD9MAS8k= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?wKIPZjpGV5qEnvfsJdlyzX/j7uCoxp3d36lKA4v/otgNuBwQDAi9x4yb9tbx?= =?us-ascii?Q?pKXyZfZ2qra8gHqxevgJwn7y9x41BILi6bZoEEo1OnRhsABF95wHsyWtE6Un?= =?us-ascii?Q?0YIlQuQPKYnol6va8GXPKsYRwoy3gVUUFT6aMwNC6kEw9Y1KphDPkdhSw3JK?= =?us-ascii?Q?y8FLVSEOdqD/Y5Y+A7LxYUKV5u0FsLLeo4NoPkerboKhK6/mqI8YYoJcdxwy?= =?us-ascii?Q?e6wvJaFVeVzEiYwk8uebGitpB1GUJ+bxze9tQs0XSP8zm4tPCwCVcFXDkjR2?= =?us-ascii?Q?eT7VhZxnN1gyvOLlrz6IoXGTqXwm236GgtMyr0l6JlmOhigbmMqK6ycTs8lb?= =?us-ascii?Q?UUlPuuopw+ECJGyazfNre9hxsnylOZMq2zn8h6E6+vfECiwunyVtIeP9eZ2Z?= =?us-ascii?Q?wZApIA/OPr8jGWHWDt7T7e7581AoU+kjLCPH3ON0o2wwWf4mNoY/LyFcRVBw?= =?us-ascii?Q?85Fme60SK2aKVv3dA0V0QIKQwtgUd/wiigzkG1fPsSSRv8eGeMILrpWmkU5i?= =?us-ascii?Q?bqXEr0AbpDYi1xtWo+LbAZ2sAJ2uP2gL1KsL7WZpblRi5CCEjDjjG40Egtzc?= =?us-ascii?Q?FcbiTJjCwVyg7gw1hjAZU5IHSYOuVN02tfKFQWPzCKoJDMuBJZqU2uThKqYv?= =?us-ascii?Q?2Jc52MGcWqRDX0Yjpt/NtcweP+2qujqO7rrfl3Nn2bHgnUkfCtHB4mX64GbM?= =?us-ascii?Q?Avvm5xybL8X2EBbPt4O8/zDLyf0Vg+Db7QDuJZVhq9vVz7fMsPAOlrIw5Rq+?= =?us-ascii?Q?ZUZzF0UMuNj58R/p3zA8VVy9/hA1oun49raCAjYcRH/Xvll5Zs6hHKkx29gv?= =?us-ascii?Q?AZAX+A+P2VOWg08rBcHZ9EemVMqMdjHhaaD5ZbzLm8EUofC6nbZPOe5tm7QX?= =?us-ascii?Q?JwHVysrgiyc8N1MLyfuW5aUpdaZCoB2TuXmuV6s+XuXKNlQHNKG49gBrDuG2?= =?us-ascii?Q?D67ab5a49iVFXN9T0ZXs/xLr1gOVZQ2WfzmBd33Qi4M/27Yxqjx2FT9QMixU?= =?us-ascii?Q?1OOzjyoQlHw3dQNojiS91I95Y9AT7wIY7e/UFHz47Tf333+oO8XyIO0IeI1I?= =?us-ascii?Q?Vw8P24jI?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbc69340-ae6a-4d3d-5758-08d8c3f13809 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:06.9995 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fE8T43r/GGwJErxkZdmqc5J5Vb7wW9zkpLUcYW2R81E6d7b4lwaUXZlKzr1N8L+XAtSJszx/xTkO17kvw0F4tTywzB0vqvAJAi5dgPtvO68= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: vyFyzhQEmzv7GG1PosbNyZ6Jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882075; bh=9D3utrqATAuzN5nU4mmWM/v4jxSQ+XwMtYmX0Mo9uiA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=aIKZAt11mIvnDhzZpP194X8dK2e+m4/QLfx+fbshC+FIyuBFIilRzJfoKvQpXujVzOf wacjwKzy1qAnyVYOJCTR38SyMelnV8HCzTewqLuTyI9wxav5MwfZVHxM9k6IKUYyR0Xvv gjnisdKSp1xjT3IbF5bCKbX44MTcWU1GLqw= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add CpuEject(), which handles the CPU ejection, and provides a holding area for said CPUs. It is called via SmmCpuFeaturesRendezvousExit(), at the tail end of the SMI handling. Also UnplugCpus() now stashes APIC IDs of CPUs which need to be ejected in CPU_HOT_EJECT_DATA.ApicIdMap. These are used by CpuEject() to identify such CPUs. 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 | 109 +++++++++++++++++++++++++++++++++= ++-- 1 file changed, 105 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 70d69f6ed65b..526f51faf070 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -14,6 +14,7 @@ #include // gMmst #include // PcdGetBool() #include // SafeUintnSub() +#include // CPU_HOT_EJECT_DATA #include // EFI_MM_CPU_IO_PROTOCOL #include // EFI_SMM_CPU_SERVICE_PROTOC= OL #include // EFI_STATUS @@ -32,11 +33,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 serve as 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. @@ -188,11 +190,53 @@ RevokeNewSlot: } =20 /** + CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit(), + on each CPU at exit from SMM. + + If, the executing CPU is not being ejected, nothing to be done. + If, the executing CPU is being ejected, wait in a CpuDeadLoop() + until ejected. + + @param[in] ProcessorNum Index of executing CPU. + +**/ +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; + } + + // + // CPU(s) being unplugged get here from SmmCpuFeaturesSmiRendezvousExit() + // after having been cleared to exit the SMI by the monarch and thus have + // no SMM processing remaining. + // + // Given that we cannot allow them to escape to the guest, we pen them + // here until the SMM monarch tells the HW to unplug them. + // + CpuDeadLoop (); +} + +/** Process to be hot-unplugged CPUs, per QemuCpuhpCollectApicIds(). =20 For each such CPU, report the CPU to PiSmmCpuDxeSmm via - EFI_SMM_CPU_SERVICE_PROTOCOL. If the to be hot-unplugged CPU is - unknown, skip it silently. + EFI_SMM_CPU_SERVICE_PROTOCOL and stash the APIC ID for later ejection. + If the to be hot-unplugged CPU is unknown, skip it silently. + + Additonally, if we do stash any APIC IDs, also install a CPU eject handl= er + which would handle the ejection. =20 @param[in] ToUnplugApicIds The APIC IDs of the CPUs that are about to= be hot-unplugged. @@ -216,9 +260,11 @@ UnplugCpus ( { EFI_STATUS Status; UINT32 ToUnplugIdx; + UINT32 EjectCount; UINTN ProcessorNum; =20 ToUnplugIdx =3D 0; + EjectCount =3D 0; while (ToUnplugIdx < ToUnplugCount) { APIC_ID RemoveApicId; =20 @@ -255,13 +301,41 @@ UnplugCpus ( DEBUG ((DEBUG_ERROR, "%a: RemoveProcessor(" FMT_APIC_ID "): %r\n", __FUNCTION__, RemoveApicId, Status)); goto Fatal; + } else { + // + // Stash the APIC IDs so we can do the actual ejection later. + // + if (mCpuHotEjectData->ApicIdMap[ProcessorNum] !=3D CPU_EJECT_INVALID= ) { + // + // Since ProcessorNum and APIC-ID map 1-1, so a valid + // mCpuHotEjectData->ApicIdMap[ProcessorNum] means something + // is horribly wrong. + // + DEBUG ((DEBUG_ERROR, "%a: ProcessorNum %u maps to %llx, cannot " + "map to " FMT_APIC_ID "\n", __FUNCTION__, ProcessorNum, + mCpuHotEjectData->ApicIdMap[ProcessorNum], RemoveApicId)); + + Status =3D EFI_INVALID_PARAMETER; + goto Fatal; + } + + mCpuHotEjectData->ApicIdMap[ProcessorNum] =3D (UINT64)RemoveApicId; + EjectCount++; } =20 ToUnplugIdx++; } =20 + if (EjectCount !=3D 0) { + // + // We have processors to be ejected; install the handler. + // + mCpuHotEjectData->Handler =3D CpuEject; + } + // - // We've removed this set of APIC IDs from SMM data structures. + // We've removed this set of APIC IDs from SMM data structures and + // have installed an ejection handler if needed. // return EFI_SUCCESS; =20 @@ -458,7 +532,13 @@ 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 Hot-unplug is available only if CPU Hotplug is, so + // the same DEPEX also guarantees that PcdCpuHotEjectDataAddress points + // to CPU_HOT_EJECT_DATA in SMRAM. + // mCpuHotPlugData =3D (VOID *)(UINTN)PcdGet64 (PcdCpuHotPlugDataAddress); + 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)); @@ -470,6 +550,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. // @@ -552,6 +635,24 @@ CpuHotplugEntry ( // SmbaseInstallFirstSmiHandler (); =20 + if (mCpuHotEjectData) { + UINT32 Idx; + // + // For CPU ejection we need to map ProcessorNum -> APIC_ID. By the time + // we need the mapping, however, the Processor's APIC ID has already b= een + // removed from SMM data structures. So we will maintain a local map + // in mCpuHotEjectData->ApicIdMap. + // + for (Idx =3D 0; Idx < mCpuHotEjectData->ArrayLength; Idx++) { + mCpuHotEjectData->ApicIdMap[Idx] =3D CPU_EJECT_INVALID; + } + + // + // Wait to init the handler until an ejection is warranted + // + mCpuHotEjectData->Handler =3D NULL; + } + return EFI_SUCCESS; =20 ReleasePostSmmPen: --=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 (#70873): https://edk2.groups.io/g/devel/message/70873 Mute This Topic: https://groups.io/mt/80199926/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- From nobody Thu Nov 14 04:58:38 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+70874+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+70874+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882077855585.2182268156394; Thu, 28 Jan 2021 17:01:17 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id khBZYY1788612xpfC6Rde9ni; Thu, 28 Jan 2021 17:01:17 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web09.3202.1611882071984432895 for ; Thu, 28 Jan 2021 17:01:12 -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 10T0eplt064441; Fri, 29 Jan 2021 01:01:09 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 368brkxs9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:01:09 +0000 X-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10T0dtF1084478; Fri, 29 Jan 2021 01:01:08 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by userp3020.oracle.com with ESMTP id 368wjutpvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:01:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cm68AqGZGw//plVfF/Y0m9jMLrEsabv+Jf7msq6JoapvuAvAJ1MjDRr/81Np0gbINPlYB6Qz8y+ugW6w/oQn+ObYMKkCQMB6vJLYV/DUpKX82gqRcwVGnlERZwemCRwmLGu0vPwTomTWCbywZE7BpYHw0gBuZcVAApR8fOsDb8mdeFx+FE1TzhqFwh8rq1ztO4MTCaKtdDu8LWRc+koeTNFXUIFgEILOByyWtZ1U0l64Z2WCm4HfVxQL+ADjWSZmAT7+4tylc3y7g/xFXZcVr/ScEJgJ4f/CSli9Kr/dhRQe+AfYsr5lFNvakjlGOsWusP1/3s3VyDw1/q+hvil9dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JCwKS/cvEanE1H3hBiZcnWxV/RiXa5isy4L/1PprdC0=; b=GU7AXLY1dW4C3JY2jjJ+lw3jiB9Z0GBP28Tk+9QVIcs0PG6cP+DpjG7pxAknD8aXl7Q5vtDLp7Z8rQUg0+JRlDc+BkBgB/QHNevDPoClrbkVV42ITurri2QKpwrNkwQt9kLI7fSth92Rzr64jGTN8gCoxaXNvyJL6TOxkCzpeAzff03dTfAJYiI/x2TR3mPADtqwlS+ocT5ki5F4Xj+Mq6zQtXA2FnR/C6GbYmrMYfcFotZBCJ3lN0Hm0dVEBZ0mMMH1FBw2gQ7pt+4lUbF19IHwQtSXFivMvRDshbb7YKybz5cHo+HEQEVl9IYjDAJsCDDWRTV8+xQf9vXX10QFbA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:01:04 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:01:04 +0000 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 v6 8/9] OvmfPkg/CpuHotplugSmm: add worker to do CPU ejection Date: Thu, 28 Jan 2021 16:59:49 -0800 Message-Id: <20210129005950.467638-9-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c12de2ec-cc4e-4d07-f023-08d8c3f138df X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: HlklQwGDx+sOxIISa3ler/tnNd7RFDlP5pYVYIl0AERY7sQzYpFe2vDsjd/agkcJyofBwSQpVdcvke0BFe5kdjNRjsnLKjbtifRVdrsl3KL+cp8oMpwrL8s5AUd6iArEmzdedbfxiHnuUoInegQaIhlTabVq/ddbLjbESpamHFu91d6WLHXpzQqHDhWZeS3MCMsqmsdXL59ZT0zJ54POvld4wuNzIOBaUfblBQkCtR3RbYin47FXUsxbT7IQJLe3Z52WE43bB1ZhfpNdOjeGiCEnT8qwLytPY7eWOG17YG5SU4P2hvbUEbH3xAK/T4GkS0R82iizfokf0Qa9THbYjuY6a0dVZi9gZHcxS/rr5V5m7f6iSdee0e7zgl4Fc2TxxHqw8YwPn//vI8A29DSURk9i5bsWW5Rz7fMmF1XwxMOapVoZ9ZbL+MPkXyPCnu+HJzU2hYBhUjM7a9mox4AD68JYV5ZHnM1ceS2NrgZBrVfaYiqGcTl2VB6lmRluFSpQQMH7oCcjcovT6jzSqLRIqwHiP7OixU9K/6TIbi2jn4k7QrtqA7+OWPfQe967beuGqFuQ+OYB3tS6JnyL3N/o3D4WVUGTi4EZpDSMTLkzLIk= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qn0ehnigrCcA7VLK6uGGuW7cWw1kxy3l4SMcS18Uaz1GjQdo87Yz3a8oEV76?= =?us-ascii?Q?H+sR0CbT3OShOEco09LuNJV8XmMemZXBFxuZY1uxM/cxX5im7O6raUr6UcND?= =?us-ascii?Q?XyjLLMtwCU0MHymBsqLKCNP+IQGz+gzwXhD9FQ7fYCLppNxx9+1hSNQyOo8Q?= =?us-ascii?Q?sV2kmvTJlIvzOsUtqRO+cISJPR6Yo4Aq5SLHjoXBQlrvTugKzgNWjxsPPthn?= =?us-ascii?Q?BQXk8Icgb1aeKYiCRRrR4qPkvm5GcPSqp+7HWmIq1twpoGB7bJbptnhg+fAK?= =?us-ascii?Q?dQGRR9as+reVhOzAn+hGDxCKaETLwLJK7TKa8Q6Wtl6wrw61df6moN5EOEHg?= =?us-ascii?Q?EDwIHa2gyvx2FlXgfs1gQCGHlpEKmK0ZD9mqv3DTSB3T1bNJjTInjUcmHCPO?= =?us-ascii?Q?w/cNAESW2yIsxquQYfPgoBcRyUFhYW2b3TAcOK/Cjw5D0qe9k2HpZmTTwLNM?= =?us-ascii?Q?X6Y8zdRTPL3FOViSg3wiW/KBzOhZ4+f559W1f31+AAEe96nAIcxHUOu7YsHP?= =?us-ascii?Q?mwB4Nud/oiMGCjpqkY+4HP0QufTF5brKugDn7m4SHpwvDPzX7V7fyw1av8yl?= =?us-ascii?Q?+kADqQ96p8VB2SktnrOgoEBX9ASU5WKP7HWsM5Q5h2Ensh1tIj+lKeMx03XP?= =?us-ascii?Q?9IaISIjFTDYHmQRFYF9TL8UoNDi6f+c508v1QnNT7AoQDympYZTwSDgJ46MU?= =?us-ascii?Q?pFowWWC8DpRcoa5yNZlG9umx8PthlxxbBbDmmlap0aV0j5bX5vrIcVYLgOxz?= =?us-ascii?Q?i8v4GkULx08DpXIJWGPGTXsqGovpIOlsJzBuJHbKtkfpxoXmrHjxMX1iu1Mv?= =?us-ascii?Q?vBl62IalMHBSPk42bwQivodhsuVIPGNrFmGnHxdPZqjoCCCzlh4L3Jhn4lI1?= =?us-ascii?Q?Y8KLTfX0mHp/6XJY3dMOmsmpXL2iy83Tz5Y5va4NyklSbGHxmUKF0xwz4X4Y?= =?us-ascii?Q?+S1bFQGkqpXyBGKALZ3moMdd4E56cAfz90PDe8n3EZi30tpKYd2oDRyjJgjU?= =?us-ascii?Q?CjcTs+u2yplnqJJYR6LjQE51u9SsgXhNdwrrJq+7fYT0SBrv6yGXGC/GXSTO?= =?us-ascii?Q?qfJCmo+I?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c12de2ec-cc4e-4d07-f023-08d8c3f138df X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:08.5218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: elx558NLx7BawA20Ume7sl9zyaUeyTP772QEn0+5hu+lFwqoNrPisVAu9SEhkqJpbKiayDBWUCfKCyBftpgd6VUMtc7ZTAxnWnZzDNjsQEw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: DIeFLGUF8rkIAzHOKTV0qfaex1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882077; bh=Ffi3VXM/fJq3qdBQu+GuwzwA3ag8xZI7puyYtoLtxNc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=qcuCNb50zf2eho6Fqd/M5F74tBx7eJSJ1/SX9gzLT/ECHOj7v60YXDiZ9sZ4o77nBoB 2LThhajxIhWB7OmbTYCKS7A44QsDXMNBrmCw8icIT4CuWP5s7c5zgyCVRGn52ms2dhPK1 H706otH2FNYAcdpGHI8wrtlJVSyEI3KBDsY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Designate a worker CPU (we use the one executing the root MMI handler), which will do the actual ejection via QEMU in CpuEject(). CpuEject(), on the worker CPU, ejects each marked CPU by first selecting its APIC ID and then sending the QEMU "eject" command. QEMU in-turn signals the remote VCPU thread which context-switches it out of the SMI. CpuEject(), on the CPU being ejected, spins around in its holding area until this final context-switch. This does mean that there is some CPU state that would ordinarily be restored (in SmiRendezvous() and in SmiEntry.nasm::CommonHandler), but will not be anymore. This unrestored state includes FPU state, CET enable, stuffing of RSB and the final RSM. Since the CPU state is destroyed by QEMU, this should be okay. 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 | 73 ++++++++++++++++++++++++++++++++++= ---- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index 526f51faf070..bf91344eef9c 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -193,9 +193,12 @@ RevokeNewSlot: CPU Hot-eject handler, called from SmmCpuFeaturesRendezvousExit(), on each CPU at exit from SMM. =20 - If, the executing CPU is not being ejected, nothing to be done. + If, the executing CPU is neither a worker, nor being ejected, nothing + to be done. If, the executing CPU is being ejected, wait in a CpuDeadLoop() until ejected. + If, the executing CPU is a worker CPU, set QEMU CPU status to eject + for CPUs being ejected. =20 @param[in] ProcessorNum Index of executing CPU. =20 @@ -217,6 +220,56 @@ CpuEject ( return; } =20 + if (ApicId =3D=3D CPU_EJECT_WORKER) { + UINT32 CpuIndex; + + for (CpuIndex =3D 0; CpuIndex < mCpuHotEjectData->ArrayLength; CpuInde= x++) { + UINT64 RemoveApicId; + + RemoveApicId =3D mCpuHotEjectData->ApicIdMap[CpuIndex]; + + if ((RemoveApicId !=3D CPU_EJECT_INVALID && + RemoveApicId !=3D CPU_EJECT_WORKER)) { + // + // This to-be-ejected-CPU has already received the BSP's SMI exit + // signal and, will execute SmmCpuFeaturesSmiRendezvousExit() + // followed by this callback or is already waiting in the + // CpuDeadLoop() below. + // + // Tell QEMU to context-switch it out. + // + QemuCpuhpWriteCpuSelector (mMmCpuIo, (APIC_ID) RemoveApicId); + QemuCpuhpWriteCpuStatus (mMmCpuIo, QEMU_CPUHP_STAT_EJECTED); + + // + // Compiler barrier to ensure the next store isn't reordered + // + MemoryFence (); + + // + // Clear the eject status for CpuIndex to ensure that an invalid + // SMI later does not end up trying to eject it or a newly + // hotplugged CpuIndex does not go into the dead loop. + // + mCpuHotEjectData->ApicIdMap[CpuIndex] =3D CPU_EJECT_INVALID; + + DEBUG ((DEBUG_INFO, "%a: Unplugged CPU %u -> " FMT_APIC_ID "\n", + __FUNCTION__, CpuIndex, RemoveApicId)); + } + } + + // + // Clear our own worker status. + // + mCpuHotEjectData->ApicIdMap[ProcessorNum] =3D CPU_EJECT_INVALID; + + // + // We are done until the next hot-unplug; clear the handler. + // + mCpuHotEjectData->Handler =3D NULL; + return; + } + // // CPU(s) being unplugged get here from SmmCpuFeaturesSmiRendezvousExit() // after having been cleared to exit the SMI by the monarch and thus have @@ -327,6 +380,19 @@ UnplugCpus ( } =20 if (EjectCount !=3D 0) { + UINTN Worker; + + Status =3D mMmCpuService->WhoAmI (mMmCpuService, &Worker); + ASSERT_EFI_ERROR (Status); + // + // UnplugCpus() is called via the root MMI handler and thus we are + // executing in the BSP context. + // + // Mark ourselves as the worker CPU. + // + ASSERT (mCpuHotEjectData->ApicIdMap[Worker] =3D=3D CPU_EJECT_INVALID); + mCpuHotEjectData->ApicIdMap[Worker] =3D CPU_EJECT_WORKER; + // // We have processors to be ejected; install the handler. // @@ -451,11 +517,6 @@ CpuHotplugMmi ( if (EFI_ERROR (Status)) { goto Fatal; } - if (ToUnplugCount > 0) { - DEBUG ((DEBUG_ERROR, "%a: hot-unplug is not supported yet\n", - __FUNCTION__)); - goto Fatal; - } =20 if (PluggedCount > 0) { Status =3D ProcessHotAddedCpus (mPluggedApicIds, PluggedCount); --=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 (#70874): https://edk2.groups.io/g/devel/message/70874 Mute This Topic: https://groups.io/mt/80199930/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- From nobody Thu Nov 14 04:58:38 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+70878+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+70878+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=fail(p=none dis=none) header.from=oracle.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611882200161737.5762230152853; Thu, 28 Jan 2021 17:03:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id DW5vYY1788612xdhClAFoRI9; Thu, 28 Jan 2021 17:03:19 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web11.3165.1611882194308091904 for ; Thu, 28 Jan 2021 17:03:14 -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 10T0dvT0041186; Fri, 29 Jan 2021 01:03:10 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 368b7r6v8r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:03:09 +0000 X-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10T0duse084583; Fri, 29 Jan 2021 01:01:09 GMT X-Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by userp3020.oracle.com with ESMTP id 368wjutpx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 29 Jan 2021 01:01:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cvn+FtmixTjPMFGiLq2KiSHKnzqxYl1tzQCJhJxPbjbtg7S4PYGj9PBcyl0Tsa0aP25jUVWVbsV1yHcTr13EHBwoUVFsAx2Kl4YBi06FgI33hNGhIgUUtKktLHGJX39/XZieeRzjhB3I2+wCYq4RSl7+Hvl4MmqpJ8dquySSBtBhc6Qg8AS3W0P6yUgLc83CNgSZeIs7CX9UULnzGWFXOGSl90ZporXvxjscDx1dMybUL616aohQ5lhYDgs3YgA3yD3Mx91nFqwEW80Bv9895mla7kUCAY/V9519KH6MD1X2fuZ6PiJA47woX0GvVTWn8/5oZKggCvwd5UAHJo8S6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=36qBbBe5dOPYeRoLF8Xd0QOYo8RDNVjRX3kTgxR0JyU=; b=WVQb2bG/jeFeut5abVjwdquWSQsEqEPZjskrQPMPbb1/XgcK9IJB8bnMOL0VFCzcfY/q/SBEBRC1fO4dQQg+JnO2WH2KSFSo8YbAnP1lfUXWyGi4j2vv9UlAAF8GHrpuhsQw98+kjcR79/GNWpCYe3Y6lfV4yRHGtWi+O22rFJzV9kO74WTBFKDDWBMCY2uThkgCLJcXli3eHO6NqU7kqOPsJA5urlo1l0vFQACLBw+nP/YR+ZDW5RolKOQSFMkHCiEPesCb6cTfuJHg7Z0yM9Xnj4UM1trcKQ1452q00HFlrXZi4miIF9l3VO3Vam4my6RkqEEHJKfE023F96P+Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2246.namprd10.prod.outlook.com (2603:10b6:910:41::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.16; Fri, 29 Jan 2021 01:01:06 +0000 X-Received: from CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6]) by CY4PR10MB1718.namprd10.prod.outlook.com ([fe80::39dc:6ba7:9397:cb6%6]) with mapi id 15.20.3805.019; Fri, 29 Jan 2021 01:01:06 +0000 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 v6 9/9] OvmfPkg/SmmControl2Dxe: negotiate CPU hot-unplug Date: Thu, 28 Jan 2021 16:59:50 -0800 Message-Id: <20210129005950.467638-10-ankur.a.arora@oracle.com> In-Reply-To: <20210129005950.467638-1-ankur.a.arora@oracle.com> References: <20210129005950.467638-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.8] X-ClientProxiedBy: MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.8) by MWHPR1401CA0022.namprd14.prod.outlook.com (2603:10b6:301:4b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17 via Frontend Transport; Fri, 29 Jan 2021 01:00:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ec8659c4-0b50-4212-4fe5-08d8c3f139c7 X-MS-TrafficTypeDiagnostic: CY4PR1001MB2246: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info: PSfKCr4ixzWzgbpxdu4H+SdG+gI1nZmF4GAbLPVQIcd+vUB25sGyPccNlRwFFgKIZFgeI9Sqyis8VSZp0Fgc6tYVKixl43vXjPa5UD1SEdebI2TwxGje1hbMzZ0nOhagmMr6g4zxLGtlU0dhNZwUIPvVuo8sLhJwv4xs9BCN78agNl81d534H7Oli/ReZZkV737HGk9Ol16swXeIFevhfZughL2D+f3YrwPQx1yr8bbjzH6n1/MKdi3qLEEIyBbn7YRbsKnreZz4XaXf2MkRisxi8dJSF68Evi2kIbNtm/DwX0qOQHmRNstZpHJPncEGuco0Ady/1uWI4drE79+qCUucbZaBbZdebMu1YL2b/5EoOtVRSmizqAdB8P/dxKlW1lMXuYaqaqBZcHAdCZdZq2aaVwdXigmjwWsz7m9ZO9De+jv4H7dxgP3zStrLp7oIH6p0J4xry8EH1nv/GPOUgOnFbBZPCuUL/0VHmZySSc3mACeR8IWORwTHI5Ag3BTkw25j5GPQeQ4UPRvpmTAD/+U4AWF518yizssKLAyQhbX+QcZWY3BMzpoDER15l/nYkYdNPp+yu50mGPGQ+WLkV0JlSu70fqPBCB/asKEYcmI= X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?4kIu5JAIE6IUBErz/c3xJyesRoz3XvSdb4in7Jh+N1Wak4P3PMESlpRqekxG?= =?us-ascii?Q?dHX0gsW9o/quxeuQhbRLsd9p0+XvMDHlEpMblhsccV0fDimH5oP5AUKRrbJU?= =?us-ascii?Q?6PTT3VlHXVxZxOxOTGmoeO4lZzrRbJCkSixk031IvpqBwF+1dCK6fgXT/D2b?= =?us-ascii?Q?Grtao4A7GSBKcSRQKzUIcWLgJ1wMweDtxcUrxFtHiaVsF9GNwxyTmdfMu0gd?= =?us-ascii?Q?6ib6xRcxSyyU3G61VUpYzbJylPZYMCTn/u7SlIbqddnwZ5Nai/NUJkE0zUuW?= =?us-ascii?Q?MP9O4tc9eVmh9ICI+utcZF3GBszZSHDErwWu2V8/kBdEEKSa3jzu7sebzVQB?= =?us-ascii?Q?X3dzrwGhZa7qAxok5/+rPT07EQUjyuST0Y+uhf+iDxl7/PoFMA0ruzFslLjF?= =?us-ascii?Q?NhmNholNKrHGeXq7oatZkMzIwjE7VCpgVhfkjlurVe5Mi0OAuvEhmPSOz1al?= =?us-ascii?Q?dLpAHF/ndN0wDJ0WL4vCRnROeEZxzGoXbVmx3yDp90uQD9vBggUcM6oLQ1Ak?= =?us-ascii?Q?wwHVKGQdAUZQ5TY6etRr/l2/4eJbFk8G7EgcHB+yLXolQGQVST3OVOCozCR+?= =?us-ascii?Q?tFIvL722ou8dyN2j4J5jUrQFNeKx0/yVScgfsTZGihIz7e8MwEIfgDs12oEB?= =?us-ascii?Q?6nfBuQKfuzPILQZIzVo2LfCTJrkFYdpWsI6WYqUbQy0h1qbxUDZ0o23MBk9z?= =?us-ascii?Q?Jk1NEN54Qatf6Ynp1F6R9JQUohuWG/95CPDhLVwnnrWQ0bUsjI604T1zQeO3?= =?us-ascii?Q?wVjQi5jnge1uPwBI9Cud+tbu/dNptaG2XCfI+IMVInt3uAppWiD4n/TwvRPk?= =?us-ascii?Q?SIc4V27ck1HjFmS3wehqE04D7wJDS/Z36Gi7fYy+6UBB2hA/YHyPh08+ytnu?= =?us-ascii?Q?rrHCnsfUqnmPcHN7aUsmGijZsVbCSTfBLbkyPFb3JUoCw4+ukqA36MwZFVOG?= =?us-ascii?Q?2uE9E4DmUbJXJwM35dwrsfbDW8A9H1hgU4lQ5o5Tm+zy/3xQCBEyAFjKIi8B?= =?us-ascii?Q?QN708PzmNQSlJUxKxzWiVyMI6HtETe1jXw6X0qgUj4T71zoK4KfXUpjaqWqH?= =?us-ascii?Q?gUNIOz9j?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec8659c4-0b50-4212-4fe5-08d8c3f139c7 X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2021 01:00:09.8952 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4lONGSThHdZBDeHgCxovl2n4+VWnbrbHsPOGSxupWtzNCO9ZKIqprzT1+mvzqUThudl+ZBTVnY1MrWWqnoGp9f11fRfCgNISvcAwvNGoX4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2246 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: HletZVujWwpJiqoMkkWWFuP4x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611882199; bh=ITOpNsdfDpYa2b2FpD3n6KQstIUI2WBtseFrMjv5WXA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=IkMgalLQUEs0TrWoa3J5OhH6xqPyT1sar98xtqLzI7tUvJltS/SRYp0y96NGEZESKwK QrQSLbTqsqgkan4HH50xgE5JVZ+C5d77OY2lKo3AYvZet2Vcdd+MCArJxkAbrDrq0N13D O3lgUR0XWcaw4Z+WAQwZ9hj5qvw/RMbP5/k= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" As part of the negotiation treat ICH9_LPC_SMI_F_CPU_HOT_UNPLUG as a subfeature of feature flag ICH9_LPC_SMI_F_CPU_HOTPLUG, so enable it only if the other is also being negotiated. 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/SmmControl2Dxe/SmiFeatures.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c b/OvmfPkg/SmmControl2Dxe/= SmiFeatures.c index c9d875543205..e70f3f8b58cb 100644 --- a/OvmfPkg/SmmControl2Dxe/SmiFeatures.c +++ b/OvmfPkg/SmmControl2Dxe/SmiFeatures.c @@ -29,6 +29,13 @@ // #define ICH9_LPC_SMI_F_CPU_HOTPLUG BIT1 =20 +// The following bit value stands for "enable CPU hot unplug, and inject a= n SMI +// with control value ICH9_APM_CNT_CPU_HOT_UNPLUG upon hot unplug", in the +// "etc/smi/supported-features" and "etc/smi/requested-features" fw_cfg fi= les. +// Is only negotiated alongside ICH9_LPC_SMI_F_CPU_HOTPLUG. +// +#define ICH9_LPC_SMI_F_CPU_HOT_UNPLUG BIT2 + // // Provides a scratch buffer (allocated in EfiReservedMemoryType type memo= ry) // for the S3 boot script fragment to write to and read from. @@ -112,7 +119,8 @@ NegotiateSmiFeatures ( QemuFwCfgReadBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 // - // We want broadcast SMI, SMI on CPU hotplug, and nothing else. + // We want broadcast SMI, SMI on CPU hotplug, on CPU hot-unplug + // and nothing else. // RequestedFeaturesMask =3D ICH9_LPC_SMI_F_BROADCAST; if (!MemEncryptSevIsEnabled ()) { @@ -120,8 +128,18 @@ NegotiateSmiFeatures ( // For now, we only support hotplug with SEV disabled. // RequestedFeaturesMask |=3D ICH9_LPC_SMI_F_CPU_HOTPLUG; + RequestedFeaturesMask |=3D ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; } mSmiFeatures &=3D RequestedFeaturesMask; + + if (!(mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) && + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG)) { + DEBUG ((DEBUG_WARN, "%a CPU host-features %Lx, requested mask %Lx\n", + __FUNCTION__, mSmiFeatures, RequestedFeaturesMask)); + + mSmiFeatures &=3D ~ICH9_LPC_SMI_F_CPU_HOT_UNPLUG; + } + QemuFwCfgSelectItem (mRequestedFeaturesItem); QemuFwCfgWriteBytes (sizeof mSmiFeatures, &mSmiFeatures); =20 @@ -162,8 +180,9 @@ NegotiateSmiFeatures ( if ((mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOTPLUG) =3D=3D 0) { DEBUG ((DEBUG_INFO, "%a: CPU hotplug not negotiated\n", __FUNCTION__)); } else { - DEBUG ((DEBUG_INFO, "%a: CPU hotplug with SMI negotiated\n", - __FUNCTION__)); + DEBUG ((DEBUG_INFO, "%a: CPU hotplug%s with SMI negotiated\n", + __FUNCTION__, + (mSmiFeatures & ICH9_LPC_SMI_F_CPU_HOT_UNPLUG) ? ", unplug" : "")); } =20 // --=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 (#70878): https://edk2.groups.io/g/devel/message/70878 Mute This Topic: https://groups.io/mt/80199973/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-