Commit Graph

3956 Commits

Author SHA1 Message Date
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
kamil 5a3fb2eb52 Bump the number of threads in LWP t_ptrace_wait*() tests from to 100
This is a torture, but on purpose to catch LWP_CREATED and LWP_EXITED bugs.
The threads do nothing other than calling sched_yield() in a loop.

MAXLWP is now defined to 2048 on all ports.

This change effects the following tests:

 - trace_thread_nolwpevents
 - trace_thread_lwpexit
 - trace_thread_lwpcreate
 - trace_thread_lwpcreate_and_exit
2019-10-13 04:00:12 +00:00
mrg ad0c4b353e use memcpy() for non C-strings. 2019-10-06 01:05:36 +00:00
mrg 662908cac2 sprintf->snprintf 2019-10-05 22:06:29 +00:00
christos 6b7001662d Add tests for escape sequences. 2019-10-05 20:24:16 +00:00
jhigh c7ab523edc adding full scheme comparison to libcrypt:crypt and pwhash tests 2019-10-05 18:06:16 +00:00
mrg a83f6c1317 msg:
avoid passing the same pointer in multiple arguments for restrict
marked arguments:
- sigaction() wants separate in/out
- use memmove() not memcpy() for overlapping regions (this may fix
  a real bug in nvi -- but it seems unlikely)
- select() wants separate read/write/except
- sigprocmask() wants separate set/oset
2019-10-04 09:01:59 +00:00
kamil 081796c351 Remove ATF t_ptrace_wait test suspend1
The tests verifies that a thread can be suspended by a debugger and later
resumed by a tracee.

This is an unwanted behavior and will be fixed soon.
2019-10-02 23:15:09 +00:00
kamil 1f257ef9aa Merge PT_GET_PROCESS_STATE checks into traceme_raise ATF ptrace tests
Assert that PT_GET_PROCESS_STATE for !child and !lwp events returns
non-error and zeroed struct ptrace_state.

These checks are not really special to traceme_raise, it's just an
opportunity to reuse them in an existing tests without writing a dedicated
one.

This behavior is needed to maintain in 3rd party software (GDB).
2019-10-01 22:26:38 +00:00
kamil b0c977dcb4 Add a few static asserts in t_ptrace_wait.c for conditions that must be kept
Assert that ptrace_state and siginfo_t's _ptrace_state are synchronized.
2019-10-01 21:13:30 +00:00
mrg 21303c93e9 convert HAVE_GCC == 7 to HAVE_GCC >= 7. 2019-09-29 23:44:58 +00:00
christos 38a0431bfa Restore binary compatibility by using the statvfs90 structure internally. 2019-09-23 12:00:57 +00:00
kre f77bb6aeed Initialise the sometvs array of struct timeval that is to be used to
validate that utimes() cannot update the times of a file on a read only
filesystem.   The values are never actually used, but since
	src/sys/kern/vfs_syscalls.c 1.535
they are validated for sanity, and the syscall returns EINVAL if the
values passed are invalid (tv_usec <0 or >= 1000000).  If that happens
we don't get as far as the test which produces the EROFS that is expected
from this test (these tests - one for each filesystem type).

So, init the timeval structs (just to 0, the values will still not be
used) so that the EINVAL doesn't bite us before we're eaten by the EROFS
which is the way we're supposed to die.

If the syscall API args were labelled as "const" the compiler probably
would have caught the use of uninit'd vars and complained much sooner.
2019-09-21 14:25:42 +00:00
blymn e275f7f7db Rototill to add complex character support:
- Add cchar command to director test language to allow a complex character
  to be defined and passed to the slave.
- Removed the distinction between args and returns internally to prevent
  confusing the two which leads to errors and/or crashes.
- Converted mutt_test to use the new cchar definition and fixed the
  check files for the test.
2019-09-19 11:31:57 +00:00
christos 3f24065918 Remove the incomplete define. 2019-09-15 23:39:13 +00:00
christos 7d2cda35f1 Add tests for fexecve(2) 2019-09-15 16:53:58 +00:00