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.web11.5477.1686219430567193290 for ; Thu, 08 Jun 2023 03:17:10 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=ALC5muwN; 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=1686219430; x=1717755430; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=TN+6npgf6+chv5QZSqGhXnxaZamKdCjKZ/1FagnzxNk=; b=ALC5muwNuhCUz+5M3aFlFMv5uvM+GFaCXy0zId4vm+DAIvefxY3wzW3n Fe79d7iEiuwxUJJQAaiEhbAwkxvaCFMJ8QYE78Nq3De5wBDewdGXMEVpR B3NkAhNqZt0RPsbGjt6TJXwVkstpV//6O0J9U0f9cBUPt7QE3xWoEC1pE NgxVQCOdkAPB0HBzT1VmBsSBCfFTsPtc7BAl9kgI0hUrFKzXDziXb2wRS dKWAzEoiqRSsgPdhM6HnCqW1M2ujI6SnvAlCENnJYkRd4NXR7/ioiExOl eIDvhfV46zDK/5lKyPQ9KZhxc6spK9XVC7kBtM0Vd3oTqK/4kmYf9zlOE g==; X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="341924965" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="341924965" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Jun 2023 03:16:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10734"; a="709924658" X-IronPort-AV: E=Sophos;i="6.00,226,1681196400"; d="scan'208";a="709924658" Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by orsmga002.jf.intel.com with ESMTP; 08 Jun 2023 03:16:53 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Thu, 8 Jun 2023 03:16:53 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Thu, 8 Jun 2023 03:16:53 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.168) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Thu, 8 Jun 2023 03:16:53 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mC65b0ntrcMKI6eHwRkKsXj2BIWTZXlw5olcEOZY/FIXqY844Cdkfbx23h9wl61pORAf5qpfTpTd1lc94V0oDi8lMjxAD9b9cWohab7LQlye+Lm4MppcGBOpJXw2yfd/wgT7hQQGgNp25x+9hW5hUb0t52/cukf5m+ZEHbQRj6kxLFZCOkNSrQyAyvzeolDr0I5p+Y02JkkWP7l3YQUKAFQfCMeou7IraLceP68SLsYjjy8EdAlX4m1KvuWb64Jcewwn+Ncw7g2zA3HcZN4LB+Q83f4RXHXXkkI9sBxx0O3O3DAWu3O0xjaS/Xmq4kYujifQUPsFvIMwzyqhkfdTVw== 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=vtFAv1cepvorZ7wG/rXQ6bz5vNpdzsi3H8yPOgq5uFc=; b=ZyHmJOwo3L608XqlAXP48mKrmfa7gUJbbG8NxYbnUbaXeGFbzCDQe6oYph4gsMY1XEkqZKaoStrnptyli9BsiUFmwy3MCeyOoQqHsF/heAmxlAXDO7usnXdM7rcm0iH0c839nr1LT/JeqH0XPL/NI5RL8OQcA8DaZ0w7G37VJLWWzwNgBEWe2A4IgPdHcvhkAdqtx02na7vCrT4IkDvxFZYcwSbkPAYCOYl1bhag4MTxTI8/gyGDL4hInPuvLXkCFhXR2hqfSy90Gl5Y7wn8zmC4wYhv/nyPQ0TMQUTINghFKX05e0XDVoWiQmHiJMr81tIHTvULOl1rd5xk4/g50g== 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 PH0PR11MB4934.namprd11.prod.outlook.com (2603:10b6:510:30::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Thu, 8 Jun 2023 10:16:53 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::892b:b8e6:bab7:635d%2]) with mapi id 15.20.6455.034; Thu, 8 Jun 2023 10:16:53 +0000 From: "Ni, Ray" To: "Tan, Dun" , "devel@edk2.groups.io" CC: "Dong, Eric" , "Kumar, Rahul R" , Gerd Hoffmann Subject: Re: [Patch V5 11/14] UefiCpuPkg: Sort mSmmCpuSmramRanges in FindSmramInfo Thread-Topic: [Patch V5 11/14] UefiCpuPkg: Sort mSmmCpuSmramRanges in FindSmramInfo Thread-Index: AQHZmbEGEYCBwmxc20aqhSYv303yaK+AsUFg Date: Thu, 8 Jun 2023 10:16:53 +0000 Message-ID: References: <20230608022742.1292-1-dun.tan@intel.com> <20230608022742.1292-12-dun.tan@intel.com> In-Reply-To: <20230608022742.1292-12-dun.tan@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_|PH0PR11MB4934:EE_ x-ms-office365-filtering-correlation-id: 71799109-3142-456b-c782-08db68097b14 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: g378DbRvUbbdRhJJst5CMvfcsy/wEWaSk2Aib231ocVwy9NGlzN/GxTX0DlfaZxKCDHFC1kLSZTXR3AbBA4UerSXY2GPVCVbQgiQFPmuFWnA5O3JZYwDJcbtI4w3kxSbBA9uvObi86BgcwO1nsAe/65N6jByNBvspJ88jRYg3c2HLN8p/38zXOMne/SPyE1d4bIgb9XIs2SbkWCEPh4F0qicmMchU1kR4OBQpTQ8MTkWG8DYiDvE41LdKQSFFAF0ro1cc/Oy/1yTvvIaDao7IagmOx4Ms404xES+Utoz7ujTJG/YNDVtNxxnw1krcvo6saEekjGc1kDdlLWbX0iNjpccb6AF8bYqsQX9/PhSxcpOCWy1Zucel+Frd7Hi122P8c2QRZy19L0Q4TV+g4vO3z4a2hOFkWt5y0KMBU1SqLro9chPrJkr4iaDJuz2Nsy55svK0BjJE0VrZu/2H+Fn3eRe/ZUKe/fIYfJS7+z57D4I3IjBBGSj1rx/69lU6uuxipNwAkVZ7v35KVtdJRwwrE9i6F/dD4PJnf+qcbLrDZnAY2+O6AlT/bP/JkzvGSNkS/BrcK8XMG9R809IaTro03eUPyDsx71bDXz4wR/stzgJIHPtSU4Fv+0+/vCSBaoWQx/M8pQ9um6oSiTBWLrTxw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(376002)(346002)(39860400002)(396003)(366004)(136003)(451199021)(41300700001)(8676002)(4326008)(66446008)(76116006)(66556008)(66476007)(64756008)(8936002)(66946007)(110136005)(5660300002)(316002)(52536014)(54906003)(55016003)(2906002)(478600001)(38100700002)(82960400001)(122000001)(9686003)(6506007)(53546011)(86362001)(26005)(186003)(71200400001)(7696005)(83380400001)(38070700005)(33656002)(145543001);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?u4CJ60BTK04lKtKhmyK/Jw9t6YCuXJ30Wi2m8HEYD279VRlyTfsz9eYfIAUL?= =?us-ascii?Q?kbJcKPKY1JnN6MMko4V0xElyobucQdVxHJr4ng/bbe8967n5q6hpH/AvT0Ip?= =?us-ascii?Q?acW8B3mwSCFYX7noSKWQMC/ud59ol9zYqLbSvqzTTPEU1agoLsniRXiKwUXb?= =?us-ascii?Q?22KaPP0GZw3V5VY0+/vHE7HxKVT831z/62eejwwmUCOLoRBs5trFkx/PRp5Q?= =?us-ascii?Q?ytw0hhutQqkadXUjaRvXQjOU8xU1tufKS+8Zx+/mg7iCDsM6ilnMt48XR5WV?= =?us-ascii?Q?vkwAsMK4WsrxwWpngBQsmjaiN7K+KroGaXSY6gyo+aG3DE4YDz9ZG12yKxNt?= =?us-ascii?Q?/GuOK5996XicXGeIL0zYHiz0RCCzwEyMFC7IPRYT6f3Ne2zQFeMZCYorsESk?= =?us-ascii?Q?9MCJwEUTWC5wT6SXR7foecD/i9EvDk1vEIZSrUL1+KLhp8P8RlGx9IRi70Uv?= =?us-ascii?Q?AKJrFaDZscPcWzBdveWCB+m8rcKCgddwDgAxpxE564ZCETLDaWrvBNSP0dJS?= =?us-ascii?Q?8pgfOCpQjwsoSZyGcXTkKQRExFVcubzBs1pkLfWXMJZ3vIGw442vhxYed/AP?= =?us-ascii?Q?Z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=?us-ascii?Q?Ee14QTofEQHhpSBwwqx/kZ3BjZsf1fvOKsw6B5lmnaBhi2ijxZSG1rocZWHv?= =?us-ascii?Q?mOhJH0zmpklmKE2MAsDEivKg6JwpQGGa/gxz6PwI?= 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: 71799109-3142-456b-c782-08db68097b14 X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Jun 2023 10:16:53.1797 (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: eFefKPx+hb2ivgKlJQpKpz8FI1PYvsaL9GnK+VMxPANRmFCVIWZRTVoATmSLTm02ujG35srUxERIUrkWp2mizQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR11MB4934 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: Tan, Dun > Sent: Thursday, June 8, 2023 10:28 AM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Ni, Ray ; Kumar, > Rahul R ; Gerd Hoffmann > Subject: [Patch V5 11/14] UefiCpuPkg: Sort mSmmCpuSmramRanges in > FindSmramInfo >=20 > Sort mSmmCpuSmramRanges after get the SMRAM info in > FindSmramInfo() function. >=20 > Signed-off-by: Dun Tan > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > --- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 32 > ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > index 2144d6ade8..2568ffd677 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > @@ -1197,6 +1197,32 @@ PiCpuSmmEntry ( > return EFI_SUCCESS; > } >=20 > +/** > + Function to compare 2 EFI_SMRAM_DESCRIPTOR based on CpuStart. > + > + @param[in] Buffer1 pointer to Device Path poiner to compare > + @param[in] Buffer2 pointer to second DevicePath pointer to = compare > + > + @retval 0 Buffer1 equal to Buffer2 > + @retval <0 Buffer1 is less than Buffer2 > + @retval >0 Buffer1 is greater than Buffer2 > +**/ > +INTN > +EFIAPI > +CpuSmramRangeCompare ( > + IN CONST VOID *Buffer1, > + IN CONST VOID *Buffer2 > + ) > +{ > + if (((EFI_SMRAM_DESCRIPTOR *)Buffer1)->CpuStart > > ((EFI_SMRAM_DESCRIPTOR *)Buffer2)->CpuStart) { > + return 1; > + } else if (((EFI_SMRAM_DESCRIPTOR *)Buffer1)->CpuStart < > ((EFI_SMRAM_DESCRIPTOR *)Buffer2)->CpuStart) { > + return -1; > + } > + > + return 0; > +} > + > /** >=20 > Find out SMRAM information including SMRR base and SMRR size. > @@ -1218,6 +1244,7 @@ FindSmramInfo ( > UINTN Index; > UINT64 MaxSize; > BOOLEAN Found; > + EFI_SMRAM_DESCRIPTOR SmramDescriptor; >=20 > // > // Get SMM Access Protocol > @@ -1240,6 +1267,11 @@ FindSmramInfo ( >=20 > mSmmCpuSmramRangeCount =3D Size / sizeof (EFI_SMRAM_DESCRIPTOR); >=20 > + // > + // Sort the mSmmCpuSmramRanges > + // > + QuickSort (mSmmCpuSmramRanges, mSmmCpuSmramRangeCount, sizeof > (EFI_SMRAM_DESCRIPTOR), > (BASE_SORT_COMPARE)CpuSmramRangeCompare, &SmramDescriptor); > + > // > // Find the largest SMRAM range between 1MB and 4GB that is at least 2= 56K > - 4K in size > // > -- > 2.31.1.windows.1