Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add kernel/arch/x86 ATF tests for CPU Debug Registers for am...
details: https://anonhg.NetBSD.org/src/rev/47384d7f0e66
branches: trunk
changeset: 351667:47384d7f0e66
user: kamil <kamil%NetBSD.org@localhost>
date: Wed Feb 22 01:07:13 2017 +0000
description:
Add kernel/arch/x86 ATF tests for CPU Debug Registers for amd64 and i386
This moves kernel/arch/amd64 tests, the ones to be shared between amd64 and
i386, into kernel/arch/x86. This covers all Debug Register tests.
kernel/arch/amd64 is reduced to regs1
kernel/arch/i386 is reduced to regs1
kernel/arch/x86 tests:
- dbregs_print
- dbregs_preserve_dr0
- dbregs_preserve_dr1
- dbregs_preserve_dr2
- dbregs_preserve_dr3
- dbregs_preserve_dr0_yield
- dbregs_preserve_dr1_yield
- dbregs_preserve_dr2_yield
- dbregs_preserve_dr3_yield
- dbregs_preserve_dr0_continued
- dbregs_preserve_dr1_continued
- dbregs_preserve_dr2_continued
- dbregs_preserve_dr3_continued
- dbregs_dr0_trap_variable_writeonly_byte
- dbregs_dr1_trap_variable_writeonly_byte
- dbregs_dr2_trap_variable_writeonly_byte
- dbregs_dr3_trap_variable_writeonly_byte
- dbregs_dr0_trap_variable_writeonly_2bytes
- dbregs_dr1_trap_variable_writeonly_2bytes
- dbregs_dr2_trap_variable_writeonly_2bytes
- dbregs_dr3_trap_variable_writeonly_2bytes
- dbregs_dr0_trap_variable_writeonly_4bytes
- dbregs_dr1_trap_variable_writeonly_4bytes
- dbregs_dr2_trap_variable_writeonly_4bytes
- dbregs_dr3_trap_variable_writeonly_4bytes
- dbregs_dr0_trap_variable_readwrite_write_byte
- dbregs_dr1_trap_variable_readwrite_write_byte
- dbregs_dr2_trap_variable_readwrite_write_byte
- dbregs_dr3_trap_variable_readwrite_write_byte
- dbregs_dr0_trap_variable_readwrite_write_2bytes
- dbregs_dr1_trap_variable_readwrite_write_2bytes
- dbregs_dr2_trap_variable_readwrite_write_2bytes
- dbregs_dr3_trap_variable_readwrite_write_2bytes
- dbregs_dr0_trap_variable_readwrite_write_4bytes
- dbregs_dr1_trap_variable_readwrite_write_4bytes
- dbregs_dr2_trap_variable_readwrite_write_4bytes
- dbregs_dr3_trap_variable_readwrite_write_4bytes
- dbregs_dr0_trap_variable_readwrite_read_byte
- dbregs_dr1_trap_variable_readwrite_read_byte
- dbregs_dr2_trap_variable_readwrite_read_byte
- dbregs_dr3_trap_variable_readwrite_read_byte
- dbregs_dr0_trap_variable_readwrite_read_2bytes
- dbregs_dr1_trap_variable_readwrite_read_2bytes
- dbregs_dr2_trap_variable_readwrite_read_2bytes
- dbregs_dr3_trap_variable_readwrite_read_2bytes
- dbregs_dr0_trap_variable_readwrite_read_4bytes
- dbregs_dr1_trap_variable_readwrite_read_4bytes
- dbregs_dr2_trap_variable_readwrite_read_4bytes
- dbregs_dr3_trap_variable_readwrite_read_4bytes
- dbregs_dr0_trap_code
- dbregs_dr1_trap_code
- dbregs_dr2_trap_code
- dbregs_dr3_trap_code
- dbregs_dr0_dont_inherit_lwp
- dbregs_dr1_dont_inherit_lwp
- dbregs_dr2_dont_inherit_lwp
- dbregs_dr3_dont_inherit_lwp
- dbregs_dr6_dont_inherit_lwp
- dbregs_dr7_dont_inherit_lwp
- dbregs_dr0_dont_inherit_execve
- dbregs_dr1_dont_inherit_execve
- dbregs_dr2_dont_inherit_execve
- dbregs_dr3_dont_inherit_execve
- dbregs_dr6_dont_inherit_execve
- dbregs_dr7_dont_inherit_execve
Sponsored by <The NetBSD Foundation>
diffstat:
distrib/sets/lists/debug/md.amd64 | 8 +-
distrib/sets/lists/debug/md.i386 | 8 +-
distrib/sets/lists/tests/md.amd64 | 11 +
distrib/sets/lists/tests/md.i386 | 11 +
tests/kernel/arch/Makefile | 6 +-
tests/kernel/arch/amd64/t_ptrace_wait.c | 7243 +-----------------------------
tests/kernel/arch/x86/Makefile | 18 +
tests/kernel/arch/x86/Makefile.inc | 1 +
tests/kernel/arch/x86/t_ptrace_wait.c | 7412 ++++++++++++++++++++++++++++++
tests/kernel/arch/x86/t_ptrace_wait3.c | 30 +
tests/kernel/arch/x86/t_ptrace_wait4.c | 30 +
tests/kernel/arch/x86/t_ptrace_wait6.c | 30 +
tests/kernel/arch/x86/t_ptrace_waitid.c | 30 +
tests/kernel/arch/x86/t_ptrace_waitpid.c | 30 +
14 files changed, 7624 insertions(+), 7244 deletions(-)
diffs (truncated from 14976 to 300 lines):
diff -r 91ded731b660 -r 47384d7f0e66 distrib/sets/lists/debug/md.amd64
--- a/distrib/sets/lists/debug/md.amd64 Tue Feb 21 21:22:45 2017 +0000
+++ b/distrib/sets/lists/debug/md.amd64 Wed Feb 22 01:07:13 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.92 2016/12/29 12:13:34 wiz Exp $
+# $NetBSD: md.amd64,v 1.93 2017/02/22 01:07:13 kamil Exp $
./usr/lib/i386/12.202++_g.a comp-c-debuglib debuglib,compat,12.202xx
./usr/lib/i386/libi386_g.a comp-c-debuglib debuglib,compat
./usr/lib/i386/libiberty_g.a comp-obsolete obsolete
@@ -14,3 +14,9 @@
./usr/libdata/debug/usr/libexec/ld.elf_so-i386.debug comp-sys-debug debug,compat
./usr/libdata/debug/usr/sbin/acpidump.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/amldb.debug comp-sysutil-debug debug
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait3.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait4.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait6.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitid.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitpid.debug tests-kernel-tests debug,atf,compattestfile
diff -r 91ded731b660 -r 47384d7f0e66 distrib/sets/lists/debug/md.i386
--- a/distrib/sets/lists/debug/md.i386 Tue Feb 21 21:22:45 2017 +0000
+++ b/distrib/sets/lists/debug/md.i386 Wed Feb 22 01:07:13 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.9 2015/07/06 08:25:43 martin Exp $
+# $NetBSD: md.i386,v 1.10 2017/02/22 01:07:13 kamil Exp $
./usr/lib/libi386_g.a comp-c-debuglib debuglib
./usr/lib/libm387_g.a comp-c-debuglib debuglib
./usr/lib/libpmc_g.a comp-c-debuglib debuglib
@@ -17,3 +17,9 @@
./usr/libdata/debug/usr/sbin/bad144.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/ipwctl.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/ndiscvt.debug comp-sysutil-debug debug
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait3.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait4.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_wait6.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitid.debug tests-kernel-tests debug,atf,compattestfile
+./usr/libdata/debug/usr/tests/kernel/arch/x86/t_ptrace_waitpid.debug tests-kernel-tests debug,atf,compattestfile
diff -r 91ded731b660 -r 47384d7f0e66 distrib/sets/lists/tests/md.amd64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/tests/md.amd64 Wed Feb 22 01:07:13 2017 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: md.amd64,v 1.1 2017/02/22 01:07:13 kamil Exp $
+./usr/libdata/debug/usr/tests/kernel/arch/x86 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/Atffile tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/Kyuafile tests-kernel-tests compattestfile,atf,kyua
+./usr/tests/kernel/arch/x86/t_ptrace_wait tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait3 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait4 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait6 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_waitid tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_waitpid tests-kernel-tests compattestfile,atf
diff -r 91ded731b660 -r 47384d7f0e66 distrib/sets/lists/tests/md.i386
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/tests/md.i386 Wed Feb 22 01:07:13 2017 +0000
@@ -0,0 +1,11 @@
+# $NetBSD: md.i386,v 1.3 2017/02/22 01:07:13 kamil Exp $
+./usr/libdata/debug/usr/tests/kernel/arch/x86 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/Atffile tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/Kyuafile tests-kernel-tests compattestfile,atf,kyua
+./usr/tests/kernel/arch/x86/t_ptrace_wait tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait3 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait4 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_wait6 tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_waitid tests-kernel-tests compattestfile,atf
+./usr/tests/kernel/arch/x86/t_ptrace_waitpid tests-kernel-tests compattestfile,atf
diff -r 91ded731b660 -r 47384d7f0e66 tests/kernel/arch/Makefile
--- a/tests/kernel/arch/Makefile Tue Feb 21 21:22:45 2017 +0000
+++ b/tests/kernel/arch/Makefile Wed Feb 22 01:07:13 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2016/12/13 18:00:10 kamil Exp $
+# $NetBSD: Makefile,v 1.3 2017/02/22 01:07:13 kamil Exp $
NOMAN= # defined
@@ -14,4 +14,8 @@
TESTS_SUBDIRS+= i386
.endif
+.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
+TESTS_SUBDIRS+= x86
+.endif
+
.include <bsd.test.mk>
diff -r 91ded731b660 -r 47384d7f0e66 tests/kernel/arch/amd64/t_ptrace_wait.c
--- a/tests/kernel/arch/amd64/t_ptrace_wait.c Tue Feb 21 21:22:45 2017 +0000
+++ b/tests/kernel/arch/amd64/t_ptrace_wait.c Wed Feb 22 01:07:13 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.24 2017/02/21 08:40:16 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.25 2017/02/22 01:07:13 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.24 2017/02/21 08:40:16 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.25 2017/02/22 01:07:13 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -55,36 +55,6 @@
#include "../../t_ptrace_wait.h"
-union u {
- long raw;
- struct {
- long local_dr0_breakpoint : 1; /* 0 */
- long global_dr0_breakpoint : 1; /* 1 */
- long local_dr1_breakpoint : 1; /* 2 */
- long global_dr1_breakpoint : 1; /* 3 */
- long local_dr2_breakpoint : 1; /* 4 */
- long global_dr2_breakpoint : 1; /* 5 */
- long local_dr3_breakpoint : 1; /* 6 */
- long global_dr3_breakpoint : 1; /* 7 */
- long local_exact_breakpt : 1; /* 8 */
- long global_exact_breakpt : 1; /* 9 */
- long reserved_10 : 1; /* 10 */
- long rest_trans_memory : 1; /* 11 */
- long reserved_12 : 1; /* 12 */
- long general_detect_enable : 1; /* 13 */
- long reserved_14 : 1; /* 14 */
- long reserved_15 : 1; /* 15 */
- long condition_dr0 : 2; /* 16-17 */
- long len_dr0 : 2; /* 18-19 */
- long condition_dr1 : 2; /* 20-21 */
- long len_dr1 : 2; /* 22-23 */
- long condition_dr2 : 2; /* 24-25 */
- long len_dr2 : 2; /* 26-27 */
- long condition_dr3 : 2; /* 28-29 */
- long len_dr3 : 2; /* 30-31 */
- } bits;
-};
-
#if defined(HAVE_GPREGS)
ATF_TC(regs1);
ATF_TC_HEAD(regs1, tc)
@@ -168,7134 +138,6 @@
}
#endif
-#if defined(HAVE_DBREGS)
-ATF_TC(dbregs_print);
-ATF_TC_HEAD(dbregs_print, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Verify plain PT_GETDBREGS with printing Debug Registers");
-}
-
-ATF_TC_BODY(dbregs_print, tc)
-{
- const int exitval = 5;
- const int sigval = SIGSTOP;
- pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
- int status;
-#endif
- struct dbreg r;
- size_t i;
-
- printf("Before forking process PID=%d\n", getpid());
- ATF_REQUIRE((child = fork()) != -1);
- if (child == 0) {
- printf("Before calling PT_TRACE_ME from child %d\n", getpid());
- FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
- printf("Before raising %s from child\n", strsignal(sigval));
- FORKEE_ASSERT(raise(sigval) == 0);
-
- printf("Before exiting of the child process\n");
- _exit(exitval);
- }
- printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
- validate_status_stopped(status, sigval);
-
- printf("Call GETDBREGS for the child process\n");
- ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r, 0) != -1);
-
- printf("State of the debug registers:\n");
- for (i = 0; i < __arraycount(r.dr); i++)
- printf("r[%zu]=%#lx\n", i, r.dr[i]);
-
- printf("Before resuming the child process where it left off and "
- "without signal to be sent\n");
- ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
- validate_status_exited(status, exitval);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-#endif
-
-#if defined(HAVE_DBREGS)
-ATF_TC(dbregs_preserve_dr0);
-ATF_TC_HEAD(dbregs_preserve_dr0, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Verify that setting DR0 is preserved across ptrace(2) calls");
-}
-
-ATF_TC_BODY(dbregs_preserve_dr0, tc)
-{
- const int exitval = 5;
- const int sigval = SIGSTOP;
- pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
- int status;
-#endif
- struct dbreg r1;
- struct dbreg r2;
- size_t i;
- int watchme;
-
- printf("Before forking process PID=%d\n", getpid());
- ATF_REQUIRE((child = fork()) != -1);
- if (child == 0) {
- printf("Before calling PT_TRACE_ME from child %d\n", getpid());
- FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
- printf("Before raising %s from child\n", strsignal(sigval));
- FORKEE_ASSERT(raise(sigval) == 0);
-
- printf("Before exiting of the child process\n");
- _exit(exitval);
- }
- printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
- validate_status_stopped(status, sigval);
-
- printf("Call GETDBREGS for the child process (r1)\n");
- ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
-
- printf("State of the debug registers (r1):\n");
- for (i = 0; i < __arraycount(r1.dr); i++)
- printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
-
- r1.dr[0] = (long)(intptr_t)&watchme;
- printf("Set DR0 (r1.dr[0]) to new value %#lx\n", r1.dr[0]);
-
- printf("New state of the debug registers (r1):\n");
- for (i = 0; i < __arraycount(r1.dr); i++)
- printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
-
- printf("Call SETDBREGS for the child process (r1)\n");
- ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
-
- printf("Call GETDBREGS for the child process (r2)\n");
- ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
- printf("Assert that (r1) and (r2) are the same\n");
- ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
-
- printf("Before resuming the child process where it left off and "
- "without signal to be sent\n");
- ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
-
- validate_status_exited(status, exitval);
-
- printf("Before calling %s() for the child\n", TWAIT_FNAME);
- TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
-}
-#endif
-
-#if defined(HAVE_DBREGS)
-ATF_TC(dbregs_preserve_dr1);
-ATF_TC_HEAD(dbregs_preserve_dr1, tc)
-{
- atf_tc_set_md_var(tc, "descr",
- "Verify that setting DR1 is preserved across ptrace(2) calls");
-}
-
-ATF_TC_BODY(dbregs_preserve_dr1, tc)
-{
- const int exitval = 5;
- const int sigval = SIGSTOP;
- pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
- int status;
-#endif
- struct dbreg r1;
- struct dbreg r2;
- size_t i;
Home |
Main Index |
Thread Index |
Old Index