From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.30789.1679443023007772831 for ; Tue, 21 Mar 2023 16:57:03 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Dsni6nM+; spf=pass (domain: intel.com, ip: 134.134.136.65, 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=1679443023; x=1710979023; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8dNdUYnY2r/nHURZmumjC9avyapqitqzgCx2GX475js=; b=Dsni6nM+fgRYbtnhdEfNnaZPuenXvmz5ZTKKTEaFBwoLntPqYu8vkaWZ 9VKkavnXPkGnPpo+6JSQEXJEZmI6jUm+zAMghQby+2q7uDeTEjZ2sETra o3vY4YDt36GngQnyHnf9/RCZHDREpPdDhLbAsSy+lgfzIn1sj2Qua41p9 FB6GksIXA0HepfAs8RQdh7xGyF0e8P77xSltSgO7rfTXEidWLSkmL2jG6 1oKrvpCOdLQOBoP8ykf6LSghfjoH95NrWW85/feyORayBvwVod5KWp+QR qZ63ifJk02MITc6pjm3LYqnqjr6RtBLObCL56E5aUey8gBrOxEGZO6lfV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="341441518" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="341441518" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Mar 2023 16:57:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10656"; a="805627764" X-IronPort-AV: E=Sophos;i="5.98,280,1673942400"; d="scan'208";a="805627764" Received: from shwdeopenlab706.ccr.corp.intel.com ([10.239.55.95]) by orsmga004.jf.intel.com with ESMTP; 21 Mar 2023 16:57:00 -0700 From: "Ni, Ray" To: devel@edk2.groups.io Cc: Eric Dong , Rahul Kumar , Gerd Hoffmann , Michael D Kinney , Ahmad Anadani Subject: [PATCH 4/6] UefiCpuPkg/CpuDxe: Refactor to use CPUID definitions Date: Wed, 22 Mar 2023 07:56:48 +0800 Message-Id: <20230321235650.675-5-ray.ni@intel.com> X-Mailer: git-send-email 2.39.1.windows.1 In-Reply-To: <20230321235650.675-1-ray.ni@intel.com> References: <20230321235650.675-1-ray.ni@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable The patch does not change any code behavior but only refactors by: * replaces the hardcode 0x80000000 with CPUID_EXTENDED_FUNCTION * replaces the hardcode 0x80000008 with CPUID_VIR_PHY_ADDRESS_SIZE * replace "UINT32 Eax" with "CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize" Signed-off-by: Ray Ni Cc: Eric Dong Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Michael D Kinney Cc: Ahmad Anadani --- UefiCpuPkg/CpuDxe/CpuDxe.c | 18 ++++++++---------- UefiCpuPkg/CpuDxe/CpuDxe.h | 3 ++- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index a6a91507f6..920976c576 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -1,7 +1,7 @@ /** @file=0D CPU DXE Module to produce CPU ARCH Protocol.=0D =0D - Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -505,20 +505,18 @@ InitializeMtrrMask ( VOID=0D )=0D {=0D - UINT32 RegEax;=0D - UINT8 PhysicalAddressBits;=0D + UINT32 MaxExtendedFunction;=0D + CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize;=0D =0D - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL);=0D + AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NUL= L);=0D =0D - if (RegEax >=3D 0x80000008) {=0D - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL);=0D -=0D - PhysicalAddressBits =3D (UINT8)RegEax;=0D + if (MaxExtendedFunction >=3D CPUID_VIR_PHY_ADDRESS_SIZE) {=0D + AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &VirPhyAddressSize.Uint32, NULL,= NULL, NULL);=0D } else {=0D - PhysicalAddressBits =3D 36;=0D + VirPhyAddressSize.Bits.PhysicalAddressBits =3D 36;=0D }=0D =0D - mValidMtrrBitsMask =3D LShiftU64 (1, PhysicalAddressBits) - 1;=0D + mValidMtrrBitsMask =3D LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalA= ddressBits) - 1;=0D mValidMtrrAddressMask =3D mValidMtrrBitsMask & 0xfffffffffffff000ULL;=0D }=0D =0D diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h index 49a390b4c4..0e7d88dd35 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.h +++ b/UefiCpuPkg/CpuDxe/CpuDxe.h @@ -1,7 +1,7 @@ /** @file=0D CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol.=0D =0D - Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.
=0D + Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -13,6 +13,7 @@ =0D #include =0D #include =0D +#include =0D #include =0D =0D #include =0D --=20 2.39.1.windows.1