public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Dong, Eric" <eric.dong@intel.com>
To: devel@edk2.groups.io
Cc: Ray Ni <ray.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>
Subject: [Patch 0/4] Add "Test then Set" mechanism.
Date: Fri,  9 Aug 2019 14:11:55 +0800	[thread overview]
Message-ID: <20190809061159.40248-1-eric.dong@intel.com> (raw)

Below code is current implementation:
  if (MsrRegister[ProcessorNumber].Bits.Lock == 0) {
    CPU_REGISTER_TABLE_WRITE_FIELD (
      ProcessorNumber,
      Msr,
      MSR_IA32_FEATURE_CONTROL,
      MSR_IA32_FEATURE_CONTROL_REGISTER,
      Bits.Lock,
      1
    );
  }

With below steps, the Bits.Lock bit will lose its value:
1. Trig normal boot, the Bits.Lock is 0. 1 will be added
   into the register table and then will set to the MSR.
2. Trig warm reboot, MSR value preserves. After normal boot phase,
   the Bits.Lock is 1, so it will not be added into the register
   table during the warm reboot phase.
3. Trig S3 then resume, the Bits.Lock change to 0 and Bits.Lock is
   not added in register table during normal boot phase. so it's
   still 0 after resume. 
This is not an expect behavior. The expect result is the value should
always 1 after booting or resuming from S3.

The root cause for this issue is
1. driver bases on current value to insert the "set value action" to
   the register table.
2. Some MSRs may reserve their value during warm reboot. So the insert
   action may be skip after warm reboot.

The solution for this issue is:
1. Always add "Test then Set" action for above referred MSRs.
2. Detect current value before set new value. Only set new value when
   current value not same as new value.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>

Eric Dong (4):
  UefiCpuPkg/RegisterCpuFeaturesLib: Add "detect before set" Micros.
  UefiCpuPkg/RegisterCpuFeaturesLib: Supports detect before set new
    value logic.
  UefiCpuPkg/PiSmmCpuDxeSmm: Supports detect before set new value logic.
  UefiCpuPkg/CpuCommonFeaturesLib: Use new micros.

 UefiCpuPkg/Include/AcpiCpuData.h              |   1 +
 .../Include/Library/RegisterCpuFeaturesLib.h  |  77 +++++++++-
 .../CpuCommonFeaturesLib/CpuCommonFeatures.h  |  15 --
 .../CpuCommonFeaturesLib.c                    |   8 +-
 .../CpuCommonFeaturesLib/FeatureControl.c     | 141 ++++++------------
 .../CpuCommonFeaturesLib/MachineCheck.c       |  23 ++-
 .../CpuFeaturesInitialize.c                   | 141 ++++++++++++------
 .../RegisterCpuFeaturesLib.c                  |  14 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c             | 135 +++++++++++------
 9 files changed, 323 insertions(+), 232 deletions(-)

-- 
2.21.0.windows.1


             reply	other threads:[~2019-08-09  6:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09  6:11 Dong, Eric [this message]
2019-08-09  6:11 ` [Patch 1/4] UefiCpuPkg/RegisterCpuFeaturesLib: Add "detect before set" Micros Dong, Eric
2019-08-09 15:14   ` Laszlo Ersek
2019-08-12  7:46     ` [edk2-devel] " Dong, Eric
2019-08-12 13:01       ` Laszlo Ersek
2019-08-09 15:31   ` Laszlo Ersek
2019-08-12  8:05     ` Dong, Eric
2019-08-09  6:11 ` [Patch 2/4] UefiCpuPkg/RegisterCpuFeaturesLib: Supports detect before set new value logic Dong, Eric
2019-08-09  6:11 ` [Patch 3/4] UefiCpuPkg/PiSmmCpuDxeSmm: " Dong, Eric
2019-08-09 15:30   ` Laszlo Ersek
2019-08-12  8:37     ` [edk2-devel] " Dong, Eric
2019-08-09  6:11 ` [Patch 4/4] UefiCpuPkg/CpuCommonFeaturesLib: Use "Test then set" action Dong, Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190809061159.40248-1-eric.dong@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox