From nobody Fri Oct 18 05:16:45 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+101522+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+101522+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1679443026; cv=none; d=zohomail.com; s=zohoarc; b=JqzutBLPRrIcPoKy4Q32dCtFYh9lvZXDl5sn/+xYW+d6jdrLsrMG38vcs5kv62TeX9wgS9+Y2pUUI1MpQdMykhDFCI7YoqJXT/Wk6rWfe9egIIU0x5sEklX+mEZXJDbF3yftyl68bQMrN24mc66LA6le/432KZa6d7QLZ82IK/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679443026; 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=ubDlzQXMiG/Utd6W+ANE0XGD9OFnnJHMlkpUW/HcDSk=; b=eM6Kiga2kEfx8WQhzsbWJ35GX9mQFkxIUgqkviUUF5YZ/ObgoWcbTqy6sNeE3oGjNLs5KCl3qb0YW7rZBdRrwTnd7aZVA/IF7Ol4POyUt9CiVO5jeQS2isOcrhLMdPOnZv0WGh9TWFFO+xvOYQq59aNMW9qSCqPmGMwtB+baRgU= 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+101522+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 1679443026193459.82514652401267; Tue, 21 Mar 2023 16:57:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rveNYY1788612x1MUgOr4rHj; Tue, 21 Mar 2023 16:57:05 -0700 X-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 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" X-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" X-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: [edk2-devel] [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> In-Reply-To: <20230321235650.675-1-ray.ni@intel.com> References: <20230321235650.675-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: 9dTF2nKHKRB5Sax8vD7KGorEx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679443025; bh=hYAl/J7JMW2EEiTQlYes3VjP2Pz4y5iHEVOso868Dts=; h=Cc:Date:From:Reply-To:Subject:To; b=e5zGaeBGWi8FBcwp2x5B31/bC+6hNm1a1La+mMJc4aRmGyxHYkgJOQ+RIq8gehZv8KG 4jpLwD9dpqmZjIfQu/Y08XM9DTHXb2KFKvkEIlVXy/RtxK2ConVxcvmoqt6IIyGoM2CyV I1iaLJS2cQ6DR7ZFsi658O7bS2Mz2ZyovSI= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679443026878100011 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Michael D Kinney --- 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 CPU DXE Module to produce CPU ARCH Protocol. =20 - Copyright (c) 2008 - 2022, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -505,20 +505,18 @@ InitializeMtrrMask ( VOID ) { - UINT32 RegEax; - UINT8 PhysicalAddressBits; + UINT32 MaxExtendedFunction; + CPUID_VIR_PHY_ADDRESS_SIZE_EAX VirPhyAddressSize; =20 - AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + AsmCpuid (CPUID_EXTENDED_FUNCTION, &MaxExtendedFunction, NULL, NULL, NUL= L); =20 - if (RegEax >=3D 0x80000008) { - AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); - - PhysicalAddressBits =3D (UINT8)RegEax; + if (MaxExtendedFunction >=3D CPUID_VIR_PHY_ADDRESS_SIZE) { + AsmCpuid (CPUID_VIR_PHY_ADDRESS_SIZE, &VirPhyAddressSize.Uint32, NULL,= NULL, NULL); } else { - PhysicalAddressBits =3D 36; + VirPhyAddressSize.Bits.PhysicalAddressBits =3D 36; } =20 - mValidMtrrBitsMask =3D LShiftU64 (1, PhysicalAddressBits) - 1; + mValidMtrrBitsMask =3D LShiftU64 (1, VirPhyAddressSize.Bits.PhysicalA= ddressBits) - 1; mValidMtrrAddressMask =3D mValidMtrrBitsMask & 0xfffffffffffff000ULL; } =20 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 CPU DXE Module to produce CPU ARCH Protocol and CPU MP Protocol. =20 - Copyright (c) 2008 - 2019, Intel Corporation. All rights reserved.
+ Copyright (c) 2008 - 2023, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -13,6 +13,7 @@ =20 #include #include +#include #include =20 #include --=20 2.39.1.windows.1 -=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 (#101522): https://edk2.groups.io/g/devel/message/101522 Mute This Topic: https://groups.io/mt/97767969/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076= /xyzzy [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-