From nobody Thu Nov 14 17:04:58 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+71829+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+71829+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 1613725502754474.28497189522193; Fri, 19 Feb 2021 01:05:02 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id UfOEYY1788612xTm2C8ju9Ho; Fri, 19 Feb 2021 01:05:02 -0800 X-Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.6069.1613725501373003584 for ; Fri, 19 Feb 2021 01:05:01 -0800 X-Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 11J94Fvb111119; Fri, 19 Feb 2021 09:04:58 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 36p7dnrn7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:04:58 +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 11J8tl0s182210; Fri, 19 Feb 2021 09:04:58 GMT X-Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3020.oracle.com with ESMTP id 36prhve0ju-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:04:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=krsszLS2JIyf/JmUhymkojMC0vPSPz/7205Z4rf5GFlJg9gd1rqfTtDcBB1PkmmgCTUiHMlFQGujsh7ClNjXRqQqZTZDQJ05n+ZDFKvcs8Dxlu4+A91gsnVDQO9JxpPKnoGdcp0IT+qocMcmwAPVnVC+nxUilweJCLkLdA8n+p1ogGSLGcmN+dlE/fwlxx7ytDgBgugOLHRMYjYGdhiCJcuXx5sUpRTx4uG1ltW+JkWi+kuVuWXYWLqm1NJvJQKk4QjFGhx7n3b8RZPWS/35QQmqEmJVqlCmOOGxtyR/XD68TzWXdrFp4l2lMt8G+ZwTXSBxQC99vz3nHfepiesmEQ== 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=OMGaxWd1RoojsEPKaoxxLGBPOqwDAsRCSCGyCkMN5Ugc6rj5npa9+yYC9CxAhUXTwXecsLxG9wkMrgnQYqLSu2hNq079fngtWRiDbgnj3/4zOBceYIBOjAfygL2aa+26yyA2fKqJX9E/yJFoIDLuvJZjKuPWPvpyKnRNpatgIv4wvPEE4Anmrlvsffv8001GhfbXsWVGU98NThrb4i1DRcCdjRxfebPQ3PsPwS15CZh0mqJp2u6PdLGxURMovuB1BxP+UdvwaicuqseMqhBEtZiw9E47M9uUzM8gyMvZPGLUuWEr4eUE+xrPEH8pgevWvzwQNjvXh9p6qeHqQY9oCQ== 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 BYAPR10MB3605.namprd10.prod.outlook.com (2603:10b6:a03:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Fri, 19 Feb 2021 09:04:56 +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.029; Fri, 19 Feb 2021 09:04:56 +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 v7 02/10] OvmfPkg/CpuHotplugSmm: collect hot-unplug events Date: Fri, 19 Feb 2021 01:04:36 -0800 Message-Id: <20210219090444.1332380-3-ankur.a.arora@oracle.com> In-Reply-To: <20210219090444.1332380-1-ankur.a.arora@oracle.com> References: <20210219090444.1332380-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.5] X-ClientProxiedBy: MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) 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.5) by MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.8 via Frontend Transport; Fri, 19 Feb 2021 09:04:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 191fa47a-41ac-40e2-829b-08d8d4b56d4a X-MS-TrafficTypeDiagnostic: BYAPR10MB3605: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-Sen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us-ascii?Q?qa6XQcEGYoM1ObiyXf65icT5SShgHR00hFFtgS4B4ubBUQ5+Lc/Ylo3UdR9w?= =?us-ascii?Q?sXp9j5SSYIwSoScTAon/ix7Jud3WszvUxjA426+fmEmnhXKl0VGHBEbc/GET?= =?us-ascii?Q?9A0/Yf+RrEg3xh+IpR04hL/I?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 191fa47a-41ac-40e2-829b-08d8d4b56d4a X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2021 09:04:56.2326 (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: ZPfIezvB0z2y/VKag7vWE9jwCDQVFxACeK5niqxflr3yuqXKhOUYcEGI9TUWptwa9Vc2HbKe4kWX6bziVv6by8SpDpIWHRprRmnyTHZn3OM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3605 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: Y69LLLUZ7FymSKz95kCTZ3Ajx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1613725502; bh=l2Ivvx2ZmMF4vjryqlUHawIY0CHUd3IhaKw4gua6W6M=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=RwPMnhGVp1sf2OKkiOZbw8zCGU9NXmJw4JRi6EbOTanq8+cXlhIPGZ6oA4sSEVMxWQi VTYV6/LntYgYKDTqBKyKUZ8YjgsrK62d7UtdsvvOca7mlCOJ4e5YNez2BInwkVtfqmL9p lbirzeRI9S8FWpzS4axylanW5syhOm4Zng4= 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 (#71829): https://edk2.groups.io/g/devel/message/71829 Mute This Topic: https://groups.io/mt/80751392/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-