From nobody Sun Feb 8 06:05:24 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+45659+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+45659+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1565837445; cv=none; d=zoho.com; s=zohoarc; b=UC+18UTBlbCNtCUkWOFNwkskmf8WL3vGKcbPm8PAGY9JLzJsn6dBUU19EP5WVk4mhmcJ2novksyVjsSmywfrX7nMdtqBSx7vsmwiF8yltIqULRViWZ9FaHhOXldj2JXL+bYS82XB4GTB7go0VlEp64VkPK2OuxbQTXgwoVoQ+14= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565837445; 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=SuyDsurmZtG/zAuFtqZH0xzarb6wQY5if+mLV7OuNeM=; b=Cv/4jf70UPSLeCo1W15inu/r3QOT25TiRt48w6bJyuGes3TrwbHtPuDF86NeA1BBlRuBnp6XxjKskEk3npaaybenYwlQEFOF/69NmphVPj6q4fP05ZNH6dWqBwvjnxcLASg75kdVDs5qWr1DxEmTZFbcQBiQUSLs6kylwFL6XSE= 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+45659+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 156583744514861.43154345241419; Wed, 14 Aug 2019 19:50:45 -0700 (PDT) Return-Path: X-Received: from mga12.intel.com (mga12.intel.com []) by groups.io with SMTP; Wed, 14 Aug 2019 19:50:43 -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:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,387,1559545200"; d="scan'208";a="176753309" 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:42 -0700 From: "Dong, Eric" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek Subject: [edk2-devel] [Patch v3 3/6] UefiCpuPkg/PiSmmCpuDxeSmm: Supports test then write new value logic. Date: Thu, 15 Aug 2019 10:50:33 +0800 Message-Id: <20190815025036.6780-4-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=1565837444; bh=niMQz/KyMpQeqmQQCAYnb7NpdwxbntYwK4Vu3SztyGE=; h=Cc:Date:From:Reply-To:Subject:To; b=rn53SR10yxN/DPA5p4S5OP28u/C8P0NyOVU271lCqTXYX1LFpFdAbr33dYuR46gnm5J +oVRQthYduTmG3WHe69i5P+A1vnQBTQ3wClks10iBFqD3rxkhjmpfqJTeNcYvsB0t1qpH dbicdYHR6pphcUi6cK8/f7V8/PghHczF6Jo= 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 Reviewed-by: Laszlo Ersek --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c b/UefiCpuPkg/PiSmmCpuDxeSmm/= CpuS3.c index 627a3b87ac..ba5cc0194c 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c @@ -241,6 +241,7 @@ ProgramProcessorRegister ( UINTN ValidThreadCount; UINT32 *ValidCoreCountPerPackage; EFI_STATUS Status; + UINT64 CurrentValue; =20 // // Traverse Register Table of this logical processor @@ -263,6 +264,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, @@ -275,6 +286,24 @@ ProgramProcessorRegister ( // 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 this function is called to restore register setting after INIT= signal, // there is no need to restore MSRs in register table. --=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 (#45659): https://edk2.groups.io/g/devel/message/45659 Mute This Topic: https://groups.io/mt/32882707/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-