From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web08.3082.1630032303758723734 for ; Thu, 26 Aug 2021 19:45:04 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=cYxwU3t4; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: ray.ni@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10088"; a="205089002" X-IronPort-AV: E=Sophos;i="5.84,355,1620716400"; d="scan'208";a="205089002" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2021 19:45:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,355,1620716400"; d="scan'208";a="426989445" Received: from fmsmsx605.amr.corp.intel.com ([10.18.126.85]) by orsmga003.jf.intel.com with ESMTP; 26 Aug 2021 19:45:02 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx605.amr.corp.intel.com (10.18.126.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Thu, 26 Aug 2021 19:45:02 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx611.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.10 via Frontend Transport; Thu, 26 Aug 2021 19:45:02 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2242.10; Thu, 26 Aug 2021 19:44:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZxCKsN0caNRyT0VeEt3sXFAKhwFAoXoP5XkxEfy9SFowbjnmqPXYzrPEBO7VkPdsYqaL78cnYt5ohboBr6gesQV0nVfc9IIlAbsfR/5/2ZPf3gj9eJ0kwbiz5fayzOSq7ZpxHUoihyY1Wcui4vkvR1XxOJ/loxRbZouzRqfQA51+SFOqlDbiL7tMVu5tVjMc3f1Pafuhj+qkEfpeWSs7l9uct85WXglf7YkYMfQn3CvkFbNiN78Ve8RM1lqiKor6Lpwo4laoET2cKaIxz6s/p4raPH4EQpo0hr5X5bLjdM8sQvLS657Fj9QScu58vVTws18fyXwgn6ug4TG1XKiNig== 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-SenderADCheck; bh=Kv+bkRL/hFxAm2eAbsbgTiFwOrvcD5Np/Jc30TDSx0E=; b=ExCgRKPIYDY9rDnNWXgPrC5KIf5WvvLNJCq6JOCQ3IVyTEfO2hf7jv1veDr2bjbie/34/gAfyiqmiJUbLgK1Lpu5XySP3VG1PWZw8EiUy5Skq5Z4mwL0ATf5+/5YOUw+9UzhoWRKNGjbkLCzi3OFJQt6Inon/EgIpyv3emR9wOkg6GiTOE1Q58KQRGCPEPUCiQFS0UqxOxW0mOoSAlfNpp+9jktudH91liA+0RKyaaWuzwTyl0/9r7BAxGOCXCrDfZ9iIJCPIjE9crbccAiqZrNcP/Xr0IM61k9GwiFECB/UEAXckqW9yfJmOsxRuhSA7m7/Qwu5xbNTGXdFIMOrIQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Kv+bkRL/hFxAm2eAbsbgTiFwOrvcD5Np/Jc30TDSx0E=; b=cYxwU3t4bRrz/ypo3EG1iWx188L/hgmgys+c30x7C+22QoNa6sWuktAyeBFmj0oMSxRr9BvCdvklQc9mal6IDzudkBw7kSEig40QOSQXKRljMRD9QgTZlc3oW/KIjnCO/lctnGosxvZpKwxkQFiDbozbHpkuOlXszKc9o9yrEOM= Received: from PH0PR11MB4936.namprd11.prod.outlook.com (2603:10b6:510:42::20) by PH0PR11MB5013.namprd11.prod.outlook.com (2603:10b6:510:30::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4457.17; Fri, 27 Aug 2021 02:44:53 +0000 Received: from PH0PR11MB4936.namprd11.prod.outlook.com ([fe80::1db5:81b2:cdfe:40a0]) by PH0PR11MB4936.namprd11.prod.outlook.com ([fe80::1db5:81b2:cdfe:40a0%7]) with mapi id 15.20.4457.021; Fri, 27 Aug 2021 02:44:53 +0000 From: "Ni, Ray" To: "Lin, JackX" , "devel@edk2.groups.io" CC: "Chiu, Chasel" , "Dong, Eric" , "Yao, Jiewen" , "Chaganty, Rangasai V" , "Kuo, Donald" , "Kumar, Chandana C" Subject: Re: [edk2-platforms: PATCH V9] Platform/Intel: Correct CPU APIC IDs Thread-Topic: [edk2-platforms: PATCH V9] Platform/Intel: Correct CPU APIC IDs Thread-Index: AQHXlbG2HN6RM647b0G9DyAeDNfmIauGGSyQgACVZaA= Date: Fri, 27 Aug 2021 02:44:52 +0000 Message-ID: References: <20210820105338.606-1-JackX.Lin@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.6.100.41 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: intel.com; dkim=none (message not signed) header.d=none;intel.com; dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 388f853f-384e-4099-bb97-08d96904a5b9 x-ms-traffictypediagnostic: PH0PR11MB5013: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3383; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MNlNArk3807YJTEywLu1wzhac2InWg/l56v/2FykWWEPKsMiN7+zZgSU2LL1Q8D5kp25IRcAKf+Za/sumij6DJbJIiU0/D20yEW/2TM5sNcYbNagl9BX5yNb4HUhC2c7LQ0OQLUI9fDf6mOBq9Nbb7tE9oB2IG/qXz+8/uZTp++cp5LZlFy0fDvKLo6qeLXRjIGwzlCWuXrukiyYo/XwWmxQ680hjY1RL3KTrJQ24bMA7oRlaCY3xQEA5gecwYTDPD4UOcUZ4bVXdbQGb+e9gDHLKifxLpGUIntv8LiDd2GNOjUtLDSp8suk+dQ0FYVvLJW+ZKonukBYuY2iixyarqazOY1T+TSVuW73jVutNb95RNpnCW2kEGTHllgootjHcyOk/AVKcFBJL5+XX9xozCW3d3uwpS1JhSipMxPep32mBj/SgnVSEfhmKssgCGGS/uOSVj7bZMcSfd7pyPpPK4C9QcOVJGfeI5icPfNSPrBoqAAEWcAAqcazU7ksGkb4GZrO6p8VK0ha0h3XEi1htoVTkPmnPf+JHIbH4kmaOGncjk+j8hXcblYL/iUALFPia87b7SjEULwDHUju+CWBxPSaZv8GzZCPvrr3udxSjCm/HfIy0cVqsu/C+xTo6aXBaZagyNOT/xTnrPmLH4KKoEluZElPoZAD00N4Qj7QsztMR45h3V2L+syXM/dqyPVBkFw2Vz1XxFwlFKqHKfrLZn85RZUUwAugbxBISHraR78= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR11MB4936.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39860400002)(376002)(396003)(136003)(366004)(346002)(8676002)(186003)(66556008)(316002)(38100700002)(478600001)(54906003)(8936002)(86362001)(33656002)(7696005)(26005)(110136005)(71200400001)(19627235002)(122000001)(2906002)(66446008)(55016002)(5660300002)(107886003)(38070700005)(4326008)(52536014)(6506007)(64756008)(9686003)(66476007)(30864003)(66946007)(76116006)(83380400001)(579004)(44824005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?w+gMA8bXmZJMCql/i8KM+Fr+u+m14mxOJnBmAvbkVHSQoKw4Zb7c9kJ4gaFd?= =?us-ascii?Q?BQlZzoAiWImkqMQlnAiEwudJXpVtqxcZHNsKK1KQC6KK3juxcqIFptNaas0s?= =?us-ascii?Q?3zyaDDvJKF1tv6AqoW7Pa1yrwTDvQ0mqW5n03KIQRKkeZPU1AcMOk2XmjyGb?= =?us-ascii?Q?0HRi6YuPNs/ytS4+rGjp+odTAtV1vI71wsvqwn6yxT6cuEsemdKtmvnMdEHd?= =?us-ascii?Q?PfQ8EKVI9EwNUg3GUpQppm7IS2r0iteqCSuwr1gEkwr30XRyWFvbIlYbn8wj?= =?us-ascii?Q?fzoqCroedLhPbbdqxylC8dEOKOqMjg4XuOFuQsZ/EUADRgO8pnIoQZhx3jW7?= =?us-ascii?Q?OMbovOVbZBQLuU8qCsGE5zD3zktHUn440JCCpOEqZsRCuNZA8rPrVTX4bh1G?= =?us-ascii?Q?Iw9eGx1pT+Cj7yl3wwkdSCZgWLr/G/9YOL66N/0vPRK4jaSMnXeTMQsroQ/6?= =?us-ascii?Q?GtuYcQOeW6extDdA36xjSwEbvJcfHel7fNb9HJLD38JH3ep/4nJxKI6Az6YQ?= =?us-ascii?Q?mWrZBP8OUFoDOm3kLfCbWdlOGUW7AIMBLmzn07pbXUZML843WWnRFlzAbUDh?= =?us-ascii?Q?yavy06MtKpaLgZA/ISPpW4Sny9hpfyKXprzUD5qBmuVLWLg35bTiGx+m9Ri3?= =?us-ascii?Q?oJpdaZG7Pz49JUQjaGEbtZW8zNag8QqI9d1g/enC2nNB9nI/GLrHMyMnHQ2L?= =?us-ascii?Q?oIYcdtncQl/r9W1HX6GBUGUytj/rI7raczEMQnqzAsbblNjnpKshWWhUUVL7?= =?us-ascii?Q?+mGOumekcETjgs4aGYFT4sB0oNfGbq40gU2hSReFO2aHKP59Ezlwr2nCFrwh?= =?us-ascii?Q?pDDDTI5HZXyxvVPNXy6pBH4vovgT+i4gCSrKKsvyr4LaRlkF7WIpi8galQ3L?= =?us-ascii?Q?DgKKLg/Y4ktcNkULQgASin4URK6UDI01b3CGCiJFs57cwuuhK6sbshSjyZFD?= =?us-ascii?Q?dPhA9fiIEYNZjtSlmDP3Hu8nmgpnBkzdSf/ci/z/LPEaSVVP1yXZtn0fYYrM?= =?us-ascii?Q?cIIMKbYGS1Ju4YeCVpZ7FKyeWhbJGpvHeKBzGm6y9zcKCPOx5IvMSMBXfQNV?= =?us-ascii?Q?eP7JdetAYNWlW5imNVL1ExwKiH1R2iSxOS/YJNWNM0ic/ZvK1C8uQ3EBcHcs?= =?us-ascii?Q?16IxdC5UNgwTc92fXuWTzP87kPBfGIW7DP5mpPwF+Ff3C0UboiVMJrHQgP4Y?= =?us-ascii?Q?mFGd8IZKCBWeIfQcIz0Yl3yc4oFiwRr46N+fikxw76LCW+xq78aDwJDDf5Fc?= =?us-ascii?Q?TemNnZgn3vQR9ePFgboDN+P40EurKSLHp5X3BBqZPQyhtHFYaE0apWy4/WK9?= =?us-ascii?Q?bpeJsBgeFg3XEbrQjJgw/U2X?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB4936.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 388f853f-384e-4099-bb97-08d96904a5b9 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Aug 2021 02:44:52.8823 (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: Z0VgOeTRivqV+4+7EKjN/CJMSo5U0x5eVw9gS5FyUSHDXxE0KodaCcSkEm2rew86oKjjU65ruQ9+9dYTDv3qIA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB5013 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 > > + // > > + // 5. Re-assigen AcpiProcessorId for AcpiProcessorUId uses purpose. > > + // > > + for (Socket =3D 0; Socket < MAX_SOCKET; Socket++) { 1. Or if you add a "Index =3D 0" to reset Index for each Socket, that also = work. > > + for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCp= us; CurrProcessor++) { > > + if (mCpuApicIdOrderTable[CurrProcessor].Flags && (mCpuApicIdOrde= rTable[CurrProcessor].SocketNum =3D=3D Socket)) { > > + mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId =3D (Proce= ssorInfoBuffer.Location.Package << mNumOfBitShift) + > > Index; > > + Index++; > > } > > } > > + } >=20 > 1. I think you need to change above code to as below? > UINTN IndexInSocket[MAX_SOCKET]; >=20 > ZeroMem (IndexInSocket, sizeof (IndexInSocket)); >=20 > for (Socket =3D 0; Socket < MAX_SOCKET; Socket++) { 2. My code is wrong. The for-loop above is not needed. I think you can simp= ly make sure resetting "Index" to 0 for each socket in your original logic. > for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus; C= urrProcessor++) { > if (mCpuApicIdOrderTable[CurrProcessor].Flags && (mCpuApicIdOrderTab= le[CurrProcessor].SocketNum =3D=3D Socket)) { > mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorId =3D (Processo= rInfoBuffer.Location.Package << mNumOfBitShift) + > IndexInSocket[Socket]; > IndexInSocket[Socket]++; > } > } >=20 > 2. Can you separate the code refinement change (looks like most of the ch= anges below) in a separate patch? > (No more comments) Sending multiple patches together basically consists of several steps: a. make changes and commit first patch that fix the bug b. make changes and commit second patch that refines the existing code. (The 2nd change should not impact any behavior.) c. "git format-patch -3" to generate three patch files. d. use text editor to edit the number #0 patch file (cover letter) to descr= ibe briefly of the two patches e. "git send-email *.patch" >=20 > > > > - //keep for debug purpose > > - DEBUG ((EFI_D_ERROR, "APIC ID Order Table ReOrdered\n")); > > - DebugDisplayReOrderTable(); > > + //keep for debug purpose > > + DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n")); > > + DebugDisplayReOrderTable (mCpuApicIdOrderTable); > > > > - mCpuOrderSorted =3D TRUE; > > - } > > + mCpuOrderSorted =3D TRUE; > > > > return Status; > > } > > @@ -602,11 +493,11 @@ InitializeMadtHeader ( > > } > > > > Status =3D InitializeHeader ( > > - &MadtHeader->Header, > > - EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, > > - EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, > > - 0 > > - ); > > + &MadtHeader->Header, > > + EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, > > + EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, > > + 0 > > + ); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -784,11 +675,11 @@ BuildAcpiTable ( > > // Allocate the memory needed for the table. > > // > > Status =3D AllocateTable ( > > - TableSpecificHdrLength, > > - Structures, > > - StructureCount, > > - &InternalTable > > - ); > > + TableSpecificHdrLength, > > + Structures, > > + StructureCount, > > + &InternalTable > > + ); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -871,18 +762,22 @@ InstallMadtFromScratch ( > > NewMadtTable =3D NULL; > > MaxMadtStructCount =3D 0; > > > > - DetectApicIdMap(); > > + mCpuApicIdOrderTable =3D AllocateZeroPool (mNumberOfCpus * sizeof (E= FI_CPU_ID_ORDER_MAP)); > > + if (mCpuApicIdOrderTable =3D=3D NULL) { > > + DEBUG ((DEBUG_ERROR, "Could not allocate mCpuApicIdOrderTable stru= cture pointer array\n")); > > + return EFI_OUT_OF_RESOURCES; > > + } > > > > // Call for Local APIC ID Reorder > > Status =3D SortCpuLocalApicInTable (); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "SortCpuLocalApicInTable failed: %r\n", Statu= s)); > > + DEBUG ((DEBUG_ERROR, "SortCpuLocalApicInTable failed: %r\n", Statu= s)); > > goto Done; > > } > > > > MaxMadtStructCount =3D (UINT32) ( > > - MAX_CPU_NUM + // processor local APIC structures > > - MAX_CPU_NUM + // processor local x2APIC structures > > + mNumberOfCpus + // processor local APIC structures > > + mNumberOfCpus + // processor local x2APIC structures > > 1 + PcdGet8(PcdPcIoApicCount) + // I/O APIC structures > > 2 + // interrupt source override structures > > 1 + // local APIC NMI structures > > @@ -906,11 +801,11 @@ InstallMadtFromScratch ( > > // > > Status =3D InitializeMadtHeader (&MadtTableHeader); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "InitializeMadtHeader failed: %r\n", Status))= ; > > + DEBUG ((DEBUG_ERROR, "InitializeMadtHeader failed: %r\n", Status))= ; > > goto Done; > > } > > > > - DEBUG ((EFI_D_INFO, "Number of CPUs detected =3D %d \n", mNumberOfCP= Us)); > > + DEBUG ((DEBUG_INFO, "Number of CPUs detected =3D %d \n", mNumberOfCp= us)); > > > > // > > // Build Processor Local APIC Structures and Processor Local X2APIC = Structures > > @@ -923,7 +818,7 @@ InstallMadtFromScratch ( > > ProcLocalX2ApicStruct.Reserved[0] =3D 0; > > ProcLocalX2ApicStruct.Reserved[1] =3D 0; > > > > - for (Index =3D 0; Index < MAX_CPU_NUM; Index++) { > > + for (Index =3D 0; Index < mNumberOfCpus; Index++) { > > // > > // If x2APIC mode is not enabled, and if it is possible to express= the > > // APIC ID as a UINT8, use a processor local APIC structure. Other= wise, > > @@ -936,10 +831,10 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &ProcLocalApicStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &ProcLocalApicStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > } else if (mCpuApicIdOrderTable[Index].ApicId !=3D 0xFFFFFFFF) { > > ProcLocalX2ApicStruct.Flags =3D (UINT8) mCpuApicIdOrd= erTable[Index].Flags; > > ProcLocalX2ApicStruct.X2ApicId =3D mCpuApicIdOrderTable[= Index].ApicId; > > @@ -947,13 +842,13 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &ProcLocalX2ApicStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > } > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (local APIC/x2APIC) fail= ed: %r\n", Status)); > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (local APIC/x2APIC) fail= ed: %r\n", Status)); > > goto Done; > > } > > } > > @@ -965,44 +860,44 @@ InstallMadtFromScratch ( > > IoApicStruct.Length =3D sizeof (EFI_ACPI_4_0_IO_APIC_STRUCTURE); > > IoApicStruct.Reserved =3D 0; > > > > - PcIoApicEnable =3D PcdGet32(PcdPcIoApicEnable); > > + PcIoApicEnable =3D PcdGet32 (PcdPcIoApicEnable); > > > > - if (FixedPcdGet32(PcdMaxCpuSocketCount) <=3D 4) { > > + if (FixedPcdGet32 (PcdMaxCpuSocketCount) <=3D 4) { > > IoApicStruct.IoApicId =3D PcdGet8(PcdIoApicId); > > IoApicStruct.IoApicAddress =3D PcdGet32(PcdIoApicAddre= ss); > > IoApicStruct.GlobalSystemInterruptBase =3D 0; > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &IoApicStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &IoApicStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n"= , Status)); > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n"= , Status)); > > goto Done; > > } > > } > > > > for (PcIoApicIndex =3D 0; PcIoApicIndex < PcdGet8(PcdPcIoApicCount);= PcIoApicIndex++) { > > - PcIoApicMask =3D (1 << PcIoApicIndex); > > - if ((PcIoApicEnable & PcIoApicMask) =3D=3D 0) { > > - continue; > > - } > > + PcIoApicMask =3D (1 << PcIoApicIndex); > > + if ((PcIoApicEnable & PcIoApicMask) =3D=3D 0) { > > + continue; > > + } > > > > - IoApicStruct.IoApicId =3D (UINT8)(PcdGet8(PcdPc= IoApicIdBase) + PcIoApicIndex); > > - IoApicStruct.IoApicAddress =3D CurrentIoApicAddress; > > - CurrentIoApicAddress =3D (CurrentIoApicAddress= & 0xFFFF8000) + 0x8000; > > - IoApicStruct.GlobalSystemInterruptBase =3D (UINT32)(24 + (PcIoAp= icIndex * 8)); > > - ASSERT (MadtStructsIndex < MaxMadtStructCount); > > - Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &IoApicStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > - if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\= n", Status)); > > - goto Done; > > - } > > + IoApicStruct.IoApicId =3D (UINT8)(PcdGet8(PcdPcIo= ApicIdBase) + PcIoApicIndex); > > + IoApicStruct.IoApicAddress =3D CurrentIoApicAddress; > > + CurrentIoApicAddress =3D (CurrentIoApicAddress &= 0xFFFF8000) + 0x8000; > > + IoApicStruct.GlobalSystemInterruptBase =3D (UINT32)(24 + (PcIoApic= Index * 8)); > > + ASSERT (MadtStructsIndex < MaxMadtStructCount); > > + Status =3D CopyStructure ( > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &IoApicStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > + if (EFI_ERROR (Status)) { > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (I/O APIC) failed: %r\n"= , Status)); > > + goto Done; > > + } > > } > > > > // > > @@ -1021,12 +916,12 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &IntSrcOverrideStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &IntSrcOverrideStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ2 source override) fai= led: %r\n", Status)); > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ2 source override) fai= led: %r\n", Status)); > > goto Done; > > } > > > > @@ -1040,12 +935,12 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &IntSrcOverrideStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &IntSrcOverrideStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (IRQ9 source override) fai= led: %r\n", Status)); > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (IRQ9 source override) fai= led: %r\n", Status)); > > goto Done; > > } > > > > @@ -1060,12 +955,12 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &LocalApciNmiStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &LocalApciNmiStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", = Status)); > > + DEBUG ((DEBUG_ERROR, "CopyMadtStructure (APIC NMI) failed: %r\n", = Status)); > > goto Done; > > } > > > > @@ -1084,10 +979,10 @@ InstallMadtFromScratch ( > > > > ASSERT (MadtStructsIndex < MaxMadtStructCount); > > Status =3D CopyStructure ( > > - &MadtTableHeader.Header, > > - (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct, > > - &MadtStructs[MadtStructsIndex++] > > - ); > > + &MadtTableHeader.Header, > > + (STRUCTURE_HEADER *) &LocalX2ApicNmiStruct, > > + &MadtStructs[MadtStructsIndex++] > > + ); > > if (EFI_ERROR (Status)) { > > DEBUG ((DEBUG_ERROR, "CopyMadtStructure (x2APIC NMI) failed: %r\= n", Status)); > > goto Done; > > @@ -1098,14 +993,14 @@ InstallMadtFromScratch ( > > // Build Madt Structure from the Madt Header and collection of point= ers in MadtStructs[] > > // > > Status =3D BuildAcpiTable ( > > - (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader, > > - sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER), > > - MadtStructs, > > - MadtStructsIndex, > > - (UINT8 **)&NewMadtTable > > - ); > > + (EFI_ACPI_DESCRIPTION_HEADER *) &MadtTableHeader, > > + sizeof (EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEAD= ER), > > + MadtStructs, > > + MadtStructsIndex, > > + (UINT8 **) &NewMadtTable > > + ); > > if (EFI_ERROR (Status)) { > > - DEBUG ((EFI_D_ERROR, "BuildAcpiTable failed: %r\n", Status)); > > + DEBUG ((DEBUG_ERROR, "BuildAcpiTable failed: %r\n", Status)); > > goto Done; > > } > > > > @@ -1113,11 +1008,11 @@ InstallMadtFromScratch ( > > // Publish Madt Structure to ACPI > > // > > Status =3D mAcpiTable->InstallAcpiTable ( > > - mAcpiTable, > > - NewMadtTable, > > - NewMadtTable->Header.Length, > > - &TableHandle > > - ); > > + mAcpiTable, > > + NewMadtTable, > > + NewMadtTable->Header.Length, > > + &TableHandle > > + ); > > > > Done: > > // > > @@ -1136,6 +1031,10 @@ Done: > > FreePool (NewMadtTable); > > } > > > > + if (mCpuApicIdOrderTable !=3D NULL) { > > + FreePool (mCpuApicIdOrderTable); > > + } > > + > > return Status; > > } > > > > @@ -1155,8 +1054,8 @@ InstallMcfgFromScratch ( > > PciSegmentInfo =3D GetPciSegmentInfo (&SegmentCount); > > > > McfgTable =3D AllocateZeroPool ( > > - sizeof(EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDRE= SS_TABLE_HEADER) + > > - > > sizeof(EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS= _ALLOCATION_STRUCTURE) * > > SegmentCount > > + sizeof (EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_BASE_ADDR= ESS_TABLE_HEADER) + > > + sizeof > > (EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOC= ATION_STRUCTURE) * > > SegmentCount > > ); > > if (McfgTable =3D=3D NULL) { > > DEBUG ((DEBUG_ERROR, "Could not allocate MCFG structure\n")); > > @@ -1164,11 +1063,11 @@ InstallMcfgFromScratch ( > > } > > > > Status =3D InitializeHeader ( > > - &McfgTable->Header, > > - > > > EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_D= ESCRIPTION_TABLE_SIGNATURE, > > - EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION, > > - 0 > > - ); > > + &McfgTable->Header, > > + > > > EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_D= ESCRIPTION_TABLE_SIGNATURE, > > + EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_R= EVISION, > > + 0 > > + ); > > if (EFI_ERROR (Status)) { > > return Status; > > } > > @@ -1192,11 +1091,11 @@ InstallMcfgFromScratch ( > > // Publish Madt Structure to ACPI > > // > > Status =3D mAcpiTable->InstallAcpiTable ( > > - mAcpiTable, > > - McfgTable, > > - McfgTable->Header.Length, > > - &TableHandle > > - ); > > + mAcpiTable, > > + McfgTable, > > + McfgTable->Header.Length, > > + &TableHandle > > + ); > > > > return Status; > > } > > @@ -1280,7 +1179,7 @@ PlatformUpdateTables ( > > switch (Table->Signature) { > > > > case EFI_ACPI_4_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE: > > - ASSERT(FALSE); > > + ASSERT (FALSE); > > break; > > > > case EFI_ACPI_5_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE: > > @@ -1324,9 +1223,9 @@ PlatformUpdateTables ( > > FadtHeader->XGpe1Blk.AccessSize =3D 0; > > } > > > > - DEBUG(( EFI_D_ERROR, "ACPI FADT table @ address 0x%x\n", Table )); > > - DEBUG(( EFI_D_ERROR, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBoot= Arch )); > > - DEBUG(( EFI_D_ERROR, " Flags 0x%x\n", FadtHeader->Flags )); > > + DEBUG ((DEBUG_INFO, "ACPI FADT table @ address 0x%x\n", Table)); > > + DEBUG ((DEBUG_INFO, " IaPcBootArch 0x%x\n", FadtHeader->IaPcBootA= rch)); > > + DEBUG ((DEBUG_INFO, " Flags 0x%x\n", FadtHeader->Flags)); > > break; > > > > case EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE: > > @@ -1346,12 +1245,12 @@ PlatformUpdateTables ( > > HpetBlockId.Bits.VendorId =3D HpetCapabilities.Bits.VendorId= ; > > HpetTable->EventTimerBlockId =3D HpetBlockId.Uint32; > > HpetTable->MainCounterMinimumClockTickInPeriodicMode =3D (UINT16)H= petCapabilities.Bits.CounterClockPeriod; > > - DEBUG(( EFI_D_ERROR, "ACPI HPET table @ address 0x%x\n", Table )); > > - DEBUG(( EFI_D_ERROR, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAd= dress) )); > > + DEBUG ((DEBUG_INFO, "ACPI HPET table @ address 0x%x\n", Table)); > > + DEBUG ((DEBUG_INFO, " HPET base 0x%x\n", PcdGet32 (PcdHpetBaseAdd= ress))); > > break; > > > > case > > > EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_D= ESCRIPTION_TABLE_SIGNATURE: > > - ASSERT(FALSE); > > + ASSERT (FALSE); > > break; > > > > default: > > @@ -1403,8 +1302,8 @@ IsHardwareChange ( > > // pFADT->XDsdt > > // > > HWChangeSize =3D HandleCount + 1; > > - HWChange =3D AllocateZeroPool( sizeof(UINT32) * HWChangeSize ); > > - ASSERT( HWChange !=3D NULL ); > > + HWChange =3D AllocateZeroPool (sizeof(UINT32) * HWChangeSize); > > + ASSERT(HWChange !=3D NULL); > > > > if (HWChange =3D=3D NULL) return; > > > > @@ -1445,14 +1344,14 @@ IsHardwareChange ( > > // Calculate CRC value with HWChange data. > > // > > Status =3D gBS->CalculateCrc32(HWChange, HWChangeSize, &CRC); > > - DEBUG((DEBUG_INFO, "CRC =3D %x and Status =3D %r\n", CRC, Status)); > > + DEBUG ((DEBUG_INFO, "CRC =3D %x and Status =3D %r\n", CRC, Status)); > > > > // > > // Set HardwareSignature value based on CRC value. > > // > > FacsPtr =3D (EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE *)(UINTN)p= FADT->FirmwareCtrl; > > FacsPtr->HardwareSignature =3D CRC; > > - FreePool( HWChange ); > > + FreePool (HWChange); > > } > > > > VOID > > @@ -1475,17 +1374,16 @@ UpdateLocalTable ( > > > > if (Version !=3D EFI_ACPI_TABLE_VERSION_NONE) { > > Status =3D mAcpiTable->InstallAcpiTable ( > > - mAcpiTable, > > - CurrentTable, > > - CurrentTable->Length, > > - &TableHandle > > - ); > > + mAcpiTable, > > + CurrentTable, > > + CurrentTable->Length, > > + &TableHandle > > + ); > > ASSERT_EFI_ERROR (Status); > > } > > } > > } > > > > - > > VOID > > EFIAPI > > AcpiEndOfDxeEvent ( > > @@ -1493,16 +1391,14 @@ AcpiEndOfDxeEvent ( > > VOID *ParentImageHandle > > ) > > { > > - > > if (Event !=3D NULL) { > > - gBS->CloseEvent(Event); > > + gBS->CloseEvent (Event); > > } > > > > - > > // > > // Calculate Hardware Signature value based on current platform conf= igurations > > // > > - IsHardwareChange(); > > + IsHardwareChange (); > > } > > > > /** > > @@ -1526,7 +1422,6 @@ InstallAcpiPlatform ( > > EFI_STATUS Status; > > EFI_EVENT EndOfDxeEvent; > > > > - > > Status =3D gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (V= OID **)&mMpService); > > ASSERT_EFI_ERROR (Status); > > > > @@ -1550,19 +1445,19 @@ InstallAcpiPlatform ( > > // Determine the number of processors > > // > > mMpService->GetNumberOfProcessors ( > > - mMpService, > > - &mNumberOfCPUs, > > - &mNumberOfEnabledCPUs > > - ); > > - ASSERT (mNumberOfCPUs <=3D MAX_CPU_NUM && mNumberOfEnabledCPUs >=3D = 1); > > - DEBUG ((DEBUG_INFO, "mNumberOfCPUs - %d\n", mNumberOfCPUs)); > > + mMpService, > > + &mNumberOfCpus, > > + &mNumberOfEnabledCPUs > > + ); > > + > > + DEBUG ((DEBUG_INFO, "mNumberOfCpus - %d\n", mNumberOfCpus)); > > DEBUG ((DEBUG_INFO, "mNumberOfEnabledCPUs - %d\n", mNumberOfEnabledC= PUs)); > > > > DEBUG ((DEBUG_INFO, "mX2ApicEnabled - 0x%x\n", mX2ApicEnabled)); > > DEBUG ((DEBUG_INFO, "mForceX2ApicId - 0x%x\n", mForceX2ApicId)); > > > > // support up to 64 threads/socket > > - AsmCpuidEx(CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL, = NULL); > > + AsmCpuidEx (CPUID_EXTENDED_TOPOLOGY, 1, &mNumOfBitShift, NULL, NULL,= NULL); > > mNumOfBitShift &=3D 0x1F; > > DEBUG ((DEBUG_INFO, "mNumOfBitShift - 0x%x\n", mNumOfBitShift)); > > > > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform= .h > > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.h > > index bd11f9e988..61f7470f80 100644 > > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.h > > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.h > > @@ -1,7 +1,7 @@ > > /** @file > > This is an implementation of the ACPI platform driver. > > > > -Copyright (c) 2017, Intel Corporation. All rights reserved.
> > +Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > **/ > > @@ -35,6 +35,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent > > #include > > #include > > #include > > +#include > > +#include > > > > #include > > #include > > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform= .inf > > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > > index 5d9c8cab50..95f6656af0 100644 > > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.inf > > @@ -1,7 +1,7 @@ > > ### @file > > # Component information file for AcpiPlatform module > > # > > -# Copyright (c) 2017, Intel Corporation. All rights reserved.
> > +# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved. > > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -43,6 +43,8 @@ > > PciSegmentInfoLib > > AslUpdateLib > > BoardAcpiTableLib > > + SortLib > > + LocalApicLib > > > > [Pcd] > > gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemId > > -- > > 2.32.0.windows.2