From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by mx.groups.io with SMTP id smtpd.web11.37957.1679475830336572822 for ; Wed, 22 Mar 2023 02:03:51 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=e5fKCYAA; spf=pass (domain: intel.com, ip: 192.55.52.43, 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=1679475830; x=1711011830; h=from:to:cc:subject:date:message-id:references: in-reply-to:mime-version; bh=Wvv4uSylYbpYTmvOPjVmEVZimwjgNZOty/xahSA0suk=; b=e5fKCYAAmWrGwfKYhaxFaFaZTf+bbZJaYWO1+zZq5bSQzd3Ku1PkuCgg isR9be8RCyicuH3NIWWwAwTpIl6/RmZiKF0URBM/qnAWApDZRKtN0Phxq P/HIMhaNHyNlk/6kUjrpR0yOz5LHsEoJbWZA4FBlDZTpxunerya8lQIKi ZSlyfI6tyTklmRRYRLgdOum6/5YuhrcpC3IofktsP78mYZgog/GXfsdoL xQlxD9R61POjSTDLMFAuZ9jIaSRFDam0KWYGcvXrq74ARZKotFgyo2lHz RDFDbcNMTvqoCdhy6WUm5xMhLJIzvWDWlqt7JGOI8EYFIsqZycVYKTHNW A==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="425448627" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208,217";a="425448627" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2023 02:03:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="856037131" X-IronPort-AV: E=Sophos;i="5.98,281,1673942400"; d="scan'208,217";a="856037131" Received: from fmsmsx601.amr.corp.intel.com ([10.18.126.81]) by orsmga005.jf.intel.com with ESMTP; 22 Mar 2023 02:03:49 -0700 Received: from fmsmsx611.amr.corp.intel.com (10.18.126.91) by fmsmsx601.amr.corp.intel.com (10.18.126.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 22 Mar 2023 02:03:48 -0700 Received: from FMSEDG603.ED.cps.intel.com (10.1.192.133) 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.2507.21 via Frontend Transport; Wed, 22 Mar 2023 02:03:48 -0700 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (104.47.56.173) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.21; Wed, 22 Mar 2023 02:03:48 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OiLOsqtPBqDHgGo+5tRMjlda7b6gGVe3fUixggqJ59J5wtp/y57dW0+9J2IROy+HnxJ7bqEPtNBvuY5iLV8kKc9gRwWyHgf4rBGW18YCsVHCLIWmV/MX6wePQL6o8U54PptxvF91qpj9zINOv6sb/Cqe10y49asVVvFSnjPG5vJrN3p0oN64uj1gcap9hHNhy3lTKASRMiw4blbbZaYO+6NhygswaHvZ7LnJ1IRaQ/oHFLgQzHS03eccgk2eqYJSIt45XLTqwbyBJkbPBa5aGd7Hxzl6WT/BlbajwRXjRis247Mf4di40+ZO27TPUvpzdF2pc5lrk6xEiqmfIw3Zjg== 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=14u9KdCHsEQ/ZOGA5rRN4USY7yKnKj2YaS/xcip4/uA=; b=fDDNh1/4s5xyoWvT8b9Q4aPkLpWU6lupVqqsRcxlUTAlD0K9cx+Ksmjlc08X0+c5UWgnGd0DrlAsi8AEFEMaM0Lg/f2vtNI3nKkG5mDOpGgvJUgp4sGayPJohJ42ApOQUfLcCy/cHASPet28avF1Zhd0scBg4naaoiqlT/jxQTOtVUQmnrNzeK4JUefbwXo6P7ixZLOVt1eo5kSJKerT8NjAC23K3J5u/h5bJeKpQ/YKtyhKzy/Diz+jzv1XCc4w1cY3X4D5rX5neUIsYLDenKPOgGDsxKKnTbITCfENj9/2iRvwDQvxsQnbS2rF8n+guZzZ9e84d1s/dGXVSCBz1w== 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 PH7PR11MB7099.namprd11.prod.outlook.com (2603:10b6:510:20e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.37; Wed, 22 Mar 2023 09:03:44 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69%7]) with mapi id 15.20.6178.037; Wed, 22 Mar 2023 09:03:44 +0000 From: "Ni, Ray" To: Gerd Hoffmann , "devel@edk2.groups.io" CC: "Kinney, Michael D" , "Aktas, Erdem" , James Bottomley , "Gao, Liming" , =?iso-8859-1?Q?Marvin_H=E4user?= , Pawel Polawski , Michael Roth , Tom Lendacky , Gerd Hoffmann , "Yao, Jiewen" , "Wang, Jian J" , Ard Biesheuvel , "Justen, Jordan L" , "Wu, Hao A" , "Liu, Zhiguang" , "Xu, Min M" , Oliver Steffen Subject: Re: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro. Thread-Topic: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro. Thread-Index: AQHZXIxnirMy6xVtRkqkLnnHvAvo1a8GgJkn Date: Wed, 22 Mar 2023 09:03:44 +0000 Message-ID: References: <20230322070243.410903-1-kraxel@redhat.com> <20230322070243.410903-7-kraxel@redhat.com> In-Reply-To: <20230322070243.410903-7-kraxel@redhat.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_|PH7PR11MB7099:EE_ x-ms-office365-filtering-correlation-id: 8301c811-8b09-49a6-0bd6-08db2ab456c6 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: 0Ikl8gGZp7MhYkr1pjpDIxqpJcWTbiKmOIuoKI3sC1a238hl2tinR93j6QX3KHi2ntTrTGwJsInZqWLuqI5DNihnLOYkypKh+6ZR9wtU/0SnYO0B6eRR5qYGbCEKvN0WVJh+PMasK7+MI6NBwKUwT/tWp12IICZczEcjJdyqkjJZ/vovnV5CqtHMgal+izPDXfTnVRIxfVPJTIwqMml6grsHLjETV85eiqBzc7po57McvCpfJ7PmZyNmBXpzxnG+sEfmaES6yatU6ftlMi1y2TAwz2e5mtkBG9OYaDZEI9hpM2uWAa7CNC/jA87FBQrmQLdhO/3uhvmyzgqPHX3z3/6KUVA+sMpEl45LXajzgbGY2ok7KZfahh+ogmKAPzrQ3CRMkTt4Ta4/2vjUN1WOT4+RhRKTu+PxOYsC9q/xGxDZT2ZruIx/weB+qQF8mkEZuriduw1rq4rdDZoz/2N61bstSstcepMbGoVswgOXHwVOmXHk5D9wbIUk+/K1AryDetUlilNZP5UmUGPlnT/oRqqPRCzVVz2mAaW4YM+7nKBsED8UPu0OLesTE8mH3XnvQCkYDBHPYVv7Q539cdusB57e0Z61tqPV75FIsN8UJTAXrUB7AwhPaxQ4KIgOqsu0I2nHim/WlKplbwbyZIo0zkF8j3cf47h2MaAcb2fMxW5KKfPqxOh4N+cIhXcFveQAY+tYhJfLU2j+RJgwpgzPEw== 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:(13230025)(39860400002)(366004)(346002)(136003)(396003)(376002)(451199018)(7696005)(186003)(316002)(83380400001)(478600001)(71200400001)(66446008)(91956017)(66476007)(66556008)(66946007)(64756008)(76116006)(8676002)(110136005)(53546011)(6506007)(54906003)(9686003)(4326008)(52536014)(41300700001)(7416002)(5660300002)(82960400001)(38100700002)(2906002)(8936002)(122000001)(55016003)(38070700005)(86362001)(33656002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?o5h3/j8KFvjhPTj8k/egi8sJLff7Osc8ee/Xr/Qk72xabN4i3ZeGDxc9L/?= =?iso-8859-1?Q?OpQjyw1p8erS8zSfv0QqKMHt/VQ6yZnrb+bpQHWqONtcbe0kV68fxE1hMb?= =?iso-8859-1?Q?LswOuvziLV2cHE9wzvXjBze7vCbq1qJ9hL6vkZHXj6GNE7Bgq3kB4a5y1s?= =?iso-8859-1?Q?cZ4NmugFuJxglI+Puo+6cmTkBGdTUeGf7lkFJIv1TPZ89fN1m9kiEyFJTc?= =?iso-8859-1?Q?zVsCIXwZUweftl96kqRd2ee8e38/7MlPK0R3H5sO4z3AafBbMVADFhPjV9?= =?iso-8859-1?Q?f1JzCptXoiZXBo+j0ZXhmwdoTjHebGX9Xoc2PaLzZsb1f0+kElji3KX70v?= =?iso-8859-1?Q?sk+ama/ptp0fot+UjLSKUHO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859-1?Q?E0X3rdrzHCA0/T9gLMtVTE4wBZMpkL9x5+UW15nC1aq0Sr2jEmtHXPPurY?= =?iso-8859-1?Q?/Rqjxzusr/zDCqjpZ/qQzE0bc5j1WTjOGr98exxThBCJsW/cwTaVQFqtRJ?= =?iso-8859-1?Q?TQK/9ALKcCW4OGnkTuthuI9lM23IM/6SvnsskDaXNEDIgvunJ0WNX5cJUB?= =?iso-8859-1?Q?dwUu6csBAoTVM4r8vz2evoAACl7GjKgsKvs2UG255SSrBhAPR5Zup7Zgor?= =?iso-8859-1?Q?LDLAQig7PmzgCXnsy68JnlJZDBzTRXYV0M8jUXZenYJvLj2oQbl9vKbba6?= =?iso-8859-1?Q?kKy6GAEz6sa1JJOmFuUhuKSVe6VQvV5d73cQkW0M5GtfupfYvX5wXEPPdG?= =?iso-8859-1?Q?dQjqGodo5JOdcA2kRWkzsFnjyOHmeIVWaKlqmtYUcK/gWZXSUPrAUnT3I1?= =?iso-8859-1?Q?hxrkD4g1tlVmT8g5ayLS6KG7bz7tP2cTy/EjdpHExTaiQqD+jsnLaafu4m?= =?iso-8859-1?Q?Bx5g=3D=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: 8301c811-8b09-49a6-0bd6-08db2ab456c6 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2023 09:03:44.1200 (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: WSB1OoFNIv/JOZRk6o9dWE8uhrKTRNTEeIiKydgSNLscQVlAO2/n07DSv6P6ihlKhMUmZ8sQCeQphN72HNt9yA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7099 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB824456ED78EBA888324BE3018C869MN6PR11MB8244namp_" --_000_MN6PR11MB824456ED78EBA888324BE3018C869MN6PR11MB8244namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni thanks, ray ________________________________ From: Gerd Hoffmann Sent: Wednesday, March 22, 2023 3:02:43 PM To: devel@edk2.groups.io Cc: Kinney, Michael D ; Aktas, Erdem ; James Bottomley ; Gao, Liming ; Marvin H=E4user ; Pawel Polawski ; Michael Roth ; Tom Lendacky ; Gerd Hoffmann ; Yao, Jiewen ; Wang, Jian J ; Ard Biesheuvel ; Justen, Jordan L ; Wu, H= ao A ; Liu, Zhiguang ; Ni, Ray = ; Xu, Min M ; Oliver Steffen Subject: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro. Drop MtrrLibIsPowerOfTwo function, use the new IS_POW2() macro instead. The ASSERT() removed (inside MtrrLibIsPowerOfTwo) is superfluous, another ASSERT() a few lines up in MtrrLibCalculateMtrrs() already guarantees that Length can not be zero at this point. Signed-off-by: Gerd Hoffmann --- UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c index e5c862c83d61..dd0b668d7782 100644 --- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c +++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c @@ -1253,21 +1253,6 @@ MtrrLibLowestType ( return (MTRR_MEMORY_CACHE_TYPE)Type; } -/** - Return TRUE when the Operand is exactly power of 2. - - @retval TRUE Operand is exactly power of 2. - @retval FALSE Operand is not power of 2. -**/ -BOOLEAN -MtrrLibIsPowerOfTwo ( - IN UINT64 Operand - ) -{ - ASSERT (Operand !=3D 0); - return (BOOLEAN)((Operand & (Operand - 1)) =3D=3D 0); -} - /** Calculate the subtractive path from vertex Start to Stop. @@ -1638,7 +1623,7 @@ MtrrLibCalculateMtrrs ( break; } - if ((Weight[M (Start, Stop)] =3D=3D MAX_WEIGHT) && MtrrLibIsPowerO= fTwo (Length)) { + if ((Weight[M (Start, Stop)] =3D=3D MAX_WEIGHT) && IS_POW2 (Length= )) { if (MtrrLibGetNumberOfTypes ( Ranges, RangeCount, -- 2.39.2 --_000_MN6PR11MB824456ED78EBA888324BE3018C869MN6PR11MB8244namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Ray Ni <ray.ni@intel.com>

thanks,
ray

From: Gerd Hoffmann <kra= xel@redhat.com>
Sent: Wednesday, March 22, 2023 3:02:43 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Aktas, Erd= em <erdemaktas@google.com>; James Bottomley <jejb@linux.ibm.com>= ;; Gao, Liming <gaoliming@byosoft.com.cn>; Marvin H=E4user <mhaeus= er@posteo.de>; Pawel Polawski <ppolawsk@redhat.com>; Michael Roth <michael.roth@amd.com>; Tom Lendacky <thomas.lendacky@amd.co= m>; Gerd Hoffmann <kraxel@redhat.com>; Yao, Jiewen <jiewen.yao@= intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Ard Biesheuvel &= lt;ardb+tianocore@kernel.org>; Justen, Jordan L <jordan.l.justen@inte= l.com>; Wu, Hao A <hao.a.wu@intel.com>; Liu, Zhiguang <zhiguang.liu@intel= .com>; Ni, Ray <ray.ni@intel.com>; Xu, Min M <min.m.xu@intel.co= m>; Oliver Steffen <osteffen@redhat.com>
Subject: [PATCH v2 6/6] UefiCpuPkg/MtrrLib: use new IS_POW2() macro.=
 
Drop MtrrLibIsPowerOfTwo function, use the new IS_= POW2() macro instead.

The ASSERT() removed (inside MtrrLibIsPowerOfTwo) is superfluous,
another ASSERT() a few lines up in MtrrLibCalculateMtrrs() already
guarantees that Length can not be zero at this point.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/Mtrr= Lib/MtrrLib.c
index e5c862c83d61..dd0b668d7782 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -1253,21 +1253,6 @@ MtrrLibLowestType (
   return (MTRR_MEMORY_CACHE_TYPE)Type;
 }
 
-/**
-  Return TRUE when the Operand is exactly power of 2.
-
-  @retval TRUE  Operand is exactly power of 2.
-  @retval FALSE Operand is not power of 2.
-**/
-BOOLEAN
-MtrrLibIsPowerOfTwo (
-  IN     UINT64  Operand
-  )
-{
-  ASSERT (Operand !=3D 0);
-  return (BOOLEAN)((Operand & (Operand - 1)) =3D=3D 0);
-}
-
 /**
   Calculate the subtractive path from vertex Start to Stop.
 
@@ -1638,7 +1623,7 @@ MtrrLibCalculateMtrrs (
           break;
         }
 
-        if ((Weight[M (Start, Stop)] = =3D=3D MAX_WEIGHT) && MtrrLibIsPowerOfTwo (Length)) {
+        if ((Weight[M (Start, Stop)] = =3D=3D MAX_WEIGHT) && IS_POW2 (Length)) {
           if (MtrrLibGet= NumberOfTypes (
            &nb= sp;    Ranges,
            &nb= sp;    RangeCount,
--
2.39.2

--_000_MN6PR11MB824456ED78EBA888324BE3018C869MN6PR11MB8244namp_--