[edk2-devel] [PATCH v1 03/11] ShellPkg: acpiview: RSDP: Make printing table checksum optional

Krzysztof Koch krzysztof.koch at arm.com
Fri Jul 12 06:52:35 UTC 2019


1. Don't validate Root System Description Pointer (RSDP) structure
checksum if the '-q' command line flag is used with the acpiview UEFI
shell tool. This change makes the RSDP parser consistent with the
parsers for other ACPI tables.

2. Check if XsdtAddress pointer has been successfully updated before it
is used for further table parsing.

3. Remove redundant forward function declarations by repositioning
blocks of code.

Signed-off-by: Krzysztof Koch <krzysztof.koch at arm.com>
---

Changes can be seen at: https://github.com/KrzysztofKoch1/edk2/commit/73e6d7e117da244f8f4065620115a47f7f66d372

Notes:
    v1:
    - make RSDP parser behavior consistent with other tables [Krzysztof]

 ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 144 +++++++++-----------
 1 file changed, 68 insertions(+), 76 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
index 586de7cbfb12f856c0c735b6e295c1cc32eb2ceb..952517cd09aaff601bb363fd73331c750a9e97ff 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
@@ -1,7 +1,7 @@
 /** @file
   RSDP table parser
 
-  Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Reference(s):
@@ -11,6 +11,7 @@
 #include <Library/UefiLib.h>
 #include "AcpiParser.h"
 #include "AcpiTableParser.h"
+#include "AcpiView.h"
 
 // Local Variables
 STATIC CONST UINT64* XsdtAddress;
@@ -28,7 +29,27 @@ EFIAPI
 ValidateRsdtAddress (
   IN UINT8* Ptr,
   IN VOID*  Context
-  );
+  )
+{
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+  // Reference: Server Base Boot Requirements System Software on ARM Platforms
+  // Section: 4.2.1.1 RSDP
+  // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
+  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
+  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
+  UINT32 RsdtAddr;
+
+  RsdtAddr = *(UINT32*)Ptr;
+
+  if (RsdtAddr != 0) {
+    IncrementErrorCount ();
+    Print (
+      L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",
+      RsdtAddr
+      );
+  }
+#endif
+}
 
 /**
   This function validates the XSDT Address.
@@ -43,7 +64,27 @@ EFIAPI
 ValidateXsdtAddress (
   IN UINT8* Ptr,
   IN VOID*  Context
-  );
+  )
+{
+#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
+  // Reference: Server Base Boot Requirements System Software on ARM Platforms
+  // Section: 4.2.1.1 RSDP
+  // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
+  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
+  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
+  UINT64 XsdtAddr;
+
+  XsdtAddr = *(UINT64*)Ptr;
+
+  if (XsdtAddr == 0) {
+    IncrementErrorCount ();
+    Print (
+      L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",
+      XsdtAddr
+      );
+  }
+#endif
+}
 
 /**
   An array describing the ACPI RSDP Table.
@@ -61,76 +102,6 @@ STATIC CONST ACPI_PARSER RsdpParser[] = {
   {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
 };
 
-/**
-  This function validates the RSDT Address.
-
-  @param [in] Ptr     Pointer to the start of the field data.
-  @param [in] Context Pointer to context specific information e.g. this
-                      could be a pointer to the ACPI table header.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateRsdtAddress (
-  IN UINT8* Ptr,
-  IN VOID*  Context
-  )
-{
-#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
-  // Reference: Server Base Boot Requirements System Software on ARM Platforms
-  // Section: 4.2.1.1 RSDP
-  // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
-  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
-  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
-  UINT32 RsdtAddr;
-
-  RsdtAddr = *(UINT32*)Ptr;
-
-  if (RsdtAddr != 0) {
-    IncrementErrorCount ();
-    Print (
-      L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",
-      RsdtAddr
-      );
-  }
-#endif
-}
-
-/**
-  This function validates the XSDT Address.
-
-  @param [in] Ptr     Pointer to the start of the field data.
-  @param [in] Context Pointer to context specific information e.g. this
-                      could be a pointer to the ACPI table header.
-**/
-STATIC
-VOID
-EFIAPI
-ValidateXsdtAddress (
-  IN UINT8* Ptr,
-  IN VOID*  Context
-  )
-{
-#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
-  // Reference: Server Base Boot Requirements System Software on ARM Platforms
-  // Section: 4.2.1.1 RSDP
-  // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
-  //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
-  //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
-  UINT64 XsdtAddr;
-
-  XsdtAddr = *(UINT64*)Ptr;
-
-  if (XsdtAddr == 0) {
-    IncrementErrorCount ();
-    Print (
-      L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",
-      XsdtAddr
-      );
-  }
-#endif
-}
-
 /**
   This function parses the ACPI RSDP table.
 
@@ -156,10 +127,31 @@ ParseAcpiRsdp (
 {
   if (Trace) {
     DumpRaw (Ptr, AcpiTableLength);
-    VerifyChecksum (TRUE, Ptr, AcpiTableLength);
+    if (GetConsistencyChecking ()) {
+      VerifyChecksum (TRUE, Ptr, AcpiTableLength);
+    }
   }
 
-  ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS (RsdpParser));
+  ParseAcpi (
+    Trace,
+    0,
+    "RSDP",
+    Ptr,
+    AcpiTableLength,
+    PARSER_PARAMS (RsdpParser)
+    );
+
+  // Check if the values used to control the parsing logic have been
+  // successfully read.
+  if (XsdtAddress == NULL) {
+    IncrementErrorCount ();
+    Print (
+      L"ERROR: Insufficient table length. AcpiTableLength = %d." \
+        L"RSDP parsing aborted.\n",
+      AcpiTableLength
+      );
+    return;
+  }
 
   // This code currently supports parsing of XSDT table only
   // and does not parse the RSDT table. Platforms provide the
@@ -167,7 +159,7 @@ ParseAcpiRsdp (
   // Therefore the RSDT should not be used on ARM platforms.
   if ((*XsdtAddress) == 0) {
     IncrementErrorCount ();
-    Print (L"ERROR: XSDT Pointer is not set.\n");
+    Print (L"ERROR: XSDT Pointer is not set. RSDP parsing aborted.\n");
     return;
   }
 
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43644): https://edk2.groups.io/g/devel/message/43644
Mute This Topic: https://groups.io/mt/32439506/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list