Blame SOURCES/0012-Support-DMAR-in-a-big-endian-world.patch

214d7a
From 06623392351dfea54bd69507b6672c933a5e3fd2 Mon Sep 17 00:00:00 2001
214d7a
From: Al Stone <ahs3@redhat.com>
214d7a
Date: Sat, 19 Sep 2020 15:22:00 -0600
214d7a
Subject: [PATCH 12/45] Support DMAR in a big-endian world
214d7a
214d7a
Signed-off-by: Al Stone <ahs3@redhat.com>
214d7a
---
214d7a
 source/common/dmtable.c    |  4 ++--
214d7a
 source/common/dmtbdump1.c  | 26 +++++++++++++++-----------
214d7a
 source/compiler/dttable1.c | 12 +++++++-----
214d7a
 3 files changed, 24 insertions(+), 18 deletions(-)
214d7a
214d7a
Index: acpica-unix2-20210604/source/common/dmtable.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/common/dmtable.c
214d7a
+++ acpica-unix2-20210604/source/common/dmtable.c
214d7a
@@ -1341,13 +1341,13 @@ AcpiDmDumpTable (
214d7a
 
214d7a
             /* DMAR subtable types */
214d7a
 
214d7a
-            Temp16 = ACPI_GET16 (Target);
214d7a
+            Temp16 = AcpiUtReadUint16 (Target);
214d7a
             if (Temp16 > ACPI_DMAR_TYPE_RESERVED)
214d7a
             {
214d7a
                 Temp16 = ACPI_DMAR_TYPE_RESERVED;
214d7a
             }
214d7a
 
214d7a
-            AcpiOsPrintf (UINT16_FORMAT, ACPI_GET16 (Target),
214d7a
+            AcpiOsPrintf (UINT16_FORMAT, Temp16,
214d7a
                 AcpiDmDmarSubnames[Temp16]);
214d7a
             break;
214d7a
 
214d7a
Index: acpica-unix2-20210604/source/common/dmtbdump1.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/common/dmtbdump1.c
214d7a
+++ acpica-unix2-20210604/source/common/dmtbdump1.c
214d7a
@@ -604,13 +604,15 @@ AcpiDmDumpDmar (
214d7a
 {
214d7a
     ACPI_STATUS             Status;
214d7a
     ACPI_DMAR_HEADER        *Subtable;
214d7a
-    UINT32                  Length = Table->Length;
214d7a
+    UINT32                  Length = AcpiUtReadUint32 (&Table->Length);
214d7a
     UINT32                  Offset = sizeof (ACPI_TABLE_DMAR);
214d7a
     ACPI_DMTABLE_INFO       *InfoTable;
214d7a
     ACPI_DMAR_DEVICE_SCOPE  *ScopeTable;
214d7a
     UINT32                  ScopeOffset;
214d7a
     UINT8                   *PciPath;
214d7a
     UINT32                  PathOffset;
214d7a
+    UINT16                  SubtableType;
214d7a
+    UINT16                  SubtableLength;
214d7a
 
214d7a
 
214d7a
     /* Main table */
214d7a
@@ -624,13 +626,14 @@ AcpiDmDumpDmar (
214d7a
     /* Subtables */
214d7a
 
214d7a
     Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Table, Offset);
214d7a
-    while (Offset < Table->Length)
214d7a
+    while (Offset < Length)
214d7a
     {
214d7a
         /* Common subtable header */
214d7a
 
214d7a
         AcpiOsPrintf ("\n");
214d7a
+        SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
214d7a
         Status = AcpiDmDumpTable (Length, Offset, Subtable,
214d7a
-            Subtable->Length, AcpiDmTableInfoDmarHdr);
214d7a
+            SubtableLength, AcpiDmTableInfoDmarHdr);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
         {
214d7a
             return;
214d7a
@@ -638,7 +641,8 @@ AcpiDmDumpDmar (
214d7a
 
214d7a
         AcpiOsPrintf ("\n");
214d7a
 
214d7a
-        switch (Subtable->Type)
214d7a
+        SubtableType = AcpiUtReadUint16 (&Subtable->Type);
214d7a
+        switch (SubtableType)
214d7a
         {
214d7a
         case ACPI_DMAR_TYPE_HARDWARE_UNIT:
214d7a
 
214d7a
@@ -673,12 +677,12 @@ AcpiDmDumpDmar (
214d7a
         default:
214d7a
 
214d7a
             AcpiOsPrintf ("\n**** Unknown DMAR subtable type 0x%X\n\n",
214d7a
-                Subtable->Type);
214d7a
+                SubtableType);
214d7a
             return;
214d7a
         }
214d7a
 
214d7a
         Status = AcpiDmDumpTable (Length, Offset, Subtable,
214d7a
-            Subtable->Length, InfoTable);
214d7a
+            SubtableLength, InfoTable);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
         {
214d7a
             return;
214d7a
@@ -687,8 +691,8 @@ AcpiDmDumpDmar (
214d7a
         /*
214d7a
          * Dump the optional device scope entries
214d7a
          */
214d7a
-        if ((Subtable->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
214d7a
-            (Subtable->Type == ACPI_DMAR_TYPE_NAMESPACE))
214d7a
+        if ((SubtableType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
214d7a
+            (SubtableType == ACPI_DMAR_TYPE_NAMESPACE))
214d7a
         {
214d7a
             /* These types do not support device scopes */
214d7a
 
214d7a
@@ -696,7 +700,7 @@ AcpiDmDumpDmar (
214d7a
         }
214d7a
 
214d7a
         ScopeTable = ACPI_ADD_PTR (ACPI_DMAR_DEVICE_SCOPE, Subtable, ScopeOffset);
214d7a
-        while (ScopeOffset < Subtable->Length)
214d7a
+        while (ScopeOffset < SubtableLength)
214d7a
         {
214d7a
             AcpiOsPrintf ("\n");
214d7a
             Status = AcpiDmDumpTable (Length, Offset + ScopeOffset, ScopeTable,
214d7a
@@ -737,9 +741,9 @@ AcpiDmDumpDmar (
214d7a
 NextSubtable:
214d7a
         /* Point to next subtable */
214d7a
 
214d7a
-        Offset += Subtable->Length;
214d7a
+        Offset += SubtableLength;
214d7a
         Subtable = ACPI_ADD_PTR (ACPI_DMAR_HEADER, Subtable,
214d7a
-            Subtable->Length);
214d7a
+            SubtableLength);
214d7a
     }
214d7a
 }
214d7a
 
214d7a
Index: acpica-unix2-20210604/source/compiler/dttable1.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/compiler/dttable1.c
214d7a
+++ acpica-unix2-20210604/source/compiler/dttable1.c
214d7a
@@ -634,6 +634,7 @@ DtCompileDmar (
214d7a
     ACPI_DMAR_DEVICE_SCOPE  *DmarDeviceScope;
214d7a
     UINT32                  DeviceScopeLength;
214d7a
     UINT32                  PciPathLength;
214d7a
+    UINT16                  DmarHeaderType;
214d7a
 
214d7a
 
214d7a
     Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmar, &Subtable);
214d7a
@@ -664,7 +665,8 @@ DtCompileDmar (
214d7a
 
214d7a
         DmarHeader = ACPI_CAST_PTR (ACPI_DMAR_HEADER, Subtable->Buffer);
214d7a
 
214d7a
-        switch (DmarHeader->Type)
214d7a
+        DmarHeaderType = AcpiUtReadUint16 (&DmarHeader->Type);
214d7a
+        switch (DmarHeaderType)
214d7a
         {
214d7a
         case ACPI_DMAR_TYPE_HARDWARE_UNIT:
214d7a
 
214d7a
@@ -711,8 +713,8 @@ DtCompileDmar (
214d7a
         /*
214d7a
          * Optional Device Scope subtables
214d7a
          */
214d7a
-        if ((DmarHeader->Type == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
214d7a
-            (DmarHeader->Type == ACPI_DMAR_TYPE_NAMESPACE))
214d7a
+        if ((DmarHeaderType == ACPI_DMAR_TYPE_HARDWARE_AFFINITY) ||
214d7a
+            (DmarHeaderType == ACPI_DMAR_TYPE_NAMESPACE))
214d7a
         {
214d7a
             /* These types do not support device scopes */
214d7a
 
214d7a
@@ -721,8 +723,8 @@ DtCompileDmar (
214d7a
         }
214d7a
 
214d7a
         DtPushSubtable (Subtable);
214d7a
-        DeviceScopeLength = DmarHeader->Length - Subtable->Length -
214d7a
-            ParentTable->Length;
214d7a
+        DeviceScopeLength = AcpiUtReadUint16 (&DmarHeader->Length) -
214d7a
+                Subtable->Length - ParentTable->Length;
214d7a
         while (DeviceScopeLength)
214d7a
         {
214d7a
             Status = DtCompileTable (PFieldList, AcpiDmTableInfoDmarScope,