]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoSort sys/ #includes some more
Enji Cooper [Tue, 7 Feb 2017 01:28:55 +0000 (01:28 +0000)]
Sort sys/ #includes some more

MFC after: 1 week
X-MFC with: r313358
Sponsored by: Dell EMC Isilon

7 years agoFix the ifdef protection and remove superfluous extern statements
George V. Neville-Neil [Tue, 7 Feb 2017 01:21:18 +0000 (01:21 +0000)]
Fix the ifdef protection and remove superfluous extern statements

Reported by: Konstantin Belousov
MFC after: 2 weeks
Sponsored by: DARPA, AFRL

7 years agoSort sys/ #includes and zap an unnecessary trailing space nearby
Enji Cooper [Tue, 7 Feb 2017 00:47:33 +0000 (00:47 +0000)]
Sort sys/ #includes and zap an unnecessary trailing space nearby

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoUse a flexible array for TypeNames instead of hardcoding the array length
Enji Cooper [Tue, 7 Feb 2017 00:42:55 +0000 (00:42 +0000)]
Use a flexible array for TypeNames instead of hardcoding the array length

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix typos in comments (returing -> returning)
Enji Cooper [Tue, 7 Feb 2017 00:09:48 +0000 (00:09 +0000)]
Fix typos in comments (returing -> returning)

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years ago[iwm] fix path.
Adrian Chadd [Mon, 6 Feb 2017 21:02:26 +0000 (21:02 +0000)]
[iwm] fix path.

7 years agoAdd kern_vm_mmap2(), kern_vm_mprotect(), kern_vm_msync(), kern_vm_munlock(),
Edward Tomasz Napierala [Mon, 6 Feb 2017 20:57:12 +0000 (20:57 +0000)]
Add kern_vm_mmap2(), kern_vm_mprotect(), kern_vm_msync(), kern_vm_munlock(),
kern_vm_munmap(), and kern_vm_madvise(), and use them in various compats
instead of their sys_*() counterparts.

Reviewed by: ed, dchagin, kib
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9378

7 years agoMake root_mount_hold() work after boot. This is important for two
Edward Tomasz Napierala [Mon, 6 Feb 2017 20:44:34 +0000 (20:44 +0000)]
Make root_mount_hold() work after boot. This is important for two
reasons. First is rerooting into USB-mounted device that happens
to be not yet enumerated. The second is when mounting with (non-root)
filesystem on USB device on a hub that's enumerated later than the root
mount: the rc scripts explicitly mount for the root mount holds to be
released, but each USB bus takes the hold asynchronously, and if that
happens after root mount, it would just get ignored.

Reviewed by: marcel
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9388

7 years agoIn r290196 the root mount hold mechanism was changed to make it not wait
Edward Tomasz Napierala [Mon, 6 Feb 2017 20:36:59 +0000 (20:36 +0000)]
In r290196 the root mount hold mechanism was changed to make it not wait
for mount hold release if the root device already exists.  So, unless your
rootdev is not on USB - ie in the usual case - the root mount won't wait
for USB.  However, the old behaviour was sometimes used as "wait until USB
is fully enumerated", and r290196 broke that.

This commit adds vfs.root_mount_always_wait tunable, to force the kernel
to always wait for root mount holds, even if the root is already there.

Reviewed by: kib
MFC after: 2 weeks
Relnotes: yes
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9387

7 years agoloader: disk io should not use alloca()
Toomas Soome [Mon, 6 Feb 2017 18:44:15 +0000 (18:44 +0000)]
loader: disk io should not use alloca()

The alloca() does give us pointer and we have no practical way to check if the
area is actually available, resulting in corruption in corner cases.

Unfortunately we do not have too many options right now, but to use one page.

Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9455

7 years agoloader: biosdisk fix for 2+TB disks
Toomas Soome [Mon, 6 Feb 2017 18:29:43 +0000 (18:29 +0000)]
loader: biosdisk fix for 2+TB disks

This fix is implementing partition based boundary check for
disk IO and updates disk mediasize (if needed), based on information
from partition table.

As it appeared, the signed int based approach still has corner cases,
and the wrapover based behavior is non-standard.

The idea for this fix is based on two assumptions:

The bug about media size is hitting large (2+TB) disks, lesser disks
hopefully, are not affected.

Large disks are using GPT (which does include information about disk size).
Since our concern is about boot support and boot disks are partitioned,
implementing partition boundaries based IO verification should make the
media size issues mostly disappear.

However, for large disk case, we do have the disk size available from GPT table.
If non-GPT cases will appear, we still can make approximate calculation about
disk size based on defined partition(s), however, this is not the objective
of this patch, and can be added later if there is any need.

This patch does implement disk media size adjustment (if needed) in bd_open(),
and boundary check in bd_realstrategy().

Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D8595

7 years agoRemove arm64_tlb_flushID_SE, it's unused and may be wrong.
Andrew Turner [Mon, 6 Feb 2017 17:50:09 +0000 (17:50 +0000)]
Remove arm64_tlb_flushID_SE, it's unused and may be wrong.

Sponsored by: ABT Systems Ltd

7 years agocxgbe/t4_tom: Fix CLIP entry refcounting on the passive side. Every
Navdeep Parhar [Mon, 6 Feb 2017 17:48:25 +0000 (17:48 +0000)]
cxgbe/t4_tom: Fix CLIP entry refcounting on the passive side.  Every
IPv6 connection being handled by the TOE should have a reference on its
CLIP entry.

Sponsored by: Chelsio Communications

7 years agoUpdate arm and arm64 counters MD bits.
Konstantin Belousov [Mon, 6 Feb 2017 17:20:37 +0000 (17:20 +0000)]
Update arm and arm64 counters MD bits.

On arm64 use atomics.  Then, both arm and arm64 do not need a critical
section around update.  Replace all cpus loop by CPU_FOREACH().
This brings arm and arm64 counter(9) implementation closer to current
amd64, but being more RISC-y, arm* version cannot avoid atomics.

Reported by: Alexandre Martins <alexandre.martins@stormshield.eu>
Reviewed by: andrew
Tested by: Alexandre Martins, andrew
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years agoTemporary disable gicv3_its.c when FDT is missing from the kernel until
Andrew Turner [Mon, 6 Feb 2017 15:24:52 +0000 (15:24 +0000)]
Temporary disable gicv3_its.c when FDT is missing from the kernel until
INTRNG supports ACPI.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation

7 years agosys/arm/arm/identcpu-v4.c: fix identify_arm_cpu()
Stanislav Galabov [Mon, 6 Feb 2017 14:58:24 +0000 (14:58 +0000)]
sys/arm/arm/identcpu-v4.c: fix identify_arm_cpu()

identify_arm_cpu() in sys/arm/arm/identcpu-v4.c incorrectly uses a
u_int8_t variable to store the result of cpu_get_control().
It should really use a u_int variable, the same way as done for cpu_ident()
in the same function, as both cpuid and control registers are 32-bit..
This issue causes users of identcpu-v4 to incorrectly report things such as
icache status (bit 12 in cpu control register) and basically anything
defined in bits above bit 7 :-)

Reviewed by: manu
Sponsored by: Smartcom - Bulgaria AD
Differential Revision: https://reviews.freebsd.org/D9460

7 years agoOnly build the ACPI PCI drivers on x86, they are unlikely to be used on
Andrew Turner [Mon, 6 Feb 2017 14:41:34 +0000 (14:41 +0000)]
Only build the ACPI PCI drivers on x86, they are unlikely to be used on
arm64 without dignificant changes.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation

7 years agoUse 64bit store instruction in atomic_fcmpset_64.
Alexander Kabaev [Mon, 6 Feb 2017 14:00:28 +0000 (14:00 +0000)]
Use 64bit store instruction in atomic_fcmpset_64.

Reported by: br

7 years agoOnly allow the pic type to be either a PIC or MSI type. All interrupt
Andrew Turner [Mon, 6 Feb 2017 13:08:48 +0000 (13:08 +0000)]
Only allow the pic type to be either a PIC or MSI type. All interrupt
controller drivers handle either MSI/MSI-X interrupts, or regular
interrupts, as such enforce this in the interrupt handling framework.
If a later driver was to handle both it would need to create one of each.

This will allow future changes to allow the xref space to overlap, but
refer to different drivers.

Obtained from: ABT Systems Ltd
Sponsored by: The FreeBSD Foundation
X-Differential Revision: https://reviews.freebsd.org/D8616

7 years agogxemul:
Sean Bruno [Mon, 6 Feb 2017 11:37:20 +0000 (11:37 +0000)]
gxemul:

Add a format string to call to g_new_providerf() found when compiling
mips64 target with clang.

Reviewed by: brooks

7 years agoloader: 313329 missed ZFS guard in loader/main.c
Toomas Soome [Mon, 6 Feb 2017 10:57:54 +0000 (10:57 +0000)]
loader: 313329 missed ZFS guard in loader/main.c

Missing guard added.

Reviewed by: imp, allanjude
Approved by: imp (mentor), allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9458

7 years agoAdd ObsoleteFiles entries for bdes(1) missed in r313329
Allan Jude [Mon, 6 Feb 2017 10:51:53 +0000 (10:51 +0000)]
Add ObsoleteFiles entries for bdes(1) missed in r313329

Reported by: delphij
Reviewed by: bapt, imp
Differential Revision: https://reviews.freebsd.org/D9457

7 years agolocks: fix recursion support after recent changes
Mateusz Guzik [Mon, 6 Feb 2017 09:40:14 +0000 (09:40 +0000)]
locks: fix recursion support after recent changes

When a relevant lockstat probe is enabled the fallback primitive is called with
a constant signifying a free lock. This works fine for typical cases but breaks
with recursion, since it checks if the passed value is that of the executing
thread.

Read the value if necessary.

7 years agoloader: Replace EFI part devices.
Toomas Soome [Mon, 6 Feb 2017 09:18:47 +0000 (09:18 +0000)]
loader: Replace EFI part devices.

Rewrite EFI part device interface to present disk devices in more
user friendly way.

We keep list of three types of devices: floppy, cd and disk, the
visible names: fdX: cdX: and diskX:

Use common/disk.c and common/part.c interfaces to manage the
partitioning.

The lsdev -l will additionally list the device path.

Reviewed by: imp, allanjude
Approved by: imp (mentor), allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D8581

7 years agoloader: bcache read ahead block count should take account the large sectors
Toomas Soome [Mon, 6 Feb 2017 08:58:40 +0000 (08:58 +0000)]
loader: bcache read ahead block count should take account the large sectors

The loader bcache is implementing simple read-ahead to boost the cache.
The bcache is built based on 512B block sizes, and the read ahead is attempting
to read number of cache blocks, based on amount of the free bcache space.

However, there are devices using larger sector sizes than 512B, most obviously
the CD media is based on 2k sectors. This means the read-ahead can not be just
random number of blocks, but we should use value suitable also for use with
larger sectors, as for example, with CD devices, we should read multiple of 2KB.
Since the sector size from disk interface is not too reliable, i guess we can
just use "good enough" value, so the implementation is rounding down the read
ahead block count to be multiple of 16.

This means we have covered sector sizes to 8k.

In addition, the update does implement the end of cache marker, to help to
detect the possible memory corruption - I have not seen it happening so far,
but it does not hurt to have the detection mechanism in place.

Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9179

7 years agoAdd removed headers into the ObsoleteFiles.inc.
Andrey V. Elsukov [Mon, 6 Feb 2017 08:56:04 +0000 (08:56 +0000)]
Add removed headers into the ObsoleteFiles.inc.

7 years agoMerge projects/ipsec into head/.
Andrey V. Elsukov [Mon, 6 Feb 2017 08:49:57 +0000 (08:49 +0000)]
Merge projects/ipsec into head/.

 Small summary
 -------------

o Almost all IPsec releated code was moved into sys/netipsec.
o New kernel modules added: ipsec.ko and tcpmd5.ko. New kernel
  option IPSEC_SUPPORT added. It enables support for loading
  and unloading of ipsec.ko and tcpmd5.ko kernel modules.
o IPSEC_NAT_T option was removed. Now NAT-T support is enabled by
  default. The UDP_ENCAP_ESPINUDP_NON_IKE encapsulation type
  support was removed. Added TCP/UDP checksum handling for
  inbound packets that were decapsulated by transport mode SAs.
  setkey(8) modified to show run-time NAT-T configuration of SA.
o New network pseudo interface if_ipsec(4) added. For now it is
  build as part of ipsec.ko module (or with IPSEC kernel).
  It implements IPsec virtual tunnels to create route-based VPNs.
o The network stack now invokes IPsec functions using special
  methods. The only one header file <netipsec/ipsec_support.h>
  should be included to declare all the needed things to work
  with IPsec.
o All IPsec protocols handlers (ESP/AH/IPCOMP protosw) were removed.
  Now these protocols are handled directly via IPsec methods.
o TCP_SIGNATURE support was reworked to be more close to RFC.
o PF_KEY SADB was reworked:
  - now all security associations stored in the single SPI namespace,
    and all SAs MUST have unique SPI.
  - several hash tables added to speed up lookups in SADB.
  - SADB now uses rmlock to protect access, and concurrent threads
    can do SA lookups in the same time.
  - many PF_KEY message handlers were reworked to reflect changes
    in SADB.
  - SADB_UPDATE message was extended to support new PF_KEY headers:
    SADB_X_EXT_NEW_ADDRESS_SRC and SADB_X_EXT_NEW_ADDRESS_DST. They
    can be used by IKE daemon to change SA addresses.
o ipsecrequest and secpolicy structures were cardinally changed to
  avoid locking protection for ipsecrequest. Now we support
  only limited number (4) of bundled SAs, but they are supported
  for both INET and INET6.
o INPCB security policy cache was introduced. Each PCB now caches
  used security policies to avoid SP lookup for each packet.
o For inbound security policies added the mode, when the kernel does
  check for full history of applied IPsec transforms.
o References counting rules for security policies and security
  associations were changed. The proper SA locking added into xform
  code.
o xform code was also changed. Now it is possible to unregister xforms.
  tdb_xxx structures were changed and renamed to reflect changes in
  SADB/SPDB, and changed rules for locking and refcounting.

Reviewed by: gnn, wblock
Obtained from: Yandex LLC
Relnotes: yes
Sponsored by: Yandex LLC
Differential Revision: https://reviews.freebsd.org/D9352

7 years agoRemove bdes(1)
Allan Jude [Mon, 6 Feb 2017 08:27:19 +0000 (08:27 +0000)]
Remove bdes(1)

The use of DES for anything is discouraged, especially with a static IV of 0

If you still need bdes(1) to decrypt Kirk's video lectures, see
security/bdes in ports.

This commit brought to you by the FOSDEM DevSummit and the
"remove unneeded dependancies on openssl in base" working group

Reviewed by: bapt, brnrd
Relnotes: yes
Sponsored by: FOSDEM DevSummit
Differential Revision: https://reviews.freebsd.org/D9424

7 years agoloader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.
Toomas Soome [Mon, 6 Feb 2017 08:26:45 +0000 (08:26 +0000)]
loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.

Need interface to extract information about disk abstraction,
to read disk or partition size depending on the provided argument
and adjust disk size based on information in partition table.

The disk handle from disk_open() has d_offset field to point to
partition start. So we can use this fact to return either whole disk
size or partition size. For this we only need to record partition size
we get from disk_open() anyhow.

In addition, this will also make it possible to adjust the disk media size
based on information from partition table. The problem with disk size is
about some BIOS systems reporting bogus disk size for 2+TB disks, but
since such disks are using GPT partitioning, and GPT does have information
about disk size (alternate LBA + 1), we can use this fact to record disk
size based on partition table.

This patch does exactly this: implements DIOCGSECTORSIZE and DIOCGMEDIASIZE
ioctl, and DIOCGMEDIASIZE will report either disk media size or partition size.

Adds ptable_getsize() call to read partition size in bytes from ptable pointer.
Updates disk_open() to use ptable_getsize() to update mediasize value.

Implements GPT detection function to update ptable size (used by
ptable_getsize()) according to alternate lba (which is location of backup copy
of GPT header table).

Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D8594

7 years agoReflect actual NetBSD revision we already have.
Xin LI [Mon, 6 Feb 2017 07:02:17 +0000 (07:02 +0000)]
Reflect actual NetBSD revision we already have.

MFC after: 3 days

7 years agoo Add mkimg to the cross tools, and use the TMPPATH as PATH to pick up
Warner Losh [Mon, 6 Feb 2017 06:15:38 +0000 (06:15 +0000)]
o Add mkimg to the cross tools, and use the TMPPATH as PATH to pick up
  mkimg for building on systems like FreeBSD 11.0 that don't have my
  -a changes.
o Set NANO_ROOT and NANO_ALTROOT for std-* since their values don't
  change when we set NANO_SLICE*.

PR: 216829
PR: 216830

7 years ago[iwm] Use notification wait API to wait for calibration to complete.
Adrian Chadd [Mon, 6 Feb 2017 05:35:11 +0000 (05:35 +0000)]
[iwm] Use notification wait API to wait for calibration to complete.

Tested:

* 7260, STA mode (2g, 5g)

Obtained from: DragonflyBSD commit 1e0cf8ec6fcd77978f5336297ece61a415790f84

7 years ago[iwm] Add implementation of the notification wait api from iwlwifi.
Adrian Chadd [Mon, 6 Feb 2017 05:27:07 +0000 (05:27 +0000)]
[iwm] Add implementation of the notification wait api from iwlwifi.

Obtained from: Linux iwlwifi
Obtained from: DragonflyBSD commit 94dc1dadceb57b688036211262d678bc6bbdde37

7 years agocxgbe(4): Allow tunables that control the number of queues to be set to
Navdeep Parhar [Mon, 6 Feb 2017 05:19:29 +0000 (05:19 +0000)]
cxgbe(4):  Allow tunables that control the number of queues to be set to
'-n' to tell the driver to create _up to_ 'n' queues if enough cores are
available.  For example, setting hw.cxgbe.nrxq10g="-32" will result in
16 queues if the system has 16 cores, 32 if it has 32.

There is no change in the default number of queues of any type.

MFC after: 1 week
Sponsored by: Chelsio Communications

7 years ago[iwm] Change 2nd arg of iwm_phy_db_set_section() to struct iwm_rx_packet.
Adrian Chadd [Mon, 6 Feb 2017 05:09:42 +0000 (05:09 +0000)]
[iwm] Change 2nd arg of iwm_phy_db_set_section() to struct iwm_rx_packet.

* This matches the function declaration in Linux's iwlwifi.

Obtained from: DragonflyBSD commit de7995a5e0ebf2d0016a87a0142a98c75db58fb4

7 years ago[iwm] Store paging_mem_size field in firmware image information struct.
Adrian Chadd [Mon, 6 Feb 2017 05:08:21 +0000 (05:08 +0000)]
[iwm] Store paging_mem_size field in firmware image information struct.

Obtained from: DragonflyBSD commit a8524cc6c440e5ce9490ba2b0507c99ff6777c6d

7 years ago[iwm] Get rid of some gratuitous constant renaming wrt. Linux iwlwifi.
Adrian Chadd [Mon, 6 Feb 2017 05:07:15 +0000 (05:07 +0000)]
[iwm] Get rid of some gratuitous constant renaming wrt. Linux iwlwifi.

* IWM_UCODE_SECT_MAX -> IWM_UCODE_SECTION_MAX

* IWM_UCODE_TYPE_* -> IWM_UCODE_* (except for IWM_UCODE_TYPE_MAX which
  stays).

Obtained from: DragonflyBSD commit ff4d1fc3ed002c9fb362423da6c45d711b65658a

7 years ago[iwm] Sync valid_tx_ant and valid_rx_ant mask handling with iwlwifi.
Adrian Chadd [Mon, 6 Feb 2017 05:03:41 +0000 (05:03 +0000)]
[iwm] Sync valid_tx_ant and valid_rx_ant mask handling with iwlwifi.

* This fixes the phy_cfg field sent in the iwm_send_phy_cfg_cmd()
  command, which wasn't taking into account the valid_rx_ant and
  valid_tx_ant masks from nvm_data before.

Tested:

* 7260, STA mode, 2G and 5G

Obtained from: DragonflyBSD commit cbb82693c18fd71b4eb86855b82d03995f352d65

7 years ago[iwm] Use chipset configuration structs like iwlwifi does.
Adrian Chadd [Mon, 6 Feb 2017 03:29:50 +0000 (03:29 +0000)]
[iwm] Use chipset configuration structs like iwlwifi does.

* This makes it a bit easier to factor out common parts for e.g. the
  7000 chipset family.

* Add iwm7265d config, and recognize the 7265D chipset variant via the
  hardware revision.

Tested:

* 7260, STA mode (2ghz)

Obtained from: Dragonflybsd commit cc8d6ccf5583fd45964f3bde9b057ee4f834c0e0

7 years ago[iwm] Sync nvm parsing code with Linux iwlwifi.
Adrian Chadd [Mon, 6 Feb 2017 03:06:11 +0000 (03:06 +0000)]
[iwm] Sync nvm parsing code with Linux iwlwifi.

* sc->sc_nvm becomes sc->nvm_data and is now a pointer instead of an
  inlined struct.

* Add sc->eeprom_size and sc->nvm_hw_section_num configuration values to
  struct iwm_softc.

* For now continue to avoid negative error return-values, and use pointer
  variables for some return values, as before.

* Continue to omit LAR (location aware regulatory) related code as well.

Tested:

* Intel 7260, STA mode (2GHz)

Obtained from: dragonflybsd commit 39f8331b1a6f295291e08c377da12a8e7a5436c0

7 years ago[iwm] make sure we call iwm_detach_local() only once.
Adrian Chadd [Mon, 6 Feb 2017 02:20:05 +0000 (02:20 +0000)]
[iwm] make sure we call iwm_detach_local() only once.

Obtained from: DragonflyBSD git ebd4ceab76a6f161362029cbfd08efaedaab0519

7 years ago[iwm] Sync if_iwm_phy_db code with Linux iwlwifi.
Adrian Chadd [Mon, 6 Feb 2017 02:14:34 +0000 (02:14 +0000)]
[iwm] Sync if_iwm_phy_db code with Linux iwlwifi.

Obtained from: Dragonflybsd commit c1019b6bfff36c856f7b4fccbdf3bb13ac27750c

7 years ago[iwm] The HW Revision stepping constants should be in if_iwmreg.h.
Adrian Chadd [Mon, 6 Feb 2017 02:01:22 +0000 (02:01 +0000)]
[iwm] The HW Revision stepping constants should be in if_iwmreg.h.

Obtained from: dragonflybsd 84292f0c38594c462c719c0e59da5908b93aba5f

7 years ago[iwm] TODO for QOS support.
Adrian Chadd [Mon, 6 Feb 2017 01:57:59 +0000 (01:57 +0000)]
[iwm] TODO for QOS support.

7 years ago[iwm] free node reference if rxparams addition fails.
Adrian Chadd [Mon, 6 Feb 2017 01:57:41 +0000 (01:57 +0000)]
[iwm] free node reference if rxparams addition fails.

7 years agoAdd tsw_busy support to usb_serial (ucom).
Ian Lepore [Sun, 5 Feb 2017 15:45:31 +0000 (15:45 +0000)]
Add tsw_busy support to usb_serial (ucom).

The tty layer uses tsw_busy to poll for busy/idle status of the transmitter
hardware during close() and tcdrain(). The ucom layer defines ULSR_TXRDY and
ULSR_TSRE bits for the line status register; when both are set, the
transmitter is idle. Not all chip drivers maintain those bits in the sc_lsr
field, and if the bits never get set the transmitter will always appear
busy, causing hangs in tcdrain().

These changes add a new sc_flag bit, UCOM_FLAG_LSRTXIDLE. When this flag is
set, ucom_busy() uses the lsr bits to return busy vs. idle state, otherwise
it always returns idle (which is effectively what happened before this
change because tsw_busy wasn't implemented).

For the uftdi chip driver, these changes stop masking out the tx idle bits
when processing the status register (because now they're useful), and it
calls ucom_use_lsr_txbits() to indicate the bits are maintained by the
driver and can be used by ucom_busy().

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

7 years agoRegen after r313284.
Dmitry Chagin [Sun, 5 Feb 2017 14:19:19 +0000 (14:19 +0000)]
Regen after r313284.

MFC after: 2 week

7 years agoUpdate syscall.master to 4.10-rc6. Also fix comments, a typo,
Dmitry Chagin [Sun, 5 Feb 2017 14:17:09 +0000 (14:17 +0000)]
Update syscall.master to 4.10-rc6. Also fix comments, a typo,
and wrong numbering for a few unimplemented syscalls.

For 32-bit Linuxulator, socketcall() syscall was historically
the entry point for the sockets API. Starting in Linux 4.3, direct
syscalls are provided for the sockets API. Enable it.

The initial version of patch was provided by trasz@ and extended by me.

Submitted by: trasz
MFC after: 2 week
Differential Revision: https://reviews.freebsd.org/D9381

7 years agoFix linux_pipe() and linux_pipe2() to close file descriptors on copyout
Edward Tomasz Napierala [Sun, 5 Feb 2017 14:03:25 +0000 (14:03 +0000)]
Fix linux_pipe() and linux_pipe2() to close file descriptors on copyout
error.

Reviewed by: dchagin
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9425

7 years agorwlock: move lockstat handling out of inline primitives
Mateusz Guzik [Sun, 5 Feb 2017 13:37:23 +0000 (13:37 +0000)]
rwlock: move lockstat handling out of inline primitives

See r313275 for details.

One difference here is that recursion handling was removed from the fallback
routine. As it is it was never supposed to see a recursed lock in the first
place. Future changes will move it out of inline variants, but right now
there is no easy to way to test if the lock is recursed without reading
additional words.

7 years agoAdd kern_cpuset_getaffinity() and kern_cpuset_getaffinity(),
Edward Tomasz Napierala [Sun, 5 Feb 2017 13:24:54 +0000 (13:24 +0000)]
Add kern_cpuset_getaffinity() and kern_cpuset_getaffinity(),
and use it in compats instead of their sys_*() counterparts.

Reviewed by: kib, jhb, dchagin
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9383

7 years agosx: move lockstat handling out of inline primitives
Mateusz Guzik [Sun, 5 Feb 2017 09:54:16 +0000 (09:54 +0000)]
sx: move lockstat handling out of inline primitives

See r313275 for details.

7 years agomtx: fixup r313278, the assignemnt was supposed to go inside the loop
Mateusz Guzik [Sun, 5 Feb 2017 09:53:13 +0000 (09:53 +0000)]
mtx: fixup r313278, the assignemnt was supposed to go inside the loop

7 years agomtx: fix up _mtx_obtain_lock_fetch usage in thread lock
Mateusz Guzik [Sun, 5 Feb 2017 09:35:17 +0000 (09:35 +0000)]
mtx: fix up _mtx_obtain_lock_fetch usage in thread lock

Since _mtx_obtain_lock_fetch no longer sets the argument to MTX_UNOWNED,
callers have to do it on their own.

7 years agoRestore r312404:
Xin LI [Sun, 5 Feb 2017 08:51:41 +0000 (08:51 +0000)]
Restore r312404:

Use S_ISREG instead of manual & (also it's better to compare the
result from & and the pattern instead of just assuming it's one bit
value).

Pointed out by Tianjie Mao <tjmao tjmao com>.

MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D4827

7 years agoUse kldload -n when loading if_deqna
Enji Cooper [Sun, 5 Feb 2017 08:24:37 +0000 (08:24 +0000)]
Use kldload -n when loading if_deqna

This fixes if_deqna from being loaded by accident twice if it's already loaded
in the kernel.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agomtx: move lockstat handling out of inline primitives
Mateusz Guzik [Sun, 5 Feb 2017 08:04:11 +0000 (08:04 +0000)]
mtx: move lockstat handling out of inline primitives

Lockstat requires checking if it is enabled and if so, calling a 6 argument
function. Further, determining whether to call it on unlock requires
pre-reading the lock value.

This is problematic in at least 3 ways:
- more branches in the hot path than necessary
- additional cacheline ping pong under contention
- bigger code

Instead, check first if lockstat handling is necessary and if so, just fall
back to regular locking routines. For this purpose a new macro is introduced
(LOCKSTAT_PROFILE_ENABLED).

LOCK_PROFILING uninlines all primitives. Fold in the current inline lock
variant into the _mtx_lock_flags to retain the support. With this change
the inline variants are not used when LOCK_PROFILING is defined and thus
can ignore its existence.

This results in:
   text    data     bss     dec     hex filename
22259667 1303208 4994976 28557851 1b3c21b kernel.orig
21797315 1303208 4994976 28095499 1acb40b kernel.patched

i.e. about 3% reduction in text size.

A remaining action is to remove spurious arguments for internal kernel
consumers.

7 years agosx: add witness support missed in r313272
Mateusz Guzik [Sun, 5 Feb 2017 06:51:45 +0000 (06:51 +0000)]
sx: add witness support missed in r313272

7 years agostyle(9) cleanup
Enji Cooper [Sun, 5 Feb 2017 05:36:51 +0000 (05:36 +0000)]
style(9) cleanup

- Delete trailing whitespace
- Fix alignment/variable sorting
- Delete single-line enclosing braces

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agosx: uninline slock/sunlock
Mateusz Guzik [Sun, 5 Feb 2017 05:20:29 +0000 (05:20 +0000)]
sx: uninline slock/sunlock

Shared locking routines explicitly read the value and test it. If the
change attempt fails, they fall back to a regular function which would
retry in a loop.

The problem is that with many concurrent readers the risk of failure is pretty
high and even the value returned by fcmpset is very likely going to be stale
by the time the loop in the fallback routine is reached.

Uninline said primitives. It gives a throughput increase when doing concurrent
slocks/sunlocks with 80 hardware threads from ~50 mln/s to ~56 mln/s.

Interestingly, rwlock primitives are already not inlined.

7 years agosx: switch to fcmpset
Mateusz Guzik [Sun, 5 Feb 2017 04:54:20 +0000 (04:54 +0000)]
sx: switch to fcmpset

Discussed with: jhb
Tested by: pho (previous version)

7 years agorwlock: switch to fcmpset
Mateusz Guzik [Sun, 5 Feb 2017 04:53:13 +0000 (04:53 +0000)]
rwlock: switch to fcmpset

Discussed with: jhb
Tested by: pho

7 years agomtx: switch to fcmpset
Mateusz Guzik [Sun, 5 Feb 2017 03:26:34 +0000 (03:26 +0000)]
mtx: switch to fcmpset

The found value is passed to locking routines in order to reduce cacheline
accesses.

mtx_unlock grows an explicit check for regular unlock. On ll/sc architectures
the routine can fail even if the lock could have been handled by the inline
primitive.

Discussed with: jhb
Tested by: pho (previous version)

7 years agovfs: use atomic_fcmpset in vfs_refcount_*
Mateusz Guzik [Sun, 5 Feb 2017 03:23:16 +0000 (03:23 +0000)]
vfs: use atomic_fcmpset in vfs_refcount_*

7 years agoEnsure that the DOF string length is divisible by 2.
Mark Johnston [Sun, 5 Feb 2017 02:47:34 +0000 (02:47 +0000)]
Ensure that the DOF string length is divisible by 2.

It is an ASCII encoding of a hexadecimal representation of the DOF file
used to enable anonymous tracing, so its length should always be even.

MFC after: 1 week

7 years agoSearch for _DTRACE_VERSION in sys/sdt.h rather than unistd.h.
Mark Johnston [Sun, 5 Feb 2017 02:45:35 +0000 (02:45 +0000)]
Search for _DTRACE_VERSION in sys/sdt.h rather than unistd.h.

MFC after: 1 week

7 years agoAvoid using Sun compiler-specific flags.
Mark Johnston [Sun, 5 Feb 2017 02:44:48 +0000 (02:44 +0000)]
Avoid using Sun compiler-specific flags.

MFC after: 1 week

7 years agoFix a double free of libelf data buffers in the USDT link code.
Mark Johnston [Sun, 5 Feb 2017 02:44:08 +0000 (02:44 +0000)]
Fix a double free of libelf data buffers in the USDT link code.

libdtrace needs to append to the input object files' string and symbol
tables. Currently it does so by allocating a larger buffer, copying the
existing sections into them, and swapping pointers in the libelf data
descriptors. However, it also frees those buffers when its processing is
complete, which leads to a double free since the elftoolchain libelf
owns them and also frees them in elf_end(3). Instead, free the buffers
originally allocated by libelf.

MFC after: 2 weeks

7 years agoUse PC-relative relocations for USDT probe sites on i386 and amd64.
Mark Johnston [Sun, 5 Feb 2017 02:39:12 +0000 (02:39 +0000)]
Use PC-relative relocations for USDT probe sites on i386 and amd64.

When recording probe site addresses in the output DOF file, dtrace -G
needs to emit relocations for the .SUNW_dof section in order to obtain
the addresses of functions containing probe sites. DTrace expects the
addresses to be relative to the base address of the final ELF file,
and the amd64 USDT implementation was relying on some unspecified and
incorrect behaviour in the base system GNU ld to achieve this.

This change reimplements the probe site relocation handling to allow
USDT to be used with lld and newer GNU binutils. Specifically, it
makes use of R_X86_64_PC64/R_386_PC32 relocations to obtain the
probe site address relative to the DOF file address, and adds and uses a
new DOF relocation type which computes the final probe site address using
these relative offsets.

Reported by and discussed with: Rafael EspĂ­ndola
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D9374

7 years agoMake witness_warn() always print to the console.
Mark Johnston [Sun, 5 Feb 2017 02:27:04 +0000 (02:27 +0000)]
Make witness_warn() always print to the console.

witness_warn() either breaks into the debugger or panics the system, so its
output should go to the console regardless of the witness(4) output channel
configuration.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agofd: switch fget_unlocked to atomic_fcmpset
Mateusz Guzik [Sun, 5 Feb 2017 01:40:27 +0000 (01:40 +0000)]
fd: switch fget_unlocked to atomic_fcmpset

7 years agoUse ssize_t instead of uint32_t to prevent warnings about a comparison
Warner Losh [Sun, 5 Feb 2017 01:20:39 +0000 (01:20 +0000)]
Use ssize_t instead of uint32_t to prevent warnings about a comparison
with different signs. Due to the promotion rules, this would only
happen on 32-bit platforms.

7 years agoAdd the ability to dump log pages directly in binary to stdout.
Warner Losh [Sun, 5 Feb 2017 00:55:07 +0000 (00:55 +0000)]
Add the ability to dump log pages directly in binary to stdout.
Update man page to include this flag, and an example of dumping a
vendor-specific page while I'm here.

7 years agoAdd some descriptions to the man page for the supported log pages as
Warner Losh [Sun, 5 Feb 2017 00:45:02 +0000 (00:45 +0000)]
Add some descriptions to the man page for the supported log pages as
well as the new wdc commands. Make wdc be an alias for hgst when
specifying the vendor to use to interpret the page.

7 years agoImplement atomic_fcmpset_*() for RISC-V.
Ruslan Bukin [Sun, 5 Feb 2017 00:32:12 +0000 (00:32 +0000)]
Implement atomic_fcmpset_*() for RISC-V.

Requested by: mjg
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9447

7 years ago[net80211] fix quiet_duration parameter to match what is provided in the manpage.
Adrian Chadd [Sat, 4 Feb 2017 20:57:09 +0000 (20:57 +0000)]
[net80211] fix quiet_duration parameter to match what is provided in the manpage.

7 years agoFix off by one error that truncated the serial number for filenames.
Warner Losh [Sat, 4 Feb 2017 20:43:54 +0000 (20:43 +0000)]
Fix off by one error that truncated the serial number for filenames.

7 years agoFix a typo in usage string for unimplemented command.
Warner Losh [Sat, 4 Feb 2017 20:43:45 +0000 (20:43 +0000)]
Fix a typo in usage string for unimplemented command.

7 years agoFix some more overly long lines, whitespace and other bugs according to
Marius Strobl [Sat, 4 Feb 2017 19:35:38 +0000 (19:35 +0000)]
Fix some more overly long lines, whitespace and other bugs according to
style(9) as well as spelling in comments.

7 years agoStyle, use tab after #define.
Konstantin Belousov [Sat, 4 Feb 2017 19:16:19 +0000 (19:16 +0000)]
Style, use tab after #define.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

7 years agoDelete duplicate break.
Sean Bruno [Sat, 4 Feb 2017 18:25:09 +0000 (18:25 +0000)]
Delete duplicate break.

7 years agoFix bugs found by Coverity in decryptcore(8) and savecore(8):
Konrad Witaszczyk [Sat, 4 Feb 2017 14:10:16 +0000 (14:10 +0000)]
Fix bugs found by Coverity in decryptcore(8) and savecore(8):
- Perform final decryption and write decrypted data in case of non-block aligned
input data;
- Use strlcpy(3) instead of strncpy(3) to verify if paths aren't too long;
- Check errno after calling unlink(2) instead of calling stat(2) in order to
verify if a decrypted core was created by a child process;
- Free dumpkey.

Reported by: Coverity, cem, pfg
Suggested by: cem
CID: 1366936136694213669511366952
Approved by: pjd (mentor)

7 years agoDefine the vm_ooffset_t and vm_pindex_t types as machine-independend.
Konstantin Belousov [Sat, 4 Feb 2017 12:26:38 +0000 (12:26 +0000)]
Define the vm_ooffset_t and vm_pindex_t types as machine-independend.

The types are for the byte offset and page index in vm object.  They
are similar to off_t, which is defined as 64bit MI integer.  Using MI
definitions will allow to provide consistent MD values of vm
object-related maximum sizes.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoRevert r313037
Jason A. Harmening [Sat, 4 Feb 2017 06:24:49 +0000 (06:24 +0000)]
Revert r313037

The switch to get_pcpu() in MI code seems to cause hangs on MIPS.
Back out until we can get a better idea of what's happening there.

Reported by: kan, lidl

7 years agoSwitch hastctl and hastd to libmd instead of openssl for sha256
Allan Jude [Sat, 4 Feb 2017 06:12:48 +0000 (06:12 +0000)]
Switch hastctl and hastd to libmd instead of openssl for sha256

Reviewed by: bapt, brnrd, pjd
Approved by: pjd (maintainer)
Sponsored by: ScaleEngine Inc., FOSDEM DevSummit
Differential Revision: https://reviews.freebsd.org/D9423

7 years agoImplement 5 wdc-specific nvme control options for their HGST drives:
Warner Losh [Sat, 4 Feb 2017 05:53:00 +0000 (05:53 +0000)]
Implement 5 wdc-specific nvme control options for their HGST drives:
wdc cap-diag Capture diagnostic data from drive
wdc drive-log Capture drive history data from drive
wdc get-crash-dump Retrieve firmware crash dump from drive

7 years agoMove the usage and command name lookup into functions.
Warner Losh [Sat, 4 Feb 2017 05:52:53 +0000 (05:52 +0000)]
Move the usage and command name lookup into functions.

7 years agoBack off using CPUTYPE for the moment. There's still some issues with
Warner Losh [Sat, 4 Feb 2017 05:52:51 +0000 (05:52 +0000)]
Back off using CPUTYPE for the moment. There's still some issues with
that.

7 years agoPut the arguments to aligned_alloc in the right order.
Warner Losh [Sat, 4 Feb 2017 05:52:50 +0000 (05:52 +0000)]
Put the arguments to aligned_alloc in the right order.

7 years agoOver the years, the code and comments in vm_page_startup() have diverged in
Alan Cox [Sat, 4 Feb 2017 05:23:10 +0000 (05:23 +0000)]
Over the years, the code and comments in vm_page_startup() have diverged in
one respect.  When determining how many page structures to allocate,
contrary to what the comments say, the code does not account for the
overhead of a page structure per page of physical memory.  This revision
changes the code to match the comments.

Reviewed by: kib, markj
MFC after: 6 weeks
Differential Revision: https://reviews.freebsd.org/D9081

7 years agoCheck that primary GPT header is valid before wiping partitioning.
Andrey V. Elsukov [Sat, 4 Feb 2017 05:09:47 +0000 (05:09 +0000)]
Check that primary GPT header is valid before wiping partitioning.

This allows safely destroy corrupted GPT when primary header was
rewritten by some data, that do not want to destroy.

MFC after: 1 week

7 years agoRemove LOCAL_LIB_DIRS warning added in r275839.
Bryan Drewery [Sat, 4 Feb 2017 02:15:49 +0000 (02:15 +0000)]
Remove LOCAL_LIB_DIRS warning added in r275839.

The case for which this was added, r274807, causes this warning to
always show.  LOCAL_DIRS=foo LOCAL_LIB_DIRS=foo/lib.  The only case in
which r274807 is a problem is if foo/Makefile does not contain
SUBDIR+=lib, which is a normal convention.  LOCAL_LIB_DIRS is a special
hack only to get a library into the _generic_libs list for the
'make libraries' bootstrapping phase.  The old behavior changed in
r274807 was only in head during the 10.0 cycle, so the warning was
only ever needed until release anyhow.

Reported by: ngie
MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoFix typo in variable name (_REDUNDENT_LIB_DIRS -> _REDUNDANT_LIB_DIRS)
Enji Cooper [Sat, 4 Feb 2017 01:21:48 +0000 (01:21 +0000)]
Fix typo in variable name (_REDUNDENT_LIB_DIRS -> _REDUNDANT_LIB_DIRS)

MFC after: 3 days
Sponsored by: Dell EMC Isilon

7 years agoFix grammar in getpeereid(3)
Eric van Gyzen [Sat, 4 Feb 2017 00:37:25 +0000 (00:37 +0000)]
Fix grammar in getpeereid(3)

7 years agoPCIe HotPlug: remove tests for DL active link capability
Eric van Gyzen [Sat, 4 Feb 2017 00:34:00 +0000 (00:34 +0000)]
PCIe HotPlug: remove tests for DL active link capability

As of r313097, the HotPlug code requires the link to support
reporting of the data-link status.  Remove tests for this capability
from code that can now assume its presence.

Suggested by: jhb
Reviewed by: jhb
MFC after: 3 days
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D9431

7 years agoFiles which implement the new random number system code for DTrace
George V. Neville-Neil [Fri, 3 Feb 2017 22:40:13 +0000 (22:40 +0000)]
Files which implement the new random number system code for DTrace

Submitted by: Graeme Jenkinson
MFC after: 2 weeks
Sponsored by: DARPA, AFRL

7 years agoReplace the implementation of DTrace's RAND subroutine for generating
George V. Neville-Neil [Fri, 3 Feb 2017 22:26:19 +0000 (22:26 +0000)]
Replace the implementation of DTrace's RAND subroutine for generating
low-quality random numbers with a modern implementation (xoroshiro128+)
that is capable of generating better quality randomness without compromising performance.

Submitted by: Graeme Jenkinson
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9051

7 years agoClean up documentation of AF_UNIX control messages.
Jilles Tjoelker [Fri, 3 Feb 2017 20:33:23 +0000 (20:33 +0000)]
Clean up documentation of AF_UNIX control messages.

Document AF_UNIX control messages in unix(4) only, not split between unix(4)
and recv(2).

Also, warn about LOCAL_CREDS effective uid/gid fields, since the write could
be from a setuid or setgid program (with the explicit SCM_CREDS and
LOCAL_PEERCRED, the credentials are read at such a time that it can be
assumed that the process intends for them to be used in this context).

Reviewed by: wblock
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D9298

7 years agoRe-enable an accidentally-disabled temp directory creation test.
Warren Block [Fri, 3 Feb 2017 20:17:54 +0000 (20:17 +0000)]
Re-enable an accidentally-disabled temp directory creation test.

Reported by: bjk
Sponsored by: iXsystems

7 years agoDecromulate an extra "if".
Warren Block [Fri, 3 Feb 2017 19:21:28 +0000 (19:21 +0000)]
Decromulate an extra "if".

Reported by: rpokala
Sponsored by: iXsystems