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-20210730/source/common/dmtable.c
===================================================================
--- acpica-unix2-20210730.orig/source/common/dmtable.c
+++ acpica-unix2-20210730/source/common/dmtable.c
@@ -1487,13 +1487,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-20210730/source/common/dmtbdump1.c
===================================================================
--- acpica-unix2-20210730.orig/source/common/dmtbdump1.c
+++ acpica-unix2-20210730/source/common/dmtbdump1.c
@@ -823,13 +823,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 */
@@ -843,13 +845,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;
@@ -857,7 +860,8 @@ AcpiDmDumpDmar (
AcpiOsPrintf ("\n");
- switch (Subtable->Type)
+ SubtableType = AcpiUtReadUint16 (&Subtable->Type);
+ switch (SubtableType)
{
case ACPI_DMAR_TYPE_HARDWARE_UNIT:
@@ -892,12 +896,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;
@@ -906,8 +910,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 */
@@ -915,7 +919,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,
@@ -956,9 +960,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-20210730/source/compiler/dttable1.c
===================================================================
--- acpica-unix2-20210730.orig/source/compiler/dttable1.c
+++ acpica-unix2-20210730/source/compiler/dttable1.c
@@ -851,6 +851,7 @@ DtCompileDmar (
ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
UINT32 DeviceScopeLength;
UINT32 PciPathLength;
+ UINT16 DmarHeaderType;
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
@@ -881,7 +882,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:
@@ -928,8 +930,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 */
@@ -938,8 +940,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,