2021-07-12 03:22:10 +00:00
|
|
|
From 915b8b70726fd01befdeac0c8630db528ac40552 Mon Sep 17 00:00:00 2001
|
2020-10-19 18:24:09 +00:00
|
|
|
From: Al Stone <ahs3@redhat.com>
|
|
|
|
Date: Fri, 25 Sep 2020 16:56:55 -0600
|
2021-07-12 03:22:10 +00:00
|
|
|
Subject: [PATCH 28/45] Support HMAT in a big-endian world
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
|
---
|
|
|
|
source/common/dmtbdump1.c | 70 ++++++++++++++++++++++----------------
|
|
|
|
source/compiler/dttable1.c | 24 ++++++++++---
|
|
|
|
2 files changed, 59 insertions(+), 35 deletions(-)
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
Index: acpica-unix2-20210730/source/common/dmtbdump1.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2022-03-10 02:45:13 +00:00
|
|
|
--- acpica-unix2-20210730.orig/source/common/dmtbdump1.c
|
|
|
|
+++ acpica-unix2-20210730/source/common/dmtbdump1.c
|
|
|
|
@@ -1598,37 +1598,45 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
UINT32 Length;
|
|
|
|
ACPI_DMTABLE_INFO *InfoTable;
|
|
|
|
UINT32 i, j;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ UINT16 HmatStructType;
|
|
|
|
+ UINT32 HmatStructLength;
|
|
|
|
+ UINT32 InitPDs;
|
|
|
|
+ UINT32 TgtPDs;
|
|
|
|
+ UINT16 SMBIOSHandles;
|
|
|
|
|
|
|
|
|
|
|
|
/* Main table */
|
|
|
|
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoHmat);
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoHmat);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Offset = sizeof (ACPI_TABLE_HMAT);
|
|
|
|
|
|
|
|
- while (Offset < Table->Length)
|
|
|
|
+ while (Offset < TableLength)
|
|
|
|
{
|
|
|
|
AcpiOsPrintf ("\n");
|
|
|
|
|
|
|
|
/* Dump HMAT structure header */
|
|
|
|
|
|
|
|
HmatStruct = ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, Table, Offset);
|
|
|
|
- if (HmatStruct->Length < sizeof (ACPI_HMAT_STRUCTURE))
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatStructLength = AcpiUtReadUint32 (&HmatStruct->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ if (HmatStructLength < sizeof (ACPI_HMAT_STRUCTURE))
|
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid HMAT structure length\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
|
|
|
|
- HmatStruct->Length, AcpiDmTableInfoHmatHdr);
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
|
|
|
|
+ HmatStructLength, AcpiDmTableInfoHmatHdr);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
- switch (HmatStruct->Type)
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ switch (HmatStructType)
|
|
|
|
{
|
|
|
|
case ACPI_HMAT_TYPE_ADDRESS_RANGE:
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1651,7 +1659,7 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
default:
|
|
|
|
|
|
|
|
AcpiOsPrintf ("\n**** Unknown HMAT structure type 0x%X\n",
|
|
|
|
- HmatStruct->Type);
|
|
|
|
+ HmatStructType);
|
|
|
|
|
|
|
|
/* Attempt to continue */
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1660,13 +1668,13 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump HMAT structure body */
|
|
|
|
|
|
|
|
- if (HmatStruct->Length < Length)
|
|
|
|
+ if (HmatStructLength < Length)
|
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid HMAT structure length\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
|
|
|
|
- HmatStruct->Length, InfoTable);
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
|
|
|
|
+ HmatStructLength, InfoTable);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
|
|
|
return;
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1674,7 +1682,7 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump HMAT structure additionals */
|
|
|
|
|
|
|
|
- switch (HmatStruct->Type)
|
|
|
|
+ switch (HmatStructType)
|
|
|
|
{
|
|
|
|
case ACPI_HMAT_TYPE_LOCALITY:
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1683,15 +1691,16 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump initiator proximity domains */
|
|
|
|
|
|
|
|
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
|
- (UINT32)(HmatLocality->NumberOfInitiatorPDs * 4))
|
2021-07-12 03:22:10 +00:00
|
|
|
+ InitPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfInitiatorPDs);
|
|
|
|
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
|
+ (UINT32) (InitPDs * 4))
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid initiator proximity domain number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
|
|
|
|
+ for (i = 0; i < InitPDs; i++)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
|
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
|
4, AcpiDmTableInfoHmat1a);
|
|
|
|
if (ACPI_FAILURE (Status))
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1704,15 +1713,16 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump target proximity domains */
|
|
|
|
|
|
|
|
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
|
- (UINT32)(HmatLocality->NumberOfTargetPDs * 4))
|
2021-07-12 03:22:10 +00:00
|
|
|
+ TgtPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfTargetPDs);
|
|
|
|
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
|
+ (UINT32) (TgtPDs * 4))
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid target proximity domain number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- for (i = 0; i < HmatLocality->NumberOfTargetPDs; i++)
|
|
|
|
+ for (i = 0; i < TgtPDs; i++)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
|
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
|
4, AcpiDmTableInfoHmat1b);
|
|
|
|
if (ACPI_FAILURE (Status))
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1725,18 +1735,17 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump latency/bandwidth entris */
|
|
|
|
|
|
|
|
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
|
- (UINT32)(HmatLocality->NumberOfInitiatorPDs *
|
|
|
|
- HmatLocality->NumberOfTargetPDs * 2))
|
2021-07-12 03:22:10 +00:00
|
|
|
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
|
+ (UINT32) (InitPDs * TgtPDs * 2))
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid latency/bandwidth entry number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
|
|
|
|
+ for (i = 0; i < InitPDs; i++)
|
|
|
|
{
|
|
|
|
- for (j = 0; j < HmatLocality->NumberOfTargetPDs; j++)
|
|
|
|
+ for (j = 0; j < TgtPDs; j++)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
|
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
|
2, AcpiDmTableInfoHmat1c);
|
|
|
|
if (ACPI_FAILURE(Status))
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1756,15 +1765,16 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Dump SMBIOS handles */
|
|
|
|
|
|
|
|
- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
|
|
|
|
- (UINT32)(HmatCache->NumberOfSMBIOSHandles * 2))
|
2021-07-12 03:22:10 +00:00
|
|
|
+ SMBIOSHandles = AcpiUtReadUint16 (&HmatCache->NumberOfSMBIOSHandles);
|
|
|
|
+ if ((UINT32) (HmatStructLength - SubtableOffset) <
|
|
|
|
+ (UINT32) (SMBIOSHandles * 2))
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
AcpiOsPrintf ("Invalid SMBIOS handle number\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- for (i = 0; i < HmatCache->NumberOfSMBIOSHandles; i++)
|
|
|
|
+ for (i = 0; i < SMBIOSHandles; i++)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
|
|
|
|
ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
|
|
|
|
2, AcpiDmTableInfoHmat2a);
|
|
|
|
if (ACPI_FAILURE (Status))
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1784,6 +1794,6 @@ AcpiDmDumpHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
NextSubtable:
|
|
|
|
/* Point to next HMAT structure subtable */
|
|
|
|
|
|
|
|
- Offset += (HmatStruct->Length);
|
|
|
|
+ Offset += (HmatStructLength);
|
|
|
|
}
|
|
|
|
}
|
2022-03-10 02:45:13 +00:00
|
|
|
Index: acpica-unix2-20210730/source/compiler/dttable1.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2022-03-10 02:45:13 +00:00
|
|
|
--- acpica-unix2-20210730.orig/source/compiler/dttable1.c
|
|
|
|
+++ acpica-unix2-20210730/source/compiler/dttable1.c
|
|
|
|
@@ -1586,6 +1586,8 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
UINT32 TgtPDNumber;
|
|
|
|
UINT64 EntryNumber;
|
|
|
|
UINT16 SMBIOSHandleNumber;
|
|
|
|
+ UINT16 HmatStructType;
|
|
|
|
+ UINT32 Length;
|
|
|
|
|
|
|
|
|
|
|
|
ParentTable = DtPeekSubtable ();
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1616,7 +1618,8 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Compile HMAT structure body */
|
|
|
|
|
|
|
|
- switch (HmatStruct->Type)
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ switch (HmatStructType)
|
|
|
|
{
|
|
|
|
case ACPI_HMAT_TYPE_ADDRESS_RANGE:
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1649,7 +1652,7 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Compile HMAT structure additionals */
|
|
|
|
|
|
|
|
- switch (HmatStruct->Type)
|
|
|
|
+ switch (HmatStructType)
|
|
|
|
{
|
|
|
|
case ACPI_HMAT_TYPE_LOCALITY:
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1675,7 +1678,7 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
HmatStruct->Length += Subtable->Length;
|
|
|
|
IntPDNumber++;
|
|
|
|
}
|
|
|
|
- HmatLocality->NumberOfInitiatorPDs = IntPDNumber;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatLocality->NumberOfInitiatorPDs = AcpiUtReadUint32 (&IntPDNumber);
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Compile target proximity domain list */
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1696,7 +1699,7 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
HmatStruct->Length += Subtable->Length;
|
|
|
|
TgtPDNumber++;
|
|
|
|
}
|
|
|
|
- HmatLocality->NumberOfTargetPDs = TgtPDNumber;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatLocality->NumberOfTargetPDs = AcpiUtReadUint32 (&TgtPDNumber);
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Save start of the entries for reporting errors */
|
|
|
|
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1722,6 +1725,9 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
EntryNumber++;
|
|
|
|
}
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
|
|
|
|
+ HmatStruct->Length = Length;
|
|
|
|
+
|
2020-10-19 18:24:09 +00:00
|
|
|
/* Validate number of entries */
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
if (EntryNumber !=
|
2022-03-10 02:45:13 +00:00
|
|
|
@@ -1755,11 +1761,19 @@ DtCompileHmat (
|
2020-10-19 18:24:09 +00:00
|
|
|
HmatStruct->Length += Subtable->Length;
|
|
|
|
SMBIOSHandleNumber++;
|
|
|
|
}
|
|
|
|
- HmatCache->NumberOfSMBIOSHandles = SMBIOSHandleNumber;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ HmatCache->NumberOfSMBIOSHandles =
|
|
|
|
+ AcpiUtReadUint16 (&SMBIOSHandleNumber);
|
2020-10-19 18:24:09 +00:00
|
|
|
+
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
|
|
|
|
+ HmatStruct->Length = Length;
|
2020-10-19 18:24:09 +00:00
|
|
|
+
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Length = AcpiUtReadUint32(&HmatStruct->Length);
|
|
|
|
+ HmatStruct->Length = Length;
|
2020-10-19 18:24:09 +00:00
|
|
|
+
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|