Skip to contentSkip to conversation

tests: acpi: add UEFI (ARM) testing support

PATCH Superseded Igor Mammedov 6 participants 44 messages Apr 25, 2019 – May 2, 2019

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v3 cover tests: acpi: add UEFI (ARM) testing support

Changelog:
- from v2:
* rebase on top current master (with UEFI blobs merged)
* added a Makefile rule to include bios-tables-test to aarch64 tests by default into 11/13 (kept Reviewed-bys)
* other trivial fixes and cleanups (see per patch changelogs)

- from v1:
* rebase on top
(1) [PATCH for-4.1 v3 00/12] bundle edk2 platform firmware with QEMU
let me to drop edk2 images and drop Makefile magic to unpack them, Laszlo's series conveniently does it all for me.
* use new path/names for firmware images as supplied by [1]
* reorder patches a bit so that UEFI parts would go after generic changes

Series adds support for ACPI tables located above 4G. It adds 64-bit handling necessary for testing arm/virt board (i.e. might be not complete wrt spec) and uses recently merged UEFI (AVMF) firmware/test disk image which provides an entry point[1] for fetching ACPI tables (RSDP pointer).

Git tree for testing:
https://github.com/imammedo/qemu.git acpi_arm_tests_v3

Ref to previos vesrsion:
[Qemu-devel] [PATCH for 4.1 v2 00/13] tests: acpi: add UEFI (ARM) testing support
https://www.mail-archive.com/[email protected]/msg607564.html

CC Laszlo Ersek <[email protected]>
CC "Michael S. Tsirkin" <[email protected]>
CC Gonglei <[email protected]>
CC Philippe Mathieu-Daudé <[email protected]>
CC Shannon Zhao <[email protected]>
CC Wei Yang <[email protected]>
CC Andrew Jones <[email protected]>
CC Shameer Kolothum <[email protected]>
CC Ben Warren <[email protected]>

Igor Mammedov (13):
tests: acpi: make RSDT test routine handle XSDT
tests: acpi: rename acpi_parse_rsdp_table() into
acpi_fetch_rsdp_table()
tests: acpi: make pointer to RSDP 64bit
tests: acpi: fetch X_DSDT if pointer to DSDT is 0
tests: acpi: skip FACS table if board uses hw reduced ACPI profile
tests: acpi: move boot_sector_init() into x86 tests branch
tests: acpi: add acpi_find_rsdp_address_uefi() helper
tests: acpi: add a way to start tests with UEFI firmware
tests: acpi: ignore SMBIOS tests when UEFI firmware is used
tests: add expected ACPI tables for arm/virt board
tests: acpi: add simple arm/virt testcase
tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for
a specified list of targets
tests: acpi: print error unable to dump ACPI table during rebuild

 tests/acpi-utils.h                      |   5 +-
 tests/Makefile.include                  |   1 +
 tests/acpi-utils.c                      |  58 ++++++++++----
 tests/bios-tables-test.c                | 133 ++++++++++++++++++++++++--------
 tests/data/acpi/rebuild-expected-aml.sh |  23 +++---
 tests/data/acpi/virt/APIC               | Bin 0 -> 168 bytes
 tests/data/acpi/virt/DSDT               | Bin 0 -> 18476 bytes
 tests/data/acpi/virt/FACP               | Bin 0 -> 268 bytes
 tests/data/acpi/virt/GTDT               | Bin 0 -> 96 bytes
 tests/data/acpi/virt/MCFG               | Bin 0 -> 60 bytes
 tests/data/acpi/virt/SPCR               | Bin 0 -> 80 bytes
 tests/vmgenid-test.c                    |   2 +-
 12 files changed, 162 insertions(+), 60 deletions(-)
 create mode 100644 tests/data/acpi/virt/APIC
 create mode 100644 tests/data/acpi/virt/DSDT
 create mode 100644 tests/data/acpi/virt/FACP
 create mode 100644 tests/data/acpi/virt/GTDT
 create mode 100644 tests/data/acpi/virt/MCFG
 create mode 100644 tests/data/acpi/virt/SPCR
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/13 tests: acpi: make RSDT test routine handle XSDT

If RSDP revision is more than 0 fetch table pointed by XSDT and fallback to legacy RSDT table otherwise.

While at it drop unused acpi_get_xsdt_address().

---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0 but it will be used by followup patch to enable testing arm/virt board which uses provides XSDT table.

---
 tests/acpi-utils.h       |  3 +--
 tests/acpi-utils.c       | 14 +-------------
 tests/bios-tables-test.c | 18 +++++++++++++-----
 3 files changed, 15 insertions(+), 20 deletions(-)
tests/acpi-utils.h +1 -2
index ef388bb..8c68201 100644
@@ -46,8 +46,7 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                       const uint8_t *addr_ptr, const char *sig,
                       bool verify_checksum);
tests/acpi-utils.c +1 -13
index cc33b46..9a6d1d3 100644
@@ -51,19 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
     return off;
 }
 
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
-    uint64_t xsdt_physical_address;
-    uint8_t revision = rsdp_table[15 /* Revision offset */];
-
-    /* We must have revision 2 if we're looking for an XSDT pointer */
-    g_assert(revision == 2);
-
-    memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
-    return le64_to_cpu(xsdt_physical_address);
-}
-
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
     uint8_t revision;
 
tests/bios-tables-test.c +13 -5
index a506dcb..24bd102 100644
@@ -107,17 +107,25 @@ static void test_acpi_rsdp_table(test_data *data)
     }
 }
 
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
 {
+    const char *sig = "RSDT";
     AcpiSdtTable rsdt = {};
+    int entry_size = 4;
+    int addr_off = 16 /* RsdtAddress */;
     uint8_t *ent;
 
-    /* read RSDT table */
+    if (data->rsdp_table[15 /* Revision offset */] != 0) {
+        addr_off = 24 /* XsdtAddress */;
+        entry_size = 8;
+        sig = "XSDT";
+    }
+    /* read [RX]SDT table */
     acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
-                     &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+                     &data->rsdp_table[addr_off], sig, true);
 
     /* Load all tables and add to test list directly RSDT referenced tables */
-    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
         AcpiSdtTable ssdt_table = {};
 
         acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
     data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
     test_acpi_rsdp_address(data);
     test_acpi_rsdp_table(data);
-    test_acpi_rsdt_table(data);
+    test_acpi_rxsdt_table(data);
     test_acpi_fadt_table(data);
 
     if (iasl) {
Signature · 1 line
2.7.4
#2 lore raw

Re: [Qemu-devel] [PATCH v3 01/13] tests: acpi: make RSDT test routine handle XSDT

Quoted 4 lines · Igor Mammedov

If RSDP revision is more than 0 fetch table pointed by XSDT and fallback to legacy RSDT table otherwise.

While at it drop unused acpi_get_xsdt_address().

Would it be proper to split this into another patch?

Quoted 18 lines

---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0 but it will be used by followup patch to enable testing arm/virt board which uses provides XSDT table.
---

tests/acpi-utils.h       |  3 +--
tests/acpi-utils.c       | 14 +-------------
tests/bios-tables-test.c | 18 +++++++++++++-----
3 files changed, 15 insertions(+), 20 deletions(-)
tests/acpi-utils.h +0 -0
index ef388bb..8c68201 100644

tests/acpi-utils.h typedef struct { · line 49

Quoted 6 lines
tests/acpi-utils.h +1 -2
@@ -46,8 +46,7 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);

Would you mind giving some hint of this change?

Quoted 73 lines
tests/acpi-utils.h +0 -0
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
                      bool verify_checksum);
tests/acpi-utils.c +1 -13
index cc33b46..9a6d1d3 100644
@@ -51,19 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
    return off;
 }
 
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
-    uint64_t xsdt_physical_address;
-    uint8_t revision = rsdp_table[15 /* Revision offset */];
-
-    /* We must have revision 2 if we're looking for an XSDT pointer */
-    g_assert(revision == 2);
-
-    memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
-    return le64_to_cpu(xsdt_physical_address);
-}
-
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
    uint8_t revision;
 
tests/bios-tables-test.c +13 -5
index a506dcb..24bd102 100644
@@ -107,17 +107,25 @@ static void test_acpi_rsdp_table(test_data *data)
    }
 }
 
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
 {
+    const char *sig = "RSDT";
    AcpiSdtTable rsdt = {};
+    int entry_size = 4;
+    int addr_off = 16 /* RsdtAddress */;
    uint8_t *ent;
 
-    /* read RSDT table */
+    if (data->rsdp_table[15 /* Revision offset */] != 0) {
+        addr_off = 24 /* XsdtAddress */;
+        entry_size = 8;
+        sig = "XSDT";
+    }
+    /* read [RX]SDT table */
    acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
-                     &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+                     &data->rsdp_table[addr_off], sig, true);
 
    /* Load all tables and add to test list directly RSDT referenced tables */
-    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
        AcpiSdtTable ssdt_table = {};
 
        acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
    test_acpi_rsdp_address(data);
    test_acpi_rsdp_table(data);
-    test_acpi_rsdt_table(data);
+    test_acpi_rxsdt_table(data);
    test_acpi_fadt_table(data);
 
    if (iasl) {
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#3 lore raw

Re: [Qemu-devel] [PATCH v3 01/13] tests: acpi: make RSDT test routine handle XSDT

Quoted 7 lines · On Thu, 25 Apr 2019 15:22:56 +0800 Wei Yang <[email protected]>…
Quoted 4 lines · Igor Mammedov

If RSDP revision is more than 0 fetch table pointed by XSDT and fallback to legacy RSDT table otherwise.

While at it drop unused acpi_get_xsdt_address().

Would it be proper to split this into another patch?

it should be fine to remove code that's being replaced by new one which substitutes the former within the same patch.
but if you insist I can split it into another patch.

Quoted 19 lines
Quoted 19 lines

---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0 but it will be used by followup patch to enable testing arm/virt board which uses provides XSDT table.
---

tests/acpi-utils.h       |  3 +--
tests/acpi-utils.c       | 14 +-------------
tests/bios-tables-test.c | 18 +++++++++++++-----
3 files changed, 15 insertions(+), 20 deletions(-)
tests/acpi-utils.h +0 -0
index ef388bb..8c68201 100644
@@ -46,8 +46,7 @@ typedef struct {
 
Quoted 7 lines

tests/acpi-utils.h typedef struct { · line 49

Quoted 5 lines
tests/acpi-utils.h +1 -2
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);  

Would you mind giving some hint of this change?

thanks for spotting it. IT certainly doesn't belong to this patch. I'll need to recheck if supporting 64bit address fields is done properly and find another place where to move this hunk.

Quoted 75 lines
Quoted 74 lines
tests/acpi-utils.h +0 -0
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
                      bool verify_checksum);
tests/acpi-utils.c +1 -13
index cc33b46..9a6d1d3 100644
@@ -51,19 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
    return off;
 }
 
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
-    uint64_t xsdt_physical_address;
-    uint8_t revision = rsdp_table[15 /* Revision offset */];
-
-    /* We must have revision 2 if we're looking for an XSDT pointer */
-    g_assert(revision == 2);
-
-    memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
-    return le64_to_cpu(xsdt_physical_address);
-}
-
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
    uint8_t revision;
 
tests/bios-tables-test.c +13 -5
index a506dcb..24bd102 100644
@@ -107,17 +107,25 @@ static void test_acpi_rsdp_table(test_data *data)
    }
 }
 
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
 {
+    const char *sig = "RSDT";
    AcpiSdtTable rsdt = {};
+    int entry_size = 4;
+    int addr_off = 16 /* RsdtAddress */;
    uint8_t *ent;
 
-    /* read RSDT table */
+    if (data->rsdp_table[15 /* Revision offset */] != 0) {
+        addr_off = 24 /* XsdtAddress */;
+        entry_size = 8;
+        sig = "XSDT";
+    }
+    /* read [RX]SDT table */
    acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
-                     &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+                     &data->rsdp_table[addr_off], sig, true);
 
    /* Load all tables and add to test list directly RSDT referenced tables */
-    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
        AcpiSdtTable ssdt_table = {};
 
        acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
    test_acpi_rsdp_address(data);
    test_acpi_rsdp_table(data);
-    test_acpi_rsdt_table(data);
+    test_acpi_rxsdt_table(data);
    test_acpi_fadt_table(data);
 
    if (iasl) {
Signature · 1 line
2.7.4  
#4 lore raw

Re: [Qemu-devel] [PATCH v3 01/13] tests: acpi: make RSDT test routine handle XSDT

Quoted 7 lines · Igor Mammedov
Quoted 4 lines · On Thu, 25 Apr 2019 15:22:56 +0800 Wei Yang <[email protected]>…
Quoted 3 lines · Igor Mammedov

If RSDP revision is more than 0 fetch table pointed by XSDT and fallback to legacy RSDT table otherwise.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

While at it drop unused acpi_get_xsdt_address().

Would it be proper to split this into another patch?

it should be fine to remove code that's being replaced by new one which substitutes the former within the same patch.
but if you insist I can split it into another patch.

I am fine with this included.

Quoted 106 lines
Quoted 20 lines
Quoted 20 lines

---
PS:
it doesn't affect existing pc/q35 machines as they use RSDP.revision == 0 but it will be used by followup patch to enable testing arm/virt board which uses provides XSDT table.
---

tests/acpi-utils.h       |  3 +--
tests/acpi-utils.c       | 14 +-------------
tests/bios-tables-test.c | 18 +++++++++++++-----
3 files changed, 15 insertions(+), 20 deletions(-)
tests/acpi-utils.h +0 -0
index ef388bb..8c68201 100644
@@ -46,8 +46,7 @@ typedef struct {
 
Quoted 7 lines

tests/acpi-utils.h typedef struct { · line 49

Quoted 5 lines
tests/acpi-utils.h +1 -2
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table);
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table);
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);  

Would you mind giving some hint of this change?

thanks for spotting it. IT certainly doesn't belong to this patch. I'll need to recheck if supporting 64bit address fields is done properly and find another place where to move this hunk.

Quoted 75 lines
Quoted 74 lines
tests/acpi-utils.h +0 -0
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
                      bool verify_checksum);
tests/acpi-utils.c +1 -13
index cc33b46..9a6d1d3 100644
@@ -51,19 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
    return off;
 }
 
-uint64_t acpi_get_xsdt_address(uint8_t *rsdp_table)
-{
-    uint64_t xsdt_physical_address;
-    uint8_t revision = rsdp_table[15 /* Revision offset */];
-
-    /* We must have revision 2 if we're looking for an XSDT pointer */
-    g_assert(revision == 2);
-
-    memcpy(&xsdt_physical_address, &rsdp_table[24 /* XsdtAddress offset */], 8);
-    return le64_to_cpu(xsdt_physical_address);
-}
-
-void acpi_parse_rsdp_table(QTestState *qts, uint32_t addr, uint8_t *rsdp_table)
+void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
    uint8_t revision;
 
tests/bios-tables-test.c +13 -5
index a506dcb..24bd102 100644
@@ -107,17 +107,25 @@ static void test_acpi_rsdp_table(test_data *data)
    }
 }
 
-static void test_acpi_rsdt_table(test_data *data)
+static void test_acpi_rxsdt_table(test_data *data)
 {
+    const char *sig = "RSDT";
    AcpiSdtTable rsdt = {};
+    int entry_size = 4;
+    int addr_off = 16 /* RsdtAddress */;
    uint8_t *ent;
 
-    /* read RSDT table */
+    if (data->rsdp_table[15 /* Revision offset */] != 0) {
+        addr_off = 24 /* XsdtAddress */;
+        entry_size = 8;
+        sig = "XSDT";
+    }
+    /* read [RX]SDT table */
    acpi_fetch_table(data->qts, &rsdt.aml, &rsdt.aml_len,
-                     &data->rsdp_table[16 /* RsdtAddress */], "RSDT", true);
+                     &data->rsdp_table[addr_off], sig, true);
 
    /* Load all tables and add to test list directly RSDT referenced tables */
-    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, 4 /* Entry size */) {
+    ACPI_FOREACH_RSDT_ENTRY(rsdt.aml, rsdt.aml_len, ent, entry_size) {
        AcpiSdtTable ssdt_table = {};
 
        acpi_fetch_table(data->qts, &ssdt_table.aml, &ssdt_table.aml_len, ent,
@@ -521,7 +529,7 @@ static void test_acpi_one(const char *params, test_data *data)
    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
    test_acpi_rsdp_address(data);
    test_acpi_rsdp_table(data);
-    test_acpi_rsdt_table(data);
+    test_acpi_rxsdt_table(data);
    test_acpi_fadt_table(data);
 
    if (iasl) {
Signature · 1 line
2.7.4  
Signature · 2 lines
Wei Yang
Help you, Help me
#5 lore raw

PATCH v3 2/13 tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

In reply to Igor Mammedov

so name would reflect what the function does

---
 tests/acpi-utils.h       | 2 +-
 tests/acpi-utils.c       | 2 +-
 tests/bios-tables-test.c | 2 +-
 tests/vmgenid-test.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tests/acpi-utils.h +1 -1
index 8c68201..75f78f2 100644
@@ -46,7 +46,7 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                       const uint8_t *addr_ptr, const char *sig,
                       bool verify_checksum);
tests/acpi-utils.c +1 -1
index 9a6d1d3..2dd4fe0 100644
@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
     return off;
 }
 
-void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
     uint8_t revision;
 
tests/bios-tables-test.c +1 -1
index 24bd102..2ee044c 100644
@@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
     uint8_t *rsdp_table = data->rsdp_table, revision;
     uint32_t addr = data->rsdp_addr;
 
-    acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
+    acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
     revision = rsdp_table[15 /* Revision offset */];
 
     switch (revision) {
tests/vmgenid-test.c +1 -1
index ae38ee5..f400184 100644
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
     g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
 
 
-    acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
+    acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
     acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
                      "RSDT", true);
 
Signature · 1 line
2.7.4
Reviewed-by on v3 2/13
#6 lore raw

Re: [Qemu-devel] [PATCH v3 02/13] tests: acpi: rename acpi_parse_rsdp_table() into acpi_fetch_rsdp_table()

Quoted 4 lines · Igor Mammedov

so name would reflect what the function does

Quoted 61 lines

---

tests/acpi-utils.h       | 2 +-
tests/acpi-utils.c       | 2 +-
tests/bios-tables-test.c | 2 +-
tests/vmgenid-test.c     | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
tests/acpi-utils.h +1 -1
index 8c68201..75f78f2 100644
@@ -46,7 +46,7 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
-void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
                      bool verify_checksum);
tests/acpi-utils.c +1 -1
index 9a6d1d3..2dd4fe0 100644
@@ -51,7 +51,7 @@ uint32_t acpi_find_rsdp_address(QTestState *qts)
    return off;
 }
 
-void acpi_parse_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
+void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table)
 {
    uint8_t revision;
 
tests/bios-tables-test.c +1 -1
index 24bd102..2ee044c 100644
@@ -89,7 +89,7 @@ static void test_acpi_rsdp_table(test_data *data)
    uint8_t *rsdp_table = data->rsdp_table, revision;
    uint32_t addr = data->rsdp_addr;
 
-    acpi_parse_rsdp_table(data->qts, addr, rsdp_table);
+    acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
    revision = rsdp_table[15 /* Revision offset */];
 
    switch (revision) {
tests/vmgenid-test.c +1 -1
index ae38ee5..f400184 100644
@@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(QTestState *qts)
    g_assert_cmphex(rsdp_offset, <, RSDP_ADDR_INVALID);
 
 
-    acpi_parse_rsdp_table(qts, rsdp_offset, rsdp_table);
+    acpi_fetch_rsdp_table(qts, rsdp_offset, rsdp_table);
    acpi_fetch_table(qts, &rsdt, &rsdt_len, &rsdp_table[16 /* RsdtAddress */],
                     "RSDT", true);
 
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#7 lore raw

PATCH v3 3/13 tests: acpi: make pointer to RSDP 64bit

In reply to Igor Mammedov

In case of UEFI, RSDP doesn't have to be located in lowmem, it could be placed at any address. Make sure that test won't break if it is placed above the first 4Gb of address space.

PS:
While at it cleanup some local variables as we don't really need them.

---
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)

---
 tests/bios-tables-test.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
tests/bios-tables-test.c +4 -6
index 2ee044c..c29dcf4 100644
@@ -26,7 +26,7 @@
 typedef struct {
     const char *machine;
     const char *variant;
-    uint32_t rsdp_addr;
+    uint64_t rsdp_addr;
     uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
     GArray *tables;
     uint32_t smbios_ep_addr;
@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
 
 static void test_acpi_rsdp_table(test_data *data)
 {
-    uint8_t *rsdp_table = data->rsdp_table, revision;
-    uint32_t addr = data->rsdp_addr;
+    uint8_t *rsdp_table = data->rsdp_table;
 
-    acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
-    revision = rsdp_table[15 /* Revision offset */];
+    acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);
 
-    switch (revision) {
+    switch (rsdp_table[15 /* Revision offset */]) {
     case 0: /* ACPI 1.0 RSDP */
         /* With rev 1, checksum is only for the first 20 bytes */
         g_assert(!acpi_calc_checksum(rsdp_table,  20));
Signature · 1 line
2.7.4
#8 lore raw

Re: [Qemu-devel] [PATCH v3 03/13] tests: acpi: make pointer to RSDP 64bit

Quoted 31 lines · Igor Mammedov

In case of UEFI, RSDP doesn't have to be located in lowmem, it could be placed at any address. Make sure that test won't break if it is placed above the first 4Gb of address space.

PS:
While at it cleanup some local variables as we don't really need them.

---
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)
---
tests/bios-tables-test.c | 10 ++++------

1 file changed, 4 insertions(+), 6 deletions(-)
tests/bios-tables-test.c +1 -1
index 2ee044c..c29dcf4 100644
@@ -26,7 +26,7 @@
 typedef struct {
    const char *machine;
    const char *variant;
-    uint32_t rsdp_addr;
+    uint64_t rsdp_addr;
    uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
    GArray *tables;
    uint32_t smbios_ep_addr;

tests/bios-tables-test.c static void test_acpi_rsdp_address(test_data *data) · line 91

Quoted 10 lines
tests/bios-tables-test.c +2 -4
@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
 
 static void test_acpi_rsdp_table(test_data *data)
 {
-    uint8_t *rsdp_table = data->rsdp_table, revision;
-    uint32_t addr = data->rsdp_addr;
+    uint8_t *rsdp_table = data->rsdp_table;
 
-    acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
-    revision = rsdp_table[15 /* Revision offset */];
+    acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);

Ok, I think this is the reason you change the second parameter from uint32_t to uint64_t in 1st patch.

Maybe we need to move that on to this one?

Quoted 8 lines
tests/bios-tables-test.c +1 -1
-    switch (revision) {
+    switch (rsdp_table[15 /* Revision offset */]) {
    case 0: /* ACPI 1.0 RSDP */
        /* With rev 1, checksum is only for the first 20 bytes */
        g_assert(!acpi_calc_checksum(rsdp_table,  20));
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#9 lore raw

Re: [Qemu-devel] [PATCH v3 03/13] tests: acpi: make pointer to RSDP 64bit

Quoted 39 lines · On Thu, 25 Apr 2019 15:31:42 +0800 Wei Yang <[email protected]>…
Quoted 38 lines · Igor Mammedov

In case of UEFI, RSDP doesn't have to be located in lowmem, it could be placed at any address. Make sure that test won't break if it is placed above the first 4Gb of address space.

PS:
While at it cleanup some local variables as we don't really need them.

---
v2:
- s/In case of UEFI/In case of UEFI,/ (Laszlo Ersek <[email protected]>)
---
tests/bios-tables-test.c | 10 ++++------

1 file changed, 4 insertions(+), 6 deletions(-)
tests/bios-tables-test.c +2 -3
index 2ee044c..c29dcf4 100644
@@ -26,7 +26,7 @@
 typedef struct {
    const char *machine;
    const char *variant;
-    uint32_t rsdp_addr;
+    uint64_t rsdp_addr;
    uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
    GArray *tables;
    uint32_t smbios_ep_addr;
@@ -86,13 +86,11 @@ static void test_acpi_rsdp_address(test_data *data)
 
 static void test_acpi_rsdp_table(test_data *data)
 {
-    uint8_t *rsdp_table = data->rsdp_table, revision;
-    uint32_t addr = data->rsdp_addr;
+    uint8_t *rsdp_table = data->rsdp_table;
 
Quoted 8 lines

tests/bios-tables-test.c static void test_acpi_rsdp_address(test_data *data) · line 91

Quoted 3 lines
tests/bios-tables-test.c +1 -2
-    acpi_fetch_rsdp_table(data->qts, addr, rsdp_table);
-    revision = rsdp_table[15 /* Revision offset */];
+    acpi_fetch_rsdp_table(data->qts, data->rsdp_addr, rsdp_table);  

Ok, I think this is the reason you change the second parameter from uint32_t to uint64_t in 1st patch.

Maybe we need to move that on to this one?

Sure.
There is one additional path to make 64-bit table pointers support a bit more complete. I'll respin series once travis build passes.

Quoted 9 lines
Quoted 8 lines
tests/bios-tables-test.c +1 -2
-    switch (revision) {
+    switch (rsdp_table[15 /* Revision offset */]) {
    case 0: /* ACPI 1.0 RSDP */
        /* With rev 1, checksum is only for the first 20 bytes */
        g_assert(!acpi_calc_checksum(rsdp_table,  20));
-- 

2.7.4

#10 lore raw

PATCH v3 4/13 tests: acpi: fetch X_DSDT if pointer to DSDT is 0

In reply to Igor Mammedov

that way it would be possible to test a DSDT pointed by 64bit X_DSDT field in FADT.

PS:
it will allow to enable testing arm/virt board, which sets only newer X_DSDT field.

---
v2:
add 'val = le32_to_cpu(val)' even if it doesn't necessary it works as reminder that value copied from table is in little-endian format (Philippe Mathieu-Daudé <[email protected]>)

---
 tests/bios-tables-test.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +8 -1
index c29dcf4..ed62a17 100644
@@ -140,6 +140,8 @@ static void test_acpi_fadt_table(test_data *data)
     AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
     uint8_t *fadt_aml = table.aml;
     uint32_t fadt_len = table.aml_len;
+    uint32_t val;
+    int dsdt_offset = 40 /* DSDT */;
 
     g_assert(compare_signature(&table, "FACP"));
 
@@ -148,8 +150,13 @@ static void test_acpi_fadt_table(test_data *data)
                      fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
     g_array_append_val(data->tables, table);
 
+    memcpy(&val, fadt_aml + dsdt_offset, 4);
+    val = le32_to_cpu(val);
+    if (!val) {
+        dsdt_offset = 140 /* X_DSDT */;
+    }
     acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
-                     fadt_aml + 40 /* DSDT */, "DSDT", true);
+                     fadt_aml + dsdt_offset, "DSDT", true);
     g_array_append_val(data->tables, table);
 
     memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
Signature · 1 line
2.7.4
Reviewed-by on v3 4/13
#11 lore raw

Re: [Qemu-devel] [PATCH v3 04/13] tests: acpi: fetch X_DSDT if pointer to DSDT is 0

Quoted 9 lines · Igor Mammedov

that way it would be possible to test a DSDT pointed by 64bit X_DSDT field in FADT.

PS:
it will allow to enable testing arm/virt board, which sets only newer X_DSDT field.

Quoted 39 lines

---
v2:
add 'val = le32_to_cpu(val)' even if it doesn't necessary it works as reminder that value copied from table is in little-endian format (Philippe Mathieu-Daudé <[email protected]>)
---
tests/bios-tables-test.c | 9 ++++++++-

1 file changed, 8 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +8 -1
index c29dcf4..ed62a17 100644
@@ -140,6 +140,8 @@ static void test_acpi_fadt_table(test_data *data)
    AcpiSdtTable table = g_array_index(data->tables, typeof(table), 0);
    uint8_t *fadt_aml = table.aml;
    uint32_t fadt_len = table.aml_len;
+    uint32_t val;
+    int dsdt_offset = 40 /* DSDT */;
 
    g_assert(compare_signature(&table, "FACP"));
 
@@ -148,8 +150,13 @@ static void test_acpi_fadt_table(test_data *data)
                     fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
    g_array_append_val(data->tables, table);
 
+    memcpy(&val, fadt_aml + dsdt_offset, 4);
+    val = le32_to_cpu(val);
+    if (!val) {
+        dsdt_offset = 140 /* X_DSDT */;
+    }
    acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
-                     fadt_aml + 40 /* DSDT */, "DSDT", true);
+                     fadt_aml + dsdt_offset, "DSDT", true);
    g_array_append_val(data->tables, table);
 
    memset(fadt_aml + 36, 0, 4); /* sanitize FIRMWARE_CTRL ptr */
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#12 lore raw

PATCH v3 5/13 tests: acpi: skip FACS table if board uses hw reduced ACPI profile

In reply to Igor Mammedov

If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch FACS as it's not provided by the board.

---
 tests/bios-tables-test.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +7 -3
index ed62a17..e944d00 100644
@@ -146,9 +146,13 @@ static void test_acpi_fadt_table(test_data *data)
     g_assert(compare_signature(&table, "FACP"));
 
     /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
-    acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
-                     fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
-    g_array_append_val(data->tables, table);
+    memcpy(&val, fadt_aml + 112 /* Flags */, 4);
+    val = le32_to_cpu(val);
+    if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
+        acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
+                         fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
+        g_array_append_val(data->tables, table);
+    }
 
     memcpy(&val, fadt_aml + dsdt_offset, 4);
     val = le32_to_cpu(val);
Signature · 1 line
2.7.4
Reviewed-by on v3 5/13
#13 lore raw

Re: [Qemu-devel] [PATCH v3 05/13] tests: acpi: skip FACS table if board uses hw reduced ACPI profile

Quoted 5 lines · Igor Mammedov

If FADT has HW_REDUCED_ACPI flag set, do not attempt to fetch FACS as it's not provided by the board.

Quoted 27 lines

---
tests/bios-tables-test.c | 10 +++++++---

1 file changed, 7 insertions(+), 3 deletions(-)
tests/bios-tables-test.c +7 -3
index ed62a17..e944d00 100644
@@ -146,9 +146,13 @@ static void test_acpi_fadt_table(test_data *data)
    g_assert(compare_signature(&table, "FACP"));
 
    /* Since DSDT/FACS isn't in RSDT, add them to ASL test list manually */
-    acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
-                     fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
-    g_array_append_val(data->tables, table);
+    memcpy(&val, fadt_aml + 112 /* Flags */, 4);
+    val = le32_to_cpu(val);
+    if (!(val & 1UL << 20 /* HW_REDUCED_ACPI */)) {
+        acpi_fetch_table(data->qts, &table.aml, &table.aml_len,
+                         fadt_aml + 36 /* FIRMWARE_CTRL */, "FACS", false);
+        g_array_append_val(data->tables, table);
+    }
 
    memcpy(&val, fadt_aml + dsdt_offset, 4);
    val = le32_to_cpu(val);
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#14 lore raw

PATCH v3 6/13 tests: acpi: move boot_sector_init() into x86 tests branch

In reply to Igor Mammedov

boot_sector_init() won't be used by arm/virt board, so move it from global scope to x86 branch that uses it.

---
v3:
- fix checkpatch errors triggered by moved old code (ident/space/braces)

---
 tests/bios-tables-test.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
tests/bios-tables-test.c +5 -4
index e944d00..5790ee4 100644
@@ -786,13 +786,14 @@ int main(int argc, char *argv[])
     const char *arch = qtest_get_arch();
     int ret;
 
-    ret = boot_sector_init(disk);
-    if(ret)
-        return ret;
-
     g_test_init(&argc, &argv, NULL);
 
     if (strcmp(arch, "i386") == 0 || strcmp(arch, "x86_64") == 0) {
+        ret = boot_sector_init(disk);
+        if (ret) {
+            return ret;
+        }
+
         qtest_add_func("acpi/piix4", test_acpi_piix4_tcg);
         qtest_add_func("acpi/piix4/bridge", test_acpi_piix4_tcg_bridge);
         qtest_add_func("acpi/q35", test_acpi_q35_tcg);
Signature · 1 line
2.7.4
#15 lore raw

PATCH v3 7/13 tests: acpi: add acpi_find_rsdp_address_uefi() helper

In reply to Igor Mammedov

introduce UEFI specific counterpart to acpi_find_rsdp_address() that will help to find RSDP address when [OA]VMF is used as firmware. It requires guest firmware or other guest app to place 1Mb aligned UefiTestSupport structure (defined in this patch) in RAM with UefiTestSupport::signature_guid set to AB87A6B1-2034-BDA0-71BD-375007757785

---
v3:
* fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
v2:
* Laszlo Ersek <[email protected]>
- s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
- use GUID_SIZE instead of opencodding size
- make AcpiTestSupportGuid const
- s/TCI/TCG/

---
 tests/acpi-utils.h |  2 ++
 tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
tests/acpi-utils.h +2 -0
index 75f78f2..dcfa721 100644
@@ -46,6 +46,8 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+                                     uint64_t size);
 void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                       const uint8_t *addr_ptr, const char *sig,
tests/acpi-utils.c +44 -0

47 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v3 7/13
#16 lore raw

Re: [Qemu-devel] [PATCH v3 07/13] tests: acpi: add acpi_find_rsdp_address_uefi() helper

Quoted 6 lines · Igor Mammedov

introduce UEFI specific counterpart to acpi_find_rsdp_address() that will help to find RSDP address when [OA]VMF is used as firmware. It requires guest firmware or other guest app to place 1Mb aligned UefiTestSupport structure (defined in this patch) in RAM with UefiTestSupport::signature_guid set to AB87A6B1-2034-BDA0-71BD-375007757785

Just curious about where we get this signature? Randomly generated?

Quoted 3 lines
Quoted 81 lines

---
v3:
* fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
v2:
* Laszlo Ersek <[email protected]>
- s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
- use GUID_SIZE instead of opencodding size
- make AcpiTestSupportGuid const
- s/TCI/TCG/
---
tests/acpi-utils.h | 2 ++
tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++

2 files changed, 46 insertions(+)
tests/acpi-utils.h +2 -0
index 75f78f2..dcfa721 100644
@@ -46,6 +46,8 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+                                     uint64_t size);
 void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
tests/acpi-utils.c +44 -0
index 2dd4fe0..197af82 100644
@@ -99,3 +99,47 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
        g_assert(!acpi_calc_checksum(*aml, *aml_len));
    }
 }
+
+#define GUID_SIZE 16
+static const uint8_t AcpiTestSupportGuid[GUID_SIZE] = {
+       0xb1, 0xa6, 0x87, 0xab,
+       0x34, 0x20,
+       0xa0, 0xbd,
+       0x71, 0xbd, 0x37, 0x50, 0x07, 0x75, 0x77, 0x85 };
+
+typedef struct {
+    uint8_t signature_guid[GUID_SIZE];
+    uint64_t rsdp10;
+    uint64_t rsdp20;
+} __attribute__((packed)) UefiTestSupport;
+
+/* Wait at most 600 seconds (test is slow with TCG and --enable-debug) */
+#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
+#define TEST_CYCLES MAX((600 * G_USEC_PER_SEC / TEST_DELAY), 1)
+#define MB 0x100000ULL
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+                                     uint64_t size)
+{
+    int i, j;
+    uint8_t data[GUID_SIZE];
+
+    for (i = 0; i < TEST_CYCLES; ++i) {
+        for (j = 0; j < size / MB; j++) {
+            /* look for GUID at every 1Mb block */
+            uint64_t addr = start + j * MB;
+
+            qtest_memread(qts, addr, data, sizeof(data));
+            if (!memcmp(AcpiTestSupportGuid, data, sizeof(data))) {
+                UefiTestSupport ret;
+
+                qtest_memread(qts, addr, &ret, sizeof(ret));
+                ret.rsdp10 = le64_to_cpu(ret.rsdp10);
+                ret.rsdp20 = le64_to_cpu(ret.rsdp20);
+                return ret.rsdp20 ? ret.rsdp20 : ret.rsdp10;
+            }
+        }
+        g_usleep(TEST_DELAY);
+    }
+    g_assert_not_reached();
+    return 0;
+}
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#17 lore raw

Re: [Qemu-devel] [PATCH v3 07/13] tests: acpi: add acpi_find_rsdp_address_uefi() helper

Quoted 9 lines · On Thu, 25 Apr 2019 16:00:46 +0800 Wei Yang <[email protected]>…
Quoted 6 lines · Igor Mammedov

introduce UEFI specific counterpart to acpi_find_rsdp_address() that will help to find RSDP address when [OA]VMF is used as firmware. It requires guest firmware or other guest app to place 1Mb aligned UefiTestSupport structure (defined in this patch) in RAM with UefiTestSupport::signature_guid set to AB87A6B1-2034-BDA0-71BD-375007757785

Just curious about where we get this signature? Randomly generated?

something like this, see 09a274d82f, I'll add commit id here for reference

Quoted 89 lines
Quoted 4 lines
Quoted 81 lines

---
v3:
* fix checkpatch error (separate opening brace from values in AcpiTestSupportGuid initializer)
v2:
* Laszlo Ersek <[email protected]>
- s/uefi_find_rsdp_addr/acpi_find_rsdp_address_uefi/
- use GUID_SIZE instead of opencodding size
- make AcpiTestSupportGuid const
- s/TCI/TCG/
---
tests/acpi-utils.h | 2 ++
tests/acpi-utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++++

2 files changed, 46 insertions(+)
tests/acpi-utils.h +2 -0
index 75f78f2..dcfa721 100644
@@ -46,6 +46,8 @@ typedef struct {
 
 uint8_t acpi_calc_checksum(const uint8_t *data, int len);
 uint32_t acpi_find_rsdp_address(QTestState *qts);
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+                                     uint64_t size);
 void acpi_fetch_rsdp_table(QTestState *qts, uint64_t addr, uint8_t *rsdp_table);
 void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
                      const uint8_t *addr_ptr, const char *sig,
tests/acpi-utils.c +44 -0
index 2dd4fe0..197af82 100644
@@ -99,3 +99,47 @@ void acpi_fetch_table(QTestState *qts, uint8_t **aml, uint32_t *aml_len,
        g_assert(!acpi_calc_checksum(*aml, *aml_len));
    }
 }
+
+#define GUID_SIZE 16
+static const uint8_t AcpiTestSupportGuid[GUID_SIZE] = {
+       0xb1, 0xa6, 0x87, 0xab,
+       0x34, 0x20,
+       0xa0, 0xbd,
+       0x71, 0xbd, 0x37, 0x50, 0x07, 0x75, 0x77, 0x85 };
+
+typedef struct {
+    uint8_t signature_guid[GUID_SIZE];
+    uint64_t rsdp10;
+    uint64_t rsdp20;
+} __attribute__((packed)) UefiTestSupport;
+
+/* Wait at most 600 seconds (test is slow with TCG and --enable-debug) */
+#define TEST_DELAY (1 * G_USEC_PER_SEC / 10)
+#define TEST_CYCLES MAX((600 * G_USEC_PER_SEC / TEST_DELAY), 1)
+#define MB 0x100000ULL
+uint64_t acpi_find_rsdp_address_uefi(QTestState *qts, uint64_t start,
+                                     uint64_t size)
+{
+    int i, j;
+    uint8_t data[GUID_SIZE];
+
+    for (i = 0; i < TEST_CYCLES; ++i) {
+        for (j = 0; j < size / MB; j++) {
+            /* look for GUID at every 1Mb block */
+            uint64_t addr = start + j * MB;
+
+            qtest_memread(qts, addr, data, sizeof(data));
+            if (!memcmp(AcpiTestSupportGuid, data, sizeof(data))) {
+                UefiTestSupport ret;
+
+                qtest_memread(qts, addr, &ret, sizeof(ret));
+                ret.rsdp10 = le64_to_cpu(ret.rsdp10);
+                ret.rsdp20 = le64_to_cpu(ret.rsdp20);
+                return ret.rsdp20 ? ret.rsdp20 : ret.rsdp10;
+            }
+        }
+        g_usleep(TEST_DELAY);
+    }
+    g_assert_not_reached();
+    return 0;
+}
Signature · 1 line
2.7.4  
#18 lore raw

PATCH v3 8/13 tests: acpi: add a way to start tests with UEFI firmware

In reply to Igor Mammedov

For testcase to use UEFI firmware, one needs to provide and specify firmwarei and varstore blobs names in test_data { uefi_fl1, uefi_fl2) } fields respectively and RAM start address plus size where to look for test structure signature. Additionally testcase should specify bootable cdrom image uefi-boot-images EFI test utility.

---
v3:
* drop data_dir prefix and firmware will come from pc-bios directly
* add cdrom option so test could use it for providing boot cdrom image
* add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
v2:
* move RAM start address and size to test_data, as it could differ between boards (and even versions)

---
 tests/bios-tables-test.c | 44 ++++++++++++++++++++++++++++++++++----------
 1 file changed, 34 insertions(+), 10 deletions(-)
tests/bios-tables-test.c +34 -10
index 5790ee4..0f24540 100644
@@ -26,6 +26,11 @@
 typedef struct {
     const char *machine;
     const char *variant;
+    const char *uefi_fl1;
+    const char *uefi_fl2;
+    const char *cd;
+    const uint64_t ram_start;
+    const uint64_t scan_len;
     uint64_t rsdp_addr;
     uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
     GArray *tables;
@@ -522,21 +527,40 @@ static void test_smbios_structs(test_data *data)
 static void test_acpi_one(const char *params, test_data *data)
 {
     char *args;
-
-    /* Disable kernel irqchip to be able to override apic irq0. */
-    args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
-                           "-net none -display none %s "
-                           "-drive id=hd0,if=none,file=%s,format=raw "
-                           "-device ide-hd,drive=hd0 ",
-                           data->machine, "kvm:tcg",
-                           params ? params : "", disk);
+    bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
+
+    if (use_uefi) {
+        /*
+         * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
+         * when arm/virt boad starts to support it.
+         */
+        args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
+            "-drive if=pflash,format=raw,file=%s,readonly "
+            "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
+            data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
+            data->cd, params ? params : "");
+
+    } else {
+        /* Disable kernel irqchip to be able to override apic irq0. */
+        args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+            "-net none -display none %s "
+            "-drive id=hd0,if=none,file=%s,format=raw "
+            "-device ide-hd,drive=hd0 ",
+             data->machine, "kvm:tcg", params ? params : "", disk);
+    }
 
     data->qts = qtest_init(args);
 
-    boot_sector_test(data->qts);
+    if (use_uefi) {
+        g_assert(data->scan_len);
+        data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
+            data->ram_start, data->scan_len);
+    } else {
+        boot_sector_test(data->qts);
+        test_acpi_rsdp_address(data);
+    }
 
     data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
-    test_acpi_rsdp_address(data);
     test_acpi_rsdp_table(data);
     test_acpi_rxsdt_table(data);
     test_acpi_fadt_table(data);
Signature · 1 line
2.7.4
#19 lore raw

Re: [Qemu-devel] [PATCH v3 08/13] tests: acpi: add a way to start tests with UEFI firmware

Quoted 2 lines · Igor Mammedov

For testcase to use UEFI firmware, one needs to provide and specify firmwarei and varstore blobs names in test_data { uefi_fl1, uefi_fl2) }

^
a typo here?

Quoted 65 lines

fields respectively and RAM start address plus size where to look for test structure signature. Additionally testcase should specify bootable cdrom image uefi-boot-images EFI test utility.

---
v3:
* drop data_dir prefix and firmware will come from pc-bios directly
* add cdrom option so test could use it for providing boot cdrom image
* add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
v2:
* move RAM start address and size to test_data, as it could differ between boards (and even versions)
---
tests/bios-tables-test.c | 44 ++++++++++++++++++++++++++++++++++----------

1 file changed, 34 insertions(+), 10 deletions(-)
tests/bios-tables-test.c +24 -8
index 5790ee4..0f24540 100644
@@ -26,6 +26,11 @@
 typedef struct {
    const char *machine;
    const char *variant;
+    const char *uefi_fl1;
+    const char *uefi_fl2;
+    const char *cd;
+    const uint64_t ram_start;
+    const uint64_t scan_len;
    uint64_t rsdp_addr;
    uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
    GArray *tables;
@@ -522,21 +527,40 @@ static void test_smbios_structs(test_data *data)
 static void test_acpi_one(const char *params, test_data *data)
 {
    char *args;
-
-    /* Disable kernel irqchip to be able to override apic irq0. */
-    args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
-                           "-net none -display none %s "
-                           "-drive id=hd0,if=none,file=%s,format=raw "
-                           "-device ide-hd,drive=hd0 ",
-                           data->machine, "kvm:tcg",
-                           params ? params : "", disk);
+    bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
+
+    if (use_uefi) {
+        /*
+         * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
+         * when arm/virt boad starts to support it.
+         */
+        args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
+            "-drive if=pflash,format=raw,file=%s,readonly "
+            "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
+            data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
+            data->cd, params ? params : "");
+
+    } else {
+        /* Disable kernel irqchip to be able to override apic irq0. */
+        args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+            "-net none -display none %s "
+            "-drive id=hd0,if=none,file=%s,format=raw "
+            "-device ide-hd,drive=hd0 ",

tests/bios-tables-test.c static void test_smbios_structs(test_data *data) · line 557

Quoted 10 lines
tests/bios-tables-test.c +6 -1
+             data->machine, "kvm:tcg", params ? params : "", disk);
+    }
 
    data->qts = qtest_init(args);
 
-    boot_sector_test(data->qts);
+    if (use_uefi) {
+        g_assert(data->scan_len);
+        data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
+            data->ram_start, data->scan_len);

Is this possible to merge this in test_acpi_rsdp_address()? Both of them set the data->rsdp_addr.

Quoted 12 lines
tests/bios-tables-test.c +4 -1
+    } else {
+        boot_sector_test(data->qts);
+        test_acpi_rsdp_address(data);
+    }
 
    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
-    test_acpi_rsdp_address(data);
    test_acpi_rsdp_table(data);
    test_acpi_rxsdt_table(data);
    test_acpi_fadt_table(data);
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#20 lore raw

Re: [Qemu-devel] [PATCH v3 08/13] tests: acpi: add a way to start tests with UEFI firmware

Quoted 5 lines · On Thu, 25 Apr 2019 16:08:42 +0800 Wei Yang <[email protected]>…
Quoted 2 lines · Igor Mammedov

For testcase to use UEFI firmware, one needs to provide and specify firmwarei and varstore blobs names in test_data { uefi_fl1, uefi_fl2) }

^
a typo here?

fixed

Quoted 70 lines
Quoted 70 lines

fields respectively and RAM start address plus size where to look for test structure signature. Additionally testcase should specify bootable cdrom image uefi-boot-images EFI test utility.

---
v3:
* drop data_dir prefix and firmware will come from pc-bios directly
* add cdrom option so test could use it for providing boot cdrom image
* add TODO comment convert '-drive if=pflash' to new syntax (Laszlo)
v2:
* move RAM start address and size to test_data, as it could differ between boards (and even versions)
---
tests/bios-tables-test.c | 44 ++++++++++++++++++++++++++++++++++----------

1 file changed, 34 insertions(+), 10 deletions(-)
tests/bios-tables-test.c +26 -8
index 5790ee4..0f24540 100644
@@ -26,6 +26,11 @@
 typedef struct {
    const char *machine;
    const char *variant;
+    const char *uefi_fl1;
+    const char *uefi_fl2;
+    const char *cd;
+    const uint64_t ram_start;
+    const uint64_t scan_len;
    uint64_t rsdp_addr;
    uint8_t rsdp_table[36 /* ACPI 2.0+ RSDP size */];
    GArray *tables;
@@ -522,21 +527,40 @@ static void test_smbios_structs(test_data *data)
 static void test_acpi_one(const char *params, test_data *data)
 {
    char *args;
-
-    /* Disable kernel irqchip to be able to override apic irq0. */
-    args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
-                           "-net none -display none %s "
-                           "-drive id=hd0,if=none,file=%s,format=raw "
-                           "-device ide-hd,drive=hd0 ",
-                           data->machine, "kvm:tcg",
-                           params ? params : "", disk);
+    bool use_uefi = data->uefi_fl1 && data->uefi_fl2;
+
+    if (use_uefi) {
+        /*
+         * TODO: convert '-drive if=pflash' to new syntax (see e33763be7cd3)
+         * when arm/virt boad starts to support it.
+         */
+        args = g_strdup_printf("-machine %s,accel=%s -nodefaults -nographic "
+            "-drive if=pflash,format=raw,file=%s,readonly "
+            "-drive if=pflash,format=raw,file=%s,snapshot=on -cdrom %s %s",
+            data->machine, "kvm:tcg", data->uefi_fl1, data->uefi_fl2,
+            data->cd, params ? params : "");
+
+    } else {
+        /* Disable kernel irqchip to be able to override apic irq0. */
+        args = g_strdup_printf("-machine %s,accel=%s,kernel-irqchip=off "
+            "-net none -display none %s "
+            "-drive id=hd0,if=none,file=%s,format=raw "
+            "-device ide-hd,drive=hd0 ",
+             data->machine, "kvm:tcg", params ? params : "", disk);
+    }
 
    data->qts = qtest_init(args);
 
Quoted 8 lines

tests/bios-tables-test.c static void test_smbios_structs(test_data *data) · line 557

Quoted 5 lines
tests/bios-tables-test.c +4 -1
-    boot_sector_test(data->qts);
+    if (use_uefi) {
+        g_assert(data->scan_len);
+        data->rsdp_addr = acpi_find_rsdp_address_uefi(data->qts,
+            data->ram_start, data->scan_len);  

Is this possible to merge this in test_acpi_rsdp_address()? Both of them set the data->rsdp_addr.

I didn't want to duplicate use_uefi calculation and well test_acpi_rsdp_address() isn't doing much and not reused elsewhere. I'll fold in here.

Quoted 14 lines
Quoted 13 lines
tests/bios-tables-test.c +4 -1
+    } else {
+        boot_sector_test(data->qts);
+        test_acpi_rsdp_address(data);
+    }
 
    data->tables = g_array_new(false, true, sizeof(AcpiSdtTable));
-    test_acpi_rsdp_address(data);
    test_acpi_rsdp_table(data);
    test_acpi_rxsdt_table(data);
    test_acpi_fadt_table(data);
Signature · 1 line
2.7.4  
#21 lore raw

PATCH v3 9/13 tests: acpi: ignore SMBIOS tests when UEFI firmware is used

In reply to Igor Mammedov

once FW provides a pointer to SMBIOS entry point like it does for RSDP it should be possible to enable this one the same way.

---
v3:
- add ref to a uefi-test-tools feature req into comment (Laszlo)

---
 tests/bios-tables-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +9 -2
index 0f24540..1be55a1 100644
@@ -573,8 +573,15 @@ static void test_acpi_one(const char *params, test_data *data)
         }
     }
 
-    test_smbios_entry_point(data);
-    test_smbios_structs(data);
+    /*
+     * TODO: make SMBIOS tests work with UEFI firmware,
+     * Bug on uefi-test-tools to provide entry point:
+     * https://bugs.launchpad.net/qemu/+bug/1821884
+     */
+    if (!use_uefi) {
+        test_smbios_entry_point(data);
+        test_smbios_structs(data);
+    }
 
     assert(!global_qtest);
     qtest_quit(data->qts);
Signature · 1 line
2.7.4
#22 lore raw

Re: [Qemu-devel] [PATCH v3 09/13] tests: acpi: ignore SMBIOS tests when UEFI firmware is used

Hi Igor,

Quoted 21 lines · Igor Mammedov

once FW provides a pointer to SMBIOS entry point like it does for RSDP it should be possible to enable this one the same way.

---
v3:
- add ref to a uefi-test-tools feature req into comment (Laszlo)

---
 tests/bios-tables-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +0 -1
index 0f24540..1be55a1 100644
@@ -573,8 +573,15 @@ static void test_acpi_one(const char *params, test_data *data)
         }
     }
 
-    test_smbios_entry_point(data);

tests/bios-tables-test.c static void test_acpi_one(const char *params, test_data *data) · line 584

Quoted 10 lines
tests/bios-tables-test.c +9 -1
-    test_smbios_structs(data);
+    /*
+     * TODO: make SMBIOS tests work with UEFI firmware,
+     * Bug on uefi-test-tools to provide entry point:
+     * https://bugs.launchpad.net/qemu/+bug/1821884
+     */
+    if (!use_uefi) {
+        test_smbios_entry_point(data);
+        test_smbios_structs(data);
+    }

Now that Laszlo resolved this bug, you can update the SMBIOS tests :)

Without this patch I get:

ERROR:/home/phil/source/qemu/tests/bios-tables-test.c:460:test_smbios_entry_point:
assertion failed (off < 0x100000): (0x00100000 < 0x00100000)

And the UEFI console shows:

BdsDxe: failed to load Boot0001 "UEFI Misc Device" from
VenHw(93E34C7E-B50E-11DF-9223-2443DFD72085,00): Not Found
FatDiskIo: Cache Page OutBound occurred!
add-symbol-file /home/lacos/src/upstream/qemu/tests/uefi-test-tools/Build/UefiTestTools/DEBUG_GCC5/AARCH64/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest/DEBUG/BiosTablesTest.dll 0x442C3000
Loading driver at 0x000442C2000 EntryPoint=0x000442C47AC BiosTablesTest.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 4654EE18
ProtectUefiImageCommon - 0x451AA140
- 0x00000000442C2000 - 0x0000000000006000
SetUefiImageMemoryAttributes - 0x00000000442C2000 - 0x0000000000001000
(0x0000000000004008)
SetUefiImageMemoryAttributes - 0x00000000442C3000 - 0x0000000000003000
(0x0000000000020008)
SetUefiImageMemoryAttributes - 0x00000000442C6000 - 0x0000000000002000
(0x0000000000004008)
BdsDxe: starting Boot0002 "UEFI Misc Device 2" from
PciRoot(0x0)/Pci(0x2,0x0)
BiosTablesTest: BiosTablesTest=45100000 Rsdp10=0 Rsdp20=44020000
BiosTablesTest: Smbios21=0 Smbios30=47640000
BiosTablesTest: press any key to exit

Quoted 4 lines
tests/bios-tables-test.c +0 -0
     assert(!global_qtest);
     qtest_quit(data->qts);
 
#23 lore raw

Re: [Qemu-devel] [PATCH v3 09/13] tests: acpi: ignore SMBIOS tests when UEFI firmware is used

Quoted 23 lines · On Thu, 25 Apr 2019 14:37:35 +0200 Philippe Mathieu-Daudé <[email protected]>…

Hi Igor,

Quoted 20 lines · Igor Mammedov

once FW provides a pointer to SMBIOS entry point like it does for RSDP it should be possible to enable this one the same way.

---
v3:
- add ref to a uefi-test-tools feature req into comment (Laszlo)

---
 tests/bios-tables-test.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
tests/bios-tables-test.c +0 -0
index 0f24540..1be55a1 100644
@@ -573,8 +573,15 @@ static void test_acpi_one(const char *params, test_data *data)
         }
     }
 
Quoted 13 lines

tests/bios-tables-test.c static void test_acpi_one(const char *params, test_data *data) · line 584

Quoted 11 lines
tests/bios-tables-test.c +9 -2
-    test_smbios_entry_point(data);
-    test_smbios_structs(data);
+    /*
+     * TODO: make SMBIOS tests work with UEFI firmware,
+     * Bug on uefi-test-tools to provide entry point:
+     * https://bugs.launchpad.net/qemu/+bug/1821884
+     */
+    if (!use_uefi) {
+        test_smbios_entry_point(data);
+        test_smbios_structs(data);
+    }  

Now that Laszlo resolved this bug, you can update the SMBIOS tests :)

It's not on top of priority list, I'll do it later on as time would allow.

For me it's important to get virt-arm ACPI tested so that NEMU folks could generalize code ACPI between x86- and arm- virt machines without testing it manually for regressions each time.

Quoted 34 lines

Without this patch I get:

ERROR:/home/phil/source/qemu/tests/bios-tables-test.c:460:test_smbios_entry_point:
assertion failed (off < 0x100000): (0x00100000 < 0x00100000)

And the UEFI console shows:

BdsDxe: failed to load Boot0001 "UEFI Misc Device" from
VenHw(93E34C7E-B50E-11DF-9223-2443DFD72085,00): Not Found
FatDiskIo: Cache Page OutBound occurred!
add-symbol-file /home/lacos/src/upstream/qemu/tests/uefi-test-tools/Build/UefiTestTools/DEBUG_GCC5/AARCH64/UefiTestToolsPkg/BiosTablesTest/BiosTablesTest/DEBUG/BiosTablesTest.dll 0x442C3000
Loading driver at 0x000442C2000 EntryPoint=0x000442C47AC BiosTablesTest.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 4654EE18
ProtectUefiImageCommon - 0x451AA140
- 0x00000000442C2000 - 0x0000000000006000
SetUefiImageMemoryAttributes - 0x00000000442C2000 - 0x0000000000001000
(0x0000000000004008)
SetUefiImageMemoryAttributes - 0x00000000442C3000 - 0x0000000000003000
(0x0000000000020008)
SetUefiImageMemoryAttributes - 0x00000000442C6000 - 0x0000000000002000
(0x0000000000004008)
BdsDxe: starting Boot0002 "UEFI Misc Device 2" from
PciRoot(0x0)/Pci(0x2,0x0)
BiosTablesTest: BiosTablesTest=45100000 Rsdp10=0 Rsdp20=44020000
BiosTablesTest: Smbios21=0 Smbios30=47640000
BiosTablesTest: press any key to exit

Quoted 4 lines
tests/bios-tables-test.c +0 -0
     assert(!global_qtest);
     qtest_quit(data->qts);
 
#24 lore raw

PATCH v3 10/13 tests: add expected ACPI tables for arm/virt board

In reply to Igor Mammedov

---
this patch is ahead fo "tests: acpi: add simple arm/virt testcase" to keep 'make check' working during bisection and not to pollute code with binary blobs which are not reviewable.

---
 tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
 tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
 tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
 tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
 tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
 tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
 6 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/data/acpi/virt/APIC
 create mode 100644 tests/data/acpi/virt/DSDT
 create mode 100644 tests/data/acpi/virt/FACP
 create mode 100644 tests/data/acpi/virt/GTDT
 create mode 100644 tests/data/acpi/virt/MCFG
 create mode 100644 tests/data/acpi/virt/SPCR
tests/data/acpi/virt/APIC new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
tests/data/acpi/virt/DSDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
tests/data/acpi/virt/FACP new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
tests/data/acpi/virt/GTDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
tests/data/acpi/virt/MCFG new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
tests/data/acpi/virt/SPCR new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
Signature · 1 line
2.7.4
Tested-by on v3 10/13
#25 lore raw

Re: [Qemu-devel] [PATCH v3 10/13] tests: add expected ACPI tables for arm/virt board

Quoted 1 line · Igor Mammedov
Quoted 157 lines

---
this patch is ahead fo "tests: acpi: add simple arm/virt testcase" to keep 'make check' working during bisection and not to pollute code with binary blobs which are not reviewable.

---
 tests/data/acpi/virt/APIC | Bin 0 -> 168 bytes
 tests/data/acpi/virt/DSDT | Bin 0 -> 18476 bytes
 tests/data/acpi/virt/FACP | Bin 0 -> 268 bytes
 tests/data/acpi/virt/GTDT | Bin 0 -> 96 bytes
 tests/data/acpi/virt/MCFG | Bin 0 -> 60 bytes
 tests/data/acpi/virt/SPCR | Bin 0 -> 80 bytes
 6 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 tests/data/acpi/virt/APIC
 create mode 100644 tests/data/acpi/virt/DSDT
 create mode 100644 tests/data/acpi/virt/FACP
 create mode 100644 tests/data/acpi/virt/GTDT
 create mode 100644 tests/data/acpi/virt/MCFG
 create mode 100644 tests/data/acpi/virt/SPCR
tests/data/acpi/virt/APIC new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..797dfde2841c51b7e72065602e99ce1714347f0d
GIT binary patch
tests/data/acpi/virt/DSDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..20e85c7f89f645c69935c615c07084e221419960
GIT binary patch
tests/data/acpi/virt/FACP new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..27de99f51bfe846b1f8796ace49d83f5b33a1aed
GIT binary patch
tests/data/acpi/virt/GTDT new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..10107a65e958ff6495bb8c17d63d0539690f59f6
GIT binary patch
tests/data/acpi/virt/MCFG new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e8987e1af0ec3829770bf4fe11fab02b06160dd2
GIT binary patch
tests/data/acpi/virt/SPCR new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..377271a0e7817cc21a28c02123a89facad63604f
GIT binary patch
#26 lore raw

PATCH v3 11/13 tests: acpi: add simple arm/virt testcase

In reply to Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +17 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
Signature · 1 line
2.7.4
Reviewed-by Tested-by on v3 11/13
#27 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 11 lines · Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

Please replace previous R-b by:

Quoted 63 lines

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +17 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
#28 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 6 lines · On Thu, 25 Apr 2019 14:41:28 +0200 Philippe Mathieu-Daudé <[email protected]>…
Quoted 5 lines · Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

Quoted 7 lines
Quoted 6 lines

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

Please replace previous R-b by:

done

Quoted 67 lines
Quoted 63 lines

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +17 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);
#29 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

In reply to Igor Mammedov

Hi Igor,

+static void test_acpi_virt_tcg(void)
+{
+ test_data data = {

+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,

+ };
+
+ test_acpi_one("-cpu cortex-a57 ", &data);

Replaced the cortex-a57 with host and succesfully tested on the hisilicon arm64 D05 board. Otherwise it failed with "kvm_init_vcpu failed: Invalid argument". Is it possilbe to set the cpu type like numa-test.c?
Thanks!

Best Regards,
Wei

#30 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 15 lines · On Fri, 26 Apr 2019 00:51:56 +0800 x00249684 <[email protected]> wrote:

Hi Igor,

tests/bios-tables-test.c +12 -0
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
Quoted 3 lines

Replaced the cortex-a57 with host and succesfully tested on the hisilicon arm64 D05 board. Otherwise it failed with "kvm_init_vcpu failed: Invalid argument". Is it possilbe to set the cpu type like numa-test.c?

I think it works with numa-test because it uses TCG only but in case of bios-tables-test it uses accel="kvm:tcg" to leverage KVM capabilities whenever possible to speed up test.

Now back to our ARM test case, uefi requirement is to use 64bit CPU (hence it was cortex-a57) however unlike x86 it obviously breaks since KVM accelerator on ARM host is used and it doesn't work with anything other than 'host' cpu model.

I think we still want to use KVM whenever possible, but problem lies in that user (testcase) doesn't have an idea if KVM accelerator is available and host is 64 CPU.

to sum up we need to support 2 modes:
1. host is 64 ARM, use kvm with -cpu host
2. all other cases use tcg with -cpu cortex-a57

I can hack to probe if /dev/kvm is accessible and host is 64 bit and use #1 otherwise fallback to #2
or as quick fix do only #2 initially and think about a better solution to #1

Is there any other suggestions/opinions how to approach issue/proceed.

PS:
we probably would like to reuse this not only for acpi tests but also for other arm/virt test cases that involve running guest code.

Quoted 4 lines

Thanks!

Best Regards,
Wei

#31 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Hi Igor,

Quoted 32 lines · Igor Mammedov
Quoted 15 lines · On Fri, 26 Apr 2019 00:51:56 +0800 x00249684 <[email protected]> wrote:

Hi Igor,

tests/bios-tables-test.c +12 -0
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
Quoted 3 lines

Replaced the cortex-a57 with host and succesfully tested on the hisilicon arm64 D05 board. Otherwise it failed with "kvm_init_vcpu failed: Invalid argument". Is it possilbe to set the cpu type like numa-test.c?

I think it works with numa-test because it uses TCG only but in case of bios-tables-test it uses accel="kvm:tcg" to leverage KVM capabilities whenever possible to speed up test.

Now back to our ARM test case, uefi requirement is to use 64bit CPU (hence it was cortex-a57) however unlike x86 it obviously breaks since KVM accelerator on ARM host is used and it doesn't work with anything other than 'host' cpu model.

I think we still want to use KVM whenever possible, but problem lies in that user (testcase) doesn't have an idea if KVM accelerator is available and host is 64 CPU.

Quoted 7 lines

to sum up we need to support 2 modes:
1. host is 64 ARM, use kvm with -cpu host
2. all other cases use tcg with -cpu cortex-a57

I can hack to probe if /dev/kvm is accessible and host is 64 bit and use #1 otherwise fallback to #2
or as quick fix do only #2 initially and think about a better solution to #1

Thanks!
Fine to me.

Quoted 2 lines

Is there any other suggestions/opinions how to approach issue/proceed.

To check the host cpu architecture is ARM or not, maybe we can check the value of "CPU implementer" is 0x41 or not from the /proc/cpuinfo.

Best Regards,
Wei

Quoted 13 lines

PS:
we probably would like to reuse this not only for acpi tests but also for other arm/virt test cases that involve running guest code.

Quoted 4 lines

Thanks!

Best Regards,
Wei

.

#32 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 43 lines · On Fri, 26 Apr 2019 17:28:10 +0100 Wei Xu <[email protected]> wrote:

Hi Igor,

Quoted 32 lines · Igor Mammedov
Quoted 15 lines · On Fri, 26 Apr 2019 00:51:56 +0800 x00249684 <[email protected]> wrote:

Hi Igor,

tests/bios-tables-test.c +12 -0
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
Quoted 3 lines

Replaced the cortex-a57 with host and succesfully tested on the hisilicon arm64 D05 board. Otherwise it failed with "kvm_init_vcpu failed: Invalid argument". Is it possilbe to set the cpu type like numa-test.c?

I think it works with numa-test because it uses TCG only but in case of bios-tables-test it uses accel="kvm:tcg" to leverage KVM capabilities whenever possible to speed up test.

Now back to our ARM test case, uefi requirement is to use 64bit CPU (hence it was cortex-a57) however unlike x86 it obviously breaks since KVM accelerator on ARM host is used and it doesn't work with anything other than 'host' cpu model.

I think we still want to use KVM whenever possible, but problem lies in that user (testcase) doesn't have an idea if KVM accelerator is available and host is 64 CPU.

Quoted 7 lines

to sum up we need to support 2 modes:
1. host is 64 ARM, use kvm with -cpu host
2. all other cases use tcg with -cpu cortex-a57

I can hack to probe if /dev/kvm is accessible and host is 64 bit and use #1 otherwise fallback to #2
or as quick fix do only #2 initially and think about a better solution to #1

Quoted 8 lines

Thanks!
Fine to me.

Quoted 2 lines

Is there any other suggestions/opinions how to approach issue/proceed.

To check the host cpu architecture is ARM or not, maybe we can check the value of "CPU implementer" is 0x41 or not from the /proc/cpuinfo.

it turned out it's more complicated.
we also should pick a correct GIC depending on host's CPU and that changes ACPI tables, so it will worn on some hosts and fail on other.

I'll add a patch to enable test case to pick accelerator and force TCG for ARM tests for now.

Quoted 18 lines

Best Regards,
Wei

Quoted 13 lines

PS:
we probably would like to reuse this not only for acpi tests but also for other arm/virt test cases that involve running guest code.

Quoted 4 lines

Thanks!

Best Regards,
Wei

.

#33 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Hi Igor,

Quoted 50 lines · Igor Mammedov
Quoted 47 lines · On Fri, 26 Apr 2019 17:28:10 +0100 Wei Xu <[email protected]> wrote:

Hi Igor,

Quoted 32 lines · Igor Mammedov
Quoted 15 lines · On Fri, 26 Apr 2019 00:51:56 +0800 x00249684 <[email protected]> wrote:

Hi Igor,

tests/bios-tables-test.c +12 -0
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
Quoted 3 lines

Replaced the cortex-a57 with host and succesfully tested on the hisilicon arm64 D05 board. Otherwise it failed with "kvm_init_vcpu failed: Invalid argument". Is it possilbe to set the cpu type like numa-test.c?

I think it works with numa-test because it uses TCG only but in case of bios-tables-test it uses accel="kvm:tcg" to leverage KVM capabilities whenever possible to speed up test.

Now back to our ARM test case, uefi requirement is to use 64bit CPU (hence it was cortex-a57) however unlike x86 it obviously breaks since KVM accelerator on ARM host is used and it doesn't work with anything other than 'host' cpu model.

I think we still want to use KVM whenever possible, but problem lies in that user (testcase) doesn't have an idea if KVM accelerator is available and host is 64 CPU.

Quoted 7 lines

to sum up we need to support 2 modes:
1. host is 64 ARM, use kvm with -cpu host
2. all other cases use tcg with -cpu cortex-a57

I can hack to probe if /dev/kvm is accessible and host is 64 bit and use #1 otherwise fallback to #2
or as quick fix do only #2 initially and think about a better solution to #1

Thanks!
Fine to me.

Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Is there any other suggestions/opinions how to approach issue/proceed.

To check the host cpu architecture is ARM or not, maybe we can check the value of "CPU implementer" is 0x41 or not from the /proc/cpuinfo.

it turned out it's more complicated.
we also should pick a correct GIC depending on host's CPU and that changes ACPI tables, so it will worn on some hosts and fail on other.

Sorry, I did not consider that case.

Quoted 4 lines

I'll add a patch to enable test case to pick accelerator and force TCG for ARM tests for now.

Thanks!

Best Regards,
Wei

Quoted 22 lines
Quoted 18 lines

Best Regards,
Wei

Quoted 13 lines

PS:
we probably would like to reuse this not only for acpi tests but also for other arm/virt test cases that involve running guest code.

Quoted 4 lines

Thanks!

Best Regards,
Wei

.

.

#34 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

In reply to Igor Mammedov
Quoted 65 lines · Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +15 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();

tests/bios-tables-test.c int main(int argc, char *argv[]) · line 862

Quoted 8 lines
tests/bios-tables-test.c +2 -0
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);

Looks good, my R-b stands.

(Please let me know if you want me to look at other patches in the series... struggling again with email bankruptcy...)

Thanks!
Laszlo

#35 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 77 lines · On Fri, 26 Apr 2019 19:11:50 +0200 Laszlo Ersek <[email protected]> wrote:
Quoted 65 lines · Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +15 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();

tests/bios-tables-test.c int main(int argc, char *argv[]) · line 862

Quoted 8 lines
tests/bios-tables-test.c +2 -0
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);

Looks good, my R-b stands.

Quoted 6 lines

(Please let me know if you want me to look at other patches in the series... struggling again with email bankruptcy...)

Thanks!
Laszlo

on respin there will be a new patch added

[PATCH v4 11/15] tests: acpi: allow to override default accelerator

and change to this patch will be forcing TCG accelerator:

tests/bios-tables-test.c +1 -0
index 6cb8b16..385e1ab 100644
@@ -817,7 +817,6 @@ static void test_acpi_virt_tcg(void)
 {
     test_data data = {
         .machine = "virt",
+        .accel = "tcg",
         .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
         .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
         .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
#36 lore raw

Re: [Qemu-devel] [PATCH v3 11/13] tests: acpi: add simple arm/virt testcase

Quoted 99 lines · Igor Mammedov
Quoted 77 lines · On Fri, 26 Apr 2019 19:11:50 +0200 Laszlo Ersek <[email protected]> wrote:
Quoted 65 lines · Igor Mammedov

adds simple arm/virt test case that starts guest with bios-tables-test.aarch64.iso.qcow2 boot image which initializes UefiTestSupport* structure in RAM once guest is booted.

* see commit: tests: acpi: add acpi_find_rsdp_address_uefi() helper

---
v3:
* use firmware blobs directly from pc-bios directory
* use bios-tables-test.aarch64.iso.qcow2 as test boot image
* drop leftover qtest-uefi-images-aarch64 iMakefile rule from previos version (Laszlo)
* add Makefile rule to include bios-tables-test into check-qtest-aarch64 target
v2:
* specify in test_data where board's RAM starts and RAM size

---
 tests/Makefile.include   |  1 +
 tests/bios-tables-test.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
tests/Makefile.include +1 -0
index e2432d5..983c8b1 100644
@@ -267,6 +267,7 @@ check-qtest-arm-y += tests/hexloader-test$(EXESUF)
 check-qtest-aarch64-y = tests/numa-test$(EXESUF)
 check-qtest-aarch64-y += tests/boot-serial-test$(EXESUF)
 check-qtest-aarch64-y += tests/migration-test$(EXESUF)
+check-qtest-aarch64-y += tests/bios-tables-test$(EXESUF)
 
 check-qtest-microblazeel-y += $(check-qtest-microblaze-y)
 
tests/bios-tables-test.c +15 -0
index 1be55a1..f117461 100644
@@ -812,6 +812,21 @@ static void test_acpi_piix4_tcg_dimm_pxm(void)
     test_acpi_tcg_dimm_pxm(MACHINE_PC);
 }
 
+static void test_acpi_virt_tcg(void)
+{
+    test_data data = {
+        .machine = "virt",
+        .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
+        .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
+        .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",
+        .ram_start = 0x40000000ULL,
+        .scan_len = 128ULL * 1024 * 1024,
+    };
+
+    test_acpi_one("-cpu cortex-a57 ", &data);
+    free_test_data(&data);
+}
+
 int main(int argc, char *argv[])
 {
     const char *arch = qtest_get_arch();

tests/bios-tables-test.c int main(int argc, char *argv[]) · line 862

Quoted 8 lines
tests/bios-tables-test.c +2 -0
@@ -840,6 +855,8 @@ int main(int argc, char *argv[])
         qtest_add_func("acpi/q35/numamem", test_acpi_q35_tcg_numamem);
         qtest_add_func("acpi/piix4/dimmpxm", test_acpi_piix4_tcg_dimm_pxm);
         qtest_add_func("acpi/q35/dimmpxm", test_acpi_q35_tcg_dimm_pxm);
+    } else if (strcmp(arch, "aarch64") == 0) {
+        qtest_add_func("acpi/virt", test_acpi_virt_tcg);
     }
     ret = g_test_run();
     boot_sector_cleanup(disk);

Looks good, my R-b stands.

Quoted 6 lines

(Please let me know if you want me to look at other patches in the series... struggling again with email bankruptcy...)

Thanks!
Laszlo

on respin there will be a new patch added

[PATCH v4 11/15] tests: acpi: allow to override default accelerator

and change to this patch will be forcing TCG accelerator:

tests/bios-tables-test.c +0 -0
index 6cb8b16..385e1ab 100644

tests/bios-tables-test.c static void test_acpi_virt_tcg(void)

Quoted 7 lines
tests/bios-tables-test.c +1 -0
@@ -817,7 +817,6 @@ static void test_acpi_virt_tcg(void)
 {
     test_data data = {
         .machine = "virt",
+        .accel = "tcg",
         .uefi_fl1 = "pc-bios/edk2-aarch64-code.fd",
         .uefi_fl2 = "pc-bios/edk2-arm-vars.fd",
         .cd = "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2",

You can keep my R-b with that update.

Thanks!
Laszlo

#37 lore raw

PATCH v3 12/13 tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

In reply to Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

---
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)

---
 tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +11 -12
index abdff70..52793f3 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # This work is licensed under the terms of the GNU GPLv2.
 # See the COPYING.LIB file in the top-level directory.
 
-qemu=
-
-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
-    qemu="x86_64-softmmu/qemu-system-x86_64"
-elif [ -e i386-softmmu/qemu-system-i386 ]; then
-    qemu="i386-softmmu/qemu-system-i386"
-else
-    echo "Run 'make' to build the qemu exectutable!"
-    echo "Run this script from the build directory."
-    exit 1;
-fi
+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
 
 if [ ! -e "tests/bios-tables-test" ]; then
     echo "Test: bios-tables-test is required! Run make check before this script."
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
     exit 1;
 fi
 
-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+for qemu in $qemu_bins; do
+    if [ ! -e $qemu ]; then
+        echo "Run 'make' to build the following QEMU exectutables: $qemu_bins"
+        echo "Also, run this script from the build directory."
+        exit 1;
+    fi
+    TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+done
+
 
 echo "The files were rebuilt and can be added to git."
Signature · 1 line
2.7.4
#38 lore raw

Re: [Qemu-devel] [PATCH v3 12/13] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

Quoted 1 line · Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

so i386 is taken out?

Quoted 42 lines

---
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)
---
tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------

1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +2 -11
index abdff70..52793f3 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # This work is licensed under the terms of the GNU GPLv2.
 # See the COPYING.LIB file in the top-level directory.
 
-qemu=
-
-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
-    qemu="x86_64-softmmu/qemu-system-x86_64"
-elif [ -e i386-softmmu/qemu-system-i386 ]; then
-    qemu="i386-softmmu/qemu-system-i386"
-else
-    echo "Run 'make' to build the qemu exectutable!"
-    echo "Run this script from the build directory."
-    exit 1;
-fi
+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
 

if [ ! -e "tests/bios-tables-test" ]; then
echo "Test: bios-tables-test is required! Run make check before this script."

tests/data/acpi/rebuild-expected-aml.sh +0 -0
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
    exit 1;

fi

tests/data/acpi/rebuild-expected-aml.sh if [ ! -e "tests/bios-tables-test" ]; then · line 25

Quoted 4 lines
tests/data/acpi/rebuild-expected-aml.sh +3 -1
-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+for qemu in $qemu_bins; do
+    if [ ! -e $qemu ]; then
+        echo "Run 'make' to build the following QEMU exectutables: $qemu_bins"

s/exectutables/executables

tests/data/acpi/rebuild-expected-aml.sh if [ ! -e "tests/bios-tables-test" ]; then · line 31

Quoted 6 lines
tests/data/acpi/rebuild-expected-aml.sh +6 -0
+        echo "Also, run this script from the build directory."
+        exit 1;
+    fi
+    TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+done
+

The original behavior is either one executable exist will pass.

But now, either of one doesn't exist will fail. Is this what we expect?

Quoted 4 lines

echo "The files were rebuilt and can be added to git."

Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
#39 lore raw

Re: [Qemu-devel] [PATCH v3 12/13] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

Quoted 47 lines · On Thu, 25 Apr 2019 16:20:50 +0800 Wei Yang <[email protected]>…
Quoted 1 line · Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

so i386 is taken out?

Quoted 42 lines

---
v2:
* fix up error message (Philippe Mathieu-Daudé <[email protected]>)
---
tests/data/acpi/rebuild-expected-aml.sh | 23 +++++++++++------------

1 file changed, 11 insertions(+), 12 deletions(-)
tests/data/acpi/rebuild-expected-aml.sh +2 -11
index abdff70..52793f3 100755
@@ -7,21 +7,12 @@
 #
 # Authors:
 #  Marcel Apfelbaum <[email protected]>
+#  Igor Mammedov <[email protected]>
 #
 # This work is licensed under the terms of the GNU GPLv2.
 # See the COPYING.LIB file in the top-level directory.
 
-qemu=
-
-if [ -e x86_64-softmmu/qemu-system-x86_64 ]; then
-    qemu="x86_64-softmmu/qemu-system-x86_64"
-elif [ -e i386-softmmu/qemu-system-i386 ]; then
-    qemu="i386-softmmu/qemu-system-i386"
-else
-    echo "Run 'make' to build the qemu exectutable!"
-    echo "Run this script from the build directory."
-    exit 1;
-fi
+qemu_bins="aarch64-softmmu/qemu-system-aarch64 x86_64-softmmu/qemu-system-x86_64"
 

if [ ! -e "tests/bios-tables-test" ]; then
echo "Test: bios-tables-test is required! Run make check before this script."

tests/data/acpi/rebuild-expected-aml.sh +0 -0
@@ -29,6 +20,14 @@ if [ ! -e "tests/bios-tables-test" ]; then
    exit 1;

fi

Quoted 6 lines

tests/data/acpi/rebuild-expected-aml.sh if [ ! -e "tests/bios-tables-test" ]; then · line 25

Quoted 4 lines
tests/data/acpi/rebuild-expected-aml.sh +3 -1
-TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+for qemu in $qemu_bins; do
+    if [ ! -e $qemu ]; then
+        echo "Run 'make' to build the following QEMU exectutables: $qemu_bins"  

s/exectutables/executables

fixed

Quoted 10 lines

tests/data/acpi/rebuild-expected-aml.sh if [ ! -e "tests/bios-tables-test" ]; then · line 31

Quoted 6 lines
tests/data/acpi/rebuild-expected-aml.sh +6 -0
+        echo "Also, run this script from the build directory."
+        exit 1;
+    fi
+    TEST_ACPI_REBUILD_AML=y QTEST_QEMU_BINARY=$qemu tests/bios-tables-test
+done
+  

The original behavior is either one executable exist will pass.

But now, either of one doesn't exist will fail. Is this what we expect?

It's mainly maintainers tool to update reference blobs. And I intentionally made it fail to force maintainer/developer building all targets that depend on ACPI to make sure that mistakes won't silently creep in due to non build target.

Quoted 4 lines
Quoted 3 lines

echo "The files were rebuilt and can be added to git."

Signature · 1 line
2.7.4  
#40 lore raw

Re: [Qemu-devel] [PATCH v3 12/13] tests: acpi: refactor rebuild-expected-aml.sh to dump ACPI tables for a specified list of targets

Quoted 7 lines · On Thu, 25 Apr 2019 13:32:50 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 4 lines · On Thu, 25 Apr 2019 16:20:50 +0800 Wei Yang <[email protected]>…
Quoted 1 line · Igor Mammedov

Make initial list contain aarch64 and x86_64 targets.

so i386 is taken out?

we use the same blobs for both i386 and x86_64 targets so it was sort of duplication. But someone who intends to update reference blobs, surely can build x86_64 and aarch64 targets to achieve their goal.

#41 lore raw

PATCH v3 13/13 tests: acpi: print error unable to dump ACPI table during rebuild

In reply to Igor Mammedov

Instead of just asserting print the error that lead to assert first. While at it move assert into rebuild branch, which removes reduntant check done in case of !rebuild branch is taken (the later is taken care of by g_assert_no_error).

---
 tests/bios-tables-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +4 -1
index f117461..5a5d036 100644
@@ -199,11 +199,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
                                        sdt->aml, ext);
             fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
                         S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+            if (fd < 0) {
+                perror(aml_file);
+            }
+            g_assert(fd >= 0);
         } else {
             fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
             g_assert_no_error(error);
         }
-        g_assert(fd >= 0);
 
         ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
         g_assert(ret == sdt->aml_len);
Signature · 1 line
2.7.4
Reviewed-by on v3 13/13
#42 lore raw

Re: [Qemu-devel] [PATCH v3 13/13] tests: acpi: print error unable to dump ACPI table during rebuild

Quoted 6 lines · Igor Mammedov

Instead of just asserting print the error that lead to assert first. While at it move assert into rebuild branch, which removes reduntant check done in case of !rebuild branch is taken (the later is taken care of by g_assert_no_error).

Quoted 26 lines

---
tests/bios-tables-test.c | 5 ++++-

1 file changed, 4 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +4 -1
index f117461..5a5d036 100644
@@ -199,11 +199,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
                                       sdt->aml, ext);
            fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
                        S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+            if (fd < 0) {
+                perror(aml_file);
+            }
+            g_assert(fd >= 0);
        } else {
            fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
            g_assert_no_error(error);
        }
-        g_assert(fd >= 0);
 
        ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
        g_assert(ret == sdt->aml_len);
Signature · 1 line
2.7.4
Signature · 2 lines
Wei Yang
Help you, Help me
Reviewed-by on v3 13/13
#43 lore raw

Re: [Qemu-devel] [PATCH v3 13/13] tests: acpi: print error unable to dump ACPI table during rebuild

In reply to Igor Mammedov
Quoted 2 lines · Igor Mammedov

Instead of just asserting print the error that lead to assert first. While at it move assert into rebuild branch, which removes reduntant

"redundant"

Quoted 19 lines

check done in case of !rebuild branch is taken (the later is taken care of by g_assert_no_error).

---
 tests/bios-tables-test.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tests/bios-tables-test.c +2 -0
index f117461..5a5d036 100644
@@ -199,11 +199,14 @@ static void dump_aml_files(test_data *data, bool rebuild)
                                        sdt->aml, ext);
             fd = g_open(aml_file, O_WRONLY|O_TRUNC|O_CREAT,
                         S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
+            if (fd < 0) {
+                perror(aml_file);

tests/bios-tables-test.c static void dump_aml_files(test_data *data, bool rebuild) · line 212

Quoted 10 lines
tests/bios-tables-test.c +2 -1
+            }
+            g_assert(fd >= 0);
         } else {
             fd = g_file_open_tmp("aml-XXXXXX", &sdt->aml_file, &error);
             g_assert_no_error(error);
         }
-        g_assert(fd >= 0);
 
         ret = qemu_write_full(fd, sdt->aml, sdt->aml_len);
         g_assert(ret == sdt->aml_len);