[CRIU] [PATCHv2 8/9] zdtm/x86: Add a mxcsr preserving fpu test
Dmitry Safonov
dima at arista.com
Wed Feb 7 15:48:53 MSK 2018
It helped a bit to debug Skylake ptrace() bug, let's put it in.
Signed-off-by: Dmitry Safonov <dima at arista.com>
---
test/zdtm/static/Makefile | 1 +
test/zdtm/static/fpu02.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 89 insertions(+)
create mode 100644 test/zdtm/static/fpu02.c
diff --git a/test/zdtm/static/Makefile b/test/zdtm/static/Makefile
index 99a57033f861..fd333ee0ba9a 100644
--- a/test/zdtm/static/Makefile
+++ b/test/zdtm/static/Makefile
@@ -13,6 +13,7 @@ TST_NOFILE := \
zombie01 \
fpu00 \
fpu01 \
+ fpu02 \
arm-neon00 \
futex \
futex-rl \
diff --git a/test/zdtm/static/fpu02.c b/test/zdtm/static/fpu02.c
new file mode 100644
index 000000000000..660fc7d59e71
--- /dev/null
+++ b/test/zdtm/static/fpu02.c
@@ -0,0 +1,88 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+
+#include "zdtmtst.h"
+
+#if defined(__i386__) || defined(__x86_64__)
+
+#include "cpuid.h"
+
+const char *test_doc = "Test preserve of mxcsr in FPU";
+const char *test_author = "Dmitry Safonov <0x7f454c46 at gmail.com>";
+
+static int verify_cpu(void)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ /* Do we have xsave? */
+ cpuid(1, &eax, &ebx, &ecx, &edx);
+ if (!(ecx & (1u << 27)))
+ return -1;
+
+ /* Is YMM here? */
+ cpuid_count(0xd, 0, &eax, &ebx, &ecx, &edx);
+ if ((eax & (0x4)) != 0x4)
+ return -1;
+
+ return 0;
+}
+
+#define __aligned __attribute__((aligned(64)))
+
+static int fpu_test(void)
+{
+ uint32_t before, after;
+
+ asm volatile("stmxcsr %0\n"
+ : "+m"(before));
+
+ test_daemon();
+ test_waitsig();
+
+ asm volatile("stmxcsr %0\n"
+ : "+m"(after));
+
+ test_msg("before: %x, after: %x\n", before, after);
+
+ return (before != after);
+}
+
+static int bare_run(void)
+{
+ test_msg("Your cpu doesn't support ymm registers, skipping\n");
+
+ test_daemon();
+ test_waitsig();
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ int ret = 0;
+
+ test_init(argc, argv);
+
+ ret = verify_cpu() ? bare_run() : fpu_test();
+
+ if (!ret)
+ pass();
+ else
+ fail();
+
+ return 0;
+}
+
+#else
+
+int main(int argc, char *argv[])
+{
+ test_init(argc, argv);
+ skip("Unsupported arch");
+ return 0;
+}
+
+#endif
--
2.13.6
More information about the CRIU
mailing list