acpica-tools/0045-CSRT-fixed-use-of-optional-ResourceInfo.patch
Al Stone fc3eef63e8 Update to 20220331 upstream sources
This includes new source tarballs, updated patches, and updated
expected results for test cases.  In addition, three new tables
(PRMT, RGRT and SVKL) now have big-endian support.

Signed-off-by: Al Stone <ahs3@redhat.com>
2022-04-03 15:18:02 -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-20220331/source/common/dmtbdump1.c
===================================================================
--- acpica-unix2-20220331.orig/source/common/dmtbdump1.c
+++ acpica-unix2-20220331/source/common/dmtbdump1.c
@@ -669,11 +669,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 */
@@ -681,13 +683,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;
@@ -700,26 +703,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;
@@ -729,11 +734,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))
{
@@ -743,16 +749,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-20220331/source/compiler/dttable1.c
===================================================================
--- acpica-unix2-20220331.orig/source/compiler/dttable1.c
+++ acpica-unix2-20220331/source/compiler/dttable1.c
@@ -716,14 +716,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 */
@@ -738,16 +740,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 ();
@@ -762,10 +761,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,
@@ -774,6 +776,10 @@ DtCompileCsrt (
{
return (Status);
}
+ DescriptorLength = AcpiUtReadUint32 (
+ &(ACPI_CAST_PTR (ACPI_CSRT_GROUP,
+ Subtable->Buffer))->Length);
+
DtInsertSubtable (ParentTable, Subtable);
@@ -783,11 +789,7 @@ DtCompileCsrt (
{
Status = DtCompileTable (PFieldList, AcpiDmTableInfoCsrt2a,
&Subtable);
- if (ACPI_FAILURE (Status))
- {
- return (Status);
- }
- if (Subtable)
+ if (ACPI_SUCCESS (Status) && Subtable)
{
DtInsertSubtable (ParentTable, Subtable);
}
@@ -795,7 +797,7 @@ DtCompileCsrt (
DtPopSubtable ();
ParentTable = DtPeekSubtable ();
- DescriptorCount--;
+ Offset += DescriptorLength;
}
DtPopSubtable ();