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.web11.31684.1613978384065597426 for ; Sun, 21 Feb 2021 23:19:44 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=Kh+GHImV; 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 11M7FMVo133524; Mon, 22 Feb 2021 07:19:41 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=j5sLrnWcUR41bTrM95Iz2yAXNjCYFkDKXmHyHRZ5diI=; b=Kh+GHImVbvWBOrSCrPnNp+C1X5ceeH3yNz4RgZRQAzvpemFXpxsdt/boRgBbzsI+BVUd RjV+XYu2OaWDeBbjWVcFey4IoMrFZteMYyfl0I6qrnaVh3a9cpWLlNiVh34MrjOBmcM0 XotTzv2XTDUz81HtGi9Ymhwi+gZCcin62e+d335AaJMCo6TJadkokLmciRKpNv4qWdYV TDl3tUeFgwa38rmhxRGWs8Q7WtBsy9ShNBgv9HCiZ5Enb9aJC2+LwQisZwIn04GqZx4r ZCuVOke60Nm6M4MOVjCl9Agp/OmryzLv8hPR1o3LdCcWq9pzfkkm1sJ8oxJzEnG+WO/o 0g== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 36tsuqtktm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:41 +0000 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 11M7EeNc161412; Mon, 22 Feb 2021 07:19:40 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2171.outbound.protection.outlook.com [104.47.59.171]) by aserp3030.oracle.com with ESMTP id 36uc0kwq89-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Feb 2021 07:19:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bdYTtf5Ry7xSgliUkKFuEWTJZKEneg8G2ArxfToKljXij5FVM+cMTAp9V/AW/bJC+TiB0zbvmF96kYn1ffcqlkvhWtHGxmuu2poiNQq370vAFu8gxAFZZkRfLMK3QCAO+u5Fw9PHCFZXzFazKn4rbhA5bgbFkWC4ywb9N/78+1o3+wW3eJ8Y+ZZg3Og5VILKLNVuUMtOh70Q/dwt5r7To/hb2cUnq985McENCdkWWgTLx4UmUWM35mNxvsPMgj+Jp7K03t80J8MLfYij/R+BrlnqRx2Dx3mNLJqZAegFCW0QJMoAp+UM7XZaYd7Wz1hK+9vGjsEjuZAhOKJJWuZQqQ== 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=j5sLrnWcUR41bTrM95Iz2yAXNjCYFkDKXmHyHRZ5diI=; b=S9MfSgoCi9njgIJ+p4t+Lgo7zifOIB4qP715BzOXN+oZrnOJZkDbkYiZRz8XTMhtHBP5gPCtFhmIpdhjnWNHScq/BVec8nR39FgYDV065epkqRzKGgWPAJV+LGMnEQAfpZVtLlEXubw7cLmp7+Fo/ybCRa9eZT4Bt7yEAcRvlPPYe/XRsmox9pTxerpLFHbcgq4LB1oliIKr+cYIxQ4hjSiw+k9NShfqvG9tf3WiO6PY8dIpPjDp9YqsCpk0uJnOp5JaA7z+5SJcDYXEnWo4vG0/93X36nsjuuMhzp0GEK80YtS7COHuKKA/aJ5F4NFn/ldpri0QEADiqDFoUXWuww== 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=j5sLrnWcUR41bTrM95Iz2yAXNjCYFkDKXmHyHRZ5diI=; b=yfrr5DAJQwDdh9GoU+jTEuGBqHETAMwGgH7APVRBX5OcBQuhgRQClpg+wyxnYaR7CQUNW0AOQLIB3AIlXm2847itJJR5VnEOmOIF1Q2x7YQ93DHqLmLVa/NKyjrkwk5tt+y2FNYcM0LXWfq6BY/gqWZtXaJaef5hO6cLUsJKp4c= 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 BYAPR10MB3191.namprd10.prod.outlook.com (2603:10b6:a03:14f::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.29; Mon, 22 Feb 2021 07:19:38 +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.3868.033; Mon, 22 Feb 2021 07:19:38 +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 v8 01/10] OvmfPkg/CpuHotplugSmm: refactor hotplug logic Date: Sun, 21 Feb 2021 23:19:19 -0800 Message-Id: <20210222071928.1401820-2-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210222071928.1401820-1-ankur.a.arora@oracle.com> References: <20210222071928.1401820-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.11] X-ClientProxiedBy: MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) 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.11) by MWHPR17CA0065.namprd17.prod.outlook.com (2603:10b6:300:93::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Mon, 22 Feb 2021 07:19:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 456845d1-22ce-4068-3790-08d8d7023706 X-MS-TrafficTypeDiagnostic: BYAPR10MB3191: 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: lQN2RhuAc6meb7JNl27VpvHQSyoQYFKpRPjex+roBNIGfe8I0qH+rb77J3yzWF9EQJsvcu4sia72usPu+kKmPLMfXkyBRkExH9moYj1juvIGksc0DmSL9HZ+zcoAeWRx+BbQjJW3uEyinAlJY8+EHPoEttxzFKurxHZYoKUYriUGMJSVqaeGXuX5mHgUZbtXM+guVr3dgkkeH9CODGFiUWApyVlONnefz7/g+GQ7n9Rwbr1YO+uSAoeDSyp1/o2C9MIBOwTkwlvYxTj5k9UPkocUeNSxr5DueR0O0ktdGkz28W8g/Wdq5EgKTNN+KYKZoxACAG8dcHsjajIo4AJh/h/pud70mTDirjE/Wt/08mJG4BCZCuV0QwsbUqf2VtPm+3z7YelcqtFixPAsa8ubQDTZKyz44BA4za88CLLR0zyW1j1KEVBYmJU0unYQPKR08szRVgznGuy05N3chEWC4pqBbZRG02Zh+3APvUvqap8RGb1syePvSMhAPHJUu8aeUkGBaRRoejyDpHf4iCOoYaM4EcBliSc8/IE7Yc3u4xUnX2M9ScC7JtGEoQjBnabWVPHeez3IB0guGI7rz1xo2e1Z1VEbp0giTem6KrsX6k8= 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:(39860400002)(136003)(346002)(376002)(396003)(366004)(2906002)(8936002)(54906003)(316002)(83380400001)(478600001)(86362001)(8676002)(6916009)(6486002)(2616005)(186003)(16526019)(956004)(26005)(107886003)(5660300002)(7696005)(52116002)(66946007)(6666004)(66476007)(66556008)(36756003)(1076003)(4326008)(966005)(103116003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?3J3kI7NuM+cVkJv2BJgRu+JzddAetfERD4hrIz5mGRVXbLrefAUueDSBskwr?= =?us-ascii?Q?c0SS4RcqI6BIPoJzRMLPz2cSxj9F7fm09oqmcebT3QUVABj20S9Q7VMeB0Qp?= =?us-ascii?Q?hUhueXMy6QIjaJ9DQo4XwUuLsKaThGhOfcLADpWlnTdnmBkowK6kt9bEUt+e?= =?us-ascii?Q?ZqjWT81MO71HiXIu8BHGXRA9oOY5Bt14am8gQZox4Ym3sZ7SlDQJaY9ACBE7?= =?us-ascii?Q?aqvDw4Sb77lIMzFFawxZhjcpaLJLOVt8uanS8sBy71U/rvl/l3gBioyrmKCW?= =?us-ascii?Q?EPzamqfOP/9rsW5Jd8SvFJ4yxhpLawNww+t70fk0JQjH1Vb1ByanDp7TN5ov?= =?us-ascii?Q?0C7V9hbMNnr5OgnaLwy+2wsXy2xwq4X9KwNTnMTu5TO9EnPyNy8MsBH/SigJ?= =?us-ascii?Q?gjtVnf3jZA+fUonzmoDdj9Cb5yXtPd4gnUpuFpo6dgAkQlq71GmsC7Uuee+V?= =?us-ascii?Q?S3orMdF8m+tEMIdFL9DREeQLzph/J4en84Oqmv7APJSvqMXsToKQ87iMtsMb?= =?us-ascii?Q?sWSIWPq9zxdjrxywm+PRAC7mwBGWC9RjvY1DEsn9Gzy86ZtF95AQCSQu6uGR?= =?us-ascii?Q?cBuOs0UxQom5l8X9NAgLDitLeDdIVjlXnskOU5vA3mJ27SzGXFm/CKw0yPNS?= =?us-ascii?Q?KM7KcldvoDk5wDy+GFkzDK5oCmsALqvJhV2P2LAstbB77ZV/eWBqGKFTceAi?= =?us-ascii?Q?1MqXPP/bTRTknVzKfIj+gYZu5HdjmbL88BqFM0rBY5T39z22hCErwbpMEkrf?= =?us-ascii?Q?rGi1a/rGbRB/u0Z6/Eoh9uzLJz58AxGHShDrM3s8qagFRKdL8cA0WuQT+7GB?= =?us-ascii?Q?GAQqM4DwvKUnmLby7hYRztUXXmGaKHWg/JJLp1+6UtSSQ7hbrBc/f0CGCfAw?= =?us-ascii?Q?QCJKBEr95xjvvAXVqdBD/XRZRUm1R9eBBsKS8jPCrAsFrpY1jn6GdapwxMKp?= =?us-ascii?Q?xc+++a1RNm63+bTARvGlZAeg14RwoiUScur4wAoPD4Bp0UKbCYBpcGAQ/uMT?= =?us-ascii?Q?+MDzLoUmuE8LOIH0GUHvW6/ZV8kI4mcMjfRb4bGRhEYZqOPtL2iLE9h1aezy?= =?us-ascii?Q?/lfpPKI5ZtcT3J9fjEj484ESfLoiaMiiQ4jxe1dDnjmC8gTiy3hMnLnZCFzs?= =?us-ascii?Q?/5bjXhm0oyst6OAPwV6hxZd/v3A/WtOVnscdMieqMX4za4raUcK0xXqX080+?= =?us-ascii?Q?QWCBggiKC5vPhnRuX2WOWkMgA8VwF40mmOe++y54om2Ha63mG+D9a/UgM2Iz?= =?us-ascii?Q?GKz3gzyKMjd7DGE2h4DJX2cD4U/qs5LTviLN4gBqDVvCUdiGJoFsvddjkbmb?= =?us-ascii?Q?vCVIv6wUHBztAgIlDJIx0SiI?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 456845d1-22ce-4068-3790-08d8d7023706 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2021 07:19:38.7987 (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: IfrEdx1+YM5OcwV3aR/+j84D7RO4v6yq/5p61ckWvkYflu1vB+BYlUBnCkA31Vxg7DDh1k+2/qCbynWfMvJppW74cOBWKNMngiCJYDcgLLc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3191 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9902 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 adultscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220064 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9902 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 priorityscore=1501 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 clxscore=1015 phishscore=0 mlxlogscore=999 lowpriorityscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102220064 Content-Transfer-Encoding: 8bit Content-Type: text/plain Refactor CpuHotplugMmi() to pull out the CPU hotplug logic into ProcessHotAddedCpus(). This is in preparation for supporting CPU hot-unplug. 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 Reviewed-by: Laszlo Ersek --- Notes: Addresses these review comments from v6: (1) s/EFI_ERROR(/EFI_ERROR (/ (2) Remove the empty line in the comment block above ProcessHotAddedCpus(). () Nest the EFI_ERROR handling inside the (PluggedCount > 0) clause. OvmfPkg/CpuHotplugSmm/CpuHotplug.c | 210 ++++++++++++++++++++++--------------- 1 file changed, 126 insertions(+), 84 deletions(-) diff --git a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c index cfe698ed2b5e..bf68fcd42914 100644 --- a/OvmfPkg/CpuHotplugSmm/CpuHotplug.c +++ b/OvmfPkg/CpuHotplugSmm/CpuHotplug.c @@ -62,6 +62,129 @@ STATIC UINT32 mPostSmmPenAddress; // STATIC EFI_HANDLE mDispatchHandle; +/** + Process CPUs that have been hot-added, per QemuCpuhpCollectApicIds(). + + For each such CPU, relocate the SMBASE, and report the CPU to PiSmmCpuDxeSmm + via EFI_SMM_CPU_SERVICE_PROTOCOL. If the supposedly hot-added CPU is already + known, skip it silently. + + @param[in] PluggedApicIds The APIC IDs of the CPUs that have been + hot-plugged. + + @param[in] PluggedCount The number of filled-in APIC IDs in + PluggedApicIds. + + @retval EFI_SUCCESS CPUs corresponding to all the APIC IDs are + populated. + + @retval EFI_OUT_OF_RESOURCES Out of APIC ID space in "mCpuHotPlugData". + + @return Error codes propagated from SmbaseRelocate() + and mMmCpuService->AddProcessor(). +**/ +STATIC +EFI_STATUS +ProcessHotAddedCpus ( + IN APIC_ID *PluggedApicIds, + IN UINT32 PluggedCount + ) +{ + EFI_STATUS Status; + UINT32 PluggedIdx; + UINT32 NewSlot; + + // + // The Post-SMM Pen need not be reinstalled multiple times within a single + // root MMI handling. Even reinstalling once per root MMI is only prudence; + // in theory installing the pen in the driver's entry point function should + // suffice. + // + SmbaseReinstallPostSmmPen (mPostSmmPenAddress); + + PluggedIdx = 0; + NewSlot = 0; + while (PluggedIdx < PluggedCount) { + APIC_ID NewApicId; + UINT32 CheckSlot; + UINTN NewProcessorNumberByProtocol; + + NewApicId = PluggedApicIds[PluggedIdx]; + + // + // Check if the supposedly hot-added CPU is already known to us. + // + for (CheckSlot = 0; + CheckSlot < mCpuHotPlugData->ArrayLength; + CheckSlot++) { + if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) { + break; + } + } + if (CheckSlot < mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " + "before; ignoring it\n", __FUNCTION__, NewApicId)); + PluggedIdx++; + continue; + } + + // + // Find the first empty slot in CPU_HOT_PLUG_DATA. + // + while (NewSlot < mCpuHotPlugData->ArrayLength && + mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64) { + NewSlot++; + } + if (NewSlot == mCpuHotPlugData->ArrayLength) { + DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", + __FUNCTION__, NewApicId)); + return EFI_OUT_OF_RESOURCES; + } + + // + // Store the APIC ID of the new processor to the slot. + // + mCpuHotPlugData->ApicId[NewSlot] = NewApicId; + + // + // Relocate the SMBASE of the new CPU. + // + Status = SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], + mPostSmmPenAddress); + if (EFI_ERROR (Status)) { + goto RevokeNewSlot; + } + + // + // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. + // + Status = mMmCpuService->AddProcessor (mMmCpuService, NewApicId, + &NewProcessorNumberByProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", + __FUNCTION__, NewApicId, Status)); + goto RevokeNewSlot; + } + + DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, " + "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, + NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], + (UINT64)NewProcessorNumberByProtocol)); + + NewSlot++; + PluggedIdx++; + } + + // + // We've processed this batch of hot-added CPUs. + // + return EFI_SUCCESS; + +RevokeNewSlot: + mCpuHotPlugData->ApicId[NewSlot] = MAX_UINT64; + + return Status; +} /** CPU Hotplug MMI handler function. @@ -122,8 +245,6 @@ CpuHotplugMmi ( UINT8 ApmControl; UINT32 PluggedCount; UINT32 ToUnplugCount; - UINT32 PluggedIdx; - UINT32 NewSlot; // // Assert that we are entering this function due to our root MMI handler @@ -179,87 +300,11 @@ CpuHotplugMmi ( goto Fatal; } - // - // Process hot-added CPUs. - // - // The Post-SMM Pen need not be reinstalled multiple times within a single - // root MMI handling. Even reinstalling once per root MMI is only prudence; - // in theory installing the pen in the driver's entry point function should - // suffice. - // - SmbaseReinstallPostSmmPen (mPostSmmPenAddress); - - PluggedIdx = 0; - NewSlot = 0; - while (PluggedIdx < PluggedCount) { - APIC_ID NewApicId; - UINT32 CheckSlot; - UINTN NewProcessorNumberByProtocol; - - NewApicId = mPluggedApicIds[PluggedIdx]; - - // - // Check if the supposedly hot-added CPU is already known to us. - // - for (CheckSlot = 0; - CheckSlot < mCpuHotPlugData->ArrayLength; - CheckSlot++) { - if (mCpuHotPlugData->ApicId[CheckSlot] == NewApicId) { - break; - } - } - if (CheckSlot < mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_VERBOSE, "%a: APIC ID " FMT_APIC_ID " was hot-plugged " - "before; ignoring it\n", __FUNCTION__, NewApicId)); - PluggedIdx++; - continue; - } - - // - // Find the first empty slot in CPU_HOT_PLUG_DATA. - // - while (NewSlot < mCpuHotPlugData->ArrayLength && - mCpuHotPlugData->ApicId[NewSlot] != MAX_UINT64) { - NewSlot++; - } - if (NewSlot == mCpuHotPlugData->ArrayLength) { - DEBUG ((DEBUG_ERROR, "%a: no room for APIC ID " FMT_APIC_ID "\n", - __FUNCTION__, NewApicId)); + if (PluggedCount > 0) { + Status = ProcessHotAddedCpus (mPluggedApicIds, PluggedCount); + if (EFI_ERROR (Status)) { goto Fatal; } - - // - // Store the APIC ID of the new processor to the slot. - // - mCpuHotPlugData->ApicId[NewSlot] = NewApicId; - - // - // Relocate the SMBASE of the new CPU. - // - Status = SmbaseRelocate (NewApicId, mCpuHotPlugData->SmBase[NewSlot], - mPostSmmPenAddress); - if (EFI_ERROR (Status)) { - goto RevokeNewSlot; - } - - // - // Add the new CPU with EFI_SMM_CPU_SERVICE_PROTOCOL. - // - Status = mMmCpuService->AddProcessor (mMmCpuService, NewApicId, - &NewProcessorNumberByProtocol); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "%a: AddProcessor(" FMT_APIC_ID "): %r\n", - __FUNCTION__, NewApicId, Status)); - goto RevokeNewSlot; - } - - DEBUG ((DEBUG_INFO, "%a: hot-added APIC ID " FMT_APIC_ID ", SMBASE 0x%Lx, " - "EFI_SMM_CPU_SERVICE_PROTOCOL assigned number %Lu\n", __FUNCTION__, - NewApicId, (UINT64)mCpuHotPlugData->SmBase[NewSlot], - (UINT64)NewProcessorNumberByProtocol)); - - NewSlot++; - PluggedIdx++; } // @@ -267,9 +312,6 @@ CpuHotplugMmi ( // return EFI_SUCCESS; -RevokeNewSlot: - mCpuHotPlugData->ApicId[NewSlot] = MAX_UINT64; - Fatal: ASSERT (FALSE); CpuDeadLoop (); -- 2.9.3