]> git.pld-linux.org Git - packages/acpica.git/blame - 0028-Support-HMAT-in-a-big-endian-world.patch
- updated tests
[packages/acpica.git] / 0028-Support-HMAT-in-a-big-endian-world.patch
CommitLineData
b643ab7e
JB
1From 915b8b70726fd01befdeac0c8630db528ac40552 Mon Sep 17 00:00:00 2001
2From: Al Stone <ahs3@redhat.com>
3Date: Fri, 25 Sep 2020 16:56:55 -0600
4Subject: [PATCH 28/45] Support HMAT in a big-endian world
5
6Signed-off-by: Al Stone <ahs3@redhat.com>
7---
8 source/common/dmtbdump1.c | 70 ++++++++++++++++++++++----------------
9 source/compiler/dttable1.c | 24 ++++++++++---
10 2 files changed, 59 insertions(+), 35 deletions(-)
11
12Index: acpica-unix2-20220331/source/common/dmtbdump1.c
13===================================================================
14--- acpica-unix2-20220331.orig/source/common/dmtbdump1.c
15+++ acpica-unix2-20220331/source/common/dmtbdump1.c
16@@ -1680,37 +1680,45 @@ AcpiDmDumpHmat (
17 UINT32 Length;
18 ACPI_DMTABLE_INFO *InfoTable;
19 UINT32 i, j;
20+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
21+ UINT16 HmatStructType;
22+ UINT32 HmatStructLength;
23+ UINT32 InitPDs;
24+ UINT32 TgtPDs;
25+ UINT16 SMBIOSHandles;
26
27
28 /* Main table */
29
30- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoHmat);
31+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoHmat);
32 if (ACPI_FAILURE (Status))
33 {
34 return;
35 }
36 Offset = sizeof (ACPI_TABLE_HMAT);
37
38- while (Offset < Table->Length)
39+ while (Offset < TableLength)
40 {
41 AcpiOsPrintf ("\n");
42
43 /* Dump HMAT structure header */
44
45 HmatStruct = ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, Table, Offset);
46- if (HmatStruct->Length < sizeof (ACPI_HMAT_STRUCTURE))
47+ HmatStructLength = AcpiUtReadUint32 (&HmatStruct->Length);
48+ if (HmatStructLength < sizeof (ACPI_HMAT_STRUCTURE))
49 {
50 AcpiOsPrintf ("Invalid HMAT structure length\n");
51 return;
52 }
53- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
54- HmatStruct->Length, AcpiDmTableInfoHmatHdr);
55+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
56+ HmatStructLength, AcpiDmTableInfoHmatHdr);
57 if (ACPI_FAILURE (Status))
58 {
59 return;
60 }
61
62- switch (HmatStruct->Type)
63+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
64+ switch (HmatStructType)
65 {
66 case ACPI_HMAT_TYPE_ADDRESS_RANGE:
67
68@@ -1733,7 +1741,7 @@ AcpiDmDumpHmat (
69 default:
70
71 AcpiOsPrintf ("\n**** Unknown HMAT structure type 0x%X\n",
72- HmatStruct->Type);
73+ HmatStructType);
74
75 /* Attempt to continue */
76
77@@ -1742,13 +1750,13 @@ AcpiDmDumpHmat (
78
79 /* Dump HMAT structure body */
80
81- if (HmatStruct->Length < Length)
82+ if (HmatStructLength < Length)
83 {
84 AcpiOsPrintf ("Invalid HMAT structure length\n");
85 return;
86 }
87- Status = AcpiDmDumpTable (Table->Length, Offset, HmatStruct,
88- HmatStruct->Length, InfoTable);
89+ Status = AcpiDmDumpTable (TableLength, Offset, HmatStruct,
90+ HmatStructLength, InfoTable);
91 if (ACPI_FAILURE (Status))
92 {
93 return;
94@@ -1756,7 +1764,7 @@ AcpiDmDumpHmat (
95
96 /* Dump HMAT structure additionals */
97
98- switch (HmatStruct->Type)
99+ switch (HmatStructType)
100 {
101 case ACPI_HMAT_TYPE_LOCALITY:
102
103@@ -1765,15 +1773,16 @@ AcpiDmDumpHmat (
104
105 /* Dump initiator proximity domains */
106
107- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
108- (UINT32)(HmatLocality->NumberOfInitiatorPDs * 4))
109+ InitPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfInitiatorPDs);
110+ if ((UINT32) (HmatStructLength - SubtableOffset) <
111+ (UINT32) (InitPDs * 4))
112 {
113 AcpiOsPrintf ("Invalid initiator proximity domain number\n");
114 return;
115 }
116- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
117+ for (i = 0; i < InitPDs; i++)
118 {
119- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
120+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
121 ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
122 4, AcpiDmTableInfoHmat1a);
123 if (ACPI_FAILURE (Status))
124@@ -1786,15 +1795,16 @@ AcpiDmDumpHmat (
125
126 /* Dump target proximity domains */
127
128- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
129- (UINT32)(HmatLocality->NumberOfTargetPDs * 4))
130+ TgtPDs = AcpiUtReadUint32 (&HmatLocality->NumberOfTargetPDs);
131+ if ((UINT32) (HmatStructLength - SubtableOffset) <
132+ (UINT32) (TgtPDs * 4))
133 {
134 AcpiOsPrintf ("Invalid target proximity domain number\n");
135 return;
136 }
137- for (i = 0; i < HmatLocality->NumberOfTargetPDs; i++)
138+ for (i = 0; i < TgtPDs; i++)
139 {
140- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
141+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
142 ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
143 4, AcpiDmTableInfoHmat1b);
144 if (ACPI_FAILURE (Status))
145@@ -1807,18 +1817,17 @@ AcpiDmDumpHmat (
146
147 /* Dump latency/bandwidth entris */
148
149- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
150- (UINT32)(HmatLocality->NumberOfInitiatorPDs *
151- HmatLocality->NumberOfTargetPDs * 2))
152+ if ((UINT32) (HmatStructLength - SubtableOffset) <
153+ (UINT32) (InitPDs * TgtPDs * 2))
154 {
155 AcpiOsPrintf ("Invalid latency/bandwidth entry number\n");
156 return;
157 }
158- for (i = 0; i < HmatLocality->NumberOfInitiatorPDs; i++)
159+ for (i = 0; i < InitPDs; i++)
160 {
161- for (j = 0; j < HmatLocality->NumberOfTargetPDs; j++)
162+ for (j = 0; j < TgtPDs; j++)
163 {
164- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
165+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
166 ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
167 2, AcpiDmTableInfoHmat1c);
168 if (ACPI_FAILURE(Status))
169@@ -1838,15 +1847,16 @@ AcpiDmDumpHmat (
170
171 /* Dump SMBIOS handles */
172
173- if ((UINT32)(HmatStruct->Length - SubtableOffset) <
174- (UINT32)(HmatCache->NumberOfSMBIOSHandles * 2))
175+ SMBIOSHandles = AcpiUtReadUint16 (&HmatCache->NumberOfSMBIOSHandles);
176+ if ((UINT32) (HmatStructLength - SubtableOffset) <
177+ (UINT32) (SMBIOSHandles * 2))
178 {
179 AcpiOsPrintf ("Invalid SMBIOS handle number\n");
180 return;
181 }
182- for (i = 0; i < HmatCache->NumberOfSMBIOSHandles; i++)
183+ for (i = 0; i < SMBIOSHandles; i++)
184 {
185- Status = AcpiDmDumpTable (Table->Length, Offset + SubtableOffset,
186+ Status = AcpiDmDumpTable (TableLength, Offset + SubtableOffset,
187 ACPI_ADD_PTR (ACPI_HMAT_STRUCTURE, HmatStruct, SubtableOffset),
188 2, AcpiDmTableInfoHmat2a);
189 if (ACPI_FAILURE (Status))
190@@ -1866,6 +1876,6 @@ AcpiDmDumpHmat (
191 NextSubtable:
192 /* Point to next HMAT structure subtable */
193
194- Offset += (HmatStruct->Length);
195+ Offset += (HmatStructLength);
196 }
197 }
198Index: acpica-unix2-20220331/source/compiler/dttable1.c
199===================================================================
200--- acpica-unix2-20220331.orig/source/compiler/dttable1.c
201+++ acpica-unix2-20220331/source/compiler/dttable1.c
202@@ -1737,6 +1737,8 @@ DtCompileHmat (
203 UINT32 TgtPDNumber;
204 UINT64 EntryNumber;
205 UINT16 SMBIOSHandleNumber;
206+ UINT16 HmatStructType;
207+ UINT32 Length;
208
209
210 ParentTable = DtPeekSubtable ();
211@@ -1767,7 +1769,8 @@ DtCompileHmat (
212
213 /* Compile HMAT structure body */
214
215- switch (HmatStruct->Type)
216+ HmatStructType = AcpiUtReadUint16 (&HmatStruct->Type);
217+ switch (HmatStructType)
218 {
219 case ACPI_HMAT_TYPE_ADDRESS_RANGE:
220
221@@ -1800,7 +1803,7 @@ DtCompileHmat (
222
223 /* Compile HMAT structure additionals */
224
225- switch (HmatStruct->Type)
226+ switch (HmatStructType)
227 {
228 case ACPI_HMAT_TYPE_LOCALITY:
229
230@@ -1826,7 +1829,7 @@ DtCompileHmat (
231 HmatStruct->Length += Subtable->Length;
232 IntPDNumber++;
233 }
234- HmatLocality->NumberOfInitiatorPDs = IntPDNumber;
235+ HmatLocality->NumberOfInitiatorPDs = AcpiUtReadUint32 (&IntPDNumber);
236
237 /* Compile target proximity domain list */
238
239@@ -1847,7 +1850,7 @@ DtCompileHmat (
240 HmatStruct->Length += Subtable->Length;
241 TgtPDNumber++;
242 }
243- HmatLocality->NumberOfTargetPDs = TgtPDNumber;
244+ HmatLocality->NumberOfTargetPDs = AcpiUtReadUint32 (&TgtPDNumber);
245
246 /* Save start of the entries for reporting errors */
247
248@@ -1873,6 +1876,9 @@ DtCompileHmat (
249 EntryNumber++;
250 }
251
252+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
253+ HmatStruct->Length = Length;
254+
255 /* Validate number of entries */
256
257 if (EntryNumber !=
258@@ -1906,11 +1912,19 @@ DtCompileHmat (
259 HmatStruct->Length += Subtable->Length;
260 SMBIOSHandleNumber++;
261 }
262- HmatCache->NumberOfSMBIOSHandles = SMBIOSHandleNumber;
263+ HmatCache->NumberOfSMBIOSHandles =
264+ AcpiUtReadUint16 (&SMBIOSHandleNumber);
265+
266+ Length = AcpiUtReadUint32 (&HmatStruct->Length);
267+ HmatStruct->Length = Length;
268+
269 break;
270
271 default:
272
273+ Length = AcpiUtReadUint32(&HmatStruct->Length);
274+ HmatStruct->Length = Length;
275+
276 break;
277 }
278 }
This page took 0.0916 seconds and 4 git commands to generate.