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 7C1437803CC for ; Thu, 22 Feb 2024 17:32:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=5U/qcRLD6X8vClkD12A6V6X7AzoPco6n6JwTCwgVDDc=; 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=1708623152; v=1; b=EKYzl7D9YXcYFczXnIdRL02WxZ2l3FBwundkTxiUyqDj4O4TPHxBtxqgLLLBBf7rGq+T561p SvJVlXltz+tDAshpgfwA3H3s33l8Id0+2VuGb2zXUhQ1K3UT2N0+Q7k9tRdSf1oOD55YnPDz2NC EG0T0yllRpydkzkC2rRH1i0E= X-Received: by 127.0.0.2 with SMTP id k0XMYY7687511xVXNB406Lzu; Thu, 22 Feb 2024 09:32:32 -0800 X-Received: from NAM02-BN1-obe.outbound.protection.outlook.com (NAM02-BN1-obe.outbound.protection.outlook.com [40.107.212.50]) by mx.groups.io with SMTP id smtpd.web11.18856.1708623151532179479 for ; Thu, 22 Feb 2024 09:32:31 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ci9m2A+FxZBfs7iOONzGTEdMX9BBU3SI3Uhdqe/Idz7KrcJt2mX5zb2AExd2BlyU5f9YCzYkXv2dYAcw7moyzAjv1+4FCOeAmskT/ZtYLpYhRbprycxtQQ2csEOz6I9+qt0sQ3ahJetexaS8L1GZrC2ykb9EqbdUzGTTw1s5QUGwffVPEz/H7IphgZZycuUAzyEyiluBtKozR/ZtBBnMGMsTURRQG5hLFnPTXfQ9SA3YJAPoHvTSV7Y43ZFJBjZLJRuR0oDezIC7z7Iju/WeTn83HzdMFyC7Qz16fJJoEgBfwXkNIjztRDyoHnoM27UYKFbAzS67/8K1WcI+pzzrOQ== 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=5/PHC75bVafApalyb8QhvoPhhB6R9YUSU2p0CkWV7/U=; b=n5hBTpMUcP7Gg6DtlbpWa/U5IkUSppKgaSrhOJeCu6NX/6frsTH2I2ZpRiEviNL5Yzwd7wJebH/fBJN9Yvwom31f/iEpr1r7YBH9uqGwpnjLYe67hTQOwqGG54o8lZm0qZMwIQKFYLfNB5172NY5zmIbHXM5FsoLig9mrcwnb31P/jht17fFtdMRujUztikPfF5ilyl55qUvraRFFcBkGOO1OVsq2PUe31lLuf7WwX1zy6DigK8qf0rxXTErXp63pkXYp6ZspvqHP9MAHvu7JMoD3WkjvMA3GgSO9bA9A7ysIuUwxt3XdYcf/sKiRbKwPdUrnrJHPUzyOktIb4DajA== 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 BN9PR03CA0046.namprd03.prod.outlook.com (2603:10b6:408:fb::21) by CY8PR12MB7705.namprd12.prod.outlook.com (2603:10b6:930:84::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.21; Thu, 22 Feb 2024 17:32:28 +0000 X-Received: from BN2PEPF000044AC.namprd04.prod.outlook.com (2603:10b6:408:fb:cafe::f1) by BN9PR03CA0046.outlook.office365.com (2603:10b6:408:fb::21) 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:32:28 +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 BN2PEPF000044AC.mail.protection.outlook.com (10.167.243.107) 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:32:28 +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:32:27 -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 19/23] OvmfPkg/BaseMemEncryptSevLib: Maximize Page State Change efficiency Date: Thu, 22 Feb 2024 11:29:58 -0600 Message-ID: <3b1a27c006158fb49a0229cb15622732db8b5905.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: BN2PEPF000044AC:EE_|CY8PR12MB7705:EE_ X-MS-Office365-Filtering-Correlation-Id: 5058dbe5-1887-42f1-082e-08dc33cc3e28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: S8OPpwO884267Mbz2Q3zLIdOUcosFpqijDAX1VtVMDdZ4DCgKH0gGBvuy9m0yeSrHevouRi0hdcNQtqmfh8sG4Ktv0E5uDDDXVbUYsAQfm0dO4F/y2gkeDMYFe+4e4bDKSND+Jh37MdnJIkfEFSpZHBd8cxzCIhsgraxazyGNm45m4VIEiS2k/JeL3G/aMbqTcCTpMysD3XG6JChF10rea7IxJBP4tOsARC6RKa3Snr8kGTNpYAgNqWwDOdiYGmsCYaE96CHfhck//lmkbE80Espj/LX16X/aoMo9YckUscsyew+uGuU8IBT0K2i2DaREOgFT2USMeBp4WIoCWyGcGdPrl3EhWNu2ce6bLzIAX/47d8siwKGCKbhEROV22eFuVSOpyW+2k4j3aywAkVkm3TIpLJiy6goaFZVFX+Q5oHX1y++t5yi14hSb0qlJz29WQzTBSvTqk91osrHBkSn5G97bbqKOnPeyNhkZqkyEz/f3cMSAeEbFVoV8Q/gCYXxFWEXQDYrf8WHtM5ETi5oFVkwppX6P1BDXrVNItNTlXQY0r8f+BWZ0Pvs24g+zr/LVGh7wtsayZyy78ZgIdlcRrMFIKHkoFDEuhqzXz+valOzq680ADpTS11JGBg7hYWjXrTwLpY1X116aaqIhQUx6w== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 17:32:28.8454 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5058dbe5-1887-42f1-082e-08dc33cc3e28 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: BN2PEPF000044AC.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7705 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: QtCk8IxMNKkKhjzxpuKEh2Nax7686176AA= 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=EKYzl7D9; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4654 Similar to the Page State Change optimization added previously, also take into account the possiblity of using the SVSM for PVALIDATE instructions. Conditionally adjust the maximum number of entries based on how many entries the SVSM calling area can support. Signed-off-by: Tom Lendacky --- OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c | 7 = +++++++ 1 file changed, 7 insertions(+) diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInt= ernal.c b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeIntern= al.c index 4e1225d12797..7060cd61b21c 100644 --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/SnpPageStateChangeInternal.c @@ -18,6 +18,7 @@ =20 #include #include +#include =20 #include "SnpPageStateChange.h" =20 @@ -78,6 +79,7 @@ BuildPageStateBuffer ( UINTN Index; UINTN IndexMax; UINTN PscIndexMax; + UINTN SvsmIndexMax; =20 // Clear the page state structure SetMem (Info, InfoSize, 0); @@ -96,6 +98,11 @@ BuildPageStateBuffer ( IndexMax =3D MIN (IndexMax, PscIndexMax); } =20 + SvsmIndexMax =3D (IndexMax / SVSM_PVALIDATE_MAX_ENTRY) * SVSM_PVALIDATE_= MAX_ENTRY; + if (SvsmIndexMax > 0) { + IndexMax =3D MIN (IndexMax, SvsmIndexMax); + } + // // Populate the page state entry structure // --=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 (#115854): https://edk2.groups.io/g/devel/message/115854 Mute This Topic: https://groups.io/mt/104512975/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-