From nobody Thu Nov 14 17:06:44 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+71914+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+71914+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 1613978393259704.8973420738513; Sun, 21 Feb 2021 23:19:53 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 15KQYY1788612xQxrjgeCXUi; Sun, 21 Feb 2021 23:19:52 -0800 X-Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by mx.groups.io with SMTP id smtpd.web08.32137.1613978387296919807 for ; Sun, 21 Feb 2021 23:19:47 -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 11M7Dv4e131242; Mon, 22 Feb 2021 07:19:43 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 36ttcm2ke6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:43 +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 11M7GCDt126471; Mon, 22 Feb 2021 07:19:42 GMT X-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by userp3020.oracle.com with ESMTP id 36uc6pynae-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=flr4z6yQlAxFaUCZ9MvKDtoNuUQZ+XW0SFRSSYA2HNlXknK+DbI4shM2+wD9X9C5PSJXQKkNRuWVl36I8kHRDIxf3u0f9Kj+Sv5zP+IFz7KK9oPyUW5Y2HRgkoxqAvVzmxQ01u4jJ0aOIS2opgBn3Ik6qwC/kBeU1QkZ6RbEq0qfAcMQ+hJf1nfXEg6QlV8SwaqJYpAhkVjv9jSCXu8nZ/8I2Z0fSNN1/ZItMBV8OouWgt8wd73+o2lHa7mt2SXnIY6/PUMU0zrD4YFkvTMvZ8raz8wIUK6kaujbA3GzQA1+nzDi6UmVR2m7HdLSGO1b0vpzOZ4VlZ9nyN+c5X6c4g== 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=LRmSgHeU2Z8fSi2Ls38i75CZGzgGp6EbcgbHjRODjIU=; b=FSRPC4FVq9x+56VbzB+G4l2Au80TDTZGRZ7817+Yuaaa3vEuyhJLJX+WDAV16PZKIB6ad1nlfUio5XHIvWVkfGjZ3RiXeE0WMpm1vKzkEPeZyH961wI5fk4kk36rg2Q0eu/qKDmRWM+doMcJ+vrBFGtbEoIgjs//i32/8dpmCPpjNQQAcyqqQyQdFxABydCYfo+aTCFQBtCKaNr+/Mj6BdOsIudzD9aZpYicydRdYOWX24eoSm4Qa9womfhos4r4OzoLYhilk8p6sjdp4eMwi7QJD8C1gFxqqo2xBhbQPg4N0XFjrN1fb14AkP3lczLQW5sxa2ZeExSszlSLWXePaQ== 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 SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) by BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.29; Mon, 22 Feb 2021 07:19:40 +0000 X-Received: from SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16]) by SJ0PR10MB4605.namprd10.prod.outlook.com ([fe80::a021:790:7ce6:6f16%6]) with mapi id 15.20.3868.033; Mon, 22 Feb 2021 07:19:40 +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 v8 02/10] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Sun, 21 Feb 2021 23:19:20 -0800 Message-Id: <20210222071928.1401820-3-ankur.a.arora@oracle.com> In-Reply-To: <20210222071928.1401820-1-ankur.a.arora@oracle.com> References: <20210222071928.1401820-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.11] X-ClientProxiedBy: MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) To SJ0PR10MB4605.namprd10.prod.outlook.com (2603:10b6:a03:2d9::24) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Received: from prion.us.oracle.com (148.87.23.11) by MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Mon, 22 Feb 2021 07:19:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 28450373-8cec-48dc-8cdb-08d8d70237d2 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBCl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YWQK0ljYQM2H8gCGT2coamrtdwMrtJVPf1?= =?us-ascii?Q?q87EQdWLQkRx+1QYafvz5beZ9WrR+Jm2nVDNRgyLoH/msuPNrUmnA1GztzED?= =?us-ascii?Q?u/P1+xasovQm4193R23mvA6W8AqHdt+dalRdw5ydObfcF40bHcM56/GwT3Zb?= =?us-ascii?Q?md7yS1KUOCc1mn639d5p9yjU?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 28450373-8cec-48dc-8cdb-08d8d70237d2 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 07:19:40.0790 (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: EjlBEqMLSBUtlfwWuWxY8sbIXFTJauL6oiwqLa/fucPZANn7t8fd4HHruIDSAyDeUwm6lOrdn+f4fiopzwavxm+nDEF0DfXf5BxBgZQPM/U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 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: XS3QZveGRDQNo5dwqoOW0O77x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613978392; bh=nWHmRU+iLq3oQsFSdmqHuk9t3nRflpBC5qw526t/O/Q=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=cswJcSRiG3nm+z9Dojxl68ABzr1Y45wOACwlmHItyez8Wnzg1TFuqmv39fbcuViqUK+ Pvni1jxzDnxBOrw+1098GEe3fepHkDfVci5KIyRucFZXb8pLCFT92Krcnse1ImYJCO3vE muf8fQIVGGy3ksqaFG+wyst0EI5kOH3vUSw= 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/ 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: Addresses the following review comments from v6: (1,4) Move (and also rename) QEMU_CPUHP_STAT_EJECTED to patch 8, where we actually use it. (2) Downgrade debug mask from DEBUG_INFO to DEBUG_VERBOSE. (3a,3b,3c) Keep the CurrentSelector increment operation at the tail of the loop. () As discussed elsewhere we also need to get the CpuSelector while collecting ApicIds in QemuCpuhpCollectApicIds(). This patch adds a separate parameter for the CpuSelector values, because that works better alongside the hotplug ExtendIds logic. OvmfPkg/CpuHotplugSmm/QemuCpuhp.h | 1 + OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h | 1 + OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 21 +++++- OvmfPkg/CpuHotplugSmm/QemuCpuhp.c | 84 ++++++++++++++++---= ---- 4 files changed, 79 insertions(+), 28 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.h index 8adaa0ad91f0..1e23b150910e 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.h @@ -55,6 +55,7 @@ QemuCpuhpCollectApicIds ( OUT APIC_ID *PluggedApicIds, OUT UINT32 *PluggedCount, OUT APIC_ID *ToUnplugApicIds, + OUT UINT32 *ToUnplugSelector, OUT UINT32 *ToUnplugCount ); =20 diff --git a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h b/OvmfPkg/In= clude/IndustryStandard/QemuCpuHotplug.h index a34a6d3fae61..2ec7a107a64d 100644 --- a/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h +++ b/OvmfPkg/Include/IndustryStandard/QemuCpuHotplug.h @@ -34,6 +34,7 @@ #define QEMU_CPUHP_STAT_ENABLED BIT0 #define QEMU_CPUHP_STAT_INSERT BIT1 #define QEMU_CPUHP_STAT_REMOVE BIT2 +#define QEMU_CPUHP_STAT_FW_REMOVE BIT4 =20 #define QEMU_CPUHP_RW_CMD_DATA 0x8 =20 diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/Cpu= Hotplug.c index bf68fcd42914..3192bfea1f15 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -52,6 +52,7 @@ STATIC CPU_HOT_PLUG_DATA *mCpuHotPlugData; // STATIC APIC_ID *mPluggedApicIds; STATIC APIC_ID *mToUnplugApicIds; +STATIC UINT32 *mToUnplugSelector; // // Address of the non-SMRAM reserved memory page that contains the Post-SM= M Pen // for hot-added CPUs. @@ -289,6 +290,7 @@ CpuHotplugMmi ( mPluggedApicIds, &PluggedCount, mToUnplugApicIds, + mToUnplugSelector, &ToUnplugCount ); if (EFI_ERROR (Status)) { @@ -333,7 +335,9 @@ CpuHotplugEntry ( ) { EFI_STATUS Status; + UINTN Len; UINTN Size; + UINTN SizeSel; =20 // // This module should only be included when SMM support is required. @@ -387,8 +391,9 @@ CpuHotplugEntry ( // // Allocate the data structures that depend on the possible CPU count. // - if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Size))= || - RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Size, &Size))) { + if (RETURN_ERROR (SafeUintnSub (mCpuHotPlugData->ArrayLength, 1, &Len)) = || + RETURN_ERROR (SafeUintnMult (sizeof (APIC_ID), Len, &Size))|| + RETURN_ERROR (SafeUintnMult (sizeof (UINT32), Len, &SizeSel))) { Status =3D EFI_ABORTED; DEBUG ((DEBUG_ERROR, "%a: invalid CPU_HOT_PLUG_DATA\n", __FUNCTION__)); goto Fatal; @@ -405,6 +410,12 @@ CpuHotplugEntry ( DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Statu= s)); goto ReleasePluggedApicIds; } + Status =3D gMmst->MmAllocatePool (EfiRuntimeServicesData, SizeSel, + (VOID **)&mToUnplugSelector); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: MmAllocatePool(): %r\n", __FUNCTION__, Statu= s)); + goto ReleaseToUnplugApicIds; + } =20 // // Allocate the Post-SMM Pen for hot-added CPUs. @@ -412,7 +423,7 @@ CpuHotplugEntry ( Status =3D SmbaseAllocatePostSmmPen (&mPostSmmPenAddress, SystemTable->BootServices); if (EFI_ERROR (Status)) { - goto ReleaseToUnplugApicIds; + goto ReleaseToUnplugSelector; } =20 // @@ -472,6 +483,10 @@ ReleasePostSmmPen: SmbaseReleasePostSmmPen (mPostSmmPenAddress, SystemTable->BootServices); mPostSmmPenAddress =3D 0; =20 +ReleaseToUnplugSelector: + gMmst->MmFreePool (mToUnplugSelector); + mToUnplugSelector =3D NULL; + ReleaseToUnplugApicIds: gMmst->MmFreePool (mToUnplugApicIds); mToUnplugApicIds =3D NULL; diff --git a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c b/OvmfPkg/CpuHotplugSmm/Qemu= Cpuhp.c index 8d4a6693c8d6..36372a5e6193 100644 --- a/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c +++ b/OvmfPkg/CpuHotplugSmm/QemuCpuhp.c @@ -164,6 +164,9 @@ QemuCpuhpWriteCommand ( @param[out] ToUnplugApicIds The APIC IDs of the CPUs that are about to = be hot-unplugged. =20 + @param[out] ToUnplugSelector The QEMU Selectors of the CPUs that are abo= ut to + be hot-unplugged. + @param[out] ToUnplugCount The number of filled-in APIC IDs in ToUnplugApicIds. =20 @@ -187,6 +190,7 @@ QemuCpuhpCollectApicIds ( OUT APIC_ID *PluggedApicIds, OUT UINT32 *PluggedCount, OUT APIC_ID *ToUnplugApicIds, + OUT UINT32 *ToUnplugSelector, OUT UINT32 *ToUnplugCount ) { @@ -204,6 +208,7 @@ QemuCpuhpCollectApicIds ( UINT32 PendingSelector; UINT8 CpuStatus; APIC_ID *ExtendIds; + UINT32 *ExtendSel; UINT32 *ExtendCount; APIC_ID NewApicId; =20 @@ -245,10 +250,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)); @@ -259,40 +264,69 @@ QemuCpuhpCollectApicIds ( CurrentSelector)); =20 ExtendIds =3D PluggedApicIds; + ExtendSel =3D NULL; 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; + ExtendSel =3D ToUnplugSelector; ExtendCount =3D ToUnplugCount; + } else if ((CpuStatus & QEMU_CPUHP_STAT_REMOVE) !=3D 0) { + // + // Let the OSPM deal with the "remove" event. + // + DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: remove (ignored)\n= ", + __FUNCTION__, CurrentSelector)); + + ExtendIds =3D NULL; + ExtendSel =3D NULL; + ExtendCount =3D NULL; } else { DEBUG ((DEBUG_VERBOSE, "%a: CurrentSelector=3D%u: no event\n", __FUNCTION__, CurrentSelector)); break; } =20 - // - // Save the APIC ID of the CPU with the pending event, to the correspo= nding - // APIC ID array. - // - if (*ExtendCount =3D=3D ApicIdCount) { - DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__)); - return EFI_BUFFER_TOO_SMALL; - } - QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); - NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); - DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION__, - NewApicId)); - ExtendIds[(*ExtendCount)++] =3D NewApicId; + ASSERT ((ExtendIds =3D=3D NULL) =3D=3D (ExtendCount =3D=3D NULL)); + if (ExtendIds !=3D NULL) { + // + // Save the APIC ID of the CPU with the pending event, to the + // corresponding APIC ID array. + // For unplug events, also save the CurrentSelector. + // + if (*ExtendCount =3D=3D ApicIdCount) { + DEBUG ((DEBUG_ERROR, "%a: APIC ID array too small\n", __FUNCTION__= )); + return EFI_BUFFER_TOO_SMALL; + } + QemuCpuhpWriteCommand (MmCpuIo, QEMU_CPUHP_CMD_GET_ARCH_ID); + NewApicId =3D QemuCpuhpReadCommandData (MmCpuIo); + DEBUG ((DEBUG_VERBOSE, "%a: ApicId=3D" FMT_APIC_ID "\n", __FUNCTION_= _, + NewApicId)); + if (ExtendSel !=3D NULL) { + ExtendSel[(*ExtendCount)] =3D CurrentSelector; + } + ExtendIds[(*ExtendCount)++] =3D NewApicId; =20 - // - // We've processed the CPU with (known) pending events, but we must ne= ver - // clear events. Therefore we need to advance past this CPU manually; - // otherwise, QEMU_CPUHP_CMD_GET_PENDING would stick to the currently - // selected CPU. - // - CurrentSelector++; + // + // We've processed the CPU with (known) pending events, but we must = never + // clear events. Therefore we need to advance past this CPU manually; + // otherwise, QEMU_CPUHP_CMD_GET_PENDING would stick to the currently + // selected CPU. + // + CurrentSelector++; + } } while (CurrentSelector < PossibleCpuCount); =20 DEBUG ((DEBUG_VERBOSE, "%a: PluggedCount=3D%u ToUnplugCount=3D%u\n", --=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 (#71914): https://edk2.groups.io/g/devel/message/71914 Mute This Topic: https://groups.io/mt/80819858/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-