From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=r3kxJ2KW; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: ankur.a.arora@oracle.com) 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 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=3OWrUIIbd1oenoDL+1GkDyLmB2u83RTuk/kTz8vCYRs=; b=r3kxJ2KWjcUlasVSAWKvJRP6uyCejpjcLp2X6yX7QivApZz7q5WZYm5WcmPxMtCHLUsG UK8cpIlwMTdQDD4RCtECN15y1B1oPRA4cUawEwmxEr/lztKN0JmzCMadSjSIyjLgvNk0 SXsx3mNWvLGHjCMAC6kHB2bH3ENms9XRZ01dPjKMUQBtP3jWTiIzzmTcuSrQroTcio9g VVTiahTQ9kb2BguE3sg7rPHtYovXin+3YRsV4gURYYmd6MRhj8cC79tyC30/kuwCVv5y AuJHKEuKWJdiQMEsJL/uwHvuyFzad5lw7XiZlOHRG6+l3RgtihVD78cmdMOEA2zjoBht VA== 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 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 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 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=3OWrUIIbd1oenoDL+1GkDyLmB2u83RTuk/kTz8vCYRs=; b=piUnWA43pe2bxf3Z1azne1Mx7PQnCYQbUi/QkWnjCuVNT3ASkDy0xOV3nRZEGz92HSRmy3eVKd+HkLbfHAlcc0+Jr+obU5qvn3TpArtdDModUAo4/Ul8F7icoF7tYDiA8MRXACfbTb+/k5OuryNSFdl5xmZorbzZ3+PQI/NJYeg= 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 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 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: [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> X-Mailer: git-send-email 2.29.2 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 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: BCL:0; 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-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR10MB4605.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(39860400002)(136003)(346002)(376002)(956004)(83380400001)(1076003)(26005)(2616005)(6666004)(107886003)(6486002)(6916009)(66946007)(7696005)(4326008)(5660300002)(103116003)(66476007)(86362001)(36756003)(8676002)(66556008)(316002)(2906002)(478600001)(966005)(54906003)(16526019)(8936002)(52116002)(186003);DIR:OUT;SFP:1101; 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?JfUoPsZ2pmn4qRMOHPONebGwVQJFgKTewHxj1IYql1WH9DO52gOcr2pulJR0?= =?us-ascii?Q?kAJbu/H2APFWXe6O2rCI/O4ixcXFLleU7jil4m6wEsl7O5JKMMSYb5joE8O3?= =?us-ascii?Q?GYeUm93xgdsL6dlnM+fr+rAMNxfQXV+Cxz0Je99RFeZB+wPyS3xLStB3jWNA?= =?us-ascii?Q?GO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u0fVvrIRDVKiDhHRmH?= =?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 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9920 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 adultscore=0 malwarescore=0 bulkscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120044 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9920 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 lowpriorityscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 adultscore=0 phishscore=0 spamscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2103120043 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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=3132 Signed-off-by: Ankur Arora --- Notes: Addresses the following comments from v8: (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/OvmfPkg/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 != 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 = mCpuHotEjectData->Handler; + + if (Handler != NULL) { + Handler (CpuIndex); + } + } } /** -- 2.9.3