acpica-tools/0012-Support-DMAR-in-a-big-endian-world.patch

172 lines
6.0 KiB
Diff
Raw Normal View History

From 06623392351dfea54bd69507b6672c933a5e3fd2 Mon Sep 17 00:00:00 2001
From: Al Stone <ahs3@redhat.com>
Date: Sat, 19 Sep 2020 15:22:00 -0600
Subject: [PATCH 12/45] Support DMAR in a big-endian world
Signed-off-by: Al Stone <ahs3@redhat.com>
---
source/common/dmtable.c | 4 ++--
source/common/dmtbdump1.c | 26 +++++++++++++++-----------
source/compiler/dttable1.c | 12 +++++++-----
3 files changed, 24 insertions(+), 18 deletions(-)
Index: acpica-unix2-20210604/source/common/dmtable.c
===================================================================
--- acpica-unix2-20210604.orig/source/common/dmtable.c
+++ acpica-unix2-20210604/source/common/dmtable.c
@@ -1341,13 +1341,13 @@ AcpiDmDumpTable (
/* DMAR subtable types */
- Temp16 = ACPI_GET16 (Target);
+ Temp16 = AcpiUtReadUint16 (Target);
if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
{
Temp16 = ACPI_DMAR_TYPE_RESERVED;
}
- AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
+ AcpiOsPrintf (UINT16_FORMAT, Temp16,
AcpiDmDmarSubnames[Temp16]);
break;
Index: acpica-unix2-20210604/source/common/dmtbdump1.c
===================================================================
--- acpica-unix2-20210604.orig/source/common/dmtbdump1.c
+++ acpica-unix2-20210604/source/common/dmtbdump1.c
@@ -604,13 +604,15 @@ AcpiDmDumpDmar (
{
ACPI_STATUS Status;
ACPI_DMAR_HEADER *Subtable;
- UINT32 Length = Table->Length;
+ UINT32 Length = AcpiUtReadUint32 (&Table->Length);
UINT32 Offset = sizeof (ACPI_TABLE_DMAR);
ACPI_DMTABLE_INFO *InfoTable;
ACPI_DMAR_DEVICE_SCOPE *ScopeTable;
UINT32 ScopeOffset;
UINT8 *PciPath;
UINT32 PathOffset;
+ UINT16 SubtableType;
+ UINT16 SubtableLength;
/* Main table */
@@ -624,13 +626,14 @@ AcpiDmDumpDmar (
/* Subtables */
Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
- while (Offset < Table->Length)
+ while (Offset < Length)
{
/* Common subtable header */
AcpiOsPrintf ("\n");
+ SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
Status = AcpiDmDumpTable (Length, Offset, Subtable,
- Subtable->Length, AcpiDmTableInfoDmarHdr);
+ SubtableLength, AcpiDmTableInfoDmarHdr);
if (ACPI_FAILURE (Status))
{
return;
@@ -638,7 +641,8 @@ AcpiDmDumpDmar (
AcpiOsPrintf ("\n");
- switch (Subtable->Type)
+ SubtableType = AcpiUtReadUint16 (&Subtable->Type);
+ switch (SubtableType)
{
case ACPI_DMAR_TYPE_HARDWARE_UNIT:
@@ -673,12 +677,12 @@ AcpiDmDumpDmar (
default:
AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
- Subtable->Type);
+ SubtableType);
return;
}
Status = AcpiDmDumpTable (Length, Offset, Subtable,
- Subtable->Length, InfoTable);
+ SubtableLength, InfoTable);
if (ACPI_FAILURE (Status))
{
return;
@@ -687,8 +691,8 @@ AcpiDmDumpDmar (
/*
* Dump the optional device scope entries
*/
- if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
- (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
+ if ((SubtableType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
+ (SubtableType == ACPI_DMAR_TYPE_NAMESPACE))
{
/* These types do not support device scopes */
@@ -696,7 +700,7 @@ AcpiDmDumpDmar (
}
ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
- while (ScopeOffset < Subtable->Length)
+ while (ScopeOffset < SubtableLength)
{
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
@@ -737,9 +741,9 @@ AcpiDmDumpDmar (
NextSubtable:
/* Point to next subtable */
- Offset += Subtable->Length;
+ Offset += SubtableLength;
Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
- Subtable->Length);
+ SubtableLength);
}
}
Index: acpica-unix2-20210604/source/compiler/dttable1.c
===================================================================
--- acpica-unix2-20210604.orig/source/compiler/dttable1.c
+++ acpica-unix2-20210604/source/compiler/dttable1.c
@@ -634,6 +634,7 @@ DtCompileDmar (
ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
UINT32 DeviceScopeLength;
UINT32 PciPathLength;
+ UINT16 DmarHeaderType;
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
@@ -664,7 +665,8 @@ DtCompileDmar (
DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer);
- switch (DmarHeader->Type)
+ DmarHeaderType = AcpiUtReadUint16 (&DmarHeader->Type);
+ switch (DmarHeaderType)
{
case ACPI_DMAR_TYPE_HARDWARE_UNIT:
@@ -711,8 +713,8 @@ DtCompileDmar (
/*
* Optional Device Scope subtables
*/
- if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
- (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE))
+ if ((DmarHeaderType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
+ (DmarHeaderType == ACPI_DMAR_TYPE_NAMESPACE))
{
/* These types do not support device scopes */
@@ -721,8 +723,8 @@ DtCompileDmar (
}
DtPushSubtable (Subtable);
- DeviceScopeLength = DmarHeader->Length - Subtable->Length -
- ParentTable->Length;
+ DeviceScopeLength = AcpiUtReadUint16 (&DmarHeader->Length) -
+ Subtable->Length - ParentTable->Length;
while (DeviceScopeLength)
{
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,