172 lines
5.9 KiB
Diff
172 lines
5.9 KiB
Diff
|
From 01aad41e59efd615ac075fcedbaab0c60f9e1e11 Mon Sep 17 00:00:00 2001
|
||
|
From: Al Stone <ahs3@redhat.com>
|
||
|
Date: Sat, 19 Sep 2020 15:22:00 -0600
|
||
|
Subject: [PATCH 09/40] 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-20200925/source/common/dmtable.c
|
||
|
===================================================================
|
||
|
--- acpica-unix2-20200925.orig/source/common/dmtable.c
|
||
|
+++ acpica-unix2-20200925/source/common/dmtable.c
|
||
|
@@ -1244,13 +1244,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-20200925/source/common/dmtbdump1.c
|
||
|
===================================================================
|
||
|
--- acpica-unix2-20200925.orig/source/common/dmtbdump1.c
|
||
|
+++ acpica-unix2-20200925/source/common/dmtbdump1.c
|
||
|
@@ -526,13 +526,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 */
|
||
|
@@ -546,13 +548,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;
|
||
|
@@ -560,7 +563,8 @@ AcpiDmDumpDmar (
|
||
|
|
||
|
AcpiOsPrintf ("\n");
|
||
|
|
||
|
- switch (Subtable->Type)
|
||
|
+ SubtableType = AcpiUtReadUint16(&Subtable->Type);
|
||
|
+ switch (SubtableType)
|
||
|
{
|
||
|
case ACPI_DMAR_TYPE_HARDWARE_UNIT:
|
||
|
|
||
|
@@ -595,12 +599,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;
|
||
|
@@ -609,8 +613,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 */
|
||
|
|
||
|
@@ -618,7 +622,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,
|
||
|
@@ -659,9 +663,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-20200925/source/compiler/dttable1.c
|
||
|
===================================================================
|
||
|
--- acpica-unix2-20200925.orig/source/compiler/dttable1.c
|
||
|
+++ acpica-unix2-20200925/source/compiler/dttable1.c
|
||
|
@@ -560,6 +560,7 @@ DtCompileDmar (
|
||
|
ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
|
||
|
UINT32 DeviceScopeLength;
|
||
|
UINT32 PciPathLength;
|
||
|
+ UINT16 DmarHeaderType;
|
||
|
|
||
|
|
||
|
Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
|
||
|
@@ -590,7 +591,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:
|
||
|
|
||
|
@@ -637,8 +639,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 */
|
||
|
|
||
|
@@ -647,8 +649,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,
|