From nobody Thu Nov 14 17:05:20 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-