From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id B177B9416A0 for ; Mon, 22 Apr 2024 12:18:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VF/lIqU3Mlr3CLRFlCdu45VWsymFwpo+P1XXecYZjR0=; c=relaxed/simple; d=groups.io; h=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:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1713788310; v=1; b=IKSlJLMpAVsBgz+VR0Ip/q3eOPxhuct1sCJyL0bcOB/jdEtD5DyS7cTEHp4XUrzUMii2DE4K V04tgilzlgkYz0c5zeAc+MO3ToTiW+FeJHmd821Sk8yoWeIXSeYRNs/fyQ2IEpP0SfZ8cATKWM/ A/3K+c3CtoFgpkw4jwduQSETvxEdLL632JgyKBfli3uFxmL9+wN+EXHrsyfW3Nc/6iUFHkSq7ia 9AU4AkvIPkUdUVUoFd219vQ+01l02dGHq3lafMckR5s/Fec1tyZHvzqEELGWNP2dTHwgdQ1I6fS L1VGSp8ntik447cll4wAObXX+y0eGkfG7BLXB2XlcYZug== X-Received: by 127.0.0.2 with SMTP id DG56YY7687511xrzn4RW3Nuv; Mon, 22 Apr 2024 05:18:30 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (NAM12-MW2-obe.outbound.protection.outlook.com [40.107.244.56]) by mx.groups.io with SMTP id smtpd.web10.16964.1713788309335416762 for ; Mon, 22 Apr 2024 05:18:29 -0700 X-Received: from SA1P222CA0032.NAMP222.PROD.OUTLOOK.COM (2603:10b6:806:2d0::13) by DS7PR12MB6192.namprd12.prod.outlook.com (2603:10b6:8:97::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.44; Mon, 22 Apr 2024 12:18:26 +0000 X-Received: from SN1PEPF0002BA4F.namprd03.prod.outlook.com (2603:10b6:806:2d0:cafe::96) by SA1P222CA0032.outlook.office365.com (2603:10b6:806:2d0::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7495.34 via Frontend Transport; Mon, 22 Apr 2024 12:18:26 +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 SN1PEPF0002BA4F.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7519.19 via Frontend Transport; Mon, 22 Apr 2024 12:18:26 +0000 X-Received: from aiemdee.2.ozlabs.ru (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.35; Mon, 22 Apr 2024 07:18:24 -0500 From: "Alexey Kardashevskiy via groups.io" To: CC: Gerd Hoffmann , Tom Lendacky , Alexey Kardashevskiy Subject: [edk2-devel] [PATCH ovmf v2 4/5] UefiCpuPkg: Add AMD SEV-ES features support Date: Mon, 22 Apr 2024 22:17:03 +1000 Message-ID: <20240422121704.200856-5-aik@amd.com> In-Reply-To: <20240422121704.200856-1-aik@amd.com> References: <20240422121704.200856-1-aik@amd.com> 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: SN1PEPF0002BA4F:EE_|DS7PR12MB6192:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d68659a-119e-4c33-0a48-08dc62c6502b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?34hRFia3TwVivZPqKXiplh1w9SyepcWoXD7rvo/oKbMmsGEEDzCPK29UA4zb?= =?us-ascii?Q?bhZNRLgu0k1QBhMsjTJmPgSMDsOthpwPSOWfmDViuN5IX/dANgUnzB9kwmaA?= =?us-ascii?Q?cirj0WjaMxymG37NCpt0LCn2icM42ELy7ceW/+COV8hLK8T4NLmzce965fes?= =?us-ascii?Q?eA67AiK1hlZa4VHHfG95JrKSMZteAWPc5fvO6XOw2qa/s3kmCcYbQUHccb6b?= =?us-ascii?Q?xnqygb4ZnZQJQF2DAPiY+u90sbY1LlxI9PUPdSC6JN0rM1R7VxJUgnxjdVKE?= =?us-ascii?Q?Q5DBqzfYBm0jy6cdvfzNvn953AcdfaLCF3VTa+WYNj0aXTdOd2F0QrCComRi?= =?us-ascii?Q?b1T26EGKS4FGAR790I4BQX+YqszLoNd+EIXk089etdj8OvHH7QNA74PB5GlA?= =?us-ascii?Q?aHnb5IIDvDkd+ci4w6vy4kkLhDAw2lXHUCtzsllZrT1GrZPjYlCU6Go0X1nI?= =?us-ascii?Q?LMBQTy7Zm7SyUfQ8zCYXrWUYZP36GH+DRl+Y6QFfnHiGepOYUZ/HG/LQrunN?= =?us-ascii?Q?fcsU8HtiNXFnEwm4u+5tzU3EvbXVEqUTbxKugXKikf8+tJG/uGp7b+Vo40iq?= =?us-ascii?Q?rdJENWJvU0+EzBMd27PW7zRDUQ9LJ9KOzYDiB9BQiPQuTM0y1XzjvLLydCbW?= =?us-ascii?Q?LcDJCpheJUc3as9OjFrLfwsp2X8njzmIDHQ3g6cE3I+bBH6TGcl3xB4aKZqr?= =?us-ascii?Q?RXu6BCsY5Metn3rysLGrHcG682bP6WvUrNiGEf6PBx6/rmzvR8fvJ4CTQiNL?= =?us-ascii?Q?iFst0LIugoaOr4aARG4YNTYlb8WZu0vHMftb4kqhNe9uWsc48lQ4N3NgS/Co?= =?us-ascii?Q?VOk/ZZ5IpNHbc0XNSde4ZS+ucANx8uuw81/uJG6CgfqWRydFHdORr60Ryq4P?= =?us-ascii?Q?YKcfuOmqHPdbeVJwCvTgLKFTYWethuF/vAJ4bUiBXVQzgLEPDWJtS5abc6e9?= =?us-ascii?Q?s2UCWsTU6qoBksRIn/sCu4t9kEu69qZwG1Zb2dQOKrtICurjbDtSdQB2phBJ?= =?us-ascii?Q?/zoqHpItnp3kOwtZ9A9OJguhpM3cjCzRIxbsRhpp9G4gDDzY7kbTUbndwfIs?= =?us-ascii?Q?dyd9oUG/e98deI1S5OhuJQsDkvJZVLkQnz5vQE/g89w4k7Tcltyd7fvccy2E?= =?us-ascii?Q?bwHhy0obSAYXukQDV0URX8ypGM0ymXU5Vpo+HCrjgzsgps6GJlH7zb3gU8ul?= =?us-ascii?Q?p7+nDPXjn/5j9JJtWsRRi58OJIPUo7dQWP/qGBIwMXSEt0481Jp91uH8KQ7F?= =?us-ascii?Q?y7M7PCzNYxJ3vX/CJcSYUIPsnpgwuQzmLR+Y6ld0CQhUm8SUqxM1c9cHrNV/?= =?us-ascii?Q?MtJSx4CfAUbUsTpB58G4xpreh6NRsWOVWIy72fruufTMJsWj9BakccbEV7cN?= =?us-ascii?Q?okh4+8jMjVvR+NEH5PLHmNp7D7pe?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2024 12:18:26.7343 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d68659a-119e-4c33-0a48-08dc62c6502b 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: SN1PEPF0002BA4F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6192 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 Resent-Date: Mon, 22 Apr 2024 05:18:29 -0700 Resent-From: aik@amd.com Reply-To: devel@edk2.groups.io,aik@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: mSQBAde8pGFdJxddPATqcoBPx7686176AA= 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=20240206 header.b=IKSlJLMp; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io CONFIDENTIAL_COMPUTING_GUEST_ATTR is not a simple SEV level anymore and includes a feature mask since a previous commit. This fixes AmdMemEncryptionAttrCheck to check the level and feature correctly and adds DebugSwap support. Since the actual feature flag is not set yet, this should cause no behavioral change. Signed-off-by: Alexey Kardashevskiy --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index d7244565029d..5904dc69121b 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -3178,19 +3178,23 @@ AmdMemEncryptionAttrCheck ( IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr ) { + UINT64 CurrentLevel =3D CurrentAttr & CCAttrTypeMask; + switch (Attr) { case CCAttrAmdSev: // // SEV is automatically enabled if SEV-ES or SEV-SNP is active. // - return CurrentAttr >=3D CCAttrAmdSev; + return CurrentLevel >=3D CCAttrAmdSev; case CCAttrAmdSevEs: // // SEV-ES is automatically enabled if SEV-SNP is active. // - return CurrentAttr >=3D CCAttrAmdSevEs; + return CurrentLevel >=3D CCAttrAmdSevEs; case CCAttrAmdSevSnp: - return CurrentAttr =3D=3D CCAttrAmdSevSnp; + return CurrentLevel =3D=3D CCAttrAmdSevSnp; + case CCAttrFeatureAmdSevDebugSwap: + return !!(CurrentAttr & CCAttrFeatureAmdSevDebugSwap); default: return FALSE; } --=20 2.41.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 (#118092): https://edk2.groups.io/g/devel/message/118092 Mute This Topic: https://groups.io/mt/105668065/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-