All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gryanko <xpahos@gmail.com>
To: qemu-devel@nongnu.org
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Zhao Liu" <zhao1.liu@intel.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Ani Sinha" <anisinha@redhat.com>,
	"Alexander Gryanko" <xpahos@gmail.com>
Subject: [PATCH 3/3] tests/qtest: Add SMBIOS Type 8 handle base tests
Date: Sat, 23 May 2026 06:41:58 +0300	[thread overview]
Message-ID: <20260523034158.57487-4-xpahos@gmail.com> (raw)
In-Reply-To: <20260523034158.57487-1-xpahos@gmail.com>

Verify that SMBIOS Type 8 table handles use the correct base address
depending on the machine type version:
- pc-q35-11.2 and pc-i440fx-11.2 (latest): handles start at 0x800
- pc-q35-11.1 and pc-i440fx-11.1 (compat): handles start at 0x0
Each test creates two Type 8 entries to verify both the base address
and sequential handle assignment (base+0, base+1).

Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
---
 tests/qtest/bios-tables-test.c | 70 +++++++++++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/tests/qtest/bios-tables-test.c b/tests/qtest/bios-tables-test.c
index 510751799e..66d6015667 100644
--- a/tests/qtest/bios-tables-test.c
+++ b/tests/qtest/bios-tables-test.c
@@ -99,6 +99,7 @@ typedef struct {
     uint16_t smbios_core_count2;
     uint8_t smbios_thread_count;
     uint16_t smbios_thread_count2;
+    bool smbios_type8_t8_base;
     uint8_t *required_struct_types;
     int required_struct_types_len;
     int type4_count;
@@ -720,12 +721,22 @@ static void smbios_type4_count_test(test_data *data, int type4_count)
     }
 }
 
+static void smbios_type8_test(test_data *data, uint32_t addr,
+                              int instance)
+{
+    uint16_t handle = qtest_readw(data->qts,
+        addr + offsetof(struct smbios_structure_header, handle));
+    uint16_t expected_base = data->smbios_type8_t8_base ? 0x800 : 0x0;
+
+    g_assert_cmpuint(handle, ==, expected_base + instance);
+}
+
 static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_type)
 {
     DECLARE_BITMAP(struct_bitmap, SMBIOS_MAX_TYPE+1) = { 0 };
 
     SmbiosEntryPoint *ep_table = &data->smbios_ep_table;
-    int i = 0, len, max_len = 0, type4_count = 0;
+    int i = 0, len, max_len = 0, type4_count = 0, type8_count = 0;
     uint8_t type, prv, crt;
     uint64_t addr;
 
@@ -754,6 +765,11 @@ static void test_smbios_structs(test_data *data, SmbiosEntryPointType ep_type)
             type4_count++;
         }
 
+        if (type == 8) {
+            smbios_type8_test(data, addr, type8_count);
+            type8_count++;
+        }
+
         /* seek to end of unformatted string area of this struct ("\0\0") */
         prv = crt = 1;
         while (prv || crt) {
@@ -2534,6 +2550,50 @@ static void test_acpi_isapc_smbios_legacy(void)
     free_test_data(&data);
 }
 
+static void test_smbios_type8_common(const char *machine,
+                                     const char *variant, bool t8_base)
+{
+    uint8_t req_type8[] = { 8 };
+    test_data data = {
+        .machine = machine,
+        .arch    = "x86",
+        .variant = variant,
+        .required_struct_types = req_type8,
+        .required_struct_types_len = ARRAY_SIZE(req_type8),
+        .smbios_type8_t8_base = t8_base,
+    };
+
+    test_smbios("-smbios type=8,connector_type=7,port_type=8,"
+                "external_reference=USB1 "
+                "-smbios type=8,connector_type=8,port_type=9,"
+                "external_reference=USB2", &data);
+    free_test_data(&data);
+}
+
+static void test_acpi_q35_smbios_type8(void)
+{
+    test_smbios_type8_common(MACHINE_Q35,
+        ".q35_smbios_type8", true);
+}
+
+static void test_acpi_q35_smbios_type8_compat(void)
+{
+    test_smbios_type8_common("pc-q35-11.1",
+        ".q35_smbios_type8_compat", false);
+}
+
+static void test_acpi_pc_smbios_type8(void)
+{
+    test_smbios_type8_common(MACHINE_PC,
+        ".pc_smbios_type8", true);
+}
+
+static void test_acpi_pc_smbios_type8_compat(void)
+{
+    test_smbios_type8_common("pc-i440fx-11.1",
+        ".pc_smbios_type8_compat", false);
+}
+
 static void test_oem_fields(test_data *data)
 {
     int i;
@@ -2760,6 +2820,10 @@ int main(int argc, char *argv[])
                            test_acpi_pc_smbios_options);
             qtest_add_func("acpi/piix4/smbios-blob",
                            test_acpi_pc_smbios_blob);
+            qtest_add_func("acpi/piix4/smbios-type8",
+                           test_acpi_pc_smbios_type8);
+            qtest_add_func("acpi/piix4/smbios-type8-compat",
+                           test_acpi_pc_smbios_type8_compat);
             qtest_add_func("acpi/piix4/smbios-legacy",
                            test_acpi_isapc_smbios_legacy);
         }
@@ -2828,6 +2892,10 @@ int main(int argc, char *argv[])
             qtest_add_func("acpi/q35/cxl", test_acpi_q35_cxl);
 #endif
             qtest_add_func("acpi/q35/slic", test_acpi_q35_slic);
+            qtest_add_func("acpi/q35/smbios-type8",
+                test_acpi_q35_smbios_type8);
+            qtest_add_func("acpi/q35/smbios-type8-compat",
+                test_acpi_q35_smbios_type8_compat);
         }
         if (qtest_has_machine("microvm")) {
             qtest_add_func("acpi/microvm", test_acpi_microvm_tcg);
-- 
2.39.5 (Apple Git-154)



      parent reply	other threads:[~2026-05-23 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-23  3:41 [PATCH 0/3] hw/smbios: Add dedicated handle range for Type 8 tables Alexander Gryanko
2026-05-23  3:41 ` [PATCH 1/3] hw/i386/pc: Introduce 11.2 machine type for SMBIOS type 8 base migration Alexander Gryanko
2026-05-23  3:41 ` [PATCH 2/3] hw/smbios: Add dedicated handle range for Type 8 tables Alexander Gryanko
2026-05-23  3:41 ` Alexander Gryanko [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260523034158.57487-4-xpahos@gmail.com \
    --to=xpahos@gmail.com \
    --cc=anisinha@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhao1.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.