2 * Boot order test cases.
4 * Copyright (c) 2013 Red Hat Inc.
7 * Michael S. Tsirkin <mst@redhat.com>,
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include <glib/gstdio.h>
15 #include "qemu-common.h"
16 #include "hw/firmware/smbios.h"
17 #include "qemu/bitmap.h"
18 #include "acpi-utils.h"
19 #include "boot-sector.h"
21 #define MACHINE_PC "pc"
22 #define MACHINE_Q35 "q35"
24 #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
33 const uint64_t ram_start
;
34 const uint64_t scan_len
;
36 uint8_t rsdp_table
[36 /* ACPI 2.0+ RSDP size */];
38 uint32_t smbios_ep_addr
;
39 struct smbios_21_entry_point smbios_ep_table
;
40 uint8_t *required_struct_types
;
41 int required_struct_types_len
;
45 static char disk
[] = "tests/acpi-test-disk-XXXXXX";
46 static const char *data_dir
= "tests/data/acpi";
48 static const char *iasl
= stringify(CONFIG_IASL
);
50 static const char *iasl
;
53 static bool compare_signature(const AcpiSdtTable
*sdt
, const char *signature
)
55 return !memcmp(sdt
->aml
, signature
, 4);
58 static void cleanup_table_descriptor(AcpiSdtTable
*table
)
61 if (table
->aml_file
&&
62 !table
->tmp_files_retain
&&
63 g_strstr_len(table
->aml_file
, -1, "aml-")) {
64 unlink(table
->aml_file
);
66 g_free(table
->aml_file
);
68 if (table
->asl_file
&&
69 !table
->tmp_files_retain
) {
70 unlink(table
->asl_file
);
72 g_free(table
->asl_file
);
75 static void free_test_data(test_data
*data
)
79 for (i
= 0; i
< data
->tables
->len
; ++i
) {
80 cleanup_table_descriptor(&g_array_index(data
->tables
, AcpiSdtTable
, i
));
83 g_array_free(data
->tables
, true);
86 static void test_acpi_rsdp_table(test_data
*data
)
88 uint8_t *rsdp_table
= data
->rsdp_table
;
90 acpi_fetch_rsdp_table(data
->qts
, data
->rsdp_addr
, rsdp_table
);
92 switch (rsdp_table
[15 /* Revision offset */]) {
93 case 0: /* ACPI 1.0 RSDP */
94 /* With rev 1, checksum is only for the first 20 bytes */
95 g_assert(!acpi_calc_checksum(rsdp_table
, 20));
97 case 2: /* ACPI 2.0+ RSDP */
98 /* With revision 2, we have 2 checksums */
99 g_assert(!acpi_calc_checksum(rsdp_table
, 20));
100 g_assert(!acpi_calc_checksum(rsdp_table
, 36));
103 g_assert_not_reached();
107 static void test_acpi_rxsdt_table(test_data
*data
)
109 const char *sig
= "RSDT";
110 AcpiSdtTable rsdt
= {};
112 int addr_off
= 16 /* RsdtAddress */;
115 if (data
->rsdp_table
[15 /* Revision offset */] != 0) {
116 addr_off
= 24 /* XsdtAddress */;
120 /* read [RX]SDT table */
121 acpi_fetch_table(data
->qts
, &rsdt
.aml
, &rsdt
.aml_len
,
122 &data
->rsdp_table
[addr_off
], entry_size
, sig
, true);
124 /* Load all tables and add to test list directly RSDT referenced tables */
125 ACPI_FOREACH_RSDT_ENTRY(rsdt
.aml
, rsdt
.aml_len
, ent
, entry_size
) {
126 AcpiSdtTable ssdt_table
= {};
128 acpi_fetch_table(data
->qts
, &ssdt_table
.aml
, &ssdt_table
.aml_len
, ent
,
129 entry_size
, NULL
, true);
130 /* Add table to ASL test tables list */
131 g_array_append_val(data
->tables
, ssdt_table
);
133 cleanup_table_descriptor(&rsdt
);
136 static void test_acpi_fadt_table(test_data
*data
)
138 /* FADT table is 1st */
139 AcpiSdtTable table
= g_array_index(data
->tables
, typeof(table
), 0);
140 uint8_t *fadt_aml
= table
.aml
;
141 uint32_t fadt_len
= table
.aml_len
;
143 int dsdt_offset
= 40 /* DSDT */;
144 int dsdt_entry_size
= 4;
146 g_assert(compare_signature(&table
, "FACP"));
148 /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
149 memcpy(&val
, fadt_aml
+ 112 /* Flags */, 4);
150 val
= le32_to_cpu(val
);
151 if (!(val
& 1UL << 20 /* HW_REDUCED_ACPI */)) {
152 acpi_fetch_table(data
->qts
, &table
.aml
, &table
.aml_len
,
153 fadt_aml
+ 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
154 g_array_append_val(data
->tables
, table
);
157 memcpy(&val
, fadt_aml
+ dsdt_offset
, 4);
158 val
= le32_to_cpu(val
);
160 dsdt_offset
= 140 /* X_DSDT */;
163 acpi_fetch_table(data
->qts
, &table
.aml
, &table
.aml_len
,
164 fadt_aml
+ dsdt_offset
, dsdt_entry_size
, "DSDT", true);
165 g_array_append_val(data
->tables
, table
);
167 memset(fadt_aml
+ 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
168 memset(fadt_aml
+ 40, 0, 4); /* sanitize DSDT ptr */
169 if (fadt_aml
[8 /* FADT Major Version */] >= 3) {
170 memset(fadt_aml
+ 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
171 memset(fadt_aml
+ 140, 0, 8); /* sanitize X_DSDT ptr */
174 /* update checksum */
175 fadt_aml
[9 /* Checksum */] = 0;
176 fadt_aml
[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml
, fadt_len
);
179 static void dump_aml_files(test_data
*data
, bool rebuild
)
182 GError
*error
= NULL
;
183 gchar
*aml_file
= NULL
;
188 for (i
= 0; i
< data
->tables
->len
; ++i
) {
189 const char *ext
= data
->variant
? data
->variant
: "";
190 sdt
= &g_array_index(data
->tables
, AcpiSdtTable
, i
);
194 aml_file
= g_strdup_printf("%s/%s/%.4s%s", data_dir
, data
->machine
,
196 fd
= g_open(aml_file
, O_WRONLY
|O_TRUNC
|O_CREAT
,
197 S_IRUSR
|S_IWUSR
|S_IRGRP
|S_IWGRP
|S_IROTH
);
203 fd
= g_file_open_tmp("aml-XXXXXX", &sdt
->aml_file
, &error
);
204 g_assert_no_error(error
);
207 ret
= qemu_write_full(fd
, sdt
->aml
, sdt
->aml_len
);
208 g_assert(ret
== sdt
->aml_len
);
216 static bool load_asl(GArray
*sdts
, AcpiSdtTable
*sdt
)
219 GError
*error
= NULL
;
220 GString
*command_line
= g_string_new(iasl
);
222 gchar
*out
, *out_err
;
226 fd
= g_file_open_tmp("asl-XXXXXX.dsl", &sdt
->asl_file
, &error
);
227 g_assert_no_error(error
);
230 /* build command line */
231 g_string_append_printf(command_line
, " -p %s ", sdt
->asl_file
);
232 if (compare_signature(sdt
, "DSDT") ||
233 compare_signature(sdt
, "SSDT")) {
234 for (i
= 0; i
< sdts
->len
; ++i
) {
235 temp
= &g_array_index(sdts
, AcpiSdtTable
, i
);
236 if (compare_signature(temp
, "DSDT") ||
237 compare_signature(temp
, "SSDT")) {
238 g_string_append_printf(command_line
, "-e %s ", temp
->aml_file
);
242 g_string_append_printf(command_line
, "-d %s", sdt
->aml_file
);
244 /* pass 'out' and 'out_err' in order to be redirected */
245 ret
= g_spawn_command_line_sync(command_line
->str
, &out
, &out_err
, NULL
, &error
);
246 g_assert_no_error(error
);
248 ret
= g_file_get_contents(sdt
->asl_file
, &sdt
->asl
,
249 &sdt
->asl_len
, &error
);
251 g_assert_no_error(error
);
252 ret
= (sdt
->asl_len
> 0);
257 g_string_free(command_line
, true);
262 #define COMMENT_END "*/"
263 #define DEF_BLOCK "DefinitionBlock ("
264 #define BLOCK_NAME_END ","
266 static GString
*normalize_asl(gchar
*asl_code
)
268 GString
*asl
= g_string_new(asl_code
);
269 gchar
*comment
, *block_name
;
271 /* strip comments (different generation days) */
272 comment
= g_strstr_len(asl
->str
, asl
->len
, COMMENT_END
);
274 comment
+= strlen(COMMENT_END
);
275 while (*comment
== '\n') {
278 asl
= g_string_erase(asl
, 0, comment
- asl
->str
);
281 /* strip def block name (it has file path in it) */
282 if (g_str_has_prefix(asl
->str
, DEF_BLOCK
)) {
283 block_name
= g_strstr_len(asl
->str
, asl
->len
, BLOCK_NAME_END
);
284 g_assert(block_name
);
285 asl
= g_string_erase(asl
, 0,
286 block_name
+ sizeof(BLOCK_NAME_END
) - asl
->str
);
292 static GArray
*load_expected_aml(test_data
*data
)
296 GError
*error
= NULL
;
300 GArray
*exp_tables
= g_array_new(false, true, sizeof(AcpiSdtTable
));
304 for (i
= 0; i
< data
->tables
->len
; ++i
) {
305 AcpiSdtTable exp_sdt
;
306 gchar
*aml_file
= NULL
;
307 const char *ext
= data
->variant
? data
->variant
: "";
309 sdt
= &g_array_index(data
->tables
, AcpiSdtTable
, i
);
311 memset(&exp_sdt
, 0, sizeof(exp_sdt
));
314 aml_file
= g_strdup_printf("%s/%s/%.4s%s", data_dir
, data
->machine
,
317 fprintf(stderr
, "Looking for expected file '%s'\n", aml_file
);
319 if (g_file_test(aml_file
, G_FILE_TEST_EXISTS
)) {
320 exp_sdt
.aml_file
= aml_file
;
321 } else if (*ext
!= '\0') {
322 /* try fallback to generic (extension less) expected file */
327 g_assert(exp_sdt
.aml_file
);
329 fprintf(stderr
, "Using expected file '%s'\n", aml_file
);
331 ret
= g_file_get_contents(aml_file
, (gchar
**)&exp_sdt
.aml
,
333 exp_sdt
.aml_len
= aml_len
;
335 g_assert_no_error(error
);
336 g_assert(exp_sdt
.aml
);
337 g_assert(exp_sdt
.aml_len
);
339 g_array_append_val(exp_tables
, exp_sdt
);
345 /* test the list of tables in @data->tables against reference tables */
346 static void test_acpi_asl(test_data
*data
)
349 AcpiSdtTable
*sdt
, *exp_sdt
;
351 gboolean exp_err
, err
;
353 memset(&exp_data
, 0, sizeof(exp_data
));
354 exp_data
.tables
= load_expected_aml(data
);
355 dump_aml_files(data
, false);
356 for (i
= 0; i
< data
->tables
->len
; ++i
) {
357 GString
*asl
, *exp_asl
;
359 sdt
= &g_array_index(data
->tables
, AcpiSdtTable
, i
);
360 exp_sdt
= &g_array_index(exp_data
.tables
, AcpiSdtTable
, i
);
362 err
= load_asl(data
->tables
, sdt
);
363 asl
= normalize_asl(sdt
->asl
);
365 exp_err
= load_asl(exp_data
.tables
, exp_sdt
);
366 exp_asl
= normalize_asl(exp_sdt
->asl
);
368 /* TODO: check for warnings */
369 g_assert(!err
|| exp_err
);
371 if (g_strcmp0(asl
->str
, exp_asl
->str
)) {
374 "Warning! iasl couldn't parse the expected aml\n");
376 sdt
->tmp_files_retain
= true;
377 exp_sdt
->tmp_files_retain
= true;
379 "acpi-test: Warning! %.4s mismatch. "
380 "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
381 exp_sdt
->aml
, sdt
->asl_file
, sdt
->aml_file
,
382 exp_sdt
->asl_file
, exp_sdt
->aml_file
);
384 const char *diff_cmd
= getenv("DIFF");
386 int ret G_GNUC_UNUSED
;
387 char *diff
= g_strdup_printf("%s %s %s", diff_cmd
,
388 exp_sdt
->asl_file
, sdt
->asl_file
);
392 fprintf(stderr
, "acpi-test: Warning. not showing "
393 "difference since no diff utility is specified. "
394 "Set 'DIFF' environment variable to a preferred "
395 "diff utility and run 'make V=1 check' again to "
396 "see ASL difference.");
401 g_string_free(asl
, true);
402 g_string_free(exp_asl
, true);
405 free_test_data(&exp_data
);
408 static bool smbios_ep_table_ok(test_data
*data
)
410 struct smbios_21_entry_point
*ep_table
= &data
->smbios_ep_table
;
411 uint32_t addr
= data
->smbios_ep_addr
;
413 qtest_memread(data
->qts
, addr
, ep_table
, sizeof(*ep_table
));
414 if (memcmp(ep_table
->anchor_string
, "_SM_", 4)) {
417 if (memcmp(ep_table
->intermediate_anchor_string
, "_DMI_", 5)) {
420 if (ep_table
->structure_table_length
== 0) {
423 if (ep_table
->number_of_structures
== 0) {
426 if (acpi_calc_checksum((uint8_t *)ep_table
, sizeof *ep_table
) ||
427 acpi_calc_checksum((uint8_t *)ep_table
+ 0x10,
428 sizeof *ep_table
- 0x10)) {
434 static void test_smbios_entry_point(test_data
*data
)
438 /* find smbios entry point structure */
439 for (off
= 0xf0000; off
< 0x100000; off
+= 0x10) {
440 uint8_t sig
[] = "_SM_";
443 for (i
= 0; i
< sizeof sig
- 1; ++i
) {
444 sig
[i
] = qtest_readb(data
->qts
, off
+ i
);
447 if (!memcmp(sig
, "_SM_", sizeof sig
)) {
448 /* signature match, but is this a valid entry point? */
449 data
->smbios_ep_addr
= off
;
450 if (smbios_ep_table_ok(data
)) {
456 g_assert_cmphex(off
, <, 0x100000);
459 static inline bool smbios_single_instance(uint8_t type
)
475 static void test_smbios_structs(test_data
*data
)
477 DECLARE_BITMAP(struct_bitmap
, SMBIOS_MAX_TYPE
+1) = { 0 };
478 struct smbios_21_entry_point
*ep_table
= &data
->smbios_ep_table
;
479 uint32_t addr
= le32_to_cpu(ep_table
->structure_table_address
);
480 int i
, len
, max_len
= 0;
481 uint8_t type
, prv
, crt
;
483 /* walk the smbios tables */
484 for (i
= 0; i
< le16_to_cpu(ep_table
->number_of_structures
); i
++) {
486 /* grab type and formatted area length from struct header */
487 type
= qtest_readb(data
->qts
, addr
);
488 g_assert_cmpuint(type
, <=, SMBIOS_MAX_TYPE
);
489 len
= qtest_readb(data
->qts
, addr
+ 1);
491 /* single-instance structs must not have been encountered before */
492 if (smbios_single_instance(type
)) {
493 g_assert(!test_bit(type
, struct_bitmap
));
495 set_bit(type
, struct_bitmap
);
497 /* seek to end of unformatted string area of this struct ("\0\0") */
501 crt
= qtest_readb(data
->qts
, addr
+ len
);
505 /* keep track of max. struct size */
508 g_assert_cmpuint(max_len
, <=, ep_table
->max_structure_size
);
511 /* start of next structure */
515 /* total table length and max struct size must match entry point values */
516 g_assert_cmpuint(le16_to_cpu(ep_table
->structure_table_length
), ==,
517 addr
- le32_to_cpu(ep_table
->structure_table_address
));
518 g_assert_cmpuint(le16_to_cpu(ep_table
->max_structure_size
), ==, max_len
);
520 /* required struct types must all be present */
521 for (i
= 0; i
< data
->required_struct_types_len
; i
++) {
522 g_assert(test_bit(data
->required_struct_types
[i
], struct_bitmap
));
526 static void test_acpi_one(const char *params
, test_data
*data
)
529 bool use_uefi
= data
->uefi_fl1
&& data
->uefi_fl2
;
533 * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
534 * when arm/virt boad starts to support it.
536 args
= g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
537 "-drive if=pflash,format=raw,file=%s,readonly "
538 "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
539 data
->machine
, data
->accel
? data
->accel
: "kvm:tcg",
540 data
->uefi_fl1
, data
->uefi_fl2
, data
->cd
, params
? params
: "");
543 /* Disable kernel irqchip to be able to override apic irq0. */
544 args
= g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
545 "-net none -display none %s "
546 "-drive id=hd0,if=none,file=%s,format=raw "
547 "-device ide-hd,drive=hd0 ",
548 data
->machine
, data
->accel
? data
->accel
: "kvm:tcg",
549 params
? params
: "", disk
);
552 data
->qts
= qtest_init(args
);
555 g_assert(data
->scan_len
);
556 data
->rsdp_addr
= acpi_find_rsdp_address_uefi(data
->qts
,
557 data
->ram_start
, data
->scan_len
);
559 boot_sector_test(data
->qts
);
560 data
->rsdp_addr
= acpi_find_rsdp_address(data
->qts
);
561 g_assert_cmphex(data
->rsdp_addr
, <, 0x100000);
564 data
->tables
= g_array_new(false, true, sizeof(AcpiSdtTable
));
565 test_acpi_rsdp_table(data
);
566 test_acpi_rxsdt_table(data
);
567 test_acpi_fadt_table(data
);
570 if (getenv(ACPI_REBUILD_EXPECTED_AML
)) {
571 dump_aml_files(data
, true);
578 * TODO: make SMBIOS tests work with UEFI firmware,
579 * Bug on uefi-test-tools to provide entry point:
580 * https://bugs.launchpad.net/qemu/+bug/1821884
583 test_smbios_entry_point(data
);
584 test_smbios_structs(data
);
587 assert(!global_qtest
);
588 qtest_quit(data
->qts
);
592 static uint8_t base_required_struct_types
[] = {
593 0, 1, 3, 4, 16, 17, 19, 32, 127
596 static void test_acpi_piix4_tcg(void)
600 /* Supplying -machine accel argument overrides the default (qtest).
601 * This is to make guest actually run.
603 memset(&data
, 0, sizeof(data
));
604 data
.machine
= MACHINE_PC
;
605 data
.required_struct_types
= base_required_struct_types
;
606 data
.required_struct_types_len
= ARRAY_SIZE(base_required_struct_types
);
607 test_acpi_one(NULL
, &data
);
608 free_test_data(&data
);
611 static void test_acpi_piix4_tcg_bridge(void)
615 memset(&data
, 0, sizeof(data
));
616 data
.machine
= MACHINE_PC
;
617 data
.variant
= ".bridge";
618 data
.required_struct_types
= base_required_struct_types
;
619 data
.required_struct_types_len
= ARRAY_SIZE(base_required_struct_types
);
620 test_acpi_one("-device pci-bridge,chassis_nr=1", &data
);
621 free_test_data(&data
);
624 static void test_acpi_q35_tcg(void)
628 memset(&data
, 0, sizeof(data
));
629 data
.machine
= MACHINE_Q35
;
630 data
.required_struct_types
= base_required_struct_types
;
631 data
.required_struct_types_len
= ARRAY_SIZE(base_required_struct_types
);
632 test_acpi_one(NULL
, &data
);
633 free_test_data(&data
);
636 static void test_acpi_q35_tcg_bridge(void)
640 memset(&data
, 0, sizeof(data
));
641 data
.machine
= MACHINE_Q35
;
642 data
.variant
= ".bridge";
643 data
.required_struct_types
= base_required_struct_types
;
644 data
.required_struct_types_len
= ARRAY_SIZE(base_required_struct_types
);
645 test_acpi_one("-device pci-bridge,chassis_nr=1",
647 free_test_data(&data
);
650 static void test_acpi_q35_tcg_mmio64(void)
653 .machine
= MACHINE_Q35
,
654 .variant
= ".mmio64",
655 .required_struct_types
= base_required_struct_types
,
656 .required_struct_types_len
= ARRAY_SIZE(base_required_struct_types
)
659 test_acpi_one("-m 128M,slots=1,maxmem=2G "
660 "-device pci-testdev,membar=2G",
662 free_test_data(&data
);
665 static void test_acpi_piix4_tcg_cphp(void)
669 memset(&data
, 0, sizeof(data
));
670 data
.machine
= MACHINE_PC
;
671 data
.variant
= ".cphp";
672 test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
673 " -numa node -numa node"
674 " -numa dist,src=0,dst=1,val=21",
676 free_test_data(&data
);
679 static void test_acpi_q35_tcg_cphp(void)
683 memset(&data
, 0, sizeof(data
));
684 data
.machine
= MACHINE_Q35
;
685 data
.variant
= ".cphp";
686 test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
687 " -numa node -numa node"
688 " -numa dist,src=0,dst=1,val=21",
690 free_test_data(&data
);
693 static uint8_t ipmi_required_struct_types
[] = {
694 0, 1, 3, 4, 16, 17, 19, 32, 38, 127
697 static void test_acpi_q35_tcg_ipmi(void)
701 memset(&data
, 0, sizeof(data
));
702 data
.machine
= MACHINE_Q35
;
703 data
.variant
= ".ipmibt";
704 data
.required_struct_types
= ipmi_required_struct_types
;
705 data
.required_struct_types_len
= ARRAY_SIZE(ipmi_required_struct_types
);
706 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
707 " -device isa-ipmi-bt,bmc=bmc0",
709 free_test_data(&data
);
712 static void test_acpi_piix4_tcg_ipmi(void)
716 /* Supplying -machine accel argument overrides the default (qtest).
717 * This is to make guest actually run.
719 memset(&data
, 0, sizeof(data
));
720 data
.machine
= MACHINE_PC
;
721 data
.variant
= ".ipmikcs";
722 data
.required_struct_types
= ipmi_required_struct_types
;
723 data
.required_struct_types_len
= ARRAY_SIZE(ipmi_required_struct_types
);
724 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
725 " -device isa-ipmi-kcs,irq=0,bmc=bmc0",
727 free_test_data(&data
);
730 static void test_acpi_q35_tcg_memhp(void)
734 memset(&data
, 0, sizeof(data
));
735 data
.machine
= MACHINE_Q35
;
736 data
.variant
= ".memhp";
737 test_acpi_one(" -m 128,slots=3,maxmem=1G"
738 " -numa node -numa node"
739 " -numa dist,src=0,dst=1,val=21",
741 free_test_data(&data
);
744 static void test_acpi_piix4_tcg_memhp(void)
748 memset(&data
, 0, sizeof(data
));
749 data
.machine
= MACHINE_PC
;
750 data
.variant
= ".memhp";
751 test_acpi_one(" -m 128,slots=3,maxmem=1G"
752 " -numa node -numa node"
753 " -numa dist,src=0,dst=1,val=21",
755 free_test_data(&data
);
758 static void test_acpi_q35_tcg_numamem(void)
762 memset(&data
, 0, sizeof(data
));
763 data
.machine
= MACHINE_Q35
;
764 data
.variant
= ".numamem";
765 test_acpi_one(" -numa node -numa node,mem=128", &data
);
766 free_test_data(&data
);
769 static void test_acpi_piix4_tcg_numamem(void)
773 memset(&data
, 0, sizeof(data
));
774 data
.machine
= MACHINE_PC
;
775 data
.variant
= ".numamem";
776 test_acpi_one(" -numa node -numa node,mem=128", &data
);
777 free_test_data(&data
);
780 static void test_acpi_tcg_dimm_pxm(const char *machine
)
784 memset(&data
, 0, sizeof(data
));
785 data
.machine
= machine
;
786 data
.variant
= ".dimmpxm";
787 test_acpi_one(" -machine nvdimm=on,nvdimm-persistence=cpu"
789 " -m 128M,slots=3,maxmem=1G"
790 " -numa node,mem=32M,nodeid=0"
791 " -numa node,mem=32M,nodeid=1"
792 " -numa node,mem=32M,nodeid=2"
793 " -numa node,mem=32M,nodeid=3"
794 " -numa cpu,node-id=0,socket-id=0"
795 " -numa cpu,node-id=1,socket-id=1"
796 " -numa cpu,node-id=2,socket-id=2"
797 " -numa cpu,node-id=3,socket-id=3"
798 " -object memory-backend-ram,id=ram0,size=128M"
799 " -object memory-backend-ram,id=nvm0,size=128M"
800 " -device pc-dimm,id=dimm0,memdev=ram0,node=1"
801 " -device nvdimm,id=dimm1,memdev=nvm0,node=2",
803 free_test_data(&data
);
806 static void test_acpi_q35_tcg_dimm_pxm(void)
808 test_acpi_tcg_dimm_pxm(MACHINE_Q35
);
811 static void test_acpi_piix4_tcg_dimm_pxm(void)
813 test_acpi_tcg_dimm_pxm(MACHINE_PC
);
816 int main(int argc
, char *argv
[])
818 const char *arch
= qtest_get_arch();
821 g_test_init(&argc
, &argv
, NULL
);
823 if (strcmp(arch
, "i386") == 0 || strcmp(arch
, "x86_64") == 0) {
824 ret
= boot_sector_init(disk
);
829 qtest_add_func("acpi/piix4", test_acpi_piix4_tcg
);
830 qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge
);
831 qtest_add_func("acpi/q35", test_acpi_q35_tcg
);
832 qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge
);
833 qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64
);
834 qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi
);
835 qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi
);
836 qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp
);
837 qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp
);
838 qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp
);
839 qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp
);
840 qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem
);
841 qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem
);
842 qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm
);
843 qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm
);
846 boot_sector_cleanup(disk
);