From nobody Sat May 18 23:44:30 2024 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+87234+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+87234+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234598; cv=none; d=zohomail.com; s=zohoarc; b=lBGVS/XlUalHzyyZmMfGjPGOmrTFqjKdS9ZHdUh7vnGn8tBO0Bbxm7UoqptDYA6l1BY84KtUd+bpx1TP3qMfOS9apnJjfXCbj+HQVeIwMTc9cIbP5KJpymyLUsY5JksU9bpoQdD35xniuYMmVoMNxfkVI/MH6CMUOA7mS2CYM4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234598; 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=f3U2geBz26z1Ajx7PPlRVzQIEYv/8Cd1TRg+heq0CxI=; b=JFaWPG5avh508SvL3PS4K2T+tBkLg0uW3EG2COf88jo1QnOkbSdbna8MIgbkkWblwEzNZpJfxt3yMoEUkC1GFExnZsL8TdmgjUCzKJ4jwX09RrWOS7yrOxavy2zQjNbNnqVnEKLfArdAI0EY+hEk2I46YLfs23QMSI2ebiieilQ= 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+87234+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 1646234598900252.29803655944568; Wed, 2 Mar 2022 07:23:18 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id SPFcYY1788612xOW6hAUNiif; Wed, 02 Mar 2022 07:23:18 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:19:56 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324159" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324159" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:19:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630294" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:19:53 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Eric Dong , Ray Ni Subject: [edk2-devel] [PATCH v1 1/7] UefiCpuPackage: Add APIs for CPU physical address mask calculation Date: Wed, 2 Mar 2022 17:18:53 +0800 Message-Id: <20220302091859.2783-2-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: dOQRWAo2ZDDPUYgSpsUFDEo8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234598; bh=9O5zNI0vUyvhSWG33ZyVXzDKwqcEdGYWHjYBZJp8ESg=; h=Cc:Date:From:Reply-To:Subject:To; b=Wuy9OBOXvu5OV6ZTTO6UWKiNsRjJL+iSCsOAvjjvclrZco0Ngur5JDLdR4cQ2turY5b Q3FmesNnxctLRur5qdSym8pf9cqImpKbbVM0SdMEdqwj/xLLt5UbUORgM9y9Uyg0i8DKS 8445DwkgMN/pjip6plEtAWnPqKnJYIXjytc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646235502720100005 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Add API named GetPhysicalAddressBits() for CPU physical address mask calculation, and remove the duplicated code in UefiCpuPackage. Cc: Eric Dong Cc: Ray Ni Signed-off-by: Yu Pu --- UefiCpuPkg/CpuDxe/CpuDxe.c | 16 +------ UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c | 47 ++++++++++++++++++= ++ UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c | 9 +--- UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 9 +--- UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c | 9 +--- UefiCpuPkg/Include/Library/UefiCpuLib.h | 17 +++++++ 6 files changed, 70 insertions(+), 37 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index 00f3cb09572c..8aca1bf72b4c 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -503,21 +503,7 @@ InitializeMtrrMask ( VOID ) { - UINT32 RegEax; - UINT8 PhysicalAddressBits; - - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } - - mValidMtrrBitsMask =3D LShiftU64 (1, PhysicalAddressBits) - 1; - mValidMtrrAddressMask =3D mValidMtrrBitsMask & 0xfffffffffffff000ULL; + GetPhysicalAddressBits(&mValidMtrrBitsMask, &mValidMtrrAddressMask); } =20 /** diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c b/UefiCpuPk= g/Library/BaseUefiCpuLib/BaseUefiCpuLib.c index 5d925bc273f8..bb1343f3cd21 100644 --- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c +++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c @@ -79,3 +79,50 @@ GetCpuSteppingId ( =20 return (UINT8)Eax.Bits.SteppingId; } + +/** + Get the physical address width supported by the processor. + @param[out] ValidAddressMask Bitmask with valid address bits se= t to + one; other bits are clear. Optional + parameter. + @param[out] ValidPageBaseAddressMask Bitmask with valid page base addre= ss + bits set to one; other bits are cl= ear. + Optional parameter. + @return The physical address width supported by the processor. +**/ +UINT8 +EFIAPI +GetPhysicalAddressBits ( + OUT UINT64 *ValidAddressMask OPTIONAL, + OUT UINT64 *ValidPageBaseAddressMask OPTIONAL + ) +{ + UINT32 MaxExtendedFunction; + CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize; + UINT64 AddressMask; + UINT64 PageBaseAddressMask; + + AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NUL= L); + if (MaxExtendedFunction >=3D CPUID_VIR_PHY_ADDRESS_SIZE) { + AsmCpuid ( + CPUID_VIR_PHY_ADDRESS_SIZE, + &VirPhyAddressSize.Uint32, + NULL, + NULL, + NULL + ); + } else { + VirPhyAddressSize.Bits.PhysicalAddressBits =3D 36; + } + + AddressMask =3D LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalAddressBits= ) - 1; + PageBaseAddressMask =3D AddressMask & ~(UINT64)0xFFF; + + if (ValidAddressMask !=3D NULL) { + *ValidAddressMask =3D AddressMask; + } + if (ValidPageBaseAddressMask !=3D NULL) { + *ValidPageBaseAddressMask =3D PageBaseAddressMask; + } + return (UINT8)VirPhyAddressSize.Bits.PhysicalAddressBits; +} diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c b/UefiCpuPkg/Lib= rary/SmmCpuFeaturesLib/SmmStm.c index 4e8f897f5e9c..ec7cd4013132 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -330,13 +331,7 @@ SmmCpuFeaturesInstallSmiHandler ( if (Hob !=3D NULL) { Psd->PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - Psd->PhysicalAddressBits =3D (UINT8)RegEax; - } else { - Psd->PhysicalAddressBits =3D 36; - } + Psd->PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL); } =20 if (!mStmConfigurationTableInitialized) { diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuD= xeSmm/X64/PageTbl.c index 538394f23910..de1385a86948 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c @@ -194,7 +194,6 @@ CalculateMaximumSupportAddress ( VOID ) { - UINT32 RegEax; UINT8 PhysicalAddressBits; VOID *Hob; =20 @@ -205,13 +204,7 @@ CalculateMaximumSupportAddress ( if (Hob !=3D NULL) { PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL); } =20 return PhysicalAddressBits; diff --git a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c b/UefiCpuPkg= /Universal/Acpi/S3Resume2Pei/S3Resume.c index 8419a4e32acb..1017f0316093 100644 --- a/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c +++ b/UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume.c @@ -42,6 +42,7 @@ #include #include #include +#include =20 /** This macro aligns the address of a variable with auto storage @@ -646,13 +647,7 @@ RestoreS3PageTables ( if (Hob !=3D NULL) { PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL); } =20 // diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h b/UefiCpuPkg/Include/L= ibrary/UefiCpuLib.h index 0ff4a35774c1..dabed95ab38a 100644 --- a/UefiCpuPkg/Include/Library/UefiCpuLib.h +++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h @@ -62,4 +62,21 @@ GetCpuSteppingId ( VOID ); =20 +/** + Get the physical address width supported by the processor. + @param[out] ValidAddressMask Bitmask with valid address bits se= t to + one; other bits are clear. Optional + parameter. + @param[out] ValidPageBaseAddressMask Bitmask with valid page base addre= ss + bits set to one; other bits are cl= ear. + Optional parameter. + @return The physical address width supported by the processor. +**/ +UINT8 +EFIAPI +GetPhysicalAddressBits ( + OUT UINT64 *ValidAddressMask OPTIONAL, + OUT UINT64 *ValidPageBaseAddressMask OPTIONAL + ); + #endif --=20 2.30.0.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 (#87234): https://edk2.groups.io/g/devel/message/87234 Mute This Topic: https://groups.io/mt/89503324/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- From nobody Sat May 18 23:44:30 2024 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+87235+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+87235+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234599; cv=none; d=zohomail.com; s=zohoarc; b=HslH6QeuQgyYlwsgjWmsDdYQbIr5YYe8VTB+JnTod8xByuXviE7NmkB/snJ1iZ/pnPFSSCtTbXCUP0PbJwtalKcYDkFijD5N2kRwjm5tIQ0HpSORAuWq8+WhYrduG7U/hDBg23RgrbL7Mh8U3gJ2pQCVgpByAi/aF3GmY/36zn0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234599; 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=4bZXRRwiLoS8jRfjkpLNSC1VC2nqyyJ45LEMAWTqZOs=; b=I6fLSgJYRW9kAVIO2yTs7m+/xhbLd51uE9+1F13LF3kpOgrAqp3fp4dP8X0lKl62ZmlxWy4SkTkPxfnA9nLNgz3HO9gcS6XG8S4zaQL9IU2q0U7/51rdDIqYwz3LxP5wGeWsu0orzXk9p5wGHe6QXtp9mXREMmSgiHm7HfgAN+A= 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+87235+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 1646234599283962.8223308737003; Wed, 2 Mar 2022 07:23:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id e7jUYY1788612xFupf1XDJLJ; Wed, 02 Mar 2022 07:23:19 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:19:59 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324188" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324188" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:19:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630321" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:19:57 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Jian J Wang , Liming Gao Subject: [edk2-devel] [PATCH v1 2/7] MdeModulePkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:54 +0800 Message-Id: <20220302091859.2783-3-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: H1OWvxd3fXdOYAofNqCVA4Svx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234599; bh=sR7PIUGKN3EKfKXVUvL4t7/O4XrJ5WeNd1ar5Bm4MBk=; h=Cc:Date:From:Reply-To:Subject:To; b=ncRpgiqyUqg/sJmQGp/ZDriInSfo4EoCQMynQBq9/auk77lCeH4FfG20MR40z/N5xdh LGW/Jx2Qq0S/76wCdJLUDb8+L7EtShfa9Y5Lr1lvzI8wXU18SPV5+h83PRINWsZwxEpJR P6RutosgaWK4NkNtndtsxtgEdOaXJAp/X60= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646234601205100007 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical addr= ess mask calculation and remove the duplicated code in MdeModulePkg. Cc: Jian J Wang Cc: Liming Gao Signed-off-by: Yu Pu --- MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c = | 9 ++------- MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c = | 14 ++------------ MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c = | 14 ++------------ MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf = | 2 ++ MdeModulePkg/MdeModulePkg.dsc = | 1 + MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.in= f | 2 ++ MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf = | 2 ++ 7 files changed, 13 insertions(+), 31 deletions(-) diff --git a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c b/MdeModulePk= g/Core/DxeIplPeim/X64/VirtualMemory.c index 0700f310b203..78e91e6e9024 100644 --- a/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c +++ b/MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c @@ -22,6 +22,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 +#include #include #include "DxeIpl.h" #include "VirtualMemory.h" @@ -733,13 +734,7 @@ CreateIdentityMappingPageTables ( if (Hob !=3D NULL) { PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits(NULL, NULL); } =20 Page5LevelSupport =3D FALSE; diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEn= try.c b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c index 6b44f50bac70..367bf8cdd1e6 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/X64/SetIdtEntry.c @@ -10,6 +10,7 @@ Copyright (c) 2017, AMD Incorporated. All rights reserved= .
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ +#include #include "ScriptExecute.h" =20 // @@ -51,20 +52,9 @@ HookPageFaultHandler ( IN IA32_IDT_GATE_DESCRIPTOR *IdtEntry ) { - UINT32 RegEax; - UINT8 PhysicalAddressBits; UINTN PageFaultHandlerHookAddress; =20 - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } - - mPhyMask =3D LShiftU64 (1, PhysicalAddressBits) - 1; - mPhyMask &=3D (1ull << 48) - SIZE_4KB; + GetPhysicalAddressBits(NULL, &mPhyMask); =20 // // Set Page Fault entry to catch >4G access diff --git a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c b/MdeModulePk= g/Universal/CapsulePei/X64/X64Entry.c index 05941f9f8d56..06d6129c5e6d 100644 --- a/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c +++ b/MdeModulePkg/Universal/CapsulePei/X64/X64Entry.c @@ -12,6 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include "CommonHeader.h" =20 #define EXCEPTION_VECTOR_NUMBER 0x22 @@ -61,20 +62,9 @@ HookPageFaultHandler ( IN OUT PAGE_FAULT_CONTEXT *PageFaultContext ) { - UINT32 RegEax; - UINT8 PhysicalAddressBits; UINTN PageFaultHandlerHookAddress; =20 - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } - - PageFaultContext->PhyMask =3D LShiftU64 (1, PhysicalAddressBits) - 1; - PageFaultContext->PhyMask &=3D (1ull << 48) - SIZE_4KB; + GetPhysicalAddressBits(NULL, &(PageFaultContext->PhyMask)); =20 // // Set Page Fault entry to catch >4G access diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf b/MdeModulePkg/Core/Dx= eIplPeim/DxeIpl.inf index 19b8a4c8aefa..45808bcdcd6c 100644 --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf @@ -55,6 +55,7 @@ =20 [Packages] MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec MdeModulePkg/MdeModulePkg.dec =20 [Packages.ARM, Packages.AARCH64] @@ -75,6 +76,7 @@ DebugAgentLib PeiServicesTablePointerLib PerformanceLib + UefiCpuLib =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] ArmMmuLib diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b1d83461865e..da6213c02da0 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -62,6 +62,7 @@ DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableL= ib.inf UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManag= erLib.inf VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ib.inf + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf # # Generic Modules # diff --git a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptEx= ecutorDxe.inf b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScrip= tExecutorDxe.inf index fb149c2f0271..dd3dd2fc8c10 100644 --- a/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorD= xe.inf +++ b/MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorD= xe.inf @@ -41,6 +41,7 @@ =20 [Packages] MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] @@ -54,6 +55,7 @@ UefiBootServicesTableLib CacheMaintenanceLib UefiLib + UefiCpuLib DebugAgentLib LockBoxLib CpuExceptionHandlerLib diff --git a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf b/MdeModulePk= g/Universal/CapsulePei/CapsuleX64.inf index 35d2535a5b48..75813b1e5481 100644 --- a/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf +++ b/MdeModulePkg/Universal/CapsulePei/CapsuleX64.inf @@ -38,12 +38,14 @@ [Packages] MdePkg/MdePkg.dec MdeModulePkg/MdeModulePkg.dec + UefiCpuPkg/UefiCpuPkg.dec =20 [LibraryClasses] BaseLib DebugLib CpuExceptionHandlerLib DebugAgentLib + UefiCpuLib =20 [Depex] FALSE --=20 2.30.0.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 (#87235): https://edk2.groups.io/g/devel/message/87235 Mute This Topic: https://groups.io/mt/89503325/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- From nobody Sat May 18 23:44:30 2024 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+87236+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+87236+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234599; cv=none; d=zohomail.com; s=zohoarc; b=aPzbjBaMYHLobmwfI0jJ7JSCYmu1hJDtDEKiW9Rx2yBf3Q+4AbIBeM3BYk3EwGEISho0u+6lsJ1NtAaV6aSnXeyWEqsFbfIeoJ7cylbTS3lWFv7vAOm1EJdfszMMdyhe0+jj4oUq/4Qnz+zK7TV+rORh0mSgO5/UpgV39w2OtXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234599; 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=yJvK9TaZePd/5dtYgtu2XMP8Edy5nsDUqiPfrv5s4oo=; b=XQtn3POL0gbzDJ1N9nGCOsteK/bIH6PxbpvosK4vPROQqxfaboe42AFI4ywPiGVStUcIfGB7PG7nLDOoyP9GzQXxpeY7mvPrQmliLg9ljBa+6P2QA+rTfL21EJ9H/obmWpxuPCY5ZUqG0AAu45cFsjkajwqE6qzwEl7XhgUlQns= 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+87236+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 1646234599568741.6300190659588; Wed, 2 Mar 2022 07:23:19 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id V3xzYY1788612xRGpePMWOWF; Wed, 02 Mar 2022 07:23:19 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:01 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324199" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324199" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630343" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:00 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Chasel Chiu Subject: [edk2-devel] [PATCH v1 3/7] IntelFsp2Pkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:55 +0800 Message-Id: <20220302091859.2783-4-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: ANfzrpT72weore1kAE1Nze6Hx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234599; bh=yvR/5YCxadl1feZJxt5WI9H2el7vo2EbDLRTe2aVJL4=; h=Cc:Date:From:Reply-To:Subject:To; b=DGr8pehO/T/NZv6AKniGGSKIErvoA23Ug7aXVewjqfmyt0b/rTkjJNKot+/HMRuK9LE r8oE81eOrp4oYbtfBaUF1ouviVCBXeJnz1LyUG8c4tfXpayRsJ48X1vbq31LDXPOJpnzT g+00cS8Pcehg/Syhcfi7/gRgRGdq0MWWRTs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646235502689100003 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical address mask calculation and remove the duplicated code in edk2\IntelFsp2Pkg\Library\BaseCacheLib\CacheLib.c. Cc: Chasel Chiu Signed-off-by: Yu Pu Reviewed-by: Chasel Chiu --- IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c | 10 ++-------- IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c b/IntelFsp2Pkg/Li= brary/BaseCacheLib/CacheLib.c index f879c268e7ec..3f8ed122b2be 100644 --- a/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c +++ b/IntelFsp2Pkg/Library/BaseCacheLib/CacheLib.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "CacheLibInternal.h" =20 /** @@ -388,15 +389,8 @@ SetCacheAttributes ( UINT32 UsedMsrNum; EFI_MEMORY_CACHE_TYPE UsedMemoryCacheType; UINT64 ValidMtrrAddressMask; - UINT32 Cpuid_RegEax; =20 - AsmCpuid (CPUID_EXTENDED_FUNCTION, &Cpuid_RegEax, NULL, NULL, NULL); - if (Cpuid_RegEax >=3D CPUID_VIR_PHY_ADDRESS_SIZE) { - AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &Cpuid_RegEax, NULL, NULL, NULL); - ValidMtrrAddressMask =3D (LShiftU64 ((UINT64)1, (Cpuid_RegEax & 0xFF))= - 1) & (~(UINT64)0x0FFF); - } else { - ValidMtrrAddressMask =3D (LShiftU64 ((UINT64)1, 36) - 1) & (~(UINT64)0= x0FFF); - } + GetPhysicalAddressBits(NULL, &ValidMtrrAddressMask); =20 // // Check for invalid parameter diff --git a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf b/IntelFsp2= Pkg/Library/BaseCacheLib/BaseCacheLib.inf index 9a513fb6df77..e6b14ae4a802 100644 --- a/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf +++ b/IntelFsp2Pkg/Library/BaseCacheLib/BaseCacheLib.inf @@ -21,9 +21,11 @@ =20 [Packages] MdePkg/MdePkg.dec + UefiCpuPkg/UefiCpuPkg.dec IntelFsp2Pkg/IntelFsp2Pkg.dec =20 [LibraryClasses] BaseMemoryLib CacheAsRamLib + UefiCpuLib =20 --=20 2.30.0.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 (#87236): https://edk2.groups.io/g/devel/message/87236 Mute This Topic: https://groups.io/mt/89503326/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- From nobody Sat May 18 23:44:30 2024 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+87237+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+87237+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234600; cv=none; d=zohomail.com; s=zohoarc; b=YCfIiwsPhQnr+lcSkW/mrfBuES5/zRUpzdEs0K0YuIRHOp+CKryTP2aZCYbCZo26rvk/EExaBMxx1ItD8XNjYZhJCJGCTbCY0Qp81JC30bDeG5f//j3zkaJ5gQduvyvZFvBpwobO3MtiRjDMBkGazIlYATUAfWnt2puRbqi442Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234600; 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=NJkpvFy5N174tBaHEJEfI3WHlzEfCsfIOHxH91ZVQe8=; b=EC6EmW2Cl2I+GRtIR1MjC6bbo6YGrZp/tRSB5DbKdZMNkUI/2F0jBItWHhuqKPU2jd7eaqdFo0lSttaX/lOoOGkQBhUqoaeEeM8ZSj5z/W16xLxxGUFNrJVFTFjOXdg6qVgUUjhSUSMxNXaNPH9mG6JZq2a4dQalZXQGF7GeIKg= 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+87237+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 1646234600278934.2837383718924; Wed, 2 Mar 2022 07:23:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id oqTWYY1788612xRfkCDNWZ2G; Wed, 02 Mar 2022 07:23:19 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:04 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324211" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324211" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630364" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:02 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Ard Biesheuvel , Sami Mujawar , Jiewen Yao Subject: [edk2-devel] [PATCH v1 4/7] StandaloneMmPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:56 +0800 Message-Id: <20220302091859.2783-5-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: 3hkUKnYkvKU0IjlwlK7IMPnwx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234599; bh=RgFPrSP5zsDqxIJuzl9zawg+q1dIbEDL9Yw6Aj7xz1w=; h=Cc:Date:From:Reply-To:Subject:To; b=Bru5gi8KGrnecmeKcrIvBmSwBVDcn+pmIr6/Mt3WUStCl9rjvd4SXzEAo4RuSiXd4jO 8fQsv3UZhzOhoJqlykGRdJzv0RVsvaGYCs0w84Lt7OzjRbvqS5qPXvyRTEWeL6MKbpXUe cRHAwxTxr7HsMHONuQ8ShTFpQoaWf3sKeiQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646235502687100002 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical addr= ess mask calculation and remove the duplicated code in StandaloneMmPkg\Library\StandaloneMmMemLib\X86StandaloneMmMemLibInternal.c Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Jiewen Yao Signed-off-by: Yu Pu --- StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c= | 10 ++-------- StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf = | 2 ++ StandaloneMmPkg/StandaloneMmPkg.dsc = | 1 + 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemL= ibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMe= mLibInternal.c index c309d1bc6a56..4afd9b938934 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInter= nal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInter= nal.c @@ -19,6 +19,7 @@ #include #include #include +#include =20 #include #include @@ -40,7 +41,6 @@ MmMemLibInternalCalculateMaximumSupportAddress ( ) { VOID *Hob; - UINT32 RegEax; UINT8 PhysicalAddressBits; =20 // @@ -50,13 +50,7 @@ MmMemLibInternalCalculateMaximumSupportAddress ( if (Hob !=3D NULL) { PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL); } =20 // diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.= inf b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf index b29d97a74607..94f7fbb1c4f7 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf @@ -43,12 +43,14 @@ [Packages] MdePkg/MdePkg.dec StandaloneMmPkg/StandaloneMmPkg.dec + UefiCpuPkg/UefiCpuPkg.dec =20 [LibraryClasses] BaseMemoryLib DebugLib HobLib MemoryAllocationLib + UefiCpuLib =20 [Guids] gMmCoreDataHobGuid ## SOMETIMES_CONSUMES ## HOB diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/Standalo= neMmPkg.dsc index 8012f93b7dcc..41449046799f 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -59,6 +59,7 @@ StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntry= Point/StandaloneMmCoreEntryPoint.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/Variab= leMmDependency.inf + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf =20 [LibraryClasses.AARCH64, LibraryClasses.ARM] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf --=20 2.30.0.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 (#87237): https://edk2.groups.io/g/devel/message/87237 Mute This Topic: https://groups.io/mt/89503327/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- From nobody Sat May 18 23:44:30 2024 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+87238+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+87238+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234600; cv=none; d=zohomail.com; s=zohoarc; b=GdGaltPj9Jsw9TpnVXQDWM1UdnPKeEmHWnR13LjBwBITrTH+awxejRM3lhpN+YmB0bOU4iwsoGb0qJxkHMtFai7UmIiCMxJN/azOZ4nhuj0pOm/o7sotzkiC7UaXkK2qQdvelwUom0CkELWhKLBSptvonnzx82XMyp3X+0y9zVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234600; 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=sXOESfkUPPLEGkHPTvEtObjw3fEyhchviOvSZr7dv7M=; b=HTU2iuQ7oULOYyHgWlW9+vtA/oR8YuLMqp1uDssCOvlRWLAvWY0+C/Xed21mOddxLDtt3PilnJygRVjCI0rVMvwszqM5rtupyxnfUG3dirx/qLgEReW+/LxpBvJmgsuOSEw2khW2mUlz6cWwAF6JKsd0NPFYp3QR3H+qRfKKKwQ= 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+87238+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 1646234600741247.86090505357788; Wed, 2 Mar 2022 07:23:20 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0be9YY1788612x5sEHj5VF0W; Wed, 02 Mar 2022 07:23:20 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:07 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324224" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324224" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630383" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:05 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu Subject: [edk2-devel] [PATCH v1 5/7] OvmfPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:57 +0800 Message-Id: <20220302091859.2783-6-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: JoS1M1m4wEmsuSLF2KhEh9Q8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234600; bh=u+rL3lkd7T2jup4mQa2La1qJz2orIycpu8Y3HYY3OFw=; h=Cc:Date:From:Reply-To:Subject:To; b=nVozVLWEp7OMjZNtWM6NsvSx/my4DQbouJ8GDqtDkRuYGekrNDxcp+wH9bRkWhcKFMB FOaZ1Wn4HpOQRFjL0BaTrJM/sGDczIQT1yPP4mPPfmH4/j95wbvn46xyE0GHkU1qoCF4c R9v40Qh9sy6JVTArXV74jKZj6U++VFdy1rU= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646235502684100001 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical addr= ess mask calculation and remove the duplicated code in OvmfPkg\XenPlatformPei\MemDetect.c. Cc: Ard Biesheuvel Cc: Jiewen Yao Signed-off-by: Yu Pu --- OvmfPkg/XenPlatformPei/MemDetect.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/OvmfPkg/XenPlatformPei/MemDetect.c b/OvmfPkg/XenPlatformPei/Me= mDetect.c index d412d1f4db6f..bd24612c21ef 100644 --- a/OvmfPkg/XenPlatformPei/MemDetect.c +++ b/OvmfPkg/XenPlatformPei/MemDetect.c @@ -30,6 +30,7 @@ Module Name: #include #include #include +#include =20 #include "Platform.h" #include "Cmos.h" @@ -180,15 +181,7 @@ AddressWidthInitialization ( VOID ) { - UINT32 RegEax; - - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - mPhysMemAddressWidth =3D (UINT8)RegEax; - } else { - mPhysMemAddressWidth =3D 36; - } + mPhysMemAddressWidth =3D GetPhysicalAddressBits(NULL, NULL); =20 // // IA-32e paging translates 48-bit linear addresses to 52-bit physical a= ddresses. --=20 2.30.0.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 (#87238): https://edk2.groups.io/g/devel/message/87238 Mute This Topic: https://groups.io/mt/89503328/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- From nobody Sat May 18 23:44:30 2024 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+87239+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+87239+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1646234601; cv=none; d=zohomail.com; s=zohoarc; b=WEnyTfxe0aSfhQDoBe47cFMioeW7Qfz7IJMmCChKoaPHf4s1wepOQcNHPg7+uDHohP7WYnovppLZtQ6mMFogLGebQG0OnK9Kp0/3BZilA5EwYRWA7meNBB4kYetXqICYMe7ml6tFQlfWVt64TWqPkLoz6BkBthoM3x4xxuY4BMU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646234601; 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=+vlg9UslzTxI637piL7vh+f4UbEpoltyfM0pnQVaxfM=; b=FDRz8WGhEd4BMvoBDuLywpO1QSyUBjfpdTR8UjJesZwfmN3Jmk4DuMnrv6nZYJk3VuS98th5LSuQf4gmJ7mboJs1uLR0Mh1IwOrQMXbntFTfCDHU/awM0w9e7luINzbAhBSejFDPci7YV75L8CJyFSsc9F4R77oVGQ+8sHjQRR0= 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+87239+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 1646234601909749.4344702498056; Wed, 2 Mar 2022 07:23:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id lynzYY1788612x9nxlECJPTG; Wed, 02 Mar 2022 07:23:21 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:10 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324258" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324258" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630412" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:08 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Andrew Fish , Ray Ni Subject: [edk2-devel] [PATCH v1 6/7] EmulatorPkg: fixed a bug caused by Invoking GetPhysicalAddressBits() Date: Wed, 2 Mar 2022 17:18:58 +0800 Message-Id: <20220302091859.2783-7-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: aqJowSLRlnw54lzhbyVGuZLLx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234601; bh=0/zgjw2RzRM+TgMH0C68AEnERJleaY62wD0IeDEWYhs=; h=Cc:Date:From:Reply-To:Subject:To; b=hX62uXriiwo8Ql9GngLYg4Mbo4zPtA4d2FEHb4P+3T2YSXMprCGhAURNhOV+BqzWFQL xAmgKwMWhHH1uxOsiLlDneAmVirRVzU7zgcbPGYdhS3jLKAdGwBbsbgimNyQ0gKXYicay Am5+DAljtMN4T6ZEZ5Yz7pNCZCDte0+cJls= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1646234603226100023 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 add the defination of UefiCpuLib in EmulatorPkg\EmulatorPkg.dsc Cc: Andrew Fish Cc: Ray Ni Signed-off-by: Yu Pu --- EmulatorPkg/EmulatorPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc index 554c13ddb500..e33b98a4b682 100644 --- a/EmulatorPkg/EmulatorPkg.dsc +++ b/EmulatorPkg/EmulatorPkg.dsc @@ -78,6 +78,7 @@ HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompres= sLib.inf + UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf =20 PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf --=20 2.30.0.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 (#87239): https://edk2.groups.io/g/devel/message/87239 Mute This Topic: https://groups.io/mt/89503329/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- From nobody Sat May 18 23:44:30 2024 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+87240+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87240+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 164623460198898.06861468330271; Wed, 2 Mar 2022 07:23:21 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id zjoQYY1788612xONDB5fvtrM; Wed, 02 Mar 2022 07:23:22 -0800 X-Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.5530.1646212796036188164 for ; Wed, 02 Mar 2022 01:20:14 -0800 X-IronPort-AV: E=McAfee;i="6200,9189,10273"; a="233324291" X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="233324291" X-Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Mar 2022 01:20:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,148,1643702400"; d="scan'208";a="641630450" X-Received: from shwdeopenlab704.ccr.corp.intel.com ([10.239.182.239]) by orsmga004.jf.intel.com with ESMTP; 02 Mar 2022 01:20:12 -0800 From: Yu Pu To: devel@edk2.groups.io Cc: Yu Pu , Guo Dong , Ray Ni Subject: [edk2-devel] [PATCH v1 7/7] UefiPayloadPkg: Invoke GetPhysicalAddressBits() and remove the duplicated code Date: Wed, 2 Mar 2022 17:18:59 +0800 Message-Id: <20220302091859.2783-8-yu.pu@intel.com> In-Reply-To: <20220302091859.2783-1-yu.pu@intel.com> References: <20220302091859.2783-1-yu.pu@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,yu.pu@intel.com X-Gm-Message-State: MmewdXwdxXKQymEvqwG9lRApx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1646234602; bh=szo/BICFmKHAw6AaBIKfb6uIgMxaMuY1w7UNtSCMwlw=; h=Cc:Date:From:Reply-To:Subject:To; b=f97OFPmKyT+sH+ugISfJAM7xysyC/UVSRXefsinw+Z01nrw7jG41X8nUHTW6QOucgK+ 9pju5nEz4pKlmU51yQuBcSNF0+VC6DD0VmvZ+TgU5tlbGfDkFLfqzZN67YaAChtOrJ335 jCQwkn5W4NWr8v81q01wXRN4gkE/jb+MZz0= X-ZohoMail-DKIM: fail (Signature date is -1 seconds in the future.) X-ZM-MESSAGEID: 1646234603284100026 Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3394 Invoke GetPhysicalAddressBits() defined in UefiCpuPkg for CPU physical addr= ess mask calculation and remove the duplicated code in UefiPayloadPkg\UefiPaylo= adEntry Cc: Guo Dong Cc: Ray Ni Signed-off-by: Yu Pu Reviewed-by: Guo Dong --- UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 10 ++-------- UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c | 9 ++------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPaylo= adPkg/UefiPayloadEntry/UefiPayloadEntry.c index 0fed1e36918a..4378aa4f1d97 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c @@ -4,6 +4,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ +#include =20 #include "UefiPayloadEntry.h" =20 @@ -341,7 +342,6 @@ BuildGenericHob ( VOID ) { - UINT32 RegEax; UINT8 PhysicalAddressBits; EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute; =20 @@ -351,13 +351,7 @@ BuildGenericHob ( // // Build CPU memory space and IO space hob // - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits(NULL, NULL); =20 BuildCpuHob (PhysicalAddressBits, 16); =20 diff --git a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c b/UefiPayl= oadPkg/UefiPayloadEntry/X64/VirtualMemory.c index ac0d58e685c8..c61aeeda7f2e 100644 --- a/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c +++ b/UefiPayloadPkg/UefiPayloadEntry/X64/VirtualMemory.c @@ -25,6 +25,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include +#include #include #include #include @@ -738,13 +739,7 @@ CreateIdentityMappingPageTables ( if (Hob !=3D NULL) { PhysicalAddressBits =3D ((EFI_HOB_CPU *)Hob)->SizeOfMemorySpace; } else { - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - PhysicalAddressBits =3D (UINT8)RegEax; - } else { - PhysicalAddressBits =3D 36; - } + PhysicalAddressBits =3D GetPhysicalAddressBits (NULL, NULL); } =20 // --=20 2.30.0.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 (#87240): https://edk2.groups.io/g/devel/message/87240 Mute This Topic: https://groups.io/mt/89503330/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-