From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by mx.groups.io with SMTP id smtpd.web11.9043.1611643503816550178 for ; Mon, 25 Jan 2021 22:45:03 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=s0iWKGfq; spf=pass (domain: oracle.com, ip: 141.146.126.79, mailfrom: ankur.a.arora@oracle.com) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 10Q6Z9xP058326; Tue, 26 Jan 2021 06:45:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2020-01-29; bh=rEZIou7OuIqHe0dmF1Nzoj9skeKqs1rwnMMR2GxDFXQ=; b=s0iWKGfqiL7g52T1r9o8xcka48x+16u5a1VJ3ckZbUHoTgcpjsKodl6pbAyW+ZisTX+9 0qQ0FJ3xFSdhGrtfBJtthLTqaAGRruUVGeAP60h5OhxLqVPF5pvIP7NxZylPbzOOJWHG jwtUAZ3TVTNEdQjnboH6pFn+aqyye01EVWS5W/+MZFjVQmvktITfzoIfwJycY+aQ9OI2 verqfxuU9mdwuk5r+SeQVwbKmTncI+1BODbaIu7Yi4+jO5az0i5QYo+9mB65h0cARGFn yN5ZsQAOXkb7MpgGgwCP0ND0pLDMNC2H50zLhgtsaeKouOLXHPyQl34Bu0G9kmfdlENk IA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2130.oracle.com with ESMTP id 3689aagu12-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:45:00 +0000 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 10Q6a687097113; Tue, 26 Jan 2021 06:44:59 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3030.oracle.com with ESMTP id 368wqw1qcn-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 26 Jan 2021 06:44:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jhm3+bPLOlHVD4T8v562b2Iaj0BYeaz27UvlV7Ci84r75Z2R9NwKD3SgXS8kYkWKFoxlBJM0FaHHvy6wLak30ZMwEApoUeyTnvXhkluzi1P6gyU9vrulcaE3TNtTEx4we7Xf2aMSxHAn8XzxSwWG7SaUDymA8MrTJZcuAwpQpUIXZrhLydjlCtihx2IHbBiiBaiAvM6yAOg4efu70aNXCXD38F7uelP5tO+b7DHieYo0NwGTxG0Gr+cAqm/vMoXOKF9Rssj/8MO3ZMWW5SMK12ISNMpUgH9lJwP3+khFk/CSmPAUIJLODWWpAir3m54t1tkGR5PZ5cT6FbdKZsFj0A== 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=rEZIou7OuIqHe0dmF1Nzoj9skeKqs1rwnMMR2GxDFXQ=; b=L0vQjVdcuSGSXR3fIlN38Trd5CMkGfoXvxH08K+e9DbryPZnZA2+IJKKzBoH71sPHJMOVjp2RT1/QzOTY54IRHJUtYE+fC6CKuokQj8s0lLIXPNfYl9ttriIDGILACagVkqCM2iwUyXZ6XY/ggl4hAFaPBPqeGbA/RkNqmCVYEladrEarzIK0hHO1KowoZKK+bnv9v6V+dEqU3Cmq+A4qHSUCs+TNmHF0jpJiyLX1qgNTXE8B4iBnfjq61yVf2R/AAY4Ltf0+JiIgCQfMVwg/heCc+VCvWd/btBMjtExFbGyKZ4z/00wgp0VanKJcgxNGv7UZNObC/X/uROksV9NQA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rEZIou7OuIqHe0dmF1Nzoj9skeKqs1rwnMMR2GxDFXQ=; b=BM7hnP+0RjBsg4cCuIEZLzStt2OFyAkokgomWTnZ2/alqI9MIYxZWn6jXRg9ziDewMFo9xYOvHKC6rZhJ8VhgWEFJjWFngeps8D1Qks8fagWtOiZZNRBGoNDSUh4zivjxCVNFD73cZKZgsyZ+x524DNp9bfbRIRsNu7KCuwoDPo= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=oracle.com; Received: from CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) by CY4PR1001MB2184.namprd10.prod.outlook.com (2603:10b6:910:45::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.14; Tue, 26 Jan 2021 06:44:57 +0000 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.3784.019; Tue, 26 Jan 2021 06:44:57 +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: [PATCH v5 6/9] OvmfPkg/SmmCpuFeaturesLib: init CPU ejection state Date: Mon, 25 Jan 2021 22:44:37 -0800 Message-Id: <20210126064440.299596-7-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210126064440.299596-1-ankur.a.arora@oracle.com> References: <20210126064440.299596-1-ankur.a.arora@oracle.com> X-Originating-IP: [70.36.60.91] X-ClientProxiedBy: MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) To CY4PR10MB1718.namprd10.prod.outlook.com (2603:10b6:910:9::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (70.36.60.91) by MWHPR18CA0061.namprd18.prod.outlook.com (2603:10b6:300:39::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Tue, 26 Jan 2021 06:44:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b X-MS-TrafficTypeDiagnostic: CY4PR1001MB2184: 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: BCL:0; X-Microsoft-Antispam-Message-Info: TC1f5VWkZwgyD7++XLvEyDNGhqjNppvQKYdHJpa98VbZxrcwKfvpYFmfr6E0/ofzfQvxmYHj03XuA8z00EVBww/bgkYAUHeiMGjIsNgF2EFwRzLnud/YQIWDlrgQOm8cD4w8enMrQURLG8Sc0zgje503bzk0l0K2OUEyGy89zvxmHpqfSd5CSqXGPxPn9Ttxtd/ZNhN1hNpBZzBmrsg4IZX0LKIdOgNfU3FpmghcxoqLsOkOESY9+MRBhVBCrnUbKajFRPYJG6y9VW0YpncPcHOjcd13MHuWhlim3zFZANJOuLtIHlKmweON59YcAbHh9XmsYzlvsaoug0nb/omJQj8AFqJtXoyb6QHsxtvPYmqfmkWrl5jEUnr8giGqe35TqDtxKAugMaIGLtpko6Hq2+dU4ApwJG74ygy1fWSF8uoXeBKR+FgU8oj+y91uDUD8p+AtA/6HskcR9OzgqEeN1aa1iGOA8AIv29NbnAaICL94isoReXk6YlvU0OU28f9QE1KTpXjswwAPY866i1nDTg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR10MB1718.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(396003)(39860400002)(376002)(346002)(136003)(69590400011)(6916009)(2616005)(4326008)(6512007)(52116002)(956004)(66556008)(6486002)(36756003)(186003)(6506007)(26005)(66476007)(6666004)(478600001)(8676002)(8936002)(966005)(1076003)(2906002)(86362001)(5660300002)(66946007)(103116003)(316002)(54906003)(16526019)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?mUxaPq6IPX7753f2lbSPJ/qPRJGn1L/Qr429xYjKqTo6/zZx9879nnmZ9Glz?= =?us-ascii?Q?Nqq6mZx1vM0FhFea+c3HLlBrcrdjons+l+5eQ5Lc7tu+G0w0cmx7R799LHi8?= =?us-ascii?Q?XnHM9H4bYYfeObw/afnQGjt5Is1uqlslq1zNOXDm1RTCXrSmvJKqWuSe4pOO?= =?us-ascii?Q?a5NBWMz/QzKB4i0MXJGr2Z5lNdvoYmb/fswglf+XtqZLe3w4sFfedRIvDqQO?= =?us-ascii?Q?iT4gmKq/JgtRLkVRPvbTByzNoGoU4t4A7qBvir1NmBAPBencwJQFV7IpZreR?= =?us-ascii?Q?JWvGCy7DeVJeSXxjR26g3dYzNNqnMvBpCWNxqBEsYbWGlfx0bXN7wDdNuido?= =?us-ascii?Q?8aUaU31WaND1ANt9dN1Rm7BUd0taVR/yVdyjs2jtI4VJm5qt2mvmh/kVchV6?= =?us-ascii?Q?59bgY0l520mAu9D4QN9IT+bcIXSF1+AEoDc5Cwh/6JqsFPjciTviX3QiN3QT?= =?us-ascii?Q?vky/kausL3R9toNEbW6MkP75PqqcDnVK0m1DDW3nF0HPCqcba1W6kTwi11mH?= =?us-ascii?Q?V8BUdpT04/EAcH1K7u+tGFojquyZyJsLxMJMMQ9Bwdgk2f9XZhL3Ux0MULXf?= =?us-ascii?Q?VrAi6dzebLTmKHyhPi57Kvqof2wCR14pruLTY36ZwggDiYnTjOlOBbueYIe6?= =?us-ascii?Q?T0zpjhsKa87rCJ25RcWAP68biOmGzRweESumFhaIfMqFDlXU0xrrSckw2R+0?= =?us-ascii?Q?JcwKa9pk3yX1+6M9Xi38G9/L+VnGV7AKab4OU2RwgdFg1RUI+kKI4Iicirp6?= =?us-ascii?Q?kiSImMlEJhSZznMkXmvf8eVgzQgHgYUoFCRxFYip2QUvGV3ltqEDK4BLK4vx?= =?us-ascii?Q?KSb14KLQ/k7ghDsEsR/FVnQT6qBLETuA5SYxHMUJSON21X9GttcoMT298ESJ?= =?us-ascii?Q?kYYaX6GKgeRq9T+zY2UQPkfQtgg2fBSRWfBcKn8iofRV3Fxyypbmx9TolXp8?= =?us-ascii?Q?q49dkbfXf/HF4K3TEDcKWoc2VOlzRs9FbnpkQ71N3NfuwJolWGkKJEeUzk1C?= =?us-ascii?Q?LNCcA+we+EEivalsIig0+4SK61qFWb9UhqThtJO68Nl/v5wUG74N4HTGL8Qp?= =?us-ascii?Q?hikw+fxq?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e365dc-2676-4935-37ec-08d8c1c5e35b X-MS-Exchange-CrossTenant-AuthSource: CY4PR10MB1718.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 06:44:54.1988 (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: g1w6MMBH7QRzSlL5YmMC/B2qk4U2s+bVKu0w8d/GCkrkWBTi6A7r9DkQuqPfWuL+REHvd5+Z0UisweFn/VN6LYpBPbX9J7u82JWfm0KJ1Bg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1001MB2184 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9875 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101260035 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9875 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 adultscore=0 lowpriorityscore=0 mlxlogscore=999 clxscore=1015 phishscore=0 bulkscore=0 spamscore=0 priorityscore=1501 mlxscore=0 suspectscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101260035 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 | 68 ++++++++++++++++++= ++++ 2 files changed, 71 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=0D =0D [Pcd]=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuHotPlugSupport=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber=0D + gUefiOvmfPkgTokenSpaceGuid.PcdCpuHotEjectDataAddress=0D gUefiOvmfPkgTokenSpaceGuid.PcdQ35SmramAtDefaultSmbase=0D diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 7ef7ed98342e..5c9cdc6710e4 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -14,7 +14,9 @@ #include =0D #include =0D #include =0D +#include // AllocatePool()= =0D #include =0D +#include =0D #include =0D #include =0D #include =0D @@ -171,6 +173,60 @@ SmmCpuFeaturesHookReturnFromSmm ( return OriginalInstructionPointer;=0D }=0D =0D +GLOBAL_REMOVE_IF_UNREFERENCED=0D +CPU_HOT_EJECT_DATA *mCpuHotEjectData =3D NULL;=0D +=0D +/**=0D + This function initializes CpuHotEjectData if PcdCpuHotPlugSupport is=0D + enabled and if more than 1 CPU is configured.=0D +=0D + Also sets up the corresponding PcdCpuHotEjectDataAddress.=0D +**/=0D +STATIC=0D +VOID=0D +EFIAPI=0D +SmmCpuFeaturesSmmInitHotEject(=0D + VOID=0D + )=0D +{=0D + UINT32 mMaxNumberOfCpus;=0D + EFI_STATUS Status;=0D +=0D + if (!FeaturePcdGet (PcdCpuHotPlugSupport)) {=0D + return;=0D + }=0D +=0D + // PcdCpuHotPlugSupport =3D> PcdCpuMaxLogicalProcessorNumber=0D + mMaxNumberOfCpus =3D PcdGet32 (PcdCpuMaxLogicalProcessorNumber);=0D +=0D + // No spare CPUs to eject=0D + if (mMaxNumberOfCpus =3D=3D 1) {=0D + return;=0D + }=0D +=0D + mCpuHotEjectData =3D=0D + (CPU_HOT_EJECT_DATA *)AllocatePool (sizeof (*mCpuHotEjectData));=0D + ASSERT (mCpuHotEjectData !=3D NULL);=0D +=0D + //=0D + // Allocate buffer for pointers to array in CPU_HOT_EJECT_DATA.=0D + //=0D + mCpuHotEjectData->Revision =3D CPU_HOT_EJECT_DATA_REVISION_1; // Revis= ion=0D + mCpuHotEjectData->ArrayLength =3D mMaxNumberOfCpus; // Array= Length of APIC ID=0D + mCpuHotEjectData->ApicIdMap =3D // CpuIn= dex -> APIC ID map=0D + (UINT64 *)AllocatePool (sizeof (UINT64) * mCpuHotEjectData->ArrayLengt= h);=0D + mCpuHotEjectData->Handler =3D NULL; // Hot E= ject handler=0D + mCpuHotEjectData->Handler =3D 0; // Reser= ved=0D +=0D + ASSERT (mCpuHotEjectData->ApicIdMap !=3D NULL);=0D +=0D + //=0D + // Expose address of CPU Hot eject Data structure=0D + //=0D + Status =3D PcdSet64S (PcdCpuHotEjectDataAddress, (UINT64)(VOID *)mCpuHot= EjectData);=0D + ASSERT_EFI_ERROR (Status);=0D +}=0D +=0D /**=0D Hook point in normal execution mode that allows the one CPU that was ele= cted=0D as monarch during System Management Mode initialization to perform addit= ional=0D @@ -188,6 +244,9 @@ SmmCpuFeaturesSmmRelocationComplete ( UINTN MapPagesBase;=0D UINTN MapPagesCount;=0D =0D +=0D + SmmCpuFeaturesSmmInitHotEject();=0D +=0D if (!MemEncryptSevIsEnabled ()) {=0D return;=0D }=0D @@ -375,6 +434,15 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex=0D )=0D {=0D + //=0D + // CPU Hot eject not enabled.=0D + //=0D + if (mCpuHotEjectData =3D=3D NULL ||=0D + mCpuHotEjectData->Handler =3D=3D NULL) {=0D + return;=0D + }=0D +=0D + mCpuHotEjectData->Handler(CpuIndex);=0D }=0D =0D /**=0D --=20 2.9.3