Blame SOURCES/0025-Support-MPST-in-a-big-endian-world.patch

214d7a
From 0a25688f36df62579f4dd0444ceba33a0f8d4dcc Mon Sep 17 00:00:00 2001
214d7a
From: Al Stone <ahs3@redhat.com>
214d7a
Date: Wed, 23 Sep 2020 16:08:24 -0600
214d7a
Subject: [PATCH 25/45] Support MPST in a big-endian world
214d7a
214d7a
Signed-off-by: Al Stone <ahs3@redhat.com>
214d7a
---
214d7a
 source/common/dmtbdump2.c  | 33 +++++++++++++++++++--------------
214d7a
 source/compiler/dttable2.c |  8 ++++----
214d7a
 2 files changed, 23 insertions(+), 18 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
@@ -995,11 +995,13 @@ AcpiDmDumpMpst (
214d7a
     UINT16                  SubtableCount;
214d7a
     UINT32                  PowerStateCount;
214d7a
     UINT32                  ComponentCount;
214d7a
+    UINT32                  TableLength = AcpiUtReadUint32 (&Table->Length);
214d7a
+    UINT16                  Tmp16;
214d7a
 
214d7a
 
214d7a
     /* Main table */
214d7a
 
214d7a
-    Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoMpst);
214d7a
+    Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoMpst);
214d7a
     if (ACPI_FAILURE (Status))
214d7a
     {
214d7a
         return;
214d7a
@@ -1007,13 +1009,14 @@ AcpiDmDumpMpst (
214d7a
 
214d7a
     /* Subtable: Memory Power Node(s) */
214d7a
 
214d7a
-    SubtableCount = (ACPI_CAST_PTR (ACPI_TABLE_MPST, Table))->PowerNodeCount;
214d7a
+    Tmp16 = (ACPI_CAST_PTR (ACPI_TABLE_MPST, Table))->PowerNodeCount;
214d7a
+    SubtableCount = AcpiUtReadUint16 (&Tmp16);
214d7a
     Subtable0 = ACPI_ADD_PTR (ACPI_MPST_POWER_NODE, Table, Offset);
214d7a
 
214d7a
-    while ((Offset < Table->Length) && SubtableCount)
214d7a
+    while ((Offset < TableLength) && SubtableCount)
214d7a
     {
214d7a
         AcpiOsPrintf ("\n");
214d7a
-        Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0,
214d7a
+        Status = AcpiDmDumpTable (TableLength, Offset, Subtable0,
214d7a
             sizeof (ACPI_MPST_POWER_NODE), AcpiDmTableInfoMpst0);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
         {
214d7a
@@ -1022,8 +1025,8 @@ AcpiDmDumpMpst (
214d7a
 
214d7a
         /* Extract the sub-subtable counts */
214d7a
 
214d7a
-        PowerStateCount = Subtable0->NumPowerStates;
214d7a
-        ComponentCount = Subtable0->NumPhysicalComponents;
214d7a
+        PowerStateCount = AcpiUtReadUint16 (&Subtable0->NumPowerStates);
214d7a
+        ComponentCount = AcpiUtReadUint16 (&Subtable0->NumPhysicalComponents);
214d7a
         Offset += sizeof (ACPI_MPST_POWER_NODE);
214d7a
 
214d7a
         /* Sub-subtables - Memory Power State Structure(s) */
214d7a
@@ -1034,7 +1037,7 @@ AcpiDmDumpMpst (
214d7a
         while (PowerStateCount)
214d7a
         {
214d7a
             AcpiOsPrintf ("\n");
214d7a
-            Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0A,
214d7a
+            Status = AcpiDmDumpTable (TableLength, Offset, Subtable0A,
214d7a
                 sizeof (ACPI_MPST_POWER_STATE), AcpiDmTableInfoMpst0A);
214d7a
             if (ACPI_FAILURE (Status))
214d7a
             {
214d7a
@@ -1057,7 +1060,7 @@ AcpiDmDumpMpst (
214d7a
 
214d7a
         while (ComponentCount)
214d7a
         {
214d7a
-            Status = AcpiDmDumpTable (Table->Length, Offset, Subtable0B,
214d7a
+            Status = AcpiDmDumpTable (TableLength, Offset, Subtable0B,
214d7a
                 sizeof (ACPI_MPST_COMPONENT), AcpiDmTableInfoMpst0B);
214d7a
             if (ACPI_FAILURE (Status))
214d7a
             {
214d7a
@@ -1074,22 +1077,24 @@ AcpiDmDumpMpst (
214d7a
         SubtableCount--;
214d7a
         Subtable0 = ACPI_ADD_PTR (ACPI_MPST_POWER_NODE, Subtable0,
214d7a
             sizeof (ACPI_MPST_POWER_NODE) +
214d7a
-            (sizeof (ACPI_MPST_POWER_STATE) * Subtable0->NumPowerStates) +
214d7a
-            (sizeof (ACPI_MPST_COMPONENT) * Subtable0->NumPhysicalComponents));
214d7a
+            (sizeof (ACPI_MPST_POWER_STATE) *
214d7a
+                AcpiUtReadUint16 (&Subtable0->NumPowerStates)) +
214d7a
+            (sizeof (ACPI_MPST_COMPONENT) *
214d7a
+                AcpiUtReadUint16 (&Subtable0->NumPhysicalComponents)));
214d7a
     }
214d7a
 
214d7a
     /* Subtable: Count of Memory Power State Characteristic structures */
214d7a
 
214d7a
     AcpiOsPrintf ("\n");
214d7a
     Subtable1 = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable0);
214d7a
-    Status = AcpiDmDumpTable (Table->Length, Offset, Subtable1,
214d7a
+    Status = AcpiDmDumpTable (TableLength, Offset, Subtable1,
214d7a
         sizeof (ACPI_MPST_DATA_HDR), AcpiDmTableInfoMpst1);
214d7a
     if (ACPI_FAILURE (Status))
214d7a
     {
214d7a
         return;
214d7a
     }
214d7a
 
214d7a
-    SubtableCount = Subtable1->CharacteristicsCount;
214d7a
+    SubtableCount = AcpiUtReadUint16 (&Subtable1->CharacteristicsCount);
214d7a
     Offset += sizeof (ACPI_MPST_DATA_HDR);
214d7a
 
214d7a
     /* Subtable: Memory Power State Characteristics structure(s) */
214d7a
@@ -1097,10 +1102,10 @@ AcpiDmDumpMpst (
214d7a
     Subtable2 = ACPI_ADD_PTR (ACPI_MPST_POWER_DATA, Subtable1,
214d7a
         sizeof (ACPI_MPST_DATA_HDR));
214d7a
 
214d7a
-    while ((Offset < Table->Length) && SubtableCount)
214d7a
+    while ((Offset < TableLength) && SubtableCount)
214d7a
     {
214d7a
         AcpiOsPrintf ("\n");
214d7a
-        Status = AcpiDmDumpTable (Table->Length, Offset, Subtable2,
214d7a
+        Status = AcpiDmDumpTable (TableLength, Offset, Subtable2,
214d7a
             sizeof (ACPI_MPST_POWER_DATA), AcpiDmTableInfoMpst2);
214d7a
         if (ACPI_FAILURE (Status))
214d7a
         {
214d7a
Index: acpica-unix2-20210604/source/compiler/dttable2.c
214d7a
===================================================================
214d7a
--- acpica-unix2-20210604.orig/source/compiler/dttable2.c
214d7a
+++ acpica-unix2-20210604/source/compiler/dttable2.c
214d7a
@@ -350,7 +350,7 @@ DtCompileMpst (
214d7a
     DtPushSubtable (Subtable);
214d7a
 
214d7a
     MpstChannelInfo = ACPI_CAST_PTR (ACPI_MPST_CHANNEL, Subtable->Buffer);
214d7a
-    SubtableCount = MpstChannelInfo->PowerNodeCount;
214d7a
+    SubtableCount = AcpiUtReadUint16 (&MpstChannelInfo->PowerNodeCount);
214d7a
 
214d7a
     while (*PFieldList && SubtableCount)
214d7a
     {
214d7a
@@ -368,8 +368,8 @@ DtCompileMpst (
214d7a
         DtPushSubtable (Subtable);
214d7a
 
214d7a
         MpstPowerNode = ACPI_CAST_PTR (ACPI_MPST_POWER_NODE, Subtable->Buffer);
214d7a
-        PowerStateCount = MpstPowerNode->NumPowerStates;
214d7a
-        ComponentCount = MpstPowerNode->NumPhysicalComponents;
214d7a
+        PowerStateCount = AcpiUtReadUint16 (&MpstPowerNode->NumPowerStates);
214d7a
+        ComponentCount = AcpiUtReadUint16 (&MpstPowerNode->NumPhysicalComponents);
214d7a
 
214d7a
         ParentTable = DtPeekSubtable ();
214d7a
 
214d7a
@@ -422,7 +422,7 @@ DtCompileMpst (
214d7a
     DtPushSubtable (Subtable);
214d7a
 
214d7a
     MpstDataHeader = ACPI_CAST_PTR (ACPI_MPST_DATA_HDR, Subtable->Buffer);
214d7a
-    SubtableCount = MpstDataHeader->CharacteristicsCount;
214d7a
+    SubtableCount = AcpiUtReadUint16(&MpstDataHeader->CharacteristicsCount);
214d7a
 
214d7a
     ParentTable = DtPeekSubtable ();
214d7a