public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: \x16devel@edk2.groups.io
Cc: Star Zeng <star.zeng@intel.com>, Laszlo Ersek <lersek@redhat.com>,
	Eric Dong <eric.dong@intel.com>, Ruiyu Ni <ruiyu.ni@intel.com>,
	Chandana Kumar <chandana.c.kumar@intel.com>,
	Kevin Li <kevin.y.li@intel.com>
Subject: [PATCH 1/2] UefiCpuPkg CpuCommFeaturesLib: Disable TraceEn at the beginning
Date: Sat,  1 Jun 2019 16:03:40 +0800	[thread overview]
Message-ID: <20190601080341.107760-2-star.zeng@intel.com> (raw)
In-Reply-To: <20190601080341.107760-1-star.zeng@intel.com>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1809

Current code disables TraceEn at the end of ProcTraceInitialize(),
then there will be much memory allocated even when ProcTrace feature
is disabled.

This patch updates code to disable TraceEn and return at the beginning
of ProcTraceInitialize() when when ProcTrace feature is disabled.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Chandana Kumar <chandana.c.kumar@intel.com>
Cc: Kevin Li <kevin.y.li@intel.com>
Signed-off-by: Star Zeng <star.zeng@intel.com>
---
 .../Library/CpuCommonFeaturesLib/ProcTrace.c  | 42 +++++++++----------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
index da6f6beb9477..b98eb116b7b6 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/ProcTrace.c
@@ -199,22 +199,6 @@ ProcTraceInitialize (
   ProcTraceData = (PROC_TRACE_DATA *) ConfigData;
   ASSERT (ProcTraceData != NULL);
 
-  MemRegionBaseAddr = 0;
-  FirstIn = FALSE;
-
-  if (ProcTraceData->ThreadMemRegionTable == NULL) {
-    FirstIn = TRUE;
-    DEBUG ((DEBUG_INFO, "Initialize Processor Trace\n"));
-  }
-
-  ///
-  /// Refer to PROC_TRACE_MEM_SIZE Table for Size Encoding
-  ///
-  MemRegionSize = (UINT32) (1 << (ProcTraceData->ProcTraceMemSize + 12));
-  if (FirstIn) {
-    DEBUG ((DEBUG_INFO, "ProcTrace: MemSize requested: 0x%X \n", MemRegionSize));
-  }
-
   //
   // Clear MSR_IA32_RTIT_CTL[0] and IA32_RTIT_STS only if MSR_IA32_RTIT_CTL[0]==1b
   //
@@ -243,6 +227,26 @@ ProcTraceInitialize (
       );
   }
 
+  if (!State) {
+    return RETURN_SUCCESS;
+  }
+
+  MemRegionBaseAddr = 0;
+  FirstIn = FALSE;
+
+  if (ProcTraceData->ThreadMemRegionTable == NULL) {
+    FirstIn = TRUE;
+    DEBUG ((DEBUG_INFO, "Initialize Processor Trace\n"));
+  }
+
+  ///
+  /// Refer to PROC_TRACE_MEM_SIZE Table for Size Encoding
+  ///
+  MemRegionSize = (UINT32) (1 << (ProcTraceData->ProcTraceMemSize + 12));
+  if (FirstIn) {
+    DEBUG ((DEBUG_INFO, "ProcTrace: MemSize requested: 0x%X \n", MemRegionSize));
+  }
+
   if (FirstIn) {
     //
     //   Let BSP allocate and create the necessary memory region (Aligned to the size of
@@ -459,11 +463,7 @@ ProcTraceInitialize (
   CtrlReg.Bits.OS = 1;
   CtrlReg.Bits.User = 1;
   CtrlReg.Bits.BranchEn = 1;
-  if (!State) {
-    CtrlReg.Bits.TraceEn = 0;
-  } else {
-    CtrlReg.Bits.TraceEn = 1;
-  }
+  CtrlReg.Bits.TraceEn = 1;
   CPU_REGISTER_TABLE_WRITE64 (
     ProcessorNumber,
     Msr,
-- 
2.21.0.windows.1


  reply	other threads:[~2019-06-01  8:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-01  8:03 [PATCH 0/2] Fix GP fault issue and enhance code about ProcTrace Zeng, Star
2019-06-01  8:03 ` Zeng, Star [this message]
2019-06-01  8:03 ` [PATCH 2/2] UefiCpuPkg CpuCommFeaturesLib: Fix GP fault issue " Zeng, Star
  -- strict thread matches above, loose matches on Subject: below --
2019-06-01  8:08 [PATCH 0/2] Fix GP fault issue and enhance code " Zeng, Star
2019-06-01  8:08 ` [PATCH 1/2] UefiCpuPkg CpuCommFeaturesLib: Disable TraceEn at the beginning Zeng, Star

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=20190601080341.107760-2-star.zeng@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