]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg VariableInfo: Always consider RT DXE and SMM stats
authorMichael Kubacki <michael.a.kubacki@intel.com>
Wed, 25 Sep 2019 21:58:45 +0000 (14:58 -0700)
committerMichael Kubacki <michael.a.kubacki@intel.com>
Wed, 6 Nov 2019 05:55:54 +0000 (21:55 -0800)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220

The current VariableInfo application only checks for variable
statistics from SMM if the variable information entries are
not present in the UEFI System Configuration table as published
by the DXE UEFI variable driver (VariableRuntimeDxe).

This change first checks for variable information entries in the
UEFI System Configuration but always checks for entries in SMM
as well. If the SMM variable driver is not present, an instance of
EFI_SMM_VARIABLE_PROTOCOL will not be found and the search for
SMM variable statistics will be aborted (an SW SMI to get variable
statistics will not be triggered).

In the case variable statistics are provided by both a Runtime DXE
driver (e.g. VariableSmmRuntimeDxe) and a SMM driver (VariableSmm),
this change will clearly identify statistics from each respective
driver.

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Acked-by: Hao A Wu <hao.a.wu@intel.com>
MdeModulePkg/Application/VariableInfo/VariableInfo.c

index f213471e9abcdc9287d75a78ce868c638ef24704..c04ba182132faa44c2fdc224a177c1e085fc1d3f 100644 (file)
@@ -3,7 +3,7 @@
   this utility will print out the statistics information. You can use console\r
   redirection to capture the data.\r
 \r
-  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -126,7 +126,7 @@ PrintInfoFromSmm (
   ASSERT (CommBuffer != NULL);\r
   ZeroMem (CommBuffer, RealCommSize);\r
 \r
-  Print (L"Non-Volatile SMM Variables:\n");\r
+  Print (L"SMM Driver Non-Volatile Variables:\n");\r
   do {\r
     CommSize = RealCommSize;\r
     Status = GetVariableStatisticsData (CommBuffer, &CommSize);\r
@@ -155,7 +155,7 @@ PrintInfoFromSmm (
     }\r
   } while (TRUE);\r
 \r
-  Print (L"Volatile SMM Variables:\n");\r
+  Print (L"SMM Driver Volatile Variables:\n");\r
   ZeroMem (CommBuffer, RealCommSize);\r
   do {\r
     CommSize = RealCommSize;\r
@@ -207,24 +207,18 @@ UefiMain (
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
 {\r
-  EFI_STATUS            Status;\r
+  EFI_STATUS            RuntimeDxeStatus;\r
+  EFI_STATUS            SmmStatus;\r
   VARIABLE_INFO_ENTRY   *VariableInfo;\r
   VARIABLE_INFO_ENTRY   *Entry;\r
 \r
-  Status = EfiGetSystemConfigurationTable (&gEfiVariableGuid, (VOID **)&Entry);\r
-  if (EFI_ERROR (Status) || (Entry == NULL)) {\r
-    Status = EfiGetSystemConfigurationTable (&gEfiAuthenticatedVariableGuid, (VOID **)&Entry);\r
+  RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiVariableGuid, (VOID **) &Entry);\r
+  if (EFI_ERROR (RuntimeDxeStatus) || (Entry == NULL)) {\r
+    RuntimeDxeStatus = EfiGetSystemConfigurationTable (&gEfiAuthenticatedVariableGuid, (VOID **) &Entry);\r
   }\r
 \r
-  if (EFI_ERROR (Status) || (Entry == NULL)) {\r
-    Status = PrintInfoFromSmm ();\r
-    if (!EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status) && (Entry != NULL)) {\r
-    Print (L"Non-Volatile EFI Variables:\n");\r
+  if (!EFI_ERROR (RuntimeDxeStatus) && (Entry != NULL)) {\r
+    Print (L"Runtime DXE Driver Non-Volatile EFI Variables:\n");\r
     VariableInfo = Entry;\r
     do {\r
       if (!VariableInfo->Volatile) {\r
@@ -242,7 +236,7 @@ UefiMain (
       VariableInfo = VariableInfo->Next;\r
     } while (VariableInfo != NULL);\r
 \r
-    Print (L"Volatile EFI Variables:\n");\r
+    Print (L"Runtime DXE Driver Volatile EFI Variables:\n");\r
     VariableInfo = Entry;\r
     do {\r
       if (VariableInfo->Volatile) {\r
@@ -258,14 +252,19 @@ UefiMain (
       }\r
       VariableInfo = VariableInfo->Next;\r
     } while (VariableInfo != NULL);\r
+  }\r
+\r
+  SmmStatus = PrintInfoFromSmm ();\r
 \r
-  } else {\r
+  if (EFI_ERROR (RuntimeDxeStatus) && EFI_ERROR (SmmStatus)) {\r
     Print (L"Warning: Variable Dxe/Smm driver doesn't enable the feature of statistical information!\n");\r
     Print (L"If you want to see this info, please:\n");\r
     Print (L"  1. Set PcdVariableCollectStatistics as TRUE\n");\r
     Print (L"  2. Rebuild Variable Dxe/Smm driver\n");\r
     Print (L"  3. Run \"VariableInfo\" cmd again\n");\r
+\r
+    return EFI_NOT_FOUND;\r
   }\r
 \r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r