tests: acpi: make pointer to RSDP 64bit
[qemu.git] / tests / bios-tables-test.c
bloba164d274a2acd831b7d61db62140cfcbfd4297bf
1 /*
2 * Boot order test cases.
4 * Copyright (c) 2013 Red Hat Inc.
6 * Authors:
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"
26 typedef struct {
27 const char *machine;
28 const char *variant;
29 uint64_t rsdp_addr;
30 uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
31 GArray *tables;
32 uint32_t smbios_ep_addr;
33 struct smbios_21_entry_point smbios_ep_table;
34 uint8_t *required_struct_types;
35 int required_struct_types_len;
36 QTestState *qts;
37 } test_data;
39 static char disk[] = "tests/acpi-test-disk-XXXXXX";
40 static const char *data_dir = "tests/data/acpi";
41 #ifdef CONFIG_IASL
42 static const char *iasl = stringify(CONFIG_IASL);
43 #else
44 static const char *iasl;
45 #endif
47 static bool compare_signature(const AcpiSdtTable *sdt, const char *signature)
49 return !memcmp(sdt->aml, signature, 4);
52 static void cleanup_table_descriptor(AcpiSdtTable *table)
54 g_free(table->aml);
55 if (table->aml_file &&
56 !table->tmp_files_retain &&
57 g_strstr_len(table->aml_file, -1, "aml-")) {
58 unlink(table->aml_file);
60 g_free(table->aml_file);
61 g_free(table->asl);
62 if (table->asl_file &&
63 !table->tmp_files_retain) {
64 unlink(table->asl_file);
66 g_free(table->asl_file);
69 static void free_test_data(test_data *data)
71 int i;
73 for (i = 0; i < data->tables->len; ++i) {
74 cleanup_table_descriptor(&g_array_index(data->tables, AcpiSdtTable, i));
77 g_array_free(data->tables, true);
80 static void test_acpi_rsdp_address(test_data *data)
82 uint32_t off = acpi_find_rsdp_address(data->qts);
83 g_assert_cmphex(off, <, 0x100000);
84 data->rsdp_addr = off;
87 static void test_acpi_rsdp_table(test_data *data)
89 uint8_t *rsdp_table = data->rsdp_table;
91 acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
93 switch (rsdp_table[15 /* Revision offset */]) {
94 case 0: /* ACPI 1.0 RSDP */
95 /* With rev 1, checksum is only for the first 20 bytes */
96 g_assert(!acpi_calc_checksum(rsdp_table, 20));
97 break;
98 case 2: /* ACPI 2.0+ RSDP */
99 /* With revision 2, we have 2 checksums */
100 g_assert(!acpi_calc_checksum(rsdp_table, 20));
101 g_assert(!acpi_calc_checksum(rsdp_table, 36));
102 break;
103 default:
104 g_assert_not_reached();
108 static void test_acpi_rxsdt_table(test_data *data)
110 const char *sig = "RSDT";
111 AcpiSdtTable rsdt = {};
112 int entry_size = 4;
113 int addr_off = 16 /* RsdtAddress */;
114 uint8_t *ent;
116 if (data->rsdp_table[15 /* Revision offset */] != 0) {
117 addr_off = 24 /* XsdtAddress */;
118 entry_size = 8;
119 sig = "XSDT";
121 /* read [RX]SDT table */
122 acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
123 &data->rsdp_table[addr_off], entry_size, sig, true);
125 /* Load all tables and add to test list directly RSDT referenced tables */
126 ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
127 AcpiSdtTable ssdt_table = {};
129 acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
130 entry_size, NULL, true);
131 /* Add table to ASL test tables list */
132 g_array_append_val(data->tables, ssdt_table);
134 cleanup_table_descriptor(&rsdt);
137 static void test_acpi_fadt_table(test_data *data)
139 /* FADT table is 1st */
140 AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
141 uint8_t *fadt_aml = table.aml;
142 uint32_t fadt_len = table.aml_len;
144 g_assert(compare_signature(&table, "FACP"));
146 /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
147 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
148 fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
149 g_array_append_val(data->tables, table);
151 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
152 fadt_aml + 40 /* DSDT */, 4, "DSDT", true);
153 g_array_append_val(data->tables, table);
155 memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
156 memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */
157 if (fadt_aml[8 /* FADT Major Version */] >= 3) {
158 memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
159 memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */
162 /* update checksum */
163 fadt_aml[9 /* Checksum */] = 0;
164 fadt_aml[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml, fadt_len);
167 static void dump_aml_files(test_data *data, bool rebuild)
169 AcpiSdtTable *sdt;
170 GError *error = NULL;
171 gchar *aml_file = NULL;
172 gint fd;
173 ssize_t ret;
174 int i;
176 for (i = 0; i < data->tables->len; ++i) {
177 const char *ext = data->variant ? data->variant : "";
178 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
179 g_assert(sdt->aml);
181 if (rebuild) {
182 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
183 sdt->aml, ext);
184 fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
185 S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
186 } else {
187 fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
188 g_assert_no_error(error);
190 g_assert(fd >= 0);
192 ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
193 g_assert(ret == sdt->aml_len);
195 close(fd);
197 g_free(aml_file);
201 static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
203 AcpiSdtTable *temp;
204 GError *error = NULL;
205 GString *command_line = g_string_new(iasl);
206 gint fd;
207 gchar *out, *out_err;
208 gboolean ret;
209 int i;
211 fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
212 g_assert_no_error(error);
213 close(fd);
215 /* build command line */
216 g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
217 if (compare_signature(sdt, "DSDT") ||
218 compare_signature(sdt, "SSDT")) {
219 for (i = 0; i < sdts->len; ++i) {
220 temp = &g_array_index(sdts, AcpiSdtTable, i);
221 if (compare_signature(temp, "DSDT") ||
222 compare_signature(temp, "SSDT")) {
223 g_string_append_printf(command_line, "-e %s ", temp->aml_file);
227 g_string_append_printf(command_line, "-d %s", sdt->aml_file);
229 /* pass 'out' and 'out_err' in order to be redirected */
230 ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
231 g_assert_no_error(error);
232 if (ret) {
233 ret = g_file_get_contents(sdt->asl_file, &sdt->asl,
234 &sdt->asl_len, &error);
235 g_assert(ret);
236 g_assert_no_error(error);
237 ret = (sdt->asl_len > 0);
240 g_free(out);
241 g_free(out_err);
242 g_string_free(command_line, true);
244 return !ret;
247 #define COMMENT_END "*/"
248 #define DEF_BLOCK "DefinitionBlock ("
249 #define BLOCK_NAME_END ","
251 static GString *normalize_asl(gchar *asl_code)
253 GString *asl = g_string_new(asl_code);
254 gchar *comment, *block_name;
256 /* strip comments (different generation days) */
257 comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
258 if (comment) {
259 comment += strlen(COMMENT_END);
260 while (*comment == '\n') {
261 comment++;
263 asl = g_string_erase(asl, 0, comment - asl->str);
266 /* strip def block name (it has file path in it) */
267 if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
268 block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
269 g_assert(block_name);
270 asl = g_string_erase(asl, 0,
271 block_name + sizeof(BLOCK_NAME_END) - asl->str);
274 return asl;
277 static GArray *load_expected_aml(test_data *data)
279 int i;
280 AcpiSdtTable *sdt;
281 GError *error = NULL;
282 gboolean ret;
283 gsize aml_len;
285 GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
286 if (getenv("V")) {
287 fputc('\n', stderr);
289 for (i = 0; i < data->tables->len; ++i) {
290 AcpiSdtTable exp_sdt;
291 gchar *aml_file = NULL;
292 const char *ext = data->variant ? data->variant : "";
294 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
296 memset(&exp_sdt, 0, sizeof(exp_sdt));
298 try_again:
299 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
300 sdt->aml, ext);
301 if (getenv("V")) {
302 fprintf(stderr, "Looking for expected file '%s'\n", aml_file);
304 if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
305 exp_sdt.aml_file = aml_file;
306 } else if (*ext != '\0') {
307 /* try fallback to generic (extension less) expected file */
308 ext = "";
309 g_free(aml_file);
310 goto try_again;
312 g_assert(exp_sdt.aml_file);
313 if (getenv("V")) {
314 fprintf(stderr, "Using expected file '%s'\n", aml_file);
316 ret = g_file_get_contents(aml_file, (gchar **)&exp_sdt.aml,
317 &aml_len, &error);
318 exp_sdt.aml_len = aml_len;
319 g_assert(ret);
320 g_assert_no_error(error);
321 g_assert(exp_sdt.aml);
322 g_assert(exp_sdt.aml_len);
324 g_array_append_val(exp_tables, exp_sdt);
327 return exp_tables;
330 /* test the list of tables in @data->tables against reference tables */
331 static void test_acpi_asl(test_data *data)
333 int i;
334 AcpiSdtTable *sdt, *exp_sdt;
335 test_data exp_data;
336 gboolean exp_err, err;
338 memset(&exp_data, 0, sizeof(exp_data));
339 exp_data.tables = load_expected_aml(data);
340 dump_aml_files(data, false);
341 for (i = 0; i < data->tables->len; ++i) {
342 GString *asl, *exp_asl;
344 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
345 exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i);
347 err = load_asl(data->tables, sdt);
348 asl = normalize_asl(sdt->asl);
350 exp_err = load_asl(exp_data.tables, exp_sdt);
351 exp_asl = normalize_asl(exp_sdt->asl);
353 /* TODO: check for warnings */
354 g_assert(!err || exp_err);
356 if (g_strcmp0(asl->str, exp_asl->str)) {
357 if (exp_err) {
358 fprintf(stderr,
359 "Warning! iasl couldn't parse the expected aml\n");
360 } else {
361 sdt->tmp_files_retain = true;
362 exp_sdt->tmp_files_retain = true;
363 fprintf(stderr,
364 "acpi-test: Warning! %.4s mismatch. "
365 "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
366 exp_sdt->aml, sdt->asl_file, sdt->aml_file,
367 exp_sdt->asl_file, exp_sdt->aml_file);
368 if (getenv("V")) {
369 const char *diff_cmd = getenv("DIFF");
370 if (diff_cmd) {
371 int ret G_GNUC_UNUSED;
372 char *diff = g_strdup_printf("%s %s %s", diff_cmd,
373 exp_sdt->asl_file, sdt->asl_file);
374 ret = system(diff) ;
375 g_free(diff);
376 } else {
377 fprintf(stderr, "acpi-test: Warning. not showing "
378 "difference since no diff utility is specified. "
379 "Set 'DIFF' environment variable to a preferred "
380 "diff utility and run 'make V=1 check' again to "
381 "see ASL difference.");
386 g_string_free(asl, true);
387 g_string_free(exp_asl, true);
390 free_test_data(&exp_data);
393 static bool smbios_ep_table_ok(test_data *data)
395 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
396 uint32_t addr = data->smbios_ep_addr;
398 qtest_memread(data->qts, addr, ep_table, sizeof(*ep_table));
399 if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
400 return false;
402 if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
403 return false;
405 if (ep_table->structure_table_length == 0) {
406 return false;
408 if (ep_table->number_of_structures == 0) {
409 return false;
411 if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
412 acpi_calc_checksum((uint8_t *)ep_table + 0x10,
413 sizeof *ep_table - 0x10)) {
414 return false;
416 return true;
419 static void test_smbios_entry_point(test_data *data)
421 uint32_t off;
423 /* find smbios entry point structure */
424 for (off = 0xf0000; off < 0x100000; off += 0x10) {
425 uint8_t sig[] = "_SM_";
426 int i;
428 for (i = 0; i < sizeof sig - 1; ++i) {
429 sig[i] = qtest_readb(data->qts, off + i);
432 if (!memcmp(sig, "_SM_", sizeof sig)) {
433 /* signature match, but is this a valid entry point? */
434 data->smbios_ep_addr = off;
435 if (smbios_ep_table_ok(data)) {
436 break;
441 g_assert_cmphex(off, <, 0x100000);
444 static inline bool smbios_single_instance(uint8_t type)
446 switch (type) {
447 case 0:
448 case 1:
449 case 2:
450 case 3:
451 case 16:
452 case 32:
453 case 127:
454 return true;
455 default:
456 return false;
460 static void test_smbios_structs(test_data *data)
462 DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
463 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
464 uint32_t addr = le32_to_cpu(ep_table->structure_table_address);
465 int i, len, max_len = 0;
466 uint8_t type, prv, crt;
468 /* walk the smbios tables */
469 for (i = 0; i < le16_to_cpu(ep_table->number_of_structures); i++) {
471 /* grab type and formatted area length from struct header */
472 type = qtest_readb(data->qts, addr);
473 g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
474 len = qtest_readb(data->qts, addr + 1);
476 /* single-instance structs must not have been encountered before */
477 if (smbios_single_instance(type)) {
478 g_assert(!test_bit(type, struct_bitmap));
480 set_bit(type, struct_bitmap);
482 /* seek to end of unformatted string area of this struct ("\0\0") */
483 prv = crt = 1;
484 while (prv || crt) {
485 prv = crt;
486 crt = qtest_readb(data->qts, addr + len);
487 len++;
490 /* keep track of max. struct size */
491 if (max_len < len) {
492 max_len = len;
493 g_assert_cmpuint(max_len, <=, ep_table->max_structure_size);
496 /* start of next structure */
497 addr += len;
500 /* total table length and max struct size must match entry point values */
501 g_assert_cmpuint(le16_to_cpu(ep_table->structure_table_length), ==,
502 addr - le32_to_cpu(ep_table->structure_table_address));
503 g_assert_cmpuint(le16_to_cpu(ep_table->max_structure_size), ==, max_len);
505 /* required struct types must all be present */
506 for (i = 0; i < data->required_struct_types_len; i++) {
507 g_assert(test_bit(data->required_struct_types[i], struct_bitmap));
511 static void test_acpi_one(const char *params, test_data *data)
513 char *args;
515 /* Disable kernel irqchip to be able to override apic irq0. */
516 args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
517 "-net none -display none %s "
518 "-drive id=hd0,if=none,file=%s,format=raw "
519 "-device ide-hd,drive=hd0 ",
520 data->machine, "kvm:tcg",
521 params ? params : "", disk);
523 data->qts = qtest_init(args);
525 boot_sector_test(data->qts);
527 data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
528 test_acpi_rsdp_address(data);
529 test_acpi_rsdp_table(data);
530 test_acpi_rxsdt_table(data);
531 test_acpi_fadt_table(data);
533 if (iasl) {
534 if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
535 dump_aml_files(data, true);
536 } else {
537 test_acpi_asl(data);
541 test_smbios_entry_point(data);
542 test_smbios_structs(data);
544 assert(!global_qtest);
545 qtest_quit(data->qts);
546 g_free(args);
549 static uint8_t base_required_struct_types[] = {
550 0, 1, 3, 4, 16, 17, 19, 32, 127
553 static void test_acpi_piix4_tcg(void)
555 test_data data;
557 /* Supplying -machine accel argument overrides the default (qtest).
558 * This is to make guest actually run.
560 memset(&data, 0, sizeof(data));
561 data.machine = MACHINE_PC;
562 data.required_struct_types = base_required_struct_types;
563 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
564 test_acpi_one(NULL, &data);
565 free_test_data(&data);
568 static void test_acpi_piix4_tcg_bridge(void)
570 test_data data;
572 memset(&data, 0, sizeof(data));
573 data.machine = MACHINE_PC;
574 data.variant = ".bridge";
575 data.required_struct_types = base_required_struct_types;
576 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
577 test_acpi_one("-device pci-bridge,chassis_nr=1", &data);
578 free_test_data(&data);
581 static void test_acpi_q35_tcg(void)
583 test_data data;
585 memset(&data, 0, sizeof(data));
586 data.machine = MACHINE_Q35;
587 data.required_struct_types = base_required_struct_types;
588 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
589 test_acpi_one(NULL, &data);
590 free_test_data(&data);
593 static void test_acpi_q35_tcg_bridge(void)
595 test_data data;
597 memset(&data, 0, sizeof(data));
598 data.machine = MACHINE_Q35;
599 data.variant = ".bridge";
600 data.required_struct_types = base_required_struct_types;
601 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
602 test_acpi_one("-device pci-bridge,chassis_nr=1",
603 &data);
604 free_test_data(&data);
607 static void test_acpi_q35_tcg_mmio64(void)
609 test_data data = {
610 .machine = MACHINE_Q35,
611 .variant = ".mmio64",
612 .required_struct_types = base_required_struct_types,
613 .required_struct_types_len = ARRAY_SIZE(base_required_struct_types)
616 test_acpi_one("-m 128M,slots=1,maxmem=2G "
617 "-device pci-testdev,membar=2G",
618 &data);
619 free_test_data(&data);
622 static void test_acpi_piix4_tcg_cphp(void)
624 test_data data;
626 memset(&data, 0, sizeof(data));
627 data.machine = MACHINE_PC;
628 data.variant = ".cphp";
629 test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
630 " -numa node -numa node"
631 " -numa dist,src=0,dst=1,val=21",
632 &data);
633 free_test_data(&data);
636 static void test_acpi_q35_tcg_cphp(void)
638 test_data data;
640 memset(&data, 0, sizeof(data));
641 data.machine = MACHINE_Q35;
642 data.variant = ".cphp";
643 test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
644 " -numa node -numa node"
645 " -numa dist,src=0,dst=1,val=21",
646 &data);
647 free_test_data(&data);
650 static uint8_t ipmi_required_struct_types[] = {
651 0, 1, 3, 4, 16, 17, 19, 32, 38, 127
654 static void test_acpi_q35_tcg_ipmi(void)
656 test_data data;
658 memset(&data, 0, sizeof(data));
659 data.machine = MACHINE_Q35;
660 data.variant = ".ipmibt";
661 data.required_struct_types = ipmi_required_struct_types;
662 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
663 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
664 " -device isa-ipmi-bt,bmc=bmc0",
665 &data);
666 free_test_data(&data);
669 static void test_acpi_piix4_tcg_ipmi(void)
671 test_data data;
673 /* Supplying -machine accel argument overrides the default (qtest).
674 * This is to make guest actually run.
676 memset(&data, 0, sizeof(data));
677 data.machine = MACHINE_PC;
678 data.variant = ".ipmikcs";
679 data.required_struct_types = ipmi_required_struct_types;
680 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
681 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
682 " -device isa-ipmi-kcs,irq=0,bmc=bmc0",
683 &data);
684 free_test_data(&data);
687 static void test_acpi_q35_tcg_memhp(void)
689 test_data data;
691 memset(&data, 0, sizeof(data));
692 data.machine = MACHINE_Q35;
693 data.variant = ".memhp";
694 test_acpi_one(" -m 128,slots=3,maxmem=1G"
695 " -numa node -numa node"
696 " -numa dist,src=0,dst=1,val=21",
697 &data);
698 free_test_data(&data);
701 static void test_acpi_piix4_tcg_memhp(void)
703 test_data data;
705 memset(&data, 0, sizeof(data));
706 data.machine = MACHINE_PC;
707 data.variant = ".memhp";
708 test_acpi_one(" -m 128,slots=3,maxmem=1G"
709 " -numa node -numa node"
710 " -numa dist,src=0,dst=1,val=21",
711 &data);
712 free_test_data(&data);
715 static void test_acpi_q35_tcg_numamem(void)
717 test_data data;
719 memset(&data, 0, sizeof(data));
720 data.machine = MACHINE_Q35;
721 data.variant = ".numamem";
722 test_acpi_one(" -numa node -numa node,mem=128", &data);
723 free_test_data(&data);
726 static void test_acpi_piix4_tcg_numamem(void)
728 test_data data;
730 memset(&data, 0, sizeof(data));
731 data.machine = MACHINE_PC;
732 data.variant = ".numamem";
733 test_acpi_one(" -numa node -numa node,mem=128", &data);
734 free_test_data(&data);
737 static void test_acpi_tcg_dimm_pxm(const char *machine)
739 test_data data;
741 memset(&data, 0, sizeof(data));
742 data.machine = machine;
743 data.variant = ".dimmpxm";
744 test_acpi_one(" -machine nvdimm=on,nvdimm-persistence=cpu"
745 " -smp 4,sockets=4"
746 " -m 128M,slots=3,maxmem=1G"
747 " -numa node,mem=32M,nodeid=0"
748 " -numa node,mem=32M,nodeid=1"
749 " -numa node,mem=32M,nodeid=2"
750 " -numa node,mem=32M,nodeid=3"
751 " -numa cpu,node-id=0,socket-id=0"
752 " -numa cpu,node-id=1,socket-id=1"
753 " -numa cpu,node-id=2,socket-id=2"
754 " -numa cpu,node-id=3,socket-id=3"
755 " -object memory-backend-ram,id=ram0,size=128M"
756 " -object memory-backend-ram,id=nvm0,size=128M"
757 " -device pc-dimm,id=dimm0,memdev=ram0,node=1"
758 " -device nvdimm,id=dimm1,memdev=nvm0,node=2",
759 &data);
760 free_test_data(&data);
763 static void test_acpi_q35_tcg_dimm_pxm(void)
765 test_acpi_tcg_dimm_pxm(MACHINE_Q35);
768 static void test_acpi_piix4_tcg_dimm_pxm(void)
770 test_acpi_tcg_dimm_pxm(MACHINE_PC);
773 int main(int argc, char *argv[])
775 const char *arch = qtest_get_arch();
776 int ret;
778 ret = boot_sector_init(disk);
779 if(ret)
780 return ret;
782 g_test_init(&argc, &argv, NULL);
784 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
785 qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
786 qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
787 qtest_add_func("acpi/q35", test_acpi_q35_tcg);
788 qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
789 qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
790 qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
791 qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
792 qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
793 qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
794 qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
795 qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
796 qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem);
797 qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
798 qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
799 qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
801 ret = g_test_run();
802 boot_sector_cleanup(disk);
803 return ret;