public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Leo Duran <leo.duran@amd.com>
To: edk2-devel@lists.01.org
Cc: Leo Duran <leo.duran@amd.com>, Eric Dong <eric.dong@intel.com>,
	Laszlo Ersek <lersek@redhat.com>
Subject: [PATCH] UefiCpuPkg/MtrrLib: Add flag to skip disabling MTRRs prior to MTRR change.
Date: Tue, 11 Sep 2018 10:41:38 -0500	[thread overview]
Message-ID: <1536680498-6554-2-git-send-email-leo.duran@amd.com> (raw)
In-Reply-To: <1536680498-6554-1-git-send-email-leo.duran@amd.com>

The default behavior is to disable MTRRs prior to an MTRR change.
However, on SMT platforms with shared CPU resources it may be desirable to
skip the default behavior, and leave the current state of the Enable bit.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Leo Duran <leo.duran@amd.com>
---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.c   | 10 +++++++---
 UefiCpuPkg/Library/MtrrLib/MtrrLib.inf |  3 +++
 UefiCpuPkg/UefiCpuPkg.dec              |  7 +++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
index dfce9a9..baf9a0f 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.c
@@ -6,6 +6,8 @@
     except for MtrrSetAllMtrrs() which is used to sync BSP's MTRR setting to APs.
 
   Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, AMD Inc. All rights reserved.<BR>
+
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -310,9 +312,11 @@ MtrrLibPreMtrrChange (
   //
   // Disable MTRRs
   //
-  DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
-  DefType.Bits.E = 0;
-  AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);
+  if (!PcdGetBool (PcdSkipDisableMtrrsOnPreMtrrChange)) {
+    DefType.Uint64 = AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE);
+    DefType.Bits.E = 0;
+    AsmWriteMsr64 (MSR_IA32_MTRR_DEF_TYPE, DefType.Uint64);
+  }
 }
 
 /**
diff --git a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
index a97cc61..06f33e8 100644
--- a/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
+++ b/UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
@@ -2,6 +2,8 @@
 #  MTRR library provides APIs for MTRR operation.
 #
 #  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2018, AMD Inc. All rights reserved.<BR>
+#
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
@@ -43,4 +45,5 @@
 
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs   ## SOMETIMES_CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdSkipDisableMtrrsOnPreMtrrChange    ## CONSUMES
 
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 69d777a..64ec763 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -2,6 +2,7 @@
 # This Package provides UEFI compatible CPU modules and libraries.
 #
 # Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, AMD Inc. All rights reserved.<BR>
 #
 # This program and the accompanying materials are licensed and made available under
 # the terms and conditions of the BSD License which accompanies this distribution.
@@ -273,6 +274,12 @@
   # @Prompt Current boot is a power-on reset.
   gUefiCpuPkgTokenSpaceGuid.PcdIsPowerOnReset|FALSE|BOOLEAN|0x0000001B
 
+  ## Indicates desired behavior for disabling MTRRs prior to MTRR change.<BR><BR>
+  #   TRUE  - Skip disabling MTRRs prior to MTRR change.<BR>
+  #   FALSE - Disable MTRRs prior to MTRR change.<BR>
+  # @Prompt Desired behavior for disabling MTRRs prior to MTRR change.
+  gUefiCpuPkgTokenSpaceGuid.PcdSkipDisableMtrrsOnPreMtrrChange|FALSE|BOOLEAN|0x0000001E
+
 [PcdsDynamic, PcdsDynamicEx]
   ## Contains the pointer to a CPU S3 data buffer of structure ACPI_CPU_DATA.
   # @Prompt The pointer to a CPU S3 data buffer.
-- 
2.7.4



  reply	other threads:[~2018-09-11 15:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11 15:41 [PATCH] Add flag to skip disabling MTRRs Leo Duran
2018-09-11 15:41 ` Leo Duran [this message]
2018-09-11 18:49   ` [PATCH] UefiCpuPkg/MtrrLib: Add flag to skip disabling MTRRs prior to MTRR change Laszlo Ersek
2018-09-11 19:47     ` Duran, Leo
2018-09-12  9:54       ` Laszlo Ersek
2018-09-12 15:17         ` Duran, Leo
2018-09-12 17:59           ` Laszlo Ersek
2018-09-12 18:21             ` Duran, Leo
2018-09-13  2:39               ` Ni, Ruiyu
2018-09-13 19:31                 ` Duran, Leo
2018-09-14  4:44                   ` Ni, Ruiyu
2018-09-17 16:20                     ` Duran, Leo
2018-09-17 16:38                       ` Laszlo Ersek
2018-09-18  8:34                         ` Ni, Ruiyu
2018-09-18 14:57                           ` Duran, Leo
2018-09-19  8:58                             ` Ni, Ruiyu
2018-09-21 16:52                               ` Duran, Leo
2018-09-21 17:13                                 ` Duran, Leo
2018-09-25 14:29                                   ` Duran, Leo

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=1536680498-6554-2-git-send-email-leo.duran@amd.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