From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web12.8937.1660029173905027327 for ; Tue, 09 Aug 2022 00:12:54 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=d4+k4h4P; spf=pass (domain: intel.com, ip: 192.55.52.151, 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=1660029173; x=1691565173; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=LhXVhrGq2zipSRwGjTF5+jQCMyYwtPwWBPOF2nJEGto=; b=d4+k4h4PESKg/fRb+H/+wMU4brqA3IR8VpNOQppuRupI/4lSmZDgI71t dgEaKCGmaNvG7sD5vNldFMu8HK9LkH3BZ9wnHbyStVNMbd3TOICVN5Ioo uqsHRMt1Vhf4FCqXAqQ0AaiWuo3a2HeptonFUojfDcyaWdoCqAKIpifKe TrpjhCMSMg5l5BNRGUhl8bK17ZoiFDsuV8lCE+AU3vep8nRnNGI0Iz6Wv OLYKlDmaTGIhn2PNNOUfADUo+wOvplVDeXgxWTdMr3bijAZGb7TfYajsR RrBVQKWuyOV3lBSXTQSnvCqnmibUAZgrnKVHkbG5u3RZcgbonk7xjkSVW Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10433"; a="271157708" X-IronPort-AV: E=Sophos;i="5.93,223,1654585200"; d="scan'208";a="271157708" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Aug 2022 00:12:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.93,223,1654585200"; d="scan'208";a="608117409" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmsmga007.fm.intel.com with ESMTP; 09 Aug 2022 00:12:45 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.2375.28; Tue, 9 Aug 2022 00:12:45 -0700 Received: from orsmsx607.amr.corp.intel.com (10.22.229.20) by ORSMSX611.amr.corp.intel.com (10.22.229.24) 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 00:12:44 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx607.amr.corp.intel.com (10.22.229.20) 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 00:12:44 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (134.134.137.102) 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 00:12:44 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FdECV61n2SbEBcvo0IWInfEryrkwlUWTpvLuYNTpEXiDcvEn6T1q8LBcufmtmoya6CM201plWTYxvW1+aPrsAYSLWje8M3ZUlT16u6HCIVC/uNgpljyNVKEbHtm28etlH0DSj6ugOf7jPgQAuVAZdhCGXvZhhq58TAeLehgMaCGTx4lY2j5xSPLl/ncvgesNkcNQznecAvkgHeP0xNWttDd8F4ufKJYa2P+P+vU3f1SR84bZnnV9ziXkXav9z0RIM4Y26ddmcGqB6tQvAKaoYHktgWVYa3zdnH2+tkwXQY2iBCwMMDcxWw4I01qfzmXM6iakdo8dsI/R6XWBwu2qOg== 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=ML2GEcBQErDkn9+vFzjjal0rMCAmgPuBEQqpMbxq6m4=; b=YTMPge0CeXwf+np4Mp/Rw4z1biXfTihFAMPaRSQc78btCVRWkXTBXWBeo0NZsNqGnXS84I4q+fJALPelnRfHva409mUfrJ8C9VtFQNHpeppKvJRbTAlB+gnLlcA6wS3CFYZeKy/Pxf8QSQBAL0CEAId4EattMysx3yFkDR99iK3g4h6ZslHjH65OPJ8UGCHn1Y39//BWHfKTliHYFgJtGcEGCCGwN8fdjrGarqbzekufR4qIlyiYA4Uz1/wpPjIyMDwBkTk+9GIe35DvRQTzguQjBYgOdb3ldDHet1J2JrG9x1AqhuvtED+1wIeQ9HYXPDE6vMJlvw6a6vUnIHEthw== 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 MN2PR11MB4318.namprd11.prod.outlook.com (2603:10b6:208:17a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Tue, 9 Aug 2022 07:12:37 +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; Tue, 9 Aug 2022 07:12:33 +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" , "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/rxuV9HgBBk06A3zrSlAd8i62mKEWQ Date: Tue, 9 Aug 2022 07:12:33 +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: d24e6d71-0047-4901-ea5a-08da79d687f0 x-ms-traffictypediagnostic: MN2PR11MB4318:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Qz59MXp0R665nMMrnPL4hw7u7NH8+HxK/c+e2rXnZq3arOavLuW1xV4VxlDYZCPiZ1P5m8m07XnL45YWFK/ZstV5Ox89lQNZKv6NZJ9fK7pJ2Foaf2KId/rxbtC6cy2fq4EAA5eF1tGk2gThbDTwbk/+8ae3dt2njh0oOwWMvZOSgJl0NexDD7hUUlnr1Q88+AY2R/axtgWnMwj5O8+Vc0aiqsMWl9X06rL+10euhVblOfSqotBS1waLWJPr7/uefjAe+2OuSP0rjVuwgxSskivua8KCRENkpa4y9C4jYwuvKQRB1jDPrEFcYDO5vBWqB0/twuiSQwi89H0WZri1fV5FgvV+LB+pAaNOzMAcXImc90noNuEYftgW5c+XvKsRd2H6RnjGKaiNKGwYxewwFkkDXHqf8NYoagph+1VcFDlUpbMvk+USvpVfrjYjWanLXqyWMw3n+vttePz5DkSwv91dWMrewlvqdhfSh4zRVw7CAZnBLtK7U9byGq8EgMF7GrJDIpM8D8xW7XbSKmsuntKCfh03JLK+uGNNM2Uu2cvQiGWk70n0t1oYSFZTv70ArCFGbvxiB9t5HPFOC+MkWEN2CJ81RPbMtYrbdgFaPhW9h8dNq7WGxb3PmbETbCf5zoL3vV8bxbroNBszVcfu441WgFq7t/Ss91HLp58oG4zOKurHRmddh34IWwfLBBLHjdl2Q6GHBridkhL/+HEE9Obalfg0vj7rkEIWDZqvnEccwlY9iCzQnK3YKPOF5KohWX37RQPkmENz3cEXWQMueU/BCcpsxwsm6QzpV5DtgHs= 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)(366004)(376002)(396003)(136003)(346002)(8676002)(4326008)(66446008)(38070700005)(186003)(38100700002)(19627235002)(122000001)(54906003)(76116006)(66476007)(110136005)(66946007)(64756008)(316002)(107886003)(9686003)(5660300002)(26005)(66556008)(71200400001)(30864003)(8936002)(52536014)(41300700001)(6506007)(53546011)(86362001)(7696005)(83380400001)(55016003)(2906002)(82960400001)(478600001)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?WACOQyOYWp+wzQZf9gEXULlXLTV363nD/oxK8/RjlIH3r/sR69kL/GUl1HSm?= =?us-ascii?Q?3ieZD+UB63DVc8gQ/Jy7zJvcyZ4xLOVSnlJNOOkFmTo3meVGGB4Igb2m5pMe?= =?us-ascii?Q?jeLI8Yi7Czp7TlFqulsRmH91pMtqNJd/MJtbaWF38nt0foYT1r3OjGWIAjrk?= =?us-ascii?Q?aLVOT+ubEoLEsyUYIz2i4bZPTTQEe5Qj0xjizrD4hiVwM4hfKFZh6mZ1Izdr?= =?us-ascii?Q?VJ/iZ75Q0p6ERpGqDpdOZ2zBK+le2HBIoAFoanxluCeJBIxd3ktCF8foG7kC?= =?us-ascii?Q?ICh0iazHctEJfG8zsUXe6nWGL22xWyJwe/x1ocOr2tJNQqBgWGjMCV+08ueI?= =?us-ascii?Q?XwdrFLyfNhTtRxrur9nn9+7Uf96HSXXXyrI286U9vg17ejFI9jxTh1CXtsj6?= =?us-ascii?Q?8PiuojM4SASx1UyKIjAj3ZHwlnwwj68vqLEukiKfuZWbQLZgTxdJBXAQHSPH?= =?us-ascii?Q?/ce1qoXJYrZZ5DbBikqipg0BEklsmfRPRmYfOckzopY+FJf60SJbi80QyT0X?= =?us-ascii?Q?SNmBGBk41I1l0F1SWa0xQeu3kxG2KwdEtTHe4BAGIPp4faw4kGiRH4GKEajx?= =?us-ascii?Q?JT28DjqKmZm+PPI8oja/S26jrQAuwGiHHwZJl7ELRIMt//PZQPnCFurYXwrB?= =?us-ascii?Q?dBDu30EmApzPNO82i6UR0LUkJILNdoeGVTTYEPoSeNn+O+nsa0hrTbU9H35M?= =?us-ascii?Q?YXu0613G4JWn6WVAjmm9wNE8Hz2IaUJJIZr6+YSN/lOzTJAkv4JfCIVA6DfZ?= =?us-ascii?Q?/r6xQoNaiSCpMrpK6uANsxCm/FoEV8drcILMVc+8Kp0xFlT4VXeLdUa6QgmM?= =?us-ascii?Q?pIKVT7CupPYPg8cJ33YXJUtddBuEt47Mr7jF9m/cOktGP0zLCWFFdhMlSvk1?= =?us-ascii?Q?Gw9wUCMXVu0hNwVKfrP5n7PshEb6c4W88TfWzn5QF72Rjiyxt+RLvgIj0Ekw?= =?us-ascii?Q?ltTP9Djz0tP/VF7Fqi1/irlo4zLIvqGkIQZDkoG3dyfgJTC2APeEpJKws7qN?= =?us-ascii?Q?J9acrg9Y2coHNuj2eXrw4slFbWvxLvstDIuVq1LeJNjTPNshNGmKhyfenXtg?= =?us-ascii?Q?mOEf4rZE7Hwo4ToyMcOZI9DDYJXyvuxSJRfD9u59E5f/3t7YDvxAakijXMwQ?= =?us-ascii?Q?pBt8f/ZsW7ILmrzyHyGEyRZlALBzfgFphg06LWSwYQ0b9zZN9eoKTCogibix?= =?us-ascii?Q?vrKzO5zgmYhSfZAfcJzJtULMT3AdM8PCXokch5ZRHU8n6BgmVtKDO2UFsYqh?= =?us-ascii?Q?UXajnq9lsPDKceS40whF1f3vgQ5AIAY/ye+kxVpsmvIhCt5+8oga8CE7oYDj?= =?us-ascii?Q?2+xfK4rujxOCmVrPgGmRIWSDqYhPHMDEmpZkoTyHA8v1MjheaQdSsHk4ZkM4?= =?us-ascii?Q?GiWaFthB+gLxlxGuIgVSJcmiqWC5A+ENatJQCjD64a65V1B40OqmhZ8t//jk?= =?us-ascii?Q?lhJQCF7sGBwq3VsAQ2lQBd0vLWkws23vSXBrdWw0zM3z4o4bcp4nHkD67lIo?= =?us-ascii?Q?52b/ppakye/cV+T+lehGfzzcMXujrhaXp2nDqH9ynkMGm+47OguFtAYYxH60?= =?us-ascii?Q?nOMAC0enGsPLiCXiYDHv1v0/4wFiaN7EbfsqFHHz?= 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: d24e6d71-0047-4901-ea5a-08da79d687f0 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Aug 2022 07:12:33.6865 (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: yuv+F80Udj4dq/caEZdIWeryqVTFCqWfkO0X3Ifq6ZZeUzaVb+uYZWOsaz3Ks9c7PTYhm45V6aAEgu1F7YSz4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR11MB4318 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 Reviewed-by: Ray Ni > -----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