From nobody Mon Feb 9 02:12:28 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+91452+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91452+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1658150328; cv=none; d=zohomail.com; s=zohoarc; b=iZqNk7GlEHcFXHSpfRANvyuCJMlQvqOCvalnbWpCzh4GzrZxsXT7Q/UukcYmeJI43fVBkSEt4qRH51I9ubbVQ4q9s3aR/Oh7XSeNBGo3e60fWBB9kDCPSEQM/4oW8++ppTkRTkRQXwY1kFDVLIQWcoGArPl/8AX1M0+TvwnSo38= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658150328; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=B/IWVfdc6Cy6EhB3qBRmrTgHIdWD5sWG1QZIefAdDNg=; b=hUUqCVBuY3trLtY0RhYe8oThH2x/a3BEjoShTjaRohm2Y8J4aD6FVUEIUuAI5V+Hm0nXCycexif2EVf3sNnDvmJMp/wx1mozZYzO3GWNc397KwSYOUjx90vk/bfnnoRCKqN+yRWYeKcRPEIZhO+PL03Ia6nOZkTx4Jb7rUSwtBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+91452+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1658150328151528.323012877917; Mon, 18 Jul 2022 06:18:48 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NmCrYY1788612xnUPcZvpy28; Mon, 18 Jul 2022 06:18:47 -0700 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web12.27079.1658150325580236005 for ; Mon, 18 Jul 2022 06:18:46 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10411"; a="287363898" X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="287363898" X-Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2022 06:18:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,281,1650956400"; d="scan'208";a="624724973" X-Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.183.102]) by orsmga008.jf.intel.com with ESMTP; 18 Jul 2022 06:18:43 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Zhiguang Liu , Eric Dong Subject: [edk2-devel] [PATCH 04/10] CpuPageTableLib: Refactor the logic Date: Mon, 18 Jul 2022 21:18:25 +0800 Message-Id: <20220718131831.660-5-ray.ni@intel.com> In-Reply-To: <20220718131831.660-1-ray.ni@intel.com> References: <20220718131831.660-1-ray.ni@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,ray.ni@intel.com X-Gm-Message-State: n2exPOw3cW7Tv2yBfdGu3S3Xx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1658150327; bh=rax9bZt/LdLNN5ia7FiSHMJJ3fkwZ/1YVyhHN1e5iVQ=; h=Cc:Date:From:Reply-To:Subject:To; b=F3qSGMS4oOLz+feLiHK4xcxPa+H4vJW9j9bMo4aniX0s0CMK2V7OS9UbZzy/3J7zio0 nUGSJJ2NPCQZ4AUAG/f9MEIBqP8OPE0ME8zWS7Nw2OaiRIftVBhgdAfWROChzPr4OVVCR L/dktbrDpOG+cilCmFF6h+H+raxxtcwByDI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1658150329533100009 Content-Type: text/plain; charset="utf-8" The patch replaces LinearAddress + Offset =3D=3D RegionStart with ((LinearAddress + Offset) & RegionMask) =3D=3D 0 The replace should not cause any behavior change. Because: 1. In first loop of while when LinearAddress + Offset =3D=3D RegionStart, because the lower "BitStart" bits of RegionStart are all-zero, all lower "BitStart" bits of (LinearAddress + Offset) are all-zero. Because all lower "BitStart" bits of RegionMask is all-one and bits are all-zero, ((LinearAddress + Offset) & RegionMask) =3D=3D 0. 2. In following loops of the while, even RegionStart is increased by RegionLength, the lower "BitStart" bits are still all-zero. So the two expressions still semantically equal to each other. Signed-off-by: Ray Ni Cc: Zhiguang Liu Cc: Eric Dong --- UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c b/UefiCpu= Pkg/Library/CpuPageTableLib/CpuPageTableMap.c index 429b014b7b..509fa5f7bd 100644 --- a/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c +++ b/UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c @@ -360,7 +360,7 @@ PageTableLibMapInLevel ( PagingEntry =3D (IA32_PAGING_ENTRY *)(UINTN)IA32_PNLE_PAGE_TABLE_BASE_AD= DRESS (&ParentPagingEntry->Pnle); while (Offset < Length && Index < 512) { SubLength =3D MIN (Length - Offset, RegionStart + RegionLength - (Line= arAddress + Offset)); - if ((Level <=3D MaxLeafLevel) && (LinearAddress + Offset =3D=3D Region= Start) && (SubLength =3D=3D RegionLength)) { + if ((Level <=3D MaxLeafLevel) && (((LinearAddress + Offset) & RegionMa= sk) =3D=3D 0) && (SubLength =3D=3D RegionLength)) { // // Create one entry mapping the entire region (1G, 2M or 4K). // --=20 2.35.1.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#91452): https://edk2.groups.io/g/devel/message/91452 Mute This Topic: https://groups.io/mt/92458157/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-