From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.69]) by mx.groups.io with SMTP id smtpd.web12.19872.1602864655299232052 for ; Fri, 16 Oct 2020 09:10:55 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=Lx7Xy//w; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.243.69, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jn4n0emovLrfmfZo7c1D5+jka5jVeUBf1ceVM7DvM898Y4xvBwpkU7z1jlhchAMbqbBV+U0VKJlfMIOYkXBnnEClkvedUQtIpIVwRjugfWZrgd2G4nOxLWkaTx8+9RMd2k5wO2nb1G7fdxcSj8EuICQZUvb/MvyaetbLtsdsnTMNjyRRHq7E72t1NzzArXk4Fmn6xHnNfn2MH1FAEtbxhcQHVuso5q7Aj6nfDtPjmp3Ubxi1ps9llhZEj2dux5FHD83nFigYImfU2tzjbqTNQOfnC4bHgMIpLslsoXDXSm7QWAaVoSZwwFM7iBv4yA76e/AGjSCq4cpXR0fOrxUSDg== 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=k333heJYsxK7ONXXuDLLjGtrxCXCKcOHHUNuhjCg3xI=; b=NZmbG51CY/WePBHZjDFR7B4WvL+LWU8NYWgqrNGOkkgeDQLKFKwJi0ZQPKsrTab2+Hq6y3mrJNXVNeAvsbNULaw9bCCtYHB+XhDRcJhhDMv/lJTpF7OROBX+6T1/eow5N6GKz45E4sA+vlTQy+i6BambewwJ+nSO0T7hS4Cgmo1mgQWbV3Q5iFg1FKO9j4FKWhMlsVv5pNkqnJY0OUmc43VJfCGpa6nHaY3B68wNtHZy90pdOcDOA6vA0VYm7GcLEdVEroyELZy7r3VTw/fnWdFmyCfWSKliU0z5A/aDThzPhRKBkql246ur4M5KcifVc1HkWTwvlV8A6Z6JSbPMcg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k333heJYsxK7ONXXuDLLjGtrxCXCKcOHHUNuhjCg3xI=; b=Lx7Xy//wwdEq8SNifwFnaY+dl79mkd1sBI+AC101cA07stl1x+b7nPXkgMv5mfWFofPYg9mLPViCehO6CvTEL7eU1FlJTj7ByxaUARrw6b85y76CVCZJY/4xhfkwjL56xquc4MZLCJTOpqdQgMD3XOg4ATYE9MU6rc0YWXZEyHk= Authentication-Results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=amd.com; Received: from DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) by DM6PR12MB3082.namprd12.prod.outlook.com (2603:10b6:5:11b::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.27; Fri, 16 Oct 2020 16:10:54 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::4d88:9239:2419:7348%2]) with mapi id 15.20.3455.030; Fri, 16 Oct 2020 16:10:54 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v2 11/11] UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number Date: Fri, 16 Oct 2020 11:09:17 -0500 Message-ID: <3a53fda34f0c765e1f28ba26ac2cb6fa1db29345.1602864557.git.thomas.lendacky@amd.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: SN1PR12CA0098.namprd12.prod.outlook.com (2603:10b6:802:21::33) To DM5PR12MB1355.namprd12.prod.outlook.com (2603:10b6:3:6e::7) Return-Path: thomas.lendacky@amd.com MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by SN1PR12CA0098.namprd12.prod.outlook.com (2603:10b6:802:21::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3477.21 via Frontend Transport; Fri, 16 Oct 2020 16:10:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 04579c69-86c7-4586-6de7-08d871ee0eea X-MS-TrafficTypeDiagnostic: DM6PR12MB3082: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2449; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rxEqiHnKOdksNN37k7LJFATmmZJx9McyLuBY6qfJqzPMNLeAtGuHnFj+KLBG8IVkXJebf3lw0SU0fURBU5iyXRpdBxW2FhZ3o3G1Xv+jiP6DBQmxRfAYmXsQffI92FQb2RSgFOpZdng85V6Nmk1yg7mnBHqJV0dY8Sk4RoaAiJbrLaU7LpIHQxGXzjenjjbu8sWvr+glR0blaH5O1z2lTymLLnEfkUh3mFMO/i5kuxgro8GZDtbmn/WcS3M27ni5UzqqpT0Ua5vp7C91GX/g5im3ECkha3VAP+7Y3xuArAazom7mYLwR8A8wFVhGI92+PTRGqx5DP2x76t75ef/F6sIzV2cpQtpLlg6M64lC4s+8/okrjpTULob3te1Ua1XYNYsg0PniHq/M/f0Py4mIgIeH5p9B0R/aIb2uCp23ayAthmp4TDanj/MIWLz0C4hUxVrVTQpYEDo35l5JDWSrhA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM5PR12MB1355.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(6029001)(4636009)(376002)(366004)(136003)(396003)(346002)(39860400002)(8936002)(8676002)(26005)(5660300002)(478600001)(6486002)(6666004)(36756003)(83380400001)(52116002)(6916009)(7696005)(2906002)(19627235002)(86362001)(16526019)(316002)(66556008)(66946007)(966005)(2616005)(956004)(4326008)(34490700002)(186003)(54906003)(66476007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: zCQMTdjSK31rv+o2fw5GMZgx7RHRNSf2cLApWEbrY7Oazy+5hhcOKgsxyCZPxYTKWp6Gtd5DLWQLzxu75TUn2QeFMIBu/oBtme12ra9vRKQk3wxhx8aMzRBYIcAJmYBOtpBqKEytuuF54qgZTe9psu0FTQMyJjEChewlR3nTMqvPEkGPH6vy/8Ve6v+VjyFIoFgmjGwnFzhmVL5FbhZaa4IttMsIBq81nCu4Yiyllo20RpkAb1RjmG+dNacN9ps38NReCcZMVhelBmI7/whoCy/3sojPIla5xC+vTd9dW7q1j+qTamQFfZbHgTACJClA7fSPZIsoy33HL19lWtzSXy9BZLpOAivMuptmLMyMIb98ii4eK4MWoP8hbxLzALh8Z7cu6Xlj9wjcinC24ZYZN0/twQX2HKQfADIh2MRpWMNkfkx5FbC4//+cPmJ4FY101uwqhkK8b8kg+D6IVovKdmPzv9mdOXnrqKY3IGz1kKRf4EKB/rycL7PFvRHwhrRDLKt/IXrpRCmeqPzDYUgST7ry+GF+I6+D89P9VT2x8/Dg46iWYiS06MMGxgoGkh7TsI7ZmvEEOKq+K7Jqtpx26mfg6bZV8VvEZ91AYmAXnyLhE/esdINPkRcT5GeNBrywb0JwgYx91ht7NQlWFhbzEQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04579c69-86c7-4586-6de7-08d871ee0eea X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2020 16:10:54.1783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KbqqHxP9lQetoHMxWvuFaUjSK2Z5q1bH6wsHsM15iS/Sm1wYP2epvc1MJYhVbmLjwmdRVLyDie9p03luNpqAeg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3082 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3008 Set the SEV-ES reset stack address for an AP based on the processor number instead of the APIC ID in case the APIC IDs are not zero-based and densely packed/enumerated. This will ensure an AP reset stack address does not get set outside of the AP reset stack memory allocation. Cc: Eric Dong Cc: Ray Ni Cc: Laszlo Ersek Cc: Rahul Kumar Acked-by: Ray Ni Signed-off-by: Tom Lendacky --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 4f4b26a7c196..c9bb1d25c616 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -680,11 +680,16 @@ MpInitLibSevEsAPReset ( IN CPU_MP_DATA *CpuMpData ) { + EFI_STATUS Status; + UINTN ProcessorNumber; UINT16 Code16, Code32; AP_RESET *APResetFn; UINTN BufferStart; UINTN StackStart; =20 + Status =3D GetProcessorNumber (CpuMpData, &ProcessorNumber); + ASSERT_EFI_ERROR (Status); + Code16 =3D GetProtectedMode16CS (); Code32 =3D GetProtectedMode32CS (); =20 @@ -696,7 +701,7 @@ MpInitLibSevEsAPReset ( =20 BufferStart =3D CpuMpData->MpCpuExchangeInfo->BufferStart; StackStart =3D CpuMpData->SevEsAPResetStackStart - - (AP_RESET_STACK_SIZE * GetApicId ()); + (AP_RESET_STACK_SIZE * ProcessorNumber); =20 // // This call never returns. --=20 2.28.0