summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/docker/dockerfiles/fedora-win32-cross.docker1
-rw-r--r--tests/docker/dockerfiles/fedora-win64-cross.docker1
-rw-r--r--tests/qtest/fuzz-sdcard-test.c36
-rw-r--r--tests/qtest/migration-test.c5
-rw-r--r--tests/tcg/s390x/Makefile.target2
-rw-r--r--tests/tcg/s390x/trap.c102
6 files changed, 144 insertions, 3 deletions
diff --git a/tests/docker/dockerfiles/fedora-win32-cross.docker b/tests/docker/dockerfiles/fedora-win32-cross.docker
index 5a03e1af43..aad39dd97f 100644
--- a/tests/docker/dockerfiles/fedora-win32-cross.docker
+++ b/tests/docker/dockerfiles/fedora-win32-cross.docker
@@ -23,6 +23,7 @@ ENV PACKAGES \
mingw32-libjpeg-turbo \
mingw32-libpng \
mingw32-libtasn1 \
+ mingw32-libusbx \
mingw32-nettle \
mingw32-nsis \
mingw32-pixman \
diff --git a/tests/docker/dockerfiles/fedora-win64-cross.docker b/tests/docker/dockerfiles/fedora-win64-cross.docker
index d3f13666e8..9a224a619b 100644
--- a/tests/docker/dockerfiles/fedora-win64-cross.docker
+++ b/tests/docker/dockerfiles/fedora-win64-cross.docker
@@ -23,6 +23,7 @@ ENV PACKAGES \
mingw64-libjpeg-turbo \
mingw64-libpng \
mingw64-libtasn1 \
+ mingw64-libusbx \
mingw64-pixman \
mingw64-pkg-config \
perl \
diff --git a/tests/qtest/fuzz-sdcard-test.c b/tests/qtest/fuzz-sdcard-test.c
index 96602eac7e..ae14305344 100644
--- a/tests/qtest/fuzz-sdcard-test.c
+++ b/tests/qtest/fuzz-sdcard-test.c
@@ -52,6 +52,41 @@ static void oss_fuzz_29225(void)
qtest_quit(s);
}
+/*
+ * https://gitlab.com/qemu-project/qemu/-/issues/495
+ * Used to trigger:
+ * Assertion `wpnum < sd->wpgrps_size' failed.
+ */
+static void oss_fuzz_36217(void)
+{
+ QTestState *s;
+
+ s = qtest_init(" -display none -m 32 -nodefaults -nographic"
+ " -device sdhci-pci,sd-spec-version=3 "
+ "-device sd-card,drive=d0 "
+ "-drive if=none,index=0,file=null-co://,format=raw,id=d0");
+
+ qtest_outl(s, 0xcf8, 0x80001010);
+ qtest_outl(s, 0xcfc, 0xe0000000);
+ qtest_outl(s, 0xcf8, 0x80001004);
+ qtest_outw(s, 0xcfc, 0x02);
+ qtest_bufwrite(s, 0xe000002c, "\x05", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x37", 0x1);
+ qtest_bufwrite(s, 0xe000000a, "\x01", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x29", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x02", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x03", 0x1);
+ qtest_bufwrite(s, 0xe0000005, "\x01", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x06", 0x1);
+ qtest_bufwrite(s, 0xe000000c, "\x05", 0x1);
+ qtest_bufwrite(s, 0xe000000e, "\x20", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x08", 0x1);
+ qtest_bufwrite(s, 0xe000000b, "\x3d", 0x1);
+ qtest_bufwrite(s, 0xe000000f, "\x1e", 0x1);
+
+ qtest_quit(s);
+}
+
int main(int argc, char **argv)
{
const char *arch = qtest_get_arch();
@@ -60,6 +95,7 @@ int main(int argc, char **argv)
if (strcmp(arch, "i386") == 0) {
qtest_add_func("fuzz/sdcard/oss_fuzz_29225", oss_fuzz_29225);
+ qtest_add_func("fuzz/sdcard/oss_fuzz_36217", oss_fuzz_36217);
}
return g_test_run();
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index 1e8b7784ef..cc5e83d98a 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -27,7 +27,8 @@
#include "migration-helpers.h"
#include "tests/migration/migration-test.h"
-#if defined(__linux__)
+/* For dirty ring test; so far only x86_64 is supported */
+#if defined(__linux__) && defined(HOST_X86_64)
#include "linux/kvm.h"
#endif
@@ -1395,7 +1396,7 @@ static void test_multifd_tcp_cancel(void)
static bool kvm_dirty_ring_supported(void)
{
-#if defined(__linux__)
+#if defined(__linux__) && defined(HOST_X86_64)
int ret, kvm_fd = open("/dev/kvm", O_RDONLY);
if (kvm_fd < 0) {
diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
index 5d3de1b27a..bd084c7840 100644
--- a/tests/tcg/s390x/Makefile.target
+++ b/tests/tcg/s390x/Makefile.target
@@ -8,4 +8,4 @@ TESTS+=exrl-trtr
TESTS+=pack
TESTS+=mvo
TESTS+=mvc
-
+TESTS+=trap
diff --git a/tests/tcg/s390x/trap.c b/tests/tcg/s390x/trap.c
new file mode 100644
index 0000000000..d4c61c7f52
--- /dev/null
+++ b/tests/tcg/s390x/trap.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright 2021 IBM Corp.
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or (at
+ * your option) any later version. See the COPYING file in the top-level
+ * directory.
+ */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <signal.h>
+
+static void error1(const char *filename, int line, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ fprintf(stderr, "%s:%d: ", filename, line);
+ vfprintf(stderr, fmt, ap);
+ fprintf(stderr, "\n");
+ va_end(ap);
+ exit(1);
+}
+
+static int __chk_error(const char *filename, int line, int ret)
+{
+ if (ret < 0) {
+ error1(filename, line, "%m (ret=%d, errno=%d/%s)",
+ ret, errno, strerror(errno));
+ }
+ return ret;
+}
+
+#define error(fmt, ...) error1(__FILE__, __LINE__, fmt, ## __VA_ARGS__)
+
+#define chk_error(ret) __chk_error(__FILE__, __LINE__, (ret))
+
+int sigfpe_count;
+int sigill_count;
+
+static void sig_handler(int sig, siginfo_t *si, void *puc)
+{
+ if (sig == SIGFPE) {
+ if (si->si_code != 0) {
+ error("unexpected si_code: 0x%x != 0", si->si_code);
+ }
+ ++sigfpe_count;
+ return;
+ }
+
+ if (sig == SIGILL) {
+ ++sigill_count;
+ return;
+ }
+
+ error("unexpected signal 0x%x\n", sig);
+}
+
+int main(int argc, char **argv)
+{
+ sigfpe_count = sigill_count = 0;
+
+ struct sigaction act;
+
+ /* Set up SIG handler */
+ act.sa_sigaction = sig_handler;
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = SA_SIGINFO;
+ chk_error(sigaction(SIGFPE, &act, NULL));
+ chk_error(sigaction(SIGILL, &act, NULL));
+
+ uint64_t z = 0x0ull;
+ uint64_t lz = 0xffffffffffffffffull;
+ asm volatile (
+ "lg %%r13,%[lz]\n"
+ "cgitne %%r13,0\n" /* SIGFPE */
+ "lg %%r13,%[z]\n"
+ "cgitne %%r13,0\n" /* no trap */
+ "nopr\n"
+ "lg %%r13,%[lz]\n"
+ "citne %%r13,0\n" /* SIGFPE */
+ "lg %%r13,%[z]\n"
+ "citne %%r13,0\n" /* no trap */
+ "nopr\n"
+ :
+ : [z] "m" (z), [lz] "m" (lz)
+ : "memory", "r13");
+
+ if (sigfpe_count != 2) {
+ error("unexpected SIGFPE count: %d != 2", sigfpe_count);
+ }
+ if (sigill_count != 0) {
+ error("unexpected SIGILL count: %d != 0", sigill_count);
+ }
+
+ printf("PASS\n");
+ return 0;
+}