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.
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.
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.
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.
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.
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).
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.
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.
- 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.
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
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'
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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@.
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.
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.
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.
- 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.
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.
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.
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.
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."