spice: merge options lists
[qemu/ericb.git] / tests / bios-tables-test.c
bloba506dcbb29a7b571f35bd34adca86b293d5c0478
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 uint32_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, revision;
90 uint32_t addr = data->rsdp_addr;
92 acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
93 revision = rsdp_table[15 /* Revision offset */];
95 switch (revision) {
96 case 0: /* ACPI 1.0 RSDP */
97 /* With rev 1, checksum is only for the first 20 bytes */
98 g_assert(!acpi_calc_checksum(rsdp_table, 20));
99 break;
100 case 2: /* ACPI 2.0+ RSDP */
101 /* With revision 2, we have 2 checksums */
102 g_assert(!acpi_calc_checksum(rsdp_table, 20));
103 g_assert(!acpi_calc_checksum(rsdp_table, 36));
104 break;
105 default:
106 g_assert_not_reached();
110 static void test_acpi_rsdt_table(test_data *data)
112 AcpiSdtTable rsdt = {};
113 uint8_t *ent;
115 /* read RSDT table */
116 acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
117 &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
119 /* Load all tables and add to test list directly RSDT referenced tables */
120 ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
121 AcpiSdtTable ssdt_table = {};
123 acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
124 NULL, true);
125 /* Add table to ASL test tables list */
126 g_array_append_val(data->tables, ssdt_table);
128 cleanup_table_descriptor(&rsdt);
131 static void test_acpi_fadt_table(test_data *data)
133 /* FADT table is 1st */
134 AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
135 uint8_t *fadt_aml = table.aml;
136 uint32_t fadt_len = table.aml_len;
138 g_assert(compare_signature(&table, "FACP"));
140 /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
141 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
142 fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
143 g_array_append_val(data->tables, table);
145 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
146 fadt_aml + 40 /* DSDT */, "DSDT", true);
147 g_array_append_val(data->tables, table);
149 memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
150 memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */
151 if (fadt_aml[8 /* FADT Major Version */] >= 3) {
152 memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
153 memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */
156 /* update checksum */
157 fadt_aml[9 /* Checksum */] = 0;
158 fadt_aml[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml, fadt_len);
161 static void dump_aml_files(test_data *data, bool rebuild)
163 AcpiSdtTable *sdt;
164 GError *error = NULL;
165 gchar *aml_file = NULL;
166 gint fd;
167 ssize_t ret;
168 int i;
170 for (i = 0; i < data->tables->len; ++i) {
171 const char *ext = data->variant ? data->variant : "";
172 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
173 g_assert(sdt->aml);
175 if (rebuild) {
176 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
177 sdt->aml, ext);
178 fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
179 S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
180 } else {
181 fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
182 g_assert_no_error(error);
184 g_assert(fd >= 0);
186 ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
187 g_assert(ret == sdt->aml_len);
189 close(fd);
191 g_free(aml_file);
195 static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
197 AcpiSdtTable *temp;
198 GError *error = NULL;
199 GString *command_line = g_string_new(iasl);
200 gint fd;
201 gchar *out, *out_err;
202 gboolean ret;
203 int i;
205 fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
206 g_assert_no_error(error);
207 close(fd);
209 /* build command line */
210 g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
211 if (compare_signature(sdt, "DSDT") ||
212 compare_signature(sdt, "SSDT")) {
213 for (i = 0; i < sdts->len; ++i) {
214 temp = &g_array_index(sdts, AcpiSdtTable, i);
215 if (compare_signature(temp, "DSDT") ||
216 compare_signature(temp, "SSDT")) {
217 g_string_append_printf(command_line, "-e %s ", temp->aml_file);
221 g_string_append_printf(command_line, "-d %s", sdt->aml_file);
223 /* pass 'out' and 'out_err' in order to be redirected */
224 ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
225 g_assert_no_error(error);
226 if (ret) {
227 ret = g_file_get_contents(sdt->asl_file, &sdt->asl,
228 &sdt->asl_len, &error);
229 g_assert(ret);
230 g_assert_no_error(error);
231 ret = (sdt->asl_len > 0);
234 g_free(out);
235 g_free(out_err);
236 g_string_free(command_line, true);
238 return !ret;
241 #define COMMENT_END "*/"
242 #define DEF_BLOCK "DefinitionBlock ("
243 #define BLOCK_NAME_END ","
245 static GString *normalize_asl(gchar *asl_code)
247 GString *asl = g_string_new(asl_code);
248 gchar *comment, *block_name;
250 /* strip comments (different generation days) */
251 comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
252 if (comment) {
253 comment += strlen(COMMENT_END);
254 while (*comment == '\n') {
255 comment++;
257 asl = g_string_erase(asl, 0, comment - asl->str);
260 /* strip def block name (it has file path in it) */
261 if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
262 block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
263 g_assert(block_name);
264 asl = g_string_erase(asl, 0,
265 block_name + sizeof(BLOCK_NAME_END) - asl->str);
268 return asl;
271 static GArray *load_expected_aml(test_data *data)
273 int i;
274 AcpiSdtTable *sdt;
275 GError *error = NULL;
276 gboolean ret;
277 gsize aml_len;
279 GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
280 if (getenv("V")) {
281 fputc('\n', stderr);
283 for (i = 0; i < data->tables->len; ++i) {
284 AcpiSdtTable exp_sdt;
285 gchar *aml_file = NULL;
286 const char *ext = data->variant ? data->variant : "";
288 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
290 memset(&exp_sdt, 0, sizeof(exp_sdt));
292 try_again:
293 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
294 sdt->aml, ext);
295 if (getenv("V")) {
296 fprintf(stderr, "Looking for expected file '%s'\n", aml_file);
298 if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
299 exp_sdt.aml_file = aml_file;
300 } else if (*ext != '\0') {
301 /* try fallback to generic (extension less) expected file */
302 ext = "";
303 g_free(aml_file);
304 goto try_again;
306 g_assert(exp_sdt.aml_file);
307 if (getenv("V")) {
308 fprintf(stderr, "Using expected file '%s'\n", aml_file);
310 ret = g_file_get_contents(aml_file, (gchar **)&exp_sdt.aml,
311 &aml_len, &error);
312 exp_sdt.aml_len = aml_len;
313 g_assert(ret);
314 g_assert_no_error(error);
315 g_assert(exp_sdt.aml);
316 g_assert(exp_sdt.aml_len);
318 g_array_append_val(exp_tables, exp_sdt);
321 return exp_tables;
324 /* test the list of tables in @data->tables against reference tables */
325 static void test_acpi_asl(test_data *data)
327 int i;
328 AcpiSdtTable *sdt, *exp_sdt;
329 test_data exp_data;
330 gboolean exp_err, err;
332 memset(&exp_data, 0, sizeof(exp_data));
333 exp_data.tables = load_expected_aml(data);
334 dump_aml_files(data, false);
335 for (i = 0; i < data->tables->len; ++i) {
336 GString *asl, *exp_asl;
338 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
339 exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i);
341 err = load_asl(data->tables, sdt);
342 asl = normalize_asl(sdt->asl);
344 exp_err = load_asl(exp_data.tables, exp_sdt);
345 exp_asl = normalize_asl(exp_sdt->asl);
347 /* TODO: check for warnings */
348 g_assert(!err || exp_err);
350 if (g_strcmp0(asl->str, exp_asl->str)) {
351 if (exp_err) {
352 fprintf(stderr,
353 "Warning! iasl couldn't parse the expected aml\n");
354 } else {
355 sdt->tmp_files_retain = true;
356 exp_sdt->tmp_files_retain = true;
357 fprintf(stderr,
358 "acpi-test: Warning! %.4s mismatch. "
359 "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
360 exp_sdt->aml, sdt->asl_file, sdt->aml_file,
361 exp_sdt->asl_file, exp_sdt->aml_file);
362 if (getenv("V")) {
363 const char *diff_cmd = getenv("DIFF");
364 if (diff_cmd) {
365 int ret G_GNUC_UNUSED;
366 char *diff = g_strdup_printf("%s %s %s", diff_cmd,
367 exp_sdt->asl_file, sdt->asl_file);
368 ret = system(diff) ;
369 g_free(diff);
370 } else {
371 fprintf(stderr, "acpi-test: Warning. not showing "
372 "difference since no diff utility is specified. "
373 "Set 'DIFF' environment variable to a preferred "
374 "diff utility and run 'make V=1 check' again to "
375 "see ASL difference.");
380 g_string_free(asl, true);
381 g_string_free(exp_asl, true);
384 free_test_data(&exp_data);
387 static bool smbios_ep_table_ok(test_data *data)
389 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
390 uint32_t addr = data->smbios_ep_addr;
392 qtest_memread(data->qts, addr, ep_table, sizeof(*ep_table));
393 if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
394 return false;
396 if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
397 return false;
399 if (ep_table->structure_table_length == 0) {
400 return false;
402 if (ep_table->number_of_structures == 0) {
403 return false;
405 if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
406 acpi_calc_checksum((uint8_t *)ep_table + 0x10,
407 sizeof *ep_table - 0x10)) {
408 return false;
410 return true;
413 static void test_smbios_entry_point(test_data *data)
415 uint32_t off;
417 /* find smbios entry point structure */
418 for (off = 0xf0000; off < 0x100000; off += 0x10) {
419 uint8_t sig[] = "_SM_";
420 int i;
422 for (i = 0; i < sizeof sig - 1; ++i) {
423 sig[i] = qtest_readb(data->qts, off + i);
426 if (!memcmp(sig, "_SM_", sizeof sig)) {
427 /* signature match, but is this a valid entry point? */
428 data->smbios_ep_addr = off;
429 if (smbios_ep_table_ok(data)) {
430 break;
435 g_assert_cmphex(off, <, 0x100000);
438 static inline bool smbios_single_instance(uint8_t type)
440 switch (type) {
441 case 0:
442 case 1:
443 case 2:
444 case 3:
445 case 16:
446 case 32:
447 case 127:
448 return true;
449 default:
450 return false;
454 static void test_smbios_structs(test_data *data)
456 DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
457 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
458 uint32_t addr = le32_to_cpu(ep_table->structure_table_address);
459 int i, len, max_len = 0;
460 uint8_t type, prv, crt;
462 /* walk the smbios tables */
463 for (i = 0; i < le16_to_cpu(ep_table->number_of_structures); i++) {
465 /* grab type and formatted area length from struct header */
466 type = qtest_readb(data->qts, addr);
467 g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
468 len = qtest_readb(data->qts, addr + 1);
470 /* single-instance structs must not have been encountered before */
471 if (smbios_single_instance(type)) {
472 g_assert(!test_bit(type, struct_bitmap));
474 set_bit(type, struct_bitmap);
476 /* seek to end of unformatted string area of this struct ("\0\0") */
477 prv = crt = 1;
478 while (prv || crt) {
479 prv = crt;
480 crt = qtest_readb(data->qts, addr + len);
481 len++;
484 /* keep track of max. struct size */
485 if (max_len < len) {
486 max_len = len;
487 g_assert_cmpuint(max_len, <=, ep_table->max_structure_size);
490 /* start of next structure */
491 addr += len;
494 /* total table length and max struct size must match entry point values */
495 g_assert_cmpuint(le16_to_cpu(ep_table->structure_table_length), ==,
496 addr - le32_to_cpu(ep_table->structure_table_address));
497 g_assert_cmpuint(le16_to_cpu(ep_table->max_structure_size), ==, max_len);
499 /* required struct types must all be present */
500 for (i = 0; i < data->required_struct_types_len; i++) {
501 g_assert(test_bit(data->required_struct_types[i], struct_bitmap));
505 static void test_acpi_one(const char *params, test_data *data)
507 char *args;
509 /* Disable kernel irqchip to be able to override apic irq0. */
510 args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
511 "-net none -display none %s "
512 "-drive id=hd0,if=none,file=%s,format=raw "
513 "-device ide-hd,drive=hd0 ",
514 data->machine, "kvm:tcg",
515 params ? params : "", disk);
517 data->qts = qtest_init(args);
519 boot_sector_test(data->qts);
521 data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
522 test_acpi_rsdp_address(data);
523 test_acpi_rsdp_table(data);
524 test_acpi_rsdt_table(data);
525 test_acpi_fadt_table(data);
527 if (iasl) {
528 if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
529 dump_aml_files(data, true);
530 } else {
531 test_acpi_asl(data);
535 test_smbios_entry_point(data);
536 test_smbios_structs(data);
538 assert(!global_qtest);
539 qtest_quit(data->qts);
540 g_free(args);
543 static uint8_t base_required_struct_types[] = {
544 0, 1, 3, 4, 16, 17, 19, 32, 127
547 static void test_acpi_piix4_tcg(void)
549 test_data data;
551 /* Supplying -machine accel argument overrides the default (qtest).
552 * This is to make guest actually run.
554 memset(&data, 0, sizeof(data));
555 data.machine = MACHINE_PC;
556 data.required_struct_types = base_required_struct_types;
557 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
558 test_acpi_one(NULL, &data);
559 free_test_data(&data);
562 static void test_acpi_piix4_tcg_bridge(void)
564 test_data data;
566 memset(&data, 0, sizeof(data));
567 data.machine = MACHINE_PC;
568 data.variant = ".bridge";
569 data.required_struct_types = base_required_struct_types;
570 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
571 test_acpi_one("-device pci-bridge,chassis_nr=1", &data);
572 free_test_data(&data);
575 static void test_acpi_q35_tcg(void)
577 test_data data;
579 memset(&data, 0, sizeof(data));
580 data.machine = MACHINE_Q35;
581 data.required_struct_types = base_required_struct_types;
582 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
583 test_acpi_one(NULL, &data);
584 free_test_data(&data);
587 static void test_acpi_q35_tcg_bridge(void)
589 test_data data;
591 memset(&data, 0, sizeof(data));
592 data.machine = MACHINE_Q35;
593 data.variant = ".bridge";
594 data.required_struct_types = base_required_struct_types;
595 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
596 test_acpi_one("-device pci-bridge,chassis_nr=1",
597 &data);
598 free_test_data(&data);
601 static void test_acpi_q35_tcg_mmio64(void)
603 test_data data = {
604 .machine = MACHINE_Q35,
605 .variant = ".mmio64",
606 .required_struct_types = base_required_struct_types,
607 .required_struct_types_len = ARRAY_SIZE(base_required_struct_types)
610 test_acpi_one("-m 128M,slots=1,maxmem=2G "
611 "-device pci-testdev,membar=2G",
612 &data);
613 free_test_data(&data);
616 static void test_acpi_piix4_tcg_cphp(void)
618 test_data data;
620 memset(&data, 0, sizeof(data));
621 data.machine = MACHINE_PC;
622 data.variant = ".cphp";
623 test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
624 " -numa node -numa node"
625 " -numa dist,src=0,dst=1,val=21",
626 &data);
627 free_test_data(&data);
630 static void test_acpi_q35_tcg_cphp(void)
632 test_data data;
634 memset(&data, 0, sizeof(data));
635 data.machine = MACHINE_Q35;
636 data.variant = ".cphp";
637 test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
638 " -numa node -numa node"
639 " -numa dist,src=0,dst=1,val=21",
640 &data);
641 free_test_data(&data);
644 static uint8_t ipmi_required_struct_types[] = {
645 0, 1, 3, 4, 16, 17, 19, 32, 38, 127
648 static void test_acpi_q35_tcg_ipmi(void)
650 test_data data;
652 memset(&data, 0, sizeof(data));
653 data.machine = MACHINE_Q35;
654 data.variant = ".ipmibt";
655 data.required_struct_types = ipmi_required_struct_types;
656 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
657 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
658 " -device isa-ipmi-bt,bmc=bmc0",
659 &data);
660 free_test_data(&data);
663 static void test_acpi_piix4_tcg_ipmi(void)
665 test_data data;
667 /* Supplying -machine accel argument overrides the default (qtest).
668 * This is to make guest actually run.
670 memset(&data, 0, sizeof(data));
671 data.machine = MACHINE_PC;
672 data.variant = ".ipmikcs";
673 data.required_struct_types = ipmi_required_struct_types;
674 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
675 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
676 " -device isa-ipmi-kcs,irq=0,bmc=bmc0",
677 &data);
678 free_test_data(&data);
681 static void test_acpi_q35_tcg_memhp(void)
683 test_data data;
685 memset(&data, 0, sizeof(data));
686 data.machine = MACHINE_Q35;
687 data.variant = ".memhp";
688 test_acpi_one(" -m 128,slots=3,maxmem=1G"
689 " -numa node -numa node"
690 " -numa dist,src=0,dst=1,val=21",
691 &data);
692 free_test_data(&data);
695 static void test_acpi_piix4_tcg_memhp(void)
697 test_data data;
699 memset(&data, 0, sizeof(data));
700 data.machine = MACHINE_PC;
701 data.variant = ".memhp";
702 test_acpi_one(" -m 128,slots=3,maxmem=1G"
703 " -numa node -numa node"
704 " -numa dist,src=0,dst=1,val=21",
705 &data);
706 free_test_data(&data);
709 static void test_acpi_q35_tcg_numamem(void)
711 test_data data;
713 memset(&data, 0, sizeof(data));
714 data.machine = MACHINE_Q35;
715 data.variant = ".numamem";
716 test_acpi_one(" -numa node -numa node,mem=128", &data);
717 free_test_data(&data);
720 static void test_acpi_piix4_tcg_numamem(void)
722 test_data data;
724 memset(&data, 0, sizeof(data));
725 data.machine = MACHINE_PC;
726 data.variant = ".numamem";
727 test_acpi_one(" -numa node -numa node,mem=128", &data);
728 free_test_data(&data);
731 static void test_acpi_tcg_dimm_pxm(const char *machine)
733 test_data data;
735 memset(&data, 0, sizeof(data));
736 data.machine = machine;
737 data.variant = ".dimmpxm";
738 test_acpi_one(" -machine nvdimm=on,nvdimm-persistence=cpu"
739 " -smp 4,sockets=4"
740 " -m 128M,slots=3,maxmem=1G"
741 " -numa node,mem=32M,nodeid=0"
742 " -numa node,mem=32M,nodeid=1"
743 " -numa node,mem=32M,nodeid=2"
744 " -numa node,mem=32M,nodeid=3"
745 " -numa cpu,node-id=0,socket-id=0"
746 " -numa cpu,node-id=1,socket-id=1"
747 " -numa cpu,node-id=2,socket-id=2"
748 " -numa cpu,node-id=3,socket-id=3"
749 " -object memory-backend-ram,id=ram0,size=128M"
750 " -object memory-backend-ram,id=nvm0,size=128M"
751 " -device pc-dimm,id=dimm0,memdev=ram0,node=1"
752 " -device nvdimm,id=dimm1,memdev=nvm0,node=2",
753 &data);
754 free_test_data(&data);
757 static void test_acpi_q35_tcg_dimm_pxm(void)
759 test_acpi_tcg_dimm_pxm(MACHINE_Q35);
762 static void test_acpi_piix4_tcg_dimm_pxm(void)
764 test_acpi_tcg_dimm_pxm(MACHINE_PC);
767 int main(int argc, char *argv[])
769 const char *arch = qtest_get_arch();
770 int ret;
772 ret = boot_sector_init(disk);
773 if(ret)
774 return ret;
776 g_test_init(&argc, &argv, NULL);
778 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
779 qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
780 qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
781 qtest_add_func("acpi/q35", test_acpi_q35_tcg);
782 qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
783 qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
784 qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
785 qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
786 qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
787 qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
788 qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
789 qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
790 qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem);
791 qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
792 qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
793 qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
795 ret = g_test_run();
796 boot_sector_cleanup(disk);
797 return ret;