From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.19968.1683883970065102154 for ; Fri, 12 May 2023 02:32:50 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=OgU65TE/; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683883970; x=1715419970; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gnHNi+ZTvAClOmHAUepf0lf304Ohs/P7uKJwnZVbQxE=; b=OgU65TE/7Gl1E7z2XZkKc46n5zewo2XvU45qsCNfX2eQv7xlOMkjl/8B 1cD4GPVkazWVfn36AUwCqWRuweBHVhPseu/0tgr3J/ZZpyHH2cbjmZfZw nS+JX8XzsPxWo1ceQiixbPlbbCRKxd3P6O/HPPL+hJuTbl1lkK9JDba9P pGZ3uOLDusQs9FdZ7r7TRpdyXee28AiSdON/faTNyCDPV9fPQjhfzzhCn 2E+R+F3NYbz9Zq3mk2haGbMneJVGpgUkBFJgkSdxFIjZzRb/+7aG99Dvu 97nj0319GZvALyPYaskaqfHHGmE31UKgpohuHVPoMTk/j12ECTk/Az/WK w==; X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="335267990" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="335267990" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 02:32:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="874340601" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="874340601" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga005.jf.intel.com with ESMTP; 12 May 2023 02:32:49 -0700 Received: from fmsmsx602.amr.corp.intel.com (10.18.126.82) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 12 May 2023 02:32:49 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Fri, 12 May 2023 02:32:49 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.109) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Fri, 12 May 2023 02:32:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UDc1h7uj11K7b+hRr/h+t7obnDplRXD4amn89a+UTnSfTjXmLwhn75HAXdgnYbcWKwfFkK6I3C5IexOfSuXiZn+c95ciXnkR2L8hHsWgE0Co42eiSEeSh4leiZW+4fNGwNOSRA3hsX3wiBl6Dk4qv2fNvD30A3LS4Hamc1yhBU3bA3Lc+KcN1xtDQ0IYBFHdScqhglfiGPqnvsRYRifpn0YkehRx9fc+dFTiJaeAFU8QCgpHLC+sDaTdBnNxTZpkUj/r3W6alELqKryQWSpm0dGgzzH6j2+63zTfphfPP3VBIonJPUDiZ4xt7w4lEqr4hljVZYYtfVWM8u2hvOxIdw== 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=ahOjXnxoJFBJ0hx1oyBH/FKpRqJd1/763JDSGytuCqs=; b=fpDqLz5c4EcBHLlhjlIMs6djMeI1P9EjDECJJ0MedxN9GOxAOC4ofBO/PcYWwbS/9eijU0bes+nmXHSuEzoVdEkVK91EWnt5FM5vDIdy6P8LkjjiEvrUq/aWR4JKFJdDNKOUiYr8Pijff72In84y42wpohxrMI4/X4s9mIfO+T3+7E91ZrB62W+auIaHBzAQMyr+aBHJGgi5jo2WL/vgzzFxF7WCj+b6bsoXVRvsw66hIGz9wj0bLf90+TXSbmmsM+yBhkvkE52z9lXMlKVy+ttlL9wirPVLHXyi1PYEGZY5QCevYJZtEIb4XTxxGtBLIf3gvAAmoQzMlQCIlbX9Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by MW3PR11MB4732.namprd11.prod.outlook.com (2603:10b6:303:2c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.19; Fri, 12 May 2023 09:32:46 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d%5]) with mapi id 15.20.6387.024; Fri, 12 May 2023 09:32:46 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Ke, VincentX" CC: "Chiu, Chasel" , "Desimone, Nathaniel L" , "Oram, Isaac W" , "Gao, Liming" , "Dong, Eric" , "Sinha, Ankit" Subject: Re: [edk2-devel] [PATCH v7] MinPlatformPkg: Update HWSignature filed in FACS Thread-Topic: [edk2-devel] [PATCH v7] MinPlatformPkg: Update HWSignature filed in FACS Thread-Index: AQHZg+99KrTKHDIbkkOvb5wUshwfoa9WX+cg Date: Fri, 12 May 2023 09:32:45 +0000 Message-ID: References: <20230511095959.562-1-vincentx.ke@intel.com> In-Reply-To: <20230511095959.562-1-vincentx.ke@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|MW3PR11MB4732:EE_ x-ms-office365-filtering-correlation-id: bef1ef46-ff5e-4531-cb97-08db52cbd7e7 x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: i/F+ccmjN8jzPz6PRIdx0Mn/R9USRRlT9PEs0hSEMe60/djZPrHIMfRo/tAboZ3Ofn2D/shwPqbihjhQpkCU9kSPG3B78ShLcW134Bhmoa1sMR4glcDhtYZw8DpNHb+TSCTWrz/LxEXUndeZskVyCem5+lyJEEYwR9cNOp+icSCohRyFYZyCGcp/gZSou9+n1D/cqAT5nk4wQrXmsbj6hhIQ6p0V/czdvmXcau4PpgkvvyohebzMGjjB90lG1ktNxxCNAkXGlL2bbPxBJmBzjG3R53Ee3ddZNWjefXjk7AsURDwWkaoqs3yQM8Y9diCtVUc/8YtNJc1yrFiTkLHWacEIYyKnFzKDzjeZN02zsIYue55ylOH9uaVSAZE53tu932uZUlAMC1Cfg7Q1LkSmt1YwuBriflPBMlyKJBKnIKypKdE/MLoxcC94yk+mCnl9qLJvbIESgXmhLmmo1+A4597o031REZpuB0ZGOcQwGsqY5jFf69xWkz/tvNdpYACFBYjtAYp4+OEiYm5Ba9TWkJpVSrD5N7TX3Pivxah9iU10RwybC5AiC23EiMcX+R89T7ohhm0Tms505HSLLM9th6n+kJgQjYvE0sEcJlYYwYN+ZbDc4QQxn6/SA6jvxmNl99sbpurXEOmO2swXBJIvyQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(346002)(136003)(366004)(39860400002)(396003)(451199021)(41300700001)(38100700002)(7696005)(66899021)(966005)(8676002)(33656002)(8936002)(5660300002)(52536014)(478600001)(316002)(110136005)(55016003)(122000001)(54906003)(82960400001)(71200400001)(6636002)(66476007)(66446008)(64756008)(76116006)(66556008)(4326008)(66946007)(86362001)(38070700005)(186003)(83380400001)(53546011)(15650500001)(2906002)(6506007)(107886003)(9686003)(30864003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?rviitFOXLZl+izFqfgkmXrc3y1MkJjXNFTM1vobGwZZnIcp8qTTsNOzMhN+i?= =?us-ascii?Q?A+r5wS4o6ZC/g/5BADDWaHkVp9L/8dyihId3kOqqNsRM8kNxxQVLrLo3EsaK?= =?us-ascii?Q?MF9x94p4wZZSEzM/qiJ6u5LiX41zLwfV9M5xtRMAerDI0FwLyQtGeIk/5B8k?= =?us-ascii?Q?KqZUx0J7XG0PlHXq3eGGaRa8wWBu5BZzouy0baDHuf0Ly0TRCY4PwZXGWOJU?= =?us-ascii?Q?J0/8DHmBmRP3G4mbgrfEwOdFb/noIWReUHSKvIR+I93HDcOC9ICACbSjST5F?= =?us-ascii?Q?NLcsCZCNqke934vNqWsXesfKdetcwO36/grxwyccrDofuTpFupxKocpO1PSK?= =?us-ascii?Q?NQafOXHSVWkG4ZgAIz7Lcl64ntmqfbTLElnc/dSBv8M1zDI0OZkr6V/pMXUT?= =?us-ascii?Q?LgE87iOS3RZNQIuf141OElHSFyNds7nsXur+I8bhnjRVNbyf9brcSTAjlnIi?= =?us-ascii?Q?+8mtjPPyqcNGCBcxFntNCSFy3REpcOVSvXzB3g/nWQw2NNSyDyw5bcLum/M5?= =?us-ascii?Q?mL7rK6/cRfyqNBR93MaPcxADhj5J+NrZGVQ4p0RI4sfNoN5qHi3f/CKLY5b7?= =?us-ascii?Q?zzu5C88P06w7sRr90lZo34W3cPGNBkJeroS/cHcv3l85EIwqe3uaCsoZJlNN?= =?us-ascii?Q?PL6qJ6QEf5ESNBTUsAZQ2b2dXOHppVzrJ2pn2DyXy+LwYH5pQyIVTamGtL4I?= =?us-ascii?Q?EMhSCSujddq72Z6m5pAkca/qACcHwKE/rP9deODASWe69R3hr7abPjRMHb9g?= =?us-ascii?Q?Z7CNQX2YxnOFnIppFsGIBXj39byYkw8fYVd8RBksLsvSalSDK2W2op74NH58?= =?us-ascii?Q?JPR/lo7gDUdcEbiNoBNNCRm2hFtBBoY2RCiy1wi4YxxEXVQJaVmqtE3935jt?= =?us-ascii?Q?GxZRmcYoPwXmgWOLCxrB3rIBUaWJ6GpIGFQlMzLwsrTyiHsqOCgNmTLrG7Zb?= =?us-ascii?Q?lUIz2AHfGneL/GXTeqVHjNzuYfzRpsSoLBTuTFpZawClcRW8duywNRJDgGEq?= =?us-ascii?Q?WywoDKwO1zU5kQww4WdRZyaaUtebdRkgUlacQF29VQFeGE9ca2zkNOEzHWqj?= =?us-ascii?Q?yTwpU96ARNcc/wQZfdsgL8sojEcbl6Lfj48V6NvPraGurx/q6x0bAT8uwvGz?= =?us-ascii?Q?HkFkh3wsR/HdbUs3kUH2h36Fnyux1CPSf31qRX2x6tdrY2KtlfAdqkbAzyVf?= =?us-ascii?Q?abDdOjui8jNXhiaEf9t6IqGp64LI3QtqkaDXpGs7wRhwFKi0zSnsPf+fPaqI?= =?us-ascii?Q?xAgLVRIsQDC/JswisZVLXzFn9DkokofmQdPqzd03dvw21MIf3n2BQAFr6BiA?= =?us-ascii?Q?cb+CWXXsO+Na2+BMgmbxg9+fYDP5ihxDI/Wx7/VtLdIDt2cfXAKzP9xNdfDJ?= =?us-ascii?Q?EbU6TGYxoSbr13Us/TyA4GakEP9azI5laZqpOqwJmmcraYGWBRzWcgK6vrAG?= =?us-ascii?Q?DtPodIohkW1YlknNL7i4pQgs15Rrm3AXMqaF2bsmf8cyxdIZItqRjMPGfJm4?= =?us-ascii?Q?6VGg6/NveI5lXTKXWf2qmPjZVuecu0mQ+4lu11gmL4TwOcHLM1eX0P0aHw?= =?us-ascii?Q?=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bef1ef46-ff5e-4531-cb97-08db52cbd7e7 X-MS-Exchange-CrossTenant-originalarrivaltime: 12 May 2023 09:32:45.6922 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qTLx7p7nRgl+3wACs9HAIIp9f0RqB8qKPoJtf0Hju76kK7iUilfkAVzi93xxuWp1nQZFCq8ANqQkTS+Iz2w8PQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4732 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of VincentX K= e > Sent: Thursday, May 11, 2023 6:00 PM > To: devel@edk2.groups.io > Cc: Ke, VincentX ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Oram, Isaac W ; > Gao, Liming ; Dong, Eric ; > Sinha, Ankit > Subject: [edk2-devel] [PATCH v7] MinPlatformPkg: Update HWSignature filed= in > FACS >=20 > From: VincentX Ke >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4428 >=20 > Calculating CRC based on each ACPI table. > Update HWSignature filed in FACS based on CRC while ACPI table changed. >=20 > Change-Id: Ic0ca66ff10cda0fbcd0683020fab1bc9aea9b78c > Signed-off-by: VincentX Ke > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Isaac Oram > Cc: Liming Gao > Cc: Eric Dong > Cc: Ankit Sinha > Signed-off-by: VincentX Ke > --- > Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 287 > +++++++++++++++----- > Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf | 1 + > 2 files changed, 223 insertions(+), 65 deletions(-) >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > index e967031a3b..3dca6f99f7 100644 > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > @@ -1191,98 +1191,255 @@ PlatformUpdateTables ( > } >=20 >=20 >=20 > /** >=20 > - This function calculates RCR based on PCI Device ID and Vendor ID from= the > devices >=20 > - available on the platform. >=20 > - It also includes other instances of BIOS change to calculate CRC and p= rovides > as >=20 > - HWSignature filed in FADT table. >=20 > + This function calculates CRC based on each offset in the ACPI table. >=20 > + >=20 > + @param[in] Table The ACPI table required to calculate CRC. >=20 > + >=20 > + @retval CRC A pointer to allocate UINT32 that >=20 > + contains the CRC32 data. >=20 > +**/ >=20 > +UINT32 >=20 > +AcpiTableCrcCalculator ( >=20 > + IN EFI_ACPI_COMMON_HEADER *Table >=20 > + ) >=20 > +{ >=20 > + EFI_STATUS Status; >=20 > + UINT32 CRC; >=20 > + >=20 > + Status =3D EFI_SUCCESS; >=20 > + CRC =3D 0; >=20 > + >=20 > + // >=20 > + // Calculate CRC value. >=20 > + // >=20 > + if (Table->Signature =3D=3D > EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) { >=20 > + // >=20 > + // Zero HardwareSignature field before Calculating FACS CRC >=20 > + // >=20 > + ((EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE *)Table)- > >HardwareSignature =3D 0; >=20 > + } >=20 > + >=20 > + Status =3D gBS->CalculateCrc32 ((UINT8 *)Table, (UINTN)Table->Length, = &CRC); >=20 > + return CRC; >=20 > +} >=20 > + >=20 > +/** >=20 > + This function count ACPI tables in RSDT/XSDT and return the result. >=20 > + >=20 > + @param[in] Sdt ACPI XSDT/RSDT. >=20 > + @param[in] TablePointerSize Size of table pointer: >=20 > + 4(RSDT) or 8(XSDT). >=20 > + >=20 > + @retval TableCount The total number of ACPI tables in >=20 > + RSDT or XSDT. >=20 > +**/ >=20 > +UINTN >=20 > +CountTableInSDT ( >=20 > + IN EFI_ACPI_DESCRIPTION_HEADER *Sdt, >=20 > + IN UINTN TablePointerSize >=20 > + ) >=20 > +{ >=20 > + UINTN Index; >=20 > + UINTN TableCount; >=20 > + UINTN EntryCount; >=20 > + UINT64 EntryPtr; >=20 > + UINTN BasePtr; >=20 > + EFI_ACPI_COMMON_HEADER *Table; >=20 > + >=20 > + EntryCount =3D (Sdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / > TablePointerSize; >=20 > + BasePtr =3D (UINTN)(Sdt + 1); >=20 > + >=20 > + for (Index =3D 0, TableCount =3D 0; Index < EntryCount; Index++) { >=20 > + EntryPtr =3D 0; >=20 > + Table =3D NULL; >=20 > + CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * TablePointerSize), > TablePointerSize); >=20 > + Table =3D (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); >=20 > + if (Table) { 1. if (Table !=3D NULL) >=20 > + TableCount++; >=20 > + } >=20 > + >=20 > + if (Table->Signature =3D=3D > EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + CopyMem ((VOID *)&Fadt, (VOID *)Table, sizeof > (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE)); 2. Different versions of FADT have different sizes. This CopyMem is dangero= us. And why do you CopyMem()? >=20 > + if (Fadt.FirmwareCtrl || Fadt.XFirmwareCtrl) { 3. if (Fadt.FirmwareCtrl !=3D 0 || ...) >=20 > + TableCount++; >=20 > + } >=20 > + >=20 > + if (Fadt.Dsdt || Fadt.XDsdt) { 4. if (Fadt. Dsdt !=3D 0 || ...) >=20 > + TableCount++; >=20 > + } >=20 > + } >=20 > + } >=20 > + >=20 > + return TableCount; >=20 > +} >=20 > + >=20 > +/** >=20 > + This function calculates CRC based on each ACPI table. >=20 > + It also calculates CRC and provides as HWSignature filed in FACS. >=20 > **/ >=20 > VOID >=20 > -IsHardwareChange ( >=20 > +IsAcpiTableChange ( >=20 > VOID >=20 > ) >=20 > { >=20 > - EFI_STATUS Status; >=20 > - UINTN Index; >=20 > - UINTN HandleCount; >=20 > - EFI_HANDLE *HandleBuffer; >=20 > - EFI_PCI_IO_PROTOCOL *PciIo; >=20 > - UINT32 CRC; >=20 > - UINT32 *HWChange; >=20 > - UINTN HWChangeSize; >=20 > - UINT32 PciId; >=20 > - UINTN Handle; >=20 > - EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE *FacsPtr; >=20 > - EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE *pFADT; >=20 > - >=20 > - HandleCount =3D 0; >=20 > - HandleBuffer =3D NULL; >=20 > - >=20 > - Status =3D gBS->LocateHandleBuffer ( >=20 > - ByProtocol, >=20 > - &gEfiPciIoProtocolGuid, >=20 > - NULL, >=20 > - &HandleCount, >=20 > - &HandleBuffer >=20 > - ); >=20 > - if (EFI_ERROR (Status)) { >=20 > - return; // PciIO protocol not installed yet! >=20 > + EFI_STATUS Status; >=20 > + UINTN Index; >=20 > + UINTN AcpiTableCount; >=20 > + UINTN EntryCount; >=20 > + UINTN BasePtr; >=20 > + UINT64 EntryPtr; >=20 > + UINT32 *TableCrcRecord; >=20 > + UINT32 HWSignature; >=20 > + EFI_ACPI_COMMON_HEADER *Table; >=20 > + EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; >=20 > + EFI_ACPI_DESCRIPTION_HEADER *Rsdt; >=20 > + EFI_ACPI_DESCRIPTION_HEADER *Xsdt; >=20 > + EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE *FacsPtr; >=20 > + >=20 > + Index =3D 0; >=20 > + AcpiTableCount =3D 0; >=20 > + EntryCount =3D 0; >=20 > + BasePtr =3D 0; >=20 > + EntryPtr =3D 0; >=20 > + HWSignature =3D 0; >=20 > + TableCrcRecord =3D NULL; >=20 > + Rsdp =3D NULL; >=20 > + Rsdt =3D NULL; >=20 > + Xsdt =3D NULL; >=20 > + FacsPtr =3D NULL; >=20 > + >=20 > + DEBUG ((DEBUG_INFO, "%a() - Start\n", __FUNCTION__)); >=20 > + >=20 > + Status =3D EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID > **)&Rsdp); >=20 > + if (EFI_ERROR (Status) || (Rsdp =3D=3D NULL)) { >=20 > + return; >=20 > + } >=20 > + >=20 > + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress; >=20 > + Xsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress; >=20 > + >=20 > + if (Xsdt->Signature !=3D > EFI_ACPI_6_5_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + if (Rsdt->Signature !=3D > EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + return; >=20 > + } >=20 > } 5. You doesn't need to check the Signature. You can check if Xsdt is not 0,= use XSDT, otherwise use RSDT. >=20 >=20 >=20 > // >=20 > - // Allocate memory for HWChange and add additional entrie for >=20 > - // pFADT->XDsdt >=20 > + // ACPI table count starts with 0. >=20 > + // Then add ACPI tables found by RSDT/XSDT and FADT. >=20 > // >=20 > - HWChangeSize =3D HandleCount + 1; >=20 > - HWChange =3D AllocateZeroPool (sizeof(UINT32) * HWChangeSize); >=20 > - ASSERT(HWChange !=3D NULL); >=20 > + AcpiTableCount =3D CountTableInSDT (Xsdt, sizeof (UINT64)); >=20 > + if (AcpiTableCount =3D=3D 0) { >=20 > + AcpiTableCount =3D CountTableInSDT (Rsdt, sizeof (UINT32)); >=20 > + } 6. No need to choose between XSDT and RSDT again. Use #5 comment to choose = between the two. >=20 >=20 >=20 > - if (HWChange =3D=3D NULL) return; 7. Why not return earlier but here? 8. I will stop reviewing. Can you please review within your team first then= send out? >=20 > + // >=20 > + // Allocate memory for founded ACPI tables. >=20 > + // >=20 > + TableCrcRecord =3D AllocateZeroPool (sizeof (UINT32) * AcpiTableCount)= ; >=20 > + if (TableCrcRecord =3D=3D NULL) { >=20 > + return; >=20 > + } >=20 >=20 >=20 > // >=20 > - // add HWChange inputs: PCI devices >=20 > + // Search XSDT >=20 > // >=20 > - for (Index =3D 0; HandleCount > 0; HandleCount--) { >=20 > - PciId =3D 0; >=20 > - Status =3D gBS->HandleProtocol (HandleBuffer[Index], &gEfiPciIoProto= colGuid, > (VOID **) &PciIo); >=20 > - if (!EFI_ERROR (Status)) { >=20 > - Status =3D PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32, 0, 1, &Pci= Id); >=20 > - if (EFI_ERROR (Status)) { >=20 > - continue; >=20 > + AcpiTableCount =3D 0; >=20 > + EntryCount =3D (Xsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER= )) / > sizeof (UINT64); >=20 > + BasePtr =3D (UINTN)(Xsdt + 1); >=20 > + for (Index =3D 0; Index < EntryCount; Index++) { >=20 > + EntryPtr =3D 0; >=20 > + Table =3D NULL; >=20 > + CopyMem ((VOID *)&EntryPtr, (VOID *)(BasePtr + Index * sizeof (UINT6= 4)), > sizeof (UINT64)); >=20 > + Table =3D (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); >=20 > + if (Table) { >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator (Table= ); >=20 > + } >=20 > + >=20 > + if (Table->Signature =3D=3D > EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + CopyMem ((VOID *)&Fadt, (VOID *)Table, sizeof > (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE)); >=20 > + // >=20 > + // Locate FACS in FADT >=20 > + // >=20 > + CopyMem ((VOID *)&EntryPtr, (VOID *)&Fadt.XFirmwareCtrl, sizeof > (UINT64)); >=20 > + if (EntryPtr !=3D 0) { >=20 > + FacsPtr =3D (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE > *)(UINTN)((EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *)Table)- > >XFirmwareCtrl; >=20 > + >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)EntryPtr); >=20 > + } else { >=20 > + FacsPtr =3D (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE > *)(UINTN)((EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *)Table)- > >FirmwareCtrl; >=20 > + >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt.FirmwareCtrl); >=20 > + } >=20 > + >=20 > + // >=20 > + // Locate DSDT in FADT >=20 > + // >=20 > + CopyMem ((VOID *)&EntryPtr, (VOID *)&Fadt.XDsdt, sizeof (UINT64)); >=20 > + if (EntryPtr !=3D 0) { >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)EntryPtr); >=20 > + } else { >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt.Dsdt); >=20 > } >=20 > - HWChange[Index++] =3D PciId; >=20 > } >=20 > } >=20 >=20 >=20 > - // >=20 > - // Locate FACP Table >=20 > - // >=20 > - Handle =3D 0; >=20 > - Status =3D LocateAcpiTableBySignature ( >=20 > - EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, >=20 > - (EFI_ACPI_DESCRIPTION_HEADER **) &pFADT, >=20 > - &Handle >=20 > - ); >=20 > - if (EFI_ERROR (Status) || (pFADT =3D=3D NULL)) { >=20 > - return; //Table not found or out of memory resource for pFADT table >=20 > + if (FacsPtr->Signature !=3D > EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) { >=20 > + // >=20 > + // Search RSDT >=20 > + // >=20 > + AcpiTableCount =3D 0; >=20 > + EntryCount =3D (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEAD= ER)) / > sizeof (UINT32); >=20 > + BasePtr =3D (UINTN)(Rsdt + 1); >=20 > + for (Index =3D 0; Index < EntryCount; Index++) { >=20 > + EntryPtr =3D 0; >=20 > + Table =3D NULL; >=20 > + CopyMem ((VOID *)&EntryPtr, (VOID *)(BasePtr + Index * sizeof (UIN= T32)), > sizeof (UINT32)); >=20 > + Table =3D (EFI_ACPI_COMMON_HEADER *)((UINTN)(EntryPtr)); >=20 > + if (Table) { >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator (Tab= le); >=20 > + } >=20 > + >=20 > + if (Table->Signature =3D=3D > EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + CopyMem ((VOID *)&Fadt, (VOID *)Table, sizeof > (EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE)); >=20 > + // >=20 > + // Locate FACS in FADT >=20 > + // >=20 > + if (Fadt.FirmwareCtrl) { >=20 > + FacsPtr =3D (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE > *)(UINTN)((EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE *)Table)- > >FirmwareCtrl; >=20 > + >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt.FirmwareCtrl); >=20 > + } >=20 > + >=20 > + // >=20 > + // Locate DSDT in FADT >=20 > + // >=20 > + if (Fadt.Dsdt) { >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)Fadt.Dsdt); >=20 > + } >=20 > + } >=20 > + } >=20 > } >=20 >=20 >=20 > // >=20 > - // add HWChange inputs: others >=20 > + // FACS not found >=20 > // >=20 > - HWChange[Index++] =3D (UINT32)pFADT->XDsdt; >=20 > + if (FacsPtr->Signature !=3D > EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE) { >=20 > + return; >=20 > + } >=20 >=20 >=20 > // >=20 > - // Calculate CRC value with HWChange data. >=20 > + // Calculate HWSignature data. >=20 > // >=20 > - Status =3D gBS->CalculateCrc32(HWChange, HWChangeSize, &CRC); >=20 > - DEBUG ((DEBUG_INFO, "CRC =3D %x and Status =3D %r\n", CRC, Status)); >=20 > + Status =3D gBS->CalculateCrc32 (TableCrcRecord, AcpiTableCount, > &HWSignature); >=20 > + DEBUG ((DEBUG_INFO, "HardwareSignature =3D %x and Status =3D %r\n", > HWSignature, Status)); >=20 >=20 >=20 > // >=20 > // Set HardwareSignature value based on CRC value. >=20 > // >=20 > - FacsPtr =3D (EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE > *)(UINTN)pFADT->FirmwareCtrl; >=20 > - FacsPtr->HardwareSignature =3D CRC; >=20 > - FreePool (HWChange); >=20 > + FacsPtr->HardwareSignature =3D HWSignature; >=20 > + FreePool (TableCrcRecord); >=20 > + DEBUG ((DEBUG_INFO, "%a() - End\n", __FUNCTION__)); >=20 > } >=20 >=20 >=20 > VOID >=20 > @@ -1329,7 +1486,7 @@ AcpiEndOfDxeEvent ( > // >=20 > // Calculate Hardware Signature value based on current platform > configurations >=20 > // >=20 > - IsHardwareChange (); >=20 > + IsAcpiTableChange (); >=20 > } >=20 >=20 >=20 > /** >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.i= nf > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > index 694492112b..f47cc3908d 100644 > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > @@ -128,6 +128,7 @@ > gEfiGlobalVariableGuid ## CONSUMES >=20 > gEfiHobListGuid ## CONSUMES >=20 > gEfiEndOfDxeEventGroupGuid ## CONSUMES >=20 > + gEfiAcpiTableGuid ## CONSUMES >=20 >=20 >=20 > [Depex] >=20 > gEfiAcpiTableProtocolGuid AND >=20 > -- > 2.39.2.windows.1 >=20 >=20 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D > Groups.io Links: You receive all messages sent to this group. > View/Reply Online (#104685): https://edk2.groups.io/g/devel/message/10468= 5 > Mute This Topic: https://groups.io/mt/98824282/1712937 > Group Owner: devel+owner@edk2.groups.io > Unsubscribe: https://edk2.groups.io/g/devel/unsub [ray.ni@intel.com] > -=3D-=3D-=3D-=3D-=3D-=3D >=20