]> git.pld-linux.org Git - packages/acpica.git/blame - 0041-Support-IORT-in-a-big-endian-world.patch
- added verbose patch not to hide compiler command line, disable stripping on install
[packages/acpica.git] / 0041-Support-IORT-in-a-big-endian-world.patch
CommitLineData
b643ab7e
JB
1From 5bd43bca1708a56d32e63da0278e04caf2865927 Mon Sep 17 00:00:00 2001
2From: Al Stone <ahs3@redhat.com>
3Date: Tue, 29 Jun 2021 17:38:20 -0600
4Subject: [PATCH 41/45] Support IORT in a big-endian world
5
6Signed-off-by: Al Stone <ahs3@redhat.com>
7---
8 source/common/dmtbdump2.c | 85 ++++++++++++++++++++++----------------
9 source/compiler/dttable1.c | 40 ++++++++++--------
10 2 files changed, 72 insertions(+), 53 deletions(-)
11
12Index: acpica-unix2-20220331/source/common/dmtbdump2.c
13===================================================================
14--- acpica-unix2-20220331.orig/source/common/dmtbdump2.c
15+++ acpica-unix2-20220331/source/common/dmtbdump2.c
16@@ -77,17 +77,20 @@ AcpiDmDumpIort (
17 ACPI_IORT_RMR *IortRmr = NULL;
18 UINT32 Offset;
19 UINT32 NodeOffset;
20+ UINT32 NodeLength;
21 UINT32 Length;
22 ACPI_DMTABLE_INFO *InfoTable;
23 char *String;
24 UINT32 i;
25 UINT32 MappingByteLength;
26 UINT8 Revision;
27+ UINT32 MappingCount;
28+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
29
30
31 /* Main table */
32
33- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIort);
34+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoIort);
35 if (ACPI_FAILURE (Status))
36 {
37 return;
38@@ -109,18 +112,19 @@ AcpiDmDumpIort (
39
40 /* Dump the OptionalPadding (optional) */
41
42- if (Iort->NodeOffset > Offset)
43+ NodeOffset = AcpiUtReadUint32 (&Iort->NodeOffset);
44+ if (NodeOffset > Offset)
45 {
46- Status = AcpiDmDumpTable (Table->Length, Offset, Table,
47- Iort->NodeOffset - Offset, AcpiDmTableInfoIortPad);
48+ Status = AcpiDmDumpTable (TableLength, Offset, Table,
49+ NodeOffset - Offset, AcpiDmTableInfoIortPad);
50 if (ACPI_FAILURE (Status))
51 {
52 return;
53 }
54 }
55
56- Offset = Iort->NodeOffset;
57- while (Offset < Table->Length)
58+ Offset = AcpiUtReadUint32 (&Iort->NodeOffset);
59+ while (Offset < TableLength)
60 {
61 /* Common subtable header */
62
63@@ -130,12 +134,12 @@ AcpiDmDumpIort (
64
65 if (Revision == 0)
66 {
67- Status = AcpiDmDumpTable (Table->Length, Offset,
68+ Status = AcpiDmDumpTable (TableLength, Offset,
69 IortNode, Length, AcpiDmTableInfoIortHdr);
70 }
71 else if (Revision >= 3)
72 {
73- Status = AcpiDmDumpTable (Table->Length, Offset,
74+ Status = AcpiDmDumpTable (TableLength, Offset,
75 IortNode, Length, AcpiDmTableInfoIortHdr3);
76 }
77
78@@ -166,7 +170,7 @@ AcpiDmDumpIort (
79 case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
80
81 InfoTable = AcpiDmTableInfoIort2;
82- Length = IortNode->Length - NodeOffset;
83+ Length = AcpiUtReadUint16 (&IortNode->Length) - NodeOffset;
84 break;
85
86 case ACPI_IORT_NODE_SMMU:
87@@ -179,19 +183,19 @@ AcpiDmDumpIort (
88 case ACPI_IORT_NODE_SMMU_V3:
89
90 InfoTable = AcpiDmTableInfoIort4;
91- Length = IortNode->Length - NodeOffset;
92+ Length = AcpiUtReadUint16 (&IortNode->Length) - NodeOffset;
93 break;
94
95 case ACPI_IORT_NODE_PMCG:
96
97 InfoTable = AcpiDmTableInfoIort5;
98- Length = IortNode->Length - NodeOffset;
99+ Length = AcpiUtReadUint16 (&IortNode->Length) - NodeOffset;
100 break;
101
102 case ACPI_IORT_NODE_RMR:
103
104 InfoTable = AcpiDmTableInfoIort6;
105- Length = IortNode->Length - NodeOffset;
106+ Length = AcpiUtReadUint16 (&IortNode->Length) - NodeOffset;
107 IortRmr = ACPI_ADD_PTR (ACPI_IORT_RMR, IortNode, NodeOffset);
108 break;
109
110@@ -202,7 +206,7 @@ AcpiDmDumpIort (
111
112 /* Attempt to continue */
113
114- if (!IortNode->Length)
115+ if (!AcpiUtReadUint16 (&IortNode->Length))
116 {
117 AcpiOsPrintf ("Invalid zero length IORT node\n");
118 return;
119@@ -213,7 +217,7 @@ AcpiDmDumpIort (
120 /* Dump the node subtable header */
121
122 AcpiOsPrintf ("\n");
123- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
124+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
125 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
126 Length, InfoTable);
127 if (ACPI_FAILURE (Status))
128@@ -233,9 +237,10 @@ AcpiDmDumpIort (
129
130 if (IortItsGroup)
131 {
132- for (i = 0; i < IortItsGroup->ItsCount; i++)
133+ UINT32 ItsCount = AcpiUtReadUint32 (&IortItsGroup->ItsCount);
134+ for (i = 0; i < ItsCount; i++)
135 {
136- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
137+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
138 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
139 4, AcpiDmTableInfoIort0a);
140 if (ACPI_FAILURE (Status))
141@@ -252,12 +257,14 @@ AcpiDmDumpIort (
142
143 /* Dump the Padding (optional) */
144
145- if (IortNode->Length > NodeOffset)
146+ NodeLength = AcpiUtReadUint16 (&IortNode->Length);
147+ if (NodeLength > NodeOffset)
148 {
149 MappingByteLength =
150- IortNode->MappingCount * sizeof (ACPI_IORT_ID_MAPPING);
151- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
152- Table, IortNode->Length - NodeOffset - MappingByteLength,
153+ AcpiUtReadUint32 (&IortNode->MappingCount) *
154+ sizeof (ACPI_IORT_ID_MAPPING);
155+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
156+ Table, NodeLength - NodeOffset - MappingByteLength,
157 AcpiDmTableInfoIort1a);
158 if (ACPI_FAILURE (Status))
159 {
160@@ -274,9 +281,11 @@ AcpiDmDumpIort (
161
162 if (IortSmmu)
163 {
164+ UINT32 InterruptCount;
165+
166 Length = 2 * sizeof (UINT64);
167- NodeOffset = IortSmmu->GlobalInterruptOffset;
168- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
169+ NodeOffset = AcpiUtReadUint32 (&IortSmmu->GlobalInterruptOffset);
170+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
171 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
172 Length, AcpiDmTableInfoIort3a);
173 if (ACPI_FAILURE (Status))
174@@ -284,10 +293,11 @@ AcpiDmDumpIort (
175 return;
176 }
177
178- NodeOffset = IortSmmu->ContextInterruptOffset;
179- for (i = 0; i < IortSmmu->ContextInterruptCount; i++)
180+ NodeOffset = AcpiUtReadUint32 (&IortSmmu->ContextInterruptOffset);
181+ InterruptCount = AcpiUtReadUint32 (&IortSmmu->ContextInterruptCount);
182+ for (i = 0; i < InterruptCount; i++)
183 {
184- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
185+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
186 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
187 8, AcpiDmTableInfoIort3b);
188 if (ACPI_FAILURE (Status))
189@@ -298,10 +308,11 @@ AcpiDmDumpIort (
190 NodeOffset += 8;
191 }
192
193- NodeOffset = IortSmmu->PmuInterruptOffset;
194- for (i = 0; i < IortSmmu->PmuInterruptCount; i++)
195+ NodeOffset = AcpiUtReadUint32 (&IortSmmu->PmuInterruptOffset);
196+ InterruptCount = AcpiUtReadUint32 (&IortSmmu->PmuInterruptCount);
197+ for (i = 0; i < InterruptCount; i++)
198 {
199- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
200+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
201 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
202 8, AcpiDmTableInfoIort3c);
203 if (ACPI_FAILURE (Status))
204@@ -319,12 +330,15 @@ AcpiDmDumpIort (
205 /* Validate IortRmr to avoid compiler warnings */
206 if (IortRmr)
207 {
208- NodeOffset = IortRmr->RmrOffset;
209+ UINT32 RmrCount;
210+
211+ NodeOffset = AcpiUtReadUint32 (&IortRmr->RmrOffset);
212+ RmrCount = AcpiUtReadUint32 (&IortRmr->RmrCount);
213 Length = sizeof (ACPI_IORT_RMR_DESC);
214- for (i = 0; i < IortRmr->RmrCount; i++)
215+ for (i = 0; i < RmrCount; i++)
216 {
217 AcpiOsPrintf ("\n");
218- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
219+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
220 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
221 Length, AcpiDmTableInfoIort6a);
222 if (ACPI_FAILURE (Status))
223@@ -344,12 +358,13 @@ AcpiDmDumpIort (
224
225 /* Dump the ID mappings */
226
227- NodeOffset = IortNode->MappingOffset;
228- for (i = 0; i < IortNode->MappingCount; i++)
229+ NodeOffset = AcpiUtReadUint32 (&IortNode->MappingOffset);
230+ MappingCount = AcpiUtReadUint32 (&IortNode->MappingCount);
231+ for (i = 0; i < MappingCount; i++)
232 {
233 AcpiOsPrintf ("\n");
234 Length = sizeof (ACPI_IORT_ID_MAPPING);
235- Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
236+ Status = AcpiDmDumpTable (TableLength, Offset + NodeOffset,
237 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
238 Length, AcpiDmTableInfoIortMap);
239 if (ACPI_FAILURE (Status))
240@@ -363,7 +378,7 @@ AcpiDmDumpIort (
241 NextSubtable:
242 /* Point to next node subtable */
243
244- Offset += IortNode->Length;
245+ Offset += AcpiUtReadUint16 (&IortNode->Length);
246 }
247 }
248
249Index: acpica-unix2-20220331/source/compiler/dttable1.c
250===================================================================
251--- acpica-unix2-20220331.orig/source/compiler/dttable1.c
252+++ acpica-unix2-20220331/source/compiler/dttable1.c
253@@ -1960,6 +1960,7 @@ DtCompileIort (
254 ACPI_IORT_ITS_GROUP *IortItsGroup;
255 ACPI_IORT_SMMU *IortSmmu;
256 ACPI_IORT_RMR *IortRmr;
257+ UINT32 IortNodeOffset;
258 UINT32 NodeNumber;
259 UINT32 NodeLength;
260 UINT32 IdMappingNumber;
261@@ -2005,7 +2006,7 @@ DtCompileIort (
262 * Optionally allows the generic data types to be used for filling
263 * this field.
264 */
265- Iort->NodeOffset = sizeof (ACPI_TABLE_IORT);
266+ IortNodeOffset = sizeof (ACPI_TABLE_IORT);
267 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad,
268 &Subtable);
269 if (ACPI_FAILURE (Status))
270@@ -2015,7 +2016,7 @@ DtCompileIort (
271 if (Subtable)
272 {
273 DtInsertSubtable (ParentTable, Subtable);
274- Iort->NodeOffset += Subtable->Length;
275+ IortNodeOffset += Subtable->Length;
276 }
277 else
278 {
279@@ -2025,7 +2026,7 @@ DtCompileIort (
280 {
281 return (Status);
282 }
283- Iort->NodeOffset += PaddingLength;
284+ IortNodeOffset += PaddingLength;
285 }
286
287 NodeNumber = 0;
288@@ -2089,7 +2090,7 @@ DtCompileIort (
289 ItsNumber++;
290 }
291
292- IortItsGroup->ItsCount = ItsNumber;
293+ IortItsGroup->ItsCount = AcpiUtReadUint32 (&ItsNumber);
294 break;
295
296 case ACPI_IORT_NODE_NAMED_COMPONENT:
297@@ -2123,15 +2124,18 @@ DtCompileIort (
298 }
299 else
300 {
301- if (NodeLength > IortNode->MappingOffset)
302+ UINT32 MappingOffset;
303+
304+ MappingOffset = IortNode->MappingOffset;
305+ if (NodeLength > MappingOffset)
306 {
307 return (AE_BAD_DATA);
308 }
309
310- if (NodeLength < IortNode->MappingOffset)
311+ if (NodeLength < MappingOffset)
312 {
313 Status = DtCompilePadding (
314- IortNode->MappingOffset - NodeLength,
315+ MappingOffset - NodeLength,
316 &Subtable);
317 if (ACPI_FAILURE (Status))
318 {
319@@ -2139,7 +2143,7 @@ DtCompileIort (
320 }
321
322 DtInsertSubtable (ParentTable, Subtable);
323- NodeLength = IortNode->MappingOffset;
324+ NodeLength = MappingOffset;
325 }
326 }
327 break;
328@@ -2172,7 +2176,7 @@ DtCompileIort (
329
330 /* Compile global interrupt array */
331
332- IortSmmu->GlobalInterruptOffset = NodeLength;
333+ IortSmmu->GlobalInterruptOffset = AcpiUtReadUint32 (&NodeLength);
334 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a,
335 &Subtable);
336 if (ACPI_FAILURE (Status))
337@@ -2186,7 +2190,7 @@ DtCompileIort (
338 /* Compile context interrupt array */
339
340 ContextIrptNumber = 0;
341- IortSmmu->ContextInterruptOffset = NodeLength;
342+ IortSmmu->ContextInterruptOffset = AcpiUtReadUint32 (&NodeLength);
343 while (*PFieldList)
344 {
345 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b,
346@@ -2206,12 +2210,12 @@ DtCompileIort (
347 ContextIrptNumber++;
348 }
349
350- IortSmmu->ContextInterruptCount = ContextIrptNumber;
351+ IortSmmu->ContextInterruptCount = AcpiUtReadUint32 (&ContextIrptNumber);
352
353 /* Compile PMU interrupt array */
354
355 PmuIrptNumber = 0;
356- IortSmmu->PmuInterruptOffset = NodeLength;
357+ IortSmmu->PmuInterruptOffset = AcpiUtReadUint32 (&NodeLength);
358 while (*PFieldList)
359 {
360 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c,
361@@ -2231,7 +2235,7 @@ DtCompileIort (
362 PmuIrptNumber++;
363 }
364
365- IortSmmu->PmuInterruptCount = PmuIrptNumber;
366+ IortSmmu->PmuInterruptCount = AcpiUtReadUint32 (&PmuIrptNumber);
367 break;
368
369 case ACPI_IORT_NODE_SMMU_V3:
370@@ -2276,7 +2280,7 @@ DtCompileIort (
371 /* Compile RMR Descriptors */
372
373 RmrCount = 0;
374- IortRmr->RmrOffset = NodeLength;
375+ IortRmr->RmrOffset = AcpiUtReadUint32 (&NodeLength);
376 while (*PFieldList)
377 {
378 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort6a,
379@@ -2296,7 +2300,7 @@ DtCompileIort (
380 RmrCount++;
381 }
382
383- IortRmr->RmrCount = RmrCount;
384+ IortRmr->RmrCount = AcpiUtReadUint32 (&RmrCount);
385 break;
386
387 default:
388@@ -2307,7 +2311,7 @@ DtCompileIort (
389
390 /* Compile Array of ID mappings */
391
392- IortNode->MappingOffset = NodeLength;
393+ IortNode->MappingOffset = AcpiUtReadUint32 (&NodeLength);
394 IdMappingNumber = 0;
395 while (*PFieldList)
396 {
397@@ -2328,7 +2332,7 @@ DtCompileIort (
398 IdMappingNumber++;
399 }
400
401- IortNode->MappingCount = IdMappingNumber;
402+ IortNode->MappingCount = AcpiUtReadUint32 (&IdMappingNumber);
403 if (!IdMappingNumber)
404 {
405 IortNode->MappingOffset = 0;
406@@ -2343,7 +2347,7 @@ DtCompileIort (
407 NodeNumber++;
408 }
409
410- Iort->NodeCount = NodeNumber;
411+ Iort->NodeCount = AcpiUtReadUint32 (&NodeNumber);
412 return (AE_OK);
413 }
414
This page took 0.12161 seconds and 4 git commands to generate.