From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D29A6D80888 for ; Mon, 6 Nov 2023 22:46:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5aQiXdHlLYCj1Cv/BRb0qO7NsmGxeDaRG8g75zB8ALY=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1699310761; v=1; b=NWQ5dN2NNF4rx368WLMBeXKu3k2gx9Sf96dZRHn4DRpu671GNYfxTm7PCAldnLk8jw4V9rlJ 8BvXL7GqKzT4lDodiFdxruFXreby7G8w9RtTCFvncrONN0DLKf3X7ge6d1cxNPngmjULCaO+lwC dw640MDwc+97rprrIJSB527U= X-Received: by 127.0.0.2 with SMTP id ylcSYY7687511xJ3ArHTJN62; Mon, 06 Nov 2023 14:46:01 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.63]) by mx.groups.io with SMTP id smtpd.web11.70911.1699310760922249132 for ; Mon, 06 Nov 2023 14:46:01 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UlRP/L8ekum7sR1l03Y2CCw2eoCsgk9VzZ/ivQlSqQ5PPkh9AvJv5rofHrwmhltndQnrJtwa0AR3QmAqpZ021qBX0fN0R21QeJlrAQvrFH9Pk0RnUrBM8bobtm67DGh8/rDxzpUQmU2QQTmHaxIbq6kokuZufHZKZk0BFTcjMFzt/OnvDUQmwymKYtuqFLvmXnKEpZth82/1aOhIk9yyI3diy3uOfDh8Apjef1Z74LQDx2bDjRfKFkSDOasjo5i+AzNWyE/2XAYPdiqK3+CwRIWlRQjDL3qBgsF2FtiVAKQTz5LNlxd0pS7razmyYdjDRVrtnSc31C4s1aRvV16IBw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Jo5m6L+rgMYyVArm5iZWvyc7/g45B9CYLiLab8EzFeQ=; b=n4oD3gMcw+aPAjIDPkRhIH27nJDq7g+k/vJ6YGmXS0r+xyu0A62uXVIOPKPsl1NXZvS2oVEKorLEhy31tnavfdBoknmEvAAiIZoN0bjL9fynN84DbNKwjsLQ57RwxoAqJmDIBzmuWcglP4uP51FPmnPKmQKaxpg8ICPJ6WtMenfdwgn0dmD/ywcS8eE+GZcQSJIL6zeRL4RPxpyE3kPkpz7cfWhhIehhnYZviFeFeekF9UtCOXGIRixTjZV86yekmNYhRN+qJqEe5JDhudUYy0Givg3VXM8Gydc3YpCoEsehxh97TJ/yGza5kmSXKLxVqQgzcn4bMCRNXU3UXUUleg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from CY5PR04CA0013.namprd04.prod.outlook.com (2603:10b6:930:1e::33) by SA0PR12MB4432.namprd12.prod.outlook.com (2603:10b6:806:98::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28; Mon, 6 Nov 2023 22:45:57 +0000 X-Received: from CY4PEPF0000E9D1.namprd03.prod.outlook.com (2603:10b6:930:1e:cafe::1a) by CY5PR04CA0013.outlook.office365.com (2603:10b6:930:1e::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6954.28 via Frontend Transport; Mon, 6 Nov 2023 22:45:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000E9D1.mail.protection.outlook.com (10.167.241.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6977.16 via Frontend Transport; Mon, 6 Nov 2023 22:45:57 +0000 X-Received: from tlendack-t1.amdoffice.net (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.32; Mon, 6 Nov 2023 16:45:56 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Ard Biesheuvel , Michael Roth Subject: [edk2-devel] [PATCH 2/2] UefiCpuPkg/MpInitLib: Copy SEV-ES save area pointer during APIC ID sorting Date: Mon, 6 Nov 2023 16:45:31 -0600 Message-ID: <09a41658fc43ceffadf5bfcda44356fa38049935.1699310731.git.thomas.lendacky@amd.com> In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000E9D1:EE_|SA0PR12MB4432:EE_ X-MS-Office365-Filtering-Correlation-Id: 76962e76-27a6-4909-56a5-08dbdf1a2475 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: 2WQvRhU8wHOBZ+fQxUnHmagz0lcabo/gkEBWjHE46P4NAWw9nwueMEUmgo2vBDDKPQ1UOjylHlc7MwLzjigy5vWtbR5vskVJlYLK/9vJ8KwdHryabauxu6rjeurNnjUtRowGnzwXNVc6QlVktrhiL7/H7RJzrBnTv3jxYDRtDkegB3QHgF9sfkGddmjymSTfqrzjqEW+/QbHZiH4AgaPoh/Y60ODt236xE8tOeAI/xGUdXSeRXff/gYNlWQNZsy0gyI+43ben8FZWHYfgm0bUBgOQZqGPW9WQ7U3Um+/xGXkP08uPfJ3H/pIOlMiNIKdwAjB/UV8jhRB4+A9lwQ4FKOkK08neccf1xOZ9lnWoZXxBJpmmwPaFfVRGrHgyOMmbGlMCZdQgt7vYsGR8263fbvYbjEO3NkZ5aN85dj7epQctgm/a5QEQU8MPO2MgaZVQiXKQMvZhjO+rkP/2RVZr7YAJcq6QrRBdX9KDsJOW+HEN51dMEfL8kthSzLz+Exg/udwZVB7KjIn7gnE+bpSNDBu06Dzr2AvsOdkPks7pppszS+Sz0J0zzqP8MBa5Kz4EpB8KQpIwBOeoCz8Ck9GsB13kCY5gQFlxu/ttNHczk2bwotAjNK8h8eCiaVIxJJ7NFzoOoE97RLOJW4shEigSR/w+DcbyXEh4GXy8CsqZaZfdNbN/Ew2j+R2z0L1mBiq1C4RR80iTaoyKM8ExdEZQ/WIb7Z7sYyK3iwqfg2hPaxz85h+fiiUBK1VP1ADH1iedFgPpxoJvOy1MYlHr09XRg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Nov 2023 22:45:57.5776 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76962e76-27a6-4909-56a5-08dbdf1a2475 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000E9D1.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4432 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,thomas.lendacky@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 3D1SG3DujLh30KoDV8vPhJUOx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=NWQ5dN2N; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") With SEV-SNP, the SEV-ES save area for a vCPU should be unique to that vCPU. After commit 3323359a811a, the VMSA allocation was re-used, but when sorting the CPUs by APIC ID, the save area was not updated to follow the original CPU. Similar to the StartupApSignal address, the SevEsSaveArea address should be updated when sorting the CPUs. This does not cause an issue at this time because all APs are in HLT state and then are (re)started at the same time, with the same VMSA contents. However, this should be fixed to account for any change in future behavior. Fixes: 3323359a811a ("UefiCpuPkg/MpInitLib: Reuse VMSA allocation to ...") Signed-off-by: Tom Lendacky --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index 9a6ec5db5ce9..a41b9e5701af 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -370,6 +370,7 @@ SortApicId ( UINT32 ApCount; CPU_INFO_IN_HOB *CpuInfoInHob; volatile UINT32 *StartupApSignal; + VOID *SevEsSaveArea; =20 ApCount =3D CpuMpData->CpuCount - 1; CpuInfoInHob =3D (CPU_INFO_IN_HOB *)(UINTN)CpuMpData->CpuInfoInHob; @@ -397,12 +398,17 @@ SortApicId ( CopyMem (&CpuInfoInHob[Index1], &CpuInfo, sizeof (CPU_INFO_IN_HOB)= ); =20 // - // Also exchange the StartupApSignal. + // Also exchange the StartupApSignal and SevEsSaveArea. // StartupApSignal =3D CpuMpData->CpuData[= Index3].StartupApSignal; CpuMpData->CpuData[Index3].StartupApSignal =3D CpuMpData->CpuData[Index1].StartupApSignal; CpuMpData->CpuData[Index1].StartupApSignal =3D StartupApSignal; + + SevEsSaveArea =3D CpuMpData->CpuData[In= dex3].SevEsSaveArea; + CpuMpData->CpuData[Index3].SevEsSaveArea =3D + CpuMpData->CpuData[Index1].SevEsSaveArea; + CpuMpData->CpuData[Index1].SevEsSaveArea =3D SevEsSaveArea; } } =20 --=20 2.42.0 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#110768): https://edk2.groups.io/g/devel/message/110768 Mute This Topic: https://groups.io/mt/102432047/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-