From nobody Wed Feb 11 06:00:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+81917+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one); dmarc=pass(p=none dis=none) header.from=groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1634144286440820.8642582688998; Wed, 13 Oct 2021 09:58:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id jGYQYY1788612xkoUdzbRP6w; Wed, 13 Oct 2021 09:58:06 -0700 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.86]) by mx.groups.io with SMTP id smtpd.web12.125.1634144284823218618 for ; Wed, 13 Oct 2021 09:58:05 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B2lIjp2wGrDRktbmiK9iTXXjNSmfI/mdyqRtQn4qpTV+Ayzn1HzN+4UFDByuTzNvO6K9JLcxkR/1S9LRtJ+OjVl0cF+hyWzouSrNC4+Glkof2GKJLBcEgMg3sLs9Dup6A7tJWM1x6HD4pkJj2WjY5QNVPuYHQvXSQNama5Dq2msJpLnlZtWgqEZV2FpnkpOL6N50CmIUiny4cRWBuDugUSqxxj/nduRJdUZ+uxFiLcFvjtw4nV3ZANc43aKJQWxPf8QQxk/SJ7CBxjLeS1PlMfre0X9RL+0NYhZy1OZzEY4US7PBU1OmqE97wM1HUrmHyTgvZA4/N9bapxEbzL+9QA== 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=ssbYYDRnBzgPINFTwLfD1QN9nBJ41Imrw0w8gRmkrZE=; b=mpdQ09sCZcbVEF+6u6JI8M+2vRFBeIAHFxvZJHnw6OxzR35SgPac/3IHYhEyplJtBUlRNHDRtDRuR9MwedB5+F40qq4Ao/vedf0cYB8Bueq6D43IxF3AUwTMZbJRgEg1us1SIb2orvfFuRZvzJ8TOuvl5EwPCf9bzHzY5rVobIrZKMqF+IyBwNkMy9fM05bpuh7Gm29nLNC15xoucKhRH2CvxfHdUMeecXfeB4CnZ24qhfr/Mi1yezjZLAAcW21NN0+oSG2r9EMfpGB2DUOz9SNWp68CTTBCi1a6pbFtQpMcBtWWXQpl6iVTRPNngUuySPeI5FaSMUiiWCfpy/gH4w== 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 X-Received: from MWHPR11CA0011.namprd11.prod.outlook.com (2603:10b6:301:1::21) by BN6PR12MB1858.namprd12.prod.outlook.com (2603:10b6:404:fe::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.20; Wed, 13 Oct 2021 16:58:01 +0000 X-Received: from CO1NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:301:1:cafe::93) by MWHPR11CA0011.outlook.office365.com (2603:10b6:301:1::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4608.14 via Frontend Transport; Wed, 13 Oct 2021 16:58:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=pass action=none header.from=amd.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+81917+1787277+3901457@groups.io; helo=mail02.groups.io; 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; X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT060.mail.protection.outlook.com (10.13.175.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4608.15 via Frontend Transport; Wed, 13 Oct 2021 16:58:01 +0000 X-Received: from sbrijesh-desktop.amd.com (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.2308.8; Wed, 13 Oct 2021 11:57:59 -0500 From: "Brijesh Singh via groups.io" To: CC: James Bottomley , Min Xu , "Jiewen Yao" , Tom Lendacky , "Jordan Justen" , Ard Biesheuvel , Erdem Aktas , "Michael Roth" , Gerd Hoffmann , Brijesh Singh , Michael Roth , Jiewen Yao Subject: [edk2-devel] [PATCH v9 29/32] OvmfPkg/MemEncryptSevLib: skip page state change for Mmio address Date: Wed, 13 Oct 2021 11:57:10 -0500 Message-ID: <20211013165713.727815-30-brijesh.singh@amd.com> In-Reply-To: <20211013165713.727815-1-brijesh.singh@amd.com> References: <20211013165713.727815-1-brijesh.singh@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cc15ee2a-9af9-4be8-6f83-08d98e6a9dac X-MS-TrafficTypeDiagnostic: BN6PR12MB1858: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: wCvfZE/I7dAQnly+PhoDGVrgVi5Jt5RIeMsJCDY1QQcQjbqG/wIH3GmI8f2a+xrW/FingypZcBuiloihsF2K950QEoTVlSst2xS811xJvex6f98bdCbKm+mt/sGtor15t4OK/VtHmEr9JmaQz8PWJ3Z1vlyhOH4bBtk0QDZC2gL1fxI45COeVvqe2m0AMNASNhtzNneYrT4uMQpdq1YJA9u4pjTEtut9JCp5rfjxrThFNyE/Xw9dp8i2ZPlvm2nmox1HbO5hwgPMeRDUyoS8WzUbqwSxxFqAUKEVrSLiabQ3kxxdwkbp6A0TMVX7RE8+DImGHpZjEl8NgbkU2cicJq74RNXTV29wQ2kuNcSl9cNsyBCwJLnyb+k7rldA5gB13c2EEtDBsw1hR2lfbRgNqhnTYsIZq6VDhIZEeJ1DX8t6plDX7aePjALmOefDd/K46D1/UXYH5nQ0oIWg0UfNDMLXEMwPoctVRWNpzW5LjRN8Mb9gNQdBS3hGkdbb3ZmOZwK6Q2/MIr1a/JHU6tHOUQokhcWucAw8fWs0Pt2wgCrDG8N55bksgUKyfK4WDWXLjnC8qEuZ/XghSWNOggjybKAxfNrRGJSYYtIcQLYVLtSARcnYkNLBgRyNIelA/fWi7QJUORieC21U8CBrE3NEUFUgNSnYELlo81R0/vLCe0vm/8nAwmNzKX8viCY/o1AxjFwGRaqtHpdREXR/9O9Tufgd/Qm9WEdO0uTbemPo5Oc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2021 16:58:01.1154 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc15ee2a-9af9-4be8-6f83-08d98e6a9dac 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: CO1NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1858 Precedence: Bulk List-Unsubscribe: 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,brijesh.singh@amd.com X-Gm-Message-State: LFAymRfdLmXDg7Cp5idmT73Wx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1634144286; bh=K9TaZ2JpPEFIbL89KeTVqSOqF3Q4wwhWAaFjmCLggsk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=v+rGgsnUNPB3BYf9bMr6Wmag01yKLx2SqLZ2/tnRme9m5ES6bFMKWGXqCKuml25RVVR uEG8QB3QenAJM25743BaOt3ckt6e5XnvByQbtyKGsrli8WP3aDuajKHRc/nAIQwyLnZeG UJVPcAQohIm8hToXmhNym1xaeOOKUTB2lD4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1634144287643100053 Content-Type: text/plain; charset="utf-8" The SetMemoryEncDec() is used by the higher level routines to set or clear the page encryption mask for system RAM and Mmio address. When SEV-SNP is active, in addition to set/clear page mask it also updates the RMP table. The RMP table updates are required for the system RAM address and not the Mmio address. Add a new parameter in SetMemoryEncDec() to tell whether the specified address is Mmio. If its Mmio then skip the page state change in the RMP table. Cc: Michael Roth Cc: James Bottomley Cc: Min Xu Cc: Jiewen Yao Cc: Tom Lendacky Cc: Jordan Justen Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Acked-by: Jiewen Yao Signed-off-by: Brijesh Singh Acked-by: Gerd Hoffmann --- .../X64/PeiDxeVirtualMemory.c | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c= b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c index 56db1e4b6ecf..0bb86d768017 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c @@ -673,6 +673,7 @@ InternalMemEncryptSevCreateIdentityMap1G ( @param[in] Mode Set or Clear mode @param[in] CacheFlush Flush the caches before applying the encryption mask + @param[in] Mmio The physical address specified is Mm= io =20 @retval RETURN_SUCCESS The attributes were cleared for the memory region. @@ -688,7 +689,8 @@ SetMemoryEncDec ( IN PHYSICAL_ADDRESS PhysicalAddress, IN UINTN Length, IN MAP_RANGE_MODE Mode, - IN BOOLEAN CacheFlush + IN BOOLEAN CacheFlush, + IN BOOLEAN Mmio ) { PAGE_MAP_AND_DIRECTORY_POINTER *PageMapLevel4Entry; @@ -711,14 +713,15 @@ SetMemoryEncDec ( =20 DEBUG (( DEBUG_VERBOSE, - "%a:%a: Cr3Base=3D0x%Lx Physical=3D0x%Lx Length=3D0x%Lx Mode=3D%a Cach= eFlush=3D%u\n", + "%a:%a: Cr3Base=3D0x%Lx Physical=3D0x%Lx Length=3D0x%Lx Mode=3D%a Cach= eFlush=3D%u Mmio=3D%u\n", gEfiCallerBaseName, __FUNCTION__, Cr3BaseAddress, PhysicalAddress, (UINT64)Length, (Mode =3D=3D SetCBit) ? "Encrypt" : "Decrypt", - (UINT32)CacheFlush + (UINT32)CacheFlush, + (UINT32)Mmio )); =20 // @@ -760,7 +763,7 @@ SetMemoryEncDec ( // // The InternalSetPageState() is used for setting the page state in the = RMP table. // - if ((Mode =3D=3D ClearCBit) && MemEncryptSevSnpIsEnabled ()) { + if (!Mmio && (Mode =3D=3D ClearCBit) && MemEncryptSevSnpIsEnabled ()) { InternalSetPageState (PhysicalAddress, EFI_SIZE_TO_PAGES (Length), Sev= SnpPageShared, FALSE); } =20 @@ -998,7 +1001,8 @@ InternalMemEncryptSevSetMemoryDecrypted ( PhysicalAddress, Length, ClearCBit, - TRUE + TRUE, + FALSE ); } =20 @@ -1031,7 +1035,8 @@ InternalMemEncryptSevSetMemoryEncrypted ( PhysicalAddress, Length, SetCBit, - TRUE + TRUE, + FALSE ); } =20 @@ -1064,6 +1069,7 @@ InternalMemEncryptSevClearMmioPageEncMask ( PhysicalAddress, Length, ClearCBit, - FALSE + FALSE, + TRUE ); } --=20 2.25.1 -=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 (#81917): https://edk2.groups.io/g/devel/message/81917 Mute This Topic: https://groups.io/mt/86292918/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-