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 BF3AF9419F8 for ; Fri, 8 Mar 2024 15:32:33 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=lcvh7lC5gMAfXkmJ6Pt1yYXlnhD3FI+B5PUAOgF2u7A=; 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=1709911952; v=1; b=VzkULCcVYB6LtH3FBf5EK/VR2C0R5KLoPtPwAnsen3+W4SJVaSdSwGxVpkI5dvlVV76Dot4V ez9zrJpu2T9sGzqajDO03myyk/P2JgiLcZSR3rbckSSG90E7Nl6W8scS7kgtwRPVzcM0DKUSXcA roAJ/xnJpqvrkGV7Z579GKM39Spna/A7mZWQ4ldRJN06cjyCRMd5W8CLgPprT6Ks+3OuqhJB0eF hfSgUkaAd/saYmfjZZWwLvljzy7VVpC8o6uFZ8t2m0BGahjZOe+jaoE4whj5+nHQKOJiJLcTbV0 vL/SLGcYcANdfoR2mS/GgYblm80YZVB0icDUkrvLqrUYg== X-Received: by 127.0.0.2 with SMTP id DN7QYY7687511x5xj9seWkZb; Fri, 08 Mar 2024 07:32:32 -0800 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.47]) by mx.groups.io with SMTP id smtpd.web11.24891.1709911951817735985 for ; Fri, 08 Mar 2024 07:32:32 -0800 X-Received: from CH0PR03CA0054.namprd03.prod.outlook.com (2603:10b6:610:b3::29) by MW3PR12MB4426.namprd12.prod.outlook.com (2603:10b6:303:58::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.27; Fri, 8 Mar 2024 15:32:27 +0000 X-Received: from CY4PEPF0000E9D6.namprd05.prod.outlook.com (2603:10b6:610:b3:cafe::ee) by CH0PR03CA0054.outlook.office365.com (2603:10b6:610:b3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.47 via Frontend Transport; Fri, 8 Mar 2024 15:32:27 +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 CY4PEPF0000E9D6.mail.protection.outlook.com (10.167.241.80) 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:32:26 +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:32:25 -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 20/24] OvmfPkg/BaseMemEncryptSevLib: Maximize Page State Change efficiency Date: Fri, 08 Mar 2024 07:32:32 -0800 Message-ID: <42b81da4a10e46034d5d7cca2e135306358a0f84.1709911792.git.thomas.lendacky@amd.com> 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: CY4PEPF0000E9D6:EE_|MW3PR12MB4426:EE_ X-MS-Office365-Filtering-Correlation-Id: 31e9d717-d3b5-4160-823e-08dc3f84f589 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: OBFCSP6HZgHUVRJ9gymtehjEKkDVGeaRICV5Hqwc+gkRbgwn2mjkJa/CETPVWeupc27TzceTrZhpWW2qmFdDEBmL4MBmSfIKnX9+763IA+T+aLML8YwjbFoLqD/I3HF1i5zutt/zYeGWH9GyzAygRE6YUBv4+NqM+nA520Zl0MHF1cxh3MmurZAIcB2nQN1WjeXQ1ROterUKN+yTD4f7zPeSKjt9fPdl5ZyiCSchashoFIA23iFkOof0crkKWMsnsY4+wodDOs7nDu8fOdMnX1QA55EzBrcgoKCikmmUh2lXSzvNOT3DqEUGj3aZJvsSgMTjHZnvcfbJSuWBSa8R6Udzy2+XJMVmgE4jOu8tK5MRPn04GotnOOu37Eav4MArfeV+3BMFbGvmFPsnzp/3t2TN8qsl+qZo4TYX1nxJOHyNrNspNWpdfmYknqkNNU9eJnoJqdzbhDaJfGI0U9qKpCiLTqanz8PcW08AWPP/ven24SGq4z/0t0amKAfWsIGkfk09o0UESm6zg8aWdYaDINqWKCCB8Fl96sHSLQl7LJgErs9bzR73Yh5nAC/6Trcq5jkcemShYlNxIbnnO3BV0RERNnRsn5rK04DAaZgieyOXIQWtZyE2orT5yH9OUKQNrLcsNOfXGbrcRJkJy0yWuNK84vQ2Mko3TUuOQngfekZdAQygBypWUyztuvB91bRCJoHiAIjAFM1Js5ysLa82tw== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 15:32:26.6180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 31e9d717-d3b5-4160-823e-08dc3f84f589 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: CY4PEPF0000E9D6.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4426 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: 2LT31YLOx93dr2ERMAubczcJx7686176AA= 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=VzkULCcV; 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. Cc: Ard Biesheuvel Cc: Erdem Aktas Cc: Gerd Hoffmann Cc: Jiewen Yao Cc: Laszlo Ersek Cc: Michael Roth Cc: Min Xu Acked-by: Gerd Hoffmann 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 c8c0c4ef0e95..e073f3937c41 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.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 (#116545): https://edk2.groups.io/g/devel/message/116545 Mute This Topic: https://groups.io/mt/104810737/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-