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 993A4D80229 for ; Wed, 5 Jun 2024 02:12:40 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=b4oaThfDHs9E+s0JIj0lGrfw/InTxMGB5TK02bZgJhA=; 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=1717553560; v=1; b=HynJyrUrBRn3/4jvGgoetQRe0NFM9b8W7Vq60K9DUxUGd9MA2NCzeyPMxS8VpTGwkPY4CuNd us0vwUgu+5jSbZUwe3N1FPhQiz9JvaGkjkBsmZGJtl9OXxImP6fQiU57vTEzHKMleLNTyeFmPXv epi/P7YfHeJ/cB3BDWDUOpFOX1PEQgeZJkGXh7THxVWDfwavW/rveEuIAfGQff4vink4IwdEwIq nflON/t6/g9t2GD3A1JylY8Gkxmy5e8pKlkz2IJS9940vmrCsTHkTAA+pdf280VltqzvaPnNQtN 9zXU1ZpdjMgzGtvcNnDeUdxK8qjWnBTdElRtVQ78T4ljw== X-Received: by 127.0.0.2 with SMTP id x700YY7687511x1Xrw5QiJPu; Tue, 04 Jun 2024 19:12:39 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.81]) by mx.groups.io with SMTP id smtpd.web10.5302.1717553558568083874 for ; Tue, 04 Jun 2024 19:12:38 -0700 X-Received: from MN2PR14CA0020.namprd14.prod.outlook.com (2603:10b6:208:23e::25) by SJ0PR12MB6904.namprd12.prod.outlook.com (2603:10b6:a03:483::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.20; Wed, 5 Jun 2024 02:12:36 +0000 X-Received: from BL6PEPF00020E64.namprd04.prod.outlook.com (2603:10b6:208:23e:cafe::42) by MN2PR14CA0020.outlook.office365.com (2603:10b6:208:23e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55 via Frontend Transport; Wed, 5 Jun 2024 02:12:35 +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 BL6PEPF00020E64.mail.protection.outlook.com (10.167.249.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7633.15 via Frontend Transport; Wed, 5 Jun 2024 02:12:35 +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; Tue, 4 Jun 2024 21:12:30 -0500 From: "Alexey Kardashevskiy via groups.io" To: CC: Tom Lendacky , Liming Gao , Michael D Kinney , Zhiguang Liu , Ard Biesheuvel , Erdem Aktas , "Gerd Hoffmann" , Jiewen Yao , Michael Roth , Min Xu , Alexey Kardashevskiy , Jiaxin Wu , Rahul Kumar , Ray Ni Subject: [edk2-devel] [PATCH ovmf v4 4/5] UefiCpuPkg: Add AMD SEV-ES features support Date: Wed, 5 Jun 2024 12:09:45 +1000 Message-ID: <20240605020946.1224515-5-aik@amd.com> In-Reply-To: <20240605020946.1224515-1-aik@amd.com> References: <20240605020946.1224515-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: BL6PEPF00020E64:EE_|SJ0PR12MB6904:EE_ X-MS-Office365-Filtering-Correlation-Id: ebe02259-c60e-4965-7777-08dc8504f792 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?Uy6U874IonSSZicjTorugbwCcptYa4SM9tC2+Qcidir0v8qu363rmxbVT4MJ?= =?us-ascii?Q?HWe4XIhoiZBmz7C1cwvxyVp5SJqM+PB0xbAfYcteUnIqz8uX6zzJxgquJKNz?= =?us-ascii?Q?W09ED4Pq+Qr9hSvzcATRBcE1KvWH3XMJ74mhjrX2BY90ODbokp8tSJD165UI?= =?us-ascii?Q?yZyY+iuCHAvwpsqNWfjcjb/RJxGjTf+SFtEEB4AU9FyFKjFFHumYEnad5W+/?= =?us-ascii?Q?/h+2axPTa69gnkhiOdviuxi90+DKNmY423hs78Tt8clZRVssmGZVxMuQQn26?= =?us-ascii?Q?q1g4qeoFGUyCrnN9ab7ve62sAV9o/jFhIRPgUkS4WbQ6q5/1dIodjaObwUG8?= =?us-ascii?Q?61MUaK5iAFfduTcUEsboTyjALsKh6v/fbrCwUZFf4sVchbNlRzHTyQMovzn6?= =?us-ascii?Q?lTF2DZzvC2z8yhjh2hGokCavr9QsdUCjVj1z3p4g/rdITdntGAI2wBsM5E+1?= =?us-ascii?Q?ludn9EvUjm4IAOgDok9GWeZlRSCFWU45h19okgCm6VbmijBmF3A1/V+g65FR?= =?us-ascii?Q?UBO9r9RLDN72ZW68msWypKPDXps6kQA6KHO0zlb32n49S++BFD1Wd2mvpJEt?= =?us-ascii?Q?stL9airWGbu3qvTZLYkTIYlarVeaimV/EIL0REfO82Yk33OwMfp8aK+UBJqf?= =?us-ascii?Q?dU5LT62HeeNUFadU+XCTFjjSWSFI1bMlC/ZwyfSrpMwxcUy8OW8j2RL0lmxf?= =?us-ascii?Q?4EzEux945yBZeUOjn66LDV/z9KatyV2310LtStncnyv6Xxoz+o1bWh2a+vSH?= =?us-ascii?Q?vLdynv/6AJs7TnYtYkcgc6dALf+Vf7T6kz8lZ1/vT2+EU9VsmLT5zWHKL9/U?= =?us-ascii?Q?69leIkrjwJykaHtZuoUDmj4ceRzeI6xG5G3HygH4WT5JdLf7FYEBUGpKu20g?= =?us-ascii?Q?rWvuGKNak/BQ67BrBm+M02qrGyR4BHCEhYZSFOcFXibwNNbYz0QDv0NdtoXy?= =?us-ascii?Q?YSwkC9vN5y8CpZGtPElEnwBnp0b+1AN+Rlpo96zSYULtOJ4gkD0c8m9ddUbQ?= =?us-ascii?Q?gIDYtNBW56MgyVFoyK55LNZ66KM7qbtQWWBIqRfZ2gazUYsvuZenubKdqqmh?= =?us-ascii?Q?0CfPLzb82pP6aXGgj1uzm0oHUVlBr1NioHACNgMzXU9v6Tpsew59eaKemGAb?= =?us-ascii?Q?rfI36upAeMP0Z3VD8IyqcHEzFyefPxYsMT3t3Oh2LN9Kxg7qnfEUYCOnNfwE?= =?us-ascii?Q?LxV02Y9KD2Wsbtme4hKJ0Wg0KU+F4EvZr6++xj5kmOWcJxeBtLMc6ddE42oJ?= =?us-ascii?Q?eJbWZAttaXQh/YKrMRcishUKzdblYBCZY3tCzLLwJb0aC9Uk33oPDaSyiG95?= =?us-ascii?Q?csUp6KmucEqn2SPUTJNa20EDnjhxk4pWbvKaUztJKbCRds8dO0SCvk9TtI5D?= =?us-ascii?Q?RYq8AnE=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2024 02:12:35.9077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ebe02259-c60e-4965-7777-08dc8504f792 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: BL6PEPF00020E64.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6904 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: Tue, 04 Jun 2024 19:12:38 -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: M5OlTZR3USg27Ud60adefJ8xx7686176AA= 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=HynJyrUr; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=pass (policy=none) header.from=groups.io CONFIDENTIAL_COMPUTING_GUEST_ATTR is not a simple SEV level anymore and includes a feature mask since the previous commit. Fix AmdMemEncryptionAttrCheck to check the level and feature correctly and add DebugVirtualization support. Since the actual feature flag is not set yet, this should cause no behavioural change. Cc: Gerd Hoffmann Cc: Jiaxin Wu Cc: Rahul Kumar Cc: Ray Ni Cc: Tom Lendacky Signed-off-by: Alexey Kardashevskiy --- UefiCpuPkg/Library/MpInitLib/MpLib.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpIn= itLib/MpLib.c index f97298887f96..444df2abdc1d 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -3196,19 +3196,25 @@ AmdMemEncryptionAttrCheck ( IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr ) { + UINT64 CurrentLevel; + + 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 CCAttrFeatureAmdSevEsDebugVirtualization: + return !!(CurrentAttr & CCAttrFeatureAmdSevEsDebugVirtualization); default: return FALSE; } --=20 2.44.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 (#119462): https://edk2.groups.io/g/devel/message/119462 Mute This Topic: https://groups.io/mt/106496089/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-