From 89d47c1927094edde494e533dc1c24e8ac34323c Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Wed, 28 Feb 2018 15:23:55 +0100 Subject: tests: acpi: don't read all fields in test_acpi_fadt_table() there is no point to read fields here but not actually checking them so drop it and read only header + dsdt/facs addresses since it's needed later to fetch that tables. With this cleanup we can get rid of AcpiFadtDescriptorRev3/ ACPI_FADT_COMMON_DEF which have no users left. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger Tested-by: Eric Auger Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test.c | 82 +++++++++++------------------------------------- 1 file changed, 18 insertions(+), 64 deletions(-) (limited to 'tests') diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index 65b271a173..cd753ffe4b 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -29,7 +29,8 @@ typedef struct { uint32_t rsdp_addr; AcpiRsdpDescriptor rsdp_table; AcpiRsdtDescriptorRev1 rsdt_table; - AcpiFadtDescriptorRev3 fadt_table; + uint32_t dsdt_addr; + uint32_t facs_addr; AcpiFacsDescriptorRev1 facs_table; uint32_t *rsdt_tables_addr; int rsdt_tables_nr; @@ -127,71 +128,18 @@ static void test_acpi_rsdt_table(test_data *data) data->rsdt_tables_nr = tables_nr; } -static void test_acpi_fadt_table(test_data *data) +static void fadt_fetch_facs_and_dsdt_ptrs(test_data *data) { - AcpiFadtDescriptorRev3 *fadt_table = &data->fadt_table; uint32_t addr; + AcpiTableHeader hdr; /* FADT table comes first */ addr = le32_to_cpu(data->rsdt_tables_addr[0]); - ACPI_READ_TABLE_HEADER(fadt_table, addr); - - ACPI_READ_FIELD(fadt_table->firmware_ctrl, addr); - ACPI_READ_FIELD(fadt_table->dsdt, addr); - ACPI_READ_FIELD(fadt_table->model, addr); - ACPI_READ_FIELD(fadt_table->reserved1, addr); - ACPI_READ_FIELD(fadt_table->sci_int, addr); - ACPI_READ_FIELD(fadt_table->smi_cmd, addr); - ACPI_READ_FIELD(fadt_table->acpi_enable, addr); - ACPI_READ_FIELD(fadt_table->acpi_disable, addr); - ACPI_READ_FIELD(fadt_table->S4bios_req, addr); - ACPI_READ_FIELD(fadt_table->reserved2, addr); - ACPI_READ_FIELD(fadt_table->pm1a_evt_blk, addr); - ACPI_READ_FIELD(fadt_table->pm1b_evt_blk, addr); - ACPI_READ_FIELD(fadt_table->pm1a_cnt_blk, addr); - ACPI_READ_FIELD(fadt_table->pm1b_cnt_blk, addr); - ACPI_READ_FIELD(fadt_table->pm2_cnt_blk, addr); - ACPI_READ_FIELD(fadt_table->pm_tmr_blk, addr); - ACPI_READ_FIELD(fadt_table->gpe0_blk, addr); - ACPI_READ_FIELD(fadt_table->gpe1_blk, addr); - ACPI_READ_FIELD(fadt_table->pm1_evt_len, addr); - ACPI_READ_FIELD(fadt_table->pm1_cnt_len, addr); - ACPI_READ_FIELD(fadt_table->pm2_cnt_len, addr); - ACPI_READ_FIELD(fadt_table->pm_tmr_len, addr); - ACPI_READ_FIELD(fadt_table->gpe0_blk_len, addr); - ACPI_READ_FIELD(fadt_table->gpe1_blk_len, addr); - ACPI_READ_FIELD(fadt_table->gpe1_base, addr); - ACPI_READ_FIELD(fadt_table->reserved3, addr); - ACPI_READ_FIELD(fadt_table->plvl2_lat, addr); - ACPI_READ_FIELD(fadt_table->plvl3_lat, addr); - ACPI_READ_FIELD(fadt_table->flush_size, addr); - ACPI_READ_FIELD(fadt_table->flush_stride, addr); - ACPI_READ_FIELD(fadt_table->duty_offset, addr); - ACPI_READ_FIELD(fadt_table->duty_width, addr); - ACPI_READ_FIELD(fadt_table->day_alrm, addr); - ACPI_READ_FIELD(fadt_table->mon_alrm, addr); - ACPI_READ_FIELD(fadt_table->century, addr); - ACPI_READ_FIELD(fadt_table->boot_flags, addr); - ACPI_READ_FIELD(fadt_table->reserved, addr); - ACPI_READ_FIELD(fadt_table->flags, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->reset_register, addr); - ACPI_READ_FIELD(fadt_table->reset_value, addr); - ACPI_READ_FIELD(fadt_table->arm_boot_flags, addr); - ACPI_READ_FIELD(fadt_table->minor_revision, addr); - ACPI_READ_FIELD(fadt_table->x_facs, addr); - ACPI_READ_FIELD(fadt_table->x_dsdt, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_event_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_event_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1a_control_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm1b_control_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm2_control_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xpm_timer_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe0_block, addr); - ACPI_READ_GENERIC_ADDRESS(fadt_table->xgpe1_block, addr); - - ACPI_ASSERT_CMP(fadt_table->signature, "FACP"); - g_assert(!acpi_calc_checksum((uint8_t *)fadt_table, - le32_to_cpu(fadt_table->length))); + ACPI_READ_TABLE_HEADER(&hdr, addr); + ACPI_ASSERT_CMP(hdr.signature, "FACP"); + + ACPI_READ_FIELD(data->facs_addr, addr); + ACPI_READ_FIELD(data->dsdt_addr, addr); } static void sanitize_fadt_ptrs(test_data *data) @@ -206,6 +154,12 @@ static void sanitize_fadt_ptrs(test_data *data) continue; } + /* check original FADT checksum before sanitizing table */ + g_assert(!(uint8_t)( + acpi_calc_checksum((uint8_t *)sdt, sizeof(AcpiTableHeader)) + + acpi_calc_checksum((uint8_t *)sdt->aml, sdt->aml_len) + )); + /* sdt->aml field offset := spec offset - header size */ memset(sdt->aml + 0, 0, 4); /* sanitize FIRMWARE_CTRL(36) ptr */ memset(sdt->aml + 4, 0, 4); /* sanitize DSDT(40) ptr */ @@ -226,7 +180,7 @@ static void sanitize_fadt_ptrs(test_data *data) static void test_acpi_facs_table(test_data *data) { AcpiFacsDescriptorRev1 *facs_table = &data->facs_table; - uint32_t addr = le32_to_cpu(data->fadt_table.firmware_ctrl); + uint32_t addr = le32_to_cpu(data->facs_addr); ACPI_READ_FIELD(facs_table->signature, addr); ACPI_READ_FIELD(facs_table->length, addr); @@ -265,7 +219,7 @@ static void fetch_table(AcpiSdtTable *sdt_table, uint32_t addr) static void test_acpi_dsdt_table(test_data *data) { AcpiSdtTable dsdt_table; - uint32_t addr = le32_to_cpu(data->fadt_table.dsdt); + uint32_t addr = le32_to_cpu(data->dsdt_addr); fetch_table(&dsdt_table, addr); ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT"); @@ -674,7 +628,7 @@ static void test_acpi_one(const char *params, test_data *data) test_acpi_rsdp_address(data); test_acpi_rsdp_table(data); test_acpi_rsdt_table(data); - test_acpi_fadt_table(data); + fadt_fetch_facs_and_dsdt_ptrs(data); test_acpi_facs_table(data); test_acpi_dsdt_table(data); fetch_rsdt_referenced_tables(data); -- cgit v1.2.3 From adae91ce32082f411f7a5a29845be82aa2da8272 Mon Sep 17 00:00:00 2001 From: Haozhong Zhang Date: Sun, 11 Mar 2018 11:02:14 +0800 Subject: tests/bios-tables-test: add test cases for DIMM proximity QEMU now builds one SRAT memory affinity structure for each PC-DIMM and NVDIMM device presented at boot time with the proximity domain specified in the device option 'node', rather than only one SRAT memory affinity structure covering the entire hotpluggable address space with the proximity domain of the last node. Add test cases on PC and Q35 machines with 4 proximity domains, and one PC-DIMM and one NVDIMM attached to the 2nd and 3rd proximity domains respectively. Check whether the QEMU-built SRAT tables match with the expected ones. The following ACPI tables need to be added for this test: tests/acpi-test-data/pc/APIC.dimmpxm tests/acpi-test-data/pc/DSDT.dimmpxm tests/acpi-test-data/pc/NFIT.dimmpxm tests/acpi-test-data/pc/SRAT.dimmpxm tests/acpi-test-data/pc/SSDT.dimmpxm tests/acpi-test-data/q35/APIC.dimmpxm tests/acpi-test-data/q35/DSDT.dimmpxm tests/acpi-test-data/q35/NFIT.dimmpxm tests/acpi-test-data/q35/SRAT.dimmpxm tests/acpi-test-data/q35/SSDT.dimmpxm New APIC and DSDT are needed because of the multiple processors configuration. New NFIT and SSDT are needed because of NVDIMM. Signed-off-by: Haozhong Zhang Suggested-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/bios-tables-test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c index cd753ffe4b..bf3e193ae9 100644 --- a/tests/bios-tables-test.c +++ b/tests/bios-tables-test.c @@ -823,6 +823,42 @@ static void test_acpi_piix4_tcg_numamem(void) free_test_data(&data); } +static void test_acpi_tcg_dimm_pxm(const char *machine) +{ + test_data data; + + memset(&data, 0, sizeof(data)); + data.machine = machine; + data.variant = ".dimmpxm"; + test_acpi_one(" -machine nvdimm=on" + " -smp 4,sockets=4" + " -m 128M,slots=3,maxmem=1G" + " -numa node,mem=32M,nodeid=0" + " -numa node,mem=32M,nodeid=1" + " -numa node,mem=32M,nodeid=2" + " -numa node,mem=32M,nodeid=3" + " -numa cpu,node-id=0,socket-id=0" + " -numa cpu,node-id=1,socket-id=1" + " -numa cpu,node-id=2,socket-id=2" + " -numa cpu,node-id=3,socket-id=3" + " -object memory-backend-ram,id=ram0,size=128M" + " -object memory-backend-ram,id=nvm0,size=128M" + " -device pc-dimm,id=dimm0,memdev=ram0,node=1" + " -device nvdimm,id=dimm1,memdev=nvm0,node=2", + &data); + free_test_data(&data); +} + +static void test_acpi_q35_tcg_dimm_pxm(void) +{ + test_acpi_tcg_dimm_pxm(MACHINE_Q35); +} + +static void test_acpi_piix4_tcg_dimm_pxm(void) +{ + test_acpi_tcg_dimm_pxm(MACHINE_PC); +} + int main(int argc, char *argv[]) { const char *arch = qtest_get_arch(); @@ -847,6 +883,8 @@ int main(int argc, char *argv[]) qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp); qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem); qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem); + qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm); + qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm); } ret = g_test_run(); boot_sector_cleanup(disk); -- cgit v1.2.3 From e0e5c8583dd0f3912113011187ed7ef32f84c057 Mon Sep 17 00:00:00 2001 From: Haozhong Zhang Date: Sun, 11 Mar 2018 11:02:15 +0800 Subject: test/acpi-test-data: add ACPI tables for dimmpxm test Reviewers can use ACPI tables in this patch to run test_acpi_{piix4,q35}_tcg_dimm_pxm cases. Signed-off-by: Haozhong Zhang Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- tests/acpi-test-data/pc/APIC.dimmpxm | Bin 0 -> 144 bytes tests/acpi-test-data/pc/DSDT.dimmpxm | Bin 0 -> 6803 bytes tests/acpi-test-data/pc/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/pc/SRAT.dimmpxm | Bin 0 -> 472 bytes tests/acpi-test-data/pc/SSDT.dimmpxm | Bin 0 -> 685 bytes tests/acpi-test-data/q35/APIC.dimmpxm | Bin 0 -> 144 bytes tests/acpi-test-data/q35/DSDT.dimmpxm | Bin 0 -> 9487 bytes tests/acpi-test-data/q35/NFIT.dimmpxm | Bin 0 -> 224 bytes tests/acpi-test-data/q35/SRAT.dimmpxm | Bin 0 -> 472 bytes tests/acpi-test-data/q35/SSDT.dimmpxm | Bin 0 -> 685 bytes 10 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/acpi-test-data/pc/APIC.dimmpxm create mode 100644 tests/acpi-test-data/pc/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/pc/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/pc/SSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/APIC.dimmpxm create mode 100644 tests/acpi-test-data/q35/DSDT.dimmpxm create mode 100644 tests/acpi-test-data/q35/NFIT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SRAT.dimmpxm create mode 100644 tests/acpi-test-data/q35/SSDT.dimmpxm (limited to 'tests') diff --git a/tests/acpi-test-data/pc/APIC.dimmpxm b/tests/acpi-test-data/pc/APIC.dimmpxm new file mode 100644 index 0000000000..427bb08248 Binary files /dev/null and b/tests/acpi-test-data/pc/APIC.dimmpxm differ diff --git a/tests/acpi-test-data/pc/DSDT.dimmpxm b/tests/acpi-test-data/pc/DSDT.dimmpxm new file mode 100644 index 0000000000..38661cb13e Binary files /dev/null and b/tests/acpi-test-data/pc/DSDT.dimmpxm differ diff --git a/tests/acpi-test-data/pc/NFIT.dimmpxm b/tests/acpi-test-data/pc/NFIT.dimmpxm new file mode 100644 index 0000000000..2bfc6c51f3 Binary files /dev/null and b/tests/acpi-test-data/pc/NFIT.dimmpxm differ diff --git a/tests/acpi-test-data/pc/SRAT.dimmpxm b/tests/acpi-test-data/pc/SRAT.dimmpxm new file mode 100644 index 0000000000..3b10a607d5 Binary files /dev/null and b/tests/acpi-test-data/pc/SRAT.dimmpxm differ diff --git a/tests/acpi-test-data/pc/SSDT.dimmpxm b/tests/acpi-test-data/pc/SSDT.dimmpxm new file mode 100644 index 0000000000..8ba0e67cb7 Binary files /dev/null and b/tests/acpi-test-data/pc/SSDT.dimmpxm differ diff --git a/tests/acpi-test-data/q35/APIC.dimmpxm b/tests/acpi-test-data/q35/APIC.dimmpxm new file mode 100644 index 0000000000..427bb08248 Binary files /dev/null and b/tests/acpi-test-data/q35/APIC.dimmpxm differ diff --git a/tests/acpi-test-data/q35/DSDT.dimmpxm b/tests/acpi-test-data/q35/DSDT.dimmpxm new file mode 100644 index 0000000000..14904e8ea2 Binary files /dev/null and b/tests/acpi-test-data/q35/DSDT.dimmpxm differ diff --git a/tests/acpi-test-data/q35/NFIT.dimmpxm b/tests/acpi-test-data/q35/NFIT.dimmpxm new file mode 100644 index 0000000000..2bfc6c51f3 Binary files /dev/null and b/tests/acpi-test-data/q35/NFIT.dimmpxm differ diff --git a/tests/acpi-test-data/q35/SRAT.dimmpxm b/tests/acpi-test-data/q35/SRAT.dimmpxm new file mode 100644 index 0000000000..3b10a607d5 Binary files /dev/null and b/tests/acpi-test-data/q35/SRAT.dimmpxm differ diff --git a/tests/acpi-test-data/q35/SSDT.dimmpxm b/tests/acpi-test-data/q35/SSDT.dimmpxm new file mode 100644 index 0000000000..8ba0e67cb7 Binary files /dev/null and b/tests/acpi-test-data/q35/SSDT.dimmpxm differ -- cgit v1.2.3