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 D182D74003A for ; Thu, 22 Feb 2024 17:31:01 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5+qFg1EjiRUoYyLO8l4KhlKRx5lBz+k43UqlxPnGoiI=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results: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=20140610; t=1708623060; v=1; b=FBFJhaB/v82T9c/2zWsS7NqapXG3emu8ZSu8eXRqmf0uW74V7dAWK2+oykHf6mSe4otEz4Ys FtxNJd8BZIFw5Kxze7/wYJi0S68sC8y4pig04MffSRu8YpEQOObOG62zEIkluuQliX8HK2DtCaC neFs3E/ld8kMqnGeo71yV4A4= X-Received: by 127.0.0.2 with SMTP id cuNkYY7687511xCzclF1drV7; Thu, 22 Feb 2024 09:31:00 -0800 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.59]) by mx.groups.io with SMTP id smtpd.web11.18800.1708623059917538701 for ; Thu, 22 Feb 2024 09:31:00 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mWSQw3uewji/daq1Hdu1hbvKlEzQdp+4eGrNdy7faX3z6qycHCA7q0MyqSefDz1gmjSWbci+wEabSWJST+6boNYUGkDRfm28U64ypEoll38+uM/38Dka5/oKl8T5i5hNcHuOkjvWCRpiGTFR8jAy+THDjNFc2UIQHrsamyV+Pku5yNHslh0aXVo7OCKtulnXSN/NM29ZT2kak7vDJh4NIRjb3Qp2tIO/m7CD9azGaCIVVIH+RBam0OLzlD0A7svRBJqwTSGdQadYpN+3hTNPphOtpXu9+qOQ4RjrMK3srlL3/qeogYY/tVy7MTA4QXM08CpT4WPSQz46dLhP8gODVg== 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=Nqiouj3U5jXIkBUjpMSCBT1fxCCMKSMAhA2LYcL5ZPI=; b=Si7A59us03lnP/LaV/ElivZ8Jk5Xfv4CLo00/kS/CNfy46DEQ/EjKP9ewl9OZh86W/FhtIdUV7bQC5Td1LU1+5dgNGA7Cwk2B6kUoQ91bwKriMNn2j7SiFZELl6VOXpaXeXZ+Wn3X6pLeQmI0atCYm6Yp515Wut+S/AbNLi8k6F1YDT9zHQ3+N8r6ZHRn3UOADxyFsQ5xk9n1kvCKNe0i2cVIBqHFazXFLhlXN5YRURL+/5VWF+Nfp4GtdVUx6GAxmt5qSY9eYyQ0/JVsnaaMzE30Mqca6avwTLosf9RaD0Nele+N0oau95zWuTeyeJjKYUZhwijLm1m/Ls7ztT+zw== 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 (0) X-Received: from BN6PR17CA0053.namprd17.prod.outlook.com (2603:10b6:405:75::42) by PH7PR12MB9224.namprd12.prod.outlook.com (2603:10b6:510:2e7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.23; Thu, 22 Feb 2024 17:30:57 +0000 X-Received: from BN2PEPF000044A9.namprd04.prod.outlook.com (2603:10b6:405:75:cafe::f7) by BN6PR17CA0053.outlook.office365.com (2603:10b6:405:75::42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.43 via Frontend Transport; Thu, 22 Feb 2024 17:30:55 +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 BN2PEPF000044A9.mail.protection.outlook.com (10.167.243.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Thu, 22 Feb 2024 17:30:55 +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; Thu, 22 Feb 2024 11:30:54 -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 v2 06/23] OvmfPkg/BaseMemEncryptSevLib: Calculate memory size for Page State Change Date: Thu, 22 Feb 2024 11:29:45 -0600 Message-ID: <1dac1edcbe6b823602d808eb244dcdb12f043dcd.1708623001.git.thomas.lendacky@amd.com> In-Reply-To: References: 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: BN2PEPF000044A9:EE_|PH7PR12MB9224:EE_ X-MS-Office365-Filtering-Correlation-Id: 1dc55cc6-3530-453c-6cc1-08dc33cc06a8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: FMZ84cJeTa68cjqf2ejtVGUckesd5XlmGBLpxBQNozZ7rJhARxUeV+kEZ/IreRHgRsG+0a1dkfTd93yLuLRxS8E+c/Yzw/t91cR0huPu00/ti4bnQ1JQPCLbTOMg98DwFGkp3xBb/Ymf+/9P8t3nb/OiqdhmvCMpFU4tB9YfSd2WhwO5OIpjBUltdrdhRZhBizGQs7u5eB5dEMnDsMLMuuCMD5RUQyJb9P4HJldnzfO7lzEtV8J9suAm0i/kc3keHWjLam4rwTGASgCoYKhBQ7qI7F/gc5YyeYW+dAOy3xsvVNXJfkYIe0iBbrkodRyIZMrQL7GPlM22DXL52bwMfnD3ELGrdIuJWapSoX4xDM0alo1Vcl4jsBbVU30pfc7R4rc1htPGHlc2j+Dn0eHmFa2yl3mefdnUarB8hkkPbQyHp+MvD/KzQWV/eJMGrFMDh5Ev9a6yNzFYg7F9DM4PxTZDuCNnhaz76nZxNZpJHpWng2J84GSP7UYpHBNZJXo12wsYNg/S13ygvAMV+hzyEaJ5dZ879I4bxMJBbkEnDagSNWelReUvNklgSIlScFOfxPbSq4O3j0c4Ze5mYeyvV6Soiq3BTk0ICQzr3aFosZjw/j2q9xq/yPZjfZewmatbdPUJinGfIV4xJqWBX+QumQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 17:30:55.7032 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1dc55cc6-3530-453c-6cc1-08dc33cc06a8 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: BN2PEPF000044A9.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB9224 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: dybVSxP3oX8woHL6D3PYaOfCx7686176AA= 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=20140610 header.b="FBFJhaB/"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") 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. 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.42.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 (#115841): https://edk2.groups.io/g/devel/message/115841 Mute This Topic: https://groups.io/mt/104512944/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-