From nobody Thu Nov 14 23:00:46 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+72709+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+72709+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 1615530445706708.5760774680898; Thu, 11 Mar 2021 22:27:25 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6bo3YY1788612xcZyNiAYHU0; Thu, 11 Mar 2021 22:27:25 -0800 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web10.4849.1615530439754786011 for ; Thu, 11 Mar 2021 22:27:19 -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 12C6A64s178494; Fri, 12 Mar 2021 06:27:16 GMT X-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 37415rgyen-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:16 +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 12C6P9bs055196; Fri, 12 Mar 2021 06:27:16 GMT X-Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2109.outbound.protection.outlook.com [104.47.55.109]) by userp3020.oracle.com with ESMTP id 374kgw3bs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 12 Mar 2021 06:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WI8IVw0eT5qaZjS9E7kLura7Bwhc6V0VoFBDh+ULxBgFbnlC6jLSHye+NmebwiYnXgOPb4rBx6Tw5JWEiyRooh4CgYjkFImsjndzUt1WETXal2WoMtyYQu8QNpI+POnEidUavhkRUosHUl5MopR0CL55pRaBKE2vPGmWJSza1PZrqa0B5ijEH1ORBdNX5sv1BZgRe6zQRWpz4dV+GkVNfcxNfLzKovbVEbvlZC3EiGkgZnxK7+f/tQIP7xmu6Lb1zGGXaec0zJ8HUoHlXU8tfGXGlVWFoYCTaWtNI7tiB1PhV9EwvpIckwGjGoXehcuI4Wv2xiigQGMr4bl5smpJYw== 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=3OWrUIIbd1oenoDL+1GkDyLmB2u83RTuk/kTz8vCYRs=; b=HOIq1wyi4T0Jccm2ToSjfRTe5Pr1eip6D8REAuzQXDeXpLbjveJJOA4mFbGCdmP9kkkLvf4fD+zDhydPG9TGk4L7pxw1Qf+spRz8JQYpLUgXH5E2jI3FhnL5/AfohVkgKL2qyt26yZT91O4mPsJrBMLuxRo7UutP6Nz6YictvcmFTE0sqE+a47xp+r6qqa70HnbVNhnIyc6Nffs0tOtdOJA66wqQOPVSA/5SI2R06jzIS7TiAUkpI+oiFzP8BpljNO8Iybau4cEreG78hV1s35EwKDOO3d8JlIv0UMTawi4/u6YIvrfF9rVLZQTg/HzYMHR2Pt2gON7OzAn+q4bjHw== 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 SJ0PR10MB4544.namprd10.prod.outlook.com (2603:10b6:a03:2ad::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3933.31; Fri, 12 Mar 2021 06:27:14 +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.3912.030; Fri, 12 Mar 2021 06:27:14 +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 v9 07/10] OvmfPkg/SmmCpuFeaturesLib: call CPU hot-eject handler Date: Thu, 11 Mar 2021 22:26:53 -0800 Message-Id: <20210312062656.2477515-8-ankur.a.arora@oracle.com> In-Reply-To: <20210312062656.2477515-1-ankur.a.arora@oracle.com> References: <20210312062656.2477515-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.12] X-ClientProxiedBy: MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) 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.12) by MWHPR02CA0018.namprd02.prod.outlook.com (2603:10b6:300:4b::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Fri, 12 Mar 2021 06:27:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 94b01732-fee4-47e4-59e3-08d8e51fe00d X-MS-TrafficTypeDiagnostic: SJ0PR10MB4544: 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: 2BYYmgBXf9VrHJlULpfvMgLJG9Kev9I/r+VSNLpEcedkAOOrwyLcChhb+uA967Hius/iRA4Ark4hcOsorc/T7coocc2+lpi2pOqkSUH5v/Y+W7wZwsFmnOqThvrUw3bSWX3GLUp3uGQzLEJ/0f8gxH/xkl/d6x4DQWzEa8TaxmsMjtmMpwAPPT6YEfdZm6b5pSbVexOjTnLuDmMl//vEOGF1ksItrffafSkStXlSzoL1AE5jn5jIjwTnC8xrbswTk8NFbv9XYc+dDqBO+JTQy/Tl8NNEJynlsamEJFGtFMFppvXBLVlwx5SAn3Ztae7DwasXVdVQip71+oV8tqNtKFEXJXNGPeOFh2LSJJsZKZFkMT587D0mdu4YWQpB+XFRJU4PD35vQt7DJ6x+rAYLn/9WF6SXVC/EvMNL+qjMHNjZyiSSXOhbwYEzNH8j5PXGnv4NKIAd3UE1QgQzug7ffv5myKn6z3PDvR2e6tjfoOeEGvP4dbq+H3sRB162vHf6mikeDJOqalNQjCgqzkp/HefOhX9KG0Gzp1iEp8TYchig08Bv99UGAi71qjDK0k5lzv4MqmsYHJTX/gmFf91BKOlGV4ABEUu7mKlIy/T48K0ksYZWerqI6o0tW9mEAdvF1ojf6SsmthlZoCA1LJdhnw== X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?BOTc14FsleBqE/qZmku48El6f/awz2NHEkP2hXzLpvYm1ZXBHVkXIzQC/mTb?= =?us-ascii?Q?FXOL8CY8mpjv84SrIgCk075lYpGHk4e8BboGJ6NKm2/OwqPXiStGr/6JgpYW?= =?us-ascii?Q?VzBjUSo3JjfCA70RbFnYOwJvpLdqQ8d0owZtkgtD2BBuP+1emof7mIuQ6IRh?= =?us-ascii?Q?UMN3QAp6MYAU1PjXiQLKV/Kbgcz86u4RMgFbY/jlN+w1oYxb0u763+SM+EZn?= =?us-ascii?Q?JfUoPsZ2pmn4qRMOHPONebGwVQJFgKTewHxj1IYql1WH9DO52gOcr2pulJ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Oyhw3LZdrIKuYrkNq30U8qJ889i2IDejg3HHB?= =?us-ascii?Q?joDcXJHL1oXLYeSo//W1ginRim8xMbv3wL6Rs26bGJCkxU3h3squ/Fc2m8LC?= =?us-ascii?Q?y0it6xDSehoUhPwF+SuOKrt6e9nxc5+AqBBMMYmiNYu0fVvrIRDVKiDhHRmH?= =?us-ascii?Q?W0M+qN3X8jSy/tS3onS/YRUB?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 94b01732-fee4-47e4-59e3-08d8e51fe00d X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Mar 2021 06:27:14.0216 (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: FWeP0RW8gGmFWcRlJwOLWRgD6f/RwTJxBizAZI30RMBI2Y08UEBViANgthmJoOgUIk6J+IRUTr4FbcZJBs9axVQ9xXMaGEhKc5b3DjgiZ6k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4544 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: nONGu6cVtFEMVK3SgLgaGeYMx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1615530445; bh=mUECUoiEzvvDvmXCKsUF9JV15M43Mt6w8D9kxr+Y4rc=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=FhwywfHscZJ7YPBefiSxFwMnvqbGlHR9B1mUsKiXjwM5ozo9AZyoUEYKNjowLIaYS8o TAQdmX2lmhHY3EXOWMQLz/Ajbi/sdYXGTN1Iu+Edv9sOi65CV+Q3zIyg3GuquQC4898yz k6PcloIAAF8UbXBCYEBcWZDbQgAYlAPBx4o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Call the CPU hot-eject handler if one is installed. The condition for installation is (PcdCpuMaxLogicalProcessorNumber > 1), and there's a hot-unplug request. The handler is called from SmmCpuFeaturesRendezvousExit(), which is in-turn called at the tail-end of SmiRendezvous() after the BSP has signalled an SMI exit via the "AllCpusInSync" loop. 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: Addresses the following comments from v8: =20 (1) Add a MemoryFence() before accessing mCpuHotEjctData->Handler (and comment to that effect.) .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 34 ++++++++++++++++++= ++++ 1 file changed, 34 insertions(+) diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c b/OvmfPk= g/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c index 5c025bc717c3..fdf2380974fa 100644 --- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c +++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c @@ -452,6 +452,40 @@ SmmCpuFeaturesRendezvousExit ( IN UINTN CpuIndex ) { + // + // We only call the Handler if CPU hot-eject is enabled + // (PcdCpuMaxLogicalProcessorNumber > 1), and hot-eject is needed + // in this SMI exit (otherwise mCpuHotEjectData->Handler is not armed.) + // + + if (mCpuHotEjectData !=3D NULL) { + CPU_HOT_EJECT_HANDLER Handler; + + // + // As the comment above mentions, mCpuHotEjectData->Handler might be + // written to on the BSP as part of handling of the CPU-ejection. + // + // We know that any initial assignment to mCpuHotEjectData->Handler + // (on the BSP, in the CpuHotplugMmi() context) is ordered-before the + // load below, since it is guaranteed to happen before the + // control-dependency of the BSP's SMI exit signal -- by way of a store + // to AllCpusInSync (on the BSP, in BspHandler()) and the corresponding + // AllCpusInSync loop (on the APs, in SmiRendezvous()) which depends on + // that store. + // + // This guarantees that these pieces of code can never execute + // simultaneously. In addition, we ensure that the following load is + // ordered-after the AllCpusInSync loop by using a MemoryFence() with + // acquire semantics. + // + MemoryFence(); + + Handler =3D mCpuHotEjectData->Handler; + + if (Handler !=3D NULL) { + 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 (#72709): https://edk2.groups.io/g/devel/message/72709 Mute This Topic: https://groups.io/mt/81273609/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-