From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web09.1931.1660103286905434040 for ; Tue, 09 Aug 2022 20:48:07 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=nobrk4Er; spf=pass (domain: intel.com, ip: 134.134.136.100, 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=1660103286; x=1691639286; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=YOcspL1B0gzsJESQ/fcOPMKKsDlKbjT8dsi9zBDUEiM=; b=nobrk4Er3Rx6uCANG1tIQ5qnpIsgtP5oNOCCtJzI1L8mwq3SJapvPbvV 9FfaoHX+rIeHvWGSXmqA6aaV3gSlo6YCX+LkV7hvfsmfLTQkwCF6bCeQV aXNLpdticKLRb900puLRB8psF3c2jF+Ov0xUoWlHAdOj8nuRdkoRYjobA T3q0RsyPMjJGmy1a4PjsOFMJb4XyumusAcDNAB68T4uKqN00Sr65JIuC0 qMTGwbYgpXtlUEz0za8v+r4kvUaN3gG/lhaRhlCluk/KJJHiaP1oUghNr DBtEhD3bc8qrEi3S4rY2pu6x9w0dKQwwytGxrXiOBYhUusvLFwxgJAEF7 w==; X-IronPort-AV: E=McAfee;i="6400,9594,10434"; a="354989364" X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="354989364" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 20:48:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,226,1654585200"; d="scan'208";a="581066887" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga006.jf.intel.com with ESMTP; 09 Aug 2022 20:48:06 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) 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.2375.28; Tue, 9 Aug 2022 20:48:05 -0700 Received: from orsmsx602.amr.corp.intel.com (10.22.229.15) by ORSMSX610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 9 Aug 2022 20:48:04 -0700 Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28 via Frontend Transport; Tue, 9 Aug 2022 20:48:04 -0700 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.174) 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.2375.28; Tue, 9 Aug 2022 20:47:55 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m5czliyQrZjcgU7e78tHXc98CRMJjaCIt70n06y4VL5U2y7p3b/4T83AbFrTgnYx3iteLuCefPKdPIIedD3IY6URpyovw9y4/USNKLi7WM/9ceBWA5IIaS4d2Wd5JXPS2phZwNolI/b+VGx97yX7hkhxBYwWZno7V5/JFvZEye2bZ4BBEQ/Kq1BRAFTePtUg0Dbx80r1gueGZURUgQ+QndH+K0KQJ+eCfRKEtzVQWKWjJTZo07NttnqXpwDLPVsQ7ypehQZlk2KkUKo2n8UVigk/KuZNY4lMpbaNQ86JMFNu1cEDZsGu1RDC5RDuEilsZIZXo3b7HrTMC6ngjGMxKA== 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=1SVMR29xy2pV2jlv7ygS1cml7ts9dN3bzwamTY3gHVk=; b=KdP3ofI3XHMltzW7rqlekk2mNJVtod3GQvcZim+V55e23tynCauxMRRYqs6OLiOptoixHlQ2mB6P1pKiKujEjpNHO8AINVHUJpIeG+0VBeTWpc0Upm2U6JPmpV1MXLdEX7gH+Eqw7ujaiLLwUE9U2s/+Zc/bW6NcllHzX3GWp6E/+rf8aaWKjUjEtMJozdJFKA9ucStYTc5GTXq3Dhid5A6d3l7aKqFY0tX847tRQLKTrpGXSgUDmyo5Z8w9vAlo/gHv7dDvx5isykXNwmB0qhclRRyDnPKAEELEKQ1dhp+QFPWufaKj1uxS8GRBQ8WCc+y32nDJxQ1JZ2kU6vmuAQ== 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 MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by DM4PR11MB6312.namprd11.prod.outlook.com (2603:10b6:8:a5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Wed, 10 Aug 2022 03:47:52 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::991b:97a0:7836:5174%10]) with mapi id 15.20.5504.020; Wed, 10 Aug 2022 03:47:52 +0000 From: "Ni, Ray" To: "Lin, JackX" , "Sinha, Ankit" CC: "Chiu, Chasel" , "Dong, Eric" , "Yao, Jiewen" , "Chaganty, Rangasai V" , "devel@edk2.groups.io" , "Kuo, Donald" , "Kumar, Chandana C" , "Palakshareddy, Lavanya C" , "Palakshareddy, Lavanya C" Subject: Re: [edk2-platforms: PATCH] Modify processor _UID ordering by CPU default fused in MADT Thread-Topic: [edk2-platforms: PATCH] Modify processor _UID ordering by CPU default fused in MADT Thread-Index: AQHYqv/rxuV9HgBBk06A3zrSlAd8i62nedig Date: Wed, 10 Aug 2022 03:47:52 +0000 Message-ID: References: <20220808082123.1999-1-jackx.lin@intel.com> In-Reply-To: <20220808082123.1999-1-jackx.lin@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-office365-filtering-correlation-id: f4bde09d-9aff-4f1e-2c41-08da7a831a1f x-ms-traffictypediagnostic: DM4PR11MB6312:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: ShrYiwt51XlUzSRH8sEbogoK8tcff4ta09kiA+N+8zVYXbDAJwB3Dj4wTCrQiM6S7ylt29Ui+QTPJnUe1LaBJEdRBv5jD13Wu6/hc7x1qvqng9ClZsJET5z7A3+IQ99ZjNOxsACQhM+3YNYCjlEGh02CArr/JbTFshDJ45J6Fp5MaYmyxdG3wx7y7R4zLr+XYUmh8R7a2jYE4hbbfoO+bOku0+BU0EzUZ4pW+H+2+yzvlum1NhnNXunTNQBMhsfA0wTjPttu3ZvKHy2A1VxwqH2AZY0L73yYC8THUfoACe7WXk6XgsVcLxHnxr3Cqsca/q0crWwFl4DmM28wWXRWazDfUZiWk5oREBmeZs8EUaH5lva2zjVk+DTP4RhLaxhzcRw9U2zUH98xEVihmobU+uM6Ps2ZJswg4MGqcIfnytAOJriytjadvA5k20ijZ6dQDWZ1StEH/PmLn1GadW5WlSzPdyZFuuS9YlCcB23E0y4cZWTeu3eY3L7wEA6wyVHUcuaMZMR0xmEuZAp2foHMiRBaPhIOJxxMGBSVcUVhmOyqr1nIVW7HSqGa3QwBQ4jt2s5H3X2vK6CEFzJiZ3qsORYxZIRxhQsGaZUSM8JA0YSYOyvalDw3CeE2a2jwtwKfGi002LvTbWPvdxuTAShPTeyyi2lijxlIPXrdH/5SfqHCBk7cy3zg0TvsmnuOMTSGZh32HPWm5njVymBhR4Oy/1u6CcWm7V/qoItGyZltoeDmDXdXr2NvSTWcrXGw5+X/6dPOm7IaSsnhSlxBIA+wyWNgVyAptIvj7SJegQEKnrUA91R1rjpRwyZF/trAwKo3 x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230016)(39860400002)(376002)(396003)(136003)(366004)(346002)(71200400001)(9686003)(7696005)(41300700001)(26005)(55016003)(38100700002)(6506007)(86362001)(19627235002)(478600001)(83380400001)(122000001)(33656002)(53546011)(186003)(107886003)(54906003)(316002)(6636002)(2906002)(76116006)(82960400001)(8936002)(52536014)(30864003)(5660300002)(66946007)(38070700005)(8676002)(66556008)(66476007)(66446008)(64756008)(110136005)(4326008);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?9NBUrsNnGEVuq1IMQZrLo5Wbyu4qq7bCVWimxbh70N0EXTqpg2I77XzxRjEm?= =?us-ascii?Q?bhM8RdAWb9mzMRkRbzvlgozhv5wO2+j3kNJsAZioXzi5FEGDYf3UqNQQxb4q?= =?us-ascii?Q?q0NoDUJS1LFIrtH+cbo0Jz2RdxtybFO6GcO/r3JTIOKnNvfFOgx2lKBr236I?= =?us-ascii?Q?HUzQemxB3ujqcXX8wbJ7J6gGB5Bq2IVyPV+EVs8dTnAhJmHr5kenmS5tbjtN?= =?us-ascii?Q?VeEjU84rquBcNuNc0MzMVzcdx3VIUCpxU2id2fWwbOKBTpos1n+TyR3vG4d6?= =?us-ascii?Q?ogruXX3wOxEswqdk5VRI3C1+yLmbi5R8gE+MPBrIUiYLhO4od/rQxRTQsYOF?= =?us-ascii?Q?OszKOYYfmWwjMFJJ02KD00d/Lt57Tcqu2cWWZWs1EYw4/Ecx3u4ZM4WqNkZG?= =?us-ascii?Q?u72URdNazvoWQdRc9FF+Re2TKEZER7bYW38AQGGF5b6oT3zRE8EhwMNdm/xW?= =?us-ascii?Q?tHI6jaSNjgfmh66ZcSPL9YPH2omp1n/RSYlnZdHnh2zw0DVyzSsG1JaMAn1y?= =?us-ascii?Q?XVgqF5rNTboq6AGcY+9rJgU9cQ4CSNJO2bfaN0DtHhyvHbrVByDyCvZxzLkm?= =?us-ascii?Q?Mma2tl9573YwhbPJGWmH0RZ2wqYP9C2wV88glKvjWKTjgBKQoneWDEZCKeyJ?= =?us-ascii?Q?xGIH1oga1tj16xOaLe2v1gII8g3kGquNt/gUlEyvr1IqtL/5/8sCtBZa8KfY?= =?us-ascii?Q?BhBXj1jGa/yBf2Upu9BQWS+Z8n7r7fSvHy8rsPRmAi3VAKQQ3fD/5GQ0h1G6?= =?us-ascii?Q?/UbfFfhnLQtvUeyj++1k6YTZ0bM9eCbCRkdiuIU9GPTqi5b8T2PtrbmL+3Q/?= =?us-ascii?Q?+QXA1Xpwc63wXwCQAzNWbbe1CloRUg02UgDeMO5Ln8ECkPtPJIbsFrsKUI1u?= =?us-ascii?Q?vWfQBCy16APmtUO++JdL+3nrs7KkfR8BFW1KF41zf8l5Odcl9BJxW9HM8oLK?= =?us-ascii?Q?ErR7xin3KrEBMoSuRsfXmoPVfPUsvNbQevcrihAW837xcbN3fvbIvxvFxrKk?= =?us-ascii?Q?gBfPMj6P6SG/2N6x2rhmLYFPbUhMQalx014WqRI7KmjTemo2VMYUx8AgxQYC?= =?us-ascii?Q?8Gi4Z8fU2zqBb6QonHH6cmp2GXIEXDSIQoS7GiVD3W8B89CXlWu3GeATM3Ej?= =?us-ascii?Q?I2UFsgAIFaxhbEwI9n8GSq4pCAWu8pVeVEVWPZzf0BbWYAUbtwNmASLGdnfN?= =?us-ascii?Q?jlzCciotd/mgPXeB3H6sjGTJZHoFZJid+6uY9z4TMgE77iYAQJcvAvw0sh4y?= =?us-ascii?Q?GjpGVZ759Lz3yCXIxKfIiptlxwCwNCU1OmwojC7MNK+etang4iNdkzK/q2BF?= =?us-ascii?Q?KPlJbii8Cf/3mHpXi9T6iep2yEACFgR5ntV6M48hrHZvzUWTv8vM58SqCo4m?= =?us-ascii?Q?z29cszWiJdJB/g4hU4sDzieZ8q2qobzN4we9jVuF9UIz5v8w33whhTYQaMz+?= =?us-ascii?Q?w181Vws8e4gweGDYagihFwEx9qn69vadCKfIch+gujdi4F4CkN2MKMRuGy8S?= =?us-ascii?Q?yBw0Ko46OEh5jFOuBSUAOyicPf/EMgyioPOEYHX3bSXSi0ZaAr79QNf0epd0?= =?us-ascii?Q?yAovu5+zzvfwI+dYFTw=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f4bde09d-9aff-4f1e-2c41-08da7a831a1f X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Aug 2022 03:47:52.3589 (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: fweT8sTu0kxyducYcJJhZvzxX4aDJP4HTHJmjGk0VQuIIp7qSON4eVg6s1YwmLUtdcP8RUKXlyGwBRDpVcK7fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6312 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 Jack, Your patch cannot be merged to trunk because Ankit just did some change in = the same C file, in below commit. * MinPlatformPkg/AcpiTables: Add additional thread mapping in MADT Ankit, It seems your patch is to add support for thread #2 and #3. Jack's patch is= to remove the additional sorting that put secondary threads after first threads. Do you see an issue that we remove the thread sorting logic? Thanks, Ray > -----Original Message----- > From: Lin, JackX > Sent: Monday, August 8, 2022 4:21 PM > To: devel@edk2.groups.io > Cc: Lin, JackX ; Lin, JackX ; C= hiu, > Chasel ; Dong, Eric ; Yao, > Jiewen ; Ni, Ray ; Chaganty, > Rangasai V ; Kuo, Donald > ; Kumar, Chandana C > ; Palakshareddy; Palakshareddy, Lavanya C > > Subject: [edk2-platforms: PATCH] Modify processor _UID ordering by CPU > default fused in MADT >=20 > BIOS should not reordering cpu processor_uid >=20 > Signed-off-by: JackX Lin > Cc: Chasel Chiu > Cc: Dong Eric > Cc: Jiewen Yao > Cc: Ray Ni > Cc: Rangasai V Chaganty > Cc: Donald Kuo > Cc: Chandana C Kumar > Cc: Palakshareddy, Lavanya C > Cc: JackX Lin > --- > Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 174 > +++++++++++++++++++++++++++++++++++++++------------------------------- > -------------------------------------------------------------------------= --------------------- > ---------- > 1 file changed, 39 insertions(+), 135 deletions(-) >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > index c7e87cbd7d..176e422e81 100644 > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > @@ -57,38 +57,9 @@ BOOLEAN mForceX2ApicId; > BOOLEAN mX2ApicEnabled; >=20 > EFI_MP_SERVICES_PROTOCOL *mMpService; > -BOOLEAN mCpuOrderSorted; > -EFI_CPU_ID_ORDER_MAP *mCpuApicIdOrderTable =3D NULL; > UINTN mNumberOfCpus =3D 0; > UINTN mNumberOfEnabledCPUs =3D 0; >=20 > - > -/** > - The function is called by PerformQuickSort to compare int values. > - > - @param[in] Left The pointer to first buffer. > - @param[in] Right The pointer to second buffer. > - > - @return -1 Buffer1 is less than Buffer2. > - @return 1 Buffer1 is greater than Buffer2. > - > -**/ > -INTN > -EFIAPI > -ApicIdCompareFunction ( > - IN CONST VOID *Left, > - IN CONST VOID *Right > - ) > -{ > - UINT32 LeftApicId; > - UINT32 RightApicId; > - > - LeftApicId =3D ((EFI_CPU_ID_ORDER_MAP *) Left)->ApicId; > - RightApicId =3D ((EFI_CPU_ID_ORDER_MAP *) Right)->ApicId; > - > - return (LeftApicId > RightApicId)? 1 : (-1); > -} > - > /** > Print Cpu Apic ID Table >=20 > @@ -116,7 +87,8 @@ DebugDisplayReOrderTable ( > EFI_STATUS > AppendCpuMapTableEntry ( > IN VOID *ApicPtr, > - IN UINT32 LocalApicCounter > + IN UINT32 LocalApicCounter, > + IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable > ) > { > EFI_STATUS Status; > @@ -131,9 +103,9 @@ AppendCpuMapTableEntry ( >=20 > if(Type =3D=3D EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC) { > if(!mX2ApicEnabled) { > - LocalApicPtr->Flags =3D > (UINT8)mCpuApicIdOrderTable[LocalApicCounter].Flags; > - LocalApicPtr->ApicId =3D > (UINT8)mCpuApicIdOrderTable[LocalApicCounter].ApicId; > - LocalApicPtr->AcpiProcessorUid =3D > (UINT8)mCpuApicIdOrderTable[LocalApicCounter].AcpiProcessorUid; > + LocalApicPtr->Flags =3D > (UINT8)CpuApicIdOrderTable[LocalApicCounter].Flags; > + LocalApicPtr->ApicId =3D > (UINT8)CpuApicIdOrderTable[LocalApicCounter].ApicId; > + LocalApicPtr->AcpiProcessorUid =3D > (UINT8)CpuApicIdOrderTable[LocalApicCounter].AcpiProcessorUid; > } else { > LocalApicPtr->Flags =3D 0; > LocalApicPtr->ApicId =3D 0xFF; > @@ -142,9 +114,9 @@ AppendCpuMapTableEntry ( > } > } else if(Type =3D=3D EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC) { > if(mX2ApicEnabled) { > - LocalX2ApicPtr->Flags =3D > (UINT8)mCpuApicIdOrderTable[LocalApicCounter].Flags; > - LocalX2ApicPtr->X2ApicId =3D > mCpuApicIdOrderTable[LocalApicCounter].ApicId; > - LocalX2ApicPtr->AcpiProcessorUid =3D > mCpuApicIdOrderTable[LocalApicCounter].AcpiProcessorUid; > + LocalX2ApicPtr->Flags =3D > (UINT8)CpuApicIdOrderTable[LocalApicCounter].Flags; > + LocalX2ApicPtr->X2ApicId =3D > CpuApicIdOrderTable[LocalApicCounter].ApicId; > + LocalX2ApicPtr->AcpiProcessorUid =3D > CpuApicIdOrderTable[LocalApicCounter].AcpiProcessorUid; > } else { > LocalX2ApicPtr->Flags =3D 0; > LocalX2ApicPtr->X2ApicId =3D (UINT32)-1; > @@ -159,32 +131,25 @@ AppendCpuMapTableEntry ( >=20 > } >=20 > +/** > + Collect all processors information and create a Cpu Apic Id table. > + > + @param[in] CpuApicIdOrderTable Buffer to store information of C= pu. > +**/ > EFI_STATUS > -SortCpuLocalApicInTable ( > - VOID > +CreateCpuLocalApicInTable ( > + IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable > ) > { > EFI_STATUS Status; > EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; > UINT32 Index; > UINT32 CurrProcessor; > - UINT32 BspApicId; > - EFI_CPU_ID_ORDER_MAP TempVal; > EFI_CPU_ID_ORDER_MAP *CpuIdMapPtr; > - UINT32 CoreThreadMask; > - EFI_CPU_ID_ORDER_MAP *TempCpuApicIdOrderTable; > UINT32 Socket; >=20 > - Index =3D 0; > Status =3D EFI_SUCCESS; >=20 > - if (mCpuOrderSorted) { > - return Status; > - } > - > - TempCpuApicIdOrderTable =3D AllocateZeroPool (mNumberOfCpus * sizeof > (EFI_CPU_ID_ORDER_MAP)); > - CoreThreadMask =3D (UINT32) ((1 << mNumOfBitShift) - 1); > - > for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus; > CurrProcessor++, Index++) { > Status =3D mMpService->GetProcessorInfo ( > mMpService, > @@ -192,7 +157,7 @@ SortCpuLocalApicInTable ( > &ProcessorInfoBuffer > ); >=20 > - CpuIdMapPtr =3D (EFI_CPU_ID_ORDER_MAP *) > &TempCpuApicIdOrderTable[Index]; > + CpuIdMapPtr =3D (EFI_CPU_ID_ORDER_MAP *) > &CpuApicIdOrderTable[Index]; > if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) !=3D 0)= { > CpuIdMapPtr->ApicId =3D (UINT32)ProcessorInfoBuffer.ProcessorId; > CpuIdMapPtr->Thread =3D ProcessorInfoBuffer.Location.Thread; > @@ -214,89 +179,26 @@ SortCpuLocalApicInTable ( > } //end if PROC ENABLE > } //end for CurrentProcessor >=20 > - //keep for debug purpose > - DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. > CoreThreadMask =3D %x, mNumOfBitShift =3D %x\n", CoreThreadMask, > mNumOfBitShift)); > - DebugDisplayReOrderTable (TempCpuApicIdOrderTable); > - > // > // Get Bsp Apic Id > // > - BspApicId =3D GetApicId (); > - DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", BspApicId)); > - > - // > - //check to see if 1st entry is BSP, if not swap it > - // > - if (TempCpuApicIdOrderTable[0].ApicId !=3D BspApicId) { > - for (Index =3D 0; Index < mNumberOfCpus; Index++) { > - if ((TempCpuApicIdOrderTable[Index].Flags =3D=3D 1) && > (TempCpuApicIdOrderTable[Index].ApicId =3D=3D BspApicId)) { > - CopyMem (&TempVal, &TempCpuApicIdOrderTable[Index], sizeof > (EFI_CPU_ID_ORDER_MAP)); > - CopyMem (&TempCpuApicIdOrderTable[Index], > &TempCpuApicIdOrderTable[0], sizeof (EFI_CPU_ID_ORDER_MAP)); > - CopyMem (&TempCpuApicIdOrderTable[0], &TempVal, sizeof > (EFI_CPU_ID_ORDER_MAP)); > - break; > - } > - } > - > - if (mNumberOfCpus <=3D Index) { > - DEBUG ((DEBUG_ERROR, "Asserting the SortCpuLocalApicInTable Index > Bufferflow\n")); > - return EFI_INVALID_PARAMETER; > - } > - } > - > - // > - // 1. Sort TempCpuApicIdOrderTable, > - // sort it by using ApicId from minimum to maximum (Socket0 to Sock= etN), > and the BSP must in the fist location of the table. > - // So, start sorting the table from the second element and total el= ements > are mNumberOfCpus-1. > - // > - PerformQuickSort ((TempCpuApicIdOrderTable + 1), (mNumberOfCpus - 1), > sizeof (EFI_CPU_ID_ORDER_MAP), (SORT_COMPARE) > ApicIdCompareFunction); > - > - // > - // 2. Sort and map the primary threads to the front of the > CpuApicIdOrderTable > - // > - for (CurrProcessor =3D 0, Index =3D 0; Index < mNumberOfCpus; Index++)= { > - if ((TempCpuApicIdOrderTable[Index].Thread) =3D=3D 0) { // primary t= hread > - CopyMem (&mCpuApicIdOrderTable[CurrProcessor], > &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP)); > - CurrProcessor++; > - } > - } > + DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", GetApicId ())); >=20 > - // > - // 3. Sort and map the second threads to the middle of the > CpuApicIdOrderTable > - // > - for (Index =3D 0; Index < mNumberOfCpus; Index++) { > - if ((TempCpuApicIdOrderTable[Index].Thread) =3D=3D 1) { //second thr= ead > - CopyMem (&mCpuApicIdOrderTable[CurrProcessor], > &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP)); > - CurrProcessor++; > - } > - } >=20 > // > - // 4. Sort and map the not enabled threads to the bottom of the > CpuApicIdOrderTable > - // > - for (Index =3D 0; Index < mNumberOfCpus; Index++) { > - if (TempCpuApicIdOrderTable[Index].Flags =3D=3D 0) { // not enabled > - CopyMem (&mCpuApicIdOrderTable[CurrProcessor], > &TempCpuApicIdOrderTable[Index], sizeof (EFI_CPU_ID_ORDER_MAP)); > - CurrProcessor++; > - } > - } > - > - // > - // 5. Re-assign AcpiProcessorId for AcpiProcessorUid uses purpose. > + // Fill in AcpiProcessorUid. > // > for (Socket =3D 0; Socket < FixedPcdGet32 (PcdMaxCpuSocketCount); > Socket++) { > for (CurrProcessor =3D 0, Index =3D 0; CurrProcessor < mNumberOfCpus= ; > CurrProcessor++) { > - if (mCpuApicIdOrderTable[CurrProcessor].Flags && > (mCpuApicIdOrderTable[CurrProcessor].SocketNum =3D=3D Socket)) { > - mCpuApicIdOrderTable[CurrProcessor].AcpiProcessorUid =3D > (mCpuApicIdOrderTable[CurrProcessor].SocketNum << mNumOfBitShift) + > Index; > + if (CpuApicIdOrderTable[CurrProcessor].Flags && > (CpuApicIdOrderTable[CurrProcessor].SocketNum =3D=3D Socket)) { > + CpuApicIdOrderTable[CurrProcessor].AcpiProcessorUid =3D > (CpuApicIdOrderTable[CurrProcessor].SocketNum << mNumOfBitShift) + > Index; > Index++; > } > } > } >=20 > - //keep for debug purpose > - DEBUG ((DEBUG_INFO, "APIC ID Order Table ReOrdered\n")); > - DebugDisplayReOrderTable (mCpuApicIdOrderTable); > - > - mCpuOrderSorted =3D TRUE; > + DEBUG ((DEBUG_INFO, "::ACPI:: APIC ID Order Table Init. > mNumOfBitShift =3D %x\n", mNumOfBitShift)); > + DebugDisplayReOrderTable (CpuApicIdOrderTable); >=20 > return Status; > } > @@ -750,6 +652,7 @@ InstallMadtFromScratch ( > EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCTURE LocalApciNmiStruct= ; > EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_STRUCTURE > ProcLocalX2ApicStruct; > EFI_ACPI_6_3_LOCAL_X2APIC_NMI_STRUCTURE > LocalX2ApicNmiStruct; > + EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTab= le; > STRUCTURE_HEADER **MadtStructs; > UINTN MaxMadtStructCount= ; > UINTN MadtStructsIndex; > @@ -760,18 +663,19 @@ InstallMadtFromScratch ( >=20 > MadtStructs =3D NULL; > NewMadtTable =3D NULL; > + CpuApicIdOrderTable =3D NULL; > MaxMadtStructCount =3D 0; >=20 > - mCpuApicIdOrderTable =3D AllocateZeroPool (mNumberOfCpus * sizeof > (EFI_CPU_ID_ORDER_MAP)); > - if (mCpuApicIdOrderTable =3D=3D NULL) { > - DEBUG ((DEBUG_ERROR, "Could not allocate mCpuApicIdOrderTable > structure pointer array\n")); > + CpuApicIdOrderTable =3D AllocateZeroPool (mNumberOfCpus * sizeof > (EFI_CPU_ID_ORDER_MAP)); > + if (CpuApicIdOrderTable =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "Could not allocate CpuApicIdOrderTable > structure pointer array\n")); > return EFI_OUT_OF_RESOURCES; > } >=20 > // Call for Local APIC ID Reorder > - Status =3D SortCpuLocalApicInTable (); > + Status =3D CreateCpuLocalApicInTable (CpuApicIdOrderTable); > if (EFI_ERROR (Status)) { > - DEBUG ((DEBUG_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status)= ); > + DEBUG ((DEBUG_ERROR, "CreateCpuLocalApicInTable failed: %r\n", > Status)); > goto Done; > } >=20 > @@ -824,10 +728,10 @@ InstallMadtFromScratch ( > // APIC ID as a UINT8, use a processor local APIC structure. Otherwi= se, > // use a processor local x2APIC structure. > // > - if (!mX2ApicEnabled && mCpuApicIdOrderTable[Index].ApicId < > MAX_UINT8) { > - ProcLocalApicStruct.Flags =3D (UINT8) > mCpuApicIdOrderTable[Index].Flags; > - ProcLocalApicStruct.ApicId =3D (UINT8) > mCpuApicIdOrderTable[Index].ApicId; > - ProcLocalApicStruct.AcpiProcessorUid =3D (UINT8) > mCpuApicIdOrderTable[Index].AcpiProcessorUid; > + if (!mX2ApicEnabled && CpuApicIdOrderTable[Index].ApicId < > MAX_UINT8) { > + ProcLocalApicStruct.Flags =3D (UINT8) > CpuApicIdOrderTable[Index].Flags; > + ProcLocalApicStruct.ApicId =3D (UINT8) > CpuApicIdOrderTable[Index].ApicId; > + ProcLocalApicStruct.AcpiProcessorUid =3D (UINT8) > CpuApicIdOrderTable[Index].AcpiProcessorUid; >=20 > ASSERT (MadtStructsIndex < MaxMadtStructCount); > Status =3D CopyStructure ( > @@ -835,10 +739,10 @@ InstallMadtFromScratch ( > (STRUCTURE_HEADER *) &ProcLocalApicStruct, > &MadtStructs[MadtStructsIndex++] > ); > - } else if (mCpuApicIdOrderTable[Index].ApicId !=3D 0xFFFFFFFF) { > - ProcLocalX2ApicStruct.Flags =3D (UINT8) > mCpuApicIdOrderTable[Index].Flags; > - ProcLocalX2ApicStruct.X2ApicId =3D > mCpuApicIdOrderTable[Index].ApicId; > - ProcLocalX2ApicStruct.AcpiProcessorUid =3D > mCpuApicIdOrderTable[Index].AcpiProcessorUid; > + } else if (CpuApicIdOrderTable[Index].ApicId !=3D 0xFFFFFFFF) { > + ProcLocalX2ApicStruct.Flags =3D (UINT8) > CpuApicIdOrderTable[Index].Flags; > + ProcLocalX2ApicStruct.X2ApicId =3D > CpuApicIdOrderTable[Index].ApicId; > + ProcLocalX2ApicStruct.AcpiProcessorUid =3D > CpuApicIdOrderTable[Index].AcpiProcessorUid; >=20 > ASSERT (MadtStructsIndex < MaxMadtStructCount); > Status =3D CopyStructure ( > @@ -1033,8 +937,8 @@ Done: > FreePool (NewMadtTable); > } >=20 > - if (mCpuApicIdOrderTable !=3D NULL) { > - FreePool (mCpuApicIdOrderTable); > + if (CpuApicIdOrderTable !=3D NULL) { > + FreePool (CpuApicIdOrderTable); > } >=20 > return Status; > -- > 2.32.0.windows.2