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

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