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 E61219418AB for ; Wed, 1 May 2024 19:04:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=J2VJ5183N4/kCSZCCm2S5TiBFML1mIs0uQSGsPpvxJI=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID: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=1714590290; v=1; b=Md6Qt4TspaPQKXlY0Uqh3vZvCVSaSbxhdTR6EnIqQr6pg6qL16TtyScDY4i2XdIXv7C7nbsy tECJolxsevMHKcqVLFcCpELkEf4GpCzWEkfLmdKaS2j0MlWVvv9RGQXYCOYqSJSwQvDaES8kjLZ pIqsFwv5+pQIFZ80V3k9o2qyau5U7LdnJV0MIXtbjjAEZ63I0GeEfQM/6GyVxT/zAve60W808ij Pb+frNzdaiZQ4V9KiyeNTkXgNRn3svvj5YoIvwP3FtlvoPNoNVvbtRBNgKBVHayBqFPRHM+tA9G /4iPKgVsN+z286UXls3PsUz8ac7TJEpsG1p/gSZJZ/u4g== X-Received: by 127.0.0.2 with SMTP id hWpUYY7687511x4kruaa3jWj; Wed, 01 May 2024 12:04:50 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.57]) by mx.groups.io with SMTP id smtpd.web10.5138.1714590289589545559 for ; Wed, 01 May 2024 12:04:49 -0700 X-Received: from SJ0PR03CA0024.namprd03.prod.outlook.com (2603:10b6:a03:33a::29) by IA0PR12MB8279.namprd12.prod.outlook.com (2603:10b6:208:40c::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.35; Wed, 1 May 2024 19:04:45 +0000 X-Received: from SJ5PEPF000001CC.namprd05.prod.outlook.com (2603:10b6:a03:33a:cafe::15) by SJ0PR03CA0024.outlook.office365.com (2603:10b6:a03:33a::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.32 via Frontend Transport; Wed, 1 May 2024 19:04:44 +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 SJ5PEPF000001CC.mail.protection.outlook.com (10.167.242.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Wed, 1 May 2024 19:04:44 +0000 X-Received: from localhost (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; Wed, 1 May 2024 14:04:43 -0500 From: "Roth, Michael via groups.io" To: CC: Gerd Hoffmann , Ard Biesheuvel , "Tom Lendacky" Subject: [edk2-devel] [PATCH v4 0/3] OvmfPkg: Don't make APIC MMIO accesses with encryption bit set Date: Wed, 1 May 2024 14:03:37 -0500 Message-ID: <20240501190340.2238565-1-michael.roth@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: SJ5PEPF000001CC:EE_|IA0PR12MB8279:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e86d95b-6fa3-46ae-6779-08dc6a118ffc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?saRjsAR+qlVyywMMbQc28P0BKHUm8X6PU0Kvt1I6IcTZVVNPzmWN4AcEUehd?= =?us-ascii?Q?ByVMgKHAIJtQBMsj+S0DwBvyoWdMYBbfBBZgRwRfa9MXqvff/+xsUwxM86Uu?= =?us-ascii?Q?lmDUykiuNLaUKtPrzqMaZadgfiONCCmpxeejS+GEWOKYpswNZa2pWrn99eKu?= =?us-ascii?Q?UZ3uOBUBRGTsq/0H37H0lT5ViMQghdFrFiFpm1Npsy3yf7JFMal7jUBPX+QS?= =?us-ascii?Q?08zIEOQ7UISWZyFQaVYSr9oaKostZUcitQ5ktcG09UwTo7hiCuMV0tT2JgN+?= =?us-ascii?Q?JyzTd57cOIUFxMh4BS2g5zN1+1GNDLe7jyaXma+Jw4sjAZFULcShYG1zFPyG?= =?us-ascii?Q?MR3aummMz+PQ4Tt1pFeDM8tcfguxDdB0aGtdRkK1lbQOGv3KWg9yeJzGmAfW?= =?us-ascii?Q?+xgJ9cdWePZRZ3nXdz5uqdahrJ6O5iNBfHJ3S1vd4w3/RpxCywJPYNpdfvBE?= =?us-ascii?Q?5DEW6zhLKusya+9ksnUuWsbE8MZbOkSgf9Ho3uHkqMHnHM265n066q9L712/?= =?us-ascii?Q?32HvO35BhyLEUsWV1a+PseLlT7q2ZlgPaFA92Gv++uCMkAnIT0m2BLYlfjtQ?= =?us-ascii?Q?Sci0VkiCJrFjohPgFbQdaUrN8cp60meGuNcDukgllK3QKjA69j5W04oQSZlx?= =?us-ascii?Q?XQHWnG7wUywS6xcxyEaPqYZeqAPYmdWfWmZQP9xpnawEg1Wqzdr1mK92PRy/?= =?us-ascii?Q?4uVl/v1X3F+SzNOQytAgNTas2/wn7sC9Cj8pSXih76nE2T+UuCB1WvzYDPs8?= =?us-ascii?Q?fz33Ufulbkrim8EpHgixchtka5uanJ/nV57+oqaB21TESqZ9oCBuSebfVL5M?= =?us-ascii?Q?1WnaQbr5DqJaGRxkg/bsW03PkSAVGFQprkXqb31mZfoOGGkeKdzUNJ6tPlfU?= =?us-ascii?Q?S/a/2PjwKem2FjJjqsvCN9M6zUxl15OyRXL4WOfRdVQHIq9kAcHTaPkFJbhj?= =?us-ascii?Q?T6dxbzqzJ+g1lJalp0JpuIO9kK8Z5dzW8Gp4O+MUlK/JwU6t/kdLurgCYrgQ?= =?us-ascii?Q?aNVspea8Q7xmIbPz33qk1hyve8oNNaudExSA2rb4UK5TQPy+MWfN6iQW7V8Y?= =?us-ascii?Q?ZNsLf4MrrG319rFEW5bcRVohJswGEvwWfU7Ou58wEAgywxXT+jMmM/8+ZIrl?= =?us-ascii?Q?NatW9MKmpPR7WJmFvqKqf1JNXEEFkeFJYVLG33ITveUqbY0nHKLdeXH3lx8Z?= =?us-ascii?Q?cFEqSycP5t7UhsxFAV7qJ+8A1tsktdEk21H7VFqCzv7HY3VVQBRLzIxkyLEg?= =?us-ascii?Q?znN1BCkKqKOWF8OICwR8sfv874bUwj8NssVkMtafa91NKdo+Kg+zVDPjDm6V?= =?us-ascii?Q?8SMUVHPUyCxS0EHMdwwHJHqu?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 19:04:44.1189 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e86d95b-6fa3-46ae-6779-08dc6a118ffc 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: SJ5PEPF000001CC.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8279 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: Wed, 01 May 2024 12:04:49 -0700 Resent-From: Michael.Roth@amd.com Reply-To: devel@edk2.groups.io,Michael.Roth@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: sbgRfcEbMhDBgAJTg6Iy5jQux7686176AA= 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=Md6Qt4Ts; 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 For the most part, OVMF will clear the encryption bit for MMIO regions, but there is currently one known exception during SEC when the APIC base address is accessed via MMIO with the encryption bit set for SEV-ES/SEV-SNP guests. In the case of SEV-SNP, this requires special handling on the hypervisor side which may not be available in the future[1], so make the necessary changes in the SEC-configured page table to clear the encryption bit for 4K region containing the APIC base address. Since CpuPageTableLib is used to handle the splitting, some additional care must be taken to clear the C-bit in all non-leaf PTEs since the library expects that to be the case. Add handling for that when setting up the SEC page table. While here, drop special handling for the APIC base address in the SEV-ES/SNP #VC handler. [1] https://lore.kernel.org/lkml/20240208002420.34mvemnzrwwsaesw@amd.com/#t Thanks! -Mike v4: - split original patch out into 3 patches for each functional change (Ger= d) v3: - also clear C-bit for non-leaf PTEs containing GHCB range - add missing Cc's to commit log v2: - use CpuPageTableLib to handle splitting (Gerd, Tom) ---------------------------------------------------------------- Michael Roth (3): OvmfPkg/ResetVector: Clear SEV encryption bit for non-leaf PTEs OvmfPkg: Don't make APIC MMIO accesses with encryption bit set OvmfPkg/CcExitLib: Drop special handling for Encrypted MMIO to APIC OvmfPkg/AmdSev/AmdSevX64.fdf | 5 ++- OvmfPkg/Bhyve/BhyveX64.dsc | 1 + OvmfPkg/CloudHv/CloudHvX64.fdf | 5 ++- OvmfPkg/Library/CcExitLib/CcExitVcHandler.c | 12 +----- OvmfPkg/Microvm/MicrovmX64.fdf | 3 ++ OvmfPkg/OvmfPkg.dec | 5 +++ OvmfPkg/OvmfPkgX64.fdf | 5 ++- OvmfPkg/ResetVector/Ia32/AmdSev.asm | 5 ++- OvmfPkg/ResetVector/Ia32/PageTables64.asm | 20 +++++----- OvmfPkg/Sec/AmdSev.c | 58 +++++++++++++++++++++++++= ++++ OvmfPkg/Sec/AmdSev.h | 14 +++++++ OvmfPkg/Sec/SecMain.c | 1 + OvmfPkg/Sec/SecMain.inf | 3 ++ 13 files changed, 112 insertions(+), 25 deletions(-) -=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 (#118470): https://edk2.groups.io/g/devel/message/118470 Mute This Topic: https://groups.io/mt/105849106/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-