From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.72]) by mx.groups.io with SMTP id smtpd.web09.614.1604685310457901336 for ; Fri, 06 Nov 2020 09:55:10 -0800 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=jQKCM7R7; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.93.72, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T5IM0Fmk6LtfD6k+7+1mfgExqb127f3Gh9Oi9RK4JaRl7ZBwPTO8P1FyVLMlhjkhuVmO/bgvRNt0Iu84rieu3sElTSlv3NommoKiTj1e6ehUXABY1vRqZP/HfEfRiOIwHjnvq061fxzAQqBuLDB/GDnCDh24KDbLM3iyAC5DZWJZOpqReRC5u7wX/E/A/DjKz00WXsHgGFFZcC2Pr8uPBU6JMnDQKdCx9V50puWMforrQlLNCRtv1ZKCcLckL5Uo5dNIHtfz3Hm1vdWm6MJJ9+jiIXYw5FmOXKisT6eLsRbq8Z7iOZ0jiZP/X2CEbiUXdSYJG+lQi7xNDSG+7RGCvw== 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=YizIqpGSk6OdeqMrTc1SwpHMZJ+B/yvtMLYEXL/H+rg=; b=CDn4NKdwReZ60zmQ5sDkuExSs/4L7yAqMofqO+QXcVI4sA8covfYy80D+AjQ9Zyfhds7iCFjN1SJMfN5tmCsLYD1nc1xdE61qemXW/E2k7huK1ZnUhySKZwpMwuzTyHo5c8Fubiq7x+j2hLSEfa+xAjCA5Zv1d7rQqgVtlwtJStI27DE++bOkWem7k/U9ePm3w8zwoCFjFJRaBGN8e3PeuRpy3HjrMazVTHtRsPUuIcXP1jcNGPut+JLQJHcS7uW0aiFbh7C+vj5ipCtezXBJdYyJnyrA+A3gul/6fA1HzpHgQI4ecrS76Hszoq+2g87ZYQo0EpdDHOshdu2W2gc0Q== 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=YizIqpGSk6OdeqMrTc1SwpHMZJ+B/yvtMLYEXL/H+rg=; b=jQKCM7R7Xo0szQpXUSUJNpUkcA046lWEfwE9QxfJpNbTHCi6YNIAthOMtEcUatYa9DthbTyV/qFr5y3nvgaZ7nPIHfljKb+6SX+LqiV2qQ3JI7jhMcGJ5bs0ESr2b3Al1Ln2B6xpIzXexiOhWdfZW/Eg6GrZ/lwVj5mH3APWUzw= 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 DM5PR1201MB0122.namprd12.prod.outlook.com (2603:10b6:4:57::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3499.18; Fri, 6 Nov 2020 17:55:08 +0000 Received: from DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba]) by DM5PR12MB1355.namprd12.prod.outlook.com ([fe80::e442:c052:8a2c:5fba%6]) with mapi id 15.20.3499.032; Fri, 6 Nov 2020 17:55:08 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH v4 11/11] UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number Date: Fri, 6 Nov 2020 11:53:13 -0600 Message-ID: <24866de07d2a954dec71df70972f1851273020d8.1604685192.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: SN6PR2101CA0002.namprd21.prod.outlook.com (2603:10b6:805:106::12) 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 SN6PR2101CA0002.namprd21.prod.outlook.com (2603:10b6:805:106::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.6 via Frontend Transport; Fri, 6 Nov 2020 17:55:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: b1aee71c-a821-457c-4606-08d8827d196b X-MS-TrafficTypeDiagnostic: DM5PR1201MB0122: 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: bvTys1AsK4jzmS6cd+hwuUrCEd1j7AzwbS3EDPwx5uKEMWBFIeWs/diDNe+4EvHllLP+JqTuj3VkfjlSGUArh2Iavg9K2vOk4XMlys2akPK8opmL9hsYtMGBQvLi7CkhzdOJdKEyTCRz0awSxcjlewIkA5zNZAcbOtTfc4wxgeA8Ijdg4tZSY2QuxDV1+NnHN4XnzoEWQurbASo6IhD+r4zNm8IGpq8pqufc4QrPkLHb/JmFrDniiPEFRRlTwix7qckU0mMzXt9z3jmrzg/cURL81l6Rd2aMSzxgcKDSO0G5Jd0Q8XRvX+lhORK6P9OpdApWwUqA0q9gYbxzTQDU1LDUncSYcQWBExcC1hJxnoaUbKNk8l40HfG5eRQIdfMMqLXEWc1R5eabZNFPWHKcng== 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)(346002)(376002)(366004)(136003)(39860400002)(396003)(52116002)(5660300002)(2906002)(4326008)(83380400001)(8676002)(2616005)(956004)(7696005)(6916009)(66476007)(66946007)(26005)(16526019)(66556008)(86362001)(6486002)(8936002)(36756003)(54906003)(478600001)(19627235002)(6666004)(316002)(186003)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: +4H3t0xDskr5UByquJMEISZctTvjnQ8YumoLQ+BVaPiboXq2i5X/a6vKVkqhFgPFaGeiNCwkYCsTTTNc+vhEgGShYHXz41elC+sKnO8TXI+5iLtLziBs1ffbLzKt2BEkwffy2ayxn3QNfSFSPybFjZQEs3Wf8GWnzcXBRNLKJrmhf9yMWTEAXWeZ9UeC8fVwOaOtP5AC/tibs+m3hfJA9zjFoVjoZSo1BzBWdtHtbQ8dLnPHohjelwl0TlbWGsZQb4YaT1RuasbHvdqAvIfSvknZUnSStNL2+wMuqOaHaW27HQ2ydJZzK4SbuUIaNOx90fq3qwav1fXGH1Dx+iUMbIo061k00AtXybISys+7tz9j2q8r4jqL3AZXfAnlXdnKT72PYqRtGIdwue6uzbvI1s4SN4ZNFTuhsYd3dj7QKvxgzl6yM+LEyCvUbMT98o8P6ZAWjlSby8y+ieP/BuCU/lmg2fAhUMkH3nlCU4hqfK6YNQE7IoD2DYCohHVs3PI7tLns1Ljag5IMOSrGrEu6bngaNZtzK/OixlJX6lRZNky04vYs/AvMbI7GqKH9UEA+OsCI+H0maMJZ1lleGgCz3j0/yxmLXczjH9AdDtCnIjNBr4yfRokEGNsfn6ehKE6jLzPqRIXNGO+k/fL25QF5ew== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1aee71c-a821-457c-4606-08d8827d196b X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2020 17:55:08.4417 (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: hjw3iCVztO9hS2CBYzc/SbTOV3KRkyPftAdR6/CpzFOI6W5b+C5mk1zZKx5eT+M/HEeWyeY3mz5X1eKAiCG+iQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0122 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 1f47ff3f73b5..681fa79b4cff 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