Blame SOURCES/0042-Support-IVRS-in-a-big-endian-world.patch

9897bb
From b64cff82b2b33ed659826d777d2db039f64fd198 Mon Sep 17 00:00:00 2001
9897bb
From: Al Stone <ahs3@redhat.com>
9897bb
Date: Tue, 29 Jun 2021 17:45:24 -0600
9897bb
Subject: [PATCH 42/45] Support IVRS in a big-endian world
9897bb
9897bb
Signed-off-by: Al Stone <ahs3@redhat.com>
9897bb
---
9897bb
 source/common/dmtbdump2.c | 34 +++++++++++++++++++---------------
9897bb
 1 file changed, 19 insertions(+), 15 deletions(-)
9897bb
9897bb
Index: acpica-unix2-20210604/source/common/dmtbdump2.c
9897bb
===================================================================
9897bb
--- acpica-unix2-20210604.orig/source/common/dmtbdump2.c
9897bb
+++ acpica-unix2-20210604/source/common/dmtbdump2.c
9897bb
@@ -419,11 +419,14 @@ AcpiDmDumpIvrs (
9897bb
     ACPI_IVRS_DE_HEADER     *DeviceEntry;
9897bb
     ACPI_IVRS_HEADER        *Subtable;
9897bb
     ACPI_DMTABLE_INFO       *InfoTable;
9897bb
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
9897bb
+    UINT16                  SubtableLength;
9897bb
+
9897bb
 
9897bb
 
9897bb
     /* Main table */
9897bb
 
9897bb
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoIvrs);
9897bb
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoIvrs);
9897bb
     if (ACPI_FAILURE (Status))
9897bb
     {
9897bb
         return;
9897bb
@@ -433,8 +436,9 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
     Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Table, Offset);
9897bb
 
9897bb
-    while (Offset < Table->Length)
9897bb
+    while (Offset < TableLength)
9897bb
     {
9897bb
+        SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
9897bb
         switch (Subtable->Type)
9897bb
         {
9897bb
         /* Type 10h, IVHD (I/O Virtualization Hardware Definition) */
9897bb
@@ -471,7 +475,7 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
             /* Attempt to continue */
9897bb
 
9897bb
-            if (!Subtable->Length)
9897bb
+            if (!SubtableLength)
9897bb
             {
9897bb
                 AcpiOsPrintf ("Invalid zero length subtable\n");
9897bb
                 return;
9897bb
@@ -481,8 +485,8 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
         /* Dump the subtable */
9897bb
 
9897bb
-        Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
9897bb
-            Subtable->Length, InfoTable);
9897bb
+        Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
9897bb
+            SubtableLength, InfoTable);
9897bb
         if (ACPI_FAILURE (Status))
9897bb
         {
9897bb
             return;
9897bb
@@ -511,7 +515,7 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
             /* Process all of the Device Entries */
9897bb
 
9897bb
-            while (EntryOffset < (Offset + Subtable->Length))
9897bb
+            while (EntryOffset < (Offset + SubtableLength))
9897bb
             {
9897bb
                 AcpiOsPrintf ("\n");
9897bb
 
9897bb
@@ -581,7 +585,7 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
                 /* Dump the Device Entry */
9897bb
 
9897bb
-                Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                     DeviceEntry, EntryLength, InfoTable);
9897bb
                 if (ACPI_FAILURE (Status))
9897bb
                 {
9897bb
@@ -605,12 +609,12 @@ AcpiDmDumpIvrs (
9897bb
                      */
9897bb
                     if (UtIsIdInteger ((UINT8 *) &HidSubtable->AcpiHid))
9897bb
                     {
9897bb
-                        Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                        Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                             &HidSubtable->AcpiHid, 8, AcpiDmTableInfoIvrsHidInteger);
9897bb
                     }
9897bb
                     else
9897bb
                     {
9897bb
-                        Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                        Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                             &HidSubtable->AcpiHid, 8, AcpiDmTableInfoIvrsHidString);
9897bb
                     }
9897bb
                     if (ACPI_FAILURE (Status))
9897bb
@@ -628,12 +632,12 @@ AcpiDmDumpIvrs (
9897bb
                      */
9897bb
                     if (UtIsIdInteger ((UINT8 *) &HidSubtable->AcpiCid))
9897bb
                     {
9897bb
-                        Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                        Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                             &HidSubtable->AcpiCid, 8, AcpiDmTableInfoIvrsCidInteger);
9897bb
                     }
9897bb
                     else
9897bb
                     {
9897bb
-                        Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                        Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                             &HidSubtable->AcpiCid, 8, AcpiDmTableInfoIvrsCidString);
9897bb
                     }
9897bb
                     if (ACPI_FAILURE (Status))
9897bb
@@ -650,7 +654,7 @@ AcpiDmDumpIvrs (
9897bb
 
9897bb
                         if (HidSubtable->UidType == ACPI_IVRS_UID_IS_STRING)
9897bb
                         {
9897bb
-                            Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                            Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                                 &HidSubtable->UidType, EntryLength, AcpiDmTableInfoIvrsUidString);
9897bb
                             if (ACPI_FAILURE (Status))
9897bb
                             {
9897bb
@@ -659,7 +663,7 @@ AcpiDmDumpIvrs (
9897bb
                         }
9897bb
                         else /* ACPI_IVRS_UID_IS_INTEGER */
9897bb
                         {
9897bb
-                            Status = AcpiDmDumpTable (Table->Length, EntryOffset,
9897bb
+                            Status = AcpiDmDumpTable (TableLength, EntryOffset,
9897bb
                                 &HidSubtable->UidType, EntryLength, AcpiDmTableInfoIvrsUidInteger);
9897bb
                             if (ACPI_FAILURE (Status))
9897bb
                             {
9897bb
@@ -678,8 +682,8 @@ AcpiDmDumpIvrs (
9897bb
 NextSubtable:
9897bb
         /* Point to next subtable */
9897bb
 
9897bb
-        Offset += Subtable->Length;
9897bb
-        Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Subtable, Subtable->Length);
9897bb
+        Offset += SubtableLength;
9897bb
+        Subtable = ACPI_ADD_PTR (ACPI_IVRS_HEADER, Subtable, SubtableLength);
9897bb
     }
9897bb
 }
9897bb