3 This is a combined patch that folds all of the past and present changes
4 for big-endian support into a single patch, hopefully eliminating any sort
5 of redundancy but also capturing all such changes in a single location.
7 To date, this has been critical for the s390x architecture only.
9 Signed-off-by: Al Stone <ahs3@redhat.com>
12 source/compiler/aslcodegen.c | 109 ++++++++++++++++++------------
13 source/compiler/aslopcodes.c | 4 +
14 source/compiler/aslrestype1.c | 68 +++++++++++++------
15 source/compiler/aslrestype1i.c | 38 +++++++---
16 source/compiler/aslrestype2.c | 25 ++++---
17 source/compiler/aslrestype2d.c | 134 +++++++++++++++++++++----------------
18 source/compiler/aslrestype2e.c | 39 +++++++----
19 source/compiler/aslrestype2q.c | 117 +++++++++++++++++++++-----------
20 source/compiler/aslrestype2s.c | 86 +++++++++++++++++-------
21 source/compiler/aslrestype2w.c | 127 +++++++++++++++++++++--------------
22 source/include/acmacros.h | 15 +++-
23 source/include/platform/aclinux.h | 8 ++
24 12 files changed, 487 insertions(+), 283 deletions(-)
26 Index: acpica-unix2-20181003/source/compiler/aslcodegen.c
27 ===================================================================
28 --- acpica-unix2-20181003.orig/source/compiler/aslcodegen.c
29 +++ acpica-unix2-20181003/source/compiler/aslcodegen.c
30 @@ -240,16 +240,12 @@ CgWriteAmlOpcode (
31 ACPI_PARSE_OBJECT *Op)
33 UINT8 PkgLenFirstByte;
37 - UINT8 OpcodeBytes[2];
51 /* We expect some DEFAULT_ARGs, just ignore them */
53 @@ -282,51 +278,52 @@ CgWriteAmlOpcode (
55 /* Special opcodes for within a field definition */
57 - Aml.Opcode = AML_FIELD_OFFSET_OP;
58 + AmlOpcode = AML_FIELD_OFFSET_OP;
61 case AML_INT_ACCESSFIELD_OP:
63 - Aml.Opcode = AML_FIELD_ACCESS_OP;
64 + AmlOpcode = AML_FIELD_ACCESS_OP;
67 case AML_INT_CONNECTION_OP:
69 - Aml.Opcode = AML_FIELD_CONNECTION_OP;
70 + AmlOpcode = AML_FIELD_CONNECTION_OP;
75 - Aml.Opcode = Op->Asl.AmlOpcode;
76 + AmlOpcode = Op->Asl.AmlOpcode;
84 case AML_PACKAGE_LENGTH:
86 /* Value is the length to be encoded (Used in field definitions) */
88 - PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
89 + PkgLen = (UINT32) Op->Asl.Value.Integer;
94 /* Check for two-byte opcode */
96 - if (Aml.Opcode > 0x00FF)
97 + if (AmlOpcode > 0x00FF)
99 /* Write the high byte first */
101 - CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
102 + Byte = ACPI_HIBYTE(AmlOpcode);
103 + CgLocalWriteAmlData (Op, &Byte, 1);
106 - CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
107 + Byte = ACPI_LOBYTE(AmlOpcode);
108 + CgLocalWriteAmlData (Op, &Byte, 1);
110 /* Subtreelength doesn't include length of package length bytes */
112 - PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
113 + PkgLen = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
117 @@ -337,8 +334,8 @@ CgWriteAmlOpcode (
118 if (Op->Asl.AmlPkgLenBytes == 1)
120 /* Simplest case -- no bytes to follow, just write the count */
122 - CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
123 + Byte = ACPI_LOBYTE(PkgLen);
124 + CgLocalWriteAmlData (Op, &Byte, 1);
126 else if (Op->Asl.AmlPkgLenBytes != 0)
128 @@ -348,7 +345,7 @@ CgWriteAmlOpcode (
130 PkgLenFirstByte = (UINT8)
131 (((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
132 - (PkgLen.LenBytes[0] & 0x0F));
135 CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
137 @@ -356,39 +353,47 @@ CgWriteAmlOpcode (
138 * Shift the length over by the 4 bits we just stuffed
145 * Now we can write the remaining bytes -
146 * either 1, 2, or 3 bytes
148 - for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
149 + Byte = ACPI_LOBYTE(PkgLen);
150 + CgLocalWriteAmlData (Op, &Byte, 1);
151 + if (Op->Asl.AmlPkgLenBytes >= 3)
153 + Byte = ACPI_HIBYTE(PkgLen);
154 + CgLocalWriteAmlData (Op, &Byte, 1);
156 + if (Op->Asl.AmlPkgLenBytes >= 4)
158 - CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
159 + Byte = ACPI_LOBYTE(ACPI_HIWORD(PkgLen));
160 + CgLocalWriteAmlData (Op, &Byte, 1);
165 - switch (Aml.Opcode)
170 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
171 + Byte = (UINT8) Op->Asl.Value.Integer;
172 + CgLocalWriteAmlData (Op, &Byte, 1);
177 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
178 + ACPI_MOVE_64_TO_16(&Word, &Op->Asl.Value.Integer);
179 + CgLocalWriteAmlData (Op, &Word, 2);
184 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
185 + ACPI_MOVE_64_TO_32(&DWord, &Op->Asl.Value.Integer);
186 + CgLocalWriteAmlData (Op, &DWord, 4);
191 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
192 + ACPI_MOVE_64_TO_64(&QWord, &Op->Asl.Value.Integer);
193 + CgLocalWriteAmlData (Op, &QWord, 8);
197 @@ -422,6 +427,7 @@ CgWriteTableHeader (
198 ACPI_PARSE_OBJECT *Op)
200 ACPI_PARSE_OBJECT *Child;
202 UINT32 CommentLength;
203 ACPI_COMMENT_NODE *Current;
205 @@ -475,7 +481,7 @@ CgWriteTableHeader (
208 Child = Child->Asl.Next;
209 - AslGbl_TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
210 + ACPI_MOVE_64_TO_32(&AslGbl_TableHeader.OemRevision, &Child->Asl.Value.Integer);
214 @@ -483,12 +489,13 @@ CgWriteTableHeader (
216 /* Compiler version */
218 - AslGbl_TableHeader.AslCompilerRevision = ACPI_CA_VERSION;
219 + DWord = ACPI_CA_VERSION;
220 + ACPI_MOVE_32_TO_32(&AslGbl_TableHeader.AslCompilerRevision, &DWord);
222 /* Table length. Checksum zero for now, will rewrite later */
224 - AslGbl_TableHeader.Length = sizeof (ACPI_TABLE_HEADER) +
225 - Op->Asl.AmlSubtreeLength;
226 + DWord = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
227 + ACPI_MOVE_32_TO_32(&AslGbl_TableHeader.Length, &DWord);
229 /* Calculate the comment lengths for this definition block parseOp */
231 @@ -646,7 +653,10 @@ CgWriteNode (
232 ACPI_PARSE_OBJECT *Op)
234 ASL_RESOURCE_NODE *Rnode;
241 /* Write all comments here. */
243 @@ -676,13 +686,24 @@ CgWriteNode (
244 switch (Op->Asl.AmlOpcode)
246 case AML_RAW_DATA_BYTE:
247 + Byte = (UINT8) Op->Asl.Value.Integer;
248 + CgLocalWriteAmlData (Op, &Byte, 1);
251 case AML_RAW_DATA_WORD:
252 - case AML_RAW_DATA_DWORD:
253 - case AML_RAW_DATA_QWORD:
254 + ACPI_MOVE_64_TO_16(&Word, &Op->Asl.Value.Integer);
255 + CgLocalWriteAmlData (Op, &Word, 2);
258 - CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
259 + case AML_RAW_DATA_DWORD:
260 + ACPI_MOVE_64_TO_32(&DWord, &Op->Asl.Value.Integer);
261 + CgLocalWriteAmlData (Op, &DWord, 4);
264 + case AML_RAW_DATA_QWORD:
265 + ACPI_MOVE_64_TO_64(&QWord, &Op->Asl.Value.Integer);
266 + CgLocalWriteAmlData (Op, &QWord, 8);
269 case AML_RAW_DATA_BUFFER:
271 Index: acpica-unix2-20181003/source/compiler/aslopcodes.c
272 ===================================================================
273 --- acpica-unix2-20181003.orig/source/compiler/aslopcodes.c
274 +++ acpica-unix2-20181003/source/compiler/aslopcodes.c
275 @@ -485,6 +485,7 @@ OpcDoUnicode (
278 UINT16 *UnicodeString;
280 ACPI_PARSE_OBJECT *BufferLengthOp;
283 @@ -511,7 +512,8 @@ OpcDoUnicode (
285 for (i = 0; i < Count; i++)
287 - UnicodeString[i] = (UINT16) AsciiString[i];
288 + UChar = (UINT16) AsciiString[i];
289 + ACPI_MOVE_16_TO_16(&UnicodeString[i], &UChar);
293 Index: acpica-unix2-20181003/source/compiler/aslrestype1.c
294 ===================================================================
295 --- acpica-unix2-20181003.orig/source/compiler/aslrestype1.c
296 +++ acpica-unix2-20181003/source/compiler/aslrestype1.c
297 @@ -142,6 +142,11 @@ RsDoMemory24Descriptor (
298 ACPI_PARSE_OBJECT *LengthOp = NULL;
299 ASL_RESOURCE_NODE *Rnode;
300 UINT32 CurrentByteOffset;
301 + UINT16 Minimum = 0;
302 + UINT16 Maximum = 0;
303 + UINT16 AddressLength = 0;
304 + UINT16 Alignment = 0;
305 + UINT16 ResourceLength;
309 @@ -151,7 +156,8 @@ RsDoMemory24Descriptor (
311 Descriptor = Rnode->Buffer;
312 Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
313 - Descriptor->Memory24.ResourceLength = 9;
314 + ResourceLength = 9;
315 + ACPI_MOVE_16_TO_16(&Descriptor->Memory24.ResourceLength, &ResourceLength);
317 /* Process all child initialization nodes */
319 @@ -168,7 +174,7 @@ RsDoMemory24Descriptor (
321 case 1: /* Min Address */
323 - Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
324 + Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
325 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
326 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
327 MinOp = InitializerOp;
328 @@ -176,7 +182,7 @@ RsDoMemory24Descriptor (
330 case 2: /* Max Address */
332 - Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
333 + Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
334 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
335 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
336 MaxOp = InitializerOp;
337 @@ -184,14 +190,14 @@ RsDoMemory24Descriptor (
339 case 3: /* Alignment */
341 - Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
342 + Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
343 RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
344 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
349 - Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
350 + AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
351 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
352 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
353 LengthOp = InitializerOp;
354 @@ -214,12 +220,17 @@ RsDoMemory24Descriptor (
355 /* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
357 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
358 - Descriptor->Memory24.Minimum,
359 - Descriptor->Memory24.Maximum,
360 - Descriptor->Memory24.AddressLength,
361 - Descriptor->Memory24.Alignment,
366 MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
368 + ACPI_MOVE_16_TO_16(&Descriptor->Memory24.Minimum, &Minimum);
369 + ACPI_MOVE_16_TO_16(&Descriptor->Memory24.Maximum, &Maximum);
370 + ACPI_MOVE_16_TO_16(&Descriptor->Memory24.AddressLength, &AddressLength);
371 + ACPI_MOVE_16_TO_16(&Descriptor->Memory24.Alignment, &Alignment);
376 @@ -248,6 +259,11 @@ RsDoMemory32Descriptor (
377 ACPI_PARSE_OBJECT *AlignOp = NULL;
378 ASL_RESOURCE_NODE *Rnode;
379 UINT32 CurrentByteOffset;
380 + UINT32 Minimum = 0;
381 + UINT32 Maximum = 0;
382 + UINT32 AddressLength = 0;
383 + UINT32 Alignment = 0;
384 + UINT16 ResourceLength;
388 @@ -257,7 +273,8 @@ RsDoMemory32Descriptor (
390 Descriptor = Rnode->Buffer;
391 Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
392 - Descriptor->Memory32.ResourceLength = 17;
393 + ResourceLength = 17;
394 + ACPI_MOVE_16_TO_16(&Descriptor->Memory32.ResourceLength, &ResourceLength);
396 /* Process all child initialization nodes */
398 @@ -274,7 +291,7 @@ RsDoMemory32Descriptor (
400 case 1: /* Min Address */
402 - Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
403 + Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
404 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
405 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
406 MinOp = InitializerOp;
407 @@ -282,7 +299,7 @@ RsDoMemory32Descriptor (
409 case 2: /* Max Address */
411 - Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
412 + Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
413 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
414 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
415 MaxOp = InitializerOp;
416 @@ -290,7 +307,7 @@ RsDoMemory32Descriptor (
418 case 3: /* Alignment */
420 - Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
421 + Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
422 RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
423 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
424 AlignOp = InitializerOp;
425 @@ -298,7 +315,7 @@ RsDoMemory32Descriptor (
429 - Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
430 + AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
431 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
432 CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
433 LengthOp = InitializerOp;
434 @@ -321,12 +338,17 @@ RsDoMemory32Descriptor (
435 /* Validate the Min/Max/Len/Align values */
437 RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
438 - Descriptor->Memory32.Minimum,
439 - Descriptor->Memory32.Maximum,
440 - Descriptor->Memory32.AddressLength,
441 - Descriptor->Memory32.Alignment,
446 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
448 + ACPI_MOVE_32_TO_32(&Descriptor->Memory32.Minimum, &Minimum);
449 + ACPI_MOVE_32_TO_32(&Descriptor->Memory32.Maximum, &Maximum);
450 + ACPI_MOVE_32_TO_32(&Descriptor->Memory32.AddressLength, &AddressLength);
451 + ACPI_MOVE_32_TO_32(&Descriptor->Memory32.Alignment, &Alignment);
456 @@ -351,6 +373,7 @@ RsDoMemory32FixedDescriptor (
457 ACPI_PARSE_OBJECT *InitializerOp;
458 ASL_RESOURCE_NODE *Rnode;
459 UINT32 CurrentByteOffset;
460 + UINT16 ResourceLength;
464 @@ -360,7 +383,8 @@ RsDoMemory32FixedDescriptor (
466 Descriptor = Rnode->Buffer;
467 Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
468 - Descriptor->FixedMemory32.ResourceLength = 9;
469 + ResourceLength = 9;
470 + ACPI_MOVE_16_TO_16(&Descriptor->FixedMemory32.ResourceLength, &ResourceLength);
472 /* Process all child initialization nodes */
474 @@ -377,14 +401,16 @@ RsDoMemory32FixedDescriptor (
476 case 1: /* Address */
478 - Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
479 + ACPI_MOVE_64_TO_32(&Descriptor->FixedMemory32.Address,
480 + &InitializerOp->Asl.Value.Integer);
481 RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
482 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
487 - Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
488 + ACPI_MOVE_64_TO_32(&Descriptor->FixedMemory32.AddressLength,
489 + &InitializerOp->Asl.Value.Integer);
490 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
491 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
493 Index: acpica-unix2-20181003/source/compiler/aslrestype1i.c
494 ===================================================================
495 --- acpica-unix2-20181003.orig/source/compiler/aslrestype1i.c
496 +++ acpica-unix2-20181003/source/compiler/aslrestype1i.c
497 @@ -198,6 +198,8 @@ RsDoFixedDmaDescriptor (
498 ACPI_PARSE_OBJECT *InitializerOp;
499 ASL_RESOURCE_NODE *Rnode;
500 UINT32 CurrentByteOffset;
501 + UINT16 RequestLines = 0;
502 + UINT16 Channels = 0;
506 @@ -217,14 +219,14 @@ RsDoFixedDmaDescriptor (
508 case 0: /* DMA Request Lines [WORD] (_DMA) */
510 - Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
511 + RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
512 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
513 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
516 case 1: /* DMA Channel [WORD] (_TYP) */
518 - Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
519 + Channels = (UINT16) InitializerOp->Asl.Value.Integer;
520 RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
521 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
523 @@ -249,6 +251,9 @@ RsDoFixedDmaDescriptor (
524 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
527 + ACPI_MOVE_16_TO_16(&Descriptor->FixedDma.RequestLines, &RequestLines);
528 + ACPI_MOVE_16_TO_16(&Descriptor->FixedDma.Channels, &Channels);
533 @@ -274,6 +279,7 @@ RsDoFixedIoDescriptor (
534 ACPI_PARSE_OBJECT *AddressOp = NULL;
535 ASL_RESOURCE_NODE *Rnode;
536 UINT32 CurrentByteOffset;
537 + UINT16 Address = 0;
541 @@ -293,8 +299,7 @@ RsDoFixedIoDescriptor (
543 case 0: /* Base Address */
545 - Descriptor->FixedIo.Address =
546 - (UINT16) InitializerOp->Asl.Value.Integer;
547 + Address = (UINT16) InitializerOp->Asl.Value.Integer;
548 RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
549 CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
550 AddressOp = InitializerOp;
551 @@ -324,11 +329,13 @@ RsDoFixedIoDescriptor (
555 - if (Descriptor->FixedIo.Address > 0x03FF)
556 + if (Address > 0x03FF)
558 AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
561 + ACPI_MOVE_16_TO_16(&Descriptor->FixedIo.Address, &Address);
566 @@ -357,6 +364,8 @@ RsDoIoDescriptor (
567 ACPI_PARSE_OBJECT *AlignOp = NULL;
568 ASL_RESOURCE_NODE *Rnode;
569 UINT32 CurrentByteOffset;
570 + UINT16 Minimum = 0;
571 + UINT16 Maximum = 0;
575 @@ -383,8 +392,7 @@ RsDoIoDescriptor (
577 case 1: /* Min Address */
579 - Descriptor->Io.Minimum =
580 - (UINT16) InitializerOp->Asl.Value.Integer;
581 + Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
582 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
583 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
584 MinOp = InitializerOp;
585 @@ -392,8 +400,7 @@ RsDoIoDescriptor (
587 case 2: /* Max Address */
589 - Descriptor->Io.Maximum =
590 - (UINT16) InitializerOp->Asl.Value.Integer;
591 + Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
592 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
593 CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
594 MaxOp = InitializerOp;
595 @@ -434,12 +441,15 @@ RsDoIoDescriptor (
596 /* Validate the Min/Max/Len/Align values */
598 RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
599 - Descriptor->Io.Minimum,
600 - Descriptor->Io.Maximum,
603 Descriptor->Io.AddressLength,
604 Descriptor->Io.Alignment,
605 MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
607 + ACPI_MOVE_16_TO_16(&Descriptor->Io.Minimum, &Minimum);
608 + ACPI_MOVE_16_TO_16(&Descriptor->Io.Maximum, &Maximum);
613 @@ -559,9 +569,9 @@ RsDoIrqDescriptor (
614 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
617 - /* Now we can set the channel mask */
618 + /* Now we can set the interrupt mask */
620 - Descriptor->Irq.IrqMask = IrqMask;
621 + ACPI_MOVE_16_TO_16(&Descriptor->Irq.IrqMask, &IrqMask);
625 @@ -660,6 +670,6 @@ RsDoIrqNoFlagsDescriptor (
627 /* Now we can set the interrupt mask */
629 - Descriptor->Irq.IrqMask = IrqMask;
630 + ACPI_MOVE_16_TO_16(&Descriptor->Irq.IrqMask, &IrqMask);
633 Index: acpica-unix2-20181003/source/compiler/aslrestype2.c
634 ===================================================================
635 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2.c
636 +++ acpica-unix2-20181003/source/compiler/aslrestype2.c
637 @@ -76,6 +76,7 @@ RsDoGeneralRegisterDescriptor (
638 ACPI_PARSE_OBJECT *InitializerOp;
639 ASL_RESOURCE_NODE *Rnode;
640 UINT32 CurrentByteOffset;
641 + UINT16 ResourceLength;
645 @@ -85,7 +86,9 @@ RsDoGeneralRegisterDescriptor (
647 Descriptor = Rnode->Buffer;
648 Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
649 - Descriptor->GenericReg.ResourceLength = 12;
650 + ResourceLength = 12;
651 + ACPI_MOVE_16_TO_16(&Descriptor->GenericReg.ResourceLength,
654 /* Process all child initialization nodes */
656 @@ -95,35 +98,52 @@ RsDoGeneralRegisterDescriptor (
658 case 0: /* Address space */
661 Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer;
663 + ACPI_MOVE_64_TO_8(&Descriptor->GenericReg.AddressSpaceId,
664 + &InitializerOp->Asl.Value.Integer);
665 RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE,
666 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId));
669 case 1: /* Register Bit Width */
672 Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer;
674 + ACPI_MOVE_64_TO_8(&Descriptor->GenericReg.BitWidth,
675 + &InitializerOp->Asl.Value.Integer);
676 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH,
677 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth));
680 case 2: /* Register Bit Offset */
683 Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer;
685 + ACPI_MOVE_64_TO_8(&Descriptor->GenericReg.BitOffset,
686 + &InitializerOp->Asl.Value.Integer);
687 RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET,
688 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset));
691 case 3: /* Register Address */
693 - Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
694 + ACPI_MOVE_64_TO_64(&Descriptor->GenericReg.Address,
695 + &InitializerOp->Asl.Value.Integer);
696 RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
697 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
700 case 4: /* Access Size (ACPI 3.0) */
703 Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer;
705 + ACPI_MOVE_64_TO_8(&Descriptor->GenericReg.AccessSize,
706 + &InitializerOp->Asl.Value.Integer);
707 RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE,
708 CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize));
710 @@ -177,6 +197,7 @@ RsDoInterruptDescriptor (
711 AML_RESOURCE *Rover = NULL;
712 ACPI_PARSE_OBJECT *InitializerOp;
713 ASL_RESOURCE_NODE *Rnode;
714 + UINT16 ResourceLength = 0;
715 UINT16 StringLength = 0;
716 UINT32 OptionIndex = 0;
717 UINT32 CurrentByteOffset;
718 @@ -225,7 +246,7 @@ RsDoInterruptDescriptor (
719 * Initial descriptor length -- may be enlarged if there are
720 * optional fields present
722 - Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
723 + ResourceLength = 2; /* Flags and table length byte */
724 Descriptor->ExtendedIrq.InterruptCount = 0;
726 Rover = ACPI_CAST_PTR (AML_RESOURCE,
727 @@ -333,10 +354,11 @@ RsDoInterruptDescriptor (
729 /* Save the integer and move pointer to the next one */
731 - Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
732 + ACPI_MOVE_64_TO_32(&Rover->DwordItem,
733 + &InitializerOp->Asl.Value.Integer);
734 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
735 Descriptor->ExtendedIrq.InterruptCount++;
736 - Descriptor->ExtendedIrq.ResourceLength += 4;
737 + ResourceLength += 4;
739 /* Case 7: First interrupt number in list */
741 @@ -372,7 +394,7 @@ RsDoInterruptDescriptor (
743 Rover->ByteItem = ResSourceIndex;
744 Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->ByteItem), 1);
745 - Descriptor->ExtendedIrq.ResourceLength += 1;
746 + ResourceLength += 1;
749 /* Add optional ResSource string if present */
750 @@ -384,14 +406,15 @@ RsDoInterruptDescriptor (
751 Rover = ACPI_ADD_PTR (
752 AML_RESOURCE, &(Rover->ByteItem), StringLength);
754 - Descriptor->ExtendedIrq.ResourceLength = (UINT16)
755 - (Descriptor->ExtendedIrq.ResourceLength + StringLength);
756 + ResourceLength = (UINT16) (ResourceLength + StringLength);
759 Rnode->BufferLength =
760 (ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
761 ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType))
762 + OptionIndex + StringLength;
763 + ACPI_MOVE_16_TO_16(&Descriptor->ExtendedIrq.ResourceLength,
768 @@ -439,7 +462,7 @@ RsDoVendorLargeDescriptor (
770 Descriptor = Rnode->Buffer;
771 Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
772 - Descriptor->VendorLarge.ResourceLength = (UINT16) i;
773 + ACPI_MOVE_32_TO_16(&Descriptor->VendorLarge.ResourceLength, &i);
775 /* Point to end-of-descriptor for vendor data */
777 Index: acpica-unix2-20181003/source/compiler/aslrestype2d.c
778 ===================================================================
779 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2d.c
780 +++ acpica-unix2-20181003/source/compiler/aslrestype2d.c
781 @@ -79,7 +79,13 @@ RsDoDwordIoDescriptor (
782 ACPI_PARSE_OBJECT *GranOp = NULL;
783 ASL_RESOURCE_NODE *Rnode;
784 UINT16 StringLength = 0;
785 + UINT16 ResourceLength = 0;
786 UINT32 OptionIndex = 0;
787 + UINT32 Minimum = 0;
788 + UINT32 Maximum = 0;
789 + UINT32 AddressLength = 0;
790 + UINT32 Granularity = 0;
791 + UINT32 TranslationOffset = 0;
792 UINT8 *OptionalFields;
793 UINT32 CurrentByteOffset;
795 @@ -102,8 +108,7 @@ RsDoDwordIoDescriptor (
796 * optional fields present
798 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
799 - Descriptor->Address32.ResourceLength = (UINT16)
800 - (sizeof (AML_RESOURCE_ADDRESS32) -
801 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS32) -
802 sizeof (AML_RESOURCE_LARGE_HEADER));
804 /* Process all child initialization nodes */
805 @@ -147,8 +152,7 @@ RsDoDwordIoDescriptor (
807 case 5: /* Address Granularity */
809 - Descriptor->Address32.Granularity =
810 - (UINT32) InitializerOp->Asl.Value.Integer;
811 + Granularity = (UINT32) InitializerOp->Asl.Value.Integer;
812 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
813 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
814 GranOp = InitializerOp;
815 @@ -156,8 +160,7 @@ RsDoDwordIoDescriptor (
817 case 6: /* Address Min */
819 - Descriptor->Address32.Minimum =
820 - (UINT32) InitializerOp->Asl.Value.Integer;
821 + Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
822 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
823 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
824 MinOp = InitializerOp;
825 @@ -165,8 +168,7 @@ RsDoDwordIoDescriptor (
827 case 7: /* Address Max */
829 - Descriptor->Address32.Maximum =
830 - (UINT32) InitializerOp->Asl.Value.Integer;
831 + Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
832 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
833 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
834 MaxOp = InitializerOp;
835 @@ -174,16 +176,14 @@ RsDoDwordIoDescriptor (
837 case 8: /* Translation Offset */
839 - Descriptor->Address32.TranslationOffset =
840 - (UINT32) InitializerOp->Asl.Value.Integer;
841 + TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer;
842 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
843 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
846 case 9: /* Address Length */
848 - Descriptor->Address32.AddressLength =
849 - (UINT32) InitializerOp->Asl.Value.Integer;
850 + AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
851 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
852 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
853 LengthOp = InitializerOp;
854 @@ -197,7 +197,7 @@ RsDoDwordIoDescriptor (
856 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
858 - Descriptor->Address32.ResourceLength++;
860 ResSourceIndex = TRUE;
863 @@ -211,8 +211,7 @@ RsDoDwordIoDescriptor (
865 /* Found a valid ResourceSource */
867 - Descriptor->Address32.ResourceLength = (UINT16)
868 - (Descriptor->Address32.ResourceLength + StringLength);
869 + ResourceLength = (UINT16) (ResourceLength + StringLength);
872 &OptionalFields[OptionIndex],
873 @@ -272,13 +271,20 @@ RsDoDwordIoDescriptor (
874 /* Validate the Min/Max/Len/Gran values */
876 RsLargeAddressCheck (
877 - (UINT64) Descriptor->Address32.Minimum,
878 - (UINT64) Descriptor->Address32.Maximum,
879 - (UINT64) Descriptor->Address32.AddressLength,
880 - (UINT64) Descriptor->Address32.Granularity,
885 Descriptor->Address32.Flags,
886 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
888 + ACPI_MOVE_16_TO_16(&Descriptor->Address32.ResourceLength, &ResourceLength);
889 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Minimum, &Minimum);
890 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Maximum, &Maximum);
891 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.AddressLength, &AddressLength);
892 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Granularity, &Granularity);
893 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.TranslationOffset, &TranslationOffset);
895 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
896 OptionIndex + StringLength;
898 @@ -310,7 +316,13 @@ RsDoDwordMemoryDescriptor (
899 ASL_RESOURCE_NODE *Rnode;
900 UINT8 *OptionalFields;
901 UINT16 StringLength = 0;
902 + UINT16 ResourceLength = 0;
903 UINT32 OptionIndex = 0;
904 + UINT32 Minimum = 0;
905 + UINT32 Maximum = 0;
906 + UINT32 AddressLength = 0;
907 + UINT32 Granularity = 0;
908 + UINT32 TranslationOffset = 0;
909 UINT32 CurrentByteOffset;
911 BOOLEAN ResSourceIndex = FALSE;
912 @@ -332,11 +344,9 @@ RsDoDwordMemoryDescriptor (
913 * optional fields present
915 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
916 - Descriptor->Address32.ResourceLength = (UINT16)
917 - (sizeof (AML_RESOURCE_ADDRESS32) -
918 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS32) -
919 sizeof (AML_RESOURCE_LARGE_HEADER));
922 /* Process all child initialization nodes */
924 for (i = 0; InitializerOp; i++)
925 @@ -385,8 +395,7 @@ RsDoDwordMemoryDescriptor (
927 case 6: /* Address Granularity */
929 - Descriptor->Address32.Granularity =
930 - (UINT32) InitializerOp->Asl.Value.Integer;
931 + Granularity = (UINT32) InitializerOp->Asl.Value.Integer;
932 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
933 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
934 GranOp = InitializerOp;
935 @@ -394,8 +403,7 @@ RsDoDwordMemoryDescriptor (
937 case 7: /* Min Address */
939 - Descriptor->Address32.Minimum =
940 - (UINT32) InitializerOp->Asl.Value.Integer;
941 + Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
942 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
943 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
944 MinOp = InitializerOp;
945 @@ -403,8 +411,7 @@ RsDoDwordMemoryDescriptor (
947 case 8: /* Max Address */
949 - Descriptor->Address32.Maximum =
950 - (UINT32) InitializerOp->Asl.Value.Integer;
951 + Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
952 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
953 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
954 MaxOp = InitializerOp;
955 @@ -412,16 +419,14 @@ RsDoDwordMemoryDescriptor (
957 case 9: /* Translation Offset */
959 - Descriptor->Address32.TranslationOffset =
960 - (UINT32) InitializerOp->Asl.Value.Integer;
961 + TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer;
962 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
963 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
966 case 10: /* Address Length */
968 - Descriptor->Address32.AddressLength =
969 - (UINT32) InitializerOp->Asl.Value.Integer;
970 + AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
971 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
972 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
973 LengthOp = InitializerOp;
974 @@ -433,7 +438,7 @@ RsDoDwordMemoryDescriptor (
976 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
978 - Descriptor->Address32.ResourceLength++;
980 ResSourceIndex = TRUE;
983 @@ -445,8 +450,8 @@ RsDoDwordMemoryDescriptor (
987 - Descriptor->Address32.ResourceLength = (UINT16)
988 - (Descriptor->Address32.ResourceLength + StringLength);
990 + ResourceLength = (UINT16) (ResourceLength + StringLength);
993 &OptionalFields[OptionIndex],
994 @@ -507,13 +512,20 @@ RsDoDwordMemoryDescriptor (
995 /* Validate the Min/Max/Len/Gran values */
997 RsLargeAddressCheck (
998 - (UINT64) Descriptor->Address32.Minimum,
999 - (UINT64) Descriptor->Address32.Maximum,
1000 - (UINT64) Descriptor->Address32.AddressLength,
1001 - (UINT64) Descriptor->Address32.Granularity,
1006 Descriptor->Address32.Flags,
1007 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1009 + ACPI_MOVE_16_TO_16(&Descriptor->Address32.ResourceLength, &ResourceLength);
1010 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Minimum, &Minimum);
1011 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Maximum, &Maximum);
1012 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.AddressLength, &AddressLength);
1013 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Granularity, &Granularity);
1014 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.TranslationOffset, &TranslationOffset);
1016 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
1017 OptionIndex + StringLength;
1019 @@ -545,7 +557,13 @@ RsDoDwordSpaceDescriptor (
1020 ASL_RESOURCE_NODE *Rnode;
1021 UINT8 *OptionalFields;
1022 UINT16 StringLength = 0;
1023 + UINT16 ResourceLength = 0;
1024 UINT32 OptionIndex = 0;
1025 + UINT32 Minimum = 0;
1026 + UINT32 Maximum = 0;
1027 + UINT32 AddressLength = 0;
1028 + UINT32 Granularity = 0;
1029 + UINT32 TranslationOffset = 0;
1030 UINT32 CurrentByteOffset;
1032 BOOLEAN ResSourceIndex = FALSE;
1033 @@ -566,8 +584,7 @@ RsDoDwordSpaceDescriptor (
1034 * optional fields present
1036 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
1037 - Descriptor->Address32.ResourceLength = (UINT16)
1038 - (sizeof (AML_RESOURCE_ADDRESS32) -
1039 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS32) -
1040 sizeof (AML_RESOURCE_LARGE_HEADER));
1042 /* Process all child initialization nodes */
1043 @@ -616,8 +633,7 @@ RsDoDwordSpaceDescriptor (
1045 case 6: /* Address Granularity */
1047 - Descriptor->Address32.Granularity =
1048 - (UINT32) InitializerOp->Asl.Value.Integer;
1049 + Granularity = (UINT32) InitializerOp->Asl.Value.Integer;
1050 RsCreateDwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1051 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Granularity));
1052 GranOp = InitializerOp;
1053 @@ -625,8 +641,7 @@ RsDoDwordSpaceDescriptor (
1055 case 7: /* Min Address */
1057 - Descriptor->Address32.Minimum =
1058 - (UINT32) InitializerOp->Asl.Value.Integer;
1059 + Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
1060 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1061 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Minimum));
1062 MinOp = InitializerOp;
1063 @@ -634,8 +649,7 @@ RsDoDwordSpaceDescriptor (
1065 case 8: /* Max Address */
1067 - Descriptor->Address32.Maximum =
1068 - (UINT32) InitializerOp->Asl.Value.Integer;
1069 + Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
1070 RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1071 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.Maximum));
1072 MaxOp = InitializerOp;
1073 @@ -643,16 +657,14 @@ RsDoDwordSpaceDescriptor (
1075 case 9: /* Translation Offset */
1077 - Descriptor->Address32.TranslationOffset =
1078 - (UINT32) InitializerOp->Asl.Value.Integer;
1079 + TranslationOffset = (UINT32) InitializerOp->Asl.Value.Integer;
1080 RsCreateDwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1081 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.TranslationOffset));
1084 case 10: /* Address Length */
1086 - Descriptor->Address32.AddressLength =
1087 - (UINT32) InitializerOp->Asl.Value.Integer;
1088 + AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
1089 RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1090 CurrentByteOffset + ASL_RESDESC_OFFSET (Address32.AddressLength));
1091 LengthOp = InitializerOp;
1092 @@ -664,7 +676,7 @@ RsDoDwordSpaceDescriptor (
1094 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
1096 - Descriptor->Address32.ResourceLength++;
1098 ResSourceIndex = TRUE;
1101 @@ -676,8 +688,7 @@ RsDoDwordSpaceDescriptor (
1105 - Descriptor->Address32.ResourceLength = (UINT16)
1106 - (Descriptor->Address32.ResourceLength + StringLength);
1107 + ResourceLength = (UINT16) (ResourceLength + StringLength);
1110 &OptionalFields[OptionIndex],
1111 @@ -724,13 +735,20 @@ RsDoDwordSpaceDescriptor (
1112 /* Validate the Min/Max/Len/Gran values */
1114 RsLargeAddressCheck (
1115 - (UINT64) Descriptor->Address32.Minimum,
1116 - (UINT64) Descriptor->Address32.Maximum,
1117 - (UINT64) Descriptor->Address32.AddressLength,
1118 - (UINT64) Descriptor->Address32.Granularity,
1123 Descriptor->Address32.Flags,
1124 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1126 + ACPI_MOVE_16_TO_16(&Descriptor->Address32.ResourceLength, &ResourceLength);
1127 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Minimum, &Minimum);
1128 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Maximum, &Maximum);
1129 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.AddressLength, &AddressLength);
1130 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.Granularity, &Granularity);
1131 + ACPI_MOVE_32_TO_32(&Descriptor->Address32.TranslationOffset, &TranslationOffset);
1133 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
1134 OptionIndex + StringLength;
1136 Index: acpica-unix2-20181003/source/compiler/aslrestype2e.c
1137 ===================================================================
1138 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2e.c
1139 +++ acpica-unix2-20181003/source/compiler/aslrestype2e.c
1140 @@ -78,6 +78,13 @@ RsDoExtendedIoDescriptor (
1141 ACPI_PARSE_OBJECT *GranOp = NULL;
1142 ASL_RESOURCE_NODE *Rnode;
1143 UINT16 StringLength = 0;
1144 + UINT16 ResourceLength = 0;
1145 + UINT64 Minimum = 0;
1146 + UINT64 Maximum = 0;
1147 + UINT64 AddressLength = 0;
1148 + UINT64 Granularity = 0;
1149 + UINT64 TranslationOffset = 0;
1150 + UINT64 TypeSpecific = 0;
1151 UINT32 CurrentByteOffset;
1154 @@ -94,9 +101,10 @@ RsDoExtendedIoDescriptor (
1155 Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
1156 Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
1158 - Descriptor->ExtAddress64.ResourceLength = (UINT16)
1159 - (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) -
1160 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) -
1161 sizeof (AML_RESOURCE_LARGE_HEADER));
1162 + ACPI_MOVE_16_TO_16(&Descriptor->ExtAddress64.ResourceLength,
1165 /* Process all child initialization nodes */
1167 @@ -139,7 +147,7 @@ RsDoExtendedIoDescriptor (
1169 case 5: /* Address Granularity */
1171 - Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
1172 + Granularity = InitializerOp->Asl.Value.Integer;
1173 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1174 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
1175 GranOp = InitializerOp;
1176 @@ -147,7 +155,7 @@ RsDoExtendedIoDescriptor (
1178 case 6: /* Address Min */
1180 - Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
1181 + Minimum = InitializerOp->Asl.Value.Integer;
1182 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1183 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
1184 MinOp = InitializerOp;
1185 @@ -155,7 +163,7 @@ RsDoExtendedIoDescriptor (
1187 case 7: /* Address Max */
1189 - Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
1190 + Maximum = InitializerOp->Asl.Value.Integer;
1191 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1192 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
1193 MaxOp = InitializerOp;
1194 @@ -163,14 +171,14 @@ RsDoExtendedIoDescriptor (
1196 case 8: /* Translation Offset */
1198 - Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1199 + TranslationOffset = InitializerOp->Asl.Value.Integer;
1200 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1201 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
1204 case 9: /* Address Length */
1206 - Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
1207 + AddressLength = InitializerOp->Asl.Value.Integer;
1208 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1209 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
1210 LengthOp = InitializerOp;
1211 @@ -178,7 +186,7 @@ RsDoExtendedIoDescriptor (
1213 case 10: /* Type-Specific Attributes */
1215 - Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
1216 + TypeSpecific = InitializerOp->Asl.Value.Integer;
1217 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
1218 CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
1220 @@ -214,13 +222,20 @@ RsDoExtendedIoDescriptor (
1221 /* Validate the Min/Max/Len/Gran values */
1223 RsLargeAddressCheck (
1224 - Descriptor->ExtAddress64.Minimum,
1225 - Descriptor->ExtAddress64.Maximum,
1226 - Descriptor->ExtAddress64.AddressLength,
1227 - Descriptor->ExtAddress64.Granularity,
1232 Descriptor->ExtAddress64.Flags,
1233 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1235 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.Minimum, &Minimum);
1236 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.Maximum, &Maximum);
1237 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.AddressLength, &AddressLength);
1238 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.Granularity, &Granularity);
1239 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.TranslationOffset, &TranslationOffset);
1240 + ACPI_MOVE_64_TO_64(&Descriptor->ExtAddress64.TypeSpecific, &TypeSpecific);
1242 Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) +
1245 Index: acpica-unix2-20181003/source/compiler/aslrestype2q.c
1246 ===================================================================
1247 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2q.c
1248 +++ acpica-unix2-20181003/source/compiler/aslrestype2q.c
1249 @@ -80,7 +80,13 @@ RsDoQwordIoDescriptor (
1250 ASL_RESOURCE_NODE *Rnode;
1251 UINT8 *OptionalFields;
1252 UINT16 StringLength = 0;
1253 + UINT16 ResourceLength = 0;
1254 UINT32 OptionIndex = 0;
1255 + UINT64 Minimum = 0;
1256 + UINT64 Maximum = 0;
1257 + UINT64 AddressLength = 0;
1258 + UINT64 Granularity = 0;
1259 + UINT64 TranslationOffset = 0;
1260 UINT32 CurrentByteOffset;
1262 BOOLEAN ResSourceIndex = FALSE;
1263 @@ -102,8 +108,7 @@ RsDoQwordIoDescriptor (
1264 * optional fields present
1266 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
1267 - Descriptor->Address64.ResourceLength = (UINT16)
1268 - (sizeof (AML_RESOURCE_ADDRESS64) -
1269 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS64) -
1270 sizeof (AML_RESOURCE_LARGE_HEADER));
1272 /* Process all child initialization nodes */
1273 @@ -147,7 +152,7 @@ RsDoQwordIoDescriptor (
1275 case 5: /* Address Granularity */
1277 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1278 + Granularity = InitializerOp->Asl.Value.Integer;
1279 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1280 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1281 GranOp = InitializerOp;
1282 @@ -155,7 +160,7 @@ RsDoQwordIoDescriptor (
1284 case 6: /* Address Min */
1286 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1287 + Minimum = InitializerOp->Asl.Value.Integer;
1288 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1289 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1290 MinOp = InitializerOp;
1291 @@ -163,7 +168,7 @@ RsDoQwordIoDescriptor (
1293 case 7: /* Address Max */
1295 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1296 + Maximum = InitializerOp->Asl.Value.Integer;
1297 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1298 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1299 MaxOp = InitializerOp;
1300 @@ -171,14 +176,14 @@ RsDoQwordIoDescriptor (
1302 case 8: /* Translation Offset */
1304 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1305 + TranslationOffset = InitializerOp->Asl.Value.Integer;
1306 RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1307 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1310 case 9: /* Address Length */
1312 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1313 + AddressLength = InitializerOp->Asl.Value.Integer;
1314 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1315 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1316 LengthOp = InitializerOp;
1317 @@ -190,7 +195,7 @@ RsDoQwordIoDescriptor (
1319 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
1321 - Descriptor->Address64.ResourceLength++;
1323 ResSourceIndex = TRUE;
1326 @@ -202,8 +207,7 @@ RsDoQwordIoDescriptor (
1330 - Descriptor->Address64.ResourceLength = (UINT16)
1331 - (Descriptor->Address64.ResourceLength + StringLength);
1332 + ResourceLength = (UINT16) (ResourceLength + StringLength);
1335 &OptionalFields[OptionIndex],
1336 @@ -263,13 +267,20 @@ RsDoQwordIoDescriptor (
1337 /* Validate the Min/Max/Len/Gran values */
1339 RsLargeAddressCheck (
1340 - Descriptor->Address64.Minimum,
1341 - Descriptor->Address64.Maximum,
1342 - Descriptor->Address64.AddressLength,
1343 - Descriptor->Address64.Granularity,
1348 Descriptor->Address64.Flags,
1349 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1351 + ACPI_MOVE_16_TO_16(&Descriptor->Address64.ResourceLength, &ResourceLength);
1352 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Minimum, &Minimum);
1353 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Maximum, &Maximum);
1354 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.AddressLength, &AddressLength);
1355 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Granularity, &Granularity);
1356 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.TranslationOffset, &TranslationOffset);
1358 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
1359 OptionIndex + StringLength;
1361 @@ -301,7 +312,13 @@ RsDoQwordMemoryDescriptor (
1362 ASL_RESOURCE_NODE *Rnode;
1363 UINT8 *OptionalFields;
1364 UINT16 StringLength = 0;
1365 + UINT16 ResourceLength = 0;
1366 UINT32 OptionIndex = 0;
1367 + UINT64 Minimum = 0;
1368 + UINT64 Maximum = 0;
1369 + UINT64 AddressLength = 0;
1370 + UINT64 Granularity = 0;
1371 + UINT64 TranslationOffset = 0;
1372 UINT32 CurrentByteOffset;
1374 BOOLEAN ResSourceIndex = FALSE;
1375 @@ -323,8 +340,7 @@ RsDoQwordMemoryDescriptor (
1376 * optional fields present
1378 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
1379 - Descriptor->Address64.ResourceLength = (UINT16)
1380 - (sizeof (AML_RESOURCE_ADDRESS64) -
1381 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS64) -
1382 sizeof (AML_RESOURCE_LARGE_HEADER));
1384 /* Process all child initialization nodes */
1385 @@ -375,7 +391,7 @@ RsDoQwordMemoryDescriptor (
1387 case 6: /* Address Granularity */
1389 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1390 + Granularity = InitializerOp->Asl.Value.Integer;
1391 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1392 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1393 GranOp = InitializerOp;
1394 @@ -383,7 +399,7 @@ RsDoQwordMemoryDescriptor (
1396 case 7: /* Min Address */
1398 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1399 + Minimum = InitializerOp->Asl.Value.Integer;
1400 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1401 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1402 MinOp = InitializerOp;
1403 @@ -391,7 +407,7 @@ RsDoQwordMemoryDescriptor (
1405 case 8: /* Max Address */
1407 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1408 + Maximum = InitializerOp->Asl.Value.Integer;
1409 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1410 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1411 MaxOp = InitializerOp;
1412 @@ -399,14 +415,14 @@ RsDoQwordMemoryDescriptor (
1414 case 9: /* Translation Offset */
1416 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1417 + TranslationOffset = InitializerOp->Asl.Value.Integer;
1418 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1419 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1422 case 10: /* Address Length */
1424 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1425 + AddressLength = InitializerOp->Asl.Value.Integer;
1426 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1427 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1428 LengthOp = InitializerOp;
1429 @@ -418,7 +434,7 @@ RsDoQwordMemoryDescriptor (
1431 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
1433 - Descriptor->Address64.ResourceLength++;
1435 ResSourceIndex = TRUE;
1438 @@ -430,8 +446,7 @@ RsDoQwordMemoryDescriptor (
1442 - Descriptor->Address64.ResourceLength = (UINT16)
1443 - (Descriptor->Address64.ResourceLength + StringLength);
1444 + ResourceLength = (UINT16) (ResourceLength + StringLength);
1447 &OptionalFields[OptionIndex],
1448 @@ -492,13 +507,20 @@ RsDoQwordMemoryDescriptor (
1449 /* Validate the Min/Max/Len/Gran values */
1451 RsLargeAddressCheck (
1452 - Descriptor->Address64.Minimum,
1453 - Descriptor->Address64.Maximum,
1454 - Descriptor->Address64.AddressLength,
1455 - Descriptor->Address64.Granularity,
1460 Descriptor->Address64.Flags,
1461 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1463 + ACPI_MOVE_16_TO_16(&Descriptor->Address64.ResourceLength, &ResourceLength);
1464 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Minimum, &Minimum);
1465 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Maximum, &Maximum);
1466 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.AddressLength, &AddressLength);
1467 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Granularity, &Granularity);
1468 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.TranslationOffset, &TranslationOffset);
1470 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
1471 OptionIndex + StringLength;
1473 @@ -530,9 +552,15 @@ RsDoQwordSpaceDescriptor (
1474 ASL_RESOURCE_NODE *Rnode;
1475 UINT8 *OptionalFields;
1476 UINT16 StringLength = 0;
1477 + UINT16 ResourceLength = 0;
1478 UINT32 OptionIndex = 0;
1479 UINT32 CurrentByteOffset;
1481 + UINT64 Minimum = 0;
1482 + UINT64 Maximum = 0;
1483 + UINT64 AddressLength = 0;
1484 + UINT64 Granularity = 0;
1485 + UINT64 TranslationOffset = 0;
1486 BOOLEAN ResSourceIndex = FALSE;
1489 @@ -551,8 +579,7 @@ RsDoQwordSpaceDescriptor (
1490 * optional fields present
1492 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
1493 - Descriptor->Address64.ResourceLength = (UINT16)
1494 - (sizeof (AML_RESOURCE_ADDRESS64) -
1495 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS64) -
1496 sizeof (AML_RESOURCE_LARGE_HEADER));
1498 /* Process all child initialization nodes */
1499 @@ -601,7 +628,7 @@ RsDoQwordSpaceDescriptor (
1501 case 6: /* Address Granularity */
1503 - Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
1504 + Granularity = InitializerOp->Asl.Value.Integer;
1505 RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
1506 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
1507 GranOp = InitializerOp;
1508 @@ -609,7 +636,7 @@ RsDoQwordSpaceDescriptor (
1510 case 7: /* Min Address */
1512 - Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
1513 + Minimum = InitializerOp->Asl.Value.Integer;
1514 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
1515 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
1516 MinOp = InitializerOp;
1517 @@ -617,7 +644,7 @@ RsDoQwordSpaceDescriptor (
1519 case 8: /* Max Address */
1521 - Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
1522 + Maximum = InitializerOp->Asl.Value.Integer;
1523 RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
1524 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
1525 MaxOp = InitializerOp;
1526 @@ -625,14 +652,14 @@ RsDoQwordSpaceDescriptor (
1528 case 9: /* Translation Offset */
1530 - Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
1531 + TranslationOffset = InitializerOp->Asl.Value.Integer;
1532 RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
1533 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
1536 case 10: /* Address Length */
1538 - Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
1539 + AddressLength = InitializerOp->Asl.Value.Integer;
1540 RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
1541 CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
1542 LengthOp = InitializerOp;
1543 @@ -644,7 +671,7 @@ RsDoQwordSpaceDescriptor (
1545 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
1547 - Descriptor->Address64.ResourceLength++;
1549 ResSourceIndex = TRUE;
1552 @@ -656,8 +683,7 @@ RsDoQwordSpaceDescriptor (
1556 - Descriptor->Address64.ResourceLength = (UINT16)
1557 - (Descriptor->Address64.ResourceLength + StringLength);
1558 + ResourceLength = (UINT16) (ResourceLength + StringLength);
1561 &OptionalFields[OptionIndex],
1562 @@ -703,13 +729,20 @@ RsDoQwordSpaceDescriptor (
1563 /* Validate the Min/Max/Len/Gran values */
1565 RsLargeAddressCheck (
1566 - Descriptor->Address64.Minimum,
1567 - Descriptor->Address64.Maximum,
1568 - Descriptor->Address64.AddressLength,
1569 - Descriptor->Address64.Granularity,
1574 Descriptor->Address64.Flags,
1575 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
1577 + ACPI_MOVE_16_TO_16(&Descriptor->Address64.ResourceLength, &ResourceLength);
1578 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Minimum, &Minimum);
1579 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Maximum, &Maximum);
1580 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.AddressLength, &AddressLength);
1581 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.Granularity, &Granularity);
1582 + ACPI_MOVE_64_TO_64(&Descriptor->Address64.TranslationOffset, &TranslationOffset);
1584 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
1585 OptionIndex + StringLength;
1587 Index: acpica-unix2-20181003/source/compiler/aslrestype2s.c
1588 ===================================================================
1589 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2s.c
1590 +++ acpica-unix2-20181003/source/compiler/aslrestype2s.c
1591 @@ -340,9 +340,14 @@ RsDoGpioIntDescriptor (
1592 UINT16 VendorLength;
1593 UINT16 InterruptLength;
1594 UINT16 DescriptorSize;
1595 + UINT16 IntFlags = 0;
1596 + UINT16 DebounceTimeout = 0;
1598 UINT32 CurrentByteOffset;
1599 UINT32 PinCount = 0;
1605 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1606 @@ -367,7 +372,7 @@ RsDoGpioIntDescriptor (
1607 sizeof (AML_RESOURCE_LARGE_HEADER));
1609 Descriptor = Rnode->Buffer;
1610 - Descriptor->Gpio.ResourceLength = DescriptorSize;
1611 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.ResourceLength, &DescriptorSize);
1612 Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO;
1613 Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION;
1614 Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_INT;
1615 @@ -382,11 +387,11 @@ RsDoGpioIntDescriptor (
1617 /* Setup offsets within the descriptor */
1619 - Descriptor->Gpio.PinTableOffset = (UINT16)
1620 - ACPI_PTR_DIFF (InterruptList, Descriptor);
1621 + Tmp16 = (UINT16) ACPI_PTR_DIFF (InterruptList, Descriptor);
1622 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.PinTableOffset, &Tmp16);
1624 - Descriptor->Gpio.ResSourceOffset = (UINT16)
1625 - ACPI_PTR_DIFF (ResourceSource, Descriptor);
1626 + Tmp16 = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor);
1627 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.ResSourceOffset, &Tmp16);
1629 /* Process all child initialization nodes */
1631 @@ -396,21 +401,21 @@ RsDoGpioIntDescriptor (
1633 case 0: /* Interrupt Mode - edge/level [Flag] (_MOD) */
1635 - RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0);
1636 + RsSetFlagBits16 (&IntFlags, InitializerOp, 0, 0);
1637 RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
1638 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0);
1641 case 1: /* Interrupt Polarity - Active high/low [Flags] (_POL) */
1643 - RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 1, 0);
1644 + RsSetFlagBits16 (&IntFlags, InitializerOp, 1, 0);
1645 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_POLARITY,
1646 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 1, 2);
1649 case 2: /* Share Type - Default: exclusive (0) [Flags] (_SHR) */
1651 - RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0);
1652 + RsSetFlagBits16 (&IntFlags, InitializerOp, 3, 0);
1653 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1654 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3, 2);
1656 @@ -424,7 +429,7 @@ RsDoGpioIntDescriptor (
1658 case 4: /* Debounce Timeout [WORD] (_DBT) */
1660 - Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
1661 + DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
1662 RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
1663 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout));
1665 @@ -451,7 +456,7 @@ RsDoGpioIntDescriptor (
1667 case 7: /* Resource Usage (consumer/producer) */
1669 - RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
1670 + RsSetFlagBits16 (&Flags, InitializerOp, 0, 1);
1673 case 8: /* Resource Tag (Descriptor Name) */
1674 @@ -466,13 +471,14 @@ RsDoGpioIntDescriptor (
1675 * This field is required in order to calculate the length
1676 * of the ResourceSource at runtime.
1678 - Descriptor->Gpio.VendorOffset = (UINT16)
1679 - ACPI_PTR_DIFF (VendorData, Descriptor);
1680 + Tmp16 = (UINT16) ACPI_PTR_DIFF (VendorData, Descriptor);
1681 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.VendorOffset, &Tmp16);
1683 if (RsGetVendorData (InitializerOp, VendorData,
1684 - (CurrentByteOffset + Descriptor->Gpio.VendorOffset)))
1685 + (CurrentByteOffset + Tmp16)))
1687 - Descriptor->Gpio.VendorLength = VendorLength;
1688 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.VendorLength,
1693 @@ -485,7 +491,9 @@ RsDoGpioIntDescriptor (
1694 * (implies resource source must immediately follow the pin list.)
1697 - *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
1698 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1699 + ACPI_MOVE_16_TO_16(&Val16, &Tmp16);
1700 + *InterruptList = Val16;
1704 @@ -507,8 +515,10 @@ RsDoGpioIntDescriptor (
1706 /* Create a named field at the start of the list */
1708 - RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN,
1709 - CurrentByteOffset + Descriptor->Gpio.PinTableOffset);
1710 + ACPI_MOVE_16_TO_16(&Tmp16, &Descriptor->Gpio.PinTableOffset);
1711 + Tmp16 += CurrentByteOffset;
1712 + ACPI_MOVE_16_TO_16(&Val16, &Tmp16);
1713 + RsCreateWordField (InitializerOp, ACPI_RESTAG_PIN, Val16);
1717 @@ -516,6 +526,10 @@ RsDoGpioIntDescriptor (
1718 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1721 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.IntFlags, &IntFlags);
1722 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.DebounceTimeout, &DebounceTimeout);
1723 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.Flags, &Flags);
1725 MpSaveGpioInfo (Info->MappingOp, Descriptor,
1726 PinCount, PinList, ResourceSource);
1728 @@ -549,9 +563,15 @@ RsDoGpioIoDescriptor (
1729 UINT16 VendorLength;
1730 UINT16 InterruptLength;
1731 UINT16 DescriptorSize;
1732 + UINT16 IntFlags = 0;
1733 + UINT16 DebounceTimeout = 0;
1734 + UINT16 DriveStrength = 0;
1736 UINT32 CurrentByteOffset;
1737 UINT32 PinCount = 0;
1743 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1744 @@ -577,7 +597,7 @@ RsDoGpioIoDescriptor (
1745 sizeof (AML_RESOURCE_LARGE_HEADER));
1747 Descriptor = Rnode->Buffer;
1748 - Descriptor->Gpio.ResourceLength = DescriptorSize;
1749 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.ResourceLength, &DescriptorSize);
1750 Descriptor->Gpio.DescriptorType = ACPI_RESOURCE_NAME_GPIO;
1751 Descriptor->Gpio.RevisionId = AML_RESOURCE_GPIO_REVISION;
1752 Descriptor->Gpio.ConnectionType = AML_RESOURCE_GPIO_TYPE_IO;
1753 @@ -591,11 +611,11 @@ RsDoGpioIoDescriptor (
1755 /* Setup offsets within the descriptor */
1757 - Descriptor->Gpio.PinTableOffset = (UINT16)
1758 - ACPI_PTR_DIFF (InterruptList, Descriptor);
1759 + Tmp16 = (UINT16) ACPI_PTR_DIFF (InterruptList, Descriptor);
1760 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.PinTableOffset, &Tmp16);
1762 - Descriptor->Gpio.ResSourceOffset = (UINT16)
1763 - ACPI_PTR_DIFF (ResourceSource, Descriptor);
1764 + Tmp16 = (UINT16) ACPI_PTR_DIFF (ResourceSource, Descriptor);
1765 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.ResSourceOffset, &Tmp16);
1767 /* Process all child initialization nodes */
1769 @@ -605,7 +625,7 @@ RsDoGpioIoDescriptor (
1771 case 0: /* Share Type [Flags] (_SHR) */
1773 - RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 3, 0);
1774 + RsSetFlagBits16 (&IntFlags, InitializerOp, 3, 0);
1775 RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
1776 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 3);
1778 @@ -619,21 +639,21 @@ RsDoGpioIoDescriptor (
1780 case 2: /* Debounce Timeout [WORD] (_DBT) */
1782 - Descriptor->Gpio.DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
1783 + DebounceTimeout = (UINT16) InitializerOp->Asl.Value.Integer;
1784 RsCreateWordField (InitializerOp, ACPI_RESTAG_DEBOUNCETIME,
1785 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DebounceTimeout));
1788 case 3: /* Drive Strength [WORD] (_DRS) */
1790 - Descriptor->Gpio.DriveStrength = (UINT16) InitializerOp->Asl.Value.Integer;
1791 + DriveStrength = (UINT16) InitializerOp->Asl.Value.Integer;
1792 RsCreateWordField (InitializerOp, ACPI_RESTAG_DRIVESTRENGTH,
1793 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.DriveStrength));
1796 case 4: /* I/O Restriction [Flag] (_IOR) */
1798 - RsSetFlagBits16 (&Descriptor->Gpio.IntFlags, InitializerOp, 0, 0);
1799 + RsSetFlagBits16 (&IntFlags, InitializerOp, 0, 0);
1800 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_IORESTRICTION,
1801 CurrentByteOffset + ASL_RESDESC_OFFSET (Gpio.IntFlags), 0, 2);
1803 @@ -659,7 +679,7 @@ RsDoGpioIoDescriptor (
1805 case 7: /* Resource Usage (consumer/producer) */
1807 - RsSetFlagBits16 (&Descriptor->Gpio.Flags, InitializerOp, 0, 1);
1808 + RsSetFlagBits16 (&Flags, InitializerOp, 0, 1);
1811 case 8: /* Resource Tag (Descriptor Name) */
1812 @@ -673,13 +693,14 @@ RsDoGpioIoDescriptor (
1813 * This field is required in order to calculate the length
1814 * of the ResourceSource at runtime.
1816 - Descriptor->Gpio.VendorOffset = (UINT16)
1817 - ACPI_PTR_DIFF (VendorData, Descriptor);
1818 + Tmp16 = (UINT16) ACPI_PTR_DIFF (VendorData, Descriptor);
1819 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.VendorOffset, &Tmp16);
1821 if (RsGetVendorData (InitializerOp, VendorData,
1822 (CurrentByteOffset + Descriptor->Gpio.VendorOffset)))
1824 - Descriptor->Gpio.VendorLength = VendorLength;
1825 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.VendorLength,
1830 @@ -692,7 +713,9 @@ RsDoGpioIoDescriptor (
1831 * (implies resource source must immediately follow the pin list.)
1834 - *InterruptList = (UINT16) InitializerOp->Asl.Value.Integer;
1835 + Tmp16 = (UINT16) InitializerOp->Asl.Value.Integer;
1836 + ACPI_MOVE_16_TO_16(&Val16, &Tmp16);
1837 + *InterruptList = Val16;
1841 @@ -723,6 +746,11 @@ RsDoGpioIoDescriptor (
1842 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1845 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.IntFlags, &IntFlags);
1846 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.DebounceTimeout, &DebounceTimeout);
1847 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.DriveStrength, &DriveStrength);
1848 + ACPI_MOVE_16_TO_16(&Descriptor->Gpio.Flags, &Flags);
1850 MpSaveGpioInfo (Info->MappingOp, Descriptor,
1851 PinCount, PinList, ResourceSource);
1853 @@ -753,8 +781,12 @@ RsDoI2cSerialBusDescriptor (
1854 UINT16 ResSourceLength;
1855 UINT16 VendorLength;
1856 UINT16 DescriptorSize;
1857 + UINT16 SlaveAddress = 0;
1858 + UINT32 ConnectionSpeed = 0;
1859 + UINT16 TypeSpecificFlags = 0;
1860 UINT32 CurrentByteOffset;
1865 InitializerOp = Info->DescriptorTypeOp->Asl.Child;
1866 @@ -777,12 +809,14 @@ RsDoI2cSerialBusDescriptor (
1867 sizeof (AML_RESOURCE_LARGE_HEADER));
1869 Descriptor = Rnode->Buffer;
1870 - Descriptor->I2cSerialBus.ResourceLength = DescriptorSize;
1871 + ACPI_MOVE_16_TO_16(&Descriptor->I2cSerialBus.ResourceLength,
1873 Descriptor->I2cSerialBus.DescriptorType = ACPI_RESOURCE_NAME_SERIAL_BUS;
1874 Descriptor->I2cSerialBus.RevisionId = AML_RESOURCE_I2C_REVISION;
1875 Descriptor->I2cSerialBus.TypeRevisionId = AML_RESOURCE_I2C_TYPE_REVISION;
1876 Descriptor->I2cSerialBus.Type = AML_RESOURCE_I2C_SERIALBUSTYPE;
1877 - Descriptor->I2cSerialBus.TypeDataLength = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
1878 + Tmp16 = AML_RESOURCE_I2C_MIN_DATA_LEN + VendorLength;
1879 + ACPI_MOVE_16_TO_16(&Descriptor->I2cSerialBus.TypeDataLength, &Tmp16);
1881 if (Info->DescriptorTypeOp->Asl.ParseOpcode == PARSEOP_I2C_SERIALBUS_V2)
1883 @@ -802,7 +836,7 @@ RsDoI2cSerialBusDescriptor (
1885 case 0: /* Slave Address [WORD] (_ADR) */
1887 - Descriptor->I2cSerialBus.SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
1888 + SlaveAddress = (UINT16) InitializerOp->Asl.Value.Integer;
1889 RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
1890 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.SlaveAddress));
1892 @@ -816,14 +850,14 @@ RsDoI2cSerialBusDescriptor (
1894 case 2: /* Connection Speed [DWORD] (_SPE) */
1896 - Descriptor->I2cSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
1897 + ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
1898 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
1899 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.ConnectionSpeed));
1902 case 3: /* Addressing Mode [Flag] (_MOD) */
1904 - RsSetFlagBits16 (&Descriptor->I2cSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
1905 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 0, 0);
1906 RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
1907 CurrentByteOffset + ASL_RESDESC_OFFSET (I2cSerialBus.TypeSpecificFlags), 0);
1909 @@ -883,6 +917,9 @@ RsDoI2cSerialBusDescriptor (
1910 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1913 + ACPI_MOVE_16_TO_16(&Descriptor->I2cSerialBus.SlaveAddress, &SlaveAddress);
1914 + ACPI_MOVE_32_TO_32(&Descriptor->I2cSerialBus.ConnectionSpeed, &ConnectionSpeed);
1915 + ACPI_MOVE_16_TO_16(&Descriptor->I2cSerialBus.TypeSpecificFlags, &TypeSpecificFlags);
1916 MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
1919 @@ -912,6 +949,9 @@ RsDoSpiSerialBusDescriptor (
1920 UINT16 ResSourceLength;
1921 UINT16 VendorLength;
1922 UINT16 DescriptorSize;
1923 + UINT16 DeviceSelection = 0;
1924 + UINT32 ConnectionSpeed = 0;
1925 + UINT16 TypeSpecificFlags = 0;
1926 UINT32 CurrentByteOffset;
1929 @@ -962,21 +1002,21 @@ RsDoSpiSerialBusDescriptor (
1931 case 0: /* Device Selection [WORD] (_ADR) */
1933 - Descriptor->SpiSerialBus.DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
1934 + DeviceSelection = (UINT16) InitializerOp->Asl.Value.Integer;
1935 RsCreateWordField (InitializerOp, ACPI_RESTAG_ADDRESS,
1936 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.DeviceSelection));
1939 case 1: /* Device Polarity [Flag] (_DPL) */
1941 - RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 1, 0);
1942 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 1, 0);
1943 RsCreateBitField (InitializerOp, ACPI_RESTAG_DEVICEPOLARITY,
1944 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 1);
1947 case 2: /* Wire Mode [Flag] (_MOD) */
1949 - RsSetFlagBits16 (&Descriptor->SpiSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
1950 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 0, 0);
1951 RsCreateBitField (InitializerOp, ACPI_RESTAG_MODE,
1952 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.TypeSpecificFlags), 0);
1954 @@ -997,7 +1037,7 @@ RsDoSpiSerialBusDescriptor (
1956 case 5: /* Connection Speed [DWORD] (_SPE) */
1958 - Descriptor->SpiSerialBus.ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
1959 + ConnectionSpeed = (UINT32) InitializerOp->Asl.Value.Integer;
1960 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
1961 CurrentByteOffset + ASL_RESDESC_OFFSET (SpiSerialBus.ConnectionSpeed));
1963 @@ -1071,6 +1111,10 @@ RsDoSpiSerialBusDescriptor (
1964 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
1967 + ACPI_MOVE_16_TO_16(&Descriptor->SpiSerialBus.DeviceSelection, &DeviceSelection);
1968 + ACPI_MOVE_32_TO_32(&Descriptor->SpiSerialBus.ConnectionSpeed, &ConnectionSpeed);
1969 + ACPI_MOVE_16_TO_16(&Descriptor->SpiSerialBus.TypeSpecificFlags, &TypeSpecificFlags);
1971 MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
1974 @@ -1100,6 +1144,10 @@ RsDoUartSerialBusDescriptor (
1975 UINT16 ResSourceLength;
1976 UINT16 VendorLength;
1977 UINT16 DescriptorSize;
1978 + UINT32 DefaultBaudRate = 0;
1979 + UINT16 TypeSpecificFlags = 0;
1980 + UINT16 RxFifoSize = 0;
1981 + UINT16 TxFifoSize = 0;
1982 UINT32 CurrentByteOffset;
1985 @@ -1149,21 +1197,21 @@ RsDoUartSerialBusDescriptor (
1987 case 0: /* Connection Speed (Baud Rate) [DWORD] (_SPE) */
1989 - Descriptor->UartSerialBus.DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
1990 + DefaultBaudRate = (UINT32) InitializerOp->Asl.Value.Integer;
1991 RsCreateDwordField (InitializerOp, ACPI_RESTAG_SPEED,
1992 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.DefaultBaudRate));
1995 case 1: /* Bits Per Byte [Flags] (_LEN) */
1997 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 4, 3);
1998 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 4, 3);
1999 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_LENGTH,
2000 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 4, 3);
2003 case 2: /* Stop Bits [Flags] (_STB) */
2005 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 2, 1);
2006 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 2, 1);
2007 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_STOPBITS,
2008 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 2, 2);
2010 @@ -1177,7 +1225,7 @@ RsDoUartSerialBusDescriptor (
2012 case 4: /* Endianness [Flag] (_END) */
2014 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 7, 0);
2015 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 7, 0);
2016 RsCreateBitField (InitializerOp, ACPI_RESTAG_ENDIANNESS,
2017 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 7);
2019 @@ -1191,21 +1239,21 @@ RsDoUartSerialBusDescriptor (
2021 case 6: /* Flow Control [Flags] (_FLC) */
2023 - RsSetFlagBits16 (&Descriptor->UartSerialBus.TypeSpecificFlags, InitializerOp, 0, 0);
2024 + RsSetFlagBits16 (&TypeSpecificFlags, InitializerOp, 0, 0);
2025 RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_FLOWCONTROL,
2026 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TypeSpecificFlags), 0, 2);
2029 case 7: /* Rx Buffer Size [WORD] (_RXL) */
2031 - Descriptor->UartSerialBus.RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2032 + RxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2033 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_RX,
2034 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.RxFifoSize));
2037 case 8: /* Tx Buffer Size [WORD] (_TXL) */
2039 - Descriptor->UartSerialBus.TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2040 + TxFifoSize = (UINT16) InitializerOp->Asl.Value.Integer;
2041 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH_TX,
2042 CurrentByteOffset + ASL_RESDESC_OFFSET (UartSerialBus.TxFifoSize));
2044 @@ -1275,6 +1323,11 @@ RsDoUartSerialBusDescriptor (
2045 InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
2048 + ACPI_MOVE_32_TO_32(&Descriptor->UartSerialBus.DefaultBaudRate, &DefaultBaudRate);
2049 + ACPI_MOVE_16_TO_16(&Descriptor->UartSerialBus.TypeSpecificFlags, &TypeSpecificFlags);
2050 + ACPI_MOVE_16_TO_16(&Descriptor->UartSerialBus.RxFifoSize, &RxFifoSize);
2051 + ACPI_MOVE_16_TO_16(&Descriptor->UartSerialBus.TxFifoSize, &TxFifoSize);
2053 MpSaveSerialInfo (Info->MappingOp, Descriptor, ResourceSource);
2056 Index: acpica-unix2-20181003/source/compiler/aslrestype2w.c
2057 ===================================================================
2058 --- acpica-unix2-20181003.orig/source/compiler/aslrestype2w.c
2059 +++ acpica-unix2-20181003/source/compiler/aslrestype2w.c
2060 @@ -81,6 +81,12 @@ RsDoWordIoDescriptor (
2061 UINT8 *OptionalFields;
2062 UINT16 StringLength = 0;
2063 UINT32 OptionIndex = 0;
2064 + UINT16 ResourceLength = 0;
2065 + UINT16 Minimum = 0;
2066 + UINT16 Maximum = 0;
2067 + UINT16 AddressLength = 0;
2068 + UINT16 Granularity = 0;
2069 + UINT16 TranslationOffset = 0;
2070 UINT32 CurrentByteOffset;
2072 BOOLEAN ResSourceIndex = FALSE;
2073 @@ -102,8 +108,7 @@ RsDoWordIoDescriptor (
2074 * optional fields present
2076 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
2077 - Descriptor->Address16.ResourceLength = (UINT16)
2078 - (sizeof (AML_RESOURCE_ADDRESS16) -
2079 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS16) -
2080 sizeof (AML_RESOURCE_LARGE_HEADER));
2082 /* Process all child initialization nodes */
2083 @@ -147,7 +152,7 @@ RsDoWordIoDescriptor (
2085 case 5: /* Address Granularity */
2087 - Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
2088 + Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
2089 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2090 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
2091 GranOp = InitializerOp;
2092 @@ -155,7 +160,7 @@ RsDoWordIoDescriptor (
2094 case 6: /* Address Min */
2096 - Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
2097 + Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
2098 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
2099 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
2100 MinOp = InitializerOp;
2101 @@ -163,7 +168,7 @@ RsDoWordIoDescriptor (
2103 case 7: /* Address Max */
2105 - Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
2106 + Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
2107 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2108 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
2109 MaxOp = InitializerOp;
2110 @@ -171,14 +176,14 @@ RsDoWordIoDescriptor (
2112 case 8: /* Translation Offset */
2114 - Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
2115 + TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
2116 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2117 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
2120 case 9: /* Address Length */
2122 - Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
2123 + AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
2124 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
2125 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
2126 LengthOp = InitializerOp;
2127 @@ -190,7 +195,7 @@ RsDoWordIoDescriptor (
2129 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
2131 - Descriptor->Address16.ResourceLength++;
2133 ResSourceIndex = TRUE;
2136 @@ -202,8 +207,7 @@ RsDoWordIoDescriptor (
2140 - Descriptor->Address16.ResourceLength = (UINT16)
2141 - (Descriptor->Address16.ResourceLength + StringLength);
2142 + ResourceLength = (UINT16) (ResourceLength + StringLength);
2145 &OptionalFields[OptionIndex],
2146 @@ -263,13 +267,20 @@ RsDoWordIoDescriptor (
2147 /* Validate the Min/Max/Len/Gran values */
2149 RsLargeAddressCheck (
2150 - (UINT64) Descriptor->Address16.Minimum,
2151 - (UINT64) Descriptor->Address16.Maximum,
2152 - (UINT64) Descriptor->Address16.AddressLength,
2153 - (UINT64) Descriptor->Address16.Granularity,
2158 Descriptor->Address16.Flags,
2159 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2161 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.ResourceLength, &ResourceLength);
2162 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Minimum, &Minimum);
2163 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Maximum, &Maximum);
2164 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.AddressLength, &AddressLength);
2165 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Granularity, &Granularity);
2166 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.TranslationOffset, &TranslationOffset);
2168 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
2169 OptionIndex + StringLength;
2171 @@ -302,6 +313,12 @@ RsDoWordBusNumberDescriptor (
2172 UINT8 *OptionalFields;
2173 UINT16 StringLength = 0;
2174 UINT32 OptionIndex = 0;
2175 + UINT16 ResourceLength = 0;
2176 + UINT16 Minimum = 0;
2177 + UINT16 Maximum = 0;
2178 + UINT16 AddressLength = 0;
2179 + UINT16 Granularity = 0;
2180 + UINT16 TranslationOffset = 0;
2181 UINT32 CurrentByteOffset;
2183 BOOLEAN ResSourceIndex = FALSE;
2184 @@ -323,8 +340,7 @@ RsDoWordBusNumberDescriptor (
2185 * optional fields present
2187 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
2188 - Descriptor->Address16.ResourceLength = (UINT16)
2189 - (sizeof (AML_RESOURCE_ADDRESS16) -
2190 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS16) -
2191 sizeof (AML_RESOURCE_LARGE_HEADER));
2193 /* Process all child initialization nodes */
2194 @@ -361,8 +377,7 @@ RsDoWordBusNumberDescriptor (
2196 case 4: /* Address Granularity */
2198 - Descriptor->Address16.Granularity =
2199 - (UINT16) InitializerOp->Asl.Value.Integer;
2200 + Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
2201 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2202 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
2203 GranOp = InitializerOp;
2204 @@ -370,8 +385,7 @@ RsDoWordBusNumberDescriptor (
2206 case 5: /* Min Address */
2208 - Descriptor->Address16.Minimum =
2209 - (UINT16) InitializerOp->Asl.Value.Integer;
2210 + Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
2211 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
2212 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
2213 MinOp = InitializerOp;
2214 @@ -379,8 +393,7 @@ RsDoWordBusNumberDescriptor (
2216 case 6: /* Max Address */
2218 - Descriptor->Address16.Maximum =
2219 - (UINT16) InitializerOp->Asl.Value.Integer;
2220 + Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
2221 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2222 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
2223 MaxOp = InitializerOp;
2224 @@ -388,16 +401,14 @@ RsDoWordBusNumberDescriptor (
2226 case 7: /* Translation Offset */
2228 - Descriptor->Address16.TranslationOffset =
2229 - (UINT16) InitializerOp->Asl.Value.Integer;
2230 + TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
2231 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2232 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
2235 case 8: /* Address Length */
2237 - Descriptor->Address16.AddressLength =
2238 - (UINT16) InitializerOp->Asl.Value.Integer;
2239 + AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
2240 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
2241 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
2242 LengthOp = InitializerOp;
2243 @@ -409,7 +420,7 @@ RsDoWordBusNumberDescriptor (
2245 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
2247 - Descriptor->Address16.ResourceLength++;
2249 ResSourceIndex = TRUE;
2252 @@ -421,8 +432,7 @@ RsDoWordBusNumberDescriptor (
2256 - Descriptor->Address16.ResourceLength = (UINT16)
2257 - (Descriptor->Address16.ResourceLength + StringLength);
2258 + ResourceLength = (UINT16) (ResourceLength + StringLength);
2261 &OptionalFields[OptionIndex],
2262 @@ -468,13 +478,20 @@ RsDoWordBusNumberDescriptor (
2263 /* Validate the Min/Max/Len/Gran values */
2265 RsLargeAddressCheck (
2266 - (UINT64) Descriptor->Address16.Minimum,
2267 - (UINT64) Descriptor->Address16.Maximum,
2268 - (UINT64) Descriptor->Address16.AddressLength,
2269 - (UINT64) Descriptor->Address16.Granularity,
2274 Descriptor->Address16.Flags,
2275 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2277 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.ResourceLength, &ResourceLength);
2278 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Minimum, &Minimum);
2279 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Maximum, &Maximum);
2280 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.AddressLength, &AddressLength);
2281 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Granularity, &Granularity);
2282 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.TranslationOffset, &TranslationOffset);
2284 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
2285 OptionIndex + StringLength;
2287 @@ -507,6 +524,12 @@ RsDoWordSpaceDescriptor (
2288 UINT8 *OptionalFields;
2289 UINT16 StringLength = 0;
2290 UINT32 OptionIndex = 0;
2291 + UINT16 Minimum = 0;
2292 + UINT16 Maximum = 0;
2293 + UINT16 AddressLength = 0;
2294 + UINT16 Granularity = 0;
2295 + UINT16 TranslationOffset = 0;
2296 + UINT16 ResourceLength = 0;
2297 UINT32 CurrentByteOffset;
2299 BOOLEAN ResSourceIndex = FALSE;
2300 @@ -527,8 +550,7 @@ RsDoWordSpaceDescriptor (
2301 * optional fields present
2303 OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
2304 - Descriptor->Address16.ResourceLength = (UINT16)
2305 - (sizeof (AML_RESOURCE_ADDRESS16) -
2306 + ResourceLength = (UINT16) (sizeof (AML_RESOURCE_ADDRESS16) -
2307 sizeof (AML_RESOURCE_LARGE_HEADER));
2309 /* Process all child initialization nodes */
2310 @@ -577,8 +599,7 @@ RsDoWordSpaceDescriptor (
2312 case 6: /* Address Granularity */
2314 - Descriptor->Address16.Granularity =
2315 - (UINT16) InitializerOp->Asl.Value.Integer;
2316 + Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
2317 RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
2318 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
2319 GranOp = InitializerOp;
2320 @@ -586,8 +607,7 @@ RsDoWordSpaceDescriptor (
2322 case 7: /* Min Address */
2324 - Descriptor->Address16.Minimum =
2325 - (UINT16) InitializerOp->Asl.Value.Integer;
2326 + Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
2327 RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
2328 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
2329 MinOp = InitializerOp;
2330 @@ -595,8 +615,7 @@ RsDoWordSpaceDescriptor (
2332 case 8: /* Max Address */
2334 - Descriptor->Address16.Maximum =
2335 - (UINT16) InitializerOp->Asl.Value.Integer;
2336 + Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
2337 RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
2338 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
2339 MaxOp = InitializerOp;
2340 @@ -604,16 +623,14 @@ RsDoWordSpaceDescriptor (
2342 case 9: /* Translation Offset */
2344 - Descriptor->Address16.TranslationOffset =
2345 - (UINT16) InitializerOp->Asl.Value.Integer;
2346 + TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
2347 RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
2348 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
2351 case 10: /* Address Length */
2353 - Descriptor->Address16.AddressLength =
2354 - (UINT16) InitializerOp->Asl.Value.Integer;
2355 + AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
2356 RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
2357 CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
2358 LengthOp = InitializerOp;
2359 @@ -625,7 +642,7 @@ RsDoWordSpaceDescriptor (
2361 OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
2363 - Descriptor->Address16.ResourceLength++;
2365 ResSourceIndex = TRUE;
2368 @@ -637,8 +654,7 @@ RsDoWordSpaceDescriptor (
2372 - Descriptor->Address16.ResourceLength = (UINT16)
2373 - (Descriptor->Address16.ResourceLength + StringLength);
2374 + ResourceLength = (UINT16) (ResourceLength + StringLength);
2377 &OptionalFields[OptionIndex],
2378 @@ -684,13 +700,20 @@ RsDoWordSpaceDescriptor (
2379 /* Validate the Min/Max/Len/Gran values */
2381 RsLargeAddressCheck (
2382 - (UINT64) Descriptor->Address16.Minimum,
2383 - (UINT64) Descriptor->Address16.Maximum,
2384 - (UINT64) Descriptor->Address16.AddressLength,
2385 - (UINT64) Descriptor->Address16.Granularity,
2390 Descriptor->Address16.Flags,
2391 MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
2393 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.ResourceLength, &ResourceLength);
2394 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Minimum, &Minimum);
2395 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Maximum, &Maximum);
2396 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.AddressLength, &AddressLength);
2397 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.Granularity, &Granularity);
2398 + ACPI_MOVE_16_TO_16(&Descriptor->Address16.TranslationOffset, &TranslationOffset);
2400 Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
2401 OptionIndex + StringLength;
2403 Index: acpica-unix2-20181003/source/include/acmacros.h
2404 ===================================================================
2405 --- acpica-unix2-20181003.orig/source/include/acmacros.h
2406 +++ acpica-unix2-20181003/source/include/acmacros.h
2408 ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\
2409 ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];}
2411 -/* 32-bit source, 16/32/64 destination */
2412 +/* 32-bit source, 8/16/32/64 destination */
2414 -#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
2415 +#define ACPI_MOVE_32_TO_8(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];}
2417 +#define ACPI_MOVE_32_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\
2418 + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];}
2420 #define ACPI_MOVE_32_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[3];\
2421 (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[2];\
2422 @@ -113,11 +116,17 @@
2423 ((UINT8 *)(void *)(d))[6] = ((UINT8 *)(void *)(s))[1];\
2424 ((UINT8 *)(void *)(d))[7] = ((UINT8 *)(void *)(s))[0];}
2426 -/* 64-bit source, 16/32/64 destination */
2427 +/* 64-bit source, 8/16/32/64 destination */
2429 -#define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
2430 +#define ACPI_MOVE_64_TO_8(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];}
2432 -#define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
2433 +#define ACPI_MOVE_64_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\
2434 + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];}
2436 +#define ACPI_MOVE_64_TO_32(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\
2437 + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\
2438 + (( UINT8 *)(void *)(d))[2] = ((UINT8 *)(void *)(s))[5];\
2439 + (( UINT8 *)(void *)(d))[3] = ((UINT8 *)(void *)(s))[4];}
2441 #define ACPI_MOVE_64_TO_64(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[7];\
2442 (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[6];\
2443 @@ -136,20 +145,26 @@
2445 /* The hardware supports unaligned transfers, just do the little-endian move */
2447 -/* 16-bit source, 16/32/64 destination */
2448 +/* 16-bit source, 8/16/32/64 destination */
2450 +#define ACPI_MOVE_16_TO_8(d, s) *(UINT8 *)(void *)(d) = *(UINT16 *)(void *)(s)
2451 #define ACPI_MOVE_16_TO_16(d, s) *(UINT16 *)(void *)(d) = *(UINT16 *)(void *)(s)
2452 #define ACPI_MOVE_16_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT16 *)(void *)(s)
2453 #define ACPI_MOVE_16_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT16 *)(void *)(s)
2455 -/* 32-bit source, 16/32/64 destination */
2456 +/* 32-bit source, 8/16/32/64 destination */
2458 +#define ACPI_MOVE_32_TO_8(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];}
2460 +#define ACPI_MOVE_32_TO_16(d, s) {(( UINT8 *)(void *)(d))[0] = ((UINT8 *)(void *)(s))[0];\
2461 + (( UINT8 *)(void *)(d))[1] = ((UINT8 *)(void *)(s))[1];}
2463 -#define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
2464 #define ACPI_MOVE_32_TO_32(d, s) *(UINT32 *)(void *)(d) = *(UINT32 *)(void *)(s)
2465 #define ACPI_MOVE_32_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT32 *)(void *)(s)
2467 -/* 64-bit source, 16/32/64 destination */
2468 +/* 64-bit source, 8/16/32/64 destination */
2470 +#define ACPI_MOVE_64_TO_8(d, s) ACPI_MOVE_16_TO_8(d, s) /* Truncate to 8 */
2471 #define ACPI_MOVE_64_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
2472 #define ACPI_MOVE_64_TO_32(d, s) ACPI_MOVE_32_TO_32(d, s) /* Truncate to 32 */
2473 #define ACPI_MOVE_64_TO_64(d, s) *(UINT64 *)(void *)(d) = *(UINT64 *)(void *)(s)
2475 #define ACPI_MOVE_16_TO_32(d, s) {(*(UINT32 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
2476 #define ACPI_MOVE_16_TO_64(d, s) {(*(UINT64 *)(void *)(d)) = 0; ACPI_MOVE_16_TO_16(d, s);}
2478 -/* 32-bit source, 16/32/64 destination */
2479 +/* 32-bit source, 8/16/32/64 destination */
2481 +#define ACPI_MOVE_32_TO_8(d, s) ACPI_MOVE_16_TO_8(d, s) /* Truncate to 8 */
2483 #define ACPI_MOVE_32_TO_16(d, s) ACPI_MOVE_16_TO_16(d, s) /* Truncate to 16 */
2485 Index: acpica-unix2-20181003/source/include/platform/aclinux.h
2486 ===================================================================
2487 --- acpica-unix2-20181003.orig/source/include/platform/aclinux.h
2488 +++ acpica-unix2-20181003/source/include/platform/aclinux.h
2491 #ifdef ACPI_USE_STANDARD_HEADERS
2493 +#include <endian.h>
2496 /* Define/disable kernel-specific declarators */
2497 @@ -227,6 +228,10 @@
2501 +#if defined(__PPC64__) || defined(__s390x__)
2502 +#define ACPI_BIG_ENDIAN
2505 #endif /* __KERNEL__ */
2507 #endif /* __ACLINUX_H__ */
2508 Index: acpica-unix2-20181003/source/compiler/aslanalyze.c
2509 ===================================================================
2510 --- acpica-unix2-20181003.orig/source/compiler/aslanalyze.c
2511 +++ acpica-unix2-20181003/source/compiler/aslanalyze.c
2512 @@ -461,7 +461,7 @@ ApCheckForGpeNameConflict (
2514 /* Need a null-terminated string version of NameSeg */
2516 - ACPI_MOVE_32_TO_32 (Name, &Op->Asl.NameSeg);
2517 + ACPI_MOVE_NAME (Name, &Op->Asl.NameSeg);
2518 Name[ACPI_NAME_SIZE] = 0;
2521 @@ -488,7 +488,7 @@ ApCheckForGpeNameConflict (
2522 * We are now sure we have an _Lxx or _Exx.
2523 * Create the target name that would cause collision (Flip E/L)
2525 - ACPI_MOVE_32_TO_32 (Target, Name);
2526 + ACPI_MOVE_NAME (Target, Name);
2528 /* Inject opposite letter ("L" versus "E") */
2530 Index: acpica-unix2-20181003/source/compiler/asllookup.c
2531 ===================================================================
2532 --- acpica-unix2-20181003.orig/source/compiler/asllookup.c
2533 +++ acpica-unix2-20181003/source/compiler/asllookup.c
2534 @@ -119,6 +119,7 @@ LkIsObjectUsed (
2536 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
2537 ACPI_NAMESPACE_NODE *Next;
2538 + ACPI_NAME_UNION tmp, tmp2;
2539 ASL_METHOD_LOCAL *MethodLocals;
2540 ASL_METHOD_LOCAL *MethodArgs;
2542 @@ -175,7 +176,8 @@ LkIsObjectUsed (
2543 * We ignore the predefined methods since often, not
2544 * all arguments are needed or used.
2546 - if ((Node->Name.Ascii[0] != '_') &&
2547 + ACPI_MOVE_32_TO_32(&tmp.Ascii, Node->Name.Ascii);
2548 + if ((tmp.Ascii[0] != '_') &&
2549 (!(MethodArgs[i].Flags & ASL_ARG_REFERENCED)))
2551 sprintf (AslGbl_MsgBuffer, "Arg%u", i);
2552 @@ -228,8 +230,10 @@ LkIsObjectUsed (
2553 * Issue a remark even if it is a reserved name (starts
2554 * with an underscore).
2556 + ACPI_MOVE_32_TO_32(&tmp.Ascii, Node->Name.Ascii);
2557 + ACPI_MOVE_32_TO_32(&tmp2.Ascii, Next->Name.Ascii);
2558 sprintf (AslGbl_MsgBuffer, "Name [%4.4s] is within a method [%4.4s]",
2559 - Node->Name.Ascii, Next->Name.Ascii);
2560 + tmp.Ascii, tmp2.Ascii);
2561 AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED,
2562 LkGetNameOp (Node->Op), AslGbl_MsgBuffer);
2564 Index: acpica-unix2-20181003/source/compiler/aslmain.c
2565 ===================================================================
2566 --- acpica-unix2-20181003.orig/source/compiler/aslmain.c
2567 +++ acpica-unix2-20181003/source/compiler/aslmain.c
2568 @@ -101,18 +101,6 @@ main (
2570 signal (SIGINT, AslSignalHandler);
2573 - * Big-endian machines are not currently supported. ACPI tables must
2574 - * be little-endian, and support for big-endian machines needs to
2577 - if (UtIsBigEndianMachine ())
2580 - "iASL is not currently supported on big-endian machines.\n");
2584 AcpiOsInitialize ();
2585 ACPI_DEBUG_INITIALIZE (); /* For debug version only */
2587 Index: acpica-unix2-20181003/source/common/acfileio.c
2588 ===================================================================
2589 --- acpica-unix2-20181003.orig/source/common/acfileio.c
2590 +++ acpica-unix2-20181003/source/common/acfileio.c
2591 @@ -280,6 +280,7 @@ AcGetOneTableFromFile (
2592 ACPI_TABLE_HEADER *Table;
2598 *ReturnTable = NULL;
2599 @@ -319,7 +320,8 @@ AcGetOneTableFromFile (
2601 /* Allocate a buffer for the entire table */
2603 - Table = AcpiOsAllocate ((ACPI_SIZE) TableHeader.Length);
2604 + ACPI_MOVE_32_TO_32(&TableLen, &TableHeader.Length);
2605 + Table = AcpiOsAllocate ((ACPI_SIZE) TableLen);
2608 return (AE_NO_MEMORY);
2609 @@ -329,13 +331,13 @@ AcGetOneTableFromFile (
2611 fseek (File, TableOffset, SEEK_SET);
2613 - Count = fread (Table, 1, TableHeader.Length, File);
2614 + Count = fread (Table, 1, TableLen, File);
2617 * Checks for data table headers happen later in the execution. Only verify
2618 * for Aml tables at this point in the code.
2620 - if (GetOnlyAmlTables && Count != (INT32) TableHeader.Length)
2621 + if (GetOnlyAmlTables && Count != TableLen)
2625 @@ -343,7 +345,7 @@ AcGetOneTableFromFile (
2627 /* Validate the checksum (just issue a warning) */
2629 - Status = AcpiTbVerifyChecksum (Table, TableHeader.Length);
2630 + Status = AcpiTbVerifyChecksum (Table, TableLen);
2631 if (ACPI_FAILURE (Status))
2633 Status = AcCheckTextModeCorruption (Table);
2634 @@ -435,6 +437,7 @@ AcValidateTableHeader (
2636 long OriginalOffset;
2638 + UINT32 TableLength;
2642 @@ -464,11 +467,12 @@ AcValidateTableHeader (
2643 /* Validate table length against bytes remaining in the file */
2645 FileSize = CmGetFileSize (File);
2646 - if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
2647 + ACPI_MOVE_32_TO_32(&TableLength, &TableHeader.Length);
2648 + if (TableLength > (UINT32) (FileSize - TableOffset))
2650 fprintf (stderr, "Table [%4.4s] is too long for file - "
2651 "needs: 0x%.2X, remaining in file: 0x%.2X\n",
2652 - TableHeader.Signature, TableHeader.Length,
2653 + TableHeader.Signature, TableLength,
2654 (UINT32) (FileSize - TableOffset));
2655 return (AE_BAD_HEADER);
2657 Index: acpica-unix2-20181003/source/common/dmtable.c
2658 ===================================================================
2659 --- acpica-unix2-20181003.orig/source/common/dmtable.c
2660 +++ acpica-unix2-20181003/source/common/dmtable.c
2661 @@ -550,7 +550,7 @@ AcpiDmDumpDataTable (
2663 if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_FACS))
2665 - Length = Table->Length;
2666 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2667 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFacs);
2668 if (ACPI_FAILURE (Status))
2670 @@ -564,13 +564,14 @@ AcpiDmDumpDataTable (
2671 else if (ACPI_COMPARE_NAME (Table->Signature, ACPI_SIG_S3PT))
2673 Length = AcpiDmDumpS3pt (Table);
2674 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2679 * All other tables must use the common ACPI table header, dump it now
2681 - Length = Table->Length;
2682 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2683 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHeader);
2684 if (ACPI_FAILURE (Status))
2686 @@ -781,6 +782,7 @@ AcpiDmDumpTable (
2687 BOOLEAN LastOutputBlankLine = FALSE;
2689 char RepairedName[8];
2694 @@ -1177,8 +1179,9 @@ AcpiDmDumpTable (
2695 /* Checksum, display and validate */
2697 AcpiOsPrintf ("%2.2X", *Target);
2698 - Temp8 = AcpiDmGenerateChecksum (Table,
2699 - ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length,
2700 + ACPI_MOVE_32_TO_32(&Temp32,
2701 + &ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Length);
2702 + Temp8 = AcpiDmGenerateChecksum (Table, Temp32,
2703 ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum);
2705 if (Temp8 != ACPI_CAST_PTR (ACPI_TABLE_HEADER, Table)->Checksum)
2706 @@ -1243,14 +1246,14 @@ AcpiDmDumpTable (
2708 /* DMAR subtable types */
2710 - Temp16 = ACPI_GET16 (Target);
2711 + Val16 = ACPI_GET16 (Target);
2712 + ACPI_MOVE_16_TO_16(&Temp16, &Val16);
2713 if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
2715 Temp16 = ACPI_DMAR_TYPE_RESERVED;
2718 - AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2719 - AcpiDmDmarSubnames[Temp16]);
2720 + AcpiOsPrintf (UINT16_FORMAT, Temp16, AcpiDmDmarSubnames[Temp16]);
2723 case ACPI_DMT_DMAR_SCOPE:
2724 @@ -1341,14 +1344,14 @@ AcpiDmDumpTable (
2726 /* HEST subtable types */
2728 - Temp16 = ACPI_GET16 (Target);
2729 + Val16 = ACPI_GET16 (Target);
2730 + ACPI_MOVE_16_TO_16(&Temp16, &Val16);
2731 if (Temp16 > ACPI_HEST_TYPE_RESERVED)
2733 Temp16 = ACPI_HEST_TYPE_RESERVED;
2736 - AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2737 - AcpiDmHestSubnames[Temp16]);
2738 + AcpiOsPrintf (UINT16_FORMAT, Temp16, AcpiDmHestSubnames[Temp16]);
2741 case ACPI_DMT_HESTNTFY:
2742 @@ -1428,13 +1431,14 @@ AcpiDmDumpTable (
2744 /* NFIT subtable types */
2746 - Temp16 = ACPI_GET16 (Target);
2747 + Val16 = ACPI_GET16 (Target);
2748 + ACPI_MOVE_16_TO_16(&Temp16, &Val16);
2749 if (Temp16 > ACPI_NFIT_TYPE_RESERVED)
2751 Temp16 = ACPI_NFIT_TYPE_RESERVED;
2754 - AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
2755 + AcpiOsPrintf (UINT16_FORMAT, Temp16,
2756 AcpiDmNfitSubnames[Temp16]);
2759 Index: acpica-unix2-20181003/source/common/dmtables.c
2760 ===================================================================
2761 --- acpica-unix2-20181003.orig/source/common/dmtables.c
2762 +++ acpica-unix2-20181003/source/common/dmtables.c
2763 @@ -142,7 +142,9 @@ AdCreateTableHeader (
2764 ACPI_TABLE_HEADER *Table)
2770 + UINT32 CompilerRev;
2772 /* Reset globals for External statements */
2774 @@ -154,9 +156,10 @@ AdCreateTableHeader (
2776 AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE);
2778 + ACPI_MOVE_32_TO_32(&TableLen, &Table->Length);
2779 AcpiOsPrintf (" * Original Table Header:\n");
2780 AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature);
2781 - AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length);
2782 + AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", TableLen, TableLen);
2784 /* Print and validate the revision */
2786 @@ -188,7 +191,7 @@ AdCreateTableHeader (
2788 AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum);
2790 - Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
2791 + Checksum = AcpiTbChecksum (ACPI_CAST_PTR (UINT8, Table), TableLen);
2794 AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
2795 @@ -198,9 +201,11 @@ AdCreateTableHeader (
2796 AcpiOsPrintf ("\n");
2797 AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId);
2798 AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId);
2799 - AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
2800 + ACPI_MOVE_32_TO_32(&OemRev, &Table->OemRevision);
2801 + AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", OemRev, OemRev);
2802 AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId);
2803 - AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
2804 + ACPI_MOVE_32_TO_32(&CompilerRev, &Table->AslCompilerRevision);
2805 + AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", CompilerRev, CompilerRev);
2806 AcpiOsPrintf (" */\n");
2809 @@ -221,7 +226,7 @@ AdCreateTableHeader (
2811 "DefinitionBlock (\"\", \"%4.4s\", %hu, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
2812 Table->Signature, Table->Revision,
2813 - Table->OemId, Table->OemTableId, Table->OemRevision);
2814 + Table->OemId, Table->OemTableId, OemRev);
2818 @@ -396,7 +401,8 @@ AdParseTable (
2820 fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
2822 - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
2823 + ACPI_MOVE_32_TO_32(&AmlLength, &Table->Length);
2824 + AmlLength -= sizeof (ACPI_TABLE_HEADER);
2825 AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
2826 ASL_CV_INIT_FILETREE(Table, AmlStart, AmlLength);
2828 Index: acpica-unix2-20181003/source/common/dmtbdump.c
2829 ===================================================================
2830 --- acpica-unix2-20181003.orig/source/common/dmtbdump.c
2831 +++ acpica-unix2-20181003/source/common/dmtbdump.c
2832 @@ -277,6 +277,8 @@ AcpiDmDumpRsdt (
2840 /* Point to start of table pointer array */
2841 @@ -286,12 +288,14 @@ AcpiDmDumpRsdt (
2843 /* RSDT uses 32-bit pointers */
2845 - Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT32);
2846 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2847 + Entries = (Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT32);
2849 for (i = 0; i < Entries; i++)
2851 AcpiDmLineHeader2 (Offset, sizeof (UINT32), "ACPI Table Address", i);
2852 - AcpiOsPrintf ("%8.8X\n", Array[i]);
2853 + ACPI_MOVE_32_TO_32(&Address, &Array[i]);
2854 + AcpiOsPrintf ("%8.8X\n", Address);
2855 Offset += sizeof (UINT32);
2858 @@ -317,6 +321,8 @@ AcpiDmDumpXsdt (
2866 /* Point to start of table pointer array */
2867 @@ -326,12 +332,14 @@ AcpiDmDumpXsdt (
2869 /* XSDT uses 64-bit pointers */
2871 - Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT64);
2872 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2873 + Entries = (Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT64);
2875 for (i = 0; i < Entries; i++)
2877 AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
2878 - AcpiOsPrintf ("%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Array[i]));
2879 + ACPI_MOVE_64_TO_64(&Address, &Array[i]);
2880 + AcpiOsPrintf ("%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Address));
2881 Offset += sizeof (UINT64);
2884 @@ -358,12 +366,12 @@ AcpiDmDumpFadt (
2885 ACPI_TABLE_HEADER *Table)
2891 /* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
2893 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
2894 - AcpiDmTableInfoFadt1);
2895 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
2896 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFadt1);
2897 if (ACPI_FAILURE (Status))
2900 @@ -371,11 +379,9 @@ AcpiDmDumpFadt (
2902 /* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
2904 - if ((Table->Length > ACPI_FADT_V1_SIZE) &&
2905 - (Table->Length <= ACPI_FADT_V2_SIZE))
2906 + if ((Length > ACPI_FADT_V1_SIZE) && (Length <= ACPI_FADT_V2_SIZE))
2908 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
2909 - AcpiDmTableInfoFadt2);
2910 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFadt2);
2911 if (ACPI_FAILURE (Status))
2914 @@ -384,10 +390,9 @@ AcpiDmDumpFadt (
2916 /* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
2918 - else if (Table->Length > ACPI_FADT_V2_SIZE)
2919 + else if (Length > ACPI_FADT_V2_SIZE)
2921 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
2922 - AcpiDmTableInfoFadt3);
2923 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoFadt3);
2924 if (ACPI_FAILURE (Status))
2927 @@ -395,9 +400,9 @@ AcpiDmDumpFadt (
2929 /* Check for FADT revision 5 fields and up (ACPI 5.0+) */
2931 - if (Table->Length > ACPI_FADT_V3_SIZE)
2932 + if (Length > ACPI_FADT_V3_SIZE)
2934 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
2935 + Status = AcpiDmDumpTable (Length, 0, Table, 0,
2936 AcpiDmTableInfoFadt5);
2937 if (ACPI_FAILURE (Status))
2939 @@ -407,9 +412,9 @@ AcpiDmDumpFadt (
2941 /* Check for FADT revision 6 fields and up (ACPI 6.0+) */
2943 - if (Table->Length > ACPI_FADT_V3_SIZE)
2944 + if (Length > ACPI_FADT_V3_SIZE)
2946 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
2947 + Status = AcpiDmDumpTable (Length, 0, Table, 0,
2948 AcpiDmTableInfoFadt6);
2949 if (ACPI_FAILURE (Status))
2951 @@ -420,11 +425,11 @@ AcpiDmDumpFadt (
2953 /* Validate various fields in the FADT, including length */
2955 - AcpiTbCreateLocalFadt (Table, Table->Length);
2956 + AcpiTbCreateLocalFadt (Table, Length);
2958 /* Validate FADT length against the revision */
2960 - AcpiDmValidateFadtLength (Table->Revision, Table->Length);
2961 + AcpiDmValidateFadtLength (Table->Revision, Length);
2965 @@ -450,6 +455,7 @@ AcpiDmValidateFadtLength (
2968 UINT32 ExpectedLength;
2973 @@ -485,7 +491,8 @@ AcpiDmValidateFadtLength (
2977 - if (Length == ExpectedLength)
2978 + ACPI_MOVE_32_TO_32(&Tmp32, &Length);
2979 + if (Tmp32 == ExpectedLength)
2983 @@ -493,5 +500,5 @@ AcpiDmValidateFadtLength (
2985 "\n// ACPI Warning: FADT revision %X does not match length: "
2986 "found %X expected %X\n",
2987 - Revision, Length, ExpectedLength);
2988 + Revision, Tmp32, ExpectedLength);
2990 Index: acpica-unix2-20181003/source/common/dmtbdump1.c
2991 ===================================================================
2992 --- acpica-unix2-20181003.orig/source/common/dmtbdump1.c
2993 +++ acpica-unix2-20181003/source/common/dmtbdump1.c
2994 @@ -79,17 +79,21 @@ AcpiDmDumpAsf (
2995 UINT32 DataOffset = 0;
3002 /* No main table, only subtables */
3004 + ACPI_MOVE_32_TO_32(&Len, &Table->Length);
3005 Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Table, Offset);
3006 - while (Offset < Table->Length)
3007 + while (Offset < Len)
3009 /* Common subtable header */
3011 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
3012 - Subtable->Header.Length, AcpiDmTableInfoAsfHdr);
3013 + ACPI_MOVE_16_TO_16(&SubLen, &Subtable->Header.Length);
3014 + Status = AcpiDmDumpTable (Len, Offset, Subtable,
3015 + SubLen, AcpiDmTableInfoAsfHdr);
3016 if (ACPI_FAILURE (Status))
3019 @@ -146,8 +150,7 @@ AcpiDmDumpAsf (
3023 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
3024 - Subtable->Header.Length, InfoTable);
3025 + Status = AcpiDmDumpTable (Len, Offset, Subtable, SubLen, InfoTable);
3026 if (ACPI_FAILURE (Status))
3029 @@ -163,7 +166,7 @@ AcpiDmDumpAsf (
3030 for (i = 0; i < DataCount; i++)
3032 AcpiOsPrintf ("\n");
3033 - Status = AcpiDmDumpTable (Table->Length, DataOffset,
3034 + Status = AcpiDmDumpTable (Len, DataOffset,
3035 DataTable, DataLength, DataInfoTable);
3036 if (ACPI_FAILURE (Status))
3038 @@ -209,15 +212,14 @@ AcpiDmDumpAsf (
3040 /* Point to next subtable */
3042 - if (!Subtable->Header.Length)
3045 AcpiOsPrintf ("Invalid zero subtable header length\n");
3049 - Offset += Subtable->Header.Length;
3050 - Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Subtable,
3051 - Subtable->Header.Length);
3053 + Subtable = ACPI_ADD_PTR (ACPI_ASF_INFO, Subtable, SubLen);
3057 @@ -241,12 +243,13 @@ AcpiDmDumpCpep (
3060 ACPI_CPEP_POLLING *Subtable;
3061 - UINT32 Length = Table->Length;
3063 UINT32 Offset = sizeof (ACPI_TABLE_CPEP);
3068 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3069 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoCpep);
3070 if (ACPI_FAILURE (Status))
3072 @@ -256,7 +259,7 @@ AcpiDmDumpCpep (
3075 Subtable = ACPI_ADD_PTR (ACPI_CPEP_POLLING, Table, Offset);
3076 - while (Offset < Table->Length)
3077 + while (Offset < Length)
3079 AcpiOsPrintf ("\n");
3080 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3081 @@ -296,7 +299,10 @@ AcpiDmDumpCsrt (
3082 ACPI_CSRT_GROUP *Subtable;
3083 ACPI_CSRT_SHARED_INFO *SharedInfoTable;
3084 ACPI_CSRT_DESCRIPTOR *SubSubtable;
3085 - UINT32 Length = Table->Length;
3088 + UINT32 SubSubLength;
3089 + UINT32 SharedInfoLength;
3090 UINT32 Offset = sizeof (ACPI_TABLE_CSRT);
3092 UINT32 SubSubOffset;
3093 @@ -307,14 +313,16 @@ AcpiDmDumpCsrt (
3095 /* Subtables (Resource Groups) */
3097 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3098 Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset);
3099 - while (Offset < Table->Length)
3100 + while (Offset < Length)
3102 /* Resource group subtable */
3104 AcpiOsPrintf ("\n");
3105 + ACPI_MOVE_32_TO_32(&SubLength, &Subtable->Length);
3106 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3107 - Subtable->Length, AcpiDmTableInfoCsrt0);
3108 + SubLength, AcpiDmTableInfoCsrt0);
3109 if (ACPI_FAILURE (Status))
3112 @@ -334,19 +342,20 @@ AcpiDmDumpCsrt (
3116 - SubOffset += Subtable->SharedInfoLength;
3117 + ACPI_MOVE_32_TO_32(&SharedInfoLength, &Subtable->SharedInfoLength);
3118 + SubOffset += SharedInfoLength;
3120 /* Sub-Subtables (Resource Descriptors) */
3122 SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table,
3123 Offset + SubOffset);
3125 - while ((SubOffset < Subtable->Length) &&
3126 - ((Offset + SubOffset) < Table->Length))
3127 + while ((SubOffset < SubLength) && ((Offset + SubOffset) < Length))
3129 AcpiOsPrintf ("\n");
3130 + ACPI_MOVE_32_TO_32(&SubSubLength, &SubSubtable->Length);
3131 Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable,
3132 - SubSubtable->Length, AcpiDmTableInfoCsrt2);
3133 + SubSubLength, AcpiDmTableInfoCsrt2);
3134 if (ACPI_FAILURE (Status))
3137 @@ -356,7 +365,7 @@ AcpiDmDumpCsrt (
3139 /* Resource-specific info buffer */
3141 - InfoLength = SubSubtable->Length - SubSubOffset;
3142 + InfoLength = SubSubLength - SubSubOffset;
3145 Status = AcpiDmDumpTable (Length,
3146 @@ -371,16 +380,15 @@ AcpiDmDumpCsrt (
3148 /* Point to next sub-subtable */
3150 - SubOffset += SubSubtable->Length;
3151 + SubOffset += SubSubLength;
3152 SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubtable,
3153 - SubSubtable->Length);
3157 /* Point to next subtable */
3159 - Offset += Subtable->Length;
3160 - Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable,
3161 - Subtable->Length);
3162 + Offset += SubLength;
3163 + Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable, SubLength);
3167 @@ -404,16 +412,20 @@ AcpiDmDumpDbg2 (
3170 ACPI_DBG2_DEVICE *Subtable;
3171 - UINT32 Length = Table->Length;
3174 UINT32 Offset = sizeof (ACPI_TABLE_DBG2);
3177 UINT32 AbsoluteOffset;
3185 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3186 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDbg2);
3187 if (ACPI_FAILURE (Status))
3189 @@ -423,11 +435,12 @@ AcpiDmDumpDbg2 (
3192 Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Table, Offset);
3193 - while (Offset < Table->Length)
3194 + while (Offset < Length)
3196 AcpiOsPrintf ("\n");
3197 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
3198 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3199 - Subtable->Length, AcpiDmTableInfoDbg2Device);
3200 + SubLength, AcpiDmTableInfoDbg2Device);
3201 if (ACPI_FAILURE (Status))
3204 @@ -437,13 +450,13 @@ AcpiDmDumpDbg2 (
3206 for (i = 0; i < Subtable->RegisterCount; i++)
3208 - ArrayOffset = Subtable->BaseAddressOffset +
3209 - (sizeof (ACPI_GENERIC_ADDRESS) * i);
3210 + ACPI_MOVE_16_TO_16(&Tmp16, &Subtable->BaseAddressOffset);
3211 + ArrayOffset = Tmp16 + (sizeof (ACPI_GENERIC_ADDRESS) * i);
3212 AbsoluteOffset = Offset + ArrayOffset;
3213 Array = (UINT8 *) Subtable + ArrayOffset;
3215 Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
3216 - Subtable->Length, AcpiDmTableInfoDbg2Addr);
3217 + SubLength, AcpiDmTableInfoDbg2Addr);
3218 if (ACPI_FAILURE (Status))
3221 @@ -454,13 +467,13 @@ AcpiDmDumpDbg2 (
3223 for (i = 0; i < Subtable->RegisterCount; i++)
3225 - ArrayOffset = Subtable->AddressSizeOffset +
3226 - (sizeof (UINT32) * i);
3227 + ACPI_MOVE_16_TO_16(&Tmp16, &Subtable->AddressSizeOffset);
3228 + ArrayOffset = Tmp16 + (sizeof (UINT32) * i);
3229 AbsoluteOffset = Offset + ArrayOffset;
3230 Array = (UINT8 *) Subtable + ArrayOffset;
3232 Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
3233 - Subtable->Length, AcpiDmTableInfoDbg2Size);
3234 + SubLength, AcpiDmTableInfoDbg2Size);
3235 if (ACPI_FAILURE (Status))
3238 @@ -470,12 +483,13 @@ AcpiDmDumpDbg2 (
3239 /* Dump the Namestring (required) */
3241 AcpiOsPrintf ("\n");
3242 - ArrayOffset = Subtable->NamepathOffset;
3243 + ACPI_MOVE_16_TO_16(&Tmp16, &Subtable->NamepathOffset);
3244 + ArrayOffset = Tmp16;
3245 AbsoluteOffset = Offset + ArrayOffset;
3246 Array = (UINT8 *) Subtable + ArrayOffset;
3248 Status = AcpiDmDumpTable (Length, AbsoluteOffset, Array,
3249 - Subtable->Length, AcpiDmTableInfoDbg2Name);
3250 + SubLength, AcpiDmTableInfoDbg2Name);
3251 if (ACPI_FAILURE (Status))
3254 @@ -485,9 +499,10 @@ AcpiDmDumpDbg2 (
3256 if (Subtable->OemDataOffset)
3258 - Status = AcpiDmDumpTable (Length, Offset + Subtable->OemDataOffset,
3259 - Table, Subtable->OemDataLength,
3260 - AcpiDmTableInfoDbg2OemData);
3261 + ACPI_MOVE_16_TO_16(&Tmp16, &Subtable->OemDataOffset);
3262 + ACPI_MOVE_16_TO_16(&AlsoTmp16, &Subtable->OemDataLength);
3263 + Status = AcpiDmDumpTable (Length, Offset + Tmp16,
3264 + Table, AlsoTmp16, AcpiDmTableInfoDbg2OemData);
3265 if (ACPI_FAILURE (Status))
3268 @@ -496,9 +511,9 @@ AcpiDmDumpDbg2 (
3270 /* Point to next subtable */
3272 - Offset += Subtable->Length;
3273 + Offset += SubLength;
3274 Subtable = ACPI_ADD_PTR (ACPI_DBG2_DEVICE, Subtable,
3275 - Subtable->Length);
3280 @@ -522,17 +537,20 @@ AcpiDmDumpDmar (
3283 ACPI_DMAR_HEADER *Subtable;
3284 - UINT32 Length = Table->Length;
3287 UINT32 Offset = sizeof (ACPI_TABLE_DMAR);
3288 ACPI_DMTABLE_INFO *InfoTable;
3289 ACPI_DMAR_DEVICE_SCOPE *ScopeTable;
3298 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3299 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDmar);
3300 if (ACPI_FAILURE (Status))
3302 @@ -542,13 +560,14 @@ AcpiDmDumpDmar (
3305 Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
3306 - while (Offset < Table->Length)
3307 + while (Offset < Length)
3309 /* Common subtable header */
3311 AcpiOsPrintf ("\n");
3312 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
3313 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3314 - Subtable->Length, AcpiDmTableInfoDmarHdr);
3315 + SubLength, AcpiDmTableInfoDmarHdr);
3316 if (ACPI_FAILURE (Status))
3319 @@ -556,7 +575,8 @@ AcpiDmDumpDmar (
3321 AcpiOsPrintf ("\n");
3323 - switch (Subtable->Type)
3324 + ACPI_MOVE_16_TO_16(&SubType, &Subtable->Type);
3327 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
3329 @@ -591,12 +611,12 @@ AcpiDmDumpDmar (
3332 AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
3338 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3339 - Subtable->Length, InfoTable);
3340 + SubLength, InfoTable);
3341 if (ACPI_FAILURE (Status))
3344 @@ -605,8 +625,8 @@ AcpiDmDumpDmar (
3346 * Dump the optional device scope entries
3348 - if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
3349 - (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
3350 + if ((SubType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
3351 + (SubType == ACPI_DMAR_TYPE_NAMESPACE))
3353 /* These types do not support device scopes */
3355 @@ -614,7 +634,7 @@ AcpiDmDumpDmar (
3358 ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
3359 - while (ScopeOffset < Subtable->Length)
3360 + while (ScopeOffset < SubLength)
3362 AcpiOsPrintf ("\n");
3363 Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
3364 @@ -655,9 +675,8 @@ AcpiDmDumpDmar (
3366 /* Point to next subtable */
3368 - Offset += Subtable->Length;
3369 - Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
3370 - Subtable->Length);
3371 + Offset += SubLength;
3372 + Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable, SubLength);
3376 @@ -684,12 +703,15 @@ AcpiDmDumpDrtm (
3377 ACPI_DRTM_RESOURCE_LIST *DrtmRl;
3378 ACPI_DRTM_DPS_ID *DrtmDps;
3380 + UINT32 ValidatedCount;
3381 + UINT32 ResourceCount;
3387 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
3388 - AcpiDmTableInfoDrtm);
3389 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3390 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoDrtm);
3391 if (ACPI_FAILURE (Status))
3394 @@ -703,7 +725,7 @@ AcpiDmDumpDrtm (
3396 DrtmVtl = ACPI_ADD_PTR (ACPI_DRTM_VTABLE_LIST, Table, Offset);
3397 AcpiOsPrintf ("\n");
3398 - Status = AcpiDmDumpTable (Table->Length, Offset,
3399 + Status = AcpiDmDumpTable (Length, Offset,
3400 DrtmVtl, ACPI_OFFSET (ACPI_DRTM_VTABLE_LIST, ValidatedTables),
3401 AcpiDmTableInfoDrtm0);
3402 if (ACPI_FAILURE (Status))
3403 @@ -716,10 +738,11 @@ AcpiDmDumpDrtm (
3404 /* Dump Validated table addresses */
3407 - while ((Offset < Table->Length) &&
3408 - (DrtmVtl->ValidatedTableCount > Count))
3409 + ACPI_MOVE_32_TO_32(&ValidatedCount, &DrtmVtl->ValidatedTableCount);
3410 + while ((Offset < Length) &&
3411 + (ValidatedCount > Count))
3413 - Status = AcpiDmDumpTable (Table->Length, Offset,
3414 + Status = AcpiDmDumpTable (Length, Offset,
3415 ACPI_ADD_PTR (void, Table, Offset), sizeof (UINT64),
3416 AcpiDmTableInfoDrtm0a);
3417 if (ACPI_FAILURE (Status))
3418 @@ -735,7 +758,7 @@ AcpiDmDumpDrtm (
3420 DrtmRl = ACPI_ADD_PTR (ACPI_DRTM_RESOURCE_LIST, Table, Offset);
3421 AcpiOsPrintf ("\n");
3422 - Status = AcpiDmDumpTable (Table->Length, Offset,
3423 + Status = AcpiDmDumpTable (Length, Offset,
3424 DrtmRl, ACPI_OFFSET (ACPI_DRTM_RESOURCE_LIST, Resources),
3425 AcpiDmTableInfoDrtm1);
3426 if (ACPI_FAILURE (Status))
3427 @@ -748,10 +771,11 @@ AcpiDmDumpDrtm (
3428 /* Dump the Resource List */
3431 - while ((Offset < Table->Length) &&
3432 - (DrtmRl->ResourceCount > Count))
3433 + ACPI_MOVE_32_TO_32(&ResourceCount, &DrtmRl->ResourceCount);
3434 + while ((Offset < Length) &&
3435 + (ResourceCount > Count))
3437 - Status = AcpiDmDumpTable (Table->Length, Offset,
3438 + Status = AcpiDmDumpTable (Length, Offset,
3439 ACPI_ADD_PTR (void, Table, Offset),
3440 sizeof (ACPI_DRTM_RESOURCE), AcpiDmTableInfoDrtm1a);
3441 if (ACPI_FAILURE (Status))
3442 @@ -767,7 +791,7 @@ AcpiDmDumpDrtm (
3444 DrtmDps = ACPI_ADD_PTR (ACPI_DRTM_DPS_ID, Table, Offset);
3445 AcpiOsPrintf ("\n");
3446 - (void) AcpiDmDumpTable (Table->Length, Offset,
3447 + (void) AcpiDmDumpTable (Length, Offset,
3448 DrtmDps, sizeof (ACPI_DRTM_DPS_ID), AcpiDmTableInfoDrtm2);
3451 @@ -791,12 +815,13 @@ AcpiDmDumpEinj (
3454 ACPI_WHEA_HEADER *Subtable;
3455 - UINT32 Length = Table->Length;
3457 UINT32 Offset = sizeof (ACPI_TABLE_EINJ);
3462 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3463 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoEinj);
3464 if (ACPI_FAILURE (Status))
3466 @@ -806,7 +831,7 @@ AcpiDmDumpEinj (
3469 Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
3470 - while (Offset < Table->Length)
3471 + while (Offset < Length)
3473 AcpiOsPrintf ("\n");
3474 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3475 @@ -844,12 +869,13 @@ AcpiDmDumpErst (
3478 ACPI_WHEA_HEADER *Subtable;
3479 - UINT32 Length = Table->Length;
3481 UINT32 Offset = sizeof (ACPI_TABLE_ERST);
3486 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3487 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoErst);
3488 if (ACPI_FAILURE (Status))
3490 @@ -859,7 +885,7 @@ AcpiDmDumpErst (
3493 Subtable = ACPI_ADD_PTR (ACPI_WHEA_HEADER, Table, Offset);
3494 - while (Offset < Table->Length)
3495 + while (Offset < Length)
3497 AcpiOsPrintf ("\n");
3498 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3499 @@ -897,17 +923,19 @@ AcpiDmDumpFpdt (
3502 ACPI_FPDT_HEADER *Subtable;
3503 - UINT32 Length = Table->Length;
3505 UINT32 Offset = sizeof (ACPI_TABLE_FPDT);
3506 ACPI_DMTABLE_INFO *InfoTable;
3510 /* There is no main table (other than the standard ACPI header) */
3514 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3515 Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, Table, Offset);
3516 - while (Offset < Table->Length)
3517 + while (Offset < Length)
3519 /* Common subtable header */
3521 @@ -919,7 +947,8 @@ AcpiDmDumpFpdt (
3525 - switch (Subtable->Type)
3526 + ACPI_MOVE_16_TO_16(&Type, &Subtable->Type);
3529 case ACPI_FPDT_TYPE_BOOT:
3531 @@ -933,8 +962,7 @@ AcpiDmDumpFpdt (
3535 - AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n",
3537 + AcpiOsPrintf ("\n**** Unknown FPDT subtable type 0x%X\n\n", Type);
3539 /* Attempt to continue */
3541 @@ -982,16 +1010,19 @@ AcpiDmDumpGtdt (
3544 ACPI_GTDT_HEADER *Subtable;
3545 - UINT32 Length = Table->Length;
3548 UINT32 Offset = sizeof (ACPI_TABLE_GTDT);
3549 ACPI_DMTABLE_INFO *InfoTable;
3550 UINT32 SubtableLength;
3553 ACPI_GTDT_TIMER_ENTRY *GtxTable;
3558 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3559 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoGtdt);
3560 if (ACPI_FAILURE (Status))
3562 @@ -1001,7 +1032,7 @@ AcpiDmDumpGtdt (
3565 Subtable = ACPI_ADD_PTR (ACPI_GTDT_HEADER, Table, Offset);
3566 - while (Offset < Table->Length)
3567 + while (Offset < Length)
3569 /* Common subtable header */
3571 @@ -1019,8 +1050,9 @@ AcpiDmDumpGtdt (
3572 case ACPI_GTDT_TYPE_TIMER_BLOCK:
3574 SubtableLength = sizeof (ACPI_GTDT_TIMER_BLOCK);
3575 - GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
3576 + Tmp32 = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
3577 Subtable))->TimerCount;
3578 + ACPI_MOVE_32_TO_32(&GtCount, &Tmp32);
3580 InfoTable = AcpiDmTableInfoGtdt0;
3582 @@ -1041,8 +1073,9 @@ AcpiDmDumpGtdt (
3586 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
3587 Status = AcpiDmDumpTable (Length, Offset, Subtable,
3588 - Subtable->Length, InfoTable);
3589 + SubLength, InfoTable);
3590 if (ACPI_FAILURE (Status))
3593 @@ -1101,16 +1134,18 @@ AcpiDmDumpHest (
3596 ACPI_HEST_HEADER *Subtable;
3597 - UINT32 Length = Table->Length;
3599 UINT32 Offset = sizeof (ACPI_TABLE_HEST);
3600 ACPI_DMTABLE_INFO *InfoTable;
3601 UINT32 SubtableLength;
3603 ACPI_HEST_IA_ERROR_BANK *BankTable;
3609 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3610 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoHest);
3611 if (ACPI_FAILURE (Status))
3613 @@ -1120,10 +1155,11 @@ AcpiDmDumpHest (
3616 Subtable = ACPI_ADD_PTR (ACPI_HEST_HEADER, Table, Offset);
3617 - while (Offset < Table->Length)
3618 + while (Offset < Length)
3621 - switch (Subtable->Type)
3622 + ACPI_MOVE_16_TO_16(&SubType, &Subtable->Type);
3625 case ACPI_HEST_TYPE_IA32_CHECK:
3627 Index: acpica-unix2-20181003/source/common/dmtbdump2.c
3628 ===================================================================
3629 --- acpica-unix2-20181003.orig/source/common/dmtbdump2.c
3630 +++ acpica-unix2-20181003/source/common/dmtbdump2.c
3631 @@ -75,15 +75,21 @@ AcpiDmDumpIort (
3632 ACPI_IORT_SMMU *IortSmmu = NULL;
3635 + UINT16 NodeLength;
3637 ACPI_DMTABLE_INFO *InfoTable;
3643 + UINT32 MappingCount;
3644 + UINT32 CtxIntCount;
3645 + UINT32 PmuIntCount;
3649 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIort);
3650 + ACPI_MOVE_32_TO_32(&TableLen, &Table->Length);
3651 + Status = AcpiDmDumpTable (TableLen, 0, Table, 0, AcpiDmTableInfoIort);
3652 if (ACPI_FAILURE (Status))
3655 @@ -94,18 +100,19 @@ AcpiDmDumpIort (
3657 /* Dump the OptionalPadding (optional) */
3659 - if (Iort->NodeOffset > Offset)
3660 + ACPI_MOVE_32_TO_32(&NodeOffset, &Iort->NodeOffset);
3661 + if (NodeOffset > Offset)
3663 - Status = AcpiDmDumpTable (Table->Length, Offset, Table,
3664 - Iort->NodeOffset - Offset, AcpiDmTableInfoIortPad);
3665 + Status = AcpiDmDumpTable (TableLen, Offset, Table,
3666 + NodeOffset - Offset, AcpiDmTableInfoIortPad);
3667 if (ACPI_FAILURE (Status))
3673 - Offset = Iort->NodeOffset;
3674 - while (Offset < Table->Length)
3675 + ACPI_MOVE_32_TO_32(&Offset, &Iort->NodeOffset);
3676 + while (Offset < TableLen)
3678 /* Common subtable header */
3680 @@ -141,7 +148,8 @@ AcpiDmDumpIort (
3681 case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
3683 InfoTable = AcpiDmTableInfoIort2;
3684 - Length = IortNode->Length - NodeOffset;
3685 + ACPI_MOVE_16_TO_16(&NodeLength, &IortNode->Length);
3686 + Length = NodeLength - NodeOffset;
3689 case ACPI_IORT_NODE_SMMU:
3690 @@ -154,7 +162,8 @@ AcpiDmDumpIort (
3691 case ACPI_IORT_NODE_SMMU_V3:
3693 InfoTable = AcpiDmTableInfoIort4;
3694 - Length = IortNode->Length - NodeOffset;
3695 + ACPI_MOVE_16_TO_16(&NodeLength, &IortNode->Length);
3696 + Length = NodeLength - NodeOffset;
3699 case ACPI_IORT_NODE_PMCG:
3700 @@ -170,7 +179,8 @@ AcpiDmDumpIort (
3702 /* Attempt to continue */
3704 - if (!IortNode->Length)
3705 + ACPI_MOVE_16_TO_16(&NodeLength, &IortNode->Length);
3708 AcpiOsPrintf ("Invalid zero length IORT node\n");
3710 @@ -181,7 +191,7 @@ AcpiDmDumpIort (
3711 /* Dump the node subtable header */
3713 AcpiOsPrintf ("\n");
3714 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3715 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3716 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3718 if (ACPI_FAILURE (Status))
3719 @@ -201,9 +211,10 @@ AcpiDmDumpIort (
3723 - for (i = 0; i < IortItsGroup->ItsCount; i++)
3724 + ACPI_MOVE_32_TO_32(&ItsCount, &IortItsGroup->ItsCount);
3725 + for (i = 0; i < ItsCount; i++)
3727 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3728 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3729 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3730 4, AcpiDmTableInfoIort0a);
3732 @@ -215,11 +226,11 @@ AcpiDmDumpIort (
3734 /* Dump the Padding (optional) */
3736 - if (IortNode->Length > NodeOffset)
3737 + ACPI_MOVE_16_TO_16(&NodeLength, &IortNode->Length);
3738 + if (NodeLength > NodeOffset)
3740 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3741 - Table, IortNode->Length - NodeOffset,
3742 - AcpiDmTableInfoIort1a);
3743 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3744 + Table, NodeLength - NodeOffset, AcpiDmTableInfoIort1a);
3745 if (ACPI_FAILURE (Status))
3748 @@ -236,8 +247,8 @@ AcpiDmDumpIort (
3751 Length = 2 * sizeof (UINT64);
3752 - NodeOffset = IortSmmu->GlobalInterruptOffset;
3753 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3754 + ACPI_MOVE_32_TO_32(&NodeOffset, &IortSmmu->GlobalInterruptOffset);
3755 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3756 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3757 Length, AcpiDmTableInfoIort3a);
3758 if (ACPI_FAILURE (Status))
3759 @@ -245,10 +256,11 @@ AcpiDmDumpIort (
3763 - NodeOffset = IortSmmu->ContextInterruptOffset;
3764 - for (i = 0; i < IortSmmu->ContextInterruptCount; i++)
3765 + ACPI_MOVE_32_TO_32(&NodeOffset, &IortSmmu->ContextInterruptOffset);
3766 + ACPI_MOVE_32_TO_32(&CtxIntCount, &IortSmmu->ContextInterruptCount);
3767 + for (i = 0; i < CtxIntCount; i++)
3769 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3770 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3771 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3772 8, AcpiDmTableInfoIort3b);
3773 if (ACPI_FAILURE (Status))
3774 @@ -259,10 +271,11 @@ AcpiDmDumpIort (
3778 - NodeOffset = IortSmmu->PmuInterruptOffset;
3779 - for (i = 0; i < IortSmmu->PmuInterruptCount; i++)
3780 + ACPI_MOVE_32_TO_32(&NodeOffset, &IortSmmu->PmuInterruptOffset);
3781 + ACPI_MOVE_32_TO_32(&PmuIntCount, &IortSmmu->PmuInterruptCount);
3782 + for (i = 0; i < PmuIntCount; i++)
3784 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3785 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3786 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3787 8, AcpiDmTableInfoIort3c);
3788 if (ACPI_FAILURE (Status))
3789 @@ -282,12 +295,13 @@ AcpiDmDumpIort (
3791 /* Dump the ID mappings */
3793 - NodeOffset = IortNode->MappingOffset;
3794 - for (i = 0; i < IortNode->MappingCount; i++)
3795 + ACPI_MOVE_32_TO_32(&NodeOffset, &IortNode->MappingOffset);
3796 + ACPI_MOVE_32_TO_32(&MappingCount, &IortNode->MappingCount);
3797 + for (i = 0; i < MappingCount; i++)
3799 AcpiOsPrintf ("\n");
3800 Length = sizeof (ACPI_IORT_ID_MAPPING);
3801 - Status = AcpiDmDumpTable (Table->Length, Offset + NodeOffset,
3802 + Status = AcpiDmDumpTable (TableLen, Offset + NodeOffset,
3803 ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeOffset),
3804 Length, AcpiDmTableInfoIortMap);
3805 if (ACPI_FAILURE (Status))
3806 @@ -301,8 +315,9 @@ AcpiDmDumpIort (
3808 /* Point to next node subtable */
3810 - Offset += IortNode->Length;
3811 - IortNode = ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, IortNode->Length);
3812 + ACPI_MOVE_16_TO_16(&NodeLength, &IortNode->Length);
3813 + Offset += NodeLength;
3814 + IortNode = ACPI_ADD_PTR (ACPI_IORT_NODE, IortNode, NodeLength);
3818 @@ -333,11 +348,14 @@ AcpiDmDumpIvrs (
3819 ACPI_IVRS_DE_HEADER *DeviceEntry;
3820 ACPI_IVRS_HEADER *Subtable;
3821 ACPI_DMTABLE_INFO *InfoTable;
3828 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIvrs);
3829 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3830 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoIvrs);
3831 if (ACPI_FAILURE (Status))
3834 @@ -346,13 +364,14 @@ AcpiDmDumpIvrs (
3837 Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset);
3838 - while (Offset < Table->Length)
3839 + while (Offset < Length)
3841 /* Common subtable header */
3843 AcpiOsPrintf ("\n");
3844 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
3845 - Subtable->Length, AcpiDmTableInfoIvrsHdr);
3846 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
3847 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
3848 + SubLength, AcpiDmTableInfoIvrsHdr);
3849 if (ACPI_FAILURE (Status))
3852 @@ -379,7 +398,7 @@ AcpiDmDumpIvrs (
3854 /* Attempt to continue */
3856 - if (!Subtable->Length)
3859 AcpiOsPrintf ("Invalid zero length subtable\n");
3861 @@ -390,8 +409,8 @@ AcpiDmDumpIvrs (
3862 /* Dump the subtable */
3864 AcpiOsPrintf ("\n");
3865 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
3866 - Subtable->Length, InfoTable);
3867 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
3868 + SubLength, InfoTable);
3869 if (ACPI_FAILURE (Status))
3872 @@ -405,7 +424,7 @@ AcpiDmDumpIvrs (
3873 DeviceEntry = ACPI_ADD_PTR (ACPI_IVRS_DE_HEADER, Subtable,
3874 sizeof (ACPI_IVRS_HARDWARE));
3876 - while (EntryOffset < (Offset + Subtable->Length))
3877 + while (EntryOffset < (Offset + SubLength))
3879 AcpiOsPrintf ("\n");
3881 @@ -467,7 +486,7 @@ AcpiDmDumpIvrs (
3883 /* Dump the Device Entry */
3885 - Status = AcpiDmDumpTable (Table->Length, EntryOffset,
3886 + Status = AcpiDmDumpTable (Length, EntryOffset,
3887 DeviceEntry, EntryLength, InfoTable);
3888 if (ACPI_FAILURE (Status))
3890 @@ -483,8 +502,8 @@ AcpiDmDumpIvrs (
3892 /* Point to next subtable */
3894 - Offset += Subtable->Length;
3895 - Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Subtable, Subtable->Length);
3896 + Offset += SubLength;
3897 + Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Subtable, SubLength);
3901 @@ -510,7 +529,7 @@ AcpiDmDumpLpit (
3904 ACPI_LPIT_HEADER *Subtable;
3905 - UINT32 Length = Table->Length;
3907 UINT32 Offset = sizeof (ACPI_TABLE_LPIT);
3908 ACPI_DMTABLE_INFO *InfoTable;
3909 UINT32 SubtableLength;
3910 @@ -518,8 +537,9 @@ AcpiDmDumpLpit (
3914 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3915 Subtable = ACPI_ADD_PTR (ACPI_LPIT_HEADER, Table, Offset);
3916 - while (Offset < Table->Length)
3917 + while (Offset < Length)
3919 /* Common subtable header */
3921 @@ -583,13 +603,14 @@ AcpiDmDumpMadt (
3924 ACPI_SUBTABLE_HEADER *Subtable;
3925 - UINT32 Length = Table->Length;
3927 UINT32 Offset = sizeof (ACPI_TABLE_MADT);
3928 ACPI_DMTABLE_INFO *InfoTable;
3933 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
3934 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoMadt);
3935 if (ACPI_FAILURE (Status))
3937 @@ -599,7 +620,7 @@ AcpiDmDumpMadt (
3940 Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset);
3941 - while (Offset < Table->Length)
3942 + while (Offset < Length)
3944 /* Common subtable header */
3946 @@ -745,11 +766,13 @@ AcpiDmDumpMcfg (
3948 UINT32 Offset = sizeof (ACPI_TABLE_MCFG);
3949 ACPI_MCFG_ALLOCATION *Subtable;
3955 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMcfg);
3956 + ACPI_MOVE_32_TO_32(&Len, &Table->Length);
3957 + Status = AcpiDmDumpTable (Len, 0, Table, 0, AcpiDmTableInfoMcfg);
3958 if (ACPI_FAILURE (Status))
3961 @@ -758,17 +781,17 @@ AcpiDmDumpMcfg (
3964 Subtable = ACPI_ADD_PTR (ACPI_MCFG_ALLOCATION, Table, Offset);
3965 - while (Offset < Table->Length)
3966 + while (Offset < Len)
3968 - if (Offset + sizeof (ACPI_MCFG_ALLOCATION) > Table->Length)
3969 + if (Offset + sizeof (ACPI_MCFG_ALLOCATION) > Len)
3971 AcpiOsPrintf ("Warning: there are %u invalid trailing bytes\n",
3972 - sizeof (ACPI_MCFG_ALLOCATION) - (Offset - Table->Length));
3973 + sizeof (ACPI_MCFG_ALLOCATION) - (Offset - Len));
3977 AcpiOsPrintf ("\n");
3978 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
3979 + Status = AcpiDmDumpTable (Len, Offset, Subtable,
3980 sizeof (ACPI_MCFG_ALLOCATION), AcpiDmTableInfoMcfg0);
3981 if (ACPI_FAILURE (Status))
3983 @@ -802,6 +825,7 @@ AcpiDmDumpMpst (
3986 UINT32 Offset = sizeof (ACPI_TABLE_MPST);
3987 + ACPI_TABLE_MPST *Mpst;
3988 ACPI_MPST_POWER_NODE *Subtable0;
3989 ACPI_MPST_POWER_STATE *Subtable0A;
3990 ACPI_MPST_COMPONENT *Subtable0B;
3991 @@ -810,11 +834,13 @@ AcpiDmDumpMpst (
3992 UINT16 SubtableCount;
3993 UINT32 PowerStateCount;
3994 UINT32 ComponentCount;
4000 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMpst);
4001 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4002 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoMpst);
4003 if (ACPI_FAILURE (Status))
4006 @@ -822,13 +848,14 @@ AcpiDmDumpMpst (
4008 /* Subtable: Memory Power Node(s) */
4010 - SubtableCount = (ACPI_CAST_PTR (ACPI_TABLE_MPST, Table))->PowerNodeCount;
4011 + Mpst = ACPI_CAST_PTR (ACPI_TABLE_MPST, Table);
4012 + ACPI_MOVE_16_TO_16(&SubtableCount, &Mpst->PowerNodeCount);
4013 Subtable0 = ACPI_ADD_PTR (ACPI_MPST_POWER_NODE, Table, Offset);
4015 - while ((Offset < Table->Length) && SubtableCount)
4016 + while ((Offset < Length) && SubtableCount)
4018 AcpiOsPrintf ("\n");
4019 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0,
4020 + Status = AcpiDmDumpTable (Length, Offset, Subtable0,
4021 sizeof (ACPI_MPST_POWER_NODE), AcpiDmTableInfoMpst0);
4022 if (ACPI_FAILURE (Status))
4024 @@ -837,8 +864,8 @@ AcpiDmDumpMpst (
4026 /* Extract the sub-subtable counts */
4028 - PowerStateCount = Subtable0->NumPowerStates;
4029 - ComponentCount = Subtable0->NumPhysicalComponents;
4030 + ACPI_MOVE_32_TO_32(&PowerStateCount, &Subtable0->NumPowerStates);
4031 + ACPI_MOVE_32_TO_32(&ComponentCount, &Subtable0->NumPhysicalComponents);
4032 Offset += sizeof (ACPI_MPST_POWER_NODE);
4034 /* Sub-subtables - Memory Power State Structure(s) */
4035 @@ -849,7 +876,7 @@ AcpiDmDumpMpst (
4036 while (PowerStateCount)
4038 AcpiOsPrintf ("\n");
4039 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0A,
4040 + Status = AcpiDmDumpTable (Length, Offset, Subtable0A,
4041 sizeof (ACPI_MPST_POWER_STATE), AcpiDmTableInfoMpst0A);
4042 if (ACPI_FAILURE (Status))
4044 @@ -859,7 +886,7 @@ AcpiDmDumpMpst (
4047 Offset += sizeof (ACPI_MPST_POWER_STATE);
4051 /* Sub-subtables - Physical Component ID Structure(s) */
4053 @@ -872,7 +899,7 @@ AcpiDmDumpMpst (
4055 while (ComponentCount)
4057 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0B,
4058 + Status = AcpiDmDumpTable (Length, Offset, Subtable0B,
4059 sizeof (ACPI_MPST_COMPONENT), AcpiDmTableInfoMpst0B);
4060 if (ACPI_FAILURE (Status))
4062 @@ -887,17 +914,19 @@ AcpiDmDumpMpst (
4063 /* Point to next Memory Power Node subtable */
4066 + ACPI_MOVE_32_TO_32(&PowerStateCount, &Subtable0->NumPowerStates);
4067 + ACPI_MOVE_32_TO_32(&ComponentCount, &Subtable0->NumPhysicalComponents);
4068 Subtable0 = ACPI_ADD_PTR (ACPI_MPST_POWER_NODE, Subtable0,
4069 sizeof (ACPI_MPST_POWER_NODE) +
4070 - (sizeof (ACPI_MPST_POWER_STATE) * Subtable0->NumPowerStates) +
4071 - (sizeof (ACPI_MPST_COMPONENT) * Subtable0->NumPhysicalComponents));
4072 + (sizeof (ACPI_MPST_POWER_STATE) * PowerStateCount) +
4073 + (sizeof (ACPI_MPST_COMPONENT) * ComponentCount));
4076 /* Subtable: Count of Memory Power State Characteristic structures */
4078 AcpiOsPrintf ("\n");
4079 Subtable1 = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable0);
4080 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable1,
4081 + Status = AcpiDmDumpTable (Length, Offset, Subtable1,
4082 sizeof (ACPI_MPST_DATA_HDR), AcpiDmTableInfoMpst1);
4083 if (ACPI_FAILURE (Status))
4085 @@ -912,10 +941,10 @@ AcpiDmDumpMpst (
4086 Subtable2 = ACPI_ADD_PTR (ACPI_MPST_POWER_DATA, Subtable1,
4087 sizeof (ACPI_MPST_DATA_HDR));
4089 - while ((Offset < Table->Length) && SubtableCount)
4090 + while ((Offset < Length) && SubtableCount)
4092 AcpiOsPrintf ("\n");
4093 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable2,
4094 + Status = AcpiDmDumpTable (Length, Offset, Subtable2,
4095 sizeof (ACPI_MPST_POWER_DATA), AcpiDmTableInfoMpst2);
4096 if (ACPI_FAILURE (Status))
4098 @@ -948,11 +977,13 @@ AcpiDmDumpMsct (
4100 UINT32 Offset = sizeof (ACPI_TABLE_MSCT);
4101 ACPI_MSCT_PROXIMITY *Subtable;
4107 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMsct);
4108 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4109 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoMsct);
4110 if (ACPI_FAILURE (Status))
4113 @@ -961,12 +992,12 @@ AcpiDmDumpMsct (
4116 Subtable = ACPI_ADD_PTR (ACPI_MSCT_PROXIMITY, Table, Offset);
4117 - while (Offset < Table->Length)
4118 + while (Offset < Length)
4120 /* Common subtable header */
4122 AcpiOsPrintf ("\n");
4123 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4124 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4125 sizeof (ACPI_MSCT_PROXIMITY), AcpiDmTableInfoMsct0);
4126 if (ACPI_FAILURE (Status))
4128 @@ -1001,11 +1032,13 @@ AcpiDmDumpMtmr (
4130 UINT32 Offset = sizeof (ACPI_TABLE_MTMR);
4131 ACPI_MTMR_ENTRY *Subtable;
4137 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMtmr);
4138 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4139 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoMtmr);
4140 if (ACPI_FAILURE (Status))
4143 @@ -1014,12 +1047,12 @@ AcpiDmDumpMtmr (
4146 Subtable = ACPI_ADD_PTR (ACPI_MTMR_ENTRY, Table, Offset);
4147 - while (Offset < Table->Length)
4148 + while (Offset < Length)
4150 /* Common subtable header */
4152 AcpiOsPrintf ("\n");
4153 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4154 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4155 sizeof (ACPI_MTMR_ENTRY), AcpiDmTableInfoMtmr0);
4156 if (ACPI_FAILURE (Status))
4158 @@ -1061,11 +1094,17 @@ AcpiDmDumpNfit (
4159 ACPI_NFIT_SMBIOS *SmbiosInfo = NULL;
4160 ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
4162 + UINT32 TableLength;
4171 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoNfit);
4172 + ACPI_MOVE_32_TO_32(&TableLength, &Table->Length);
4173 + Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoNfit);
4174 if (ACPI_FAILURE (Status))
4177 @@ -1074,19 +1113,21 @@ AcpiDmDumpNfit (
4180 Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Table, Offset);
4181 - while (Offset < Table->Length)
4182 + while (Offset < TableLength)
4184 /* NFIT subtable header */
4186 AcpiOsPrintf ("\n");
4187 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4188 - Subtable->Length, AcpiDmTableInfoNfitHdr);
4189 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
4190 + Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
4191 + SubLength, AcpiDmTableInfoNfitHdr);
4192 if (ACPI_FAILURE (Status))
4197 - switch (Subtable->Type)
4198 + ACPI_MOVE_16_TO_16(&SubType, &Subtable->Type);
4201 case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
4203 @@ -1143,7 +1184,7 @@ AcpiDmDumpNfit (
4205 /* Attempt to continue */
4207 - if (!Subtable->Length)
4210 AcpiOsPrintf ("Invalid zero length subtable\n");
4212 @@ -1152,8 +1193,8 @@ AcpiDmDumpNfit (
4215 AcpiOsPrintf ("\n");
4216 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4217 - Subtable->Length, InfoTable);
4218 + Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
4219 + SubLength, InfoTable);
4220 if (ACPI_FAILURE (Status))
4223 @@ -1161,13 +1202,14 @@ AcpiDmDumpNfit (
4225 /* Per-subtable variable-length fields */
4227 - switch (Subtable->Type)
4230 case ACPI_NFIT_TYPE_INTERLEAVE:
4232 - for (i = 0; i < Interleave->LineCount; i++)
4233 + ACPI_MOVE_32_TO_32(&Count, &Interleave->LineCount);
4234 + for (i = 0; i < Count; i++)
4236 - Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
4237 + Status = AcpiDmDumpTable (TableLength, Offset + FieldOffset,
4238 &Interleave->LineOffset[i],
4239 sizeof (UINT32), AcpiDmTableInfoNfit2a);
4240 if (ACPI_FAILURE (Status))
4241 @@ -1181,12 +1223,11 @@ AcpiDmDumpNfit (
4243 case ACPI_NFIT_TYPE_SMBIOS:
4245 - Length = Subtable->Length -
4246 - sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8);
4247 + Length = SubLength - sizeof (ACPI_NFIT_SMBIOS) + sizeof (UINT8);
4251 - Status = AcpiDmDumpTable (Table->Length,
4252 + Status = AcpiDmDumpTable (TableLength,
4253 sizeof (ACPI_NFIT_SMBIOS) - sizeof (UINT8),
4255 Length, AcpiDmTableInfoNfit3a);
4256 @@ -1200,9 +1241,10 @@ AcpiDmDumpNfit (
4258 case ACPI_NFIT_TYPE_FLUSH_ADDRESS:
4260 - for (i = 0; i < Hint->HintCount; i++)
4261 + ACPI_MOVE_16_TO_16(&Count16, &Hint->HintCount);
4262 + for (i = 0; i < Count16; i++)
4264 - Status = AcpiDmDumpTable (Table->Length, Offset + FieldOffset,
4265 + Status = AcpiDmDumpTable (TableLength, Offset + FieldOffset,
4266 &Hint->HintAddress[i],
4267 sizeof (UINT64), AcpiDmTableInfoNfit6a);
4268 if (ACPI_FAILURE (Status))
4269 @@ -1221,8 +1263,8 @@ AcpiDmDumpNfit (
4271 /* Point to next subtable */
4273 - Offset += Subtable->Length;
4274 - Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Subtable, Subtable->Length);
4275 + Offset += SubLength;
4276 + Subtable = ACPI_ADD_PTR (ACPI_NFIT_HEADER, Subtable, SubLength);
4280 @@ -1247,12 +1289,13 @@ AcpiDmDumpPcct (
4282 ACPI_PCCT_SUBSPACE *Subtable;
4283 ACPI_DMTABLE_INFO *InfoTable;
4284 - UINT32 Length = Table->Length;
4286 UINT32 Offset = sizeof (ACPI_TABLE_PCCT);
4291 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4292 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoPcct);
4293 if (ACPI_FAILURE (Status))
4295 @@ -1262,7 +1305,7 @@ AcpiDmDumpPcct (
4298 Subtable = ACPI_ADD_PTR (ACPI_PCCT_SUBSPACE, Table, Offset);
4299 - while (Offset < Table->Length)
4300 + while (Offset < Length)
4302 /* Common subtable header */
4304 @@ -1402,16 +1445,21 @@ AcpiDmDumpPmtt (
4305 ACPI_PMTT_HEADER *MemSubtable;
4306 ACPI_PMTT_HEADER *DimmSubtable;
4307 ACPI_PMTT_DOMAIN *DomainArray;
4308 - UINT32 Length = Table->Length;
4310 UINT32 Offset = sizeof (ACPI_TABLE_PMTT);
4313 UINT32 DomainOffset;
4314 - UINT32 DomainCount;
4315 + UINT16 DomainCount;
4319 + UINT16 DimmLength;
4324 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4325 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoPmtt);
4326 if (ACPI_FAILURE (Status))
4328 @@ -1421,13 +1469,14 @@ AcpiDmDumpPmtt (
4331 Subtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER, Table, Offset);
4332 - while (Offset < Table->Length)
4333 + while (Offset < Length)
4335 /* Common subtable header */
4337 AcpiOsPrintf ("\n");
4338 + ACPI_MOVE_16_TO_16(&SubLength, &Subtable->Length);
4339 Status = AcpiDmDumpTable (Length, Offset, Subtable,
4340 - Subtable->Length, AcpiDmTableInfoPmttHdr);
4341 + SubLength, AcpiDmTableInfoPmttHdr);
4342 if (ACPI_FAILURE (Status))
4345 @@ -1446,7 +1495,7 @@ AcpiDmDumpPmtt (
4346 /* Dump the fixed-length portion of the subtable */
4348 Status = AcpiDmDumpTable (Length, Offset, Subtable,
4349 - Subtable->Length, AcpiDmTableInfoPmtt0);
4350 + SubLength, AcpiDmTableInfoPmtt0);
4351 if (ACPI_FAILURE (Status))
4354 @@ -1458,15 +1507,16 @@ AcpiDmDumpPmtt (
4355 MemSubtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER, Subtable,
4356 sizeof (ACPI_PMTT_SOCKET));
4358 - while (((Offset + MemOffset) < Table->Length) &&
4359 - (MemOffset < Subtable->Length))
4360 + while (((Offset + MemOffset) < Length) &&
4361 + (MemOffset < SubLength))
4363 /* Common subtable header */
4365 AcpiOsPrintf ("\n");
4366 + ACPI_MOVE_16_TO_16(&MemLength, &MemSubtable->Length);
4367 Status = AcpiDmDumpTable (Length,
4368 Offset + MemOffset, MemSubtable,
4369 - MemSubtable->Length, AcpiDmTableInfoPmttHdr);
4370 + MemLength, AcpiDmTableInfoPmttHdr);
4371 if (ACPI_FAILURE (Status))
4374 @@ -1486,7 +1536,7 @@ AcpiDmDumpPmtt (
4376 Status = AcpiDmDumpTable (Length,
4377 Offset + MemOffset, MemSubtable,
4378 - MemSubtable->Length, AcpiDmTableInfoPmtt1);
4379 + MemLength, AcpiDmTableInfoPmtt1);
4380 if (ACPI_FAILURE (Status))
4383 @@ -1494,13 +1544,14 @@ AcpiDmDumpPmtt (
4385 /* Walk the variable count of proximity domains */
4387 - DomainCount = ((ACPI_PMTT_CONTROLLER *) MemSubtable)->DomainCount;
4388 + Tmp16 = ((ACPI_PMTT_CONTROLLER *) MemSubtable)->DomainCount;
4389 + ACPI_MOVE_16_TO_16(&DomainCount, &Tmp16);
4390 DomainOffset = sizeof (ACPI_PMTT_CONTROLLER);
4391 DomainArray = ACPI_ADD_PTR (ACPI_PMTT_DOMAIN, MemSubtable,
4392 sizeof (ACPI_PMTT_CONTROLLER));
4394 - while (((Offset + MemOffset + DomainOffset) < Table->Length) &&
4395 - ((MemOffset + DomainOffset) < Subtable->Length) &&
4396 + while (((Offset + MemOffset + DomainOffset) < Length) &&
4397 + ((MemOffset + DomainOffset) < SubLength) &&
4400 Status = AcpiDmDumpTable (Length,
4401 @@ -1528,15 +1579,16 @@ AcpiDmDumpPmtt (
4402 DimmSubtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER, MemSubtable,
4405 - while (((Offset + MemOffset + DimmOffset) < Table->Length) &&
4406 - (DimmOffset < MemSubtable->Length))
4407 + while (((Offset + MemOffset + DimmOffset) < Length) &&
4408 + (DimmOffset < MemLength))
4410 /* Common subtable header */
4412 AcpiOsPrintf ("\n");
4413 + ACPI_MOVE_16_TO_16(&DimmLength, &DimmSubtable->Length);
4414 Status = AcpiDmDumpTable (Length,
4415 Offset + MemOffset + DimmOffset, DimmSubtable,
4416 - DimmSubtable->Length, AcpiDmTableInfoPmttHdr);
4417 + DimmLength, AcpiDmTableInfoPmttHdr);
4418 if (ACPI_FAILURE (Status))
4421 @@ -1556,7 +1608,7 @@ AcpiDmDumpPmtt (
4423 Status = AcpiDmDumpTable (Length,
4424 Offset + MemOffset + DimmOffset, DimmSubtable,
4425 - DimmSubtable->Length, AcpiDmTableInfoPmtt2);
4426 + DimmLength, AcpiDmTableInfoPmtt2);
4427 if (ACPI_FAILURE (Status))
4430 @@ -1564,23 +1616,22 @@ AcpiDmDumpPmtt (
4432 /* Point to next DIMM subtable */
4434 - DimmOffset += DimmSubtable->Length;
4435 + DimmOffset += DimmLength;
4436 DimmSubtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER,
4437 - DimmSubtable, DimmSubtable->Length);
4438 + DimmSubtable, DimmLength);
4441 /* Point to next Controller subtable */
4443 - MemOffset += MemSubtable->Length;
4444 + MemOffset += MemLength;
4445 MemSubtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER,
4446 - MemSubtable, MemSubtable->Length);
4447 + MemSubtable, MemLength);
4450 /* Point to next Socket subtable */
4452 - Offset += Subtable->Length;
4453 - Subtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER,
4454 - Subtable, Subtable->Length);
4455 + Offset += SubLength;
4456 + Subtable = ACPI_ADD_PTR (ACPI_PMTT_HEADER, Subtable, SubLength);
4460 @@ -1736,6 +1787,8 @@ AcpiDmDumpS3pt (
4461 ACPI_FPDT_HEADER *Subtable;
4462 ACPI_DMTABLE_INFO *InfoTable;
4463 ACPI_TABLE_S3PT *S3ptTable = ACPI_CAST_PTR (ACPI_TABLE_S3PT, Tables);
4469 @@ -1746,20 +1799,22 @@ AcpiDmDumpS3pt (
4473 + ACPI_MOVE_32_TO_32(&Length, &S3ptTable->Length);
4474 Subtable = ACPI_ADD_PTR (ACPI_FPDT_HEADER, S3ptTable, Offset);
4475 - while (Offset < S3ptTable->Length)
4476 + while (Offset < Length)
4478 /* Common subtable header */
4480 AcpiOsPrintf ("\n");
4481 - Status = AcpiDmDumpTable (S3ptTable->Length, Offset, Subtable,
4482 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4483 Subtable->Length, AcpiDmTableInfoS3ptHdr);
4484 if (ACPI_FAILURE (Status))
4489 - switch (Subtable->Type)
4490 + ACPI_MOVE_16_TO_16(&SubType, &Subtable->Type);
4493 case ACPI_S3PT_TYPE_RESUME:
4495 @@ -1774,7 +1829,7 @@ AcpiDmDumpS3pt (
4498 AcpiOsPrintf ("\n**** Unknown S3PT subtable type 0x%X\n",
4502 /* Attempt to continue */
4504 @@ -1787,7 +1842,7 @@ AcpiDmDumpS3pt (
4507 AcpiOsPrintf ("\n");
4508 - Status = AcpiDmDumpTable (S3ptTable->Length, Offset, Subtable,
4509 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4510 Subtable->Length, InfoTable);
4511 if (ACPI_FAILURE (Status))
4513 Index: acpica-unix2-20181003/source/common/dmtbdump3.c
4514 ===================================================================
4515 --- acpica-unix2-20181003.orig/source/common/dmtbdump3.c
4516 +++ acpica-unix2-20181003/source/common/dmtbdump3.c
4517 @@ -68,9 +68,11 @@ void
4519 ACPI_TABLE_HEADER *Table)
4523 - (void) AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER), Table,
4524 - Table->Length - sizeof (*Table), AcpiDmTableInfoSlic);
4525 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4526 + (void) AcpiDmDumpTable (Length, sizeof (ACPI_TABLE_HEADER), Table,
4527 + Length - sizeof (*Table), AcpiDmTableInfoSlic);
4531 @@ -93,14 +95,17 @@ AcpiDmDumpSlit (
4535 - UINT32 Localities;
4536 + UINT64 Localities;
4545 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSlit);
4546 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4547 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSlit);
4548 if (ACPI_FAILURE (Status))
4551 @@ -108,7 +113,8 @@ AcpiDmDumpSlit (
4553 /* Display the Locality NxN Matrix */
4555 - Localities = (UINT32) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->LocalityCount;
4556 + Tmp64 = (UINT64) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->LocalityCount;
4557 + ACPI_MOVE_64_TO_64(&Localities, &Tmp64);
4558 Offset = ACPI_OFFSET (ACPI_TABLE_SLIT, Entry[0]);
4559 Row = (UINT8 *) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->Entry;
4561 @@ -121,7 +127,7 @@ AcpiDmDumpSlit (
4563 /* Check for beyond EOT */
4565 - if (Offset >= Table->Length)
4566 + if (Offset >= Length)
4569 "\n**** Not enough room in table for all localities\n");
4570 @@ -173,11 +179,13 @@ AcpiDmDumpSrat (
4571 UINT32 Offset = sizeof (ACPI_TABLE_SRAT);
4572 ACPI_SUBTABLE_HEADER *Subtable;
4573 ACPI_DMTABLE_INFO *InfoTable;
4579 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSrat);
4580 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4581 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSrat);
4582 if (ACPI_FAILURE (Status))
4585 @@ -186,12 +194,12 @@ AcpiDmDumpSrat (
4588 Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset);
4589 - while (Offset < Table->Length)
4590 + while (Offset < Length)
4592 /* Common subtable header */
4594 AcpiOsPrintf ("\n");
4595 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4596 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4597 Subtable->Length, AcpiDmTableInfoSratHdr);
4598 if (ACPI_FAILURE (Status))
4600 @@ -240,7 +248,7 @@ AcpiDmDumpSrat (
4603 AcpiOsPrintf ("\n");
4604 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4605 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4606 Subtable->Length, InfoTable);
4607 if (ACPI_FAILURE (Status))
4609 @@ -277,13 +285,14 @@ AcpiDmDumpStao (
4613 - UINT32 Length = Table->Length;
4615 UINT32 StringLength;
4616 UINT32 Offset = sizeof (ACPI_TABLE_STAO);
4621 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4622 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao);
4623 if (ACPI_FAILURE (Status))
4625 @@ -292,7 +301,7 @@ AcpiDmDumpStao (
4627 /* The rest of the table consists of Namepath strings */
4629 - while (Offset < Table->Length)
4630 + while (Offset < Length)
4632 Namepath = ACPI_ADD_PTR (char, Table, Offset);
4633 StringLength = strlen (Namepath) + 1;
4634 @@ -334,11 +343,14 @@ AcpiDmDumpTcpa (
4635 ACPI_TABLE_TCPA_HDR *Subtable = ACPI_ADD_PTR (
4636 ACPI_TABLE_TCPA_HDR, Table, Offset);
4639 + UINT16 PlatformClass;
4644 - Status = AcpiDmDumpTable (Table->Length, 0, Table,
4645 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4646 + Status = AcpiDmDumpTable (Length, 0, Table,
4647 0, AcpiDmTableInfoTcpaHdr);
4648 if (ACPI_FAILURE (Status))
4650 @@ -349,18 +361,19 @@ AcpiDmDumpTcpa (
4651 * Examine the PlatformClass field to determine the table type.
4652 * Either a client or server table. Only one.
4654 - switch (CommonHeader->PlatformClass)
4655 + ACPI_MOVE_16_TO_16(&PlatformClass, &CommonHeader->PlatformClass);
4656 + switch (PlatformClass)
4658 case ACPI_TCPA_CLIENT_TABLE:
4660 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4661 - Table->Length - Offset, AcpiDmTableInfoTcpaClient);
4662 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4663 + Length - Offset, AcpiDmTableInfoTcpaClient);
4666 case ACPI_TCPA_SERVER_TABLE:
4668 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4669 - Table->Length - Offset, AcpiDmTableInfoTcpaServer);
4670 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4671 + Length - Offset, AcpiDmTableInfoTcpaServer);
4675 @@ -455,11 +468,13 @@ AcpiDmDumpVrtc (
4677 UINT32 Offset = sizeof (ACPI_TABLE_VRTC);
4678 ACPI_VRTC_ENTRY *Subtable;
4684 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoVrtc);
4685 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4686 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoVrtc);
4687 if (ACPI_FAILURE (Status))
4690 @@ -468,12 +483,12 @@ AcpiDmDumpVrtc (
4693 Subtable = ACPI_ADD_PTR (ACPI_VRTC_ENTRY, Table, Offset);
4694 - while (Offset < Table->Length)
4695 + while (Offset < Length)
4697 /* Common subtable header */
4699 AcpiOsPrintf ("\n");
4700 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4701 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4702 sizeof (ACPI_VRTC_ENTRY), AcpiDmTableInfoVrtc0);
4703 if (ACPI_FAILURE (Status))
4705 @@ -508,11 +523,13 @@ AcpiDmDumpWdat (
4707 UINT32 Offset = sizeof (ACPI_TABLE_WDAT);
4708 ACPI_WDAT_ENTRY *Subtable;
4714 - Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat);
4715 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4716 + Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWdat);
4717 if (ACPI_FAILURE (Status))
4720 @@ -521,12 +538,12 @@ AcpiDmDumpWdat (
4723 Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset);
4724 - while (Offset < Table->Length)
4725 + while (Offset < Length)
4727 /* Common subtable header */
4729 AcpiOsPrintf ("\n");
4730 - Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
4731 + Status = AcpiDmDumpTable (Length, Offset, Subtable,
4732 sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0);
4733 if (ACPI_FAILURE (Status))
4735 @@ -561,12 +578,13 @@ AcpiDmDumpWpbt (
4738 ACPI_TABLE_WPBT *Subtable;
4739 - UINT32 Length = Table->Length;
4741 UINT16 ArgumentsLength;
4744 /* Dump the main table */
4746 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
4747 Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoWpbt);
4748 if (ACPI_FAILURE (Status))
4750 @@ -576,10 +594,10 @@ AcpiDmDumpWpbt (
4751 /* Extract the arguments buffer length from the main table */
4753 Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
4754 - ArgumentsLength = Subtable->ArgumentsLength;
4755 + ACPI_MOVE_16_TO_16(&ArgumentsLength, &Subtable->ArgumentsLength);
4757 /* Dump the arguments buffer */
4759 - (void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
4760 + (void) AcpiDmDumpTable (Length, 0, Table, ArgumentsLength,
4761 AcpiDmTableInfoWpbt0);
4763 Index: acpica-unix2-20181003/source/compiler/dtfield.c
4764 ===================================================================
4765 --- acpica-unix2-20181003.orig/source/compiler/dtfield.c
4766 +++ acpica-unix2-20181003/source/compiler/dtfield.c
4767 @@ -359,7 +359,27 @@ DtCompileInteger (
4768 DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, AslGbl_MsgBuffer);
4771 - memcpy (Buffer, &Value, ByteLength);
4772 + switch (ByteLength) {
4774 + ACPI_MOVE_64_TO_8(Buffer, &Value);
4778 + ACPI_MOVE_64_TO_16(Buffer, &Value);
4782 + ACPI_MOVE_64_TO_32(Buffer, &Value);
4786 + ACPI_MOVE_64_TO_64(Buffer, &Value);
4790 + memcpy (Buffer, &Value, ByteLength);
4796 Index: acpica-unix2-20181003/source/compiler/dtsubtable.c
4797 ===================================================================
4798 --- acpica-unix2-20181003.orig/source/compiler/dtsubtable.c
4799 +++ acpica-unix2-20181003/source/compiler/dtsubtable.c
4800 @@ -378,6 +378,21 @@ DtSetSubtableLength (
4804 - memcpy (Subtable->LengthField, &Subtable->TotalLength,
4805 - Subtable->SizeOfLengthField);
4806 + switch(Subtable->SizeOfLengthField) {
4808 + ACPI_MOVE_32_TO_8(Subtable->LengthField, &Subtable->TotalLength);
4812 + ACPI_MOVE_32_TO_16(Subtable->LengthField, &Subtable->TotalLength);
4816 + ACPI_MOVE_32_TO_32(Subtable->LengthField, &Subtable->TotalLength);
4820 + memcpy (Subtable->LengthField, &Subtable->TotalLength,
4821 + Subtable->SizeOfLengthField);
4824 Index: acpica-unix2-20181003/source/compiler/dttable1.c
4825 ===================================================================
4826 --- acpica-unix2-20181003.orig/source/compiler/dttable1.c
4827 +++ acpica-unix2-20181003/source/compiler/dttable1.c
4828 @@ -281,6 +281,8 @@ DtCompileCsrt (
4829 DT_FIELD **PFieldList = (DT_FIELD **) List;
4830 UINT32 DescriptorCount;
4832 + ACPI_CSRT_GROUP *Pgrp;
4836 /* Subtables (Resource Groups) */
4837 @@ -299,12 +301,20 @@ DtCompileCsrt (
4839 /* Compute the number of resource descriptors */
4843 (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
4844 Subtable->Buffer))->Length -
4845 (ACPI_CAST_PTR (ACPI_CSRT_GROUP,
4846 Subtable->Buffer))->SharedInfoLength -
4847 sizeof (ACPI_CSRT_GROUP);
4849 + Pgrp = ACPI_CAST_PTR(ACPI_CSRT_GROUP, Subtable->Buffer);
4850 + ACPI_MOVE_32_TO_32(&Tmp32, &Pgrp->Length);
4851 + GroupLength = Tmp32;
4852 + ACPI_MOVE_32_TO_32(&Tmp32, &Pgrp->SharedInfoLength);
4853 + GroupLength -= Tmp32;
4854 + GroupLength -= sizeof (ACPI_CSRT_GROUP);
4856 DescriptorCount = (GroupLength /
4857 sizeof (ACPI_CSRT_DESCRIPTOR));
4858 @@ -392,6 +402,8 @@ DtCompileDbg2 (
4859 ACPI_DBG2_DEVICE *DeviceInfo;
4860 UINT16 CurrentOffset;
4867 @@ -408,10 +420,11 @@ DtCompileDbg2 (
4868 /* Main table fields */
4870 Dbg2Header = ACPI_CAST_PTR (ACPI_DBG2_HEADER, Subtable->Buffer);
4871 - Dbg2Header->InfoOffset = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF (
4872 + Tmp32 = sizeof (ACPI_TABLE_HEADER) + ACPI_PTR_DIFF (
4873 ACPI_ADD_PTR (UINT8, Dbg2Header, sizeof (ACPI_DBG2_HEADER)), Dbg2Header);
4874 + ACPI_MOVE_32_TO_32(&Dbg2Header->InfoOffset, &Tmp32);
4876 - SubtableCount = Dbg2Header->InfoCount;
4877 + ACPI_MOVE_32_TO_32(&SubtableCount, &Dbg2Header->InfoCount);
4878 DtPushSubtable (Subtable);
4880 /* Process all Device Information subtables (Count = InfoCount) */
4881 @@ -438,7 +451,7 @@ DtCompileDbg2 (
4883 /* BaseAddressRegister GAS array (Required, size is RegisterCount) */
4885 - DeviceInfo->BaseAddressOffset = CurrentOffset;
4886 + ACPI_MOVE_16_TO_16(&DeviceInfo->BaseAddressOffset, &CurrentOffset);
4887 for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++)
4889 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Addr,
4890 @@ -454,7 +467,7 @@ DtCompileDbg2 (
4892 /* AddressSize array (Required, size = RegisterCount) */
4894 - DeviceInfo->AddressSizeOffset = CurrentOffset;
4895 + ACPI_MOVE_16_TO_16(&DeviceInfo->AddressSizeOffset, &CurrentOffset);
4896 for (i = 0; *PFieldList && (i < DeviceInfo->RegisterCount); i++)
4898 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Size,
4899 @@ -470,7 +483,7 @@ DtCompileDbg2 (
4901 /* NamespaceString device identifier (Required, size = NamePathLength) */
4903 - DeviceInfo->NamepathOffset = CurrentOffset;
4904 + ACPI_MOVE_16_TO_16(&DeviceInfo->NamepathOffset, &CurrentOffset);
4905 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDbg2Name,
4907 if (ACPI_FAILURE (Status))
4908 @@ -480,8 +493,9 @@ DtCompileDbg2 (
4910 /* Update the device info header */
4912 - DeviceInfo->NamepathLength = (UINT16) Subtable->Length;
4913 - CurrentOffset += (UINT16) DeviceInfo->NamepathLength;
4914 + ACPI_MOVE_32_TO_16(&DeviceInfo->NamepathLength, &Subtable->Length);
4915 + ACPI_MOVE_16_TO_16(&Tmp16, &DeviceInfo->NamepathLength);
4916 + CurrentOffset += Tmp16;
4917 DtInsertSubtable (ParentTable, Subtable);
4919 /* OemData - Variable-length data (Optional, size = OemDataLength) */
4920 @@ -508,8 +522,8 @@ DtCompileDbg2 (
4922 if (Subtable && Subtable->Length)
4924 - DeviceInfo->OemDataOffset = CurrentOffset;
4925 - DeviceInfo->OemDataLength = (UINT16) Subtable->Length;
4926 + ACPI_MOVE_16_TO_16(&DeviceInfo->OemDataOffset, &CurrentOffset);
4927 + ACPI_MOVE_32_TO_16(&DeviceInfo->OemDataLength, &Subtable->Length);
4929 DtInsertSubtable (ParentTable, Subtable);
4931 @@ -549,6 +563,8 @@ DtCompileDmar (
4932 ACPI_DMAR_DEVICE_SCOPE *DmarDeviceScope;
4933 UINT32 DeviceScopeLength;
4934 UINT32 PciPathLength;
4939 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
4940 @@ -578,8 +594,11 @@ DtCompileDmar (
4941 DtPushSubtable (Subtable);
4943 DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer);
4944 + ACPI_MOVE_16_TO_16(&Tmp16, &DmarHeader->Length);
4945 + DmarHeader->Length = Tmp16;
4947 - switch (DmarHeader->Type)
4948 + ACPI_MOVE_16_TO_16(&HdrType, &DmarHeader->Type);
4951 case ACPI_DMAR_TYPE_HARDWARE_UNIT:
4953 @@ -626,8 +645,8 @@ DtCompileDmar (
4955 * Optional Device Scope subtables
4957 - if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
4958 - (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE))
4959 + if ((HdrType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
4960 + (HdrType == ACPI_DMAR_TYPE_NAMESPACE))
4962 /* These types do not support device scopes */
4964 @@ -637,7 +656,7 @@ DtCompileDmar (
4966 DtPushSubtable (Subtable);
4967 DeviceScopeLength = DmarHeader->Length - Subtable->Length -
4968 - ParentTable->Length;
4969 + ParentTable->Length;
4970 while (DeviceScopeLength)
4972 Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,
4973 @@ -762,7 +781,7 @@ DtCompileDrtm (
4977 - DrtmVtl->ValidatedTableCount = Count;
4978 + ACPI_MOVE_32_TO_32(&DrtmVtl->ValidatedTableCount, &Count);
4980 ParentTable = DtPeekSubtable ();
4982 @@ -800,7 +819,7 @@ DtCompileDrtm (
4986 - DrtmRl->ResourceCount = Count;
4987 + ACPI_MOVE_32_TO_32(&DrtmRl->ResourceCount, &Count);
4989 ParentTable = DtPeekSubtable ();
4991 @@ -894,6 +913,7 @@ DtCompileGtdt (
4992 ACPI_SUBTABLE_HEADER *GtdtHeader;
4993 ACPI_DMTABLE_INFO *InfoTable;
4995 + ACPI_GTDT_TIMER_BLOCK *TimerBlock;
4998 Status = DtCompileTable (PFieldList, AcpiDmTableInfoGtdt,
4999 @@ -960,8 +980,9 @@ DtCompileGtdt (
5000 DtPushSubtable (Subtable);
5001 ParentTable = DtPeekSubtable ();
5003 - GtCount = (ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
5004 - Subtable->Buffer - sizeof(ACPI_GTDT_HEADER)))->TimerCount;
5005 + TimerBlock = ACPI_CAST_PTR (ACPI_GTDT_TIMER_BLOCK,
5006 + Subtable->Buffer - sizeof(ACPI_GTDT_HEADER));
5007 + ACPI_MOVE_32_TO_32(&GtCount, &TimerBlock->TimerCount);
5011 @@ -1014,6 +1035,7 @@ DtCompileFpdt (
5012 ACPI_DMTABLE_INFO *InfoTable;
5013 DT_FIELD **PFieldList = (DT_FIELD **) List;
5014 DT_FIELD *SubtableStart;
5019 @@ -1032,7 +1054,8 @@ DtCompileFpdt (
5021 FpdtHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
5023 - switch (FpdtHeader->Type)
5024 + ACPI_MOVE_16_TO_16(&HdrType, &FpdtHeader->Type);
5027 case ACPI_FPDT_TYPE_BOOT:
5029 @@ -1090,6 +1113,7 @@ DtCompileHest (
5030 ACPI_DMTABLE_INFO *InfoTable;
5036 Status = DtCompileTable (PFieldList, AcpiDmTableInfoHest,
5037 @@ -1107,8 +1131,9 @@ DtCompileHest (
5038 /* Get subtable type */
5040 SubtableStart = *PFieldList;
5041 - DtCompileInteger ((UINT8 *) &Type, *PFieldList, 2, 0);
5042 + DtCompileInteger ((UINT8 *) &Tmp16, *PFieldList, 2, 0);
5044 + ACPI_MOVE_16_TO_16(&Type, &Tmp16);
5047 case ACPI_HEST_TYPE_IA32_CHECK:
5048 @@ -1458,11 +1483,13 @@ DtCompileIort (
5049 ACPI_IORT_SMMU *IortSmmu;
5052 + UINT32 NodeOffset;
5053 UINT32 IdMappingNumber;
5055 UINT32 ContextIrptNumber;
5056 UINT32 PmuIrptNumber;
5057 UINT32 PaddingLength;
5058 + UINT32 MappingOffset;
5061 ParentTable = DtPeekSubtable ();
5062 @@ -1488,7 +1515,7 @@ DtCompileIort (
5063 * Optionally allows the generic data types to be used for filling
5066 - Iort->NodeOffset = sizeof (ACPI_TABLE_IORT);
5067 + NodeOffset = sizeof (ACPI_TABLE_IORT);
5068 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIortPad,
5070 if (ACPI_FAILURE (Status))
5071 @@ -1498,7 +1525,7 @@ DtCompileIort (
5074 DtInsertSubtable (ParentTable, Subtable);
5075 - Iort->NodeOffset += Subtable->Length;
5076 + NodeOffset += Subtable->Length;
5080 @@ -1508,8 +1535,9 @@ DtCompileIort (
5084 - Iort->NodeOffset += PaddingLength;
5085 + NodeOffset += PaddingLength;
5087 + ACPI_MOVE_32_TO_32(&Iort->NodeOffset, &NodeOffset);
5091 @@ -1563,7 +1591,7 @@ DtCompileIort (
5095 - IortItsGroup->ItsCount = ItsNumber;
5096 + ACPI_MOVE_32_TO_32(&IortItsGroup->ItsCount, &ItsNumber);
5099 case ACPI_IORT_NODE_NAMED_COMPONENT:
5100 @@ -1597,15 +1625,16 @@ DtCompileIort (
5104 - if (NodeLength > IortNode->MappingOffset)
5105 + ACPI_MOVE_32_TO_32(&MappingOffset, &IortNode->MappingOffset);
5106 + if (NodeLength > MappingOffset)
5108 return (AE_BAD_DATA);
5111 - if (NodeLength < IortNode->MappingOffset)
5112 + if (NodeLength < MappingOffset)
5114 Status = DtCompilePadding (
5115 - IortNode->MappingOffset - NodeLength,
5116 + MappingOffset - NodeLength,
5118 if (ACPI_FAILURE (Status))
5120 @@ -1613,7 +1642,8 @@ DtCompileIort (
5123 DtInsertSubtable (ParentTable, Subtable);
5124 - NodeLength = IortNode->MappingOffset;
5125 + ACPI_MOVE_32_TO_32(&MappingOffset, &IortNode->MappingOffset);
5126 + NodeLength = MappingOffset;
5130 @@ -1646,7 +1676,7 @@ DtCompileIort (
5132 /* Compile global interrupt array */
5134 - IortSmmu->GlobalInterruptOffset = NodeLength;
5135 + ACPI_MOVE_32_TO_32(&IortSmmu->GlobalInterruptOffset, &NodeLength);
5136 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3a,
5138 if (ACPI_FAILURE (Status))
5139 @@ -1660,7 +1690,7 @@ DtCompileIort (
5140 /* Compile context interrupt array */
5142 ContextIrptNumber = 0;
5143 - IortSmmu->ContextInterruptOffset = NodeLength;
5144 + ACPI_MOVE_32_TO_32(&IortSmmu->ContextInterruptOffset, &NodeLength);
5147 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3b,
5148 @@ -1680,12 +1710,12 @@ DtCompileIort (
5149 ContextIrptNumber++;
5152 - IortSmmu->ContextInterruptCount = ContextIrptNumber;
5153 + ACPI_MOVE_32_TO_32(&IortSmmu->ContextInterruptCount, &ContextIrptNumber);
5155 /* Compile PMU interrupt array */
5158 - IortSmmu->PmuInterruptOffset = NodeLength;
5159 + ACPI_MOVE_32_TO_32(&IortSmmu->PmuInterruptOffset, &NodeLength);
5162 Status = DtCompileTable (PFieldList, AcpiDmTableInfoIort3c,
5163 @@ -1705,7 +1735,7 @@ DtCompileIort (
5167 - IortSmmu->PmuInterruptCount = PmuIrptNumber;
5168 + ACPI_MOVE_32_TO_32(&IortSmmu->PmuInterruptCount, &PmuIrptNumber);
5171 case ACPI_IORT_NODE_SMMU_V3:
5172 @@ -1742,7 +1772,7 @@ DtCompileIort (
5174 /* Compile Array of ID mappings */
5176 - IortNode->MappingOffset = NodeLength;
5177 + ACPI_MOVE_32_TO_32(&IortNode->MappingOffset, &NodeLength);
5178 IdMappingNumber = 0;
5181 @@ -1763,7 +1793,7 @@ DtCompileIort (
5185 - IortNode->MappingCount = IdMappingNumber;
5186 + ACPI_MOVE_32_TO_32(&IortNode->MappingCount, &IdMappingNumber);
5187 if (!IdMappingNumber)
5189 IortNode->MappingOffset = 0;
5190 @@ -1778,7 +1808,7 @@ DtCompileIort (
5194 - Iort->NodeCount = NodeNumber;
5195 + ACPI_MOVE_32_TO_32(&Iort->NodeCount, &NodeNumber);
5199 Index: acpica-unix2-20181003/source/compiler/dttable2.c
5200 ===================================================================
5201 --- acpica-unix2-20181003.orig/source/compiler/dttable2.c
5202 +++ acpica-unix2-20181003/source/compiler/dttable2.c
5203 @@ -345,7 +345,7 @@ DtCompileMpst (
5204 DtPushSubtable (Subtable);
5206 MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
5207 - SubtableCount = MpstChannelInfo->PowerNodeCount;
5208 + ACPI_MOVE_16_TO_16(&SubtableCount, &MpstChannelInfo->PowerNodeCount);
5210 while (*PFieldList && SubtableCount)
5212 @@ -363,8 +363,8 @@ DtCompileMpst (
5213 DtPushSubtable (Subtable);
5215 MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
5216 - PowerStateCount = MpstPowerNode->NumPowerStates;
5217 - ComponentCount = MpstPowerNode->NumPhysicalComponents;
5218 + ACPI_MOVE_32_TO_32(&PowerStateCount, &MpstPowerNode->NumPowerStates);
5219 + ACPI_MOVE_32_TO_32(&ComponentCount, &MpstPowerNode->NumPhysicalComponents);
5221 ParentTable = DtPeekSubtable ();
5223 @@ -517,6 +517,7 @@ DtCompileNfit (
5225 ACPI_NFIT_INTERLEAVE *Interleave = NULL;
5226 ACPI_NFIT_FLUSH_ADDRESS *Hint = NULL;
5231 @@ -550,7 +551,8 @@ DtCompileNfit (
5233 NfitHeader = ACPI_CAST_PTR (ACPI_NFIT_HEADER, Subtable->Buffer);
5235 - switch (NfitHeader->Type)
5236 + ACPI_MOVE_16_TO_16(&SubType, &NfitHeader->Type);
5239 case ACPI_NFIT_TYPE_SYSTEM_ADDRESS:
5241 @@ -610,7 +612,7 @@ DtCompileNfit (
5242 DtInsertSubtable (ParentTable, Subtable);
5245 - switch (NfitHeader->Type)
5248 case ACPI_NFIT_TYPE_INTERLEAVE:
5250 @@ -636,7 +638,7 @@ DtCompileNfit (
5254 - Interleave->LineCount = Count;
5255 + ACPI_MOVE_32_TO_32(&Interleave->LineCount, &Count);
5258 case ACPI_NFIT_TYPE_SMBIOS:
5259 @@ -681,7 +683,7 @@ DtCompileNfit (
5263 - Hint->HintCount = (UINT16) Count;
5264 + ACPI_MOVE_32_TO_16(&Hint->HintCount, &Count);
5268 @@ -957,7 +959,7 @@ DtCompilePmtt (
5270 PmttController = ACPI_CAST_PTR (ACPI_PMTT_CONTROLLER,
5271 (Subtable->Buffer - sizeof (ACPI_PMTT_HEADER)));
5272 - DomainCount = PmttController->DomainCount;
5273 + ACPI_MOVE_16_TO_16(&DomainCount, &PmttController->DomainCount);
5277 @@ -1177,6 +1179,7 @@ DtCompileS3pt (
5278 DT_SUBTABLE *ParentTable;
5279 ACPI_DMTABLE_INFO *InfoTable;
5280 DT_FIELD *SubtableStart;
5284 Status = DtCompileTable (PFieldList, AcpiDmTableInfoS3pt,
5285 @@ -1204,7 +1207,8 @@ DtCompileS3pt (
5287 S3ptHeader = ACPI_CAST_PTR (ACPI_FPDT_HEADER, Subtable->Buffer);
5289 - switch (S3ptHeader->Type)
5290 + ACPI_MOVE_16_TO_16(&HdrType, &S3ptHeader->Type);
5293 case ACPI_S3PT_TYPE_RESUME:
5295 @@ -1514,6 +1518,7 @@ DtCompileSlit (
5296 DT_FIELD *FieldList;
5298 UINT8 *LocalityBuffer;
5302 Status = DtCompileTable (PFieldList, AcpiDmTableInfoSlit,
5303 @@ -1526,7 +1531,8 @@ DtCompileSlit (
5304 ParentTable = DtPeekSubtable ();
5305 DtInsertSubtable (ParentTable, Subtable);
5307 - Localities = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
5308 + Tmp = *ACPI_CAST_PTR (UINT32, Subtable->Buffer);
5309 + ACPI_MOVE_32_TO_32(&Localities, &Tmp);
5310 LocalityBuffer = UtLocalCalloc (Localities);
5312 /* Compile each locality buffer */
5313 @@ -1720,6 +1726,7 @@ DtCompileTcpa (
5314 ACPI_TABLE_TCPA_HDR *TcpaHeader;
5315 DT_SUBTABLE *ParentTable;
5320 /* Compile the main table */
5321 @@ -1740,7 +1747,8 @@ DtCompileTcpa (
5323 TcpaHeader = ACPI_CAST_PTR (ACPI_TABLE_TCPA_HDR, ParentTable->Buffer);
5325 - switch (TcpaHeader->PlatformClass)
5326 + ACPI_MOVE_16_TO_16(&PlatClass, &TcpaHeader->PlatformClass);
5327 + switch (PlatClass)
5329 case ACPI_TCPA_CLIENT_TABLE:
5331 @@ -2039,6 +2047,9 @@ DtCompileWpbt (
5332 ACPI_TABLE_WPBT *Table;
5340 /* Compile the main table */
5341 @@ -2066,7 +2077,16 @@ DtCompileWpbt (
5343 Length = (UINT16) Subtable->TotalLength;
5344 Table = ACPI_CAST_PTR (ACPI_TABLE_WPBT, ParentTable->Buffer);
5345 - Table->ArgumentsLength = Length;
5346 + ACPI_MOVE_16_TO_16(&Table->ArgumentsLength, &Length);
5348 + /* The arguments are in Unicode, so make sure the byte order is correct */
5349 + Ptr16 = (UINT16 *)Subtable->Buffer;
5350 + for (ii = 0; ii < Length; ii++)
5352 + ACPI_MOVE_16_TO_16(&Tmp16, Ptr16);
5357 ParentTable = DtPeekSubtable ();
5358 DtInsertSubtable (ParentTable, Subtable);
5359 Index: acpica-unix2-20181003/source/components/disassembler/dmbuffer.c
5360 ===================================================================
5361 --- acpica-unix2-20181003.orig/source/components/disassembler/dmbuffer.c
5362 +++ acpica-unix2-20181003/source/components/disassembler/dmbuffer.c
5363 @@ -204,7 +204,7 @@ AcpiDmByteList (
5366 ByteData = Op->Named.Data;
5367 - ByteCount = (UINT32) Op->Common.Value.Integer;
5368 + ByteCount = (UINT32) Op->Common.Value.Size;
5371 * The byte list belongs to a buffer, and can be produced by either
5372 @@ -304,7 +304,8 @@ AcpiDmIsUuidBuffer (
5373 /* Extract the byte list info */
5375 ByteData = NextOp->Named.Data;
5376 - ByteCount = (UINT32) NextOp->Common.Value.Integer;
5377 + /* ByteCount = (UINT32) NextOp->Common.Value.Integer; */
5378 + ByteCount = (UINT32) NextOp->Common.Value.Size;
5380 /* Byte count must be exactly 16 */
5382 @@ -424,7 +425,8 @@ AcpiDmIsUnicodeBuffer (
5383 /* Extract the byte list info */
5385 ByteData = NextOp->Named.Data;
5386 - ByteCount = (UINT32) NextOp->Common.Value.Integer;
5387 + /* ByteCount = (UINT32) NextOp->Common.Value.Integer; */
5388 + ByteCount = (UINT32) NextOp->Common.Value.Size;
5389 WordCount = ACPI_DIV_2 (ByteCount);
5392 @@ -852,19 +854,22 @@ AcpiDmUnicode (
5399 /* Extract the buffer info as a WORD buffer */
5401 WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data);
5402 - WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer));
5403 + WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Size));
5405 /* Write every other byte as an ASCII character */
5407 AcpiOsPrintf ("\"");
5408 for (i = 0; i < (WordCount - 1); i++)
5410 - OutputValue = (int) WordData[i];
5411 + /* OutputValue = (int) WordData[i]; */
5412 + ACPI_MOVE_16_TO_16(&Tmp16, &WordData[i]);
5413 + OutputValue = (int) Tmp16;
5415 /* Handle values that must be escaped */
5417 @@ -973,16 +978,18 @@ AcpiDmCheckForHardwareId (
5418 ACPI_PARSE_OBJECT *Op)
5422 ACPI_PARSE_OBJECT *NextOp;
5425 /* Get the NameSegment */
5427 - Name = AcpiPsGetName (Op);
5429 + TmpName = AcpiPsGetName (Op);
5434 + ACPI_MOVE_32_TO_32(&Name, &TmpName);
5436 NextOp = AcpiPsGetDepthNext (NULL, Op);
5438 Index: acpica-unix2-20181003/source/components/disassembler/dmopcode.c
5439 ===================================================================
5440 --- acpica-unix2-20181003.orig/source/components/disassembler/dmopcode.c
5441 +++ acpica-unix2-20181003/source/components/disassembler/dmopcode.c
5442 @@ -244,6 +244,7 @@ AcpiDmPredefinedDescription (
5444 int LastCharIsDigit;
5445 int LastCharsAreHex;
5446 + char TmpName[ACPI_NAME_SIZE + 1];
5450 @@ -261,7 +262,9 @@ AcpiDmPredefinedDescription (
5452 /* Predefined name must start with an underscore */
5454 - NameString = ACPI_CAST_PTR (char, &Op->Named.Name);
5455 + memset(TmpName, 0, ACPI_NAME_SIZE + 1);
5456 + ACPI_MOVE_32_TO_32(TmpName, &Op->Named.Name);
5457 + NameString = TmpName;
5458 if (NameString[0] != '_')
5461 @@ -880,25 +883,29 @@ AcpiDmDisassembleOneOp (
5462 AcpiDmNamestring (Op->Common.Value.Name);
5465 - case AML_INT_NAMEDFIELD_OP:
5466 + case AML_INT_NAMEDFIELD_OP: {
5468 - Length = AcpiDmDumpName (Op->Named.Name);
5471 + ACPI_MOVE_32_TO_32(&TmpName, &Op->Named.Name);
5472 + Length = AcpiDmDumpName (TmpName);
5475 ASL_CV_PRINT_ONE_COMMENT (Op, AML_NAMECOMMENT, NULL, 0);
5476 AcpiOsPrintf ("%*.s %u", (unsigned) (5 - Length), " ",
5477 - (UINT32) Op->Common.Value.Integer);
5478 + (UINT32) Op->Common.Value.Size);
5480 AcpiDmCommaIfFieldMember (Op);
5482 - Info->BitOffset += (UINT32) Op->Common.Value.Integer;
5483 + Info->BitOffset += (UINT32) Op->Common.Value.Size;
5487 case AML_INT_RESERVEDFIELD_OP:
5489 /* Offset() -- Must account for previous offsets */
5491 - Offset = (UINT32) Op->Common.Value.Integer;
5492 + Offset = Op->Common.Value.Size;
5493 Info->BitOffset += Offset;
5495 if (Info->BitOffset % 8 == 0)
5496 @@ -942,10 +949,15 @@ AcpiDmDisassembleOneOp (
5498 if (Child->Common.AmlOpcode == AML_INT_BYTELIST_OP)
5500 + /* UINT64 Tmp64; */
5502 AcpiOsPrintf ("\n");
5504 Aml = Child->Named.Data;
5506 Length = (UINT32) Child->Common.Value.Integer;
5508 + Length = (UINT32) Child->Common.Value.Size;
5511 Info->MappingOp = Op;
5512 Index: acpica-unix2-20181003/source/components/disassembler/dmresrcl.c
5513 ===================================================================
5514 --- acpica-unix2-20181003.orig/source/components/disassembler/dmresrcl.c
5515 +++ acpica-unix2-20181003/source/components/disassembler/dmresrcl.c
5516 @@ -141,7 +141,8 @@ AcpiDmMemoryFields (
5524 for (i = 0; i < 4; i++)
5526 @@ -151,14 +152,14 @@ AcpiDmMemoryFields (
5530 - AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
5531 - AcpiDmMemoryNames[i]);
5532 + ACPI_MOVE_16_TO_16(&Tmp16, &(ACPI_CAST_PTR (UINT16, Source)[i]));
5533 + AcpiDmDumpInteger16 (Tmp16, AcpiDmMemoryNames[i]);
5538 - AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
5539 - AcpiDmMemoryNames[i]);
5540 + ACPI_MOVE_32_TO_32(&Tmp32, &(ACPI_CAST_PTR (UINT32, Source)[i]));
5541 + AcpiDmDumpInteger32 (Tmp32, AcpiDmMemoryNames[i]);
5545 @@ -190,7 +191,9 @@ AcpiDmAddressFields (
5554 AcpiOsPrintf ("\n");
5556 @@ -202,20 +205,20 @@ AcpiDmAddressFields (
5560 - AcpiDmDumpInteger16 (ACPI_CAST_PTR (UINT16, Source)[i],
5561 - AcpiDmAddressNames[i]);
5562 + ACPI_MOVE_16_TO_16(&Tmp16, &(ACPI_CAST_PTR (UINT16, Source)[i]));
5563 + AcpiDmDumpInteger16 (Tmp16, AcpiDmAddressNames[i]);
5568 - AcpiDmDumpInteger32 (ACPI_CAST_PTR (UINT32, Source)[i],
5569 - AcpiDmAddressNames[i]);
5570 + ACPI_MOVE_32_TO_32(&Tmp32, &(ACPI_CAST_PTR (UINT32, Source)[i]));
5571 + AcpiDmDumpInteger32 (Tmp32, AcpiDmAddressNames[i]);
5576 - AcpiDmDumpInteger64 (ACPI_CAST_PTR (UINT64, Source)[i],
5577 - AcpiDmAddressNames[i]);
5578 + ACPI_MOVE_64_TO_64(&Tmp64, &(ACPI_CAST_PTR (UINT64, Source)[i]));
5579 + AcpiDmDumpInteger64 (Tmp64, AcpiDmAddressNames[i]);
5583 @@ -868,6 +871,7 @@ AcpiDmFixedMemory32Descriptor (
5589 /* Dump name and read/write flag */
5591 @@ -876,12 +880,12 @@ AcpiDmFixedMemory32Descriptor (
5592 AcpiGbl_RwDecode [ACPI_GET_1BIT_FLAG (Resource->FixedMemory32.Flags)]);
5594 AcpiDmIndent (Level + 1);
5595 - AcpiDmDumpInteger32 (Resource->FixedMemory32.Address,
5597 + ACPI_MOVE_32_TO_32(&Tmp, &Resource->FixedMemory32.Address);
5598 + AcpiDmDumpInteger32 (Tmp, "Address Base");
5600 AcpiDmIndent (Level + 1);
5601 - AcpiDmDumpInteger32 (Resource->FixedMemory32.AddressLength,
5602 - "Address Length");
5603 + ACPI_MOVE_32_TO_32(&Tmp, &Resource->FixedMemory32.AddressLength);
5604 + AcpiDmDumpInteger32 (Tmp, "Address Length");
5606 /* Insert a descriptor name */
5608 @@ -913,6 +917,7 @@ AcpiDmGenericRegisterDescriptor (
5614 AcpiDmIndent (Level);
5615 AcpiOsPrintf ("Register (");
5616 @@ -926,7 +931,9 @@ AcpiDmGenericRegisterDescriptor (
5617 AcpiDmDumpInteger8 (Resource->GenericReg.BitOffset, "Bit Offset");
5619 AcpiDmIndent (Level + 1);
5620 - AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address");
5621 + /* AcpiDmDumpInteger64 (Resource->GenericReg.Address, "Address"); */
5622 + ACPI_MOVE_64_TO_64(&Tmp64, &Resource->GenericReg.Address);
5623 + AcpiDmDumpInteger64 (Tmp64, "Address");
5625 /* Optional field for ACPI 3.0 */
5627 @@ -972,7 +979,7 @@ AcpiDmInterruptDescriptor (
5634 AcpiDmIndent (Level);
5635 AcpiOsPrintf ("Interrupt (%s, %s, %s, %s, ",
5636 @@ -986,10 +993,11 @@ AcpiDmInterruptDescriptor (
5637 * list. Must compute length based on length of the list. First xrupt
5638 * is included in the struct (reason for -1 below)
5640 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->ExtendedIrq.ResourceLength);
5641 AcpiDmResourceSource (Resource,
5642 sizeof (AML_RESOURCE_EXTENDED_IRQ) +
5643 ((UINT32) Resource->ExtendedIrq.InterruptCount - 1) * sizeof (UINT32),
5644 - Resource->ExtendedIrq.ResourceLength);
5647 /* Insert a descriptor name */
5649 @@ -1002,9 +1010,12 @@ AcpiDmInterruptDescriptor (
5650 AcpiOsPrintf ("{\n");
5651 for (i = 0; i < Resource->ExtendedIrq.InterruptCount; i++)
5653 + UINT32 Tmp32, Val32;
5655 AcpiDmIndent (Level + 1);
5656 - AcpiOsPrintf ("0x%8.8X,\n",
5657 - (UINT32) Resource->ExtendedIrq.Interrupts[i]);
5658 + Val32 = (UINT32) Resource->ExtendedIrq.Interrupts[i];
5659 + ACPI_MOVE_32_TO_32(&Tmp32, &Val32);
5660 + AcpiOsPrintf ("0x%8.8X,\n", Tmp32);
5663 AcpiDmIndent (Level);
5664 Index: acpica-unix2-20181003/source/components/disassembler/dmresrcl2.c
5665 ===================================================================
5666 --- acpica-unix2-20181003.orig/source/components/disassembler/dmresrcl2.c
5667 +++ acpica-unix2-20181003/source/components/disassembler/dmresrcl2.c
5668 @@ -191,22 +191,24 @@ AcpiDmGpioCommon (
5669 char *DeviceName = NULL;
5675 /* ResourceSource, ResourceSourceIndex, ResourceType */
5677 AcpiDmIndent (Level + 1);
5678 - if (Resource->Gpio.ResSourceOffset)
5679 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.ResSourceOffset);
5682 - DeviceName = ACPI_ADD_PTR (char,
5683 - Resource, Resource->Gpio.ResSourceOffset),
5684 + DeviceName = ACPI_ADD_PTR (char, Resource, Tmp16),
5685 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
5688 AcpiOsPrintf (", ");
5689 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
5690 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.Flags);
5691 AcpiOsPrintf ("%s, ",
5692 - AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
5693 + AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Tmp16)]);
5695 /* Insert a descriptor name */
5697 @@ -215,15 +217,16 @@ AcpiDmGpioCommon (
5699 /* Dump the vendor data */
5701 - if (Resource->Gpio.VendorOffset)
5702 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.VendorOffset);
5705 AcpiOsPrintf ("\n");
5706 AcpiDmIndent (Level + 1);
5707 - VendorData = ACPI_ADD_PTR (UINT8, Resource,
5708 - Resource->Gpio.VendorOffset);
5709 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.VendorOffset);
5710 + VendorData = ACPI_ADD_PTR (UINT8, Resource, Tmp16);
5712 - AcpiDmDumpRawDataBuffer (VendorData,
5713 - Resource->Gpio.VendorLength, Level);
5714 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.VendorLength);
5715 + AcpiDmDumpRawDataBuffer (VendorData, Tmp16, Level);
5718 AcpiOsPrintf (")\n");
5719 @@ -233,17 +236,25 @@ AcpiDmGpioCommon (
5720 AcpiDmIndent (Level + 1);
5721 AcpiOsPrintf ("{ // Pin list\n");
5724 PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
5725 Resource->Gpio.PinTableOffset)) /
5728 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.ResSourceOffset);
5729 + PinCount = (UINT32) Tmp16;
5730 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.PinTableOffset);
5731 + PinCount -= (UINT32) Tmp16;
5732 + PinCount /= sizeof (UINT16);
5734 - PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
5735 - Resource->Gpio.PinTableOffset);
5736 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.PinTableOffset);
5737 + PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource, Tmp16);
5739 for (i = 0; i < PinCount; i++)
5741 AcpiDmIndent (Level + 2);
5742 - AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
5743 + ACPI_MOVE_16_TO_16(&Tmp16, &PinList[i]);
5744 + AcpiOsPrintf ("0x%4.4X%s\n", Tmp16,
5745 ((i + 1) < PinCount) ? "," : "");
5748 @@ -277,16 +288,18 @@ AcpiDmGpioIntDescriptor (
5754 /* Dump the GpioInt-specific portion of the descriptor */
5756 /* EdgeLevel, ActiveLevel, Shared */
5758 AcpiDmIndent (Level);
5759 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.IntFlags);
5760 AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
5761 - AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
5762 - AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
5763 - AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
5764 + AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Tmp16)],
5765 + AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 1)],
5766 + AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
5768 /* PinConfig, DebounceTimeout */
5770 @@ -299,7 +312,8 @@ AcpiDmGpioIntDescriptor (
5772 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
5774 - AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
5775 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.DebounceTimeout);
5776 + AcpiOsPrintf ("0x%4.4X,\n", Tmp16);
5778 /* Dump the GpioInt/GpioIo common portion of the descriptor */
5780 @@ -329,14 +343,16 @@ AcpiDmGpioIoDescriptor (
5786 /* Dump the GpioIo-specific portion of the descriptor */
5788 /* Shared, PinConfig */
5790 AcpiDmIndent (Level);
5791 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.IntFlags);
5792 AcpiOsPrintf ("GpioIo (%s, ",
5793 - AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
5794 + AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Tmp16, 3)]);
5796 if (Resource->Gpio.PinConfig <= 3)
5798 @@ -350,10 +366,13 @@ AcpiDmGpioIoDescriptor (
5800 /* DebounceTimeout, DriveStrength, IoRestriction */
5802 - AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
5803 - AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
5804 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.DebounceTimeout);
5805 + AcpiOsPrintf ("0x%4.4X, ", Tmp16);
5806 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.DriveStrength);
5807 + AcpiOsPrintf ("0x%4.4X, ", Tmp16);
5808 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Gpio.IntFlags);
5809 AcpiOsPrintf ("%s,\n",
5810 - AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
5811 + AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Tmp16)]);
5813 /* Dump the GpioInt/GpioIo common portion of the descriptor */
5815 @@ -533,6 +552,7 @@ AcpiDmDumpSerialBusVendorData (
5818 UINT32 VendorLength;
5822 /* Get the (optional) vendor data and length */
5823 @@ -541,8 +561,8 @@ AcpiDmDumpSerialBusVendorData (
5825 case AML_RESOURCE_I2C_SERIALBUSTYPE:
5827 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
5828 - AML_RESOURCE_I2C_MIN_DATA_LEN;
5829 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->CommonSerialBus.TypeDataLength);
5830 + VendorLength = Tmp16 - AML_RESOURCE_I2C_MIN_DATA_LEN;
5832 VendorData = ACPI_ADD_PTR (UINT8, Resource,
5833 sizeof (AML_RESOURCE_I2C_SERIALBUS));
5834 @@ -550,8 +570,8 @@ AcpiDmDumpSerialBusVendorData (
5836 case AML_RESOURCE_SPI_SERIALBUSTYPE:
5838 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
5839 - AML_RESOURCE_SPI_MIN_DATA_LEN;
5840 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->CommonSerialBus.TypeDataLength);
5841 + VendorLength = Tmp16 - AML_RESOURCE_SPI_MIN_DATA_LEN;
5843 VendorData = ACPI_ADD_PTR (UINT8, Resource,
5844 sizeof (AML_RESOURCE_SPI_SERIALBUS));
5845 @@ -559,8 +579,8 @@ AcpiDmDumpSerialBusVendorData (
5847 case AML_RESOURCE_UART_SERIALBUSTYPE:
5849 - VendorLength = Resource->CommonSerialBus.TypeDataLength -
5850 - AML_RESOURCE_UART_MIN_DATA_LEN;
5851 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->CommonSerialBus.TypeDataLength);
5852 + VendorLength = Tmp16 - AML_RESOURCE_UART_MIN_DATA_LEN;
5854 VendorData = ACPI_ADD_PTR (UINT8, Resource,
5855 sizeof (AML_RESOURCE_UART_SERIALBUS));
5856 @@ -601,24 +621,29 @@ AcpiDmI2cSerialBusDescriptor (
5858 UINT32 ResourceSourceOffset;
5864 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
5866 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->I2cSerialBus.SlaveAddress);
5867 + ACPI_MOVE_32_TO_32(&Tmp32, &Resource->I2cSerialBus.ConnectionSpeed);
5868 AcpiDmIndent (Level);
5869 AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
5870 - Resource->I2cSerialBus.SlaveAddress,
5872 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
5873 - Resource->I2cSerialBus.ConnectionSpeed);
5876 AcpiDmIndent (Level + 1);
5877 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->I2cSerialBus.TypeSpecificFlags);
5878 AcpiOsPrintf ("%s, ",
5879 - AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
5880 + AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Tmp16)]);
5882 /* ResourceSource is a required field */
5884 - ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
5885 - Resource->CommonSerialBus.TypeDataLength;
5886 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->CommonSerialBus.TypeDataLength);
5887 + ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + Tmp16;
5889 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
5890 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
5891 Index: acpica-unix2-20181003/source/components/disassembler/dmresrcs.c
5892 ===================================================================
5893 --- acpica-unix2-20181003.orig/source/components/disassembler/dmresrcs.c
5894 +++ acpica-unix2-20181003/source/components/disassembler/dmresrcs.c
5895 @@ -72,6 +72,7 @@ AcpiDmIrqDescriptor (
5901 AcpiDmIndent (Level);
5902 AcpiOsPrintf ("%s (",
5903 @@ -93,7 +94,8 @@ AcpiDmIrqDescriptor (
5904 AcpiOsPrintf (")\n");
5906 AcpiDmIndent (Level + 1);
5907 - AcpiDmBitList (Resource->Irq.IrqMask);
5908 + ACPI_MOVE_16_TO_16(&Tmp, &Resource->Irq.IrqMask);
5909 + AcpiDmBitList (Tmp);
5913 @@ -204,16 +206,19 @@ AcpiDmIoDescriptor (
5919 AcpiDmIndent (Level);
5920 AcpiOsPrintf ("IO (%s,\n",
5921 AcpiGbl_IoDecode [ACPI_GET_1BIT_FLAG (Resource->Io.Flags)]);
5923 AcpiDmIndent (Level + 1);
5924 - AcpiDmDumpInteger16 (Resource->Io.Minimum, "Range Minimum");
5925 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Io.Minimum);
5926 + AcpiDmDumpInteger16 (Tmp16, "Range Minimum");
5928 AcpiDmIndent (Level + 1);
5929 - AcpiDmDumpInteger16 (Resource->Io.Maximum, "Range Maximum");
5930 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->Io.Maximum);
5931 + AcpiDmDumpInteger16 (Tmp16, "Range Maximum");
5933 AcpiDmIndent (Level + 1);
5934 AcpiDmDumpInteger8 (Resource->Io.Alignment, "Alignment");
5935 @@ -251,12 +256,14 @@ AcpiDmFixedIoDescriptor (
5941 AcpiDmIndent (Level);
5942 AcpiOsPrintf ("FixedIO (\n");
5944 AcpiDmIndent (Level + 1);
5945 - AcpiDmDumpInteger16 (Resource->FixedIo.Address, "Address");
5946 + ACPI_MOVE_16_TO_16(&Tmp16, &Resource->FixedIo.Address);
5947 + AcpiDmDumpInteger16 (Tmp16, "Address");
5949 AcpiDmIndent (Level + 1);
5950 AcpiDmDumpInteger8 (Resource->FixedIo.AddressLength, "Length");
5951 Index: acpica-unix2-20181003/source/components/dispatcher/dsfield.c
5952 ===================================================================
5953 --- acpica-unix2-20181003.orig/source/components/dispatcher/dsfield.c
5954 +++ acpica-unix2-20181003/source/components/dispatcher/dsfield.c
5955 @@ -325,6 +325,7 @@ AcpiDsGetFieldNames (
5958 ACPI_PARSE_OBJECT *Child;
5961 #ifdef ACPI_EXEC_APP
5963 @@ -439,10 +440,17 @@ AcpiDsGetFieldNames (
5965 /* Lookup the name, it should already exist */
5967 + ACPI_MOVE_32_TO_32(&TmpName, &Arg->Named.Name);
5968 + Status = AcpiNsLookup (WalkState->ScopeInfo,
5969 + (char *) &TmpName, Info->FieldType,
5970 + ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
5971 + WalkState, &Info->FieldNode);
5973 Status = AcpiNsLookup (WalkState->ScopeInfo,
5974 (char *) &Arg->Named.Name, Info->FieldType,
5975 ACPI_IMODE_EXECUTE, ACPI_NS_DONT_OPEN_SCOPE,
5976 WalkState, &Info->FieldNode);
5978 if (ACPI_FAILURE (Status))
5980 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
5981 @@ -686,9 +694,17 @@ AcpiDsInitFieldObjects (
5983 if (Arg->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
5987 + ACPI_MOVE_32_TO_32(&TmpName, &Arg->Named.Name);
5988 + Status = AcpiNsLookup (WalkState->ScopeInfo,
5989 + (char *) &TmpName, Type, ACPI_IMODE_LOAD_PASS1,
5990 + Flags, WalkState, &Node);
5992 Status = AcpiNsLookup (WalkState->ScopeInfo,
5993 (char *) &Arg->Named.Name, Type, ACPI_IMODE_LOAD_PASS1,
5994 Flags, WalkState, &Node);
5996 if (ACPI_FAILURE (Status))
5998 ACPI_ERROR_NAMESPACE (WalkState->ScopeInfo,
5999 Index: acpica-unix2-20181003/source/components/events/evgpeblk.c
6000 ===================================================================
6001 --- acpica-unix2-20181003.orig/source/components/events/evgpeblk.c
6002 +++ acpica-unix2-20181003/source/components/events/evgpeblk.c
6003 @@ -376,6 +376,7 @@ AcpiEvCreateGpeBlock (
6005 ACPI_GPE_BLOCK_INFO *GpeBlock;
6006 ACPI_GPE_WALK_INFO WalkInfo;
6007 + char Name[ACPI_NAME_SIZE + 1];
6010 ACPI_FUNCTION_TRACE (EvCreateGpeBlock);
6011 @@ -396,7 +397,7 @@ AcpiEvCreateGpeBlock (
6013 /* Initialize the new GPE block */
6015 - GpeBlock->Address = Address;
6016 + ACPI_MOVE_64_TO_64(&GpeBlock->Address, &Address);
6017 GpeBlock->SpaceId = SpaceId;
6018 GpeBlock->Node = GpeDevice;
6019 GpeBlock->GpeCount = (UINT16) (RegisterCount * ACPI_GPE_REGISTER_WIDTH);
6020 @@ -445,11 +446,13 @@ AcpiEvCreateGpeBlock (
6021 (*ReturnGpeBlock) = GpeBlock;
6024 + memset(&Name, 0, ACPI_NAME_SIZE + 1);
6025 + ACPI_MOVE_32_TO_32(&Name, &GpeDevice->Name.Ascii);
6026 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
6027 " Initialized GPE %02X to %02X [%4.4s] %u regs on interrupt 0x%X%s\n",
6028 (UINT32) GpeBlock->BlockBaseNumber,
6029 (UINT32) (GpeBlock->BlockBaseNumber + (GpeBlock->GpeCount - 1)),
6030 - GpeDevice->Name.Ascii, GpeBlock->RegisterCount, InterruptNumber,
6031 + Name, GpeBlock->RegisterCount, InterruptNumber,
6032 InterruptNumber == AcpiGbl_FADT.SciInterrupt ? " (SCI)" : ""));
6034 /* Update global count of currently available GPEs */
6035 Index: acpica-unix2-20181003/source/components/hardware/hwregs.c
6036 ===================================================================
6037 --- acpica-unix2-20181003.orig/source/components/hardware/hwregs.c
6038 +++ acpica-unix2-20181003/source/components/hardware/hwregs.c
6039 @@ -197,7 +197,7 @@ AcpiHwValidateRegister (
6040 * Address must not be null. A null address also indicates an optional
6041 * ACPI register that is not supported, so no error message.
6043 - ACPI_MOVE_64_TO_64 (Address, &Reg->Address);
6044 + *Address = Reg->Address;
6047 return (AE_BAD_ADDRESS);
6048 Index: acpica-unix2-20181003/source/components/hardware/hwvalid.c
6049 ===================================================================
6050 --- acpica-unix2-20181003.orig/source/components/hardware/hwvalid.c
6051 +++ acpica-unix2-20181003/source/components/hardware/hwvalid.c
6052 @@ -135,6 +135,8 @@ AcpiHwValidateIoRequest (
6054 ACPI_IO_ADDRESS LastAddress;
6055 const ACPI_PORT_INFO *PortInfo;
6060 ACPI_FUNCTION_TRACE (HwValidateIoRequest);
6061 @@ -162,7 +164,10 @@ AcpiHwValidateIoRequest (
6063 /* Maximum 16-bit address in I/O space */
6065 - if (LastAddress > ACPI_UINT16_MAX)
6066 + Max16 = (UINT64) ACPI_UINT16_MAX;
6067 + ACPI_MOVE_64_TO_64(&Tmp64, &Max16);
6069 + if ((UINT64)LastAddress > Tmp64)
6071 ACPI_ERROR ((AE_INFO,
6072 "Illegal I/O port address/length above 64K: %8.8X%8.8X/0x%X",
6073 Index: acpica-unix2-20181003/source/components/namespace/nsaccess.c
6074 ===================================================================
6075 --- acpica-unix-20181031/source/components/namespace/nsaccess.c.orig 2018-10-31 20:37:45.000000000 +0100
6076 +++ acpica-unix-20181031/source/components/namespace/nsaccess.c 2018-11-18 21:27:20.483747969 +0100
6077 @@ -422,6 +422,7 @@ AcpiNsLookup (
6078 UINT32 SearchParentFlag = ACPI_NS_SEARCH_PARENT;
6080 ACPI_INTERPRETER_MODE LocalInterpreterMode;
6084 ACPI_FUNCTION_TRACE (NsLookup);
6085 @@ -831,9 +832,10 @@ AcpiNsLookup (
6087 /* Complain about a type mismatch */
6089 + ACPI_MOVE_32_TO_32(&Tmp32, &SimpleName);
6090 ACPI_WARNING ((AE_INFO,
6091 "NsLookup: Type mismatch on %4.4s (%s), searching for (%s)",
6092 - ACPI_CAST_PTR (char, &SimpleName),
6093 + ACPI_CAST_PTR (char, &Tmp32),
6094 AcpiUtGetTypeName (ThisNode->Type),
6095 AcpiUtGetTypeName (TypeToCheckFor)));
6097 Index: acpica-unix2-20181003/source/components/namespace/nsparse.c
6098 ===================================================================
6099 --- acpica-unix2-20181003.orig/source/components/namespace/nsparse.c
6100 +++ acpica-unix2-20181003/source/components/namespace/nsparse.c
6101 @@ -206,13 +206,14 @@ AcpiNsOneCompleteParse (
6103 /* Table must consist of at least a complete header */
6105 - if (Table->Length < sizeof (ACPI_TABLE_HEADER))
6106 + ACPI_MOVE_32_TO_32(&AmlLength, &Table->Length);
6107 + if (AmlLength < sizeof (ACPI_TABLE_HEADER))
6109 return_ACPI_STATUS (AE_BAD_HEADER);
6112 AmlStart = (UINT8 *) Table + sizeof (ACPI_TABLE_HEADER);
6113 - AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
6114 + AmlLength -= sizeof (ACPI_TABLE_HEADER);
6116 Status = AcpiTbGetOwnerId (TableIndex, &OwnerId);
6117 if (ACPI_FAILURE (Status))
6118 Index: acpica-unix2-20181003/source/components/tables/tbdata.c
6119 ===================================================================
6120 --- acpica-unix2-20181003.orig/source/components/tables/tbdata.c
6121 +++ acpica-unix2-20181003/source/components/tables/tbdata.c
6122 @@ -552,6 +552,7 @@ AcpiTbVerifyTempTable (
6125 ACPI_STATUS Status = AE_OK;
6129 ACPI_FUNCTION_TRACE (TbVerifyTempTable);
6130 @@ -581,7 +582,8 @@ AcpiTbVerifyTempTable (
6132 /* Verify the checksum */
6134 - Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
6135 + ACPI_MOVE_32_TO_32(&Length, &TableDesc->Length);
6136 + Status = AcpiTbVerifyChecksum (TableDesc->Pointer, Length);
6137 if (ACPI_FAILURE (Status))
6139 ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
6140 Index: acpica-unix2-20181003/source/components/tables/tbfadt.c
6141 ===================================================================
6142 --- acpica-unix2-20181003.orig/source/components/tables/tbfadt.c
6143 +++ acpica-unix2-20181003/source/components/tables/tbfadt.c
6144 @@ -424,18 +424,20 @@ AcpiTbCreateLocalFadt (
6145 ACPI_TABLE_HEADER *Table,
6151 * Check if the FADT is larger than the largest table that we expect
6152 * (typically the current ACPI specification version). If so, truncate
6153 * the table, and issue a warning.
6155 - if (Length > sizeof (ACPI_TABLE_FADT))
6156 + ACPI_MOVE_32_TO_32(&Tmp32, &Length);
6157 + if (Tmp32 > sizeof (ACPI_TABLE_FADT))
6159 ACPI_BIOS_WARNING ((AE_INFO,
6160 "FADT (revision %u) is longer than %s length, "
6161 "truncating length %u to %u",
6162 - Table->Revision, ACPI_FADT_CONFORMANCE, Length,
6163 + Table->Revision, ACPI_FADT_CONFORMANCE, Tmp32,
6164 (UINT32) sizeof (ACPI_TABLE_FADT)));
6167 @@ -446,7 +448,7 @@ AcpiTbCreateLocalFadt (
6168 /* Copy the original FADT, up to sizeof (ACPI_TABLE_FADT) */
6170 memcpy (&AcpiGbl_FADT, Table,
6171 - ACPI_MIN (Length, sizeof (ACPI_TABLE_FADT)));
6172 + ACPI_MIN (Tmp32, sizeof (ACPI_TABLE_FADT)));
6174 /* Take a copy of the Hardware Reduced flag */
6176 @@ -520,6 +522,8 @@ AcpiTbConvertFadt (
6185 @@ -533,7 +537,8 @@ AcpiTbConvertFadt (
6186 * Note: The FADT revision value is unreliable. Only the length can be
6189 - if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
6190 + ACPI_MOVE_32_TO_32(&Tmp32, &AcpiGbl_FADT.Header.Length);
6191 + if (Tmp32 <= ACPI_FADT_V2_SIZE)
6193 AcpiGbl_FADT.PreferredProfile = 0;
6194 AcpiGbl_FADT.PstateControl = 0;
6195 @@ -546,14 +551,15 @@ AcpiTbConvertFadt (
6196 * current FADT version as defined by the ACPI specification.
6197 * Thus, we will have a common FADT internally.
6199 - AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
6200 + Tmp32 = sizeof (ACPI_TABLE_FADT);
6201 + ACPI_MOVE_32_TO_32(&AcpiGbl_FADT.Header.Length, &Tmp32);
6204 * Expand the 32-bit DSDT addresses to 64-bit as necessary.
6205 * Later ACPICA code will always use the X 64-bit field.
6207 - AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
6208 - AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
6209 + Tmp64 = AcpiTbSelectAddress ("DSDT", AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
6210 + ACPI_MOVE_64_TO_64(&AcpiGbl_FADT.XDsdt, &Tmp64);
6212 /* If Hardware Reduced flag is set, we are all done */
6214 @@ -614,7 +620,9 @@ AcpiTbConvertFadt (
6216 if (Address64->Address)
6218 - if (Address64->Address != (UINT64) Address32)
6219 + ACPI_MOVE_32_TO_32(&Tmp32, &Address32);
6220 + ACPI_MOVE_64_TO_64(&Tmp64, &Address64->Address);
6221 + if (Tmp64 != (UINT64) Tmp32)
6223 /* Address mismatch */
6225 @@ -655,9 +663,11 @@ AcpiTbConvertFadt (
6227 if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
6229 + ACPI_MOVE_32_TO_32(&Tmp32, &Address32); /* back to host order */
6230 + Tmp64 = (UINT64) Tmp32; /* promote only */
6231 AcpiTbInitGenericAddress (Address64,
6232 ACPI_ADR_SPACE_SYSTEM_IO, Length,
6233 - (UINT64) Address32, Name, Flags);
6234 + Tmp64, Name, Flags);
6238 @@ -780,10 +790,14 @@ AcpiTbSetupFadtRegisters (
6240 if (Source64->Address)
6242 + UINT64 Tmp64, Addr64;
6244 + ACPI_MOVE_64_TO_64(&Tmp64, &Source64->Address);
6245 + Tmp64 += (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth);
6246 + ACPI_MOVE_64_TO_64(&Addr64, &Tmp64);
6247 AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
6248 Source64->SpaceId, Pm1RegisterByteWidth,
6249 - Source64->Address +
6250 - (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),
6255 Index: acpica-unix2-20181003/source/components/tables/tbfind.c
6256 ===================================================================
6257 --- acpica-unix2-20181003.orig/source/components/tables/tbfind.c
6258 +++ acpica-unix2-20181003/source/components/tables/tbfind.c
6259 @@ -108,8 +108,11 @@ AcpiTbFindTable (
6260 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
6261 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
6265 + ACPI_MOVE_32_TO_32(&Tmp32, &Header.Signature);
6266 if (memcmp (&(AcpiGbl_RootTableList.Tables[i].Signature),
6267 - Header.Signature, ACPI_NAME_SIZE))
6268 + &Tmp32, ACPI_NAME_SIZE))
6270 /* Not the requested table */
6272 Index: acpica-unix2-20181003/source/components/tables/tbprint.c
6273 ===================================================================
6274 --- acpica-unix2-20181003.orig/source/components/tables/tbprint.c
6275 +++ acpica-unix2-20181003/source/components/tables/tbprint.c
6276 @@ -143,15 +143,18 @@ AcpiTbPrintTableHeader (
6277 ACPI_TABLE_HEADER *Header)
6279 ACPI_TABLE_HEADER LocalHeader;
6282 + UINT32 CompilerRev;
6285 if (ACPI_COMPARE_NAME (Header->Signature, ACPI_SIG_FACS))
6287 /* FACS only has signature and length fields */
6289 + ACPI_MOVE_32_TO_32(&Len, &Header->Length);
6290 ACPI_INFO (("%-4.4s 0x%8.8X%8.8X %06X",
6291 - Header->Signature, ACPI_FORMAT_UINT64 (Address),
6293 + Header->Signature, ACPI_FORMAT_UINT64 (Address), Len));
6295 else if (ACPI_VALIDATE_RSDP_SIG (Header->Signature))
6297 @@ -174,13 +177,16 @@ AcpiTbPrintTableHeader (
6299 AcpiTbCleanupTableHeader (&LocalHeader, Header);
6301 + ACPI_MOVE_32_TO_32(&Len, &LocalHeader.Length);
6302 + ACPI_MOVE_32_TO_32(&OemRev, &LocalHeader.OemRevision);
6303 + ACPI_MOVE_32_TO_32(&CompilerRev, &LocalHeader.AslCompilerRevision);
6305 "%-4.4s 0x%8.8X%8.8X"
6306 " %06X (v%.2d %-6.6s %-8.8s %08X %-4.4s %08X)",
6307 LocalHeader.Signature, ACPI_FORMAT_UINT64 (Address),
6308 - LocalHeader.Length, LocalHeader.Revision, LocalHeader.OemId,
6309 - LocalHeader.OemTableId, LocalHeader.OemRevision,
6310 - LocalHeader.AslCompilerId, LocalHeader.AslCompilerRevision));
6311 + Len, LocalHeader.Revision, LocalHeader.OemId,
6312 + LocalHeader.OemTableId, OemRev,
6313 + LocalHeader.AslCompilerId, CompilerRev));
6317 Index: acpica-unix2-20181003/source/components/tables/tbutils.c
6318 ===================================================================
6319 --- acpica-unix2-20181003.orig/source/components/tables/tbutils.c
6320 +++ acpica-unix2-20181003/source/components/tables/tbutils.c
6321 @@ -238,7 +238,7 @@ AcpiTbGetRootTableEntry (
6322 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
6325 - ACPI_MOVE_64_TO_64 (&Address64, TableEntry);
6326 + Address64 = (UINT64) TableEntry;
6328 #if ACPI_MACHINE_WIDTH == 32
6329 if (Address64 > ACPI_UINT32_MAX)
6330 @@ -251,7 +251,8 @@ AcpiTbGetRootTableEntry (
6331 ACPI_FORMAT_UINT64 (Address64)));
6334 - return ((ACPI_PHYSICAL_ADDRESS) (Address64));
6335 + return ((ACPI_PHYSICAL_ADDRESS) (*ACPI_CAST_PTR (
6336 + UINT64, Address64)));
6340 @@ -287,6 +288,7 @@ AcpiTbParseRootTable (
6347 ACPI_FUNCTION_TRACE (TbParseRootTable);
6348 @@ -345,7 +347,7 @@ AcpiTbParseRootTable (
6349 * Validate length of the table, and map entire table.
6350 * Minimum length table must contain at least one entry.
6352 - Length = Table->Length;
6353 + ACPI_MOVE_32_TO_32(&Length, &Table->Length);
6354 AcpiOsUnmapMemory (Table, sizeof (ACPI_TABLE_HEADER));
6356 if (Length < (sizeof (ACPI_TABLE_HEADER) + TableEntrySize))
6357 @@ -372,7 +374,7 @@ AcpiTbParseRootTable (
6359 /* Get the number of entries and pointer to first entry */
6361 - TableCount = (UINT32) ((Table->Length - sizeof (ACPI_TABLE_HEADER)) /
6362 + TableCount = (UINT32) ((Length - sizeof (ACPI_TABLE_HEADER)) /
6364 TableEntry = ACPI_ADD_PTR (UINT8, Table, sizeof (ACPI_TABLE_HEADER));
6366 @@ -394,10 +396,10 @@ AcpiTbParseRootTable (
6367 Status = AcpiTbInstallStandardTable (Address,
6368 ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, FALSE, TRUE, &TableIndex);
6370 + ACPI_MOVE_32_TO_32(&Tmp32,
6371 + &AcpiGbl_RootTableList.Tables[TableIndex].Signature);
6372 if (ACPI_SUCCESS (Status) &&
6373 - ACPI_COMPARE_NAME (
6374 - &AcpiGbl_RootTableList.Tables[TableIndex].Signature,
6376 + ACPI_COMPARE_NAME (&Tmp32, ACPI_SIG_FADT))
6378 AcpiGbl_FadtIndex = TableIndex;
6380 Index: acpica-unix2-20181003/source/components/tables/tbxface.c
6381 ===================================================================
6382 --- acpica-unix2-20181003.orig/source/components/tables/tbxface.c
6383 +++ acpica-unix2-20181003/source/components/tables/tbxface.c
6384 @@ -293,8 +293,11 @@ AcpiGetTableHeader (
6386 for (i = 0, j = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
6390 + ACPI_MOVE_32_TO_32(&Tmp32, (UINT32 *)Signature);
6391 if (!ACPI_COMPARE_NAME (
6392 - &(AcpiGbl_RootTableList.Tables[i].Signature), Signature))
6393 + &(AcpiGbl_RootTableList.Tables[i].Signature), &Tmp32))
6397 Index: acpica-unix2-20181003/source/components/tables/tbxfload.c
6398 ===================================================================
6399 --- acpica-unix2-20181003.orig/source/components/tables/tbxfload.c
6400 +++ acpica-unix2-20181003/source/components/tables/tbxfload.c
6401 @@ -159,6 +159,7 @@ AcpiTbLoadNamespace (
6402 ACPI_TABLE_DESC *Table;
6403 UINT32 TablesLoaded = 0;
6404 UINT32 TablesFailed = 0;
6408 ACPI_FUNCTION_TRACE (TbLoadNamespace);
6409 @@ -172,8 +173,9 @@ AcpiTbLoadNamespace (
6411 Table = &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex];
6413 + ACPI_MOVE_32_TO_32(&Tmp32, &Table->Signature.Ascii);
6414 if (!AcpiGbl_RootTableList.CurrentTableCount ||
6415 - !ACPI_COMPARE_NAME (Table->Signature.Ascii, ACPI_SIG_DSDT) ||
6416 + !ACPI_COMPARE_NAME (&Tmp32, ACPI_SIG_DSDT) ||
6417 ACPI_FAILURE (AcpiTbValidateTable (Table)))
6419 Status = AE_NO_ACPI_TABLES;
6420 Index: acpica-unix2-20181003/source/tools/acpiexec/aetables.c
6421 ===================================================================
6422 --- acpica-unix2-20181003.orig/source/tools/acpiexec/aetables.c
6423 +++ acpica-unix2-20181003/source/tools/acpiexec/aetables.c
6424 @@ -146,21 +146,25 @@ AeInitializeTableHeader (
6431 ACPI_MOVE_NAME (Header->Signature, Signature);
6432 - Header->Length = Length;
6433 + ACPI_MOVE_32_TO_32(&Header->Length, &Length);
6435 - Header->OemRevision = 0x1001;
6437 + ACPI_MOVE_16_TO_16(&Header->OemRevision, &Tmp16);
6438 memcpy (Header->OemId, "Intel ", ACPI_OEM_ID_SIZE);
6439 memcpy (Header->OemTableId, "AcpiExec", ACPI_OEM_TABLE_ID_SIZE);
6440 ACPI_MOVE_NAME (Header->AslCompilerId, "INTL");
6441 - Header->AslCompilerRevision = ACPI_CA_VERSION;
6442 + Tmp32 = ACPI_CA_VERSION;
6443 + ACPI_MOVE_32_TO_32(&Header->AslCompilerRevision, &Tmp32);
6445 /* Set the checksum, must set to zero first */
6447 Header->Checksum = 0;
6448 Header->Checksum = (UINT8) -AcpiTbChecksum (
6449 - (void *) Header, Header->Length);
6450 + (void *) Header, Length);
6454 @@ -188,6 +192,7 @@ AeBuildLocalTables (
6455 ACPI_NEW_TABLE_DESC *NextTable;
6457 ACPI_TABLE_FADT *ExternalFadt = NULL;
6462 @@ -374,6 +379,8 @@ AeBuildLocalTables (
6469 * Build a local FADT so we can test the hardware/event init
6471 @@ -385,34 +392,44 @@ AeBuildLocalTables (
6474 LocalFADT.XDsdt = DsdtAddress;
6475 - LocalFADT.XFacs = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
6476 + Tmp64 = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
6477 + ACPI_MOVE_64_TO_64(&LocalFADT.XFacs, &Tmp64);
6479 /* Miscellaneous FADT fields */
6481 LocalFADT.Gpe0BlockLength = 0x20;
6482 - LocalFADT.Gpe0Block = 0x00003210;
6483 + Tmp32 = 0x00003210;
6484 + ACPI_MOVE_32_TO_32(&LocalFADT.Gpe0Block, &Tmp32);
6486 LocalFADT.Gpe1BlockLength = 0x20;
6487 - LocalFADT.Gpe1Block = 0x0000BA98;
6488 + Tmp32 = 0x0000BA98;
6489 + ACPI_MOVE_32_TO_32(&LocalFADT.Gpe1Block, &Tmp32);
6490 LocalFADT.Gpe1Base = 0x80;
6492 LocalFADT.Pm1EventLength = 4;
6493 - LocalFADT.Pm1aEventBlock = 0x00001aaa;
6494 - LocalFADT.Pm1bEventBlock = 0x00001bbb;
6495 + Tmp32 = 0x00001aaa;
6496 + ACPI_MOVE_32_TO_32(&LocalFADT.Pm1aEventBlock, &Tmp32);
6497 + Tmp32 = 0x00001bbb;
6498 + ACPI_MOVE_32_TO_32(&LocalFADT.Pm1bEventBlock, &Tmp32);
6500 LocalFADT.Pm1ControlLength = 2;
6501 - LocalFADT.Pm1aControlBlock = 0xB0;
6503 + ACPI_MOVE_32_TO_32(&LocalFADT.Pm1aControlBlock, &Tmp32);
6505 LocalFADT.PmTimerLength = 4;
6506 - LocalFADT.PmTimerBlock = 0xA0;
6508 + ACPI_MOVE_32_TO_32(&LocalFADT.PmTimerBlock, &Tmp32);
6510 - LocalFADT.Pm2ControlBlock = 0xC0;
6512 + ACPI_MOVE_32_TO_32(&LocalFADT.Pm2ControlBlock, &Tmp32);
6513 LocalFADT.Pm2ControlLength = 1;
6515 /* Setup one example X-64 GAS field */
6517 LocalFADT.XPm1bEventBlock.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO;
6518 - LocalFADT.XPm1bEventBlock.Address = LocalFADT.Pm1bEventBlock;
6519 + ACPI_MOVE_32_TO_32(&Tmp32, &LocalFADT.Pm1bEventBlock);
6520 + Tmp64 = (UINT64)Tmp32;
6521 + ACPI_MOVE_64_TO_64(&LocalFADT.XPm1bEventBlock.Address, &Tmp64);
6522 LocalFADT.XPm1bEventBlock.BitWidth = (UINT8)
6523 ACPI_MUL_8 (LocalFADT.Pm1EventLength);
6525 @@ -425,13 +442,17 @@ AeBuildLocalTables (
6526 memset (&LocalFACS, 0, sizeof (ACPI_TABLE_FACS));
6527 ACPI_MOVE_NAME (LocalFACS.Signature, ACPI_SIG_FACS);
6529 - LocalFACS.Length = sizeof (ACPI_TABLE_FACS);
6530 - LocalFACS.GlobalLock = 0x11AA0011;
6531 + Tmp32 = sizeof (ACPI_TABLE_FACS);
6532 + ACPI_MOVE_32_TO_32(&LocalFACS.Length, &Tmp32);
6533 + Tmp32 = 0x11AA0011;
6534 + ACPI_MOVE_32_TO_32(&LocalFACS.GlobalLock, &Tmp32);
6536 /* Build the optional local tables */
6538 if (AcpiGbl_LoadTestTables)
6543 * Build a fake table [TEST] so that we make sure that the
6544 * ACPICA core ignores it
6545 @@ -440,11 +461,12 @@ AeBuildLocalTables (
6546 ACPI_MOVE_NAME (LocalTEST.Signature, "TEST");
6548 LocalTEST.Revision = 1;
6549 - LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
6550 + Tmp32 = sizeof (ACPI_TABLE_HEADER);
6551 + ACPI_MOVE_32_TO_32(&LocalTEST.Length, &Tmp32);
6553 LocalTEST.Checksum = 0;
6554 LocalTEST.Checksum = (UINT8) -AcpiTbChecksum (
6555 - (void *) &LocalTEST, LocalTEST.Length);
6556 + (void *) &LocalTEST, Tmp32);
6559 * Build a fake table with a bad signature [BAD!] so that we make
6560 @@ -454,11 +476,12 @@ AeBuildLocalTables (
6561 ACPI_MOVE_NAME (LocalBADTABLE.Signature, "BAD!");
6563 LocalBADTABLE.Revision = 1;
6564 - LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
6565 + Tmp32 = sizeof (ACPI_TABLE_HEADER);
6566 + ACPI_MOVE_32_TO_32(&LocalBADTABLE.Length, &Tmp32);
6568 LocalBADTABLE.Checksum = 0;
6569 LocalBADTABLE.Checksum = (UINT8) -AcpiTbChecksum (
6570 - (void *) &LocalBADTABLE, LocalBADTABLE.Length);
6571 + (void *) &LocalBADTABLE, Tmp32);
6575 Index: acpica-unix2-20181003/source/common/dmswitch.c
6576 ===================================================================
6577 --- acpica-unix2-20181003.orig/source/common/dmswitch.c
6578 +++ acpica-unix2-20181003/source/common/dmswitch.c
6579 @@ -88,13 +88,15 @@ AcpiDmProcessSwitch (
6580 ACPI_PARSE_OBJECT_LIST *Current;
6581 ACPI_PARSE_OBJECT_LIST *Previous;
6582 BOOLEAN FoundTemp = FALSE;
6586 switch (Op->Common.AmlOpcode)
6590 - Temp = (char *) (&Op->Named.Name);
6591 + ACPI_MOVE_32_TO_32(&Tmp32, &Op->Named.Name);
6592 + Temp = (char *) (&Tmp32);
6594 if (!strncmp(Temp, "_T_", 3))
6596 @@ -138,7 +140,10 @@ AcpiDmProcessSwitch (
6598 /* Note, if we get here Temp is not NULL */
6600 - if (!strncmp(Temp, (char *) (&Current->Op->Named.Name), 4))
6601 + ACPI_MOVE_32_TO_32(&Tmp32, &Current->Op->Named.Name);
6603 + /* if (!strncmp(Temp, (char *) (&Current->Op->Named.Name), 4)) */
6604 + if (!strncmp(Temp, (char *) &Tmp32, 4))
6606 /* Match found. Ignore disassembly */