diff mbox series

[PULL,kvm-unit-tests,05/10] arm64: micro-bench: ioremap userspace_emulated_addr

Message ID 20210517143900.747013-6-drjones@redhat.com (mailing list archive)
State New, archived
Headers show
Series [PULL,kvm-unit-tests,01/10] configure: arm: Replace --vmm with --target | expand

Commit Message

Andrew Jones May 17, 2021, 2:38 p.m. UTC
We should explicitly ioremap the userspace emulated address used
in the benchmark.

Reported-by: Alexandru Elisei <alexandru.elisei@arm.com>
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Tested-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 arm/micro-bench.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/arm/micro-bench.c b/arm/micro-bench.c
index 95c418c10eb4..8e1d4abdf8a8 100644
--- a/arm/micro-bench.c
+++ b/arm/micro-bench.c
@@ -273,7 +273,9 @@  static void hvc_exec(void)
 	asm volatile("mov w0, #0x4b000000; hvc #0" ::: "w0");
 }
 
-static void mmio_read_user_exec(void)
+static void *userspace_emulated_addr;
+
+static bool mmio_read_user_prep(void)
 {
 	/*
 	 * FIXME: Read device-id in virtio mmio here in order to
@@ -281,8 +283,12 @@  static void mmio_read_user_exec(void)
 	 * updated in the future if any relevant changes in QEMU
 	 * test-dev are made.
 	 */
-	void *userspace_emulated_addr = (void*)0x0a000008;
+	userspace_emulated_addr = (void*)ioremap(0x0a000008, sizeof(u32));
+	return true;
+}
 
+static void mmio_read_user_exec(void)
+{
 	readl(userspace_emulated_addr);
 }
 
@@ -309,14 +315,14 @@  struct exit_test {
 };
 
 static struct exit_test tests[] = {
-	{"hvc",			NULL,		hvc_exec,		NULL,		65536,		true},
-	{"mmio_read_user",	NULL,		mmio_read_user_exec,	NULL,		65536,		true},
-	{"mmio_read_vgic",	NULL,		mmio_read_vgic_exec,	NULL,		65536,		true},
-	{"eoi",			NULL,		eoi_exec,		NULL,		65536,		true},
-	{"ipi",			ipi_prep,	ipi_exec,		NULL,		65536,		true},
-	{"ipi_hw",		ipi_hw_prep,	ipi_exec,		NULL,		65536,		true},
-	{"lpi",			lpi_prep,	lpi_exec,		NULL,		65536,		true},
-	{"timer_10ms",		timer_prep,	timer_exec,		timer_post,	256,		true},
+	{"hvc",			NULL,			hvc_exec,		NULL,		65536,		true},
+	{"mmio_read_user",	mmio_read_user_prep,	mmio_read_user_exec,	NULL,		65536,		true},
+	{"mmio_read_vgic",	NULL,			mmio_read_vgic_exec,	NULL,		65536,		true},
+	{"eoi",			NULL,			eoi_exec,		NULL,		65536,		true},
+	{"ipi",			ipi_prep,		ipi_exec,		NULL,		65536,		true},
+	{"ipi_hw",		ipi_hw_prep,		ipi_exec,		NULL,		65536,		true},
+	{"lpi",			lpi_prep,		lpi_exec,		NULL,		65536,		true},
+	{"timer_10ms",		timer_prep,		timer_exec,		timer_post,	256,		true},
 };
 
 struct ns_time {