freebsd.git
9 years agoMerge forgotten .h files from vendor branch.
imp [Fri, 5 Sep 2014 02:21:45 +0000 (02:21 +0000)]
Merge forgotten .h files from vendor branch.

9 years agoBring in forgotten pinfunc.h files from last import.
imp [Fri, 5 Sep 2014 02:20:06 +0000 (02:20 +0000)]
Bring in forgotten pinfunc.h files from last import.

9 years agoApply known workarounds for modern MacBooks.
pfg [Fri, 5 Sep 2014 01:06:45 +0000 (01:06 +0000)]
Apply known workarounds for modern MacBooks.

The legacy USB circuit tends to give trouble on MacBook.
While the original report covered MacBook, extend the fix
preemptively for the newer MacBookPro too.

PR: 191693
Reviewed by: emaste
MFC after: 5 days

9 years agouse a straight buffer instead of an iov w/ 1 segment... The aesni
jmg [Thu, 4 Sep 2014 23:53:51 +0000 (23:53 +0000)]
use a straight buffer instead of an iov w/ 1 segment...  The aesni
driver when it hits a mbuf/iov buffer, it mallocs and copies the data
for processing..  This improves perf by ~8-10% on my machine...

I have thoughts of fixing AES-NI so that it can better handle segmented
buffers, which should help improve IPSEC performance, but that is for
the future...

9 years agoRemove an initialized, but otherwise, unused variable.
kargl [Thu, 4 Sep 2014 23:50:05 +0000 (23:50 +0000)]
Remove an initialized, but otherwise, unused variable.

9 years agoSeparate out PCI attachment from the main AHCI driver. Move checks of
imp [Thu, 4 Sep 2014 22:22:53 +0000 (22:22 +0000)]
Separate out PCI attachment from the main AHCI driver. Move checks of
PCI IDs into quirks, which mostly fit (though you'd get no argument
from me that AHCI_Q_SATA1_UNIT0 is oddly specific). Set these quirks
in the PCI attachment. Make some shared functions public so that PCI
and possibly other bus attachments can use them.

The split isn't perfect yet, but it is functional. The split will be
perfected as other bus attachments for AHCI are written.

Sponsored by: Netflix
Reviewed by: kan, mav
Differential Revision: https://reviews.freebsd.org/D699

9 years agoFix a bug which prevented mount.fstab parameter from being converted
hrs [Thu, 4 Sep 2014 22:00:52 +0000 (22:00 +0000)]
Fix a bug which prevented mount.fstab parameter from being converted
when jail_JID_devfs_enable=NO.

Spotted by: peter

9 years agosh: Allow enabling job control without a tty in non-interactive mode.
jilles [Thu, 4 Sep 2014 21:48:33 +0000 (21:48 +0000)]
sh: Allow enabling job control without a tty in non-interactive mode.

If no tty is available, 'set -m' is still useful to put jobs in their own
process groups.

9 years agoReimport dts files from vendor repo now that it has been properly
imp [Thu, 4 Sep 2014 21:48:33 +0000 (21:48 +0000)]
Reimport dts files from vendor repo now that it has been properly
trimmed.

9 years agoAllow multiple image activators to run on the same execution by changing
sbruno [Thu, 4 Sep 2014 21:31:25 +0000 (21:31 +0000)]
Allow multiple image activators to run on the same execution by changing
imgp->interpreted to a bitmask instead of, functionally, a bool. Each
imgactivator now requires its own flag in interpreted to indicate whether
or not it has already examined argv[0].

Change imgp->interpreted to an unsigned char to add one extra bit for
future use.

With this change, one can execute a shell script from a 64bit host native
make and still get the binmisc image activator to fire for the script
interpreter.  Prior to this, execution would fail.

Phabric: https://reviews.freebsd.org/D696
Reviewed by: jhb@
MFC after: 4 weeks

9 years agoDelete old arm dts tree. This was created by cherry picking from a
imp [Thu, 4 Sep 2014 21:28:25 +0000 (21:28 +0000)]
Delete old arm dts tree. This was created by cherry picking from a
full vendor tree. This worked great until it was time to update, but
now it is time to update. Hit the rest button by removing this branch
and re-adding it by a full copy of whatever is in the vendor tree.

9 years agoProperly trim the vendor tree to include only those files that we want
imp [Thu, 4 Sep 2014 21:26:34 +0000 (21:26 +0000)]
Properly trim the vendor tree to include only those files that we want
merged into FreeBSD. Cherry picking from a full vendor tree was too
hard and lead to undestirable svn results.

Note: We only tim the dts* files, we don't trim the dt-bindings tree,
since having all of them causes no problems and the benefit to
trimming there is far out weighed by the cost of doing the trim each
time.

9 years agoAdd mrsas(4) to GENERIC for i386 and amd64.
markj [Thu, 4 Sep 2014 21:06:33 +0000 (21:06 +0000)]
Add mrsas(4) to GENERIC for i386 and amd64.

Approved by: ambrisko, kadesai
MFC after: 3 days

9 years agoUpdate bindings to latest vendor branch representing 3.17-rc2 level of
imp [Thu, 4 Sep 2014 20:48:16 +0000 (20:48 +0000)]
Update bindings to latest vendor branch representing 3.17-rc2 level of
Linux DTS API.

9 years agoStop setting the iomux device status to disabled, now that we have a driver.
ian [Thu, 4 Sep 2014 19:52:17 +0000 (19:52 +0000)]
Stop setting the iomux device status to disabled, now that we have a driver.

9 years agoSatisfy assertion in m_demote().
glebius [Thu, 4 Sep 2014 19:28:02 +0000 (19:28 +0000)]
Satisfy assertion in m_demote().

Sponsored by: Nginx, Inc.

9 years agoChange a very strange code in m_demote() to simple assertion.
glebius [Thu, 4 Sep 2014 19:27:30 +0000 (19:27 +0000)]
Change a very strange code in m_demote() to simple assertion.

Sponsored by: Nginx, Inc.

9 years agoIn tcp_input(), don't acquire the pcbinfo global write lock for SYN
jhb [Thu, 4 Sep 2014 19:09:08 +0000 (19:09 +0000)]
In tcp_input(), don't acquire the pcbinfo global write lock for SYN
packets targeting a listening socket.  Permit to reduce TCP input
processing starvation in context of high SYN load (e.g. short-lived TCP
connections or SYN flood).

Submitted by: Julien Charbon <jcharbon@verisign.com>
Reviewed by: adrian, hiren, jhb, Mike Bentkofsky

9 years agolibc/locale: Remove a wrong comma.
pfg [Thu, 4 Sep 2014 17:36:21 +0000 (17:36 +0000)]
libc/locale: Remove a wrong comma.

This only had some effect when debugging.

Obtained from: DragonflyBSD
MFC after: 3 days

9 years agoFix debug output that has erroneously been committed with the last update.
se [Thu, 4 Sep 2014 17:19:16 +0000 (17:19 +0000)]
Fix debug output that has erroneously been committed with the last update.

Obtained from: Jan Beich
MFC after: 3 days

9 years agoFixes for tcp_respond() comment.
glebius [Thu, 4 Sep 2014 17:05:57 +0000 (17:05 +0000)]
Fixes for tcp_respond() comment.

9 years agoWrap some long lines.
imp [Thu, 4 Sep 2014 16:40:54 +0000 (16:40 +0000)]
Wrap some long lines.

9 years agoImplement the imx_iomux_get/set_gpr() interface for imx6.
ian [Thu, 4 Sep 2014 15:11:57 +0000 (15:11 +0000)]
Implement the imx_iomux_get/set_gpr() interface for imx6.

9 years agoThe iomux driver is no longer optional, all imx platforms have it as
ian [Thu, 4 Sep 2014 14:59:27 +0000 (14:59 +0000)]
The iomux driver is no longer optional, all imx platforms have it as
standard now, so remove it from kernel configs.

9 years agoImplement the same public interface in imx51 and imx6 iomux; use the common
ian [Thu, 4 Sep 2014 14:57:04 +0000 (14:57 +0000)]
Implement the same public interface in imx51 and imx6 iomux; use the common
header file for both.  Remove some unused code from imx51_iomux.  The iomux
drivers are required, not optional, adjust the files.* entries accordingly.

9 years agoRevert r269814: blkfront: add support for unmapped IO
royger [Thu, 4 Sep 2014 14:56:24 +0000 (14:56 +0000)]
Revert r269814: blkfront: add support for unmapped IO

Current busdma code for unmapped bios will not properly align the segment
size, causing corruption on blkfront devices. Revert the commit until
busdma code is fixed.

Reported by: mav
MFC after: 1 day

9 years agoMerge the amd64 and i386 identcpu.c into a single x86 implementation.
jhb [Thu, 4 Sep 2014 14:26:25 +0000 (14:26 +0000)]
Merge the amd64 and i386 identcpu.c into a single x86 implementation.
This brings the structured extended features mask and VT-x reporting to
i386 and Intel cache and TLB info (under bootverbose) to amd64.

9 years agoAdd a basic iomux driver for imx6.
ian [Thu, 4 Sep 2014 14:25:32 +0000 (14:25 +0000)]
Add a basic iomux driver for imx6.

Submitted by: bsam@

9 years agoFix typo in variable name.
ian [Thu, 4 Sep 2014 13:13:42 +0000 (13:13 +0000)]
Fix typo in variable name.

9 years agoAdd initial support for Altera SOCFPGA (heterogeneous ARM/FPGA) SoC family.
br [Thu, 4 Sep 2014 12:44:40 +0000 (12:44 +0000)]
Add initial support for Altera SOCFPGA (heterogeneous ARM/FPGA) SoC family.
Include board configuration for Terasic SoCKit (Altera Cyclone V).

Sponsored by: DARPA, AFRL

9 years agoImprove r265338. When inserting mbufs into TCP reassembly queue,
glebius [Thu, 4 Sep 2014 09:15:44 +0000 (09:15 +0000)]
Improve r265338. When inserting mbufs into TCP reassembly queue,
try to collapse adjacent pieces using m_catpkt(). In best case
scenario it copies data and frees mbufs, making mbuf exhaustion
attack harder.

Suggested by: Jonathan Looney <jonlooney gmail.com>
Security: Hardens against remote mbuf exhaustion attack.
Sponsored by: Netflix
Sponsored by: Nginx, Inc.

9 years agoProvide m_catpkt(), a wrapper around m_cat() that deals with M_PKTHDR mbufs.
glebius [Thu, 4 Sep 2014 09:07:14 +0000 (09:07 +0000)]
Provide m_catpkt(), a wrapper around m_cat() that deals with M_PKTHDR mbufs.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.

9 years agoSystems with lots of geom providers can end up with a kern.geom.confxml
benno [Thu, 4 Sep 2014 03:31:48 +0000 (03:31 +0000)]
Systems with lots of geom providers can end up with a kern.geom.confxml
value too large for the buffer allocated. Work around this by retrying
a few times with larger buffer sizes.

Submitted by: Scott Ferris <scott.ferris@isilon.com>
Reviewed by: mlaier, ngie
Sponsored by: EMC Isilon Storage Division

9 years agoThe imx5x and imx6 chips have an onboard IOMUX device which also contains a
ian [Thu, 4 Sep 2014 03:04:37 +0000 (03:04 +0000)]
The imx5x and imx6 chips have an onboard IOMUX device which also contains a
few "general purpose registers" whose values control chip behavior in ways
that have nothing to do with IO pin mux control.  Define a simple API that
other soc-specific code can use to read and write the registers, and provide
the imx51 implementation of them.

9 years agoRemove a stray blank line from the Intel cache and TLB info.
jhb [Thu, 4 Sep 2014 02:28:17 +0000 (02:28 +0000)]
Remove a stray blank line from the Intel cache and TLB info.

9 years ago- Move blacklists of broken TSCs out of the printcpuinfo() function
jhb [Thu, 4 Sep 2014 02:25:59 +0000 (02:25 +0000)]
- Move blacklists of broken TSCs out of the printcpuinfo() function
  and into the TSC probe routine.
- Initialize cpu_exthigh once in finishidentcpu() which is called
  before printcpuinfo() (and matches the behavior on amd64).

9 years agoFix typo: s/_maske/_mask/
gjb [Thu, 4 Sep 2014 02:06:33 +0000 (02:06 +0000)]
Fix typo: s/_maske/_mask/

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

9 years agoRemove trailing whitespace.
jhb [Thu, 4 Sep 2014 01:56:15 +0000 (01:56 +0000)]
Remove trailing whitespace.

9 years ago- Move prototypes for various functions into out of C files and into
jhb [Thu, 4 Sep 2014 01:46:06 +0000 (01:46 +0000)]
- Move prototypes for various functions into out of C files and into
  <machine/md_var.h>.
- Move some CPU-related variables out of i386/i386/identcpu.c to
  initcpu.c to match amd64.
- Move the declaration of has_f00f_hack out of identcpu.c to machdep.c.
- Remove a misleading comment from i386/i386/initcpu.c (locore zeros
  the BSS before it calls identify_cpu()) and remove explicit zero
  assignments to reduce the diff with amd64.

9 years agoPlug a hypothetical use after free in sysctl kern.proc.groups.
mjg [Thu, 4 Sep 2014 01:21:33 +0000 (01:21 +0000)]
Plug a hypothetical use after free in sysctl kern.proc.groups.

MFC after: 1 week

9 years agoDo not blindly announce 1000baseT half-duplex capability in
yongari [Thu, 4 Sep 2014 01:04:37 +0000 (01:04 +0000)]
Do not blindly announce 1000baseT half-duplex capability in
autonegotiation.  Some controllers like cgem(4) do not support
half-duplex at gigabit speeds.

9 years agoAdd KASSERTs to catch the case where a developer may have forgotten to
benno [Thu, 4 Sep 2014 00:10:06 +0000 (00:10 +0000)]
Add KASSERTs to catch the case where a developer may have forgotten to
set bo_bsize on a bufobj.

This is a slight modification of the patch provided.

PR: 193146
Submitted by: Conrad Meyer <conrad.meyer@isilon.com>
Sponsored by: EMC Isilon Storage Division

9 years agoCreate a /boot/dtb directory to house DTB blobs. The flattened device
imp [Wed, 3 Sep 2014 21:59:07 +0000 (21:59 +0000)]
Create a /boot/dtb directory to house DTB blobs. The flattened device
tree support includes a device tree source compiler dtc(8) which
converts .dts files into .dtb files. /boot/loader will load dtb files
from this directory by default, allowing for fewer differences between
images for different SoCs. Compiled dts files will wind up here
eventually as an alternative to embedding them into the kernel.
Document this in hier(7), as well as add missing entries for
/boot/firmware and /boot/zfs, though the latter two should only be
considered place holders if someone wants to make them better.

9 years agoAdd a function to get the frequency of the AHB bus. Another stopgap
ian [Wed, 3 Sep 2014 21:45:39 +0000 (21:45 +0000)]
Add a function to get the frequency of the AHB bus.  Another stopgap
function until we have full clock support for imx6.

9 years agoWhen built with FDT support, add /boot/dtb to the list of search directories.
ian [Wed, 3 Sep 2014 21:25:36 +0000 (21:25 +0000)]
When built with FDT support, add /boot/dtb to the list of search directories.

9 years agoActually save and restore FPU state on APs during suspend and resume.
jhb [Wed, 3 Sep 2014 21:17:09 +0000 (21:17 +0000)]
Actually save and restore FPU state on APs during suspend and resume.

Committed from: Atom-based HP netbook after resuming in X

9 years agoRemove DIAGNOSTIC from the kernel config of low-end arm systems. Sanity
ian [Wed, 3 Sep 2014 19:37:41 +0000 (19:37 +0000)]
Remove DIAGNOSTIC from the kernel config of low-end arm systems.  Sanity
checks such as vmem_check() can make a low-end system go completely
unresponsive for as much as 3 seconds out of every 10.

9 years agoNote that script(1) consumes filemon(4).
obrien [Wed, 3 Sep 2014 19:06:08 +0000 (19:06 +0000)]
Note that script(1) consumes filemon(4).

9 years agoAlways seek back to the beginning of a regular directory, even if the
jhb [Wed, 3 Sep 2014 19:01:34 +0000 (19:01 +0000)]
Always seek back to the beginning of a regular directory, even if the
previous seek location was 0.  Without this, readdir() would see
dd_loc of zero and call getdirentries() which would start reading
entries at the current seek location of the directory ignoring the
first batch of entries.  Also, rewinddir() should always seek so that
it reads the directory from the beginning to get updated entries.

PR: 192935
Reported by: iron@mail.ua
MFC after: 3 days

9 years agoAvoid ./ in zoneinfo entries in METALOG
emaste [Wed, 3 Sep 2014 18:51:33 +0000 (18:51 +0000)]
Avoid ./ in zoneinfo entries in METALOG

Use of "find ." resulted in METALOG entries with an extra ./ -- e.g.,
./usr/share/zoneinfo/./America/Toronto.  Avoid this by using globbing
via "find *" instead.

Reviewed by: brooks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D719

9 years agoFixes and enhancements for the if_cgem driver...
ian [Wed, 3 Sep 2014 17:51:03 +0000 (17:51 +0000)]
Fixes and enhancements for the if_cgem driver...

- miibus fixes as suggested by Yonghyeon Pyun.
- enable VLAN MTU support.
- fix a few WITNESS complaints in cgem_attach().
- have cgem_attach() properly init the ifnet struct before calling
  mii_attach() to fix panic when using e1000phy.
- fix ethernet address changing.
- fix transmit queue overflow handling.
- tweak receive queue handling to reduce receive overflows.
- bring out MAC statistic counters to sysctls.
- add e1000phy to config file.
- implement receive hang work-around described in reference guide.
- change device name from if_cgem to cgem to be consistent with other
  interfaces.

Submitted by: Thomas Skibo <ThomasSkibo@sbcglobal.net>
Reviewed by: wkoszek, Yonghyeon PYUN <pyunyh@gmail.com>

9 years agoUse sh -c '...' to launch the dtb build scripts with env stuff prepended,
ian [Wed, 3 Sep 2014 17:32:17 +0000 (17:32 +0000)]
Use sh -c '...' to launch the dtb build scripts with env stuff prepended,
otherwise it tries to treat the env var stuff as a script file name.

9 years agoImport a hackish tool I use to examine the skew of the TSC across
jhb [Wed, 3 Sep 2014 17:26:46 +0000 (17:26 +0000)]
Import a hackish tool I use to examine the skew of the TSC across
CPUs in a system.  The tool queries the kernel for its set of CPUs
and compares TSC values on each of the additional CPUs to the first
CPU in turn.  It then outputs a table of simple statistics.

9 years agoUpdate the autofs(5) manual to reflect it first appeared in
gjb [Wed, 3 Sep 2014 17:15:12 +0000 (17:15 +0000)]
Update the autofs(5) manual to reflect it first appeared in
FreeBSD 10.1-RELEASE.

Submitted by: dhw
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

9 years agoApparently, the patch commited in svn r271029 doesn't actually do anyting,
sbruno [Wed, 3 Sep 2014 15:48:07 +0000 (15:48 +0000)]
Apparently, the patch commited in svn r271029 doesn't actually do anyting,
so we still need to modify the code in place. Pointed out by emaste.

MFC after: 2 days
Relnotes: yes

9 years agoDo not direct commit to contrib/llvm. Make the change a patch file instead.
sbruno [Wed, 3 Sep 2014 15:32:38 +0000 (15:32 +0000)]
Do not direct commit to contrib/llvm.  Make the change a patch file instead.
Reverts 271025 but still functionally patches it.  Original intent is still
the same.  Pointed out by rdivacky.

MFV:  Only emit movw on ARMv6T2

Building for the FreeBSD default target ARMv6 was emitting movw ASM on certain
test cases (found building qmake4/5 for ARM).  Don't do that, moreover, the AS
in base doesn't understand this instruction for this target.  One would need
to use --integrated-as to get this to build if desired.

http://llvm.org/viewvc/llvm-project?view=revision&revision=216989

Submitted by: ian
Reviewed by: dim
Obtained from: llvm.org
MFC after: 2 days
Relnotes: yes

9 years agoUse better type for i.
pjd [Wed, 3 Sep 2014 15:08:33 +0000 (15:08 +0000)]
Use better type for i.

9 years agoDeclare i.
pjd [Wed, 3 Sep 2014 15:06:47 +0000 (15:06 +0000)]
Declare i.

Reported by: sbruno

9 years agoFix descriptors leak in case of nvlist_xunpack() failure.
pjd [Wed, 3 Sep 2014 14:44:23 +0000 (14:44 +0000)]
Fix descriptors leak in case of nvlist_xunpack() failure.

Submitted by: Mariusz Zaborski <oshogbo@FreeBSD.org>

9 years agoMFV: Only emit movw on ARMv6T2
sbruno [Wed, 3 Sep 2014 14:16:50 +0000 (14:16 +0000)]
MFV:  Only emit movw on ARMv6T2

Building for the FreeBSD default target ARMv6 was emitting movw ASM on certain
test cases (found building qmake4/5 for ARM).  Don't do that, moreover, the AS
in base doesn't understand this instruction for this target.  One would need
to use --integrated-as to get this to build if desired.

http://llvm.org/viewvc/llvm-project?view=revision&revision=216989

Submitted by: ian
Reviewed by: dim
Obtained from: llvm.org
MFC after: 2 days

9 years agoFix spelling.
hselasky [Wed, 3 Sep 2014 13:15:16 +0000 (13:15 +0000)]
Fix spelling.

PR: 193279
MFC after: 1 week

9 years agoAdd new quirk.
hselasky [Wed, 3 Sep 2014 11:46:43 +0000 (11:46 +0000)]
Add new quirk.

PR: 193279
MFC after: 1 week

9 years ago* Unconditionally turn on SIOCGI2C probing for all interfaces
melifaro [Wed, 3 Sep 2014 11:07:49 +0000 (11:07 +0000)]
* Unconditionally turn on SIOCGI2C probing for all interfaces
    on "ifconfig -v". I've seen no measurable timing difference
    for doing additional SIOCGI2C call for system with 4k vlans.
* Determine appropriate handler (SFP/QSFP) by reading identification
    byte (which is the same for both SFF-8472 and SFF-8436) instead
   of checking driver name.

MFC with: r270064
Sponsored by: Yandex LLC

9 years agoRemove always false comparison.
glebius [Wed, 3 Sep 2014 09:58:59 +0000 (09:58 +0000)]
Remove always false comparison.

Sponsored by: Nginx, Inc.

9 years agoLeave the C11 keywords alone when we have a recent version of GCC.
ed [Wed, 3 Sep 2014 09:35:38 +0000 (09:35 +0000)]
Leave the C11 keywords alone when we have a recent version of GCC.

As GCC also gained support for the C11 keywords over time, we can patch
up <sys/cdefs.h> to not define these anymore. This has the advantage
that error messages for static assertions are printed natively and that
_Alignas() will work with even a type outside of C11 mode.

All C11 keywords are supported with GCC 4.7 and higher, with the
exception of _Thread_local and _Generic. These are only supported as of
GCC 4.9.

9 years agoStyle.
kib [Wed, 3 Sep 2014 08:40:16 +0000 (08:40 +0000)]
Style.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoRetire thread_unthread(), it has only one caller. Update comment in
kib [Wed, 3 Sep 2014 08:35:42 +0000 (08:35 +0000)]
Retire thread_unthread(), it has only one caller.  Update comment in
the block of code before the previous call to thread_unthread().

Discussed with: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoClean up unused CSUM_FRAGMENT.
glebius [Wed, 3 Sep 2014 08:30:18 +0000 (08:30 +0000)]
Clean up unused CSUM_FRAGMENT.

Sponsored by: Nginx, Inc.

9 years agoUse CSUM_BITS instead of incorrect copy.
glebius [Wed, 3 Sep 2014 08:28:16 +0000 (08:28 +0000)]
Use CSUM_BITS instead of incorrect copy.

Sponsored by: Nginx, Inc.

9 years agoRight now, thread_single(SINGLE_EXIT) returns after the p_numthreads
kib [Wed, 3 Sep 2014 08:18:07 +0000 (08:18 +0000)]
Right now, thread_single(SINGLE_EXIT) returns after the p_numthreads
reaches 1. The p_numthreads counter is decremented in thread_exit() by
a call to thread_unlink(). This means that the exiting threads may
still execute on other CPUs when thread_single(SINGLE_EXIT) returns.
As result, vmspace could be destroyed while paging structures are
still used on other CPUs by exiting threads.

Delay the return from thread_single(SINGLE_EXIT) until all threads are
really destroyed by thread_stash() after the last switch out. The
p_exitthreads counter already provides the required mechanism, move
the wait from the thread_wait() (which is called from wait(2) code)
into thread_single().

Reported by: many (as "panic: pmap active <addr>")
Reviewed by: alc, jhb
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

9 years agoFix dereference after NULL check.
glebius [Wed, 3 Sep 2014 08:14:07 +0000 (08:14 +0000)]
Fix dereference after NULL check.

CID: 1234607
Sponsored by: Nginx, Inc.

9 years agoPartially revert r270964. Don't test for C++11 to define _Thread_local.
ed [Wed, 3 Sep 2014 06:34:16 +0000 (06:34 +0000)]
Partially revert r270964. Don't test for C++11 to define _Thread_local.

In addition to Clang 3.3, it turns out that GCC 4.7 in Ports also does
not support the _Thread_local keyword. Let's document this in a bit more
detail.

Reported by: antoine@

9 years agoFix up proc_realparent to always return correct process.
mjg [Wed, 3 Sep 2014 06:25:34 +0000 (06:25 +0000)]
Fix up proc_realparent to always return correct process.

Prior to the change it would always return initproc for non-traced processes.

This fixes ps apparently always returning 1 as ppid.

Pointy hat: mjg
Reported by: many
MFC after: 1 week

9 years agoFix logical error.
hselasky [Wed, 3 Sep 2014 05:14:50 +0000 (05:14 +0000)]
Fix logical error.

MFC after: 3 days

9 years agoInvoke make_dtb with MACHINE defined for enhanced cross building
imp [Wed, 3 Sep 2014 00:32:19 +0000 (00:32 +0000)]
Invoke make_dtb with MACHINE defined for enhanced cross building
friendliness. This should restore old-fashioned kernel building in a
cross environment, though this has only had limited testing.

Sponsored by: Netflix

9 years agoDefine _DTRACE_VERSION in sdt.h rather than setting it manually. This is
markj [Tue, 2 Sep 2014 23:43:06 +0000 (23:43 +0000)]
Define _DTRACE_VERSION in sdt.h rather than setting it manually. This is
similar to what illumos does, and makes it easier to enable USDT probes
in third-party software that doesn't make use of the system makefiles.

9 years agoFix regression introduced by SVN r270954. Correct way to reset getopts
dteske [Tue, 2 Sep 2014 22:59:40 +0000 (22:59 +0000)]
Fix regression introduced by SVN r270954. Correct way to reset getopts
is to set OPTIND to 1, not unset it (which causes an error).

Thanks to: jilles

9 years agoAllow standalone debug for non-default ${PROG} targets
emaste [Tue, 2 Sep 2014 19:05:34 +0000 (19:05 +0000)]
Allow standalone debug for non-default ${PROG} targets

This allows WITH_DEBUG_FILES to produce standalone debug for the ELF
runtime linker.

We previously disabled standalone debug files for bsd.prog.mk consumers
that included a non-default ${PROG} target, but this is not required.

Consumers that do not support standalone debug are still handled by
disabling it for statically linked binaries, and for those that specify
a non-default binary format.

Sponsored by: DARPA, AFRL

9 years agoUse callout(9) instead of timeout(9).
jhb [Tue, 2 Sep 2014 18:57:19 +0000 (18:57 +0000)]
Use callout(9) instead of timeout(9).

Tested by: danfe

9 years agoFix for WITNESS warning while doing xpt_rescan.
kadesai [Tue, 2 Sep 2014 18:32:41 +0000 (18:32 +0000)]
Fix for WITNESS warning while doing xpt_rescan.
This happen when converting any JBOD to RAID or creating
any new RAID from Unconfigured Drives.

Without this fix, user may see below call trace if  WITNESS is enabled.

witness_warn() at witness_warn+0x4b5/frame 0xfffffe011f929a00
uma_zalloc_arg() at uma_zalloc_arg+0x3b/frame 0xfffffe011f929a70
malloc() at malloc+0x192/frame 0xfffffe011f929ac0
mrsas_bus_scan_sim() at mrsas_bus_scan_sim+0x32/frame 0xfffffe011f929af0
mrsas_aen_handler() at mrsas_aen_handler+0x11c/frame 0xfffffe011f929b20
taskqueue_run_locked() at taskqueue_run_locked+0xf0/frame 0xfffffe011f929b80
taskqueue_thread_loop() at taskqueue_thread_loop+0x9b/frame 0xfffffe011f929bb0
fork_exit() at fork_exit+0x84/frame 0xfffffe011f929bf0
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe011f929bf0

Submitted by:   kadesai
Reviewed by:    ambrisko
MFC after:      3 days

9 years agoFix typo in a comment.
rpaulo [Tue, 2 Sep 2014 18:21:19 +0000 (18:21 +0000)]
Fix typo in a comment.

9 years agoThe proper compatibility string for the AHCI device is
imp [Tue, 2 Sep 2014 16:38:00 +0000 (16:38 +0000)]
The proper compatibility string for the AHCI device is
allwinner,sun4i-ahci, so use that instead of the older string which
had become FreeBSD specific.

9 years agoClean up <sys/cdefs.h> slightly.
ed [Tue, 2 Sep 2014 11:16:44 +0000 (11:16 +0000)]
Clean up <sys/cdefs.h> slightly.

- Remove c++0x hack from <sys/cdefs.h> that was needed when Clang did
  not fully implement C++11. We can now safely test against C++11 to
  check whether thread_local is available, like we do for all other
  C++11 keywords.

- Don't use __clang__ to test for thread safety annotation presence. It
  turns out we have a proper attribute for this.

9 years agoUpdate a comment to reflect the changes in r213408.
alc [Tue, 2 Sep 2014 04:11:20 +0000 (04:11 +0000)]
Update a comment to reflect the changes in r213408.

MFC after: 5 days

9 years agoFix typo.
ian [Tue, 2 Sep 2014 03:51:12 +0000 (03:51 +0000)]
Fix typo.

Pointy hat: ian

9 years agoUse OF_xref_from_device(), not OF_xref_from_node(). Also, use bzero()
ian [Tue, 2 Sep 2014 03:46:24 +0000 (03:46 +0000)]
Use OF_xref_from_device(), not OF_xref_from_node().  Also, use bzero()
rather than memset().

9 years agoAdd OF_xref_from_device() so that there's no need to have an intermediate
ian [Tue, 2 Sep 2014 03:45:01 +0000 (03:45 +0000)]
Add OF_xref_from_device() so that there's no need to have an intermediate
call to ofw_bus_get_node() to lookup info that's already in the xreflist.

9 years agoCreate an interface for drivers to enable or disable their clocks as listed
ian [Tue, 2 Sep 2014 03:23:05 +0000 (03:23 +0000)]
Create an interface for drivers to enable or disable their clocks as listed
in the clocks=<...> properties of their FDT data.  The clock properties
consist of 2-cell tuples, each containing a clock device node reference and
a clock number.  A clock device driver can register itself as providing
this interface, then other drivers can turn the FDT clock node reference
into the corresponding device_t so that they can use the interface to query
and manipulate their clocks.

This provides convenience functions to enable or disable all the clocks
listed in the properties for a device, so most drivers will be able to
manage their clocks with a single call to fdt_clock_enable_all(dev).

9 years agoThe anatop driver controls power and PLLs and needs to be available before
ian [Tue, 2 Sep 2014 02:56:43 +0000 (02:56 +0000)]
The anatop driver controls power and PLLs and needs to be available before
just about anything else (other than octop which provides it config info),
so make it an EARLY_DRIVER_MODULE().

9 years agoThe ocotp driver provides access to registers containing chip configuration
ian [Tue, 2 Sep 2014 02:54:55 +0000 (02:54 +0000)]
The ocotp driver provides access to registers containing chip configuration
data that is needed by other drivers, so make it an EARLY_DRIVER_MODULE()
that loads before just about anything else.

9 years agoFix a bug where command line arguments could be misprocessed if getopts is
dteske [Mon, 1 Sep 2014 22:53:47 +0000 (22:53 +0000)]
Fix a bug where command line arguments could be misprocessed if getopts is
used prior to f_dialog_init() -- e.g., in a script that sets
DIALOG_SELF_INITIALIZE to NULL, preventing f_dialog_init() from being run
automaticaly when `dialog.subr' is included. Caused by sub-shell processing
of arguments inheriting prior value of $OPTIND, used by getopts. Solved by
unsetting OPTIND prior to [re-]processing of positional arguments.

9 years agoCreate a mechanism for looking up a device_t associated with an ofw/fdt
ian [Mon, 1 Sep 2014 22:40:31 +0000 (22:40 +0000)]
Create a mechanism for looking up a device_t associated with an ofw/fdt
xref handle, and for registering that association.  Also use the same data
for faster translations between node and xref handles.

Now when fdt properties contain &othernode references, a driver can find
the device instance that corresponds to &othernode, and thus can use
interfaces provided by that instance.

Reviewed by: nwhitehorn

9 years agoAdd bsearch_b to the libc map and the stdlib header.
pfg [Mon, 1 Sep 2014 22:25:42 +0000 (22:25 +0000)]
Add bsearch_b to the libc map and the stdlib header.

bsearch_b is the Apple blocks enabled version of bsearch(3).
This was added to libc in Revision 264042 but the commit
missed the declaration required to make use of it.

While here move some other block-related functions to the
BSD_VISIBLE block as these are non-standard.

Phabric: D638
Reviewed by: theraven, wollman

9 years agoAdd -Wthread-safety to WARNS=6.
ed [Mon, 1 Sep 2014 20:18:09 +0000 (20:18 +0000)]
Add -Wthread-safety to WARNS=6.

While there, add a NO_WTHREAD_SAFETY flag that can be used to disable
this specific warning flag. Disable it for auditdistd. We can easily
patch up auditdistd to have the right annotations to build, but as
auditdistd is intended to be portable across other operating systems,
it's not worth the effort.

Approved by: brueffer@

9 years agoAdd lock annotations to libcuse.
ed [Mon, 1 Sep 2014 19:56:28 +0000 (19:56 +0000)]
Add lock annotations to libcuse.

- Add annotations to the lock/unlock function to indicate that the
  function is allowed to lock and unlock the underlying pthread mutex.

- Add __guarded_by() annotations to the global variables.

Approved by: hselasky@

9 years agosdhci.h has grown a dependency on sysctl.h, include the latter where needed.
ian [Mon, 1 Sep 2014 19:20:34 +0000 (19:20 +0000)]
sdhci.h has grown a dependency on sysctl.h, include the latter where needed.

9 years agoAccording to the ISO C standard, lgamma(-integer) returns
kargl [Mon, 1 Sep 2014 18:57:13 +0000 (18:57 +0000)]
According to the ISO C standard, lgamma(-integer) returns
inf and raises the divided-by-zero exception.  Compilers
constant fold one/zero to inf but do not raise the exception.
Introduce a volatile vzero to prevent the constant folding.

Move the declaration of zero into the main declaration block.

While here, fix a nearby disordering of 'lx,ix'

Discussed with: bde

9 years agoRename OF_xref_phandle() to OF_node_from_xref() and add a new function
ian [Mon, 1 Sep 2014 18:51:01 +0000 (18:51 +0000)]
Rename OF_xref_phandle() to OF_node_from_xref() and add a new function
that provides the inverse translation, OF_xref_from_node().

Discussed with: nwhitehorn

9 years agoAdd lock annotations to the threading API used by hastd.
ed [Mon, 1 Sep 2014 18:37:17 +0000 (18:37 +0000)]
Add lock annotations to the threading API used by hastd.

Approved by: pjd@

9 years agoAdd lock annotations to the header files of our threading libraries.
ed [Mon, 1 Sep 2014 18:34:30 +0000 (18:34 +0000)]
Add lock annotations to the header files of our threading libraries.

This change extends all of the functions present in the <pthread.h> and
<threads.h> headers to have lock annotations. This will allow Clang to
warn about the following:

- Locking a function twice,
- Unlocking a function without a mutex being locked,
- Forgetting to unlock a mutex before returning,
- Destroying or reinitializing a mutex that is currenty locked,
- Using an unlocked mutex in combination with a condition variable.

Enabling these annotations already allowed me to catch a bug in one of
our userspace tools (r270749).