|
|
214d7a |
From 915b8b70726fd01befdeac0c8630db528ac40552 Mon Sep 17 00:00:00 2001
|
|
|
214d7a |
From: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
Date: Fri, 25 Sep 2020 16:56:55 -0600
|
|
|
214d7a |
Subject: [PATCH 28/45] Support HMAT in a big-endian world
|
|
|
214d7a |
|
|
|
214d7a |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
---
|
|
|
214d7a |
source/common/dmtbdump1.c | 70 ++++++++++++++++++++++----------------
|
|
|
214d7a |
source/compiler/dttable1.c | 24 ++++++++++---
|
|
|
214d7a |
2 files changed, 59 insertions(+), 35 deletions(-)
|
|
|
214d7a |
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/common/dmtbdump1.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/common/dmtbdump1.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/common/dmtbdump1.c
|
|
|
214d7a |
@@ -1379,37 +1379,45 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
UINT32 Length;
|
|
|
214d7a |
ACPI_DMTABLE_INFO *InfoTable;
|
|
|
214d7a |
UINT32 i, j;
|
|
|
214d7a |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
+ UINT16 HmatStructType;
|
|
|
214d7a |
+ UINT32 HmatStructLength;
|
|
|
214d7a |
+ UINT32 InitPDs;
|
|
|
214d7a |
+ UINT32 TgtPDs;
|
|
|
214d7a |
+ UINT16 SMBIOSHandles;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Main table */
|
|
|
214d7a |
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoHmat);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoHmat);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
Offset = sizeof (ACPI_TABLE_HMAT);
|
|
|
214d7a |
|
|
|
214d7a |
- while (Offset < Table->Length)
|
|
|
214d7a |
+ while (Offset < TableLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump HMAT structure header */
|
|
|
214d7a |
|
|
|
214d7a |
HmatStruct = ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, Table, Offset);
|
|
|
214d7a |
- if (HmatStruct->Length < sizeof (ACPI_HMAT_STRUCTURE))
|
|
|
214d7a |
+ HmatStructLength = AcpiUtReadUint32 (&HmatStruct->Length);
|
|
|
214d7a |
+ if (HmatStructLength < sizeof (ACPI_HMAT_STRUCTURE))
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid HMAT structure length\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
|
|
|
214d7a |
- HmatStruct->Length, AcpiDmTableInfoHmatHdr);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
|
|
|
214d7a |
+ HmatStructLength, AcpiDmTableInfoHmatHdr);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
- switch (HmatStruct->Type)
|
|
|
214d7a |
+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
|
|
|
214d7a |
+ switch (HmatStructType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_HMAT_TYPE_ADDRESS_RANGE:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1432,7 +1440,7 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
default:
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n**** Unknown HMAT structure type 0x%X\n",
|
|
|
214d7a |
- HmatStruct->Type);
|
|
|
214d7a |
+ HmatStructType);
|
|
|
214d7a |
|
|
|
214d7a |
/* Attempt to continue */
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1441,13 +1449,13 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump HMAT structure body */
|
|
|
214d7a |
|
|
|
214d7a |
- if (HmatStruct->Length < Length)
|
|
|
214d7a |
+ if (HmatStructLength < Length)
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid HMAT structure length\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
|
|
|
214d7a |
- HmatStruct->Length, InfoTable);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
|
|
|
214d7a |
+ HmatStructLength, InfoTable);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -1455,7 +1463,7 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump HMAT structure additionals */
|
|
|
214d7a |
|
|
|
214d7a |
- switch (HmatStruct->Type)
|
|
|
214d7a |
+ switch (HmatStructType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_HMAT_TYPE_LOCALITY:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1464,15 +1472,16 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump initiator proximity domains */
|
|
|
214d7a |
|
|
|
214d7a |
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
214d7a |
- (UINT32)(HmatLocality->NumberOfInitiatorPDs * 4))
|
|
|
214d7a |
+ InitPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfInitiatorPDs);
|
|
|
214d7a |
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
214d7a |
+ (UINT32) (InitPDs * 4))
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid initiator proximity domain number\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
|
|
|
214d7a |
+ for (i = 0; i < InitPDs; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
214d7a |
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
214d7a |
4, AcpiDmTableInfoHmat1a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -1485,15 +1494,16 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump target proximity domains */
|
|
|
214d7a |
|
|
|
214d7a |
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
214d7a |
- (UINT32)(HmatLocality->NumberOfTargetPDs * 4))
|
|
|
214d7a |
+ TgtPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfTargetPDs);
|
|
|
214d7a |
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
214d7a |
+ (UINT32) (TgtPDs * 4))
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid target proximity domain number\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- for (i = 0; i < HmatLocality->NumberOfTargetPDs; i++)
|
|
|
214d7a |
+ for (i = 0; i < TgtPDs; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
214d7a |
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
214d7a |
4, AcpiDmTableInfoHmat1b);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -1506,18 +1516,17 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump latency/bandwidth entris */
|
|
|
214d7a |
|
|
|
214d7a |
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
214d7a |
- (UINT32)(HmatLocality->NumberOfInitiatorPDs *
|
|
|
214d7a |
- HmatLocality->NumberOfTargetPDs * 2))
|
|
|
214d7a |
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
214d7a |
+ (UINT32) (InitPDs * TgtPDs * 2))
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid latency/bandwidth entry number\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
|
|
|
214d7a |
+ for (i = 0; i < InitPDs; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- for (j = 0; j < HmatLocality->NumberOfTargetPDs; j++)
|
|
|
214d7a |
+ for (j = 0; j < TgtPDs; j++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
214d7a |
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
214d7a |
2, AcpiDmTableInfoHmat1c);
|
|
|
214d7a |
if (ACPI_FAILURE(Status))
|
|
|
214d7a |
@@ -1537,15 +1546,16 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump SMBIOS handles */
|
|
|
214d7a |
|
|
|
214d7a |
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
214d7a |
- (UINT32)(HmatCache->NumberOfSMBIOSHandles * 2))
|
|
|
214d7a |
+ SMBIOSHandles = AcpiUtReadUint16 (&HmatCache->NumberOfSMBIOSHandles);
|
|
|
214d7a |
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
214d7a |
+ (UINT32) (SMBIOSHandles * 2))
|
|
|
214d7a |
{
|
|
|
214d7a |
AcpiOsPrintf ("Invalid SMBIOS handle number\n");
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
- for (i = 0; i < HmatCache->NumberOfSMBIOSHandles; i++)
|
|
|
214d7a |
+ for (i = 0; i < SMBIOSHandles; i++)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
214d7a |
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
214d7a |
2, AcpiDmTableInfoHmat2a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -1565,6 +1575,6 @@ AcpiDmDumpHmat (
|
|
|
214d7a |
NextSubtable:
|
|
|
214d7a |
/* Point to next HMAT structure subtable */
|
|
|
214d7a |
|
|
|
214d7a |
- Offset += (HmatStruct->Length);
|
|
|
214d7a |
+ Offset += (HmatStructLength);
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|
|
|
214d7a |
Index: acpica-unix2-20210604/source/compiler/dttable1.c
|
|
|
214d7a |
===================================================================
|
|
|
214d7a |
--- acpica-unix2-20210604.orig/source/compiler/dttable1.c
|
|
|
214d7a |
+++ acpica-unix2-20210604/source/compiler/dttable1.c
|
|
|
214d7a |
@@ -1369,6 +1369,8 @@ DtCompileHmat (
|
|
|
214d7a |
UINT32 TgtPDNumber;
|
|
|
214d7a |
UINT64 EntryNumber;
|
|
|
214d7a |
UINT16 SMBIOSHandleNumber;
|
|
|
214d7a |
+ UINT16 HmatStructType;
|
|
|
214d7a |
+ UINT32 Length;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
ParentTable = DtPeekSubtable ();
|
|
|
214d7a |
@@ -1399,7 +1401,8 @@ DtCompileHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Compile HMAT structure body */
|
|
|
214d7a |
|
|
|
214d7a |
- switch (HmatStruct->Type)
|
|
|
214d7a |
+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
|
|
|
214d7a |
+ switch (HmatStructType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_HMAT_TYPE_ADDRESS_RANGE:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1432,7 +1435,7 @@ DtCompileHmat (
|
|
|
214d7a |
|
|
|
214d7a |
/* Compile HMAT structure additionals */
|
|
|
214d7a |
|
|
|
214d7a |
- switch (HmatStruct->Type)
|
|
|
214d7a |
+ switch (HmatStructType)
|
|
|
214d7a |
{
|
|
|
214d7a |
case ACPI_HMAT_TYPE_LOCALITY:
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1458,7 +1461,7 @@ DtCompileHmat (
|
|
|
214d7a |
HmatStruct->Length += Subtable->Length;
|
|
|
214d7a |
IntPDNumber++;
|
|
|
214d7a |
}
|
|
|
214d7a |
- HmatLocality->NumberOfInitiatorPDs = IntPDNumber;
|
|
|
214d7a |
+ HmatLocality->NumberOfInitiatorPDs = AcpiUtReadUint32 (&IntPDNumber);
|
|
|
214d7a |
|
|
|
214d7a |
/* Compile target proximity domain list */
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1479,7 +1482,7 @@ DtCompileHmat (
|
|
|
214d7a |
HmatStruct->Length += Subtable->Length;
|
|
|
214d7a |
TgtPDNumber++;
|
|
|
214d7a |
}
|
|
|
214d7a |
- HmatLocality->NumberOfTargetPDs = TgtPDNumber;
|
|
|
214d7a |
+ HmatLocality->NumberOfTargetPDs = AcpiUtReadUint32 (&TgtPDNumber);
|
|
|
214d7a |
|
|
|
214d7a |
/* Save start of the entries for reporting errors */
|
|
|
214d7a |
|
|
|
214d7a |
@@ -1505,6 +1508,9 @@ DtCompileHmat (
|
|
|
214d7a |
EntryNumber++;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
|
|
|
214d7a |
+ HmatStruct->Length = Length;
|
|
|
214d7a |
+
|
|
|
214d7a |
/* Validate number of entries */
|
|
|
214d7a |
|
|
|
214d7a |
if (EntryNumber !=
|
|
|
214d7a |
@@ -1538,11 +1544,19 @@ DtCompileHmat (
|
|
|
214d7a |
HmatStruct->Length += Subtable->Length;
|
|
|
214d7a |
SMBIOSHandleNumber++;
|
|
|
214d7a |
}
|
|
|
214d7a |
- HmatCache->NumberOfSMBIOSHandles = SMBIOSHandleNumber;
|
|
|
214d7a |
+ HmatCache->NumberOfSMBIOSHandles =
|
|
|
214d7a |
+ AcpiUtReadUint16 (&SMBIOSHandleNumber);
|
|
|
214d7a |
+
|
|
|
214d7a |
+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
|
|
|
214d7a |
+ HmatStruct->Length = Length;
|
|
|
214d7a |
+
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
default:
|
|
|
214d7a |
|
|
|
214d7a |
+ Length = AcpiUtReadUint32(&HmatStruct->Length);
|
|
|
214d7a |
+ HmatStruct->Length = Length;
|
|
|
214d7a |
+
|
|
|
214d7a |
break;
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|