From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.50]) by mx.groups.io with SMTP id smtpd.web10.9754.1602346111191266008 for ; Sat, 10 Oct 2020 09:08:31 -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=C/9NL93W; spf=none, err=SPF record not found (domain: amd.com, ip: 40.107.244.50, mailfrom: thomas.lendacky@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hyViYrFXgpbCYQZxQFMmC3117p1+/bRrx1gSR3f88BobRd8MSAWXc5kRRDCbSkGBCGwZlA1ifpDyQkr85PYHgvgMLvXGdvac/ccL1HBPusKulT+A5tULF79aU3resFeZUYbtFVewRMMOBW8MwYM+4rW/ysz4eERW7D1IWhpenZTY97VRhC+eFpOOYvWOgBo9g5kbRao0r67EWP1vswn/Jpo3kVfFe2dNTYIhn6zH34DxdswZR3YQkZeSco94IpMR3Xcx8DvR9KThTXl0SKHJ+PV9xhTATVihEGBTd5hUlGl6EN3gyH0JFe/6anusQXVsnSyL7tcQudsF3RqsEiKKGA== 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=8A24Hh4xqxH9hO7Yt35i7yX4z09mfgND5ZElxVjznuc=; b=kg9/LhFoGCzjGLfPz8L7G/fpxVnfUAqFGgEyvjYmlmxEDvb/BYwvR/xMa81cSnLtaqprtg3cJQdXEyXM00yTyWT9fIdvQ3F6ECJ+8vkY1bkakrMnlkDXV6uVxjOz3h+9V/1JjPejhldJcKhr1niMfEltepiQeykmpmSxyCrLSQzHlidii60+XunqMFoYyzmDEWWE3xtHFE3ScWLTo9/4UZpJ1txtnZo62oLgEx02K9frMsQh8PS2NSrpE6UE37F/bCX8PhnF/uVSkbFUbATjY/DgRNrQxMYFkAaxT8CJvy4xy9Waq/6Q+rajVc0Cj2D7+8joUZDqHU1XrlurPfeL8g== 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=8A24Hh4xqxH9hO7Yt35i7yX4z09mfgND5ZElxVjznuc=; b=C/9NL93W/+b5WYEINSLnEeeawARAzMX/XW5TX7aVUFlglwCIOwcnmBZMIsqds2FvZrt3HBb2efrFt8/SLfQ+7m88ovRExmE1+Ix9HfnlXSGVbYnEvMTdJ+Buz/fcTAmP692+5kdz5LaqZqv5zlOUO0WAeOXm0+NNGBYLGHqlTfM= 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.3455.28; Sat, 10 Oct 2020 16:08:30 +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.026; Sat, 10 Oct 2020 16:08:30 +0000 From: "Lendacky, Thomas" To: devel@edk2.groups.io CC: Brijesh Singh , Eric Dong , Ray Ni , Laszlo Ersek , Rahul Kumar Subject: [PATCH 9/9] UefiCpuPkg/MpInitLib: For SEV-ES guest set stack based on processor number Date: Sat, 10 Oct 2020 11:07:07 -0500 Message-ID: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: DM5PR04CA0061.namprd04.prod.outlook.com (2603:10b6:3:ef::23) 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 DM5PR04CA0061.namprd04.prod.outlook.com (2603:10b6:3:ef::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3455.23 via Frontend Transport; Sat, 10 Oct 2020 16:08:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 3036dd46-9fac-4996-dd3b-08d86d36ba6f 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: ES+AShF7/O/6M/pR9OfbTyXEY8zxmc83MPh2d5epUdxhy+K/loNWYDk1/WW1ZILwBCDK+mlpqUa3OATzjVJ7bUUV5DZ+mU7mfPk2kr23Ts6naYc9o1H3Nz/8Zlg92zBAZSO3U2MVAb+OItc7HMCfGwqsPlWQwrTQrZl9W2j4fah9vJlm35StmI1nBrvTgixbNXXRe59QtVBRM8RsyqujHlesqY+Le1h2qJXgqmZF2s4QnK7uoyVNmaXDruOiqSpRd8/aR2g0CNbCjn7wr5odeHAFpfrN9J//yMPXPjS29OXr2AwuD3iCRbUNNMXWSK0QF0SkqJsc0aOC7Vlj14luGw== 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)(136003)(39860400002)(396003)(346002)(366004)(376002)(478600001)(4326008)(6916009)(2616005)(956004)(86362001)(26005)(54906003)(66476007)(316002)(8676002)(66946007)(6666004)(66556008)(52116002)(5660300002)(19627235002)(2906002)(83380400001)(36756003)(6486002)(7696005)(16526019)(186003)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: ZeJVS6WHn8UjidVQ+VhpKmI8/zy/TOCPPwXYSXYdpYjduFHgtCM4Dm7+wL3PG07YZIQaHCXLL3LI+vyo5vZYd5RtTyltboMni01VrVIy9Jc1YSk6mRTxV7kpDbxVvvX3lkNVniQBe+wIyj8UpvWUH679KVXGeflW2BA12t9mjlCan0R+GNzSQSRv6yPSzoNjxiyIO4JfXz0zEfjVeS9jax8f9K7pU1qpg5/FcaRnq5g93N21kbbycseAnvctJIL9T55BvUtYBACqxRzdHccDSPA3sBUqj0XqbWXSGOFgNoAKZvtNBkyK14V1Vm029+skA5wiO4YP97kukuvAI1LiBFF+8GrOqLCBIZR1lBSN3el6/+AQdcL+fACcgaQbTCQhqQkqSYxKsDz10t2ltO4/Pt/2DSIb28O3rpOrYIQQlHEhWRrKt+YE0+4i0PjbBcM3nknoqtLjo1E3Fo6e1+3MBjYT6zovxoR2GcvZhcCXPyq+vLFZU7/5ZAKWSye3sk8UhMzuVsYKanrOK1fTDlH7eMcnuVTso8xBRjRzv+dMy5PjnX+u1b/UVTaH6OAjPUICNRS1oAyvBUbMSGfqIPsPyB7h8PAVNV5fYKLqu/3OiVNAXpljgh0H9mn2o6XkIM6qOvA8Oe8oq9kkMk8tdo9JlA== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3036dd46-9fac-4996-dd3b-08d86d36ba6f X-MS-Exchange-CrossTenant-AuthSource: DM5PR12MB1355.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2020 16:08:29.8889 (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: +uAGyLIv2YSHc1eZP4tH9iaZDg4Bft2dGMpbmH54EmKHmXZu0vlgwZDpTEzRg6KearOyuziYoOcSz2eXlFJI9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0122 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable From: Tom Lendacky 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 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 07426274f639..71922141b70b 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