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