|
|
9ae3a8 |
From 473a279de264f7d56a41ac77aa9db4d783733f34 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Date: Sat, 11 Jan 2014 18:00:07 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 17/22] i440fx-test: verify firmware under 4G and 1M, both -bios and -pflash
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1389463208-6278-18-git-send-email-lersek@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56631
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH 17/18] i440fx-test: verify firmware under 4G and 1M, both -bios and -pflash
|
|
|
9ae3a8 |
Bugzilla: 1032346
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Amos Kong <akong@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Andrew Jones <drjones@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Check whether the firmware is not hidden by other memory regions.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Qemu is started in paused mode: it shouldn't try to interpret generated
|
|
|
9ae3a8 |
garbage.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 3bcc77ae9935c8c3d10f63492af81f1d7d99d492)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/i440fx-test.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++----
|
|
|
9ae3a8 |
1 file changed, 75 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/i440fx-test.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++----
|
|
|
9ae3a8 |
1 files changed, 75 insertions(+), 6 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/tests/i440fx-test.c b/tests/i440fx-test.c
|
|
|
9ae3a8 |
index b6e0cd3..fa3e3d6 100644
|
|
|
9ae3a8 |
--- a/tests/i440fx-test.c
|
|
|
9ae3a8 |
+++ b/tests/i440fx-test.c
|
|
|
9ae3a8 |
@@ -35,6 +35,11 @@ typedef struct TestData
|
|
|
9ae3a8 |
int num_cpus;
|
|
|
9ae3a8 |
} TestData;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+typedef struct FirmwareTestFixture {
|
|
|
9ae3a8 |
+ /* decides whether we're testing -bios or -pflash */
|
|
|
9ae3a8 |
+ bool is_bios;
|
|
|
9ae3a8 |
+} FirmwareTestFixture;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static QPCIBus *test_start_get_bus(const TestData *s)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
char *cmdline;
|
|
|
9ae3a8 |
@@ -278,6 +283,7 @@ static void test_i440fx_pam(gconstpointer opaque)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
#define BLOB_SIZE ((size_t)65536)
|
|
|
9ae3a8 |
+#define ISA_BIOS_MAXSZ ((size_t)(128 * 1024))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* Create a blob file, and return its absolute pathname as a dynamically
|
|
|
9ae3a8 |
* allocated string.
|
|
|
9ae3a8 |
@@ -326,23 +332,86 @@ static char *create_blob_file(void)
|
|
|
9ae3a8 |
return ret == -1 ? NULL : pathname;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-int main(int argc, char **argv)
|
|
|
9ae3a8 |
+static void test_i440fx_firmware(FirmwareTestFixture *fixture,
|
|
|
9ae3a8 |
+ gconstpointer user_data)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- char *fw_pathname;
|
|
|
9ae3a8 |
- TestData data;
|
|
|
9ae3a8 |
- int ret;
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- g_test_init(&argc, &argv, NULL);
|
|
|
9ae3a8 |
+ char *fw_pathname, *cmdline;
|
|
|
9ae3a8 |
+ uint8_t *buf;
|
|
|
9ae3a8 |
+ size_t i, isa_bios_size;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
fw_pathname = create_blob_file();
|
|
|
9ae3a8 |
g_assert(fw_pathname != NULL);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Better hope the user didn't put metacharacters in TMPDIR and co. */
|
|
|
9ae3a8 |
+ cmdline = g_strdup_printf("-S %s %s",
|
|
|
9ae3a8 |
+ fixture->is_bios ? "-bios" : "-pflash",
|
|
|
9ae3a8 |
+ fw_pathname);
|
|
|
9ae3a8 |
+ g_test_message("qemu cmdline: %s", cmdline);
|
|
|
9ae3a8 |
+ qtest_start(cmdline);
|
|
|
9ae3a8 |
+ g_free(cmdline);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Qemu has loaded the firmware (because qtest_start() only returns after
|
|
|
9ae3a8 |
+ * the QMP handshake completes). We must unlink the firmware blob right
|
|
|
9ae3a8 |
+ * here, because any assertion firing below would leak it in the
|
|
|
9ae3a8 |
+ * filesystem. This is also the reason why we recreate the blob every time
|
|
|
9ae3a8 |
+ * this function is invoked.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
unlink(fw_pathname);
|
|
|
9ae3a8 |
g_free(fw_pathname);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ /* check below 4G */
|
|
|
9ae3a8 |
+ buf = g_malloc0(BLOB_SIZE);
|
|
|
9ae3a8 |
+ memread(0x100000000ULL - BLOB_SIZE, buf, BLOB_SIZE);
|
|
|
9ae3a8 |
+ for (i = 0; i < BLOB_SIZE; ++i) {
|
|
|
9ae3a8 |
+ g_assert_cmphex(buf[i], ==, (uint8_t)i);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* check in ISA space too */
|
|
|
9ae3a8 |
+ memset(buf, 0, BLOB_SIZE);
|
|
|
9ae3a8 |
+ isa_bios_size = ISA_BIOS_MAXSZ < BLOB_SIZE ? ISA_BIOS_MAXSZ : BLOB_SIZE;
|
|
|
9ae3a8 |
+ memread(0x100000 - isa_bios_size, buf, isa_bios_size);
|
|
|
9ae3a8 |
+ for (i = 0; i < isa_bios_size; ++i) {
|
|
|
9ae3a8 |
+ g_assert_cmphex(buf[i], ==,
|
|
|
9ae3a8 |
+ (uint8_t)((BLOB_SIZE - isa_bios_size) + i));
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ g_free(buf);
|
|
|
9ae3a8 |
+ qtest_end();
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void add_firmware_test(const char *testpath,
|
|
|
9ae3a8 |
+ void (*setup_fixture)(FirmwareTestFixture *f,
|
|
|
9ae3a8 |
+ gconstpointer test_data))
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ g_test_add(testpath, FirmwareTestFixture, NULL, setup_fixture,
|
|
|
9ae3a8 |
+ test_i440fx_firmware, NULL);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void request_bios(FirmwareTestFixture *fixture,
|
|
|
9ae3a8 |
+ gconstpointer user_data)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ fixture->is_bios = true;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+static void request_pflash(FirmwareTestFixture *fixture,
|
|
|
9ae3a8 |
+ gconstpointer user_data)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ fixture->is_bios = false;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+int main(int argc, char **argv)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ TestData data;
|
|
|
9ae3a8 |
+ int ret;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ g_test_init(&argc, &argv, NULL);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
data.num_cpus = 1;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
g_test_add_data_func("/i440fx/defaults", &data, test_i440fx_defaults);
|
|
|
9ae3a8 |
g_test_add_data_func("/i440fx/pam", &data, test_i440fx_pam);
|
|
|
9ae3a8 |
+ add_firmware_test("/i440fx/firmware/bios", request_bios);
|
|
|
9ae3a8 |
+ add_firmware_test("/i440fx/firmware/pflash", request_pflash);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = g_test_run();
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|