unit-test: Add testcase for pxb
[qemu/kevin.git] / tests / qtest / bios-tables-test.c
blob64a9a772eee768402857d2b6aa53e8f68692a9c7
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.
14 * How to add or update the tests or commit changes that affect ACPI tables:
15 * Contributor:
16 * 1. add empty files for new tables, if any, under tests/data/acpi
17 * 2. list any changed files in tests/qtest/bios-tables-test-allowed-diff.h
18 * 3. commit the above *before* making changes that affect the tables
20 * Contributor or ACPI Maintainer (steps 4-7 need to be redone to resolve conflicts
21 * in binary commit created in step 6):
23 * After 1-3 above tests will pass but ignore differences with the expected files.
24 * You will also notice that tests/qtest/bios-tables-test-allowed-diff.h lists
25 * a bunch of files. This is your hint that you need to do the below:
26 * 4. Run
27 * make check V=1
28 * this will produce a bunch of warnings about differences
29 * beween actual and expected ACPI tables. If you have IASL installed,
30 * they will also be disassembled so you can look at the disassembled
31 * output. If not - disassemble them yourself in any way you like.
32 * Look at the differences - make sure they make sense and match what the
33 * changes you are merging are supposed to do.
34 * Save the changes, preferably in form of ASL diff for the commit log in
35 * step 6.
37 * 5. From build directory, run:
38 * $(SRC_PATH)/tests/data/acpi/rebuild-expected-aml.sh
39 * 6. Now commit any changes to the expected binary, include diff from step 4
40 * in commit log.
41 * Expected binary updates needs to be a separate patch from the code that
42 * introduces changes to ACPI tables. It lets the maintainer drop
43 * and regenerate binary updates in case of merge conflicts. Further, a code
44 * change is easily reviewable but a binary blob is not (without doing a
45 * disassembly).
46 * 7. Before sending patches to the list (Contributor)
47 * or before doing a pull request (Maintainer), make sure
48 * tests/qtest/bios-tables-test-allowed-diff.h is empty - this will ensure
49 * following changes to ACPI tables will be noticed.
51 * The resulting patchset/pull request then looks like this:
52 * - patch 1: list changed files in tests/qtest/bios-tables-test-allowed-diff.h.
53 * - patches 2 - n: real changes, may contain multiple patches.
54 * - patch n + 1: update golden master binaries and empty
55 * tests/qtest/bios-tables-test-allowed-diff.h
58 #include "qemu/osdep.h"
59 #include <glib/gstdio.h>
60 #include "qemu-common.h"
61 #include "hw/firmware/smbios.h"
62 #include "qemu/bitmap.h"
63 #include "acpi-utils.h"
64 #include "boot-sector.h"
65 #include "tpm-emu.h"
66 #include "hw/acpi/tpm.h"
69 #define MACHINE_PC "pc"
70 #define MACHINE_Q35 "q35"
72 #define ACPI_REBUILD_EXPECTED_AML "TEST_ACPI_REBUILD_AML"
74 typedef struct {
75 bool tcg_only;
76 const char *machine;
77 const char *variant;
78 const char *uefi_fl1;
79 const char *uefi_fl2;
80 const char *blkdev;
81 const char *cd;
82 const uint64_t ram_start;
83 const uint64_t scan_len;
84 uint64_t rsdp_addr;
85 uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
86 GArray *tables;
87 uint32_t smbios_ep_addr;
88 struct smbios_21_entry_point smbios_ep_table;
89 uint16_t smbios_cpu_max_speed;
90 uint16_t smbios_cpu_curr_speed;
91 uint8_t *required_struct_types;
92 int required_struct_types_len;
93 QTestState *qts;
94 } test_data;
96 static char disk[] = "tests/acpi-test-disk-XXXXXX";
97 static const char *data_dir = "tests/data/acpi";
98 #ifdef CONFIG_IASL
99 static const char *iasl = CONFIG_IASL;
100 #else
101 static const char *iasl;
102 #endif
104 static bool compare_signature(const AcpiSdtTable *sdt, const char *signature)
106 return !memcmp(sdt->aml, signature, 4);
109 static void cleanup_table_descriptor(AcpiSdtTable *table)
111 g_free(table->aml);
112 if (table->aml_file &&
113 !table->tmp_files_retain &&
114 g_strstr_len(table->aml_file, -1, "aml-")) {
115 unlink(table->aml_file);
117 g_free(table->aml_file);
118 g_free(table->asl);
119 if (table->asl_file &&
120 !table->tmp_files_retain) {
121 unlink(table->asl_file);
123 g_free(table->asl_file);
126 static void free_test_data(test_data *data)
128 int i;
130 if (!data->tables) {
131 return;
133 for (i = 0; i < data->tables->len; ++i) {
134 cleanup_table_descriptor(&g_array_index(data->tables, AcpiSdtTable, i));
137 g_array_free(data->tables, true);
140 static void test_acpi_rsdp_table(test_data *data)
142 uint8_t *rsdp_table = data->rsdp_table;
144 acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
146 switch (rsdp_table[15 /* Revision offset */]) {
147 case 0: /* ACPI 1.0 RSDP */
148 /* With rev 1, checksum is only for the first 20 bytes */
149 g_assert(!acpi_calc_checksum(rsdp_table, 20));
150 break;
151 case 2: /* ACPI 2.0+ RSDP */
152 /* With revision 2, we have 2 checksums */
153 g_assert(!acpi_calc_checksum(rsdp_table, 20));
154 g_assert(!acpi_calc_checksum(rsdp_table, 36));
155 break;
156 default:
157 g_assert_not_reached();
161 static void test_acpi_rxsdt_table(test_data *data)
163 const char *sig = "RSDT";
164 AcpiSdtTable rsdt = {};
165 int entry_size = 4;
166 int addr_off = 16 /* RsdtAddress */;
167 uint8_t *ent;
169 if (data->rsdp_table[15 /* Revision offset */] != 0) {
170 addr_off = 24 /* XsdtAddress */;
171 entry_size = 8;
172 sig = "XSDT";
174 /* read [RX]SDT table */
175 acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
176 &data->rsdp_table[addr_off], entry_size, sig, true);
178 /* Load all tables and add to test list directly RSDT referenced tables */
179 ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
180 AcpiSdtTable ssdt_table = {};
182 acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
183 entry_size, NULL, true);
184 /* Add table to ASL test tables list */
185 g_array_append_val(data->tables, ssdt_table);
187 cleanup_table_descriptor(&rsdt);
190 static void test_acpi_fadt_table(test_data *data)
192 /* FADT table is 1st */
193 AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
194 uint8_t *fadt_aml = table.aml;
195 uint32_t fadt_len = table.aml_len;
196 uint32_t val;
197 int dsdt_offset = 40 /* DSDT */;
198 int dsdt_entry_size = 4;
200 g_assert(compare_signature(&table, "FACP"));
202 /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
203 memcpy(&val, fadt_aml + 112 /* Flags */, 4);
204 val = le32_to_cpu(val);
205 if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
206 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
207 fadt_aml + 36 /* FIRMWARE_CTRL */, 4, "FACS", false);
208 g_array_append_val(data->tables, table);
211 memcpy(&val, fadt_aml + dsdt_offset, 4);
212 val = le32_to_cpu(val);
213 if (!val) {
214 dsdt_offset = 140 /* X_DSDT */;
215 dsdt_entry_size = 8;
217 acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
218 fadt_aml + dsdt_offset, dsdt_entry_size, "DSDT", true);
219 g_array_append_val(data->tables, table);
221 memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
222 memset(fadt_aml + 40, 0, 4); /* sanitize DSDT ptr */
223 if (fadt_aml[8 /* FADT Major Version */] >= 3) {
224 memset(fadt_aml + 132, 0, 8); /* sanitize X_FIRMWARE_CTRL ptr */
225 memset(fadt_aml + 140, 0, 8); /* sanitize X_DSDT ptr */
228 /* update checksum */
229 fadt_aml[9 /* Checksum */] = 0;
230 fadt_aml[9 /* Checksum */] -= acpi_calc_checksum(fadt_aml, fadt_len);
233 static void dump_aml_files(test_data *data, bool rebuild)
235 AcpiSdtTable *sdt;
236 GError *error = NULL;
237 gchar *aml_file = NULL;
238 gint fd;
239 ssize_t ret;
240 int i;
242 for (i = 0; i < data->tables->len; ++i) {
243 const char *ext = data->variant ? data->variant : "";
244 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
245 g_assert(sdt->aml);
247 if (rebuild) {
248 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
249 sdt->aml, ext);
250 fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
251 S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
252 if (fd < 0) {
253 perror(aml_file);
255 g_assert(fd >= 0);
256 } else {
257 fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
258 g_assert_no_error(error);
261 ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
262 g_assert(ret == sdt->aml_len);
264 close(fd);
266 g_free(aml_file);
270 static bool load_asl(GArray *sdts, AcpiSdtTable *sdt)
272 AcpiSdtTable *temp;
273 GError *error = NULL;
274 GString *command_line = g_string_new(iasl);
275 gint fd;
276 gchar *out, *out_err;
277 gboolean ret;
278 int i;
280 fd = g_file_open_tmp("asl-XXXXXX.dsl", &sdt->asl_file, &error);
281 g_assert_no_error(error);
282 close(fd);
284 /* build command line */
285 g_string_append_printf(command_line, " -p %s ", sdt->asl_file);
286 if (compare_signature(sdt, "DSDT") ||
287 compare_signature(sdt, "SSDT")) {
288 for (i = 0; i < sdts->len; ++i) {
289 temp = &g_array_index(sdts, AcpiSdtTable, i);
290 if (compare_signature(temp, "DSDT") ||
291 compare_signature(temp, "SSDT")) {
292 g_string_append_printf(command_line, "-e %s ", temp->aml_file);
296 g_string_append_printf(command_line, "-d %s", sdt->aml_file);
298 /* pass 'out' and 'out_err' in order to be redirected */
299 ret = g_spawn_command_line_sync(command_line->str, &out, &out_err, NULL, &error);
300 g_assert_no_error(error);
301 if (ret) {
302 ret = g_file_get_contents(sdt->asl_file, &sdt->asl,
303 &sdt->asl_len, &error);
304 g_assert(ret);
305 g_assert_no_error(error);
306 ret = (sdt->asl_len > 0);
309 g_free(out);
310 g_free(out_err);
311 g_string_free(command_line, true);
313 return !ret;
316 #define COMMENT_END "*/"
317 #define DEF_BLOCK "DefinitionBlock ("
318 #define BLOCK_NAME_END ","
320 static GString *normalize_asl(gchar *asl_code)
322 GString *asl = g_string_new(asl_code);
323 gchar *comment, *block_name;
325 /* strip comments (different generation days) */
326 comment = g_strstr_len(asl->str, asl->len, COMMENT_END);
327 if (comment) {
328 comment += strlen(COMMENT_END);
329 while (*comment == '\n') {
330 comment++;
332 asl = g_string_erase(asl, 0, comment - asl->str);
335 /* strip def block name (it has file path in it) */
336 if (g_str_has_prefix(asl->str, DEF_BLOCK)) {
337 block_name = g_strstr_len(asl->str, asl->len, BLOCK_NAME_END);
338 g_assert(block_name);
339 asl = g_string_erase(asl, 0,
340 block_name + sizeof(BLOCK_NAME_END) - asl->str);
343 return asl;
346 static GArray *load_expected_aml(test_data *data)
348 int i;
349 AcpiSdtTable *sdt;
350 GError *error = NULL;
351 gboolean ret;
352 gsize aml_len;
354 GArray *exp_tables = g_array_new(false, true, sizeof(AcpiSdtTable));
355 if (getenv("V")) {
356 fputc('\n', stderr);
358 for (i = 0; i < data->tables->len; ++i) {
359 AcpiSdtTable exp_sdt;
360 gchar *aml_file = NULL;
361 const char *ext = data->variant ? data->variant : "";
363 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
365 memset(&exp_sdt, 0, sizeof(exp_sdt));
367 try_again:
368 aml_file = g_strdup_printf("%s/%s/%.4s%s", data_dir, data->machine,
369 sdt->aml, ext);
370 if (getenv("V")) {
371 fprintf(stderr, "Looking for expected file '%s'\n", aml_file);
373 if (g_file_test(aml_file, G_FILE_TEST_EXISTS)) {
374 exp_sdt.aml_file = aml_file;
375 } else if (*ext != '\0') {
376 /* try fallback to generic (extension less) expected file */
377 ext = "";
378 g_free(aml_file);
379 goto try_again;
381 g_assert(exp_sdt.aml_file);
382 if (getenv("V")) {
383 fprintf(stderr, "Using expected file '%s'\n", aml_file);
385 ret = g_file_get_contents(aml_file, (gchar **)&exp_sdt.aml,
386 &aml_len, &error);
387 exp_sdt.aml_len = aml_len;
388 g_assert(ret);
389 g_assert_no_error(error);
390 g_assert(exp_sdt.aml);
391 if (!exp_sdt.aml_len) {
392 fprintf(stderr, "Warning! zero length expected file '%s'\n",
393 aml_file);
396 g_array_append_val(exp_tables, exp_sdt);
399 return exp_tables;
402 static bool test_acpi_find_diff_allowed(AcpiSdtTable *sdt)
404 const gchar *allowed_diff_file[] = {
405 #include "bios-tables-test-allowed-diff.h"
406 NULL
408 const gchar **f;
410 for (f = allowed_diff_file; *f; ++f) {
411 if (!g_strcmp0(sdt->aml_file, *f)) {
412 return true;
415 return false;
418 /* test the list of tables in @data->tables against reference tables */
419 static void test_acpi_asl(test_data *data)
421 int i;
422 AcpiSdtTable *sdt, *exp_sdt;
423 test_data exp_data;
424 gboolean exp_err, err, all_tables_match = true;
426 memset(&exp_data, 0, sizeof(exp_data));
427 exp_data.tables = load_expected_aml(data);
428 dump_aml_files(data, false);
429 for (i = 0; i < data->tables->len; ++i) {
430 GString *asl, *exp_asl;
432 sdt = &g_array_index(data->tables, AcpiSdtTable, i);
433 exp_sdt = &g_array_index(exp_data.tables, AcpiSdtTable, i);
435 if (sdt->aml_len == exp_sdt->aml_len &&
436 !memcmp(sdt->aml, exp_sdt->aml, sdt->aml_len)) {
437 /* Identical table binaries: no need to disassemble. */
438 continue;
441 fprintf(stderr,
442 "acpi-test: Warning! %.4s binary file mismatch. "
443 "Actual [aml:%s], Expected [aml:%s].\n"
444 "See source file tests/qtest/bios-tables-test.c "
445 "for instructions on how to update expected files.\n",
446 exp_sdt->aml, sdt->aml_file, exp_sdt->aml_file);
448 all_tables_match = all_tables_match &&
449 test_acpi_find_diff_allowed(exp_sdt);
452 * don't try to decompile if IASL isn't present, in this case user
453 * will just 'get binary file mismatch' warnings and test failure
455 if (!iasl) {
456 continue;
459 err = load_asl(data->tables, sdt);
460 asl = normalize_asl(sdt->asl);
462 exp_err = load_asl(exp_data.tables, exp_sdt);
463 exp_asl = normalize_asl(exp_sdt->asl);
465 /* TODO: check for warnings */
466 g_assert(!err || exp_err);
468 if (g_strcmp0(asl->str, exp_asl->str)) {
469 sdt->tmp_files_retain = true;
470 if (exp_err) {
471 fprintf(stderr,
472 "Warning! iasl couldn't parse the expected aml\n");
473 } else {
474 exp_sdt->tmp_files_retain = true;
475 fprintf(stderr,
476 "acpi-test: Warning! %.4s mismatch. "
477 "Actual [asl:%s, aml:%s], Expected [asl:%s, aml:%s].\n",
478 exp_sdt->aml, sdt->asl_file, sdt->aml_file,
479 exp_sdt->asl_file, exp_sdt->aml_file);
480 fflush(stderr);
481 if (getenv("V")) {
482 const char *diff_env = getenv("DIFF");
483 const char *diff_cmd = diff_env ? diff_env : "diff -U 16";
484 char *diff = g_strdup_printf("%s %s %s", diff_cmd,
485 exp_sdt->asl_file, sdt->asl_file);
486 int out = dup(STDOUT_FILENO);
487 int ret G_GNUC_UNUSED;
489 dup2(STDERR_FILENO, STDOUT_FILENO);
490 ret = system(diff) ;
491 dup2(out, STDOUT_FILENO);
492 close(out);
493 g_free(diff);
497 g_string_free(asl, true);
498 g_string_free(exp_asl, true);
500 if (!iasl && !all_tables_match) {
501 fprintf(stderr, "to see ASL diff between mismatched files install IASL,"
502 " rebuild QEMU from scratch and re-run tests with V=1"
503 " environment variable set");
505 g_assert(all_tables_match);
507 free_test_data(&exp_data);
510 static bool smbios_ep_table_ok(test_data *data)
512 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
513 uint32_t addr = data->smbios_ep_addr;
515 qtest_memread(data->qts, addr, ep_table, sizeof(*ep_table));
516 if (memcmp(ep_table->anchor_string, "_SM_", 4)) {
517 return false;
519 if (memcmp(ep_table->intermediate_anchor_string, "_DMI_", 5)) {
520 return false;
522 if (ep_table->structure_table_length == 0) {
523 return false;
525 if (ep_table->number_of_structures == 0) {
526 return false;
528 if (acpi_calc_checksum((uint8_t *)ep_table, sizeof *ep_table) ||
529 acpi_calc_checksum((uint8_t *)ep_table + 0x10,
530 sizeof *ep_table - 0x10)) {
531 return false;
533 return true;
536 static void test_smbios_entry_point(test_data *data)
538 uint32_t off;
540 /* find smbios entry point structure */
541 for (off = 0xf0000; off < 0x100000; off += 0x10) {
542 uint8_t sig[] = "_SM_";
543 int i;
545 for (i = 0; i < sizeof sig - 1; ++i) {
546 sig[i] = qtest_readb(data->qts, off + i);
549 if (!memcmp(sig, "_SM_", sizeof sig)) {
550 /* signature match, but is this a valid entry point? */
551 data->smbios_ep_addr = off;
552 if (smbios_ep_table_ok(data)) {
553 break;
558 g_assert_cmphex(off, <, 0x100000);
561 static inline bool smbios_single_instance(uint8_t type)
563 switch (type) {
564 case 0:
565 case 1:
566 case 2:
567 case 3:
568 case 16:
569 case 32:
570 case 127:
571 return true;
572 default:
573 return false;
577 static bool smbios_cpu_test(test_data *data, uint32_t addr)
579 uint16_t expect_speed[2];
580 uint16_t real;
581 int offset[2];
582 int i;
584 /* Check CPU speed for backward compatibility */
585 offset[0] = offsetof(struct smbios_type_4, max_speed);
586 offset[1] = offsetof(struct smbios_type_4, current_speed);
587 expect_speed[0] = data->smbios_cpu_max_speed ? : 2000;
588 expect_speed[1] = data->smbios_cpu_curr_speed ? : 2000;
590 for (i = 0; i < 2; i++) {
591 real = qtest_readw(data->qts, addr + offset[i]);
592 if (real != expect_speed[i]) {
593 fprintf(stderr, "Unexpected SMBIOS CPU speed: real %u expect %u\n",
594 real, expect_speed[i]);
595 return false;
599 return true;
602 static void test_smbios_structs(test_data *data)
604 DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
605 struct smbios_21_entry_point *ep_table = &data->smbios_ep_table;
606 uint32_t addr = le32_to_cpu(ep_table->structure_table_address);
607 int i, len, max_len = 0;
608 uint8_t type, prv, crt;
610 /* walk the smbios tables */
611 for (i = 0; i < le16_to_cpu(ep_table->number_of_structures); i++) {
613 /* grab type and formatted area length from struct header */
614 type = qtest_readb(data->qts, addr);
615 g_assert_cmpuint(type, <=, SMBIOS_MAX_TYPE);
616 len = qtest_readb(data->qts, addr + 1);
618 /* single-instance structs must not have been encountered before */
619 if (smbios_single_instance(type)) {
620 g_assert(!test_bit(type, struct_bitmap));
622 set_bit(type, struct_bitmap);
624 if (type == 4) {
625 g_assert(smbios_cpu_test(data, addr));
628 /* seek to end of unformatted string area of this struct ("\0\0") */
629 prv = crt = 1;
630 while (prv || crt) {
631 prv = crt;
632 crt = qtest_readb(data->qts, addr + len);
633 len++;
636 /* keep track of max. struct size */
637 if (max_len < len) {
638 max_len = len;
639 g_assert_cmpuint(max_len, <=, ep_table->max_structure_size);
642 /* start of next structure */
643 addr += len;
646 /* total table length and max struct size must match entry point values */
647 g_assert_cmpuint(le16_to_cpu(ep_table->structure_table_length), ==,
648 addr - le32_to_cpu(ep_table->structure_table_address));
649 g_assert_cmpuint(le16_to_cpu(ep_table->max_structure_size), ==, max_len);
651 /* required struct types must all be present */
652 for (i = 0; i < data->required_struct_types_len; i++) {
653 g_assert(test_bit(data->required_struct_types[i], struct_bitmap));
657 static void test_acpi_one(const char *params, test_data *data)
659 char *args;
660 bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
662 #ifndef CONFIG_TCG
663 if (data->tcg_only) {
664 g_test_skip("TCG disabled, skipping ACPI tcg_only test");
665 return;
667 #endif /* CONFIG_TCG */
669 if (use_uefi) {
671 * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
672 * when arm/virt boad starts to support it.
674 if (data->cd) {
675 args = g_strdup_printf("-machine %s %s -accel tcg "
676 "-nodefaults -nographic "
677 "-drive if=pflash,format=raw,file=%s,readonly "
678 "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
679 data->machine, data->tcg_only ? "" : "-accel kvm",
680 data->uefi_fl1, data->uefi_fl2, data->cd, params ? params : "");
681 } else {
682 args = g_strdup_printf("-machine %s %s -accel tcg "
683 "-nodefaults -nographic "
684 "-drive if=pflash,format=raw,file=%s,readonly "
685 "-drive if=pflash,format=raw,file=%s,snapshot=on %s",
686 data->machine, data->tcg_only ? "" : "-accel kvm",
687 data->uefi_fl1, data->uefi_fl2, params ? params : "");
689 } else {
690 args = g_strdup_printf("-machine %s %s -accel tcg "
691 "-net none -display none %s "
692 "-drive id=hd0,if=none,file=%s,format=raw "
693 "-device %s,drive=hd0 ",
694 data->machine, data->tcg_only ? "" : "-accel kvm",
695 params ? params : "", disk,
696 data->blkdev ?: "ide-hd");
699 data->qts = qtest_init(args);
701 if (use_uefi) {
702 g_assert(data->scan_len);
703 data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
704 data->ram_start, data->scan_len);
705 } else {
706 boot_sector_test(data->qts);
707 data->rsdp_addr = acpi_find_rsdp_address(data->qts);
708 g_assert_cmphex(data->rsdp_addr, <, 0x100000);
711 data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
712 test_acpi_rsdp_table(data);
713 test_acpi_rxsdt_table(data);
714 test_acpi_fadt_table(data);
716 if (getenv(ACPI_REBUILD_EXPECTED_AML)) {
717 dump_aml_files(data, true);
718 } else {
719 test_acpi_asl(data);
723 * TODO: make SMBIOS tests work with UEFI firmware,
724 * Bug on uefi-test-tools to provide entry point:
725 * https://bugs.launchpad.net/qemu/+bug/1821884
727 if (!use_uefi) {
728 test_smbios_entry_point(data);
729 test_smbios_structs(data);
732 qtest_quit(data->qts);
733 g_free(args);
736 static uint8_t base_required_struct_types[] = {
737 0, 1, 3, 4, 16, 17, 19, 32, 127
740 static void test_acpi_piix4_tcg(void)
742 test_data data;
744 /* Supplying -machine accel argument overrides the default (qtest).
745 * This is to make guest actually run.
747 memset(&data, 0, sizeof(data));
748 data.machine = MACHINE_PC;
749 data.required_struct_types = base_required_struct_types;
750 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
751 test_acpi_one(NULL, &data);
752 free_test_data(&data);
755 static void test_acpi_piix4_tcg_bridge(void)
757 test_data data;
759 memset(&data, 0, sizeof(data));
760 data.machine = MACHINE_PC;
761 data.variant = ".bridge";
762 data.required_struct_types = base_required_struct_types;
763 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
764 test_acpi_one("-device pci-bridge,chassis_nr=1", &data);
765 free_test_data(&data);
768 static void test_acpi_piix4_no_root_hotplug(void)
770 test_data data;
772 memset(&data, 0, sizeof(data));
773 data.machine = MACHINE_PC;
774 data.variant = ".roothp";
775 data.required_struct_types = base_required_struct_types;
776 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
777 test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
778 "-device pci-bridge,chassis_nr=1", &data);
779 free_test_data(&data);
782 static void test_acpi_piix4_no_bridge_hotplug(void)
784 test_data data;
786 memset(&data, 0, sizeof(data));
787 data.machine = MACHINE_PC;
788 data.variant = ".hpbridge";
789 data.required_struct_types = base_required_struct_types;
790 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
791 test_acpi_one("-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
792 "-device pci-bridge,chassis_nr=1", &data);
793 free_test_data(&data);
796 static void test_acpi_piix4_no_acpi_pci_hotplug(void)
798 test_data data;
800 memset(&data, 0, sizeof(data));
801 data.machine = MACHINE_PC;
802 data.variant = ".hpbrroot";
803 data.required_struct_types = base_required_struct_types;
804 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
805 test_acpi_one("-global PIIX4_PM.acpi-root-pci-hotplug=off "
806 "-global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=off "
807 "-device pci-bridge,chassis_nr=1", &data);
808 free_test_data(&data);
811 static void test_acpi_q35_tcg(void)
813 test_data data;
815 memset(&data, 0, sizeof(data));
816 data.machine = MACHINE_Q35;
817 data.required_struct_types = base_required_struct_types;
818 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
819 test_acpi_one(NULL, &data);
820 free_test_data(&data);
822 data.smbios_cpu_max_speed = 3000;
823 data.smbios_cpu_curr_speed = 2600;
824 test_acpi_one("-smbios type=4,max-speed=3000,current-speed=2600", &data);
825 free_test_data(&data);
828 static void test_acpi_q35_tcg_bridge(void)
830 test_data data;
832 memset(&data, 0, sizeof(data));
833 data.machine = MACHINE_Q35;
834 data.variant = ".bridge";
835 data.required_struct_types = base_required_struct_types;
836 data.required_struct_types_len = ARRAY_SIZE(base_required_struct_types);
837 test_acpi_one("-device pci-bridge,chassis_nr=1",
838 &data);
839 free_test_data(&data);
842 static void test_acpi_q35_tcg_mmio64(void)
844 test_data data = {
845 .machine = MACHINE_Q35,
846 .variant = ".mmio64",
847 .required_struct_types = base_required_struct_types,
848 .required_struct_types_len = ARRAY_SIZE(base_required_struct_types)
851 test_acpi_one("-m 128M,slots=1,maxmem=2G "
852 "-object memory-backend-ram,id=ram0,size=128M "
853 "-numa node,memdev=ram0 "
854 "-device pci-testdev,membar=2G",
855 &data);
856 free_test_data(&data);
859 static void test_acpi_piix4_tcg_cphp(void)
861 test_data data;
863 memset(&data, 0, sizeof(data));
864 data.machine = MACHINE_PC;
865 data.variant = ".cphp";
866 test_acpi_one("-smp 2,cores=3,sockets=2,maxcpus=6"
867 " -object memory-backend-ram,id=ram0,size=64M"
868 " -object memory-backend-ram,id=ram1,size=64M"
869 " -numa node,memdev=ram0 -numa node,memdev=ram1"
870 " -numa dist,src=0,dst=1,val=21",
871 &data);
872 free_test_data(&data);
875 static void test_acpi_q35_tcg_cphp(void)
877 test_data data;
879 memset(&data, 0, sizeof(data));
880 data.machine = MACHINE_Q35;
881 data.variant = ".cphp";
882 test_acpi_one(" -smp 2,cores=3,sockets=2,maxcpus=6"
883 " -object memory-backend-ram,id=ram0,size=64M"
884 " -object memory-backend-ram,id=ram1,size=64M"
885 " -numa node,memdev=ram0 -numa node,memdev=ram1"
886 " -numa dist,src=0,dst=1,val=21",
887 &data);
888 free_test_data(&data);
891 static uint8_t ipmi_required_struct_types[] = {
892 0, 1, 3, 4, 16, 17, 19, 32, 38, 127
895 static void test_acpi_q35_tcg_ipmi(void)
897 test_data data;
899 memset(&data, 0, sizeof(data));
900 data.machine = MACHINE_Q35;
901 data.variant = ".ipmibt";
902 data.required_struct_types = ipmi_required_struct_types;
903 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
904 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
905 " -device isa-ipmi-bt,bmc=bmc0",
906 &data);
907 free_test_data(&data);
910 static void test_acpi_piix4_tcg_ipmi(void)
912 test_data data;
914 /* Supplying -machine accel argument overrides the default (qtest).
915 * This is to make guest actually run.
917 memset(&data, 0, sizeof(data));
918 data.machine = MACHINE_PC;
919 data.variant = ".ipmikcs";
920 data.required_struct_types = ipmi_required_struct_types;
921 data.required_struct_types_len = ARRAY_SIZE(ipmi_required_struct_types);
922 test_acpi_one("-device ipmi-bmc-sim,id=bmc0"
923 " -device isa-ipmi-kcs,irq=0,bmc=bmc0",
924 &data);
925 free_test_data(&data);
928 static void test_acpi_q35_tcg_memhp(void)
930 test_data data;
932 memset(&data, 0, sizeof(data));
933 data.machine = MACHINE_Q35;
934 data.variant = ".memhp";
935 test_acpi_one(" -m 128,slots=3,maxmem=1G"
936 " -object memory-backend-ram,id=ram0,size=64M"
937 " -object memory-backend-ram,id=ram1,size=64M"
938 " -numa node,memdev=ram0 -numa node,memdev=ram1"
939 " -numa dist,src=0,dst=1,val=21",
940 &data);
941 free_test_data(&data);
944 static void test_acpi_piix4_tcg_memhp(void)
946 test_data data;
948 memset(&data, 0, sizeof(data));
949 data.machine = MACHINE_PC;
950 data.variant = ".memhp";
951 test_acpi_one(" -m 128,slots=3,maxmem=1G"
952 " -object memory-backend-ram,id=ram0,size=64M"
953 " -object memory-backend-ram,id=ram1,size=64M"
954 " -numa node,memdev=ram0 -numa node,memdev=ram1"
955 " -numa dist,src=0,dst=1,val=21",
956 &data);
957 free_test_data(&data);
960 static void test_acpi_q35_tcg_numamem(void)
962 test_data data;
964 memset(&data, 0, sizeof(data));
965 data.machine = MACHINE_Q35;
966 data.variant = ".numamem";
967 test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M"
968 " -numa node -numa node,memdev=ram0", &data);
969 free_test_data(&data);
972 static void test_acpi_piix4_tcg_numamem(void)
974 test_data data;
976 memset(&data, 0, sizeof(data));
977 data.machine = MACHINE_PC;
978 data.variant = ".numamem";
979 test_acpi_one(" -object memory-backend-ram,id=ram0,size=128M"
980 " -numa node -numa node,memdev=ram0", &data);
981 free_test_data(&data);
984 uint64_t tpm_tis_base_addr;
986 static void test_acpi_tcg_tpm(const char *machine, const char *tpm_if,
987 uint64_t base)
989 #ifdef CONFIG_TPM
990 gchar *tmp_dir_name = g_strdup_printf("qemu-test_acpi_%s_tcg_%s.XXXXXX",
991 machine, tpm_if);
992 char *tmp_path = g_dir_make_tmp(tmp_dir_name, NULL);
993 TestState test;
994 test_data data;
995 GThread *thread;
996 char *args, *variant = g_strdup_printf(".%s", tpm_if);
998 tpm_tis_base_addr = base;
1000 module_call_init(MODULE_INIT_QOM);
1002 test.addr = g_new0(SocketAddress, 1);
1003 test.addr->type = SOCKET_ADDRESS_TYPE_UNIX;
1004 test.addr->u.q_unix.path = g_build_filename(tmp_path, "sock", NULL);
1005 g_mutex_init(&test.data_mutex);
1006 g_cond_init(&test.data_cond);
1007 test.data_cond_signal = false;
1009 thread = g_thread_new(NULL, tpm_emu_ctrl_thread, &test);
1010 tpm_emu_test_wait_cond(&test);
1012 memset(&data, 0, sizeof(data));
1013 data.machine = machine;
1014 data.variant = variant;
1016 args = g_strdup_printf(
1017 " -chardev socket,id=chr,path=%s"
1018 " -tpmdev emulator,id=dev,chardev=chr"
1019 " -device tpm-%s,tpmdev=dev",
1020 test.addr->u.q_unix.path, tpm_if);
1022 test_acpi_one(args, &data);
1024 g_thread_join(thread);
1025 g_unlink(test.addr->u.q_unix.path);
1026 qapi_free_SocketAddress(test.addr);
1027 g_rmdir(tmp_path);
1028 g_free(variant);
1029 g_free(tmp_path);
1030 g_free(tmp_dir_name);
1031 g_free(args);
1032 free_test_data(&data);
1033 #else
1034 g_test_skip("TPM disabled");
1035 #endif
1038 static void test_acpi_q35_tcg_tpm_tis(void)
1040 test_acpi_tcg_tpm("q35", "tis", 0xFED40000);
1043 static void test_acpi_tcg_dimm_pxm(const char *machine)
1045 test_data data;
1047 memset(&data, 0, sizeof(data));
1048 data.machine = machine;
1049 data.variant = ".dimmpxm";
1050 test_acpi_one(" -machine nvdimm=on,nvdimm-persistence=cpu"
1051 " -smp 4,sockets=4"
1052 " -m 128M,slots=3,maxmem=1G"
1053 " -object memory-backend-ram,id=ram0,size=32M"
1054 " -object memory-backend-ram,id=ram1,size=32M"
1055 " -object memory-backend-ram,id=ram2,size=32M"
1056 " -object memory-backend-ram,id=ram3,size=32M"
1057 " -numa node,memdev=ram0,nodeid=0"
1058 " -numa node,memdev=ram1,nodeid=1"
1059 " -numa node,memdev=ram2,nodeid=2"
1060 " -numa node,memdev=ram3,nodeid=3"
1061 " -numa cpu,node-id=0,socket-id=0"
1062 " -numa cpu,node-id=1,socket-id=1"
1063 " -numa cpu,node-id=2,socket-id=2"
1064 " -numa cpu,node-id=3,socket-id=3"
1065 " -object memory-backend-ram,id=ram4,size=128M"
1066 " -object memory-backend-ram,id=nvm0,size=128M"
1067 " -device pc-dimm,id=dimm0,memdev=ram4,node=1"
1068 " -device nvdimm,id=dimm1,memdev=nvm0,node=2",
1069 &data);
1070 free_test_data(&data);
1073 static void test_acpi_q35_tcg_dimm_pxm(void)
1075 test_acpi_tcg_dimm_pxm(MACHINE_Q35);
1078 static void test_acpi_piix4_tcg_dimm_pxm(void)
1080 test_acpi_tcg_dimm_pxm(MACHINE_PC);
1083 static void test_acpi_virt_tcg_memhp(void)
1085 test_data data = {
1086 .machine = "virt",
1087 .tcg_only = true,
1088 .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
1089 .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
1090 .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
1091 .ram_start = 0x40000000ULL,
1092 .scan_len = 256ULL * 1024 * 1024,
1095 data.variant = ".memhp";
1096 test_acpi_one(" -machine nvdimm=on"
1097 " -cpu cortex-a57"
1098 " -m 256M,slots=3,maxmem=1G"
1099 " -object memory-backend-ram,id=ram0,size=128M"
1100 " -object memory-backend-ram,id=ram1,size=128M"
1101 " -numa node,memdev=ram0 -numa node,memdev=ram1"
1102 " -numa dist,src=0,dst=1,val=21"
1103 " -object memory-backend-ram,id=ram2,size=128M"
1104 " -object memory-backend-ram,id=nvm0,size=128M"
1105 " -device pc-dimm,id=dimm0,memdev=ram2,node=0"
1106 " -device nvdimm,id=dimm1,memdev=nvm0,node=1",
1107 &data);
1109 free_test_data(&data);
1113 static void test_acpi_microvm_prepare(test_data *data)
1115 memset(data, 0, sizeof(*data));
1116 data->machine = "microvm";
1117 data->required_struct_types = NULL; /* no smbios */
1118 data->required_struct_types_len = 0;
1119 data->blkdev = "virtio-blk-device";
1122 static void test_acpi_microvm_tcg(void)
1124 test_data data;
1126 test_acpi_microvm_prepare(&data);
1127 test_acpi_one(" -machine microvm,acpi=on,rtc=off",
1128 &data);
1129 free_test_data(&data);
1132 static void test_acpi_microvm_usb_tcg(void)
1134 test_data data;
1136 test_acpi_microvm_prepare(&data);
1137 data.variant = ".usb";
1138 test_acpi_one(" -machine microvm,acpi=on,usb=on,rtc=off",
1139 &data);
1140 free_test_data(&data);
1143 static void test_acpi_microvm_rtc_tcg(void)
1145 test_data data;
1147 test_acpi_microvm_prepare(&data);
1148 data.variant = ".rtc";
1149 test_acpi_one(" -machine microvm,acpi=on,rtc=on",
1150 &data);
1151 free_test_data(&data);
1154 static void test_acpi_microvm_pcie_tcg(void)
1156 test_data data;
1158 test_acpi_microvm_prepare(&data);
1159 data.variant = ".pcie";
1160 data.tcg_only = true; /* need constant host-phys-bits */
1161 test_acpi_one(" -machine microvm,acpi=on,rtc=off,pcie=on",
1162 &data);
1163 free_test_data(&data);
1166 static void test_acpi_virt_tcg_numamem(void)
1168 test_data data = {
1169 .machine = "virt",
1170 .tcg_only = true,
1171 .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
1172 .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
1173 .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
1174 .ram_start = 0x40000000ULL,
1175 .scan_len = 128ULL * 1024 * 1024,
1178 data.variant = ".numamem";
1179 test_acpi_one(" -cpu cortex-a57"
1180 " -object memory-backend-ram,id=ram0,size=128M"
1181 " -numa node,memdev=ram0",
1182 &data);
1184 free_test_data(&data);
1188 #ifdef CONFIG_PXB
1189 static void test_acpi_virt_tcg_pxb(void)
1191 test_data data = {
1192 .machine = "virt",
1193 .tcg_only = true,
1194 .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
1195 .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
1196 .ram_start = 0x40000000ULL,
1197 .scan_len = 128ULL * 1024 * 1024,
1200 * While using -cdrom, the cdrom would auto plugged into pxb-pcie,
1201 * the reason is the bus of pxb-pcie is also root bus, it would lead
1202 * to the error only PCI/PCIE bridge could plug onto pxb.
1203 * Therefore,thr cdrom is defined and plugged onto the scsi controller
1204 * to solve the conflicts.
1206 data.variant = ".pxb";
1207 test_acpi_one(" -device pcie-root-port,chassis=1,id=pci.1"
1208 " -device virtio-scsi-pci,id=scsi0,bus=pci.1"
1209 " -drive file="
1210 "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"
1211 "if=none,media=cdrom,id=drive-scsi0-0-0-1,readonly=on"
1212 " -device scsi-cd,bus=scsi0.0,scsi-id=0,"
1213 "drive=drive-scsi0-0-0-1,id=scsi0-0-0-1,bootindex=1"
1214 " -cpu cortex-a57"
1215 " -device pxb-pcie,bus_nr=128",
1216 &data);
1218 free_test_data(&data);
1220 #endif
1222 static void test_acpi_tcg_acpi_hmat(const char *machine)
1224 test_data data;
1226 memset(&data, 0, sizeof(data));
1227 data.machine = machine;
1228 data.variant = ".acpihmat";
1229 test_acpi_one(" -machine hmat=on"
1230 " -smp 2,sockets=2"
1231 " -m 128M,slots=2,maxmem=1G"
1232 " -object memory-backend-ram,size=64M,id=m0"
1233 " -object memory-backend-ram,size=64M,id=m1"
1234 " -numa node,nodeid=0,memdev=m0"
1235 " -numa node,nodeid=1,memdev=m1,initiator=0"
1236 " -numa cpu,node-id=0,socket-id=0"
1237 " -numa cpu,node-id=0,socket-id=1"
1238 " -numa hmat-lb,initiator=0,target=0,hierarchy=memory,"
1239 "data-type=access-latency,latency=1"
1240 " -numa hmat-lb,initiator=0,target=0,hierarchy=memory,"
1241 "data-type=access-bandwidth,bandwidth=65534M"
1242 " -numa hmat-lb,initiator=0,target=1,hierarchy=memory,"
1243 "data-type=access-latency,latency=65534"
1244 " -numa hmat-lb,initiator=0,target=1,hierarchy=memory,"
1245 "data-type=access-bandwidth,bandwidth=32767M"
1246 " -numa hmat-cache,node-id=0,size=10K,level=1,"
1247 "associativity=direct,policy=write-back,line=8"
1248 " -numa hmat-cache,node-id=1,size=10K,level=1,"
1249 "associativity=direct,policy=write-back,line=8",
1250 &data);
1251 free_test_data(&data);
1254 static void test_acpi_q35_tcg_acpi_hmat(void)
1256 test_acpi_tcg_acpi_hmat(MACHINE_Q35);
1259 static void test_acpi_piix4_tcg_acpi_hmat(void)
1261 test_acpi_tcg_acpi_hmat(MACHINE_PC);
1264 static void test_acpi_virt_tcg(void)
1266 test_data data = {
1267 .machine = "virt",
1268 .tcg_only = true,
1269 .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
1270 .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
1271 .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
1272 .ram_start = 0x40000000ULL,
1273 .scan_len = 128ULL * 1024 * 1024,
1276 test_acpi_one("-cpu cortex-a57", &data);
1277 free_test_data(&data);
1279 data.smbios_cpu_max_speed = 2900;
1280 data.smbios_cpu_curr_speed = 2700;
1281 test_acpi_one("-cpu cortex-a57 "
1282 "-smbios type=4,max-speed=2900,current-speed=2700", &data);
1283 free_test_data(&data);
1286 int main(int argc, char *argv[])
1288 const char *arch = qtest_get_arch();
1289 int ret;
1291 g_test_init(&argc, &argv, NULL);
1293 if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
1294 ret = boot_sector_init(disk);
1295 if (ret) {
1296 return ret;
1299 qtest_add_func("acpi/q35/tpm-tis", test_acpi_q35_tcg_tpm_tis);
1300 qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
1301 qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
1302 qtest_add_func("acpi/piix4/pci-hotplug/no_root_hotplug",
1303 test_acpi_piix4_no_root_hotplug);
1304 qtest_add_func("acpi/piix4/pci-hotplug/no_bridge_hotplug",
1305 test_acpi_piix4_no_bridge_hotplug);
1306 qtest_add_func("acpi/piix4/pci-hotplug/off",
1307 test_acpi_piix4_no_acpi_pci_hotplug);
1308 qtest_add_func("acpi/q35", test_acpi_q35_tcg);
1309 qtest_add_func("acpi/q35/bridge", test_acpi_q35_tcg_bridge);
1310 qtest_add_func("acpi/q35/mmio64", test_acpi_q35_tcg_mmio64);
1311 qtest_add_func("acpi/piix4/ipmi", test_acpi_piix4_tcg_ipmi);
1312 qtest_add_func("acpi/q35/ipmi", test_acpi_q35_tcg_ipmi);
1313 qtest_add_func("acpi/piix4/cpuhp", test_acpi_piix4_tcg_cphp);
1314 qtest_add_func("acpi/q35/cpuhp", test_acpi_q35_tcg_cphp);
1315 qtest_add_func("acpi/piix4/memhp", test_acpi_piix4_tcg_memhp);
1316 qtest_add_func("acpi/q35/memhp", test_acpi_q35_tcg_memhp);
1317 qtest_add_func("acpi/piix4/numamem", test_acpi_piix4_tcg_numamem);
1318 qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
1319 qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
1320 qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
1321 qtest_add_func("acpi/piix4/acpihmat", test_acpi_piix4_tcg_acpi_hmat);
1322 qtest_add_func("acpi/q35/acpihmat", test_acpi_q35_tcg_acpi_hmat);
1323 qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
1324 qtest_add_func("acpi/microvm/usb", test_acpi_microvm_usb_tcg);
1325 qtest_add_func("acpi/microvm/rtc", test_acpi_microvm_rtc_tcg);
1326 if (strcmp(arch, "x86_64") == 0) {
1327 qtest_add_func("acpi/microvm/pcie", test_acpi_microvm_pcie_tcg);
1329 } else if (strcmp(arch, "aarch64") == 0) {
1330 qtest_add_func("acpi/virt", test_acpi_virt_tcg);
1331 qtest_add_func("acpi/virt/numamem", test_acpi_virt_tcg_numamem);
1332 qtest_add_func("acpi/virt/memhp", test_acpi_virt_tcg_memhp);
1333 #ifdef CONFIG_PXB
1334 qtest_add_func("acpi/virt/pxb", test_acpi_virt_tcg_pxb);
1335 #endif
1337 ret = g_test_run();
1338 boot_sector_cleanup(disk);
1339 return ret;