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 51D0194169B for ; Fri, 8 Mar 2024 15:30:58 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=wO5ulyqy905XKgPzl9pDAJgIvxBOUiilVb8R0H0Du9A=; 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=1709911857; v=1; b=eDYua1lvAWL6lS1JDPYhoBEnsye2N7eiYZvXv9m+b0yjeBZ3l1ig1Yx5M/cWMnpMw8ZVWjvJ Kgc1vSCwAav1cPqtCsmxpJ0m+A8U1jm5MvQTpXH4MGEHUFczTJbdmpfkqvPzP8Z+IwM9xmZJO7v b0ks2iBAP9z3iAu+UW13p835so40d8w3nJhsNrkqpkZfVpw+7dT6UbF/DdFBc8+cEMSthfzH69m VoxLUs0Gb0Tb3JDOL5f8rl+KTvU9EfiiuN6G4ANVKKiLhlZst1V/z8X2N/sjD+DRTJ6TMNdAq7Z NHgHgh6+W2YGr/CsHimQO9EhTBoc3Snek8nmh5Douvisg== X-Received: by 127.0.0.2 with SMTP id tHi7YY7687511xZ1QCCitCrC; Fri, 08 Mar 2024 07:30:57 -0800 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.24777.1709911856374155604 for ; Fri, 08 Mar 2024 07:30:56 -0800 X-Received: from CYZPR20CA0007.namprd20.prod.outlook.com (2603:10b6:930:a2::7) by SA1PR12MB6752.namprd12.prod.outlook.com (2603:10b6:806:259::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:54 +0000 X-Received: from CY4PEPF0000E9DA.namprd05.prod.outlook.com (2603:10b6:930:a2:cafe::15) by CYZPR20CA0007.outlook.office365.com (2603:10b6:930:a2::7) 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:53 +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:53 +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:52 -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 07/24] MdePkg: Avoid hardcoded value for number of Page State Change entries Date: Fri, 08 Mar 2024 07:30:56 -0800 Message-ID: <6cf14525191bb48c1a4cc54bc5b6db08b0810e9e.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: CY4PEPF0000E9DA:EE_|SA1PR12MB6752:EE_ X-MS-Office365-Filtering-Correlation-Id: 9582d08d-5630-434a-cf26-08dc3f84be20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: IKmQtsX2VK/n1WPLQqJ8OxJtgd0s/KiVx/6PHIqTwC5iJ9MDb4M4/0RzOWjP7jqBCh+KWn33VtBi51c0uvEP5jSJhhLyZocA+u04LMM05XprpgZ7IWYd/z9Bhdaw5VTblhZSEAFFPrg73EFpF550ouHq4w/qHQaZJgWzl2WHEnN+lKDru1HXSIuSGdL/4/T67DMq8YUasSqQlyNN1RgiCz/UklxX84f97+cEnVfbu+VkzHhA9HlQn+SaT2RMTnDvw+5ZzDJPyI15/awkUR2vpHxtBWnaplYaPENfNuhDhX+gmBKXIbzEVjOlh1A+WwVZNni2C39UnEcsdBUzJWCvPFcC0vaaibf74Ty8NKNWweKvUO/HiocYPO7gy5+XFJic4bb6omb64qvK2xfSFb+F3OfwGHX2a3fdULNaS+71Wp2HPOA3jXVgdY9+e1Ett6C5MoknZV73IMuXRwICVSxkks+Hyn0eauCeOth9GnwQSw5VRIJSJdfvWwX3JAsVOvANgRs8UTxwVCy9nwoYQaTRVyIy2r8rKC+P+jQGVRNYK30DRCEEw1ZFY9nTnAz5mF2qtqLL/q/UixABa1a3eQ7FRTXnvQIW0rmA6vCq7n30syERULymwzmG60dcjoF/4C/IzSa/hUze0UntAhZTU18YSfV4X8wktl1vC2rFT6JDdEs1dCd4Qepvs+kIXoQZKfo7BwE10qQuDbn8Vv+LG7RtQg== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2024 15:30:53.6728 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9582d08d-5630-434a-cf26-08dc3f84be20 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: SA1PR12MB6752 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: cSSaK0gYlbMEJjkUK994vXkpx7686176AA= 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=eDYua1lv; 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. Cc: Liming Gao Cc: Michael D Kinney Cc: Zhiguang Liu 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 bd7bf986d03f..ae1486b526a6 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.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 (#116532): https://edk2.groups.io/g/devel/message/116532 Mute This Topic: https://groups.io/mt/104810697/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-