1 From 06623392351dfea54bd69507b6672c933a5e3fd2 Mon Sep 17 00:00:00 2001
2 From: Al Stone <ahs3@redhat.com>
3 Date: Sat, 19 Sep 2020 15:22:00 -0600
4 Subject: [PATCH 12/45] Support DMAR in a big-endian world
6 Signed-off-by: Al Stone <ahs3@redhat.com>
8 source/common/dmtable.c | 4 ++--
9 source/common/dmtbdump1.c | 26 +++++++++++++++-----------
10 source/compiler/dttable1.c | 12 +++++++-----
11 3 files changed, 24 insertions(+), 18 deletions(-)
13 Index: acpica-unix2-20220331/source/common/dmtable.c
14 ===================================================================
15 --- acpica-unix2-20220331.orig/source/common/dmtable.c
16 +++ acpica-unix2-20220331/source/common/dmtable.c
17 @@ -1578,13 +1578,13 @@ AcpiDmDumpTable (
19 /* DMAR subtable types */
21 - Temp16 = ACPI_GET16 (Target);
22 + Temp16 = AcpiUtReadUint16 (Target);
23 if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
25 Temp16 = ACPI_DMAR_TYPE_RESERVED;
28 - AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
29 + AcpiOsPrintf (UINT16_FORMAT, Temp16,
30 AcpiDmDmarSubnames[Temp16]);
33 Index: acpica-unix2-20220331/source/common/dmtbdump1.c
34 ===================================================================
35 --- acpica-unix2-20220331.orig/source/common/dmtbdump1.c
36 +++ acpica-unix2-20220331/source/common/dmtbdump1.c
37 @@ -899,13 +899,15 @@ AcpiDmDumpDmar (
40 ACPI_DMAR_HEADER *Subtable;
41 - UINT32 Length = Table->Length;
42 + UINT32 Length = AcpiUtReadUint32 (&Table->Length);
43 UINT32 Offset = sizeof (ACPI_TABLE_DMAR);
44 ACPI_DMTABLE_INFO *InfoTable;
45 ACPI_DMAR_DEVICE_SCOPE *ScopeTable;
49 + UINT16 SubtableType;
50 + UINT16 SubtableLength;
54 @@ -919,13 +921,14 @@ AcpiDmDumpDmar (
57 Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
58 - while (Offset < Table->Length)
59 + while (Offset < Length)
61 /* Common subtable header */
64 + SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
65 Status = AcpiDmDumpTable (Length, Offset, Subtable,
66 - Subtable->Length, AcpiDmTableInfoDmarHdr);
67 + SubtableLength, AcpiDmTableInfoDmarHdr);
68 if (ACPI_FAILURE (Status))
71 @@ -933,7 +936,8 @@ AcpiDmDumpDmar (
75 - switch (Subtable->Type)
76 + SubtableType = AcpiUtReadUint16 (&Subtable->Type);
77 + switch (SubtableType)
79 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
81 @@ -974,12 +978,12 @@ AcpiDmDumpDmar (
84 AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
90 Status = AcpiDmDumpTable (Length, Offset, Subtable,
91 - Subtable->Length, InfoTable);
92 + SubtableLength, InfoTable);
93 if (ACPI_FAILURE (Status))
96 @@ -988,8 +992,8 @@ AcpiDmDumpDmar (
98 * Dump the optional device scope entries
100 - if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
101 - (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
102 + if ((SubtableType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
103 + (SubtableType == ACPI_DMAR_TYPE_NAMESPACE))
105 /* These types do not support device scopes */
107 @@ -997,7 +1001,7 @@ AcpiDmDumpDmar (
110 ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
111 - while (ScopeOffset < Subtable->Length)
112 + while (ScopeOffset < SubtableLength)
115 Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
116 @@ -1038,9 +1042,9 @@ AcpiDmDumpDmar (
118 /* Point to next subtable */
120 - Offset += Subtable->Length;
121 + Offset += SubtableLength;
122 Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
128 Index: acpica-unix2-20220331/source/compiler/dttable1.c
129 ===================================================================
130 --- acpica-unix2-20220331.orig/source/compiler/dttable1.c
131 +++ acpica-unix2-20220331/source/compiler/dttable1.c
132 @@ -997,6 +997,7 @@ DtCompileDmar (
133 ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
134 UINT32 DeviceScopeLength;
135 UINT32 PciPathLength;
136 + UINT16 DmarHeaderType;
139 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
140 @@ -1027,7 +1028,8 @@ DtCompileDmar (
142 DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer);
144 - switch (DmarHeader->Type)
145 + DmarHeaderType = AcpiUtReadUint16 (&DmarHeader->Type);
146 + switch (DmarHeaderType)
148 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
150 @@ -1079,8 +1081,8 @@ DtCompileDmar (
152 * Optional Device Scope subtables
154 - if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
155 - (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE))
156 + if ((DmarHeaderType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
157 + (DmarHeaderType == ACPI_DMAR_TYPE_NAMESPACE))
159 /* These types do not support device scopes */
161 @@ -1089,8 +1091,8 @@ DtCompileDmar (
164 DtPushSubtable (Subtable);
165 - DeviceScopeLength = DmarHeader->Length - Subtable->Length -
166 - ParentTable->Length;
167 + DeviceScopeLength = AcpiUtReadUint16 (&DmarHeader->Length) -
168 + Subtable->Length - ParentTable->Length;
169 while (DeviceScopeLength)
171 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,