acpica-tools/SOURCES/0045-CSRT-fixed-use-of-optional-ResourceInfo.patch

214 lines
7.8 KiB
Diff
Raw Normal View History

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