public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sean Rhodes" <sean@starlabs.systems>
To: devel@edk2.groups.io
Cc: eric.dong@intel.com, Patrick Rudolph <patrick.rudolph@9elements.com>
Subject: [PATCH 16/18] UefiCpuPkg: Disable MTRR programming for UefiPayloadPkg
Date: Thu, 10 Feb 2022 21:28:22 +0000	[thread overview]
Message-ID: <d71244033d247e4a0d40b9c2e73c5a72131a481c.1644527848.git.sean@starlabs.systems> (raw)
In-Reply-To: <df21ef7edddfef8074ba94514bf73d7a5d0d6046.1644527848.git.sean@starlabs.systems>

From: Patrick Rudolph <patrick.rudolph@9elements.com>

The MTRRs have already been programmed by FSB.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.c   | 4 ++++
 UefiCpuPkg/Library/MtrrLib/MtrrLib.inf | 2 +-
 UefiCpuPkg/UefiCpuPkg.dec              | 4 ++++
 UefiCpuPkg/UefiCpuPkg.uni              | 8 ++++++--
 UefiPayloadPkg/UefiPayloadPkg.dsc      | 4 ++++
 5 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index e5c862c83d..8734bae2f0 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -2845,6 +2845,10 @@ IsMtrrSupported (
   CPUID_VERSION_INFO_EDX     Edx;
   MSR_IA32_MTRRCAP_REGISTER  MtrrCap;
 
+  if (PcdGetBool (PcdCpuDisableMtrrProgramming)) {
+    return FALSE;
+  }
+
   //
   // Check CPUID(1).EDX[12] for MTRR capability
   //
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
index 4c9ea2def3..afc0bcc724 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
@@ -15,7 +15,6 @@
   VERSION_STRING                 = 1.0
   LIBRARY_CLASS                  = MtrrLib
 
-
 #
 # The following information is for reference only and not required by the build tools.
 #
@@ -37,4 +36,5 @@
 
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs   ## SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming          ## CONSUMES
 
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 7de66fde67..a2a4ecc094 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -217,6 +217,10 @@
   # @Prompt SMM Code Access Check.
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmCodeAccessCheckEnable|TRUE|BOOLEAN|0x60000013
 
+  ## Disables MTRR programming in case it's already programmed by FSB.
+  # @Prompt Disable MTRR programming.
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming|FALSE|BOOLEAN|0x00000017
+
   ## Specifies the number of variable MTRRs reserved for OS use. The default number of
   #  MTRRs reserved for OS use is 2.
   # @Prompt Number of reserved variable MTRRs.
diff --git a/UefiCpuPkg/UefiCpuPkg.uni b/UefiCpuPkg/UefiCpuPkg.uni
index 219c1963bf..3db0063f50 100644
--- a/UefiCpuPkg/UefiCpuPkg.uni
+++ b/UefiCpuPkg/UefiCpuPkg.uni
@@ -140,9 +140,13 @@
 
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuHotPlugDataAddress_HELP  #language en-US "Contains the pointer to a CPU Hot Plug Data structure if CPU hot-plug is supported."
 
-#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT  #language en-US "Number of reserved variable MTRRs"
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuDisableMtrrProgramming_PROMPT  #language en-US "Number of reserved variable MTRRs"
 
-#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP  #language en-US "Specifies the number of variable MTRRs reserved for OS use."
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuDisableMtrrProgramming_HELP  #language en-US "Specifies the number of variable MTRRs reserved for OS use."
+
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_PROMPT  #language en-US "Disable MTRR programming."
+
+#string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuNumberOfReservedVariableMtrrs_HELP  #language en-US "Disables MTRR programming in case it's already programmed by FSB."
 
 #string STR_gUefiCpuPkgTokenSpaceGuid_PcdCpuApLoopMode_PROMPT  #language en-US "The AP wait loop state"
 
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayloadPkg.dsc
index c8562d592b..afec9109c1 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -37,6 +37,7 @@
   DEFINE BOOT_MANAGER_ESCAPE          = FALSE
   DEFINE BOOTSPLASH_IMAGE             = FALSE
   DEFINE FOLLOW_BGRT_SPEC             = FALSE
+  DEFINE MTRR_PROGRAMMING             = TRUE
   DEFINE PLATFORM_BOOT_TIMEOUT        = 3
   #
   # SBL:      UEFI payload for Slim Bootloader
@@ -412,6 +413,9 @@
 
   gUefiPayloadPkgTokenSpaceGuid.PcdAbove4GMemory|$(ABOVE_4G_MEMORY)
 
+  # Disable MTRR programming
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuDisableMtrrProgramming|$(MTRR_PROGRAMMING)
+
 [PcdsPatchableInModule.X64]
   gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)
   gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)
-- 
2.32.0


  parent reply	other threads:[~2022-02-10 21:28 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <df21ef7edddfef8074ba94514bf73d7a5d0d6046.1644527848.git.sean@starlabs.systems>
2022-02-10 21:20 ` [PATCH 02/18] UefiPayloadPkg: Provide option to use Boot Splash Sean Rhodes
2022-02-10 21:23 ` [PATCH 03/18] MdeModulePackage: Add option to follow BGRT spec Sean Rhodes
2022-02-10 21:23 ` [PATCH 04/18] UefiPayloadPkg: Hookup BGRT build option Sean Rhodes
2022-02-10 21:23 ` [PATCH 05/18] UefiPayloadPkg: Make Boot Manager Key configurable Sean Rhodes
2022-02-10 21:24 ` [PATCH 06/18] UefiPayloadPkg: Add build option for Above 4G Memory Sean Rhodes
2022-02-10 21:24 ` [PATCH 08/18] UefiPayloadPkg: Fix case of protocol Sean Rhodes
2022-02-20 18:11   ` [edk2-devel] " Patrick Rudolph
2022-02-10 21:25 ` [PATCH 09/18] SdMmcPciDxe: Reduce timeout for SD card reset Sean Rhodes
2022-02-11  3:15   ` Wu, Hao A
2022-02-10 21:25 ` [PATCH 10/18] BlSupportSmm: fix definition of SetSmrr() Sean Rhodes
2022-02-20 18:09   ` [edk2-devel] " Patrick Rudolph
2022-02-10 21:25 ` [PATCH 11/18] UefiPayloadPkg: Make Boot Timeout configurable Sean Rhodes
2022-02-10 21:26 ` [PATCH 12/18] Ps2KbdCtrller: Make wait for SUCCESS after BAT non-fatal Sean Rhodes
2022-02-11  3:12   ` Wu, Hao A
2022-02-10 21:27 ` [PATCH 13/18] MdeModulePkg/Usb/Keyboard.c: don't request protocol before setting Sean Rhodes
2022-02-11  3:32   ` Wu, Hao A
2022-02-11 22:45     ` MrChromebox
2022-02-18  2:17       ` [edk2-devel] " Wu, Hao A
2022-02-10 21:27 ` [PATCH 14/18] UefiPayloadPkg: Add RNG support Sean Rhodes
2022-02-16 23:57   ` Guo Dong
2022-02-10 21:27 ` [PATCH 15/18] UefiPayloadPkg/Library/PlatformBootManagerLib: Remove broken VGA detection Sean Rhodes
2022-02-16 23:51   ` Guo Dong
2022-03-21  9:48     ` [edk2-devel] " Sean Rhodes
2022-03-29 17:32       ` Guo Dong
2022-03-29 17:34         ` Sean Rhodes
2022-03-29 18:01           ` Guo Dong
2022-03-29 18:04             ` Sean Rhodes
2022-03-29 18:22               ` Guo Dong
2022-02-10 21:28 ` Sean Rhodes [this message]
2022-02-10 22:06   ` [edk2-devel] [PATCH 16/18] UefiCpuPkg: Disable MTRR programming for UefiPayloadPkg Michael D Kinney
2022-02-11  7:12     ` Patrick Rudolph
2022-02-10 21:29 ` [PATCH 17/18] BmBoot: prioritize internal boot devices over external Sean Rhodes
2022-02-10 21:29 ` [PATCH 18/18] UefiPayloadPkg: Hookup Prioritise Internal build option Sean Rhodes

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=d71244033d247e4a0d40b9c2e73c5a72131a481c.1644527848.git.sean@starlabs.systems \
    --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