|
|
214d7a |
From 5aec8511fc433a71cb8b6d26be464355d0c3f5cc Mon Sep 17 00:00:00 2001
|
|
|
214d7a |
From: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
Date: Thu, 24 Sep 2020 15:25:53 -0600
|
|
|
214d7a |
Subject: [PATCH 26/45] Support NFIT in a big-endian world
|
|
|
214d7a |
|
|
|
214d7a |
NB: this required correcting the starting pointer for the NFIT
|
|
|
214d7a |
SMBIOS subtable; otherwise, disassembly did not work properly.
|
|
|
214d7a |
|
|
|
214d7a |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
---
|
|
|
214d7a |
source/common/dmtable.c | 4 ++--
|
|
|
214d7a |
source/common/dmtbdump2.c | 49 ++++++++++++++++++++++----------------
|
|
|
214d7a |
source/compiler/dttable2.c | 11 ++++++---
|
|
|
214d7a |
3 files changed, 39 insertions(+), 25 deletions(-)
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/common/dmtable.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/common/dmtable.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/common/dmtable.c
|
|
|
214d7a |
@@ -1526,13 +1526,13 @@ AcpiDmDumpTable (
|
|
|
214d7a |
|
|
|
214d7a |
/* NFIT subtable types */
|
|
|
214d7a |
|
|
|
214d7a |
- Temp16 = ACPI_GET16 (Target);
|
|
|
214d7a |
+ Temp16 = AcpiUtReadUint16 (Target);
|
|
|
214d7a |
if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
|
|
|
214d7a |
{
|
|
|
214d7a |
Temp16 = ACPI_NFIT_TYPE_RESERVED;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
- AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
|
|
|
214d7a |
+ AcpiOsPrintf (UINT16_FORMAT, Temp16,
|
|
|
214d7a |
AcpiDmNfitSubnames[Temp16]);
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/common/dmtbdump2.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/common/dmtbdump2.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/common/dmtbdump2.c
|
|
|
214d7a |
@@ -1192,18 +1192,23 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
ACPI_STATUS Status;
|
|
|
214d7a |
UINT32 Offset = sizeof (ACPI_TABLE_NFIT);
|
|
|
214d7a |
UINT32 FieldOffset = 0;
|
|
|
214d7a |
- UINT32 Length;
|
|
|
214d7a |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
ACPI_NFIT_HEADER *Subtable;
|
|
|
214d7a |
ACPI_DMTABLE_INFO *InfoTable;
|
|
|
214d7a |
ACPI_NFIT_INTERLEAVE *Interleave = NULL;
|
|
|
214d7a |
ACPI_NFIT_SMBIOS *SmbiosInfo = NULL;
|
|
|
214d7a |
ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
|
|
|
214d7a |
UINT32 i;
|
|
|
214d7a |
+ UINT32 Length;
|
|
|
214d7a |
+ UINT32 LineCount;
|
|
|
214d7a |
+ UINT16 SubtableLength;
|
|
|
214d7a |
+ UINT16 SubtableType;
|
|
|
214d7a |
+ UINT16 HintCount;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Main table */
|
|
|
214d7a |
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoNfit);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoNfit);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -1212,19 +1217,21 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
/* Subtables */
|
|
|
214d7a |
|
|
|
214d7a |
Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Table, Offset);
|
|
|
214d7a |
- while (Offset < Table->Length)
|
|
|
214d7a |
+ while (Offset < TableLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* NFIT subtable header */
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
|
|
|
214d7a |
- Subtable->Length, AcpiDmTableInfoNfitHdr);
|
|
|
214d7a |
+ SubtableType = AcpiUtReadUint16 (&Subtable->Type);
|
|
|
214d7a |
+ SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
|
|
|
214d7a |
+ SubtableLength, AcpiDmTableInfoNfitHdr);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
- switch (Subtable->Type)
|
|
|
214d7a |
+ switch (SubtableType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1275,11 +1282,11 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
|
|
|
214d7a |
default:
|
|
|
214d7a |
AcpiOsPrintf ("\n**** Unknown NFIT subtable type 0x%X\n",
|
|
|
214d7a |
- Subtable->Type);
|
|
|
214d7a |
+ SubtableType);
|
|
|
214d7a |
|
|
|
214d7a |
/* Attempt to continue */
|
|
|
214d7a |
|
|
|
214d7a |
- if (!Subtable->Length)
|
|
|
214d7a |
+ if (!SubtableLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid zero length subtable\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -1288,8 +1295,8 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
|
|
|
214d7a |
- Subtable->Length, InfoTable);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
|
|
|
214d7a |
+ SubtableLength, InfoTable);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -1297,14 +1304,15 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
|
|
|
214d7a |
/* Per-subtable variable-length fields */
|
|
|
214d7a |
|
|
|
214d7a |
- switch (Subtable->Type)
|
|
|
214d7a |
+ switch (SubtableType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_NFIT_TYPE_INTERLEAVE:
|
|
|
214d7a |
|
|
|
214d7a |
Interleave = ACPI_CAST_PTR (ACPI_NFIT_INTERLEAVE, Subtable);
|
|
|
214d7a |
- for (i = 0; i < Interleave->LineCount; i++)
|
|
|
214d7a |
+ LineCount = AcpiUtReadUint32 (&Interleave->LineCount);
|
|
|
214d7a |
+ for (i = 0; i < LineCount; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + FieldOffset,
|
|
|
214d7a |
&Interleave->LineOffset[i],
|
|
|
214d7a |
sizeof (UINT32), AcpiDmTableInfoNfit2a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -1318,14 +1326,14 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
|
|
|
214d7a |
case ACPI_NFIT_TYPE_SMBIOS:
|
|
|
214d7a |
|
|
|
214d7a |
- Length = Subtable->Length -
|
|
|
214d7a |
+ Length = SubtableLength -
|
|
|
214d7a |
sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8);
|
|
|
214d7a |
|
|
|
214d7a |
if (Length)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength,
|
|
|
214d7a |
sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8),
|
|
|
214d7a |
- SmbiosInfo,
|
|
|
214d7a |
+ SmbiosInfo + Offset,
|
|
|
214d7a |
Length, AcpiDmTableInfoNfit3a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -1338,9 +1346,10 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
|
|
|
214d7a |
|
|
|
214d7a |
Hint = ACPI_CAST_PTR (ACPI_NFIT_FLUSH_ADDRESS, Subtable);
|
|
|
214d7a |
- for (i = 0; i < Hint->HintCount; i++)
|
|
|
214d7a |
+ HintCount = AcpiUtReadUint16 (&Hint->HintCount);
|
|
|
214d7a |
+ for (i = 0; i < HintCount; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + FieldOffset,
|
|
|
214d7a |
&Hint->HintAddress[i],
|
|
|
214d7a |
sizeof (UINT64), AcpiDmTableInfoNfit6a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -1359,8 +1368,8 @@ AcpiDmDumpNfit (
|
|
|
214d7a |
NextSubtable:
|
|
|
214d7a |
/* Point to next subtable */
|
|
|
214d7a |
|
|
|
214d7a |
- Offset += Subtable->Length;
|
|
|
214d7a |
- Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Subtable, Subtable->Length);
|
|
|
214d7a |
+ Offset += SubtableLength;
|
|
|
214d7a |
+ Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Subtable, SubtableLength);
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/compiler/dttable2.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/compiler/dttable2.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/compiler/dttable2.c
|
|
|
214d7a |
@@ -497,6 +497,7 @@ DtCompileNfit (
|
|
|
214d7a |
UINT32 Count;
|
|
|
214d7a |
ACPI_NFIT_INTERLEAVE *Interleave = NULL;
|
|
|
214d7a |
ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
|
|
|
214d7a |
+ UINT16 NfitHeaderType;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Main table */
|
|
|
214d7a |
@@ -530,7 +531,8 @@ DtCompileNfit (
|
|
|
214d7a |
|
|
|
214d7a |
NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
|
|
|
214d7a |
|
|
|
214d7a |
- switch (NfitHeader->Type)
|
|
|
214d7a |
+ NfitHeaderType = AcpiUtReadUint16 (&NfitHeader->Type);
|
|
|
214d7a |
+ switch (NfitHeaderType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -590,7 +592,7 @@ DtCompileNfit (
|
|
|
214d7a |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
214d7a |
DtPopSubtable ();
|
|
|
214d7a |
|
|
|
214d7a |
- switch (NfitHeader->Type)
|
|
|
214d7a |
+ switch (NfitHeaderType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_NFIT_TYPE_INTERLEAVE:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -616,7 +618,8 @@ DtCompileNfit (
|
|
|
214d7a |
Count++;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
- Interleave->LineCount = Count;
|
|
|
214d7a |
+ AcpiUtWriteUint (&Interleave->LineCount, sizeof (UINT32),
|
|
|
214d7a |
+ &Count, sizeof (UINT32));
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
case ACPI_NFIT_TYPE_SMBIOS:
|
|
|
214d7a |
@@ -662,6 +665,8 @@ DtCompileNfit (
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
Hint->HintCount = (UINT16) Count;
|
|
|
214d7a |
+ AcpiUtWriteUint (&Hint->HintCount, sizeof (UINT16),
|
|
|
214d7a |
+ &Count, sizeof (UINT32));
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
default:
|