Skip to content

Commit

Permalink
Tables: Add deferred table verification support
Browse files Browse the repository at this point in the history
This patch allows tables not verified in early stage verfied in
AcpiReallocateRootTable(). This is useful for OSPMs like linux where tables
cannot be verified in early stage due to early ioremp limitations on some
architectures. Reported by Hans de Geode, fixed by Lv Zheng.

Reported-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Jun 16, 2017
1 parent c0d0684 commit d97b6ee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
32 changes: 26 additions & 6 deletions source/components/tables/tbdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@ AcpiTbCheckDuplication (

for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
{
/* Do not compare with unverified tables */

if (!(AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_VERIFIED))
{
continue;
}

/*
* Check for a table match on the entire table length,
* not just the header.
Expand Down Expand Up @@ -713,6 +720,8 @@ AcpiTbVerifyTempTable (
goto InvalidateAndExit;
}
}

TableDesc->Flags |= ACPI_TABLE_IS_VERIFIED;
}

return_ACPI_STATUS (Status);
Expand Down Expand Up @@ -741,6 +750,8 @@ AcpiTbResizeRootTableList (
{
ACPI_TABLE_DESC *Tables;
UINT32 TableCount;
UINT32 CurrentTableCount, MaxTableCount;
UINT32 i;


ACPI_FUNCTION_TRACE (TbResizeRootTableList);
Expand All @@ -765,9 +776,9 @@ AcpiTbResizeRootTableList (
TableCount = AcpiGbl_RootTableList.CurrentTableCount;
}

MaxTableCount = TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
Tables = ACPI_ALLOCATE_ZEROED (
((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *
sizeof (ACPI_TABLE_DESC));
((ACPI_SIZE) MaxTableCount) * sizeof (ACPI_TABLE_DESC));
if (!Tables)
{
ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
Expand All @@ -776,10 +787,19 @@ AcpiTbResizeRootTableList (

/* Copy and free the previous table array */

CurrentTableCount = 0;
if (AcpiGbl_RootTableList.Tables)
{
memcpy (Tables, AcpiGbl_RootTableList.Tables,
(ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
for (i = 0; i < TableCount; i++)
{
if (AcpiGbl_RootTableList.Tables[i].Address)
{
memcpy (Tables + CurrentTableCount,
AcpiGbl_RootTableList.Tables + i,
sizeof (ACPI_TABLE_DESC));
CurrentTableCount++;
}
}

if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
{
Expand All @@ -788,8 +808,8 @@ AcpiTbResizeRootTableList (
}

AcpiGbl_RootTableList.Tables = Tables;
AcpiGbl_RootTableList.MaxTableCount =
TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
AcpiGbl_RootTableList.MaxTableCount = MaxTableCount;
AcpiGbl_RootTableList.CurrentTableCount = CurrentTableCount;
AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;

return_ACPI_STATUS (AE_OK);
Expand Down
24 changes: 21 additions & 3 deletions source/components/tables/tbxface.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ AcpiReallocateRootTable (
void)
{
ACPI_STATUS Status;
ACPI_TABLE_DESC *TableDesc;
UINT32 i;


Expand All @@ -307,6 +308,8 @@ AcpiReallocateRootTable (
return_ACPI_STATUS (AE_SUPPORT);
}

(void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);

/*
* Ensure OS early boot logic, which is required by some hosts. If the
* table state is reported to be wrong, developers should fix the
Expand All @@ -315,11 +318,12 @@ AcpiReallocateRootTable (
*/
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
{
if (AcpiGbl_RootTableList.Tables[i].Pointer)
TableDesc = &AcpiGbl_RootTableList.Tables[i];
if (TableDesc->Pointer)
{
ACPI_ERROR ((AE_INFO,
"Table [%4.4s] is not invalidated during early boot stage",
AcpiGbl_RootTableList.Tables[i].Signature.Ascii));
TableDesc->Signature.Ascii));
}
}

Expand All @@ -330,11 +334,25 @@ AcpiReallocateRootTable (
* table initilization here once the flag is set.
*/
AcpiGbl_EnableTableValidation = TRUE;
for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
{
TableDesc = &AcpiGbl_RootTableList.Tables[i];
if (!(TableDesc->Flags & ACPI_TABLE_IS_VERIFIED))
{
Status = AcpiTbVerifyTempTable (TableDesc, NULL, NULL);
if (ACPI_FAILURE (Status))
{
AcpiTbUninstallTable (TableDesc);
}
}
}
}

AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;

Status = AcpiTbResizeRootTableList ();
AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;

(void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
return_ACPI_STATUS (Status);
}

Expand Down
1 change: 1 addition & 0 deletions source/include/actbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ typedef struct acpi_table_desc
#define ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL (1) /* Physical address, internally mapped */
#define ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL (2) /* Virtual address, internallly allocated */
#define ACPI_TABLE_ORIGIN_MASK (3)
#define ACPI_TABLE_IS_VERIFIED (4)
#define ACPI_TABLE_IS_LOADED (8)


Expand Down

0 comments on commit d97b6ee

Please sign in to comment.