Commit Graph

4171 Commits

Author SHA1 Message Date
christos 0dd6d756c6 factor out common code and set the path. 2020-04-01 01:49:26 +00:00
christos 2e16057d77 Enforce a standard path 2020-04-01 00:49:04 +00:00
christos 3763e8dd1d Some interfaces (gif) don't have a mac address... 2020-03-30 13:01:39 +00:00
isaki 1088ff9364 Add tests for poll(POLLIN) before read().
This affects only standalone test, not atf.
2020-03-26 13:43:10 +00:00
isaki 08c0ee5cd7 Sync with sys/dev/audio/audio.c rev1.65.
> Fix to start recording immediately when open() with READ mode is called.
This affects only standalone test, not atf.
2020-03-26 13:37:44 +00:00
isaki 05b122f3e6 Use exact match to search testname.
This didn't affect test results.
2020-03-25 13:07:04 +00:00
pgoyette 9c5430b66e These test cases should now succeed, after fixing rump kernel to handle
modules that establish their sysctls via SYSCTL_SETUP()
2020-03-21 04:50:21 +00:00
pgoyette 00ff0f5d11 Mark the swsensor tests "expected failure" since the rump world doesn't
seem to handle the SYSCTL_SETUP stuff.  PR kern/55088
2020-03-19 20:10:49 +00:00
ad 1912643ff9 Tweak the March 14th change to make page waits interlocked by pg->interlock.
Remove unneeded changes and only deal with the PQ_WANTED flag, to exclude
possible bugs.
2020-03-17 18:31:38 +00:00
roy a6837a9b93 tests: ndp_rtm: Check correct source address in RTA_AUTHOR
Fixes PR kern/55074.
2020-03-15 21:15:25 +00:00
martin e3d221ef2a Skip tests when we know there is not enough space available 2020-03-15 20:10:26 +00:00
martin 9fc99040ba Hardcode a check for ZFS and too little free space in workdir to skip
ZFS tests if the atf working directory is size restricted (ZFS has a
hardcoded minimal size of 64MB for a storage pool and 128 MB disk size).
2020-03-15 12:12:42 +00:00
martin b46551040d Skip tests where the old or the new image size seem to not fit into
the working directory.
2020-03-15 11:17:59 +00:00
martin 581b9627a8 Skip this test if the atf working directory has not enough space
for the created image.
2020-03-15 10:15:16 +00:00
ad 37049e7a04 Catch up with reality. 2020-03-14 20:25:46 +00:00
rillig cf957f51cb t_glob.c: clean up test code
In struct vfs_file, using an int as a boolean is an anachronism and has
been replaced with a single-character file type, like in ls(1).

Some other redundant test code has been removed as well since it was
either unreachable or existed only for performance reasons.
2020-03-13 23:27:54 +00:00
rillig afe826aa59 t_glob.c: add test cases for hidden directory and file
The existing test code was geared towards every little bit of
performance. It even duplicated the file definitions in vfs_stat in order
to avoid a few strcmp calls. This made the test code fragile. Therefore,
vfs_stat has been rewritten completely to not duplicate any information
from the vfs.

In vfs_stat, the returned st_mode is now more realistic. It had been 0
before. The file mode is only logged when it makes sense. In the ENOENT
case it is not logged anymore.

The debug logging for opendir/closedir now logs the same pointer, so that
the corresponding calls can be matched easily. Failed vfs_opendir calls
are logged as well, to get a more complete picture of which callbacks are
called.
2020-03-13 22:58:31 +00:00
rillig 518b6dae2f t_glob.c: use distinct names for test structures
Before, the structures and functions defined by the test used the same
prefix as the code to be tested. This made it difficult to draw a line
between these parts.
2020-03-13 21:44:25 +00:00
rillig 7bf961318e t_glob.c: move expected globbing result directly into the test cases
This makes the tests more self-contained. The example directory tree that
is common to all the tests is still defined elsewhere, but in the same
file. Setting up the example directory structure in each test would make
the tests even more independent and read.
2020-03-13 20:48:33 +00:00
martin 0c2085b2fd Fix typo 2020-03-12 18:08:54 +00:00
martin 77fd0cba8e bsize_torture: skip bigger page size tests if space in the database
directory is limited (numbers pulled out of thin air).
2020-03-12 14:10:59 +00:00
martin 2fd0a933ab btree_weird_page_split: set timeout to 900s, now my landisk tests have
a chance to complete this one.
2020-03-12 14:03:42 +00:00
martin a46096ef2b Bump timeout to 10m 2020-03-12 12:57:45 +00:00
roy 17da0e5463 tests: check RTA_AUTHOR in messages 2020-03-11 08:52:13 +00:00
christos a8d8f1c9d8 update expected result 2020-03-09 20:33:16 +00:00
christos 3fed5dae39 One more test from uwe. 2020-03-09 17:27:29 +00:00
mgorny 558ea2bcab PR standards/44921: Add errno consts for robust mutexes
Add the two missing errno.h constants: EOWNERDEAD and ENOTRECOVERABLE.
While technically they're used for robust mutexes which we do not
support at the moment, they are listed in POSIX and used by libc++.
While libc++ can be made to build without it, it just locally redefines
the values then, so we may as well define them globally.
2020-03-08 22:09:42 +00:00
mgorny 5fb02e28e8 Add tests for missing libc catalog entries 2020-03-08 22:08:46 +00:00
christos f3812c2b53 Add an ifdef test 2020-03-08 17:21:52 +00:00
martin b1f19796e0 Only inlcude fenv.h if __HAVE_FENV 2020-03-08 15:07:44 +00:00
nisimura 8cdadb314d address to ATF t_vlan failure. adapt ifmcstat(8) output format change. 2020-03-08 09:05:33 +00:00
kamil eef3936b89 Fix typo 2020-03-07 19:47:44 +00:00
christos 7a11b5a513 Try to fix the build. This is why all those inlines should really be in a
separate file as regular function. The code is too large and hard to manage
this way, and only increases in complexity as time goes by.
2020-03-07 14:53:14 +00:00
kamil 89a4acf72d Remove duplicated lines 2020-03-06 19:10:27 +00:00
kamil fe331b9d9e Add new ptrace(2) test file
t_ptrace_sigchld - for SIGCHLD handler + ptrace(2).

Right now a single test is enabled (raise(SIGKILL)) and marked as failed
as it never finishes as the child is never collected before exiting the
parent uninterested about its child (SA_NOCLDWAIT).
2020-03-06 18:32:35 +00:00
kamil b2c0a4b036 Add await_collected()
This functions waits for collecting a process.
2020-03-06 17:03:35 +00:00
kamil efc9362185 Move macros wrapping functions from msg.h into msg.h
This makes code reusing easier.
2020-03-06 14:06:56 +00:00
isaki 889e75ac54 Sync with sys/dev/audio/audio.c rev1.62.
> Restore backward compatibility with netbsd-7 audio.
2020-03-04 14:20:44 +00:00
kamil 1a795e44a3 Mark find_event_count() with __used 2020-03-03 17:09:22 +00:00
christos a587044e6f zfs needs rumpkern_sysproxy 2020-03-02 11:09:13 +00:00
isaki 37e454b408 Re-add -lrumpdev dropped in the previous commit. 2020-03-02 04:25:08 +00:00
christos 3e9309baa0 fix variable name 2020-03-01 20:24:07 +00:00
christos 638ad1a643 fix build by adding a Makefile.inc that chains up. 2020-03-01 20:19:54 +00:00
kamil bee75e2d31 Add new signal trap entry tests in t_ptrace_wait*
New tests:
 - syscall_signal_on_sce
 - syscall_detach_on_sce

The first one fails as a signal emitted to the child is caught by the
debugger.

The second one passes.
2020-03-01 18:22:00 +00:00
christos 0dc8cda9a3 Centralize the base rump libraries into a variable used by all the other
Makefiles so that we can make changes to it centrally as needed and have
less mess. Fixes the sun2 build that needs rumpvfs after librump after
the latest changes.
2020-03-01 18:08:12 +00:00
christos 43a5e20952 librump depends on vfs so add a dependency on for sun2. 2020-03-01 17:06:26 +00:00
kamil dcbba1fbc7 Add new test in t_ptrace_wait*
New test: syscall_killed_on_sce

Test passes correctly.
2020-02-24 23:46:45 +00:00
rin 4ecd76e535 0x%p --> %p for non-external codes. 2020-02-24 12:20:29 +00:00
ad d2a0ebb67a UVM locking changes, proposed on tech-kern:
- Change the lock on uvm_object, vm_amap and vm_anon to be a RW lock.
- Break v_interlock and vmobjlock apart.  v_interlock remains a mutex.
- Do partial PV list locking in the x86 pmap.  Others to follow later.
2020-02-23 15:46:38 +00:00
pgoyette ea561c44e3 Update the t_modctl test to ensure that static evcnts are added.
While here, remove the explicit call to sysctl_setup() routine,
since the module infrastructure already invokes such routines
automatically.
2020-02-22 19:54:34 +00:00
kamil 1706a0e6e8 Disable t_ptrace_wait* tests for MKSANITIZER/MKLIBCSANITIZER
A subset of tests is not compatible with the sanitizers.
2020-02-22 19:44:07 +00:00
kamil 3735bb21e5 Update t_siginfo.c build rules
Add logic for MKSANITIZER/MKLIBCSANITIZER checks.
2020-02-22 19:14:57 +00:00
kamil f40ba85057 Disable the t_siginfo test under MKSANITIZER / MKLIBCSANITIZER
Signal crash events are incompatible with sanitizers.
2020-02-22 19:09:51 +00:00
isaki a05df8ab92 Update AUDIO_SETINFO_channels test.
The kernel limits the number of channels that userland apps can set to
the number of channels supported by the hardware or less.
2020-02-22 05:53:19 +00:00
kamil 93226e2fbb Avoid undefined behavior in get_modstat_info
t_modctl.c:114:16, member access within misaligned address 0x71bf5bcede84
for type 'struct modstat_t'

t_modctl.c:116:13, load of misaligned address 0x7e81bc3c9104 for type
'struct modstat_t' which requires 8 byte alignment
2020-02-22 00:24:15 +00:00
kamil b216505454 Avoid undefined behavior in disabledstat
t_builtin.c:174:16, member access within misaligned address 0x741271c25004
for type 'struct modstat_t'

t_builtin.c:175:4, member access within misaligned address 0x741271c251c4
for type 'struct modstat_t'
2020-02-22 00:18:55 +00:00
kamil ea9be1b430 Mark division by 0 as expected in sigfpe_int
Disable ubsan instrumentation on the operation.
2020-02-21 22:25:50 +00:00
kamil 510d9ff8d5 Avoid undefined behavior in is_module_present()
t_fopen.c:339:18, member access within misaligned address 0x7f7ff7ebd004
for type 'modstat_t' (aka 'struct modstat') which requires 8 byte alignment
2020-02-21 22:14:59 +00:00
kamil 4fbe278b92 Refactor dbregs_dont_inherit_lwp()
Switch from native LWP calls to pthread(3) calls.
2020-02-20 23:57:16 +00:00
kamil 8eecffe079 Minor changes to t_ptrace_wait*
Add check for security.models.extensions.user_set_dbregs in the
concurrent event tests.

Use unconditionally atf_tc_skip(); as the test is racy.
2020-02-20 22:38:54 +00:00
ozaki-r 79945603f0 tests: abort if MAC address duplication found 2020-02-20 08:02:26 +00:00
ozaki-r e8f138ca5c tests: dump stats of an interface before destroying it 2020-02-20 07:58:19 +00:00
kamil f89602d104 Fix clang(1) build
Namespace a symbol that can be unused.
2020-02-19 17:13:00 +00:00
isaki da6e9a93eb Add tests.
AUDIO_SETINFO_channels
 AUDIO_SETINFO_sample_rate
 AUDIO_SETINFO_sample_rate_0
2020-02-18 12:11:26 +00:00
ozaki-r ccef126b54 tests: add missing ifconfig -w
This change mitigates PR kern/54897.
2020-02-17 08:46:10 +00:00
isaki 27995e7e3a Improve around {audioctl_,}open_multiuser.
- Make multiuser bool and remove newval.
- try_audioctl_open_multiuser() doesn't need multiuser argument.
2020-02-14 13:20:48 +00:00
christos ff10eaacc1 Instead of turning optimization off, use unique labels with %= (thanks joerg@) 2020-02-14 04:20:59 +00:00
tnn 8a068b7497 adjust r1.19; add clang equivalent of gcc specific attribute 2020-02-13 18:31:54 +00:00
tnn 8097da4b67 don't use variable 'newval' uninitialized when multiuser mode unchanged 2020-02-13 18:06:26 +00:00
mgorny 2e75d0ba6e Enable combined breakpoint, watchpoint and signal tests 2020-02-13 15:27:41 +00:00
mgorny a95d5cdb23 Extend concurrent events test to watchpoints 2020-02-13 15:27:25 +00:00
mgorny 58d307abe5 Extend concurrent events test to breakpoints
Add testing for concurrent breakpoint hits.  The code is currently
x86-specific but since it reuses most of the generic concurrent event
test code, it's put in t_ptrace_wait.c with arch-specific hooks.
2020-02-13 15:27:05 +00:00
mgorny 996324417a Include LWP events in concurrent event test
LWP events will be necessary when breakpoint/watchpoint support is added
to the test.  However, they also benefit us by testing whether TRAP_LWP
events do not break signal reporting.
2020-02-13 15:26:45 +00:00
mgorny d7515621ac Test whether signal handler is called in concurrent bombarding 2020-02-13 15:26:18 +00:00
mgorny 187584d869 Extend concurrent signal tests to pass signal back to the thread 2020-02-13 15:25:58 +00:00
mgorny 767bd35aa5 Generalize thread_concurrent_signals to a generic factory
Build thread_concurrent_signals on a generic parametrized
thread_concurrent_test() function.  At first, this permits adjusting
the number of running signal threads but in the followup commits
support for different concurrent events (breakpoints, watchpoints)
and different signal handling will be added.
2020-02-13 15:25:29 +00:00
kamil 35bacae748 Disable UBSan warnings for trigger_segv()
Dereferencing the NULL pointer is on purpose.
2020-02-13 13:38:44 +00:00
kamil 2805572094 Disable UBSan reports in trigger_fpe()
Division by 0 is on purpose.
2020-02-13 13:34:47 +00:00
christos f6da9e1679 Turn off optimization on a function which contains constant labels.
The optimizer splits it and we end up with 2 copies and duplicate symbols.
2020-02-13 02:53:46 +00:00
martin 830be2f838 Add sentinel to the testtable[] array. 2020-02-12 07:02:21 +00:00
isaki e758b536e1 Add ATF tests for audio(4).
91 passed test cases
    0 failed test cases.
    0 expected failed test cases.
    62 skipped test cases.

There are many skipped tests, because the test itself supports full-
duplex, half-duplex and uni-directional devices but pad(4) used in ATF
tests is uni-directional device.
2020-02-11 07:03:16 +00:00
riastradh 8d4c37e85f Mark compilation with -pg as xfail on aarch64.
XXX file a PR to xref
2020-02-11 06:26:19 +00:00
riastradh d78835f01e Test that fpu state is preserved by fork. 2020-02-11 03:15:10 +00:00
riastradh 51367c9b81 aarch64 doesn't trap integer division by zero either. 2020-02-11 03:11:42 +00:00
kamil c51b77c62e Rewrite the t_ptrace_wait resume1 test
Switch to pthread functions.
Rename to 'resume'.
Synchronize the threads with pthread barriers.
Avoid race in the test.

Test passes correctly.

Fixes PR bin/54893 by Andreas Gustafsson
2020-02-11 00:41:37 +00:00
riastradh 9a872c5926 Show errno on failure. 2020-02-10 16:51:48 +00:00
kamil c9fe095b51 Rename suspend2 to suspend_no_deadlock 2020-02-10 11:42:41 +00:00
kamil e601f31a6d O_SEARCH tests: expect revoke +x failure on NFS
Patch by Kyle Evans (FreeBSD)

PR misc/54946
2020-02-08 19:58:36 +00:00
kamil cc056601a4 Expand the -Wno-macro-redefined usage to MKLIBCSANITIZER
_REENTRANT can be redefined and this is considered as an error.
2020-02-08 00:11:18 +00:00
uwe b1de09dcc9 Fake terminfo should not depend on TOOL_TIC for native build.
Makes it possible to build this standalone with USETOOLS=never.
2020-02-07 22:05:16 +00:00
uwe 1bb403213a Fix typo in a comment. 2020-02-07 19:56:51 +00:00
martin a534083a51 Add a few O_SEARCH tests, currently only run on FreeBSD.
Patch from Kyle Evans.
2020-02-06 12:18:06 +00:00
kamil 4f90136b3e Refactor signal9 and signal10 tests in t_ptrace_wait*
Remove signal9 and signal10. Reimplement the idea of these test in new
trace_thread_lwpexit_masked_sigtrap, trace_thread_lwpcreate_masked_sigtrap
and trace_thread_lwpcreate_and_exit_masked_sigtrap.

This removes 2 tests directly using low-level lwp APIs.
2020-02-05 23:43:18 +00:00
martin 6d0c22e236 PR misc/54940: do not combine O_SEARCH with O_RDWR, from Kyle Evans. 2020-02-05 17:13:24 +00:00
martin 43ee572233 PR misc/54939: fix file descriptor leak, patch from Kyle Evans. 2020-02-05 08:52:46 +00:00
kamil 2d22f33331 Disable debug code 2020-02-04 21:34:47 +00:00
kamil 94d37b90a2 Add new ATF ptrace(2) test in t_ptrace_wait*
threads_and_exec - verify that the expected LWP events are reported for a
multithreaded process that calls execve(2).

Test passes.
2020-02-04 21:34:12 +00:00
kamil 9f8ca85981 Add new ATF tests for unrelated tracer in t_ptrace_wait*
New tests:
 - unrelated_tracer_posix_spawn_detach_spawner
 - unrelated_tracer_fork_detach_forker
 - unrelated_tracer_vfork_detach_vforker
 - unrelated_tracer_vfork_detach_vforkerdone
 - unrelated_tracer_posix_spawn_kill_spawner
 - unrelated_tracer_fork_kill_forker
 - unrelated_tracer_vfork_kill_vforker
 - unrelated_tracer_vfork_kill_vforkerdone

All tests pass.
2020-02-04 15:06:27 +00:00
christos 6183983cc1 hack for clang/powerpc 2020-01-30 00:42:58 +00:00
kamil 8265fdce60 Fix the t_join test
For pthread_attr_get_np() attr should be initialized prior to the call by
using pthread_attr_init(3). pthread_getattr_np() does this
automatically so switch to it.
2020-01-29 13:40:23 +00:00
kamil 6639a5abb4 Add new fork/vfork/posix_spawn ATF tests in t_ptrace_wait*
Add unrelated tracer variation of tests: fork1-16, vfork1-16,
posix_spawn1-16.

All tests pass.
2020-01-29 03:51:56 +00:00
martin 34c1cedf61 Bump timeout to 3600 - the libarchive tests take quite a while to
complete (on a nearly 1 GHz dual armv7 machine it takes more than 700s)
2020-01-28 18:18:32 +00:00
martin 968a2fe40d PR 54902: fix octal numbers accidently spelled as decimal. 2020-01-28 07:12:08 +00:00
skrll 5d55fed31a Don't print the pagesize it messes up atf-report 2020-01-24 08:45:16 +00:00
martin 9a9189223f Fix the build: access_regs_set_unaligned_pc_* tests depend on availability
of gpregs
2020-01-23 06:17:21 +00:00
kamil 7c40686451 Add new ATF tests in t_ptrace_wait*
New tests:
 - access_regs_set_unaligned_pc_0x1
 - access_regs_set_unaligned_pc_0x3
 - access_regs_set_unaligned_pc_0x7

The purpose of these tests is check whether unaligned PC can panic the
kernel. If there is a panic it is fine to return EINVAL on PT_SETREGS.
New tests check respectively pc |= 0x1, pc |= 0x3 and pc |= 0x7.

Inspired by https://marc.info/?l=openbsd-bugs&m=107558043319084&w=2

While there fix access_regs6 to really test PT_SETREGS.
2020-01-21 16:46:07 +00:00
christos d6c17dbb31 Fix static linking (sun2) 2020-01-19 17:36:57 +00:00
christos 63fc2f472b not require .d files for the build. 2020-01-18 15:16:47 +00:00
ryoon 968f5fa0dc Fix build. Three list.h files are required to generate .d files 2020-01-18 13:56:53 +00:00
christos ad61858a16 new tests for libarchive 2020-01-17 16:25:37 +00:00
christos 77da719c4b new tests 2020-01-17 16:24:03 +00:00
ad 2ddceed1d9 Hopefully fix some problems seen with MP support on non-x86, in particular
where curcpu() is defined as curlwp->l_cpu:

- mi_switch(): undo the ~2007ish optimisation to unlock curlwp before
  calling cpu_switchto().  It's not safe to let other actors mess with the
  LWP (in particular l->l_cpu) while it's still context switching.  This
  removes l->l_ctxswtch.

- Move the LP_RUNNING flag into l->l_flag and rename to LW_RUNNING since
  it's now covered by the LWP's lock.

- Ditch lwp_exit_switchaway() and just call mi_switch() instead.  Everything
  is in cache anyway so it wasn't buying much by trying to avoid saving old
  state.  This means cpu_switchto() will never be called with prevlwp ==
  NULL.

- Remove some KERNEL_LOCK handling which hasn't been needed for years.
2020-01-08 17:38:41 +00:00
mgorny b4d38fb000 Add tests for reading registers from x86 core dumps 2020-01-08 17:23:34 +00:00
mgorny 7d1a2cdc58 Combine x86 register tests into unified test function
Reduce the code duplication and improve maintainability of x86 register
tests by combining all of them to a single base function.
2020-01-08 17:23:15 +00:00
mgorny adb864df5e Fix alignment when reading core notes
Both desc and note header needs to be aligned.  Therefore, we need
to realign after skipping past desc as well.

While at it, fix the other alignment fix to use roundup() macro.
2020-01-08 17:22:40 +00:00
msaitoh a5effc3ce9 s/inital/initial/ 2019-12-27 09:25:57 +00:00
kamil 7dea4f94d7 Read TLS base pointer with _lwp_getprivate()
This avoid usage of fast versions that are mostly internal to RTLD.
2019-12-25 02:23:37 +00:00
kamil bd290c46da Define _RTLD_SOURCE in t_ptrace_wait.c
The __lwp_gettcb_fast() and __lwp_getprivate_fast() functions are
namespaced on a selection of ports.
2019-12-24 21:09:38 +00:00
kamil 4f79a48470 Introduce PT_LWPSTATUS + PT_LWPNEXT, obsolete PT_LWPINFO
PT_LWPINFO is a legacy ptrace(2) operation that was originally intended
to retrieve the thread (LWP) information inside a traced process.

It has a number of flaws and is confused with PT_LWPINFO from FreeBSD.

PT_LWPSTATUS and PT_LWPNEXT address the problems (shortly by: rename,
removal of pl_event) and introduces new features: signal context
(pl_sigpend, pl_sigmask), LWP name (pl_name), LWP TLS base address
(pl_private). The private pointer was so far missing information for
a debugger.

PT_LWPSTATUS@nnn is now shipped with core(5) files and contain LWP specific
information, so far missed in the core(5) files.

PT_LWPSTATUS retrieves LWP information for the prompted thread.
PT_LWPNEXT retrieves LWP information for the next thread, borrowing the
semantics from NetBSD specific PT_LWPINFO.

PT_LWPINFO is namespaced with __LEGACY_PT_LWPINFO and still available for
the foreseeable future, without plans of removing it.

Add ATF tests for PT_LWPSTATUS + PT_LWPNEXT.

Keep ATF tests for PT_LWPINFO.

Switch GDB to new API.

Proposed on tech-kern@.
2019-12-24 14:50:59 +00:00
macallan 58c590cd7c disable string op warnings for t_strcat
now this builds on macppc with gcc 8.3
from riastradh@
2019-12-19 19:19:28 +00:00
christos ea19b263f1 Adjust tests for 0 hex values printing 0 instead of 0x0 2019-12-08 17:37:16 +00:00
christos 91fabc4486 Fix broken tests in big endian machines. Internally field values are
stored as uint64_t/uintmax_t so printing them with %d on big endian
ends up being 0.
2019-12-06 19:28:11 +00:00
kamil 1b325ed182 Log PID.LWP in t_ptrace_wait* tests for enabled debug
This is useful for multithreaded test scenarios.
2019-12-06 01:09:50 +00:00
hikaru 068d6bf691 Add HMAC-SHA-{256,384,512} test cases. 2019-12-03 04:20:45 +00:00
riastradh d6cbc02da6 Adapt <sys/pslist.h> to use atomic_load/store_*.
Changes:

- membar_producer();
  *p = v;

    =>

  atomic_store_release(p, v);

  (Effectively like using membar_exit instead of membar_producer,
  which is what we should have been doing all along so that stores by
  the `reader' can't affect earlier loads by the writer, such as
  KASSERT(p->refcnt == 0) in the writer and atomic_inc(&p->refcnt) in
  the reader.)

- p = *pp;
  if (p != NULL) membar_datadep_consumer();

    =>

  p = atomic_load_consume(pp);

  (Only makes a difference on DEC Alpha.  As long as lists generally
  have at least one element, this is not likely to make a big
  difference, and keeps the code simpler and clearer.)

No other functional change intended.  While here, annotate each
synchronizing load and store with its counterpart in a comment.
2019-12-01 15:28:19 +00:00
maxv 6f40daa312 Several improvements. In particular, reduce CS.limit, because Intel CPUs
perform strict sanity checks, and the previous (too high) limit caused the
VM entry to fail.
2019-11-22 10:26:32 +00:00
kre 5bb52324f6 Add a missing ("quoting") '>' in an atf_fail error message string.
Since the tests don't (usually) fail no-one ever noticed the missing char.

That is, the "received this" and "expected this" strings were supposed
to appear in the output err message as "<<string>>" but one of those
closing '>' chars was missing.

No-one should ever notice this change in normal operation, as the tests
are not intended to fail.
2019-11-12 18:59:51 +00:00
kamil 84cacc6757 Rework thread_concurrent_signals and trace_thread_lwpcreate_and_exit
Change the code to remove the LWP id assumptions that broke after
src/sys/kern/kern_lwp.c r. 1.206.

Original code by <mgorny>, tested and tweaked by myself.
2019-11-12 18:18:04 +00:00
yamaguchi 0c3bbc580c atf: add test cases for MTU that is increased on SIOCSETVLAN
From t-kusaba@IIJ, thanks
2019-11-11 02:40:48 +00:00
joerg ed08d30824 Avoid warnings about tautological left shifts as conditional. 2019-10-28 18:10:22 +00:00
maxv a6418236ed Add the "nvmm" group, and make nvmm_init() public. Sent to tech-kern@ a few
days ago.
2019-10-27 07:08:15 +00:00
christos a33f2da334 - use accept4 instead of paccept for everyone.
- add test for accept preserving non-block
- comment on FreeBSD and Linux behavior.
2019-10-26 23:08:27 +00:00
maxv e6f32a5866 Three changes in libnvmm:
- Add 'mach' and 'vcpu' backpointers in the nvmm_io and nvmm_mem
   structures.

 - Rename 'nvmm_callbacks' to 'nvmm_assist_callbacks'.

 - Rename and migrate NVMM_MACH_CONF_CALLBACKS to NVMM_VCPU_CONF_CALLBACKS,
   it now becomes per-VCPU.
2019-10-23 12:02:55 +00:00
maxv f9fb7866ce Miscellaneous changes in NVMM, to address several inconsistencies and
issues in the libnvmm API.

 - Rename NVMM_CAPABILITY_VERSION to NVMM_KERN_VERSION, and check it in
   libnvmm. Introduce NVMM_USER_VERSION, for future use.

 - In libnvmm, open "/dev/nvmm" as read-only and with O_CLOEXEC. This is to
   avoid sharing the VMs with the children if the process forks. In the
   NVMM driver, force O_CLOEXEC on open().

 - Rename the following things for consistency:
       nvmm_exit*              -> nvmm_vcpu_exit*
       nvmm_event*             -> nvmm_vcpu_event*
       NVMM_EXIT_*             -> NVMM_VCPU_EXIT_*
       NVMM_EVENT_INTERRUPT_HW -> NVMM_VCPU_EVENT_INTR
       NVMM_EVENT_EXCEPTION    -> NVMM_VCPU_EVENT_EXCP
   Delete NVMM_EVENT_INTERRUPT_SW, unused already.

 - Slightly reorganize the MI/MD definitions, for internal clarity.

 - Split NVMM_VCPU_EXIT_MSR in two: NVMM_VCPU_EXIT_{RD,WR}MSR. Also provide
   separate u.rdmsr and u.wrmsr fields. This is more consistent with the
   other exit reasons.

 - Change the types of several variables:
       event.type                  enum -> u_int
       event.vector                uint64_t -> uint8_t
       exit.u.*msr.msr:            uint64_t -> uint32_t
       exit.u.io.type:             enum -> bool
       exit.u.io.seg:              int -> int8_t
       cap.arch.mxcsr_mask:        uint64_t -> uint32_t
       cap.arch.conf_cpuid_maxops: uint64_t -> uint32_t

 - Delete NVMM_VCPU_EXIT_MWAIT_COND, it is AMD-only and confusing, and we
   already intercept 'monitor' so it is never armed.

 - Introduce vmx_exit_insn() for NVMM-Intel, similar to svm_exit_insn().
   The 'npc' field wasn't getting filled properly during certain VMEXITs.

 - Introduce nvmm_vcpu_configure(). Similar to nvmm_machine_configure(),
   but as its name indicates, the configuration is per-VCPU and not per-VM.
   Migrate and rename NVMM_MACH_CONF_X86_CPUID to NVMM_VCPU_CONF_CPUID.
   This becomes per-VCPU, which makes more sense than per-VM.

 - Extend the NVMM_VCPU_CONF_CPUID conf to allow triggering VMEXITs on
   specific leaves. Until now we could only mask the leaves. An uint32_t
   is added in the structure:
	uint32_t mask:1;
	uint32_t exit:1;
	uint32_t rsvd:30;
   The two first bits select the desired behavior on the leaf. Specifying
   zero on both resets the leaf to the default behavior. The new
   NVMM_VCPU_EXIT_CPUID exit reason is added.
2019-10-23 07:01:11 +00:00
kamil a73248db21 Remove preprocessor switch TEST_LWP_ENABLED in t_ptrace_wait*
LWP tests are now enabled always and confirmed to be stable.
2019-10-21 18:36:08 +00:00
kamil eb8ea5d12d Remove preprocessor switch TEST_VFORK_ENABLED in t_ptrace_wait*
vfork(2) tests are now enabled always and confirmed to be stable.
2019-10-21 18:31:40 +00:00
mgorny 050caffe42 Fix a race condition when handling concurrent LWP signals and add a test
Fix a race condition that caused PT_GET_SIGINFO to return incorrect
information when multiple signals were delivered concurrently
to different LWPs.  Add a regression test that verifies that when 50
threads concurrently use pthread_kill() on themselves, the debugger
receives all signals with correct information.

The kernel uses separate signal queues for each LWP.  However,
the signal context used to implement PT_GET_SIGINFO is stored in 'struct
proc' and therefore common to all LWPs in the process.  Previously,
this member was filled in kpsignal2(), i.e. when the signal was sent.
This meant that if another LWP managed to send another signal
concurrently, the data was overwritten before the process was stopped.

As a result, PT_GET_SIGINFO did not report the correct LWP and signal
(it could even report a different signal than wait()).  This can be
quite reliably reproduced with the number of 20 LWPs, however it can
also occur with 10.

This patch moves setting of signal context to issignal(), just before
the process is actually stopped.  The data is taken from per-LWP
or per-process signal queue.  The added test confirms that the debugger
correctly receives all signals, and PT_GET_SIGINFO reports both correct
LWP and signal number.

Reviewed by kamil.
2019-10-21 17:07:00 +00:00
christos d35ed14f2a opening a symlink with O_NOFOLLOW is expected to fail. 2019-10-20 16:02:11 +00:00
ozaki-r 3cb3151cb2 tests: add tests for the validateion of net.inet6.ip6.temppltime 2019-10-16 07:42:22 +00:00
jhigh ab00eaeb2d added test cases
invalid version specification
	salt too short
2019-10-14 14:48:48 +00:00
jhigh b640afc213 added versioning tests for argon2 2019-10-14 14:37:31 +00:00
maxv c496a7b118 Implement XCHG, add associated tests, and add comments to explain. With
this in place the Windows 95 installer completes successfuly.

Part of PR/54611.
2019-10-14 10:39:24 +00:00
jhigh 3f4bc82592 removed incorrectly added file 2019-10-14 06:40:40 +00:00
jhigh 499c4e53b1 adding argon2 tests 2019-10-14 03:47:19 +00:00
christos 85f5895969 add missing initializer 2019-10-14 01:15:32 +00:00
maxv 416eaf02dc Fix incorrect parsing: the R/M field uses a special GPR map when the
address size is 16 bits, regardless of the actual operating mode. With
this special map there can be two registers referenced at once, and
also disp16-only.

Implement this special behavior, and add associated tests. While here
simplify a few things.

With this in place, the Windows 95 installer initializes correctly.

Part of PR/54611.
2019-10-13 17:32:15 +00:00
kamil bec2cbec70 Fix race in t_ptrace_wait* LWP tests
Increment the done variable under a mutex. This variable was updated
non-atomically and sometimes not reaching the expected treshold.
2019-10-13 09:42:15 +00:00
mrg 4e545ef793 ifr_name is nul terminated. make it so. 2019-10-13 07:46:16 +00:00
mrg de11d87641 introduce some common variables for use in GCC warning disables:
GCC_NO_FORMAT_TRUNCATION    -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION  -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW    -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE   -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints.  many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
2019-10-13 07:28:04 +00:00
kamil 1f5d3e8c5d Enable TEST_LWP_ENABLED in t_ptrace_wait*
The LWP events (created, exited) are now reliable in my local tests.

PR kern/51420
PR kern/51995
2019-10-13 04:05:39 +00:00