2021-07-12 03:22:10 +00:00
|
|
|
From b3051bc2bad8988f3ad81a8307de6f1d0eef4ace Mon Sep 17 00:00:00 2001
|
2020-10-19 18:24:09 +00:00
|
|
|
From: Al Stone <ahs3@redhat.com>
|
|
|
|
Date: Sun, 20 Sep 2020 11:42:21 -0600
|
2021-07-12 03:22:10 +00:00
|
|
|
Subject: [PATCH 16/45] Support FADT (aka, FACP) in a big-endian world
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
Signed-off-by: Al Stone <ahs3@redhat.com>
|
|
|
|
---
|
|
|
|
source/common/dmtbdump.c | 25 ++++++++++++-----------
|
|
|
|
source/components/tables/tbfadt.c | 34 +++++++++++++++++++++++--------
|
|
|
|
2 files changed, 38 insertions(+), 21 deletions(-)
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
Index: acpica-unix2-20210604/source/common/dmtbdump.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2021-07-12 03:22:10 +00:00
|
|
|
--- acpica-unix2-20210604.orig/source/common/dmtbdump.c
|
|
|
|
+++ acpica-unix2-20210604/source/common/dmtbdump.c
|
|
|
|
@@ -363,11 +363,12 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
ACPI_TABLE_HEADER *Table)
|
|
|
|
{
|
|
|
|
ACPI_STATUS Status;
|
2021-07-12 03:22:10 +00:00
|
|
|
+ UINT32 TableLength = AcpiUtReadUint32 (&Table->Length);
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
|
|
|
|
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
|
AcpiDmTableInfoFadt1);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -376,10 +377,10 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
|
|
|
|
|
|
|
|
- if ((Table->Length > ACPI_FADT_V1_SIZE) &&
|
|
|
|
- (Table->Length <= ACPI_FADT_V2_SIZE))
|
|
|
|
+ if ((TableLength > ACPI_FADT_V1_SIZE) &&
|
|
|
|
+ (TableLength <= ACPI_FADT_V2_SIZE))
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
|
AcpiDmTableInfoFadt2);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -389,9 +390,9 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
|
|
|
|
|
|
|
|
- else if (Table->Length > ACPI_FADT_V2_SIZE)
|
|
|
|
+ else if (TableLength > ACPI_FADT_V2_SIZE)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
|
AcpiDmTableInfoFadt3);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -400,9 +401,9 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Check for FADT revision 5 fields and up (ACPI 5.0+) */
|
|
|
|
|
|
|
|
- if (Table->Length > ACPI_FADT_V3_SIZE)
|
|
|
|
+ if (TableLength > ACPI_FADT_V3_SIZE)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
|
AcpiDmTableInfoFadt5);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -412,9 +413,9 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Check for FADT revision 6 fields and up (ACPI 6.0+) */
|
|
|
|
|
|
|
|
- if (Table->Length > ACPI_FADT_V3_SIZE)
|
|
|
|
+ if (TableLength > ACPI_FADT_V3_SIZE)
|
|
|
|
{
|
|
|
|
- Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
|
|
|
|
+ Status = AcpiDmDumpTable (TableLength, 0, Table, 0,
|
|
|
|
AcpiDmTableInfoFadt6);
|
|
|
|
if (ACPI_FAILURE (Status))
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
@@ -425,11 +426,11 @@ AcpiDmDumpFadt (
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* Validate various fields in the FADT, including length */
|
|
|
|
|
|
|
|
- AcpiTbCreateLocalFadt (Table, Table->Length);
|
|
|
|
+ AcpiTbCreateLocalFadt (Table, TableLength);
|
|
|
|
|
|
|
|
/* Validate FADT length against the revision */
|
|
|
|
|
|
|
|
- AcpiDmValidateFadtLength (Table->Revision, Table->Length);
|
|
|
|
+ AcpiDmValidateFadtLength (Table->Revision, TableLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-12 03:22:10 +00:00
|
|
|
Index: acpica-unix2-20210604/source/components/tables/tbfadt.c
|
2020-10-19 18:24:09 +00:00
|
|
|
===================================================================
|
2021-07-12 03:22:10 +00:00
|
|
|
--- acpica-unix2-20210604.orig/source/components/tables/tbfadt.c
|
|
|
|
+++ acpica-unix2-20210604/source/components/tables/tbfadt.c
|
2020-10-19 18:24:09 +00:00
|
|
|
@@ -289,7 +289,6 @@ AcpiTbSelectAddress (
|
|
|
|
UINT32 Address32,
|
|
|
|
UINT64 Address64)
|
|
|
|
{
|
|
|
|
-
|
|
|
|
if (!Address64)
|
|
|
|
{
|
|
|
|
/* 64-bit address is zero, use 32-bit address */
|
|
|
|
@@ -520,6 +519,9 @@ AcpiTbConvertFadt (
|
|
|
|
UINT8 Length;
|
|
|
|
UINT8 Flags;
|
|
|
|
UINT32 i;
|
|
|
|
+ UINT32 Tmp;
|
|
|
|
+ UINT32 Value32;
|
|
|
|
+ UINT64 Value64;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
@@ -533,7 +535,7 @@ AcpiTbConvertFadt (
|
|
|
|
* Note: The FADT revision value is unreliable. Only the length can be
|
|
|
|
* trusted.
|
|
|
|
*/
|
|
|
|
- if (AcpiGbl_FADT.Header.Length <= ACPI_FADT_V2_SIZE)
|
2021-07-12 03:22:10 +00:00
|
|
|
+ if (AcpiUtReadUint32 (&AcpiGbl_FADT.Header.Length) <= ACPI_FADT_V2_SIZE)
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
AcpiGbl_FADT.PreferredProfile = 0;
|
|
|
|
AcpiGbl_FADT.PstateControl = 0;
|
|
|
|
@@ -546,14 +548,19 @@ AcpiTbConvertFadt (
|
|
|
|
* current FADT version as defined by the ACPI specification.
|
|
|
|
* Thus, we will have a common FADT internally.
|
|
|
|
*/
|
|
|
|
- AcpiGbl_FADT.Header.Length = sizeof (ACPI_TABLE_FADT);
|
|
|
|
+ Tmp = sizeof (ACPI_TABLE_FADT);
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&AcpiGbl_FADT.Header.Length, sizeof (UINT32),
|
|
|
|
+ &Tmp, sizeof (UINT32));
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Expand the 32-bit DSDT addresses to 64-bit as necessary.
|
|
|
|
* Later ACPICA code will always use the X 64-bit field.
|
|
|
|
*/
|
|
|
|
- AcpiGbl_FADT.XDsdt = AcpiTbSelectAddress ("DSDT",
|
|
|
|
- AcpiGbl_FADT.Dsdt, AcpiGbl_FADT.XDsdt);
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Value32 = AcpiUtReadUint32 (&AcpiGbl_FADT.Dsdt);
|
|
|
|
+ Value64 = AcpiUtReadUint64 (&AcpiGbl_FADT.XDsdt);
|
2020-10-19 18:24:09 +00:00
|
|
|
+ Value64 = AcpiTbSelectAddress ("DSDT", Value32, Value64);
|
2021-07-12 03:22:10 +00:00
|
|
|
+ AcpiUtWriteUint (&AcpiGbl_FADT.XDsdt, sizeof (UINT64),
|
|
|
|
+ &Value64, sizeof (UINT64));
|
2020-10-19 18:24:09 +00:00
|
|
|
|
|
|
|
/* If Hardware Reduced flag is set, we are all done */
|
|
|
|
|
|
|
|
@@ -614,7 +621,11 @@ AcpiTbConvertFadt (
|
|
|
|
{
|
|
|
|
if (Address64->Address)
|
|
|
|
{
|
|
|
|
- if (Address64->Address != (UINT64) Address32)
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Value32 = AcpiUtReadUint32 (&Address32);
|
|
|
|
+ Value64 = AcpiUtReadUint64 (&Address64->Address);
|
2020-10-19 18:24:09 +00:00
|
|
|
+
|
|
|
|
+ /* if (Address64->Address != (UINT64) Address32) */
|
2021-07-12 03:22:10 +00:00
|
|
|
+ if (Value64 != (UINT64) Value32)
|
2020-10-19 18:24:09 +00:00
|
|
|
{
|
|
|
|
/* Address mismatch */
|
|
|
|
|
|
|
|
@@ -655,9 +666,10 @@ AcpiTbConvertFadt (
|
|
|
|
*/
|
|
|
|
if (!Address64->Address || AcpiGbl_Use32BitFadtAddresses)
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Value32 = AcpiUtReadUint32 (&Address32);
|
2020-10-19 18:24:09 +00:00
|
|
|
AcpiTbInitGenericAddress (Address64,
|
|
|
|
ACPI_ADR_SPACE_SYSTEM_IO, Length,
|
|
|
|
- (UINT64) Address32, Name, Flags);
|
|
|
|
+ (UINT64) Value32, Name, Flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@@ -780,10 +792,14 @@ AcpiTbSetupFadtRegisters (
|
|
|
|
|
|
|
|
if (Source64->Address)
|
|
|
|
{
|
2021-07-12 03:22:10 +00:00
|
|
|
+ UINT64 Address64;
|
2020-10-19 18:24:09 +00:00
|
|
|
+
|
2021-07-12 03:22:10 +00:00
|
|
|
+ Address64 = AcpiUtReadUint64 (&Source64->Address);
|
|
|
|
+ Address64 +=
|
|
|
|
+ (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth);
|
2020-10-19 18:24:09 +00:00
|
|
|
AcpiTbInitGenericAddress (FadtPmInfoTable[i].Target,
|
|
|
|
Source64->SpaceId, Pm1RegisterByteWidth,
|
|
|
|
- Source64->Address +
|
|
|
|
- (FadtPmInfoTable[i].RegisterNum * Pm1RegisterByteWidth),
|
|
|
|
+ Address64,
|
|
|
|
"PmRegisters", 0);
|
|
|
|
}
|
|
|
|
}
|