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.51061.1683776558969849395 for ; Wed, 10 May 2023 20:42:39 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=OLxaWVaG; 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=1683776559; x=1715312559; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gi9Km3GcOIWTubQ0pvU8vdKmwBoDczf6EkJDenRh6W8=; b=OLxaWVaGmUHJf5a9767wSqMQWEqSqF+iAWhm7OQQtT6JzeN3NHktA4o0 eJEUMngMbZhW1Mn1WSsjMPJ6P8DucJkI7RzwBfTBT2InnVvmia9bsekg1 LraVlmcQuAonpFD7lpVjmBBlA4c5BpkubDCY7eY/RnO7Z2yOCxXClNaey +8W8t8RsN8tNLnt8H1Q1S3cjfEetzVIIh8S2HJZKezqYqgHHt+L30mRrd lk7j+jMynobYheN2HwYLygeHcvGufnQ3+zBM71rNcpnZOMsAONBtO2pqV fYmsLwyuso6WflBEF+A2RSzqXoqHhAE1S6K86mOlNbTsPWAEf/OtuGjtd g==; X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="334858985" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="334858985" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 May 2023 20:42:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10706"; a="699547758" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="699547758" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga002.jf.intel.com with ESMTP; 10 May 2023 20:42:38 -0700 Received: from orsmsx612.amr.corp.intel.com (10.22.229.25) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 10 May 2023 20:42:38 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX612.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 10 May 2023 20:42:37 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Wed, 10 May 2023 20:42:37 -0700 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (104.47.51.44) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Wed, 10 May 2023 20:42:37 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKNbeWg45Wvh2j7+kJD60eBKzNCwN/PSDE06ldQ3LOQ8Zy+7Z6MEtrnpsd+L60FyeXDGhe/AmpLQRB3weFybeQH7oLx3289882t+4/uBgyeL2ES2mdT6mTUXSCgDQsT45n5p4/MoktVkr3QFVwZGjssRW/Db6xT3pfkTASFejMw2X0Yc9lYIcSfr1rqFvsdjNc4Jays59iqI98IqbZ4xUBnyBEvbM87GcG4SaODEy9RDTxCm4cieneWl2kYa8kAdlHGraeJT1QchOjpByWPEV35udoZJljQevjh3ETjmh/ZgGgQElRkLo/csYG8LdN+3TXK/9sTVF1EknPVH1tHKjw== 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=WbK0HGpPmwVD7bnrpy9x6FL7HBrBg2RMu2cycVVo/Jw=; b=gMnUdW72Fq2hz3Oh5l6WFCGNt7GwBn+o8mEv6gRUTv8FnNfupIZpWdwSsS5F3fGiOnviqqr4aUyttcYuncKVnsQPQt+daAwZ+nNAHiGzSnKEq0XGc10V1oDxb4K8D5VsYU8zNoza2UCxLUsAvbLA6/nMWP68VrxtKz1bV2q50MBv/HKof0/pobc1vxgyniPCucBdSVMKDcFiWbcytMR+PfnUKHMm7fKeu85AbEni3Lc4iWhFtbpFtCGIcxXrEqE6n/tEhJBhtoIItSZRkdhq8PG8qFmfN0vCmJNf1kvXfghgbBcAkzjYVxSR+QRsJD8C5YUK8h8PTcvSDJfASD+6Gg== 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 PH0PR11MB7496.namprd11.prod.outlook.com (2603:10b6:510:280::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.31; Thu, 11 May 2023 03:42:27 +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.6363.032; Thu, 11 May 2023 03:42:27 +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 v6] MinPlatformPkg: Update HWSignature filed in FACS Thread-Topic: [edk2-devel] [PATCH v6] MinPlatformPkg: Update HWSignature filed in FACS Thread-Index: AQHZgyYDsIJp9UFmBUiG/+1yM2WXba9Ubf6Q Date: Thu, 11 May 2023 03:42:27 +0000 Message-ID: References: <20230510095815.575-1-vincentx.ke@intel.com> In-Reply-To: <20230510095815.575-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_|PH0PR11MB7496:EE_ x-ms-office365-filtering-correlation-id: fdd0e60d-d54c-43a6-0af3-08db51d1bdc7 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: rZ7tZA1llxR8eqALcXoNPBav8ErDDuQWwfeKaBwvz0tM1FLy6J93zVBDTJmXd7z0jttyttTjTmIYoUodVCfQAGA+bMlilnXuLxFbLvgyATZv1JOblW+mjmsXVCZT5VpArSHOXmWQeQbyjzT6xYi2AtvzDrq4sCR8QGBRWygPuazNwb0fuuASzi7ZWnFMMDYzc2qARLUIvUyqs73PubVSNmfEIMmhiDT2ZMTo24lGA5KZHJPYoe67lsBj/QlN532oOoYW6pphY1er9ubB8qCoW9NF1eUTWUeEDsl8FoDIf9SeWepRs+YA7LsMIOto/hf0CauTWtguLIAqLaSUmWyFTubokkze8jfCPcmpP/SAQXsfbBWMEie7UdGNUUHJRtF5VgDtMOU3rNIaH5hmSmbwgiEYW6uQJK2wvmRgCCwB2MfCFthqcBaA9z/mbxq6TSDZ8awGItE8odOQ0k29NOgBx6P3EIuIl8YU6K+fAueoVwJgSi1tJGzPT2Xm0jC2a4fzb/26/Lwgc1sJ0Bl7gWVEXG4ToGfn0WsTz+JiRM4l+n0CMHhR6IZkNNBnrlLmq9uaICumriWjysV6F349nkR685ZYDpvRXhdBEAncHawS+v1ppsRsOEYyiY6pInV+CnR2arDa3BJeoMZYb8ET74FilQ== 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)(366004)(136003)(396003)(39860400002)(346002)(376002)(451199021)(66899021)(966005)(33656002)(4326008)(86362001)(66946007)(66556008)(316002)(76116006)(478600001)(6636002)(66446008)(7696005)(54906003)(110136005)(66476007)(53546011)(64756008)(83380400001)(9686003)(6506007)(107886003)(26005)(52536014)(8936002)(30864003)(41300700001)(15650500001)(5660300002)(55016003)(2906002)(38100700002)(122000001)(8676002)(38070700005)(71200400001)(186003)(82960400001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?ItcY3HYDhbHOQHwQbrwgiyjezPb7PExi6qMTFdQXI1f0jp/Fyyv2Q2HN2kQO?= =?us-ascii?Q?o3jc7XsOTfk887BpLUDTBbRq9oV4KEGVphMot2CTbwlSrhkS/mD+peFlCukf?= =?us-ascii?Q?q8Vnz8VwBISBOOn1K/ELsWIIfLQC4JOmuKesY/0PXFwkRW/2KVm7Z+PHL5Ge?= =?us-ascii?Q?XKJXTE0tlyCqChmQKnS+mG0S2KX33AgosfInn1gzXWaMU6WAs8HPHdel0F2S?= =?us-ascii?Q?5wdIEvTZzmpZ/NqgPTiy4Q3gT+mdbUOxleX7zWj1v20ItVUcvYNh5EZxZwBr?= =?us-ascii?Q?ImRtQ5ePmQcEJ3CuzQq/ebeqbO0/pEF2DiqKi0L7rtvTzT2RtcHsjHXhMk3i?= =?us-ascii?Q?RC6NPEmdL94GOIZhkopXRFT8VjLuqyBLCbEgOKqvD4rF2RQbhhydBVeVwV8x?= =?us-ascii?Q?nT1Z8xYSFZo1n60gr6lCEPeAz+2E1pH7PoZW3B0ynx3MclDSaKp+EE4YM8ZN?= =?us-ascii?Q?t9p+dC3UK+MH5h+UfpZO6zTFV9iK2T/6fC7HKd9DTCDptskEl8+xN/Fg1GP3?= =?us-ascii?Q?HAmZsRQUsjkxC8OohaoQoRm7XBujKrm13Cj+Gw9c/hpoV6l5UaeFmhv8bObH?= =?us-ascii?Q?4NeZZMFWrJyJZSeZbyxd86RdqI4LalgW+TTETFP5Ey/JLevPk2g8MlySgB27?= =?us-ascii?Q?jKf5xl16qWdidHcK1Mc2g1exAkNO9xnutp1KEzhoK8DCMCOSjxbVakZ+Uyy6?= =?us-ascii?Q?OYu7ZHMNtnDMycpRDxDrv6Zmle9IcLzTkUiGFUADR3CA+hmjEb8iZ9p/AauU?= =?us-ascii?Q?0wwW+DuWbWW90PyF97mZAMTgpbZ23po/wLW8SqXjsmkbF9eHBk+rDLRNsdR7?= =?us-ascii?Q?8iMqbbyfomVSQ0RJKhk5psSddJ39TDGHhZFSlS55Q3tUkKS+FyPBAcdra59l?= =?us-ascii?Q?BGFtMQBC6Rdid9NXpOoSv5ff7E2uWONajkAppW/gVSMdp/XkXXv66W4pZL6d?= =?us-ascii?Q?7hDRdg20F3B8X0t2rtfTDKssP6YAqa1QZmkHvSo0kfSUPz4bJNYPFNtNHNNO?= =?us-ascii?Q?5iExrt65hvQs9IoBdNrkcw0cnP1k8Vssk/oVnbqpHLz5M1BrL4PWr4TKa6eY?= =?us-ascii?Q?9V9SDXKnIVxbK6Yx1RNPGR0fRsSBoqzXV93vO+pz3HwdNNxf0qGI86V4cWUH?= =?us-ascii?Q?h8DJLDvvZpJ5j4eQ590oMRDDYnoCFVCa1AFKUOWvcErzZjQuL8m+pc5mqjVl?= =?us-ascii?Q?iTWI8ZVjVnMDx/JLNM9SwIDq7IvcX5xdWmf1w+xa7SFJ/3b6iO/Hea0Kz4bj?= =?us-ascii?Q?MWXOvyv34V8QE2ahHD6eBc19JvjonnGz//0P0PT/0BBvViVdLF4mdcPQ6GV7?= =?us-ascii?Q?jvUbF5D4gd7MuffkXPKb8Rx4fJuqgZLnyNxUT9DW+jgnBzQv+nd8D1wmvH9z?= =?us-ascii?Q?59w/el0TZ/nb4zv5wIi65Q5agHf7TmvXmzBvLuvBBqfFOgvZtO8FNiybhrsF?= =?us-ascii?Q?rHngrNlt6YGEf/4lJQyuLngEzloKbtwO+k0IznWnmgxqLOsf1mWv/Q9z1jXa?= =?us-ascii?Q?Wc8/tEIMT+wX+WIyR08H1OPHfKgQlt+Y0potnrp22iwFbUklo/UTGwT9GIQW?= =?us-ascii?Q?WETBSSVzuI6+GC55tzQ=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: fdd0e60d-d54c-43a6-0af3-08db51d1bdc7 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 May 2023 03:42:27.6926 (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: rgPrT8CiUiohkJtjvbdOsCO83vMUuzHRR0LLtLE7tNT9X70WJUvMsT1EnEq8mXqXgXeIotWWMdf3cFOmUJKKlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB7496 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 Vincent, ACPI spec contains following: The XSDT provides identical functionality to the RSDT but accommodates ph= ysical addresses of DESCRIPTION HEADERs that are larger than 32 bits. Notice that both the XSDT and the R= SDT can be pointed to by the RSDP structure. An ACPI-compatible OS must use the XSDT if present. Which means, XSDT is used over RSDT when it exists. But your code measures both XSDT and RSDT. It's not right. This change is not a simple change. I suggest you review the ACPI spec in d= etail and close the opens within your team before sending another version of patches. Thanks, Ray > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of VincentX K= e > Sent: Wednesday, May 10, 2023 5:58 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 v6] 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 | 271 > +++++++++++++++----- > Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf | 1 + > 2 files changed, 209 insertions(+), 63 deletions(-) >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > index e967031a3b..bb0f4a1f04 100644 > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > @@ -1191,98 +1191,243 @@ 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) { >=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)); >=20 > + if (Fadt.FirmwareCtrl || Fadt.XFirmwareCtrl) { >=20 > + TableCount++; >=20 > + } >=20 > + >=20 > + if (Fadt.Dsdt || Fadt.XDsdt) { >=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 > + >=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 > + >=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 >=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 > + Rsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->RsdtAddress; >=20 > + Xsdt =3D (EFI_ACPI_DESCRIPTION_HEADER *)(UINTN)Rsdp->XsdtAddress; >=20 >=20 >=20 > - if (HWChange =3D=3D NULL) return; >=20 > + AcpiTableCount +=3D CountTableInSDT (Rsdt, sizeof (UINT32)); >=20 > + AcpiTableCount +=3D CountTableInSDT (Xsdt, sizeof (UINT64)); >=20 >=20 >=20 > // >=20 > - // add HWChange inputs: PCI devices >=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 > - 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 > + // Search RSDT >=20 > + // >=20 > + AcpiTableCount =3D 0; >=20 > + EntryCount =3D (Rsdt->Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER= )) / > 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 (UINT3= 2)), > sizeof (UINT32)); >=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 > + if (Fadt.FirmwareCtrl) { >=20 > + CopyMem ((VOID *)&Facs, (VOID *)(UINTN)Fadt.FirmwareCtrl, sizeof > (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE)); >=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 > - HWChange[Index++] =3D PciId; >=20 > } >=20 > } >=20 >=20 >=20 > // >=20 > - // Locate FACP Table >=20 > + // Search XSDT >=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 > + 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, &Fadt.XFirmwareCtrl, sizeof (UINT64)); >=20 > + if (EntryPtr !=3D 0) { >=20 > + CopyMem ((VOID *)&Facs, (VOID *)EntryPtr, sizeof > (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE)); >=20 > + TableCrcRecord[AcpiTableCount++] =3D AcpiTableCrcCalculator > ((EFI_ACPI_COMMON_HEADER *)(UINTN)EntryPtr); >=20 > + } else { >=20 > + CopyMem ((VOID *)&Facs, (VOID *)(UINTN)Fadt.FirmwareCtrl, sizeof > (EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE)); >=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, &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 > + } >=20 > } >=20 >=20 >=20 > // >=20 > - // add HWChange inputs: others >=20 > + // FADT/FACS not found >=20 > // >=20 > - HWChange[Index++] =3D (UINT32)pFADT->XDsdt; >=20 > + if (Fadt.Header.Signature !=3D > EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE) { >=20 > + return; >=20 > + } >=20 > + >=20 > + if (Facs.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 > + Facs.HardwareSignature =3D HWSignature; >=20 > + FreePool (TableCrcRecord); >=20 > + DEBUG ((DEBUG_INFO, "%a() - End\n", __FUNCTION__)); >=20 > } >=20 >=20 >=20 > VOID >=20 > @@ -1329,7 +1474,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 (#104537): https://edk2.groups.io/g/devel/message/10453= 7 > Mute This Topic: https://groups.io/mt/98802410/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