qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Alex Bennée" <alex.bennee@linaro.org>
To: peter.maydell@linaro.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	"open list:ARM TCG CPUs" <qemu-arm@nongnu.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	qemu-devel@nongnu.org
Subject: [PULL 12/17] tests/tcg: add simple commpage test case
Date: Tue,  9 Jun 2020 11:38:04 +0100	[thread overview]
Message-ID: <20200609103809.23443-13-alex.bennee@linaro.org> (raw)
In-Reply-To: <20200609103809.23443-1-alex.bennee@linaro.org>

The COMMPAGE are a number of kernel provided user-space routines for
32 bit ARM systems. Add a basic series of smoke tests to ensure it is
working as it should.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200605154929.26910-14-alex.bennee@linaro.org>

diff --git a/tests/tcg/arm/commpage.c b/tests/tcg/arm/commpage.c
new file mode 100644
index 00000000000..c76e70cb8bd
--- /dev/null
+++ b/tests/tcg/arm/commpage.c
@@ -0,0 +1,61 @@
+/*
+ * Verify the COMMPAGE emulation
+ *
+ * The ARM commpage is a set of user space helper functions provided
+ * by the kernel in an effort to ease portability of user space code
+ * between different CPUs with potentially different capabilities. It
+ * is a 32 bit invention and similar to the vdso segment in many ways.
+ *
+ * The ABI is documented in the Linux kernel:
+ *     Documentation/arm/kernel_userspace_helpers.rst
+ *
+ * Copyright (c) 2020 Linaro Ltd
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+
+#define ARM_COMMPAGE      (0xffff0f00u)
+#define ARM_KUSER_VERSION (*(int32_t *)(ARM_COMMPAGE + 0xfc))
+typedef void * (get_tls_fn)(void);
+#define ARM_KUSER_GET_TLS (*(get_tls_fn *)(ARM_COMMPAGE + 0xe0))
+typedef int (cmpxchg_fn)(int oldval, int newval, volatile int *ptr);
+#define ARM_KUSER_CMPXCHG (*(cmpxchg_fn *)(ARM_COMMPAGE + 0xc0))
+typedef void (dmb_fn)(void);
+#define ARM_KUSER_DMB (*(dmb_fn *)(ARM_COMMPAGE + 0xa0))
+typedef int (cmpxchg64_fn)(const int64_t *oldval,
+                           const int64_t *newval,
+                           volatile int64_t *ptr);
+#define ARM_KUSER_CMPXCHG64 (*(cmpxchg64_fn *)(ARM_COMMPAGE + 0x60))
+
+#define fail_unless(x)                                                  \
+    do {                                                                \
+        if (!(x)) {                                                     \
+            fprintf(stderr, "FAILED at %s:%d\n", __FILE__, __LINE__);   \
+            exit(EXIT_FAILURE);                                         \
+        }                                                               \
+    } while (0)
+
+
+int main(int argc, char *argv[argc])
+{
+    void *kuser_tls;
+    int val = 1;
+    const int64_t oldval = 1, newval = 2;
+    int64_t val64 = 1;
+
+    fail_unless(ARM_KUSER_VERSION == 0x5);
+    kuser_tls = ARM_KUSER_GET_TLS();
+    printf("TLS = %p\n", kuser_tls);
+    fail_unless(kuser_tls != 0);
+    fail_unless(ARM_KUSER_CMPXCHG(1, 2, &val) == 0);
+    printf("val = %d\n", val);
+    /* this is a crash test, not checking an actual barrier occurs */
+    ARM_KUSER_DMB();
+    fail_unless(ARM_KUSER_CMPXCHG64(&oldval, &newval, &val64) == 0);
+    printf("val64 = %lld\n", val64);
+    return 0;
+}
diff --git a/tests/tcg/arm/Makefile.target b/tests/tcg/arm/Makefile.target
index 11c39c601ea..3da09a38be7 100644
--- a/tests/tcg/arm/Makefile.target
+++ b/tests/tcg/arm/Makefile.target
@@ -68,6 +68,8 @@ run-semiconsole-arm: semiconsole-arm
 run-plugin-semiconsole-arm-with-%:
 	$(call skip-test, $<, "MANUAL ONLY")
 
+ARM_TESTS += commpage
+
 TESTS += $(ARM_TESTS)
 
 # On ARM Linux only supports 4k pages
-- 
2.20.1



  parent reply	other threads:[~2020-06-09 10:48 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-09 10:37 [PULL 00/17] testing and misc fixes Alex Bennée
2020-06-09 10:37 ` [PULL 01/17] qemu-plugin.h: add missing include <stddef.h> to define size_t Alex Bennée
2020-06-09 10:37 ` [PULL 02/17] scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header Alex Bennée
2020-06-09 10:37 ` [PULL 03/17] tests/plugin: correctly honour io_count Alex Bennée
2020-06-09 10:37 ` [PULL 04/17] exec: flush the whole TLB if a watchpoint crosses a page boundary Alex Bennée
2020-06-09 10:37 ` [PULL 05/17] .travis.yml: allow failure for unreliable hosts Alex Bennée
2020-06-09 10:37 ` [PULL 06/17] .shippable: temporaily disable some cross builds Alex Bennée
2020-06-09 10:37 ` [PULL 07/17] tests/docker: fix pre-requisite for debian-tricore-cross Alex Bennée
2020-06-09 10:38 ` [PULL 08/17] docker: update Ubuntu to 20.04 Alex Bennée
2020-06-09 10:38 ` [PULL 09/17] hw/virtio/vhost: re-factor vhost-section and allow DIRTY_MEMORY_CODE Alex Bennée
2020-06-09 10:38 ` [PULL 10/17] linux-user: provide fallback pgd_find_hole for bare chroots Alex Bennée
2020-06-09 10:38 ` [PULL 11/17] linux-user: deal with address wrap for ARM_COMMPAGE on 32 bit Alex Bennée
2020-06-09 10:38   ` [Bug 1880225] " Alex Bennée
2020-06-09 10:38 ` Alex Bennée [this message]
2020-06-09 10:38 ` [PULL 13/17] linux-user: detect overflow of MAP_FIXED mmap Alex Bennée
2020-06-09 10:38 ` [PULL 14/17] tests/docker: Remove flex/bison packages Alex Bennée
2020-06-09 10:38 ` [PULL 15/17] tests/vm: " Alex Bennée
2020-06-09 10:53   ` Claudio Fontana
2020-06-09 11:08     ` Alex Bennée
2020-06-09 10:38 ` [PULL 16/17] cirrus-ci: " Alex Bennée
2020-06-09 10:38 ` [PULL 17/17] scripts/coverity-scan: " Alex Bennée
2020-06-11 10:20 ` [PULL 00/17] testing and misc fixes Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2020-06-05 15:49 [PATCH v1 00/14] various fixes for next PR (testing, vhost, guest_base fixes) Alex Bennée
2020-06-05 15:49 ` [PATCH v1 01/14] qemu-plugin.h: add missing include <stddef.h> to define size_t Alex Bennée
2020-06-05 15:49 ` [PATCH v1 02/14] scripts/clean-includes: Mark 'qemu/qemu-plugin.h' as special header Alex Bennée
2020-06-05 15:49 ` [PATCH v1 03/14] tests/plugin: correctly honour io_count Alex Bennée
2020-06-05 15:49 ` [PATCH v1 04/14] exec: flush the whole TLB if a watchpoint crosses a page boundary Alex Bennée
2020-06-05 15:49 ` [PATCH v1 05/14] .travis.yml: allow failure for unreliable hosts Alex Bennée
2020-06-05 15:49 ` [PATCH v1 06/14] .shippable: temporaily disable some cross builds Alex Bennée
2020-06-05 16:12   ` Philippe Mathieu-Daudé
2020-06-05 15:49 ` [PATCH v1 07/14] iotests: 194: wait migration completion on target too Alex Bennée
2020-06-05 15:49 ` [PATCH v1 08/14] tests/docker: fix pre-requisite for debian-tricore-cross Alex Bennée
2020-06-05 15:49 ` [PATCH v1 09/14] docker: update Ubuntu to 20.04 Alex Bennée
2020-06-05 15:49 ` [PATCH v1 10/14] hw/virtio/vhost: re-factor vhost-section and allow DIRTY_MEMORY_CODE Alex Bennée
2020-06-05 15:49 ` [PATCH v1 11/14] linux-user: provide fallback pgd_find_hole for bare chroots Alex Bennée
2020-06-05 15:49 ` [PATCH v1 12/14] linux-user: deal with address wrap for ARM_COMMPAGE on 32 bit Alex Bennée
2020-06-05 15:49   ` [Bug 1880225] " Alex Bennée
2020-06-05 15:49 ` [PATCH v1 13/14] tests/tcg: add simple commpage test case Alex Bennée
2020-06-05 15:49 ` [PATCH v1 14/14] linux-user: detect overflow of MAP_FIXED mmap Alex Bennée
2020-06-05 16:16   ` Philippe Mathieu-Daudé
2020-06-05 15:54 ` [PATCH v1 00/14] various fixes for next PR (testing, vhost, guest_base fixes) Eric Blake
2020-06-05 17:46 ` no-reply
2020-06-07  6:55 ` Thomas Huth
2020-06-08 15:58   ` Alex Bennée
2020-05-27 10:05 [PATCH v1 0/3] some linux-user guest_base fixes Alex Bennée
2020-05-27 10:05 ` [PATCH v1 1/3] linux-user: provide fallback pgd_find_hole for bare chroots Alex Bennée
2020-06-02  0:37   ` Richard Henderson
2020-05-27 10:05 ` [PATCH v1 2/3] linux-user: deal with address wrap for ARM_COMMPAGE on 32 bit Alex Bennée
2020-05-27 10:05   ` [Bug 1880225] " Alex Bennée
2020-05-27 12:05   ` Aleksandar Markovic
2020-05-27 12:05     ` [Bug 1880225] " Aleksandar Markovic
2020-05-27 14:47     ` Aleksandar Markovic
2020-05-27 14:47       ` [Bug 1880225] " Aleksandar Markovic
2020-05-27 16:14       ` Alex Bennée
2020-05-27 16:14         ` [Bug 1880225] " Alex Bennée
2020-06-02  0:28   ` Richard Henderson
2020-06-05  9:45     ` Alex Bennée
2020-06-05  9:45       ` [Bug 1880225] " Alex Bennée
2020-06-05 10:24       ` Alex Bennée
2020-06-05 10:24         ` [Bug 1880225] " Alex Bennée
2020-05-27 10:05 ` [PATCH v1 3/3] tests/tcg: add simple commpage test case Alex Bennée
2020-06-02  0:40   ` Richard Henderson
2020-05-27 14:12 ` [PATCH v1 0/3] some linux-user guest_base fixes no-reply
2020-05-22 18:43 [Bug 1880225] [NEW] Emulation of some arm programs fail with "Assertion `have_guest_base' failed." Aleksandar Markovic
2020-05-22 19:18 ` Alex Bennée
2020-05-22 19:18   ` Alex Bennée
2020-05-22 19:27 ` [Bug 1880225] " Alex Bennée
2020-05-23  1:07 ` Aleksandar Markovic
2020-05-23  1:14 ` Aleksandar Markovic
2020-05-23  7:40   ` Alex Bennée
2020-05-23  7:40     ` Alex Bennée
2020-05-23  1:31 ` Aleksandar Markovic
2020-05-23  7:50 ` Alex Bennée
2020-05-23  7:52 ` Aleksandar Markovic
2020-05-23 10:14   ` Alex Bennée
2020-08-20 15:08 ` Thomas Huth

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=20200609103809.23443-13-alex.bennee@linaro.org \
    --to=alex.bennee@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).