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.web10.6072.1613725501728380005 for ; Fri, 19 Feb 2021 01:05:01 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=mYtmU2fc; 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 11J94w9P192847; Fri, 19 Feb 2021 09:04:58 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=mYtmU2fck9AVv0mR7x90AMZ3OLi9EKFHWWbsGwTdAlLi/PrTKo/6yNhJ1b+EK65aHmdI v/CwzqHumfZEutVG/QIS6E6RdKj7XZX6A4EkMXuW64C+Z70W9qBLbcgmICEqZJBIuSdS 3zCRi3/XHHdNg5iDYUllJTdFyQfJEWCo5p3iWIrBBLEubggjhraPHipQ7WkLKE+kaofw dcwF5F0RcOGDeTKfYUK3ErXPAUQgBshZa/7NAMHHmAMZSCoANDVdcBNspzj8P3eTnFt5 EHDsHOajWfX2x8TdglxlXW021MV99uTldq3w7b9SmQtFqFA/RfXFUApeTvKPluZgl/2y hQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2130.oracle.com with ESMTP id 36p49bgvyx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:04:57 +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 11J8tl0q182210; Fri, 19 Feb 2021 09:04:57 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3020.oracle.com with ESMTP id 36prhve0ju-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 19 Feb 2021 09:04:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=heQaPlG0kqlW8fZdHLZgXaB7kzAVXSNNylToCRfN1+jk+Id35i4wjgYSUG6vxu79xaM7h/DSpr9erQirtK5MOcl273hNNi0LSBxWY81IAAGfcwwjrtIodGBJvoTqdwORNTOJAsqeAbM2kVPqtmcyrsl1w1QZnxLYo0UW5Yv/Mi4Em1Kple1yNNWrM4K3TqEjdqzp+LrWEysdAoNJXSKNG3B6ZMUDlP43lpdjbeIjGwauXTsxWTT8KU6xypUpD5UtCANw/Yr46zO3RvumL2n+tLsASdwNIDcLMkTxSC/hpvf/PAit+FUZqGcz3xn7QRo+IzlSmAuQOCSAu6Zicq/D7Q== 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=kFDy7L7EBUz+DRbzrzkMl+jaSnfmaN8G1hMj48P+32sKK6KDpx/xzRwSU1IK2ydXBHj6uDOUsXgduO4geinSGosWjqFUwhKgwxzxQgRAVf1k519bj5/Uq7bD52yobXWrJaLjtkMz2qHwAqLQIbfIg74ugowmta2q6Icn/wd/gy8KPM447P7fZoBN9N4D370bWsNGBdsmUVhUtedl1+V2SvqwQHaJfGVopDI0iZx+L091/lEAaVX1T+qDhoS/1iE2LwCiT5xxSOFNIgPc8iMGy98VIOerJR+ze9+og1Ac3yBNAAXFrtljss7o6h6G5iSX3BJw+rG5PGM/nebWFqkYmQ== 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=RYwAo7XB2bjIfTv6G/ocTGCj1Y8uZ1Q7BEgYxJR6y9dGa2FL8k259MCD6PHiTRPd0Burszl9f5oCWG1Gx7b7aPeATI4YANg9O5MNDOce0U1533VU2Q/nY/X7XGmLm1xj9bhamx82D5aah1mVKQiRYeBwwNwWGTU2I6Q3QLeUKt8= 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 BYAPR10MB3605.namprd10.prod.outlook.com (2603:10b6:a03:129::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.27; Fri, 19 Feb 2021 09:04:55 +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.029; Fri, 19 Feb 2021 09:04:55 +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 v7 01/10] OvmfPkg/CpuHotplugSmm: refactor hotplug logic Date: Fri, 19 Feb 2021 01:04:35 -0800 Message-Id: <20210219090444.1332380-2-ankur.a.arora@oracle.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210219090444.1332380-1-ankur.a.arora@oracle.com> References: <20210219090444.1332380-1-ankur.a.arora@oracle.com> X-Originating-IP: [148.87.23.5] X-ClientProxiedBy: MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) 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.5) by MWHPR13CA0004.namprd13.prod.outlook.com (2603:10b6:300:16::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.8 via Frontend Transport; Fri, 19 Feb 2021 09:04:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6c2bc89d-f761-4aec-c663-08d8d4b56c91 X-MS-TrafficTypeDiagnostic: BYAPR10MB3605: 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: vVzQHnj4q/E8qViDpwAUZ++cfEO70GhZWsoQWsj8lwmAp4C2KsEocmTi5pIFSUlLGUKf84n88c83RGmJEP3c2dOlivS+ty8mpCHFLJRBPL7bLrB5PV3mCqijRzsAMGFdW6FV2iRrEXhFoEgHSwY5jACPsvIR2QdLguHP5MNoCRbnd8WgMVl7xPXUEkTHS4Qp5orlPyE4N4Lx++P+8iRaX7jiHOsv7Kc83JWJKVLlvsVxXAZK5pAmEY60DWqyITnvS20ytErD8Ukt7LvthV/0RKdO+dtcI5uSURndU1EZxR0NTNWur/ZaRe7No6M7mHKHcniFU88uIYCeSLgB4wfqaUzpsYrghHe2Y1HL7bbrbRPYizLxvfvhhn1kaj6jOIJ9lg2Au/1mTAit7rDI0IrHhUg061xc/eK/IYaCp897tGO1jt8DIbdmvP7Qc/tNicAERDp4N/H7YTzx4JkXXNo1sbedqMkqqvnlsuOvwqTY+NJRvjZlHTJ/QBdXGJVFLoh33TTD0VEpHCT4iBwMK6rR/T6atlI+GuYqrJE7uXuFD0afDfu6Tai+442WwtWRQ7MdNpoDP2NBhnD1QtHbhuumfnP1KHYDaoUb6VL1i9Dmu48= 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:(366004)(376002)(39860400002)(346002)(396003)(136003)(83380400001)(7696005)(66946007)(2616005)(66556008)(6486002)(36756003)(86362001)(316002)(6666004)(54906003)(966005)(8676002)(66476007)(52116002)(478600001)(956004)(4326008)(5660300002)(6916009)(8936002)(2906002)(107886003)(1076003)(186003)(103116003)(26005)(16526019);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?qq0Oovt+HhCWPIaugAgWmiKKC1hEUPhGHBU8SaOpuby/xZxkodUtUVkxTqNZ?= =?us-ascii?Q?faHcC43YMdDwXeZyafDESlwFpOUEW7M2CPwbIdREUNxaL6WNMmxGrlQOx3sQ?= =?us-ascii?Q?wJK2buLcJht8TimczmYpF/o/C/nz0f00w8OIWGGSPZnKzB4LEV/+LRGGY2si?= =?us-ascii?Q?iQvelO0985BP5EGipGQ7bSRjxBbi0/w5Tr4HPEzamPktLEpWHdCJWryzA62D?= =?us-ascii?Q?8ZAIRkOMw1DLe1zbiPvW7NTpXvepV3FXiEn8Nfr+9ndb6Jdgjm7fGtfry7SK?= =?us-ascii?Q?TYnvWtQUt8xK/zTByyrvJRGr5psBcdz5czJleESif9ZeKNYs/92WQnqa0OB2?= =?us-ascii?Q?nSVM4xcHengyhl4oRw500M4DEfXtuOGazkpX1kLA7sn8QBAexBj/+CET+7rf?= =?us-ascii?Q?5Da3q22CyzoF5IsXNDiQLMQc0dwcTOXhed5hm7nXtrLXZS5huWtmInEhIeUw?= =?us-ascii?Q?0a2GQDfOhke2z/0QbF5K8jj+U7ESn01G/1VmvFmP+iUnO8HRGCvmsgCi5zCt?= =?us-ascii?Q?aLCLVRl+5actBrT/oWNMRKBdZsIVaP4Gahxnneu6XzoIY600nylkyiOKwL2n?= =?us-ascii?Q?n/8VQ6FFv9FP0krm9kVELUD+74fGtv2+LdkrbNnX9ynr6m5pvvn+HvDrgl6q?= =?us-ascii?Q?uJ9X9fNCIKk3CPMgEVPXo/Hn/Ys2HEc/tXHweJvUhvUqmp1jL0TtaCEVCbw1?= =?us-ascii?Q?tQjLGNx+M5kVmEBoJ9qjOA3J3lJxVpsxZUk1WLJeGHgZwy3gXGzSqGwEG9k9?= =?us-ascii?Q?2QLSJutJplLx864bJs4ZviIEBDxiUKZqeZFHe0DNnpj5hidqObOcs6QFZ1pF?= =?us-ascii?Q?p0ejJrC6HPU9wLFVail0+M7zIFEG3sJZai1SFsqrCORjEqNUGVqQclVisjU7?= =?us-ascii?Q?rFVEa+JNmwZb/tAR+GGcEbEyD7clNk245qxjaSmFGVXfjRuTq/yjl/d7iLT3?= =?us-ascii?Q?Nx1mGz9pRRAuKlD6DD0ECn2fAhBq2QN73bCntZ2QUXN7KnIwlGsksLIvyYmq?= =?us-ascii?Q?HnEzGvojRTbl5YA4mabQ4IMjiIbjaKP4mWIFRM6XYsKsKQoUewiJHFSFHnPk?= =?us-ascii?Q?ipQ5JGiQ6T/YItZiUYjFiOkUQhO9DK4Gc7HYUQEAdUXv+yg2M5KV6LpvUe2h?= =?us-ascii?Q?u9QAfr7XFgBax/kIaz3i3m1BgUYjkh/DLkckpVbuXKiHLZY3QZTu0h7tuh42?= =?us-ascii?Q?SENJ0kMd+EuLimjRgBmlixuoXHRWVXt8JFBtykLNx1qJsu4IfBFz8PHjPQFK?= =?us-ascii?Q?uueZ5S9Fig+6P0VDlMOcu0urNoPNQ5m3/Vn6+XvJM1kS7L8N2G2dmyw40w9y?= =?us-ascii?Q?OnMlSJaXyzVVLPD1XJslzx9u?= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c2bc89d-f761-4aec-c663-08d8d4b56c91 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB4605.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2021 09:04:55.0518 (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: uncPAut0d2NDZac5CH3oAYaoHkNowYbx5o9yMzF86/N8DPAasocyaNdOzPX4FZdFBsXrfgWdNBtqQqs0OEM7Hywx7HPxOyThnIBRt1Ke3ik= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3605 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9899 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 bulkscore=0 suspectscore=0 malwarescore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190070 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9899 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 bulkscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 phishscore=0 clxscore=1015 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102190071 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