[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 14/44] tests: acpi: squash sanitize_fadt_ptrs() into
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 14/44] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table() |
Date: |
Mon, 14 Jan 2019 20:36:09 -0500 |
From: Igor Mammedov <address@hidden>
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>
Acked-by: Thomas Huth <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
tests/bios-tables-test.c | 39 ++++++++++-----------------------------
1 file changed, 10 insertions(+), 29 deletions(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index dcd6be8bbd..9139decc68 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -128,6 +128,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");
@@ -139,35 +140,17 @@ static void test_acpi_fadt_table(test_data *data)
acpi_fetch_table(data->qts, &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(sdt->aml, sdt->aml_len));
-
- 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)
@@ -541,8 +524,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);
--
MST
- [Qemu-devel] [PULL 15/44] tests: acpi: use AcpiSdtTable::aml instead of AcpiSdtTable::header::signature, (continued)
- [Qemu-devel] [PULL 15/44] tests: acpi: use AcpiSdtTable::aml instead of AcpiSdtTable::header::signature, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 16/44] virtio-net: support RSC v4/v6 tcp traffic for Windows HCK, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 21/44] virtio: split virtio rng bits from virtio-pci, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 13/44] tests: smbios: fetch whole table in one step instead of reading it step by step, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 10/44] tests: acpi: simplify rsdt handling, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 06/44] vhost-user: fix ioeventfd_enabled, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 07/44] util: check the return value of fcntl in qemu_set_{block, nonblock}, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 08/44] tests: acpi: use AcpiSdtTable::aml in consistent way, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 17/44] virtio-net: changed VIRTIO_NET_F_RSC_EXT to be 61, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 23/44] virtio: split virtio 9p bits from virtio-pci, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 14/44] tests: acpi: squash sanitize_fadt_ptrs() into test_acpi_fadt_table(),
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 12/44] tests: acpi: reuse fetch_table() in vmgenid-test, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 09/44] tests: acpi: make sure FADT is fetched only once, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 01/44] pci/pcie: stop plug/unplug if the slot is locked, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 05/44] tests: vhost-user-test: initialize 'fd' in chr_read, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 04/44] qemu: avoid memory leak while remove disk, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 02/44] msix: make pba size math more uniform, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 03/44] hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 26/44] virtio: split vhost scsi bits from virtio-pci, Michael S. Tsirkin, 2019/01/14
- [Qemu-devel] [PULL 11/44] tests: acpi: reuse fetch_table() for fetching FACS and DSDT, Michael S. Tsirkin, 2019/01/14
- Re: [Qemu-devel] [PULL 00/44] pci, pc, virtio: fixes, features, Peter Xu, 2019/01/15