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

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