[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 8/9] tests: acpi: squash sanitize_fadt_ptrs() into t
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 8/9] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table() |
Date: |
Mon, 10 Dec 2018 19:10:14 +0100 |
some parts of sanitize_fadt_ptrs() do redundant job
- locating FADT
- checking original checksum
There is no need to do it as test_acpi_fadt_table() already does that,
so drop duplicate code and move remaining fixup code into
test_acpi_fadt_table().
Signed-off-by: Igor Mammedov <address@hidden>
---
tests/bios-tables-test.c | 40 ++++++++++------------------------------
1 file changed, 10 insertions(+), 30 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 9aa7c86..40b224f 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -126,6 +126,7 @@ static void test_acpi_fadt_table(test_data *data)
/* FADT table is 1st */
AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
uint8_t *fadt_aml = table.aml;
+ uint32_t fadt_len = table.aml_len;
ACPI_ASSERT_CMP(table.header->signature, "FACP");
@@ -137,36 +138,17 @@ static void test_acpi_fadt_table(test_data *data)
acpi_fetch_table(&table.aml, &table.aml_len,
fadt_aml + 40 /* DSDT */, "DSDT", true);
g_array_append_val(data->tables, table);
-}
-
-static void sanitize_fadt_ptrs(test_data *data)
-{
- /* fixup pointers in FADT */
- int i;
-
- for (i = 0; i < data->tables->len; i++) {
- AcpiSdtTable *sdt = &g_array_index(data->tables, AcpiSdtTable, i);
-
- if (memcmp(&sdt->header->signature, "FACP", 4)) {
- continue;
- }
- /* check original FADT checksum before sanitizing table */
- g_assert(!acpi_calc_checksum((uint8_t *)sdt->aml, sdt->aml_len));
-
- /* sdt->aml field offset := spec offset - header size */
- memset(sdt->aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
- memset(sdt->aml + 40, 0, 4); /* sanitize DSDT ptr */
- if (sdt->header->revision >= 3) {
- memset(sdt->aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
- memset(sdt->aml + 140, 0, 8); /* sanitize X_DSDT ptr */
- }
-
- /* update checksum */
- sdt->header->checksum = 0;
- sdt->header->checksum -= acpi_calc_checksum(sdt->aml, sdt->aml_len);
- break;
+ memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
+ memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */
+ if (fadt_aml[8 /* FADT Major Version */] >= 3) {
+ memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
+ memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */
}
+
+ /* update checksum */
+ fadt_aml[9 /* Checksum */] = 0;
+ fadt_aml[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml, fadt_len);
}
static void dump_aml_files(test_data *data, bool rebuild)
@@ -537,8 +519,6 @@ static void test_acpi_one(const char *params, test_data
*data)
test_acpi_rsdt_table(data);
test_acpi_fadt_table(data);
- sanitize_fadt_ptrs(data);
-
if (iasl) {
if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
dump_aml_files(data, true);
--
2.7.4
- [Qemu-devel] [PATCH 0/9] tests: apci: consolidate and cleanup ACPI test code, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 1/9] tests: acpi: remove not used ACPI_READ_GENERIC_ADDRESS macro, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 4/9] tests: acpi: simplify rsdt handling, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 3/9] tests: acpi: make sure FADT is fetched only once, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 2/9] tests: acpi: use AcpiSdtTable::aml in consistent way, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 5/9] tests: acpi: reuse fetch_table() for fetching FACS and DSDT, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 6/9] tests: acpi: reuse fetch_table() in vmgenid-test, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 8/9] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table(),
Igor Mammedov <=
- [Qemu-devel] [PATCH 7/9] tests: smbios: fetch whole table in one step instead of reading it step by step, Igor Mammedov, 2018/12/10
- [Qemu-devel] [PATCH 9/9] tests: acpi: use AcpiSdtTable::aml instead of AcpiSdtTable::header::signature, Igor Mammedov, 2018/12/10
- Re: [Qemu-devel] [PATCH 0/9] tests: apci: consolidate and cleanup ACPI test code, Michael S. Tsirkin, 2018/12/19