From: Vasilis Liaskovitis <vliaskov@gmail.com>
To: qemu-devel@nongnu.org
Cc: jan.kiszka@web.de, marcel.a@redhat.com, knut.omang@oracle.com,
Vasilis Liaskovitis <vliaskov@gmail.com>,
mst@redhat.com
Subject: [Qemu-devel] [PATCH v2] qtest/bios-tables: Add DMAR unit test on intel_iommu for q35
Date: Mon, 24 Nov 2014 14:37:19 +0100 [thread overview]
Message-ID: <1416836239-19314-1-git-send-email-vliaskov@gmail.com> (raw)
The test enables intel_iommu on q35, looks for and reads the DMAR table as well
as its only DRHC structure (for now), checking the header and checksums.
Signed-off-by: Vasilis Liaskovitis <vliaskov@gmail.com>
---
tests/bios-tables-test.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 9e4d205..93b4b3f 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -45,6 +45,8 @@ typedef struct {
AcpiRsdtDescriptorRev1 rsdt_table;
AcpiFadtDescriptorRev1 fadt_table;
AcpiFacsDescriptorRev1 facs_table;
+ AcpiTableDmar dmar_table;
+ AcpiDmarHardwareUnit drhd;
uint32_t *rsdt_tables_addr;
int rsdt_tables_nr;
GArray *tables;
@@ -371,6 +373,45 @@ static void test_acpi_dsdt_table(test_data *data)
g_array_append_val(data->tables, dsdt_table);
}
+static void test_acpi_dmar_table(test_data *data)
+{
+ AcpiTableDmar *dmar_table = &data->dmar_table;
+ AcpiDmarHardwareUnit *drhd = &data->drhd;
+ struct AcpiTableHeader *header = (struct AcpiTableHeader *) dmar_table;
+ uint32_t addr, signature_le;
+ bool found_dmar = false;
+ char signature_str[5] = {};
+ int i;
+
+ memset(dmar_table, 0, sizeof(*dmar_table));
+
+ /* look for DMAR signature in the tables, FADT comes first so we skip it */
+ for (i = 1; i < data->rsdt_tables_nr; i++) {
+ addr = data->rsdt_tables_addr[i];
+ ACPI_READ_TABLE_HEADER(dmar_table, addr);
+ signature_le = cpu_to_le32(header->signature);
+ memcpy(signature_str, &signature_le, 4);
+ if (!g_strcmp0(signature_str, "DMAR")) {
+ found_dmar = true;
+ break;
+ }
+ }
+ g_assert(found_dmar);
+ ACPI_READ_FIELD(dmar_table->host_address_width, addr);
+ ACPI_READ_FIELD(dmar_table->flags, addr);
+ ACPI_READ_ARRAY_PTR(dmar_table->reserved, 10, addr);
+
+ memset(drhd, 0, sizeof(*drhd));
+ ACPI_READ_FIELD(drhd->type, addr);
+ ACPI_READ_FIELD(drhd->length, addr);
+ ACPI_READ_FIELD(drhd->flags, addr);
+ ACPI_READ_FIELD(drhd->pci_segment, addr);
+ ACPI_READ_FIELD(drhd->address, addr);
+ g_assert(!acpi_checksum((uint8_t *)dmar_table, sizeof(AcpiTableDmar) +
+ drhd->length));
+
+}
+
static void test_acpi_tables(test_data *data)
{
int tables_nr = data->rsdt_tables_nr - 1; /* fadt is first */
@@ -747,6 +788,9 @@ static void test_acpi_one(const char *params, test_data *data)
test_acpi_fadt_table(data);
test_acpi_facs_table(data);
test_acpi_dsdt_table(data);
+ if (strstr(params, "iommu=on")) {
+ test_acpi_dmar_table(data);
+ }
test_acpi_tables(data);
if (iasl) {
@@ -779,7 +823,7 @@ static void test_acpi_tcg(void)
memset(&data, 0, sizeof(data));
data.machine = MACHINE_Q35;
- test_acpi_one("-machine q35,accel=tcg", &data);
+ test_acpi_one("-machine q35,accel=tcg,iommu=on", &data);
free_test_data(&data);
}
--
1.9.1
next reply other threads:[~2014-11-24 13:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-24 13:37 Vasilis Liaskovitis [this message]
2014-11-24 14:25 ` [Qemu-devel] [PATCH v2] qtest/bios-tables: Add DMAR unit test on intel_iommu for q35 Marcel Apfelbaum
2014-12-02 12:26 ` Vasilis Liaskovitis
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=1416836239-19314-1-git-send-email-vliaskov@gmail.com \
--to=vliaskov@gmail.com \
--cc=jan.kiszka@web.de \
--cc=knut.omang@oracle.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).