|
|
214d7a |
From 0d87ee42adda7837bec3cc0ff86e40c2f2e8dc4f Mon Sep 17 00:00:00 2001
|
|
|
214d7a |
From: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
Date: Fri, 9 Jul 2021 14:52:55 -0600
|
|
|
214d7a |
Subject: [PATCH 45/45] CSRT: fixed use of optional ResourceInfo
|
|
|
214d7a |
|
|
|
214d7a |
In a resource sub-sub-table, there may be a ResourceInfo entry. Neither
|
|
|
214d7a |
the compiler nor disassembler accounted for that possibility properly.
|
|
|
214d7a |
|
|
|
214d7a |
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
214d7a |
---
|
|
|
214d7a |
source/common/dmtbdump1.c | 43 +++++++++++++++++++++-----------------
|
|
|
214d7a |
source/compiler/dttable1.c | 28 +++++++++++++------------
|
|
|
214d7a |
2 files changed, 39 insertions(+), 32 deletions(-)
|
|
|
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 |
@@ -374,11 +374,13 @@ AcpiDmDumpCsrt (
|
|
|
214d7a |
ACPI_CSRT_GROUP *Subtable;
|
|
|
214d7a |
ACPI_CSRT_SHARED_INFO *SharedInfoTable;
|
|
|
214d7a |
ACPI_CSRT_DESCRIPTOR *SubSubtable;
|
|
|
214d7a |
- UINT32 Length = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
|
|
214d7a |
UINT32 Offset = sizeof (ACPI_TABLE_CSRT);
|
|
|
214d7a |
UINT32 SubOffset;
|
|
|
214d7a |
UINT32 SubSubOffset;
|
|
|
214d7a |
UINT32 InfoLength;
|
|
|
214d7a |
+ UINT32 SubtableLength;
|
|
|
214d7a |
+ UINT32 SubSubtableLength;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* The main table only contains the ACPI header, thus already handled */
|
|
|
214d7a |
@@ -386,13 +388,14 @@ AcpiDmDumpCsrt (
|
|
|
214d7a |
/* Subtables (Resource Groups) */
|
|
|
214d7a |
|
|
|
214d7a |
Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Table, Offset);
|
|
|
214d7a |
- while (Offset < Length)
|
|
|
214d7a |
+ while (Offset < TableLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* Resource group subtable */
|
|
|
214d7a |
|
|
|
214d7a |
+ SubtableLength = AcpiUtReadUint32 (&Subtable->Length);
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Length, Offset, Subtable,
|
|
|
214d7a |
- Subtable->Length, AcpiDmTableInfoCsrt0);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset, Subtable,
|
|
|
214d7a |
+ SubtableLength, AcpiDmTableInfoCsrt0);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -405,26 +408,28 @@ AcpiDmDumpCsrt (
|
|
|
214d7a |
Offset + SubOffset);
|
|
|
214d7a |
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Length, Offset + SubOffset, SharedInfoTable,
|
|
|
214d7a |
- sizeof (ACPI_CSRT_SHARED_INFO), AcpiDmTableInfoCsrt1);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubOffset,
|
|
|
214d7a |
+ SharedInfoTable, sizeof (ACPI_CSRT_SHARED_INFO),
|
|
|
214d7a |
+ AcpiDmTableInfoCsrt1);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
- SubOffset += Subtable->SharedInfoLength;
|
|
|
214d7a |
+ SubOffset += AcpiUtReadUint32 (&Subtable->SharedInfoLength);
|
|
|
214d7a |
|
|
|
214d7a |
/* Sub-Subtables (Resource Descriptors) */
|
|
|
214d7a |
|
|
|
214d7a |
SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, Table,
|
|
|
214d7a |
Offset + SubOffset);
|
|
|
214d7a |
|
|
|
214d7a |
- while ((SubOffset < Subtable->Length) &&
|
|
|
214d7a |
- ((Offset + SubOffset) < Length))
|
|
|
214d7a |
+ while ((SubOffset < SubtableLength) &&
|
|
|
214d7a |
+ ((Offset + SubOffset) < TableLength))
|
|
|
214d7a |
{
|
|
|
214d7a |
+ SubSubtableLength = AcpiUtReadUint32 (&SubSubtable->Length);
|
|
|
214d7a |
AcpiOsPrintf ("\n");
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Length, Offset + SubOffset, SubSubtable,
|
|
|
214d7a |
- SubSubtable->Length, AcpiDmTableInfoCsrt2);
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength, Offset + SubOffset,
|
|
|
214d7a |
+ SubSubtable, SubSubtableLength, AcpiDmTableInfoCsrt2);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
return;
|
|
|
214d7a |
@@ -434,11 +439,12 @@ AcpiDmDumpCsrt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Resource-specific info buffer */
|
|
|
214d7a |
|
|
|
214d7a |
- InfoLength = SubSubtable->Length - SubSubOffset;
|
|
|
214d7a |
+ InfoLength = SubSubtableLength - SubSubOffset;
|
|
|
214d7a |
if (InfoLength)
|
|
|
214d7a |
{
|
|
|
214d7a |
- Status = AcpiDmDumpTable (Length,
|
|
|
214d7a |
- Offset + SubOffset + SubSubOffset, Table,
|
|
|
214d7a |
+ Status = AcpiDmDumpTable (TableLength,
|
|
|
214d7a |
+ Offset + SubOffset + SubSubOffset,
|
|
|
214d7a |
+ (UINT8 *)SubSubtable + SubSubOffset,
|
|
|
214d7a |
InfoLength, AcpiDmTableInfoCsrt2a);
|
|
|
214d7a |
if (ACPI_FAILURE (Status))
|
|
|
214d7a |
{
|
|
|
214d7a |
@@ -448,16 +454,15 @@ AcpiDmDumpCsrt (
|
|
|
214d7a |
|
|
|
214d7a |
/* Point to next sub-subtable */
|
|
|
214d7a |
|
|
|
214d7a |
- SubOffset += SubSubtable->Length;
|
|
|
214d7a |
+ SubOffset += SubSubtableLength;
|
|
|
214d7a |
SubSubtable = ACPI_ADD_PTR (ACPI_CSRT_DESCRIPTOR, SubSubtable,
|
|
|
214d7a |
- SubSubtable->Length);
|
|
|
214d7a |
+ SubSubtableLength);
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
/* Point to next subtable */
|
|
|
214d7a |
|
|
|
214d7a |
- Offset += Subtable->Length;
|
|
|
214d7a |
- Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable,
|
|
|
214d7a |
- Subtable->Length);
|
|
|
214d7a |
+ Offset += SubtableLength;
|
|
|
214d7a |
+ Subtable = ACPI_ADD_PTR (ACPI_CSRT_GROUP, Subtable, 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 |
@@ -353,14 +353,16 @@ DtCompileCsrt (
|
|
|
214d7a |
DT_SUBTABLE *Subtable;
|
|
|
214d7a |
DT_SUBTABLE *ParentTable;
|
|
|
214d7a |
DT_FIELD **PFieldList = (DT_FIELD **) List;
|
|
|
214d7a |
- UINT32 DescriptorCount;
|
|
|
214d7a |
+ UINT32 DescriptorLength;
|
|
|
214d7a |
UINT32 GroupLength;
|
|
|
214d7a |
UINT32 Tmp;
|
|
|
214d7a |
+ UINT32 Offset;
|
|
|
214d7a |
|
|
|
214d7a |
|
|
|
214d7a |
/* Subtables (Resource Groups) */
|
|
|
214d7a |
|
|
|
214d7a |
ParentTable = DtPeekSubtable ();
|
|
|
214d7a |
+
|
|
|
214d7a |
while (*PFieldList)
|
|
|
214d7a |
{
|
|
|
214d7a |
/* Resource group subtable */
|
|
|
214d7a |
@@ -375,16 +377,13 @@ DtCompileCsrt (
|
|
|
214d7a |
/* Compute the number of resource descriptors */
|
|
|
214d7a |
|
|
|
214d7a |
Tmp = AcpiUtReadUint32 (&(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
214d7a |
- Subtable->Buffer))->Length);
|
|
|
214d7a |
+ Subtable->Buffer))->Length);
|
|
|
214d7a |
GroupLength = Tmp;
|
|
|
214d7a |
Tmp = AcpiUtReadUint32 (&(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
214d7a |
- Subtable->Buffer))->SharedInfoLength);
|
|
|
214d7a |
+ Subtable->Buffer))->SharedInfoLength);
|
|
|
214d7a |
GroupLength -= Tmp;
|
|
|
214d7a |
GroupLength -= sizeof (ACPI_CSRT_GROUP);
|
|
|
214d7a |
|
|
|
214d7a |
- DescriptorCount = (GroupLength /
|
|
|
214d7a |
- sizeof (ACPI_CSRT_DESCRIPTOR));
|
|
|
214d7a |
-
|
|
|
214d7a |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
214d7a |
DtPushSubtable (Subtable);
|
|
|
214d7a |
ParentTable = DtPeekSubtable ();
|
|
|
214d7a |
@@ -399,10 +398,13 @@ DtCompileCsrt (
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
214d7a |
+ DtPushSubtable (Subtable);
|
|
|
214d7a |
+ ParentTable = DtPeekSubtable ();
|
|
|
214d7a |
|
|
|
214d7a |
/* Sub-Subtables (Resource Descriptors) */
|
|
|
214d7a |
|
|
|
214d7a |
- while (*PFieldList && DescriptorCount)
|
|
|
214d7a |
+ Offset = 0;
|
|
|
214d7a |
+ while (*PFieldList && (Offset < GroupLength))
|
|
|
214d7a |
{
|
|
|
214d7a |
|
|
|
214d7a |
Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2,
|
|
|
214d7a |
@@ -411,6 +413,10 @@ DtCompileCsrt (
|
|
|
214d7a |
{
|
|
|
214d7a |
return (Status);
|
|
|
214d7a |
}
|
|
|
214d7a |
+ DescriptorLength = AcpiUtReadUint32 (
|
|
|
214d7a |
+ &(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
|
|
|
214d7a |
+ Subtable->Buffer))->Length);
|
|
|
214d7a |
+
|
|
|
214d7a |
|
|
|
214d7a |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
214d7a |
|
|
|
214d7a |
@@ -420,11 +426,7 @@ DtCompileCsrt (
|
|
|
214d7a |
{
|
|
|
214d7a |
Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a,
|
|
|
214d7a |
&Subtable);
|
|
|
214d7a |
- if (ACPI_FAILURE (Status))
|
|
|
214d7a |
- {
|
|
|
214d7a |
- return (Status);
|
|
|
214d7a |
- }
|
|
|
214d7a |
- if (Subtable)
|
|
|
214d7a |
+ if (ACPI_SUCCESS (Status) && Subtable)
|
|
|
214d7a |
{
|
|
|
214d7a |
DtInsertSubtable (ParentTable, Subtable);
|
|
|
214d7a |
}
|
|
|
214d7a |
@@ -432,7 +434,7 @@ DtCompileCsrt (
|
|
|
214d7a |
|
|
|
214d7a |
DtPopSubtable ();
|
|
|
214d7a |
ParentTable = DtPeekSubtable ();
|
|
|
214d7a |
- DescriptorCount--;
|
|
|
214d7a |
+ Offset += DescriptorLength;
|
|
|
214d7a |
}
|
|
|
214d7a |
|
|
|
214d7a |
DtPopSubtable ();
|