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 1E4917803D2 for ; Thu, 22 Feb 2024 17:31:08 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=iBE4QFPL6HG3cvMvBu4d46NF7QE9MZ8ipB4shT20crA=; 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=1708623067; v=1; b=N9Eao0MugOJIUZXyeYQ2gul92xLawpjI4M5gMMujAVf6T1+CAj4jWi3Hjqv2BJL76uQP5nX/ F8McYvk8NsB3wVaWxWyj4k0NykxlrJ3ZuB0bvHff2ZLEjx2dDoeBfd4479Dg1hWgyTay3wt/+1A DKruX7RPFMD7HOi0V7c+MMaA= X-Received: by 127.0.0.2 with SMTP id o9taYY7687511xRebJpaltmt; Thu, 22 Feb 2024 09:31:07 -0800 X-Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.107.220.72]) by mx.groups.io with SMTP id smtpd.web11.18804.1708623067078672092 for ; Thu, 22 Feb 2024 09:31:07 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VSxGc4hyOZk2QbYg11qXN+BN9BwomOwa9Iu/s5TiVaad7fS8crZRULmCybckChCnI3mxIyxJgjCsh+sGM+XNwWLdSANYlZv/UtUqswn1DYcc2rh9+yXOwXcSJw5FRPLcQUw8c+Iyd7WwqD7I62Wtfyv6sJ5uxkCs5T6wX4bPky2Ien63cgYi1kTZrmRHbr/FIuk403mMzMWjhRPOv/wOo9MiNA90w27/Rwg6L21KbAy8dkEiNHxGA3LFfm0Vb2EsrOL/69K5GcD642h+kB+O767mlDVQ3LWkXommjHC/cGeo+c7gRQibGRS3frzeID43o4ArsUNL1QGufLhI4msyTg== 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=zIu+/8A1Uyg0JD+oimk+32cMJd6/Q+VsL582C1WOTuE=; b=oSxg5EFfAnwKg763mZgR6fC0NwXPKRG0tpSwXpL1N0ABo3563wSZS2149pfIMOCSAuTKri+FCv11LZ6wY9XBUIJs8S40fEQ5TSGnwn4GrhudHvBD1+wggm/F2dZt/2SDA8p8VTDnmwTn/Q/rqe7lhdKduqO9EtJHvrX9Jlg4qQNzZKGnX7QIymcHJvnOSEAGOqYjhB+Zp6xP8QhrPDXUgoHoZ23jdiWRMprp+uxX/+Rl1xWXUNaVWY6KVYkWdU3x0EZCqVH8W7DGAlWYp9yBHp8zMrCUo4SgReZA38rF/7g343Egg66q0dkJc+GTV1uWvHH9it6ZhdML/l3+kljeLQ== 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 BN9PR03CA0676.namprd03.prod.outlook.com (2603:10b6:408:10e::21) by CH2PR12MB4280.namprd12.prod.outlook.com (2603:10b6:610:ac::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.22; Thu, 22 Feb 2024 17:31:03 +0000 X-Received: from BN2PEPF000044AB.namprd04.prod.outlook.com (2603:10b6:408:10e:cafe::91) by BN9PR03CA0676.outlook.office365.com (2603:10b6:408:10e::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:31:02 +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 BN2PEPF000044AB.mail.protection.outlook.com (10.167.243.106) 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:31:02 +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:31:01 -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 07/23] MdePkg: Avoid hardcoded value for number of Page State Change entries Date: Thu, 22 Feb 2024 11:29:46 -0600 Message-ID: <01099a06092b17a9866d813d22ea46a006dde3f7.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: BN2PEPF000044AB:EE_|CH2PR12MB4280:EE_ X-MS-Office365-Filtering-Correlation-Id: e5ff8d6b-d52f-4f1d-320c-08dc33cc0af2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: PQ81dF3yYxcS83vDUg1X2me2QlLJT0ARtN1ZQMzKazTChbehBgq5kpjHWcX6FQuyqbVhAI+NL87++JuTIgh3HTUUOMCadGGgWZtz6rz8TJKZQew/fwGBH2tcaVSdILNGub7mVELotOn4B8CtLzkyc7+/AuHY1O4/bpTn67nC8MjdyhEqWpUF7j+FrMYtsMgrpKM+rY30zXtUtxLLCsZzNgsPwfmZZ2JtKrIDoVfFDfGivU9vsqOW8x6pG1kKF0Jm0TfLqJ9gGIy7AfyxnuB8xprBYIuaCsPU9PDpMK0WloQXXfCLDzENRL+hiREfqlnUYCUUZXhMxbvxWB/pu7O6KGbLhp9ButLdwLf563THjeUvuKNxh+EbB4IiEgOiK6QoERJ5NxruAkAOeys/vwBmoBG5e/pxb9qsEYzI4YVxeWjsmEMBYktnIeQo+zVHjqkX2DR+zMSNpliESqRPqtYMEl7h0YSZqKht2aSyLMMl8TNrg3XvVYF/ynH2Vi9hnqcJSSzysYjvpC2QjCcIrCZ/27ZKTFISSNE1ykMQuEk0chswcIQ0PKB4XQd8E7WvZm8O1hr/fyySqrhdIEiTib4oBCYzjaS63fMjSdCir3T3fQpj3Cb8P40RJnvQR3VQDLcyXqSTy/zaAFHwXc05dHeSpg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2024 17:31:02.9288 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e5ff8d6b-d52f-4f1d-320c-08dc33cc0af2 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: BN2PEPF000044AB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4280 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: 4XsLAH1u0vVh7uu0IdKTyuVax7686176AA= 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=N9Eao0Mu; 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 The SNP_PAGE_STATE_MAX_ENTRY is based on the number of entries that can fit in the GHCB shared buffer. As a result, the SNP_PAGE_STATE_CHANGE_INFO structure maps the full GHCB shared buffer based on the shared buffer size being 2032 bytes. Instead of using a hardcoded value for SNP_PAGE_STATE_MAX_ENTRY, use a build calculated value. Since the SNP_PAGE_STATE_CHANGE_INFO is used as a mapping, eliminate the hardcoded array size so that the structure can be used based on any size buffer. Signed-off-by: Tom Lendacky --- MdePkg/Include/Register/Amd/Ghcb.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MdePkg/Include/Register/Amd/Ghcb.h b/MdePkg/Include/Register/A= md/Ghcb.h index 432d67e3e223..0cdc00627472 100644 --- a/MdePkg/Include/Register/Amd/Ghcb.h +++ b/MdePkg/Include/Register/Amd/Ghcb.h @@ -197,13 +197,14 @@ typedef struct { UINT32 Reserved; } SNP_PAGE_STATE_HEADER; =20 -#define SNP_PAGE_STATE_MAX_ENTRY 253 - typedef struct { SNP_PAGE_STATE_HEADER Header; - SNP_PAGE_STATE_ENTRY Entry[SNP_PAGE_STATE_MAX_ENTRY]; + SNP_PAGE_STATE_ENTRY Entry[]; } SNP_PAGE_STATE_CHANGE_INFO; =20 +#define SNP_PAGE_STATE_MAX_ENTRY \ + ((sizeof (((GHCB *)0)->SharedBuffer) - sizeof (SNP_PAGE_STATE_HEADER)) /= sizeof (SNP_PAGE_STATE_ENTRY)) + // // Get APIC IDs // --=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 (#115842): https://edk2.groups.io/g/devel/message/115842 Mute This Topic: https://groups.io/mt/104512946/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-