|
|
214d7a |
From 3d1ac6e76ad0c0d6454671b190ccbbfafb0cb4cc Mon Sep 17 00:00:00 2001
|
|
|
214d7a |
From: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
Date: Tue, 29 Jun 2021 16:03:36 -0600
|
|
|
214d7a |
Subject: [PATCH 27/45] Support SDEV in a big-endian world
|
|
|
214d7a |
|
|
|
214d7a |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
---
|
|
|
214d7a |
source/common/dmtbdump2.c | 48 +++++++++++++++++++++-----------------
|
|
|
214d7a |
source/compiler/dttable2.c | 27 ++++++++++++++++++++-
|
|
|
214d7a |
2 files changed, 52 insertions(+), 23 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 |
@@ -2125,7 +2125,7 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
ACPI_SDEV_NAMESPACE *Namesp;
|
|
|
214d7a |
ACPI_DMTABLE_INFO *InfoTable;
|
|
|
214d7a |
ACPI_DMTABLE_INFO *SecureComponentInfoTable;
|
|
|
214d7a |
- UINT32 Length = Table->Length;
|
|
|
214d7a |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
UINT32 Offset = sizeof (ACPI_TABLE_SDEV);
|
|
|
214d7a |
UINT16 PathOffset;
|
|
|
214d7a |
UINT16 PathLength;
|
|
|
214d7a |
@@ -2133,11 +2133,12 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
UINT16 VendorDataLength;
|
|
|
214d7a |
ACPI_SDEV_SECURE_COMPONENT *SecureComponent = NULL;
|
|
|
214d7a |
UINT32 CurrentOffset = 0;
|
|
|
214d7a |
+ UINT16 SubtableLength;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Main table */
|
|
|
214d7a |
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSdev);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0, AcpiDmTableInfoSdev);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -2146,13 +2147,14 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
/* Subtables */
|
|
|
214d7a |
|
|
|
214d7a |
Subtable = ACPI_ADD_PTR (ACPI_SDEV_HEADER, Table, Offset);
|
|
|
214d7a |
- while (Offset < Table->Length)
|
|
|
214d7a |
+ while (Offset < TableLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* Common subtable header */
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
|
|
|
214d7a |
- Subtable->Length, AcpiDmTableInfoSdevHdr);
|
|
|
214d7a |
+ SubtableLength = AcpiUtReadUint16 (&Subtable->Length);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
|
|
|
214d7a |
+ SubtableLength, AcpiDmTableInfoSdevHdr);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -2175,8 +2177,8 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0, Subtable,
|
|
|
214d7a |
- Subtable->Length, InfoTable);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0, Subtable,
|
|
|
214d7a |
+ SubtableLength, InfoTable);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -2235,12 +2237,12 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
/* Dump the PCIe device ID(s) */
|
|
|
214d7a |
|
|
|
214d7a |
Namesp = ACPI_CAST_PTR (ACPI_SDEV_NAMESPACE, Subtable);
|
|
|
214d7a |
- PathOffset = Namesp->DeviceIdOffset;
|
|
|
214d7a |
- PathLength = Namesp->DeviceIdLength;
|
|
|
214d7a |
+ PathOffset = AcpiUtReadUint16 (&Namesp->DeviceIdOffset);
|
|
|
214d7a |
+ PathLength = AcpiUtReadUint16 (&Namesp->DeviceIdLength);
|
|
|
214d7a |
|
|
|
214d7a |
if (PathLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, CurrentOffset,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, CurrentOffset,
|
|
|
214d7a |
ACPI_ADD_PTR (UINT8, Namesp, PathOffset),
|
|
|
214d7a |
PathLength, AcpiDmTableInfoSdev0a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -2252,14 +2254,14 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
|
|
|
214d7a |
/* Dump the vendor-specific data */
|
|
|
214d7a |
|
|
|
214d7a |
- VendorDataLength =
|
|
|
214d7a |
- Namesp->VendorDataLength;
|
|
|
214d7a |
+ VendorDataLength = AcpiUtReadUint16 (&Namesp->VendorDataLength);
|
|
|
214d7a |
VendorDataOffset =
|
|
|
214d7a |
- Namesp->DeviceIdOffset + Namesp->DeviceIdLength;
|
|
|
214d7a |
+ AcpiUtReadUint16 (&Namesp->DeviceIdOffset) +
|
|
|
214d7a |
+ AcpiUtReadUint16 (&Namesp->DeviceIdLength);
|
|
|
214d7a |
|
|
|
214d7a |
if (VendorDataLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0,
|
|
|
214d7a |
ACPI_ADD_PTR (UINT8, Namesp, VendorDataOffset),
|
|
|
214d7a |
VendorDataLength, AcpiDmTableInfoSdev1b);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -2274,12 +2276,12 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
/* PCI path substructures */
|
|
|
214d7a |
|
|
|
214d7a |
Pcie = ACPI_CAST_PTR (ACPI_SDEV_PCIE, Subtable);
|
|
|
214d7a |
- PathOffset = Pcie->PathOffset;
|
|
|
214d7a |
- PathLength = Pcie->PathLength;
|
|
|
214d7a |
+ PathOffset = AcpiUtReadUint16 (&Pcie->PathOffset);
|
|
|
214d7a |
+ PathLength = AcpiUtReadUint16 (&Pcie->PathLength);
|
|
|
214d7a |
|
|
|
214d7a |
while (PathLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength,
|
|
|
214d7a |
PathOffset + Offset,
|
|
|
214d7a |
ACPI_ADD_PTR (UINT8, Pcie, PathOffset),
|
|
|
214d7a |
sizeof (ACPI_SDEV_PCIE_PATH), AcpiDmTableInfoSdev1a);
|
|
|
214d7a |
@@ -2294,12 +2296,14 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
|
|
|
214d7a |
/* VendorData */
|
|
|
214d7a |
|
|
|
214d7a |
- VendorDataLength = Pcie->VendorDataLength;
|
|
|
214d7a |
- VendorDataOffset = Pcie->PathOffset + Pcie->PathLength;
|
|
|
214d7a |
+ VendorDataLength = AcpiUtReadUint16 (&Pcie->VendorDataLength);
|
|
|
214d7a |
+ VendorDataOffset =
|
|
|
214d7a |
+ AcpiUtReadUint16 (&Pcie->PathOffset) +
|
|
|
214d7a |
+ AcpiUtReadUint16 (&Pcie->PathLength);
|
|
|
214d7a |
|
|
|
214d7a |
if (VendorDataLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Table->Length, 0,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, 0,
|
|
|
214d7a |
ACPI_ADD_PTR (UINT8, Pcie, VendorDataOffset),
|
|
|
214d7a |
VendorDataLength, AcpiDmTableInfoSdev1b);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
@@ -2316,8 +2320,8 @@ AcpiDmDumpSdev (
|
|
|
214d7a |
NextSubtable:
|
|
|
214d7a |
/* Point to next subtable */
|
|
|
214d7a |
|
|
|
214d7a |
- Offset += Subtable->Length;
|
|
|
214d7a |
+ Offset += SubtableLength;
|
|
|
214d7a |
Subtable = ACPI_ADD_PTR (ACPI_SDEV_HEADER, Subtable,
|
|
|
214d7a |
- Subtable->Length);
|
|
|
214d7a |
+ SubtableLength);
|
|
|
214d7a |
}
|
|
|
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 |
@@ -1493,6 +1493,7 @@ DtCompileSdev (
|
|
|
214d7a |
UINT32 EntryCount;
|
|
|
214d7a |
ACPI_SDEV_SECURE_COMPONENT *SecureComponent = NULL;
|
|
|
214d7a |
UINT16 ComponentLength = 0;
|
|
|
214d7a |
+ UINT16 Tmp16;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Subtables */
|
|
|
214d7a |
@@ -1514,7 +1515,7 @@ DtCompileSdev (
|
|
|
214d7a |
DtPushSubtable (Subtable);
|
|
|
214d7a |
|
|
|
214d7a |
SdevHeader = ACPI_CAST_PTR (ACPI_SDEV_HEADER, Subtable->Buffer);
|
|
|
214d7a |
- SdevHeader->Length = (UINT8)(sizeof (ACPI_SDEV_HEADER));
|
|
|
214d7a |
+ SdevHeader->Length = (UINT16) (sizeof (ACPI_SDEV_HEADER));
|
|
|
214d7a |
|
|
|
214d7a |
switch (SdevHeader->Type)
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -1687,6 +1688,18 @@ DtCompileSdev (
|
|
|
214d7a |
}
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
+ /* Make sure everything is now little-endian */
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&SdevHeader->Length);
|
|
|
214d7a |
+ SdevHeader->Length = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Namesp->DeviceIdOffset);
|
|
|
214d7a |
+ Namesp->DeviceIdOffset = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Namesp->DeviceIdLength);
|
|
|
214d7a |
+ Namesp->DeviceIdLength = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Namesp->VendorDataOffset);
|
|
|
214d7a |
+ Namesp->VendorDataOffset = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Namesp->VendorDataLength);
|
|
|
214d7a |
+ Namesp->VendorDataLength = Tmp16;
|
|
|
214d7a |
+
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
case ACPI_SDEV_TYPE_PCIE_ENDPOINT_DEVICE:
|
|
|
214d7a |
@@ -1749,6 +1762,18 @@ DtCompileSdev (
|
|
|
214d7a |
SdevHeader->Length =
|
|
|
214d7a |
sizeof (ACPI_SDEV_PCIE) +
|
|
|
214d7a |
Pcie->PathLength + Pcie->VendorDataLength;
|
|
|
214d7a |
+
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&SdevHeader->Length);
|
|
|
214d7a |
+ SdevHeader->Length = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Pcie->PathOffset);
|
|
|
214d7a |
+ Pcie->PathOffset = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Pcie->PathLength);
|
|
|
214d7a |
+ Pcie->PathLength = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Pcie->VendorDataOffset);
|
|
|
214d7a |
+ Pcie->VendorDataOffset = Tmp16;
|
|
|
214d7a |
+ Tmp16 = AcpiUtReadUint16 (&Pcie->VendorDataLength);
|
|
|
214d7a |
+ Pcie->VendorDataLength = Tmp16;
|
|
|
214d7a |
+
|
|
|
214d7a |
break;
|
|
|
214d7a |
|
|
|
214d7a |
default:
|