Commit Graph

265646 Commits

Author SHA1 Message Date
maxv
65e39aee46 Reorder the functions, and constify setstate. No functional change. 2019-02-23 08:19:16 +00:00
kamil
5577155981 Fix build of kcov tests on CPUs without 64-bit atomics
Restrict the 64-bit atomics to ports defining __HAVE_ATOMIC64_OPS.

Using 64-bit atomics is still good for i586 fuzzing, but the tests are
build for earlier CPUs. This makes this code to be disabled in i386 builds.

There is a similar situation with few other ports that offer 64-bit atomics
in certain CPU models and ABIs.
2019-02-23 08:03:24 +00:00
mlelstv
8e117ced4e Reserve major number for spi driver 2019-02-23 07:33:20 +00:00
mrg
c8eaee5359 pull out libstdc++ config.h as-is, for gnu.ver processing.
pull out the cxx11_sources and cxx98_sources values to avoid hard coding.
2019-02-23 06:54:45 +00:00
kamil
0fe7e51662 Add KCOV - kernel code coverage tracing device
The KCOV driver implements collection of code coverage inside the kernel.
It can be enabled on a per process basis from userland, allowing the kernel
program counter to be collected during syscalls triggered by the same
process.

The device is oriented towards kernel fuzzers, in particular syzkaller.

Currently the only supported coverage type is -fsanitize-coverage=trace-pc.

The KCOV driver was initially developed in Linux. A driver based on the
same concept was then implemented in FreeBSD and OpenBSD.

Documentation is borrowed from OpenBSD and ATF tests from FreeBSD.

This patch has been prepared by Siddharth Muralee, improved by <maxv>
and polished by myself before importing into the mainline tree.

All ATF tests pass.
2019-02-23 03:10:05 +00:00
macallan
9a79811e23 some register bits are defined differently by SunOS's sxreg.h and the SPAM
manual, upon investigation the hardware appears to agree with the SunOS header,
so adapt accordingly
2019-02-22 23:01:25 +00:00
uwe
c07928f07f Check getchar() result for EOF.
Call cleanup(SIGHUP) if we get local EOF, as if we've got SIGHUP.
While here, use EOF constant instead of literal -1 in an existing
check.

PR bin/53996
2019-02-22 22:25:22 +00:00
tsutsui
60282a8efb Explicitly use ${TOOL_AWK} instead of system's awk. 2019-02-22 22:20:18 +00:00
tsutsui
9541ec522c Reduce diffs between common and amd64 uefi Makefile.bootimage files.
No functional change.
2019-02-22 22:13:58 +00:00
maya
92e1c52520 Default our libm to -frounding-math, if built with GCC.
The long-standing GCC default is to not respect rounding mode.
it looks like GCC 7 optimizes rint to a builtin, causing our few
rounding mode tests to fail.

Fixes PR port-amd64/54000: FP tests failing on amd64 since gcc7 import
2019-02-22 18:17:22 +00:00
maxv
b4b0af39d9 Fix omission: if we receive a guest trap on CR0, and if the original
instruction would have resulted in Long Mode being enabled, we need to
manually enable Long Mode ourselves. We were already doing that correctly
in setstate, but not in the CR0 trap handler.

Problem initially reported by Aymeric Vincent; ArchLinux wouldn't boot,
now it does and works correctly.

While here, add CR0_ET in the CR0 mask, for the associated shadow to
be taken into account. Normally this shadow bit shouldn't be necessary,
but for now I keep it regardless.
2019-02-22 12:24:34 +00:00
hannken
44e38a6483 Always set "cn_namelen" in addition to "cn_nameptr".
Fix vnode locking for REMOVE, RMDIR and RENAME.
2019-02-22 09:01:32 +00:00
msaitoh
2330b84d98 Fix a bug that if_link_state_change(ifp, LINK_STATE_DOWN) isn't called unless
link goes up at least one time. Without this change, never linkup-ed media
keeps LINK_STATE_UNKNOWN instead of LINK_STATE_DOWN.
2019-02-22 06:49:15 +00:00
christos
2252cc8ccc Mention that ENOSPC can be returned if we exhausted the max number of
semaphores.
2019-02-21 21:54:09 +00:00
christos
ae4f322282 PR/53998: Joel Bertrand: Return ENOSPC when SEM_NSEMS_MAX is exceeded
instead of -1.
2019-02-21 21:49:23 +00:00
christos
0abcbcb46c add a lint(1) comment to nothing. 2019-02-21 21:34:05 +00:00
christos
3ecfeb8539 - KNF return
- be careful with errno, only set it when it is possibly set and not before
  a system call.
- factor out a common mask comparison.
2019-02-21 21:33:34 +00:00
msaitoh
79244d2c8e Revision 2..5 == RTL8211B...F 2019-02-21 15:41:56 +00:00
maxv
6c017c9010 Add a TODO list for NVMM, just to list some known issues. 2019-02-21 14:56:23 +00:00
maxv
cb8f467cc0 Remove wrong KASSERT in EPT, and reorder the code to reduce duplication. 2019-02-21 14:31:54 +00:00
maxv
01d6ce2a3a Reorder the detection in vmx_ident(), to fix panic on old CPUs. We must
read MSR_IA32_VMX_EPT_VPID_CAP _after_ ensuring EPT is there, because if
it's not, the rdmsr faults.
2019-02-21 13:25:44 +00:00
maxv
fa98071a47 Another locking issue in NVMM: the {svm,vmx}_tlb_flush functions take VCPU
mutexes which can sleep, but their context does not allow it.

Rewrite the TLB handling code to fix that. It becomes a bit complex. In
short, we use a per-VM generation number, which we increase on each TLB
flush, before sending a broadcast IPI to everybody. The IPIs cause a
#VMEXIT of each VCPU, and each VCPU Loop will synchronize the per-VM gen
with a per-VCPU copy, and apply the flushes as neededi lazily.

The behavior differs between AMD and Intel; in short, on Intel we don't
flush the hTLB (EPT cache) if a context switch of a VCPU occurs, so now,
we need to maintain a kcpuset to know which VCPU's hTLBs are active on
which hCPU. This creates some redundancy on Intel, ie there are cases
where we flush the hTLB several times unnecessarily; but hTLB flushes are
very rare, so there is no real performance regression.

The thing is lock-less and non-blocking, so it solves our problem.
2019-02-21 12:17:52 +00:00
maxv
9f7d8f06c3 Clarify the gTLB code a little. 2019-02-21 11:58:04 +00:00
hannken
42e8a0834e Fix bad assertion: vfs_suspend(dead_rootmount) may happen and
must return EOPNOTSUPP.
2019-02-21 08:52:53 +00:00
mrg
fccaa949ae include libkern.h or strings.h. should fix i386 build issues. 2019-02-21 08:25:00 +00:00
knakahara
1da2d3b232 Fix panic when wm(4) is reattached. ok by msaitoh@n.o.
This panic occured after kern_rndq.c:r1.90.
2019-02-21 08:10:22 +00:00
mrg
543c86fd13 fix naming errors in previous. (this file is no longer compiled, but
this fix makes the pull up more obvious, before deleting this file.)
2019-02-21 05:02:20 +00:00
mrg
39e3203eaa for sysv ipc stat operations, explicitly copy the exported parts
instead of the whole ds structure.

besides triggering a recently added assert in netbsd32, this stops
exposing kernel addresses.

copy the mode clamping to 0777 from sem to shm and msg.


while here, make sure that the compat callers to sysv_ipc clear
the contents of the compat structure before setting the result
members to ensure padding bytes are cleared.

don't set/copy _sem_base, _msg_first, _msg_last or _shm_internal.
even if used, which seems very dodgy, they leak KVAs as well.
possibly this may affect linux binaries, in particular, the
comments around _shm_internal ("XXX Oh well.") may mean apps
rely upon these but hopefully not -- the comments date back to
rev 1.1 in 1995.

the _key, _seq and _msg_cbytes members are exported as before as
i found multiple consumers of these (no less than ipcs(1), and
they appear to be useful for debugging and more.


XXX: the naming of compat functions have too many styles.  there
     are at least 3 different ones changed here.
2019-02-21 03:37:18 +00:00
sevan
0c02a81b28 Sometimes negative acknowledgement also shows up as NAK 2019-02-21 01:20:45 +00:00
christos
b3b9361cff handle O_NOSIGPIPE too. 2019-02-20 19:42:14 +00:00
macallan
7ead432177 moar match string 2019-02-20 18:19:46 +00:00
wiz
b12920d30c Remove superfluous Pp. 2019-02-20 17:48:31 +00:00
msaitoh
01d880aba7 Add support for BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787. 2019-02-20 17:08:06 +00:00
msaitoh
46a6566ee5 - Add support for BCM5762 ASIC devices.
- Add BCM5762, BCM5725, BCM5727, BCM57764, BCM57767 and BCM57787.
2019-02-20 17:00:20 +00:00
msaitoh
403b39d97a Add BCM5702FE, another BCM5704S and SysKonnect SK-9Mxx support. 2019-02-20 15:56:51 +00:00
kamil
a3c646ca3f Unify the style of t_ubsan tests
Apply similar change for load_invalid_value_bool in
test_load_invalid_value_enum.

Follow up of PR bin/53968 by Michael van Elst
2019-02-20 11:40:41 +00:00
hannken
e28265c95c - Make the fstrans mount info part of the per-lwp state and replace
most accesses to the mount with fstrans mount info.

- Add "fmi_gone" to be true after unmount and add a counter of
  outstanding mount infos so fstrans_clear_lwp_info() only runs
  if there may be something to do.

- Move lookup of base mounts into per-lwp state.

- Keep a list of valid mounts for DIAGNOSTIC checks.
2019-02-20 10:09:45 +00:00
hannken
583a153e11 Move fstrans_unmount() to vfs_rele(), just before it would free the mount.
Don't take a mount reference for fstrans as it gets notified about the release.

Defer the final free of the mount to fstrans_mount_dtor() when fstrans
has released all references to this mount.  Prevents the mount's memory
to be reused as a new mount before fstrans released all references.

Address PR kern/53928 modules/t_builtin:disable test case randomly fails.
2019-02-20 10:08:37 +00:00
hannken
f421b3668b Attach "mnt_transinfo" to "dead_rootmount" so every mount has a
valid "mnt_transinfo" and remove now unneeded flag IMNT_HAS_TRANS.

Run fstrans_start()/fstrans_done() on dead_rootmount if FSTRANS_DEAD_ENABLED.
Should become the default for DIAGNOSTIC in the future.
2019-02-20 10:07:27 +00:00
hannken
a041391e45 Assign vnode to dead_rootmount before vcache_dealloc() releases it.
Now v_mount is never NULL.
2019-02-20 10:06:33 +00:00
hannken
2df7877a09 Set "mnt_lower" before the first file system operation on the new file system. 2019-02-20 10:05:59 +00:00
hannken
3c4b857dd5 Bracket do_sys_renameat() and nfsrv_rename() with fstrans.
The v_mount field for vnodes on the same file system as "from"
is now stable for referenced vnodes.

VFS_RENAMELOCK no longer may use lock from an unreferenced and
freed "struct mount".
2019-02-20 10:05:20 +00:00
hannken
8d939a9270 Fix vnode locking, must lock for VOP_OPEN() and VOP_UNLOCK() when done. 2019-02-20 10:04:28 +00:00
hannken
836873044c Remove superfluous VOP_UNLOCK(), vnode will be unlocked from spec_reclaim(). 2019-02-20 10:03:55 +00:00
hannken
b783399854 Make FSS_ERROR a flag to prevent bogus fscow_disestablish() after error. 2019-02-20 10:03:25 +00:00
hannken
936247f806 Fix vnode locking for opendisk(), must lock for VOP_OPEN(). 2019-02-20 10:02:51 +00:00
pgoyette
4d21548422 compat70_ocreds_valid is not a pointer to a boolean, it is the boolean
itself which controls whether or not we recognize the OCRED options.

Should fix the panic identified in PR kern/53991 (awaiting confirmation
from submitter).
2019-02-20 09:59:39 +00:00
kamil
dc43916dcf Try to make load_invalid_value_bool portable to Big-Endian
PR bin/53968 by Michael van Elst
2019-02-20 09:50:09 +00:00
kamil
b07a2df4fa Replace signal4 (PT_STEP) test with refactored ones with extra asserts
New tests: step_signalmasked and step_signalignored.

Assert that signal context is not reset upon PT_STEP trap.

Mark new tests as expecting to fail.
2019-02-20 09:25:11 +00:00
msaitoh
c666e7f586 Simplify PCI device table. No functional change. 2019-02-20 08:03:58 +00:00