Blame SOURCES/0039-Support-TPM2-in-a-big-endian-world.patch

9897bb
From c240ab3af6a4ad4405def7188e3d64da06a69f37 Mon Sep 17 00:00:00 2001
9897bb
From: Al Stone <ahs3@redhat.com>
9897bb
Date: Wed, 30 Sep 2020 18:42:38 -0600
9897bb
Subject: [PATCH 39/45] Support TPM2 in a big-endian world
9897bb
9897bb
Signed-off-by: Al Stone <ahs3@redhat.com>
9897bb
---
9897bb
 source/common/dmtbdump3.c  | 18 ++++++++++--------
9897bb
 source/compiler/dttable2.c |  8 +++++---
9897bb
 2 files changed, 15 insertions(+), 11 deletions(-)
9897bb
9897bb
Index: acpica-unix2-20210604/source/common/dmtbdump3.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmtbdump3.c
9897bb
+++ acpica-unix2-20210604/source/common/dmtbdump3.c
9897bb
@@ -470,11 +470,12 @@ AcpiDmDumpTpm2Rev3 (
9897bb
     ACPI_TABLE_TPM23        *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM23, Table);
9897bb
     ACPI_TPM23_TRAILER      *Subtable = ACPI_ADD_PTR (ACPI_TPM23_TRAILER, Table, Offset);
9897bb
     ACPI_STATUS             Status;
9897bb
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
 
9897bb
 
9897bb
     /* Main table */
9897bb
 
9897bb
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm23);
9897bb
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoTpm23);
9897bb
     if (ACPI_FAILURE (Status))
9897bb
     {
9897bb
         return;
9897bb
@@ -486,8 +487,8 @@ AcpiDmDumpTpm2Rev3 (
9897bb
     {
9897bb
     case ACPI_TPM23_ACPI_START_METHOD:
9897bb
 
9897bb
-        (void) AcpiDmDumpTable (Table->Length, Offset, Subtable,
9897bb
-            Table->Length - Offset, AcpiDmTableInfoTpm23a);
9897bb
+        (void) AcpiDmDumpTable (TableLength, Offset, Subtable,
9897bb
+            TableLength - Offset, AcpiDmTableInfoTpm23a);
9897bb
         break;
9897bb
 
9897bb
     default:
9897bb
@@ -517,6 +518,7 @@ AcpiDmDumpTpm2 (
9897bb
     ACPI_TPM2_TRAILER       *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset);
9897bb
     ACPI_TPM2_ARM_SMC       *ArmSubtable;
9897bb
     ACPI_STATUS             Status;
9897bb
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
 
9897bb
 
9897bb
     if (Table->Revision == 3)
9897bb
@@ -527,7 +529,7 @@ AcpiDmDumpTpm2 (
9897bb
 
9897bb
     /* Main table */
9897bb
 
9897bb
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2);
9897bb
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoTpm2);
9897bb
 
9897bb
     if (ACPI_FAILURE (Status))
9897bb
     {
9897bb
@@ -535,8 +537,8 @@ AcpiDmDumpTpm2 (
9897bb
     }
9897bb
 
9897bb
     AcpiOsPrintf ("\n");
9897bb
-    Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
9897bb
-        Table->Length - Offset, AcpiDmTableInfoTpm2a);
9897bb
+    Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
9897bb
+        TableLength - Offset, AcpiDmTableInfoTpm2a);
9897bb
     if (ACPI_FAILURE (Status))
9897bb
     {
9897bb
         return;
9897bb
@@ -551,8 +553,8 @@ AcpiDmDumpTpm2 (
9897bb
         Offset += sizeof (ACPI_TPM2_TRAILER);
9897bb
 
9897bb
         AcpiOsPrintf ("\n");
9897bb
-        (void) AcpiDmDumpTable (Table->Length, Offset, ArmSubtable,
9897bb
-            Table->Length - Offset, AcpiDmTableInfoTpm211);
9897bb
+        (void) AcpiDmDumpTable (TableLength, Offset, ArmSubtable,
9897bb
+            TableLength - Offset, AcpiDmTableInfoTpm211);
9897bb
         break;
9897bb
 
9897bb
     default:
9897bb
Index: acpica-unix2-20210604/source/compiler/dttable2.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/compiler/dttable2.c
9897bb
+++ acpica-unix2-20210604/source/compiler/dttable2.c
9897bb
@@ -2267,6 +2267,7 @@ DtCompileTpm2 (
9897bb
     DT_SUBTABLE             *ParentTable;
9897bb
     ACPI_STATUS             Status = AE_OK;
9897bb
     ACPI_TABLE_HEADER       *Header;
9897bb
+    UINT8                   StartMethod;
9897bb
 
9897bb
 
9897bb
     ParentTable = DtPeekSubtable ();
9897bb
@@ -2310,7 +2311,8 @@ DtCompileTpm2 (
9897bb
 
9897bb
     /* Subtable type depends on the StartMethod */
9897bb
 
9897bb
-    switch (Tpm2Header->StartMethod)
9897bb
+    StartMethod = *(UINT8 *) &Tpm2Header->StartMethod;
9897bb
+    switch (StartMethod)
9897bb
     {
9897bb
     case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
9897bb
 
9897bb
@@ -2341,7 +2343,7 @@ DtCompileTpm2 (
9897bb
     case ACPI_TPM2_RESERVED10:
9897bb
 
9897bb
         AcpiOsPrintf ("\n**** Reserved TPM2 Start Method type 0x%X\n",
9897bb
-            Tpm2Header->StartMethod);
9897bb
+            StartMethod);
9897bb
         Status = AE_ERROR;
9897bb
         break;
9897bb
 
9897bb
@@ -2349,7 +2351,7 @@ DtCompileTpm2 (
9897bb
     default:
9897bb
 
9897bb
         AcpiOsPrintf ("\n**** Unknown TPM2 Start Method type 0x%X\n",
9897bb
-            Tpm2Header->StartMethod);
9897bb
+            StartMethod);
9897bb
         Status = AE_ERROR;
9897bb
         break;
9897bb
     }