acpica-tools/0039-Support-TPM2-in-a-big-endian-world.patch

120 lines
4.1 KiB
Diff
Raw Normal View History

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