acpica-tools/0045-CSRT-fixed-use-of-optional-ResourceInfo.patch
Al Stone 97df1c2ef7 Update all patches to match upstream 20211217 release
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-03-18 16:08:40 -06:00

214 lines
7.8 KiB
Diff

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-20211217/source/common/dmtbdump1.c
===================================================================
--- acpica-unix2-20211217.orig/source/common/dmtbdump1.c
+++ acpica-unix2-20211217/source/common/dmtbdump1.c
@@ -591,11 +591,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 */
@@ -603,13 +605,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;
@@ -622,26 +625,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;
@@ -651,11 +656,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))
{
@@ -665,16 +671,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-20211217/source/compiler/dttable1.c
===================================================================
--- acpica-unix2-20211217.orig/source/compiler/dttable1.c
+++ acpica-unix2-20211217/source/compiler/dttable1.c
@@ -570,14 +570,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 */
@@ -592,16 +594,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 ();
@@ -616,10 +615,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,
@@ -628,6 +630,10 @@ DtCompileCsrt (
{
return (Status);
}
+ DescriptorLength = AcpiUtReadUint32 (
+ &(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
+ Subtable->Buffer))->Length);
+
DtInsertSubtable (ParentTable, Subtable);
@@ -637,11 +643,7 @@ DtCompileCsrt (
{
Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a,
&Subtable);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- if (Subtable)
+ if (ACPI_SUCCESS (Status) && Subtable)
{
DtInsertSubtable (ParentTable, Subtable);
}
@@ -649,7 +651,7 @@ DtCompileCsrt (
DtPopSubtable ();
ParentTable = DtPeekSubtable ();
- DescriptorCount--;
+ Offset += DescriptorLength;
}
DtPopSubtable ();