freebsd.git
7 years agoInclude fasttrap handling for DATAMODEL_ILP32 when compiling for amd64.
markj [Sat, 30 Jul 2016 03:11:53 +0000 (03:11 +0000)]
Include fasttrap handling for DATAMODEL_ILP32 when compiling for amd64.

MFC after: 1 month

7 years agolibdtrace: Don't hard-code the native data model.
markj [Sat, 30 Jul 2016 03:09:57 +0000 (03:09 +0000)]
libdtrace: Don't hard-code the native data model.

MFC after: 1 month

7 years agolibproc: Add proc_getmodel().
markj [Sat, 30 Jul 2016 03:09:23 +0000 (03:09 +0000)]
libproc: Add proc_getmodel().

This is used by libdtrace to determine the data model of target processes.
This allows for the creation of pid provider probes in 32-bit processes on
amd64.

MFC after: 1 month

7 years agoAdd descriptions for fields in struct proc_handle.
markj [Sat, 30 Jul 2016 03:07:14 +0000 (03:07 +0000)]
Add descriptions for fields in struct proc_handle.

Remove the unused kq field and some unnecessary includes.

MFC after: 1 month

7 years agolibrtld_db: Use the auxv to figure out where to look up loader symbols.
markj [Sat, 30 Jul 2016 03:05:23 +0000 (03:05 +0000)]
librtld_db: Use the auxv to figure out where to look up loader symbols.

Previously, librtld_db just hardcoded /libexec/ld-elf.so, which isn't
correct for processes that aren't using the native ABI. With this change,
librtld_db can be used to inspect non-native processes; in particular,
dtrace -c now works for 32-bit executables on amd64.

MFC after: 1 month

7 years agoReset errno for readdirfunc() before contunue.
ache [Sat, 30 Jul 2016 02:09:11 +0000 (02:09 +0000)]
Reset errno for readdirfunc() before contunue.

7 years agoRemove usage of _WITH_DPRINTF
bapt [Sat, 30 Jul 2016 01:16:06 +0000 (01:16 +0000)]
Remove usage of _WITH_DPRINTF

7 years agoRemove last traces of _WITH_GETLINE
bapt [Sat, 30 Jul 2016 01:13:54 +0000 (01:13 +0000)]
Remove last traces of _WITH_GETLINE

7 years agoRemove usage of _WITH_GETLINE from usr.sbin
bapt [Sat, 30 Jul 2016 01:10:05 +0000 (01:10 +0000)]
Remove usage of _WITH_GETLINE from usr.sbin

7 years agoRemove usage of _WITH_GETLINE from usr.bin
bapt [Sat, 30 Jul 2016 01:07:47 +0000 (01:07 +0000)]
Remove usage of _WITH_GETLINE from usr.bin

7 years agoindent(1): Yet more style issues.
pfg [Sat, 30 Jul 2016 01:04:18 +0000 (01:04 +0000)]
indent(1): Yet more style issues.

strchr(3) returns a pointer not a boolean.
Attempt to make the style somewhat more ocnsistent with what indent
had before recent changes.

Pointed out by: bde

7 years agoRemove _WITH_GETLINE and _WITH_DPRINTF guards
bapt [Sat, 30 Jul 2016 01:00:16 +0000 (01:00 +0000)]
Remove _WITH_GETLINE and _WITH_DPRINTF guards

When adding getline(3) and dprintf(3) into libc, those guards were added
to prevent breaking too many ports.

7 years later the ports tree have been fixed, it is time to remove this
FreeBSDism

While here remove the extra parenthesis surrounding dprintf(3)

7 years agoindent(1): Attempt to preserve some consistent style.
pfg [Fri, 29 Jul 2016 23:30:33 +0000 (23:30 +0000)]
indent(1): Attempt to preserve some consistent style.

Remove the excessive braces from r303485 and align the comments to the
right as done in the rest of the code. This is not nice but there is no
clear way to make it nice (and KNF).

Pointed out by: bde

7 years agoVarious fixes to the t4/5nex character device.
jhb [Fri, 29 Jul 2016 22:11:29 +0000 (22:11 +0000)]
Various fixes to the t4/5nex character device.

- Remove null open/close methods.
- Don't set d_flags to 0 explicitly.
- Remove t5_cdevsw as the .d_name member isn't really used and doesn't
  warrant a separate cdevsw just for the name.
- Use ENOTTY as the error value for an unknown ioctl request.
- Use make_dev_s() to close race with setting si_drv1.

Sponsored by: Chelsio Communications

7 years agolibunwind: correct return code in unwinding trace log message
emaste [Fri, 29 Jul 2016 21:37:00 +0000 (21:37 +0000)]
libunwind: correct return code in unwinding trace log message

Obtained from: LLVM r277215
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

7 years agoFix markup for -j in cpuset(1) synopsis
vangyzen [Fri, 29 Jul 2016 21:18:20 +0000 (21:18 +0000)]
Fix markup for -j in cpuset(1) synopsis

MFC after: 3 days
Sponsored by: Dell Inc.

7 years agoFix two return types in the cpuset(9) and bitset(9) man pages
vangyzen [Fri, 29 Jul 2016 21:12:48 +0000 (21:12 +0000)]
Fix two return types in the cpuset(9) and bitset(9) man pages

The *_FFS() and *_COUNT() functions return int, not size_t.

MFC after: 3 days
Sponsored by: Dell Inc.

7 years agolibblacklist: Do not use %m for logging, use strerror(errno)
lidl [Fri, 29 Jul 2016 21:11:32 +0000 (21:11 +0000)]
libblacklist: Do not use %m for logging, use strerror(errno)

The blacklist library can accept a function to use for logging,
defaulting to vsyslog(), if no function is specified.  Make the
blacklist library use strerror(errno) explicitly, instead of %m,
so that the passed in function does not need to support the
syslog specific placeholder.

This matches a change already submitted and accepted upstream.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

7 years agoUse vm_page_undirty() instead of manually setting a page field.
markj [Fri, 29 Jul 2016 21:05:37 +0000 (21:05 +0000)]
Use vm_page_undirty() instead of manually setting a page field.

Reviewed by: alc
MFC after: 3 days

7 years agoMake resizewin.1 manpage use .Fx macro
lidl [Fri, 29 Jul 2016 21:05:17 +0000 (21:05 +0000)]
Make resizewin.1 manpage use .Fx macro

Fix capitalization of "PuTTY" also.

MFC after: 1 week

7 years agoFix NTBT_QP_LINKS negotiation.
mav [Fri, 29 Jul 2016 21:03:30 +0000 (21:03 +0000)]
Fix NTBT_QP_LINKS negotiation.

I believe it never worked correctly for more the one queue even in Linux.
This fixes case when one of consumer drivers is not loaded on one side,
but its queues still announced as ready if something else brought link up.

While there, remove some pointless NULL checks.

7 years agosdp: Destroy the RDMA ID after destroying the connection's queue pair.
markj [Fri, 29 Jul 2016 21:03:02 +0000 (21:03 +0000)]
sdp: Destroy the RDMA ID after destroying the connection's queue pair.

This is the ordering documented by rdma_destroy_qp(). Also add a useful
KASSERT to sdp_pcbfree().

Sponsored by: EMC / Isilon Storage Division

7 years agosdp: Use malloc(9) instead of the Linux compat layer.
markj [Fri, 29 Jul 2016 21:01:04 +0000 (21:01 +0000)]
sdp: Use malloc(9) instead of the Linux compat layer.

SDP transmit and receive rings are always created in a sleepable context,
so we can use M_WAITOK and remove error checks.

Sponsored by: EMC / Isilon Storage Division

7 years agosdp: Use the correct socket buffer in sdp_post_recvs_needed().
markj [Fri, 29 Jul 2016 20:54:43 +0000 (20:54 +0000)]
sdp: Use the correct socket buffer in sdp_post_recvs_needed().

Sponsored by: EMC / Isilon Storage Division

7 years agoClear scratchpad after MSIX negotiation to not leak garbage.
mav [Fri, 29 Jul 2016 20:52:18 +0000 (20:52 +0000)]
Clear scratchpad after MSIX negotiation to not leak garbage.

7 years agosdp: Always free received control packets after they're handled.
markj [Fri, 29 Jul 2016 20:51:52 +0000 (20:51 +0000)]
sdp: Always free received control packets after they're handled.

Sponsored by: EMC / Isilon Storage Division

7 years agoFix the KASSERT format string arguments after r303507.
markj [Fri, 29 Jul 2016 20:48:42 +0000 (20:48 +0000)]
Fix the KASSERT format string arguments after r303507.

7 years agosdp: Use the PCB as the rx completion handler argument.
markj [Fri, 29 Jul 2016 20:39:32 +0000 (20:39 +0000)]
sdp: Use the PCB as the rx completion handler argument.

The generic socket may be detached from the PCB before the completion
queue is drained and destroyed, so this change closes a race condition
in connection teardown.

Sponsored by: EMC / Isilon Storage Division

7 years agosdp: Destroy the PCB lock before freeing to the zone.
markj [Fri, 29 Jul 2016 20:36:01 +0000 (20:36 +0000)]
sdp: Destroy the PCB lock before freeing to the zone.

Sponsored by: EMC / Isilon Storage Division

7 years agosdp: Use an mbufq for received control packets.
markj [Fri, 29 Jul 2016 20:35:04 +0000 (20:35 +0000)]
sdp: Use an mbufq for received control packets.

This is simpler than the hand-rolled queue, and fixes a use-after-free.

Sponsored by: EMC / Isilon Storage Division

7 years agosdp: Remove Linux build files.
markj [Fri, 29 Jul 2016 20:33:43 +0000 (20:33 +0000)]
sdp: Remove Linux build files.

They aren't useful here, and Linux seems to have largely abandoned SDP
anyway.

Sponsored by: EMC / Isilon Storage Division

7 years agoDon't treat NOCPU as a valid CPU to CPU_ISSET.
jhb [Fri, 29 Jul 2016 20:19:14 +0000 (20:19 +0000)]
Don't treat NOCPU as a valid CPU to CPU_ISSET.

If a thread is created bound to a cpuset it might already be bound before
it's very first timeslice, and td_lastcpu will be NOCPU in that case.

MFC after: 1 week

7 years agoindent(1): Use NULL instead of zero for pointers.
pfg [Fri, 29 Jul 2016 19:36:10 +0000 (19:36 +0000)]
indent(1): Use NULL instead of zero for pointers.

7 years agoFix locking issues with aio_fsync().
jhb [Fri, 29 Jul 2016 18:26:15 +0000 (18:26 +0000)]
Fix locking issues with aio_fsync().

- Use correct lock in aio_cancel_sync when dequeueing job.
- Add _locked variants of aio_set/clear_cancel_function and use those
  to avoid lock recursion when adding and removing fsync jobs to the
  per-process sync queue.
- While here, add a basic test for aio_fsync().

PR: 211390
Reported by: Randy Westlund <rwestlun@gmail.com>
MFC after: 1 week
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D7339

7 years agoindent(1): Support "f" and "F" floating constant suffixes.
pfg [Fri, 29 Jul 2016 18:00:10 +0000 (18:00 +0000)]
indent(1): Support "f" and "F" floating constant suffixes.

Actually this just brings back r303487 with the correct commit log.

Differential Revision: https://reviews.freebsd.org/D6966  (Partial)
Obtained from: Piotr Stefaniak

7 years agoRevert r303487: Wrong commit log.
pfg [Fri, 29 Jul 2016 17:55:38 +0000 (17:55 +0000)]
Revert r303487: Wrong commit log.

Will be brought back with the correct log.

7 years agoAdd a loader tunable (hw.pci.enable_pcie_hp) to disable PCI-e HotPlug.
jhb [Fri, 29 Jul 2016 17:54:21 +0000 (17:54 +0000)]
Add a loader tunable (hw.pci.enable_pcie_hp) to disable PCI-e HotPlug.

Some systems and/or devices (such as riser cards) do not include a
non-compliant implementation of PCI-e HotPlug that can result in devices
not being attached (e.g. the HotPlug code might assume that a card is
being unplugged and will power the slot off and detach it).  This
tunable can be set to 0 to disable support for PCI-e HotPlug ignoring
the incorrect HotPlug state on these slots.

PR: 211081
Reported by: Sergey Renkas <serg_ic@mail.ru> (SuperMicro X7 riser card)
Reported by: Jeffrey E Pieper <jeffrey.e.pieper@intel.com>
  (Intel X520 adapter)
MFC after: 1 week
Relnotes: yes

7 years agoChange the return type of freelocale(3) to void.
ed [Fri, 29 Jul 2016 17:18:47 +0000 (17:18 +0000)]
Change the return type of freelocale(3) to void.

Our version of this function currently returns an integer indicating
failure or success, whereas POSIX specifies that this function has no
return value. It returns void. Patch up the header, sources and man page
to use the right type. While there, use the opportunity to simplify the
body of this function.

Theoretically speaking, this change breaks the ABI of this function.
That said, I have yet to find any code that makes use of freelocale()'s
return value. I couldn't find any of it in the base system, nor did an
exp-run reveal any breakage caused by this change.

PR: 211394 (exp-run)

7 years agoOnce more refactor KPI between ntb_transport(4) and if_ntb(4)..
mav [Fri, 29 Jul 2016 17:15:41 +0000 (17:15 +0000)]
Once more refactor KPI between ntb_transport(4) and if_ntb(4)..

New design allows to attach multiple consumers to ntb_transport(4) instance.
Previous design obtained from Linux theoretically allowed that, but was not
practically usable (Linux also has only one consumer driver now).

7 years agoRemove a probe declaration that has been unused since r292469, when
alc [Fri, 29 Jul 2016 16:43:51 +0000 (16:43 +0000)]
Remove a probe declaration that has been unused since r292469, when
vm_pageout_grow_cache() was replaced.

MFC after: 3 days

7 years agoRevert r291022: x86/intr: allow mutex recursion in intr_remove_handler
royger [Fri, 29 Jul 2016 16:35:58 +0000 (16:35 +0000)]
Revert r291022: x86/intr: allow mutex recursion in intr_remove_handler

This was only needed for Xen, and a better way to deal with this issue has
been found, so this commit can be reverted.

Sponsored by: Citrix Systems R&D
MFC after: 5 days
Reviewed by: kib
Differential revision: https://reviews.freebsd.org/D7363

7 years agoxen-intr: fix removal of event channels during resume
royger [Fri, 29 Jul 2016 16:34:54 +0000 (16:34 +0000)]
xen-intr: fix removal of event channels during resume

Event channel handlers cannot be removed during resume because there might
be an interrupt thread running on a CPU currently blocked in the
cpususpend_handler, which prevents the call to intr_remove_handler from
finishing and completely freezes the system during resume. r291022 tried to
fix this by allowing recursion in intr_remove_handler, but that's clearly
not enough.

Instead don't remove the handlers at the interrupt resume phase, and let
each driver remove the handler by itself during resume. In order to do this,
change the opaque event channel handler cookie to use the global interrupt
vector instead of the event channel port. The event channel port cannot be
used because after resume all event channels are reset, and the port numbers
can change.

Sponsored by: Citrix Systems R&D
MFC after: 5 days

7 years agoindent(1): Removed whitespace shouldn't be considered in column calculations.
pfg [Fri, 29 Jul 2016 16:34:16 +0000 (16:34 +0000)]
indent(1): Removed whitespace shouldn't be considered in column calculations.

This piece of code removed tabs and space characters from after colons
that follow labels by decrementing the e_lab (end of label) "pointer"
which is later used to calculate the width of the string that fprintf()
puts into "output". But pad_output() gets the length from the actual
string, so it miscalculated what the current column is.

Fixed by putting a string terminator at the e_lab "pointer".

Differential Revision: https://reviews.freebsd.org/D6966
(Partial)
Obtained from: Piotr Stefaniak

7 years agoxen-netfront: fix trying to send packets with disconnected netfront
royger [Fri, 29 Jul 2016 16:33:45 +0000 (16:33 +0000)]
xen-netfront: fix trying to send packets with disconnected netfront

In certain circumstances xn_txq_mq_start might be called with num_queues ==
0 during the resume phase after a migration, which can trigger a KASSERT.
Fix this by making sure the carrier is on before trying to transmit, or else
return that the queues are full.

Just as a note, I haven't been able to reproduce this crash on my test
systems, but I still think it's possible and worth fixing.

Reported by: Karl Pielorz <kpielorz_lst@tdx.co.uk>
Sponsored by: Citrix Systems R&D
MFC after: 5 days
Reviewed by: Wei Liu <wei.liu2@citrix.com>
Differential revision: https://reviews.freebsd.org/D7349

7 years agoindent(1): fix struct termination detection.
pfg [Fri, 29 Jul 2016 16:28:51 +0000 (16:28 +0000)]
indent(1): fix struct termination detection.

Small style cleanup while here.

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak

7 years agoMention that basename(3) and dirname(3) will change in the future.
ed [Fri, 29 Jul 2016 16:25:09 +0000 (16:25 +0000)]
Mention that basename(3) and dirname(3) will change in the future.

Update the existing manual pages for basename(3) and dirname(3) to
mention that in future versions of FreeBSD, these functions will no
longer use internal buffers for storing the results.

MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D7356

7 years agoindent(1): fix struct termination detection.
pfg [Fri, 29 Jul 2016 16:23:00 +0000 (16:23 +0000)]
indent(1): fix struct termination detection.

Semicolons inside struct declarations don't end the declarations.

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak

7 years agoindent(1): Fix breakage caused by single comment following "else".
pfg [Fri, 29 Jul 2016 16:17:54 +0000 (16:17 +0000)]
indent(1): Fix breakage caused by single comment following "else".

indent(1) simply wasn't taught that "else" may be followed by a comment
without any opening brace anywhere on the line, so it was very confused
in such cases.

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak

7 years agoindent(1): Avoid potential use-after-free.
pfg [Fri, 29 Jul 2016 16:14:03 +0000 (16:14 +0000)]
indent(1): Avoid potential use-after-free.

last_bl is a char pointer that tracks the last blank character in a
comment, which is used for wrapping long comment lines. Since the
underlying array may be reallocated, make sure last_bl is up to date when
that happens.

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak

7 years agoindent(1): Avoid out of bound access of array codebuf.
pfg [Fri, 29 Jul 2016 16:09:05 +0000 (16:09 +0000)]
indent(1): Avoid out of bound access of array codebuf.

dump_line() requires s_code to be a string, because it will call count_spaces().

Differential Revision: https://reviews.freebsd.org/D6966 (Partial)
Obtained from: Piotr Stefaniak

7 years agoFix typo.
imp [Fri, 29 Jul 2016 15:24:50 +0000 (15:24 +0000)]
Fix typo.

7 years agoInclude FBT to modules build on RISC-V.
br [Fri, 29 Jul 2016 12:30:33 +0000 (12:30 +0000)]
Include FBT to modules build on RISC-V.

7 years agoRemove unused variables.
br [Fri, 29 Jul 2016 12:29:17 +0000 (12:29 +0000)]
Remove unused variables.

7 years agoRemove write-only variable.
trasz [Fri, 29 Jul 2016 12:15:55 +0000 (12:15 +0000)]
Remove write-only variable.

MFC after: 1 month

7 years agoImprove error message.
trasz [Fri, 29 Jul 2016 11:33:23 +0000 (11:33 +0000)]
Improve error message.

MFC after: 1 month

7 years agoFix MTP description in the comment.
trasz [Fri, 29 Jul 2016 11:33:01 +0000 (11:33 +0000)]
Fix MTP description in the comment.

MFC after: 1 month

7 years agoAdd a generic EHCI USB driver based on the Allwinner A10 driver. It is ACPI
andrew [Fri, 29 Jul 2016 08:50:36 +0000 (08:50 +0000)]
Add a generic EHCI USB driver based on the Allwinner A10 driver. It is ACPI
only for now, but wouldn't be too difficult to add support for FDT.

Reviewed by: hselasky
Obtained from: ABT Systems Ltd
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7352

7 years agohyperv/storvsc: Use busdma(9) and enable PIM_UNMAPPED by default.
sephe [Fri, 29 Jul 2016 06:22:11 +0000 (06:22 +0000)]
hyperv/storvsc: Use busdma(9) and enable PIM_UNMAPPED by default.

The UNMAPPED I/O greatly improves userland direct disk I/O performance
by 35% ~ 135%.

Submitted by: Hongjiang Zhang <honzhan microsoft com>
MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7195

7 years agohyperv/vmbus: Revoke unnecessary exposure of vmbus softc
sephe [Fri, 29 Jul 2016 06:10:27 +0000 (06:10 +0000)]
hyperv/vmbus: Revoke unnecessary exposure of vmbus softc

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7348

7 years agohyperv/vmbus: Move driver glue to the beginning of the files
sephe [Fri, 29 Jul 2016 05:58:24 +0000 (05:58 +0000)]
hyperv/vmbus: Move driver glue to the beginning of the files

Just as most of other drivers do.  And move sysinit function close
to its SYSINIT.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7347

7 years agohyperv/vmbus: Forward declare static functions
sephe [Fri, 29 Jul 2016 05:49:12 +0000 (05:49 +0000)]
hyperv/vmbus: Forward declare static functions

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7346

7 years agohyperv/vmbus: Reindent function declarations.
sephe [Fri, 29 Jul 2016 03:16:51 +0000 (03:16 +0000)]
hyperv/vmbus: Reindent function declarations.

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7344

7 years agoMove protocol specific stuff into a linker set object that's
imp [Thu, 28 Jul 2016 22:55:21 +0000 (22:55 +0000)]
Move protocol specific stuff into a linker set object that's
per-protocol. This reduces the number scsi symbols references by
cam_xpt significantly, and eliminates all ata / nvme symbols. There's
still some NVME / ATA specific code for dealing with XPT_NVME_IO and
XPT_ATA_IO respectively, and a bunch of scsi-specific code, but this
is progress.

Differential Revision: https://reviews.freebsd.org/D7289

7 years agoSwitch to linker sets to find the xport callback object. This
imp [Thu, 28 Jul 2016 22:55:14 +0000 (22:55 +0000)]
Switch to linker sets to find the xport callback object.  This
eliminates the need to special case everything in cam_xpt for new
transports. It is now a failure to not have a transport object when
registering the bus as well. You can still, however, create a
transport that's unspecified (XPT_)

Differential Revision: https://reviews.freebsd.org/D7289

7 years agoKill a few stray debug printfs.
imp [Thu, 28 Jul 2016 22:40:31 +0000 (22:40 +0000)]
Kill a few stray debug printfs.

7 years agoRemove any mention of cache (PG_CACHE) pages from the comments in
alc [Thu, 28 Jul 2016 22:30:48 +0000 (22:30 +0000)]
Remove any mention of cache (PG_CACHE) pages from the comments in
vm_pageout_scan().  That function has not cached pages since r284376.

MFC after: 3 days

7 years agoDon't create pointless backups of generated files in "make sysent".
brooks [Thu, 28 Jul 2016 21:29:04 +0000 (21:29 +0000)]
Don't create pointless backups of generated files in "make sysent".

Any sensible workflow will include a revision control system from which
to restore the old files if required.  In normal usage, developers just
have to clean up the mess.

Reviewed by: jhb
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D7353

7 years agocxgbe's firmware module fails to build on mips64 as well as mips32 so
brooks [Thu, 28 Jul 2016 21:27:47 +0000 (21:27 +0000)]
cxgbe's firmware module fails to build on mips64 as well as mips32 so
disable for all mips.

Sponsored by: DARPA, AFRL

7 years agoNote that not all optional ptrace events use SIGTRAP.
jhb [Thu, 28 Jul 2016 20:51:29 +0000 (20:51 +0000)]
Note that not all optional ptrace events use SIGTRAP.

New child processes attached due to PTRACE_FORK use SIGSTOP instead of
SIGTRAP.  All other ptrace events use SIGTRAP.

7 years agoCall tcp_notify() directly to shoot down routes, rather than
gallatin [Thu, 28 Jul 2016 19:32:25 +0000 (19:32 +0000)]
Call tcp_notify() directly to shoot down routes, rather than
calling in_pcbnotifyall().

This avoids lock contention on tcbinfo due to in_pcbnotifyall()
holding the tcbinfo write lock while walking all connections.

Reviewed by: rrs, karels
MFC after: 2 weeks
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D7251

7 years agoAdd tblgen to ObsoleteFiles.inc, as it was renamed to llvm-tblgen.
dim [Thu, 28 Jul 2016 18:40:43 +0000 (18:40 +0000)]
Add tblgen to ObsoleteFiles.inc, as it was renamed to llvm-tblgen.

Noticed by: pluknet
MFC after: 3 days

7 years agoRemove BSD and USL copyright and update license block in in_prot.c, as the
stevek [Thu, 28 Jul 2016 18:39:30 +0000 (18:39 +0000)]
Remove BSD and USL copyright and update license block in in_prot.c, as the
code in this file was written by Robert N. M. Waston.

Move cr_can* prototypes from sys/systm.h to sys/proc.h

Reported by: rwatson
Reviewed by: rwatson
Approved by: sjg (mentor)
Differential Revision: https://reviews.freebsd.org/D7345

7 years agoMark spg_len and fl_pktshift static.
jhb [Thu, 28 Jul 2016 17:37:12 +0000 (17:37 +0000)]
Mark spg_len and fl_pktshift static.

These variables are no longer exported to t4_netmap.c after r296478.

7 years agoNormalise the CWARNFLAGS inter-word spacing: remove all leading
br [Thu, 28 Jul 2016 17:18:02 +0000 (17:18 +0000)]
Normalise the CWARNFLAGS inter-word spacing: remove all leading
and trailing space, and convert multiple consecutive spaces to
single space.

This helps to keep build output looking good.

7 years agoindent: avoid calling write(2) with a negative second parameter.
pfg [Thu, 28 Jul 2016 16:54:12 +0000 (16:54 +0000)]
indent: avoid calling write(2) with a negative second parameter.

negative_returns: n is passed to a parameter that cannot be negative.
Fix a style issue while here.

CID: 1008107

7 years agoFix up prototypes of basename(3) and dirname(3) to comply to POSIX.
ed [Thu, 28 Jul 2016 16:20:27 +0000 (16:20 +0000)]
Fix up prototypes of basename(3) and dirname(3) to comply to POSIX.

POSIX allows these functions to be implemented in a way that the
resulting string is stored in the input buffer. Though some may find
this annoying, this has the advantage that it makes it possible to
implement this function in a thread-safe way. It also means that they
can be implemented in a way that they work for paths of arbitrary
length, as the output string of these functions is never longer than
max(1, len(input)).

Portable code already needs to be written with this in mind, so in my
opinion it makes very little sense to allow the existing behaviour.
Prevent the base system from falling back to this by switching over to
POSIX prototypes.

I'm not going to bump the __FreeBSD_version for this. The reason is that
it's possible to account for this change in a portable way, without
depending on a specific version of FreeBSD. An exp-run was done some
time ago. As far as I know, all regressions as a result of this have
already been fixed.

I'll give this change some time to settle. In the long run I want to
replace our copies by ones that are thread-safe and don't depend on
PATH_MAX/MAXPATHLEN.

7 years agoPull a copy of the input string before calling basename() and dirname().
ed [Thu, 28 Jul 2016 16:06:37 +0000 (16:06 +0000)]
Pull a copy of the input string before calling basename() and dirname().

POSIX allows implementations of these functions to modify their input.

7 years agoClean up use of basename() and dirname().
ed [Thu, 28 Jul 2016 16:02:30 +0000 (16:02 +0000)]
Clean up use of basename() and dirname().

Pull copies of the input pathname string before calling basename() and
dirname() to make this comply to POSIX. Free these copies at the end of
this function. While there, remove the duplication of the 's' ->
'logfname' string. There is no need for this.

7 years agoDo not delegate a work to geom event thread which can be done inline.
kib [Thu, 28 Jul 2016 15:57:01 +0000 (15:57 +0000)]
Do not delegate a work to geom event thread which can be done inline.

In particular, swapongeom_ev() needed event thread context when swap
pager configuration was performed under Giant and geom asserted that
Giant is not owned.  Now both of the reason went away.

On the other hand, note that swpageom_release() is called from the
bio_done context, and possible close cannot be performed inline.

Also fix some minor issues.  The swapgeom() function does not use the
td argument, remove it.  Recheck that the vnode passed is still VCHR
and not reclaimed after the lock.

Reviewed by: mav
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years agoFix style and typo.
kib [Thu, 28 Jul 2016 15:49:51 +0000 (15:49 +0000)]
Fix style and typo.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoCall basename() and dirname() in the POSIXly correct way.
ed [Thu, 28 Jul 2016 15:33:19 +0000 (15:33 +0000)]
Call basename() and dirname() in the POSIXly correct way.

Pull copies of the input string, as these functions are allowed to
modify them. Free the copies after creating the new pathname string.

7 years agoCall basename() in a portable way.
ed [Thu, 28 Jul 2016 15:19:47 +0000 (15:19 +0000)]
Call basename() in a portable way.

Pull a copy of the filename string before calling basename(). Change the
loop to not return on its own, so we can put a free() statement at the
bottom.

7 years agoDon't call basename() and dirname() in an unportable way.
ed [Thu, 28 Jul 2016 15:17:12 +0000 (15:17 +0000)]
Don't call basename() and dirname() in an unportable way.

POSIX allows these functions to modify their input buffer, so that they
have storage for the return value. Pull copies of the filename before
calling these utility functions.

7 years agoremove CONSTRUCTORS from kernel linker scripts
emaste [Thu, 28 Jul 2016 13:54:46 +0000 (13:54 +0000)]
remove CONSTRUCTORS from kernel linker scripts

The linker script CONSTRUCTORS keyword is only meaningful "when linking
object file formats which do not support arbitrary sections, such as
ECOFF and XCOFF"[1] and is ignored for other object file formats.

LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove
CONSTRUCTORS from the linker scripts as it has no effect.

[1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D7343

7 years agoRegenerate src.conf.5 after r303394
emaste [Thu, 28 Jul 2016 13:35:46 +0000 (13:35 +0000)]
Regenerate src.conf.5 after r303394

7 years agoBuild ofw_bus_if.h for modules for RISC-V.
br [Thu, 28 Jul 2016 13:21:45 +0000 (13:21 +0000)]
Build ofw_bus_if.h for modules for RISC-V.

7 years agoBuild DTrace assym.o with -msoft-float flag for RISC-V so we have
br [Thu, 28 Jul 2016 13:18:10 +0000 (13:18 +0000)]
Build DTrace assym.o with -msoft-float flag for RISC-V so we have
correct flag in ELF file.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5

7 years agoo Add warn flags required to build modules with GCC 6.1;
br [Thu, 28 Jul 2016 13:15:23 +0000 (13:15 +0000)]
o Add warn flags required to build modules with GCC 6.1;
o Sort GCC 4.8 warn flags.

Sponsored by: DARPA, AFRL
Sponsored by: HEIF5

7 years agoFix r303429 build with invariants.
mav [Thu, 28 Jul 2016 12:25:58 +0000 (12:25 +0000)]
Fix r303429 build with invariants.

7 years agoRegenerate system call table for r303435.
ed [Thu, 28 Jul 2016 12:22:34 +0000 (12:22 +0000)]
Regenerate system call table for r303435.

7 years agoChange the return type of msgrcv() to ssize_t as required by POSIX.
ed [Thu, 28 Jul 2016 12:22:01 +0000 (12:22 +0000)]
Change the return type of msgrcv() to ssize_t as required by POSIX.

It looks like the msgrcv() system call is already written in such a way
that the size is internally computed as a size_t and written into all of
td_retval[0]. This means that it is effectively already returning
ssize_t. It's just that the userspace prototype doesn't match up.

7 years agoOnce more refactor KPI between NTB hardware and consumers.
mav [Thu, 28 Jul 2016 10:48:20 +0000 (10:48 +0000)]
Once more refactor KPI between NTB hardware and consumers.

New design allows hardware resources to be split between several consumers.
For example, one BAR can be dedicated for remote memory access, while other
resources can be used for packet transport for virtual Ethernet interface.
And even without resource split, this code allows to specify which consumer
driver should attach the hardware.

From some points this makes the code even closer to Linux one, even though
Linux does not provide the described flexibility.

7 years agoAdd NI_NUMERICSCOPE.
ed [Thu, 28 Jul 2016 10:05:41 +0000 (10:05 +0000)]
Add NI_NUMERICSCOPE.

POSIX also declares NI_NUMERICSCOPE, which makes getnameinfo() return a
numerical scope identifier. The interesting thing is that support for
this is already present in code, but #ifdef disabled. Expose this
functionality by placing a definition for it in <netdb.h>.

While there, remove references to NI_WITHSCOPEID, as that got removed 11
years ago.

7 years agoChange type of MB_CUR_MAX and MB_CUR_MAX_L() to size_t.
ed [Thu, 28 Jul 2016 09:50:19 +0000 (09:50 +0000)]
Change type of MB_CUR_MAX and MB_CUR_MAX_L() to size_t.

POSIX requires that MB_CUR_MAX expands to an expression of type size_t.
It currently expands to an int. As these are already macros, don't
change the underlying type of these functions. There is no ned to touch
those.

Differential Revision: https://reviews.freebsd.org/D6645

7 years agoRewrite subr_sleepqueue.c use of callouts to not depend on the
kib [Thu, 28 Jul 2016 09:09:55 +0000 (09:09 +0000)]
Rewrite subr_sleepqueue.c use of callouts to not depend on the
specifics of callout KPI.  Esp., do not depend on the exact interface
of callout_stop(9) return values.

The main change is that instead of requiring precise callouts, code
maintains absolute time to wake up.  Callouts now should ensure that a
wake occurs at the requested moment, but we can tolerate both run-away
callout, and callout_stop(9) lying about running callout either way.

As consequence, it removes the constant source of the bugs where
sleepq_check_timeout() causes uninterruptible thread state where the
thread is detached from CPU, see e.g. r234952 and r296320.

Patch also removes dual meaning of the TDF_TIMEOUT flag, making code
(IMO much) simpler to reason about.

Tested by: pho
Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
Differential revision: https://reviews.freebsd.org/D7137

7 years agoExtract the calculation of the callout fire time into the new function
kib [Thu, 28 Jul 2016 08:57:01 +0000 (08:57 +0000)]
Extract the calculation of the callout fire time into the new function
callout_when(9).  See the man page update for the description of the
intended use.

Tested by: pho
Reviewed by: jhb, bjk (man page updates)
Sponsored by: The FreeBSD Foundation
MFC after: 1 month
X-Differential revision: https://reviews.freebsd.org/D7137

7 years agoFix typo in comment.
kib [Thu, 28 Jul 2016 08:53:38 +0000 (08:53 +0000)]
Fix typo in comment.

MFC after:  3 days

7 years agoWhen a debugger attaches to the process, SIGSTOP is sent to the
kib [Thu, 28 Jul 2016 08:41:13 +0000 (08:41 +0000)]
When a debugger attaches to the process, SIGSTOP is sent to the
target.  Due to a way issignal() selects the next signal to deliver
and report, if the simultaneous or already pending another signal
exists, that signal might be reported by the next waitpid(2) call.
This causes minor annoyance for debuggers, which must be prepared to
take any signal as the first event, then filter SIGSTOP later.

More importantly, for tools like gcore(1), which attach and then
detach without processing events, SIGSTOP might leak to be delivered
after PT_DETACH.  This results in the process being unintentionally
stopped after detach, which is fatal for automatic tools.

The solution is to force SIGSTOP to be the first signal reported after
the attach.  Attach code is modified to set P2_PTRACE_FSTP to indicate
that the attaching ritual was not yet finished, and issignal() prefers
SIGSTOP in that condition.  Also, the thread which handles
P2_PTRACE_FSTP is made to guarantee to own p_xthread during the first
waitpid(2).  All that ensures that SIGSTOP is consumed first.

Additionally, if P2_PTRACE_FSTP is still set on detach, which means
that waitpid(2) was not called at all, SIGSTOP is removed from the
queue, ensuring that the process is resumed on detach.

In issignal(), when acting on STOPing signals, remove the signal from
queue before suspending.  Otherwise parallel attach could result in
ptracestop() acting on that STOP as if it was the STOP signal from the
attach.  Then SIGSTOP from attach leaks again.

As a minor refactoring, some bits of the common attach code is moved
to new helper proc_set_traced().

Reported by: markj
Reviewed by: jhb, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D7256

7 years agohyperv/vmbus: Inclusion cleanup
sephe [Thu, 28 Jul 2016 06:46:10 +0000 (06:46 +0000)]
hyperv/vmbus: Inclusion cleanup

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7334

7 years agohyperv/vmbus: Avoid unnecessary mb()
sephe [Thu, 28 Jul 2016 06:30:29 +0000 (06:30 +0000)]
hyperv/vmbus: Avoid unnecessary mb()

MFC after: 1 week
Sponsored by: Microsoft
Differential Revision: https://reviews.freebsd.org/D7333