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 79502D811BB for ; Fri, 8 Mar 2024 15:30:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=C7tKTjgmM3xNP3eVbBCdyZ8RmZ+xTnSGIh65ukDA90M=; 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:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1709911850; v=1; b=oVBD9HHdiqSUAK22e79F/PZXnqG9hFplH8LKqHYimUeschnD/c464hQcDWDJ/AEvdkbf50ZP 8c6unCfpx50tnoOYoIceX4loq9lQvguw6rEfTfmtbAJdwobHpbP26ZzD0aAfG0fi39t1Zb61dsE 7md3Qw6jNUwzavbNmRznU60pNailyG4fR1V4K1sg4WMWTguDbqMWOyDqa0ztcRtBx3zrMfw0hBC 4qi5PTEANY1k7Ac1iv+dOK/TpLY4LoFG61y7cc/cUTRUTSj+JebAms7id3itGUr5mx+Zzjs47V3 gnbZTxWyUkof1pKIRA1I+B6LEpNf+khNHpdUVvcSnFTJQ== X-Received: by 127.0.0.2 with SMTP id xUbGYY7687511x016rgxpTgd; Fri, 08 Mar 2024 07:30:50 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.75]) by mx.groups.io with SMTP id smtpd.web11.24832.1709911849453841142 for ; Fri, 08 Mar 2024 07:30:49 -0800 X-Received: from CYZPR20CA0015.namprd20.prod.outlook.com (2603:10b6:930:a2::9) by PH7PR12MB9065.namprd12.prod.outlook.com (2603:10b6:510:1f7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.24; Fri, 8 Mar 2024 15:30:46 +0000 X-Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:930:a2:cafe::a8) by CYZPR20CA0015.outlook.office365.com (2603:10b6:930:a2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27 via Frontend Transport; Fri, 8 Mar 2024 15:30:46 +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 CY4PEPF0000E9DA.mail.protection.outlook.com (10.167.241.79) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7362.11 via Frontend Transport; Fri, 8 Mar 2024 15:30:46 +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.35; Fri, 8 Mar 2024 09:30:45 -0600 From: "Lendacky, Thomas via groups.io" To: CC: Ard Biesheuvel , Erdem Aktas , Gerd Hoffmann , Jiewen Yao , Laszlo Ersek , Liming Gao , Michael D Kinney , Min Xu , Zhiguang Liu , "Rahul Kumar" , Ray Ni , Michael Roth Subject: [edk2-devel] [PATCH v3 06/24] OvmfPkg/BaseMemEncryptSevLib: Calculate memory size for Page State Change Date: Fri, 08 Mar 2024 07:30:49 -0800 Message-ID: In-Reply-To: References: 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-TrafficTypeDiagnostic: CY4PEPF0000E9DA:EE_|PH7PR12MB9065:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e4b3bda-0031-472b-d93e-08dc3f84b9dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: y0cwupW7YT3Yrf6VohgYLhN6UT8Dtz1QWXHNfZ33roP731KC2XMZXEPTBHVmNpnsK0HMY3s+VWU3AvwkFZn2DygiKSSyF+KrnSzl4bFduUzanwWIfpjejdH7qF6ga2wn/yE22OON6DMKY+AUQboWEzo0poyVfs+bjTjm00k5+bNe2EAcmYK2x9bjMjWbO/0ucchLZCQHdCuxt43w0LL5PccM6PNcrLds533spIeZKYzq5vJweZ47KHMfjO0HufR5P/l1TkKGV3sPmwkLrDyywrUtV4s8XD4+49jJknxY6EA2R39bGmdId57XThknhmr1upWf2snSv0PutJQL5yROkGHmq38Q97crR4Lm3IJ1cE2TCg2uAwyaL1VEt8n88mbKEIOf9pqfGA9eDumQkXtBwXiYtDD8z7wMFt9VSyIaoOn+2DVOXx/AP4whjN0SDYqFi7TntEcxUwjgkYpG0fcS0WfQLZWfTm0WNsqvSDtbtBiSuHYC2t7/7P+2m2teGprx3j0hDMlA5L9FhCC5JEKjL00DGZvyLXQilT/DKQJtDSz6PnAc4V0abNphlRMDqdmLwYBdeOw6s2c/6iV1KGNsCicblevqEl9j66fkywlDQ4sTWe0PrGdaSKLhRpKmTWMVUffUHWpvCQ8Cof8VkFwbvlxQnaxA5hf39dNZI7vZWflemRCBjM8CQ2hHXjyLtwdp0ThfLjpgcQZRmxzVOJJ+/A== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 15:30:46.5165 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7e4b3bda-0031-472b-d93e-08dc3f84b9dc 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: CY4PEPF0000E9DA.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9065 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: LycqRBojoRG3CsnqnUVNr9qpx7686176AA= 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=oVBD9HHd; 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=pass (policy=none) header.from=groups.io BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 Calculate the amount of memory that can be use to build the Page State Change data (SNP_PAGE_STATE_CHANGE_INFO) instead of using a hard-coded size. This allows for changes to the GHCB shared buffer size without having to make changes to the page state change code. Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: Jiewen Yao Cc: Laszlo Ersek Cc: Michael Roth Cc: Min Xu Reviewed-by: Gerd Hoffmann Signed-off-by: Tom Lendacky --- OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 12= ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInt= ernal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeIntern= al.c index 6a11adb06efb..60b176ab14b8 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -133,23 +133,26 @@ BuildPageStateBuffer ( IN EFI_PHYSICAL_ADDRESS EndAddress, IN SEV_SNP_PAGE_STATE State, IN BOOLEAN UseLargeEntry, - IN SNP_PAGE_STATE_CHANGE_INFO *Info + IN SNP_PAGE_STATE_CHANGE_INFO *Info, + IN UINTN InfoSize ) { EFI_PHYSICAL_ADDRESS NextAddress; UINTN RmpPageSize; UINTN Index; + UINTN IndexMax; =20 // Clear the page state structure - SetMem (Info, sizeof (*Info), 0); + SetMem (Info, InfoSize, 0); =20 Index =3D 0; + IndexMax =3D (InfoSize - sizeof (Info->Header)) / sizeof (Info->Entry= [0]); NextAddress =3D EndAddress; =20 // // Populate the page state entry structure // - while ((BaseAddress < EndAddress) && (Index < SNP_PAGE_STATE_MAX_ENTRY))= { + while ((BaseAddress < EndAddress) && (Index < IndexMax)) { // // Is this a 2MB aligned page? Check if we can use the Large RMP entry= . // @@ -265,7 +268,8 @@ InternalSetPageState ( EndAddress, State, UseLargeEntry, - Info + Info, + sizeof (Ghcb->SharedBuffer) ); =20 // --=20 2.43.2 -=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 (#116531): https://edk2.groups.io/g/devel/message/116531 Mute This Topic: https://groups.io/mt/104810694/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-