From nobody Sun Feb 8 05:08:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+45661+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45661+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565837448; cv=none; d=zoho.com; s=zohoarc; b=TWaXdOlvHo+QPo/hk6yOPX+p2fDG+x/7cFhoOqtlGiR45dhJbPxY8q68r93vWbp5CECWGkbOh3bNJNDtEFk6zC2EiRzq5uxuYy6P1ugltFNe69ELRc+rxPRr9TxEwQny+V7ShUBaSTsnHo0Qt9ErqBh/aWCF2ZSz0f8a2hXebaA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565837448; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=Uu8xfTQ+cFoz/kMbIZASm4W1ftMrbWXOVieI2YKGP2E=; b=HoVoXT4AVnCOnjN5aTMRYfeUadzo67D+G1G+i3UFk4NXLtSGv3cUvJldoktiYZGhnkn8b5V4yAT+jS41urpI1SJhfMvkFLMqg32ZtXalEA8iuQVkbMZecMhKsq/R+OTVwTVLGAyyLLKLo98Gl5YUhqdTc0q4gU6LqCVIraU5zK8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+45661+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1565837448321481.4548076656856; Wed, 14 Aug 2019 19:50:48 -0700 (PDT) Return-Path: X-Received: from mga12.intel.com (mga12.intel.com []) by groups.io with SMTP; Wed, 14 Aug 2019 19:50:46 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Aug 2019 19:50:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,387,1559545200"; d="scan'208";a="176753334" X-Received: from ydong10-win10.ccr.corp.intel.com ([10.239.158.133]) by fmsmga008.fm.intel.com with ESMTP; 14 Aug 2019 19:50:45 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek Subject: [edk2-devel] [Patch v3 5/6] UefiCpuPkg/RegisterCpuFeaturesLib: Supports test then write new value logic. Date: Thu, 15 Aug 2019 10:50:35 +0800 Message-Id: <20190815025036.6780-6-eric.dong@intel.com> In-Reply-To: <20190815025036.6780-1-eric.dong@intel.com> References: <20190815025036.6780-1-eric.dong@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,eric.dong@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1565837447; bh=VMeCvIpAS8r2zH2HJSDm2H/7924GVbTu9xh01DjDBio=; h=Cc:Date:From:Reply-To:Subject:To; b=wrkM4YfH/YjeC3UqY41i+0LShGI1LWgF+Ka8F5AFaRf9Tk/tnllr39XKxXxpavy7IWD 9eVEndpiqQXKitAx4iXEz+fbK/9HVfoMGuzMslXHUC01LpeOq/MXz2fyCHYYFLWROjKQi 6o0yo0klo0l1TdaMfsBVw7bOQdCuKr0CLAk= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2040 Supports new logic which test current value before write new value. Only write new value when current value not same as new value. Signed-off-by: Eric Dong Cc: Ray Ni Acked-by: Laszlo Ersek --- .../CpuFeaturesInitialize.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitializ= e.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c index 63bc50a55f..0a4fcff033 100644 --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c @@ -826,6 +826,7 @@ ProgramProcessorRegister ( UINTN ValidThreadCount; UINT32 *ValidCoreCountPerPackage; EFI_STATUS Status; + UINT64 CurrentValue; =20 // // Traverse Register Table of this logical processor @@ -848,7 +849,16 @@ ProgramProcessorRegister ( if (EFI_ERROR (Status)) { break; } - + if (RegisterTableEntry->TestThenWrite) { + CurrentValue =3D BitFieldRead64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTable= Entry->ValidBitLength - 1 + ); + if (CurrentValue =3D=3D RegisterTableEntry->Value) { + break; + } + } Value =3D (UINTN) BitFieldWrite64 ( Value, RegisterTableEntry->ValidBitStart, @@ -857,10 +867,29 @@ ProgramProcessorRegister ( ); ReadWriteCr (RegisterTableEntry->Index, FALSE, &Value); break; + // // The specified register is Model Specific Register // case Msr: + if (RegisterTableEntry->TestThenWrite) { + Value =3D (UINTN)AsmReadMsr64 (RegisterTableEntry->Index); + if (RegisterTableEntry->ValidBitLength >=3D 64) { + if (Value =3D=3D RegisterTableEntry->Value) { + break; + } + } else { + CurrentValue =3D BitFieldRead64 ( + Value, + RegisterTableEntry->ValidBitStart, + RegisterTableEntry->ValidBitStart + RegisterTab= leEntry->ValidBitLength - 1 + ); + if (CurrentValue =3D=3D RegisterTableEntry->Value) { + break; + } + } + } + if (RegisterTableEntry->ValidBitLength >=3D 64) { // // If length is not less than 64 bits, then directly write without= reading --=20 2.21.0.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 (#45661): https://edk2.groups.io/g/devel/message/45661 Mute This Topic: https://groups.io/mt/32882709/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-