]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoAccount for the fact that jemalloc 5.0.0 dropped STATIC_PAGE_SHIFT
marius [Wed, 31 Jan 2018 21:56:23 +0000 (21:56 +0000)]
Account for the fact that jemalloc 5.0.0 dropped STATIC_PAGE_SHIFT
in favor for using LG_PAGE directly and, thus, for the fact that
host and target don't necessarily use pages of the same sizes.

Approved by: jasone

6 years agopsm(4): Reduce psm watchdog verbosity
wulf [Wed, 31 Jan 2018 21:46:37 +0000 (21:46 +0000)]
psm(4): Reduce psm watchdog verbosity

Modern touchpads do not issue interrupts on inactivity so "lost interrupt"
message became annoying spam nowadays. This change quiets the message
if debug.psm.loglevel=5 (or less) is set in /boot/loader.conf

Approved by: gonzo

6 years agoFix build by escaping a line break.
gjb [Wed, 31 Jan 2018 21:41:42 +0000 (21:41 +0000)]
Fix build by escaping a line break.

PR: 225597
Submitted by: cbnfinley at gmail.com
Sponsored by: The FreeBSD Foundation

6 years agopsm(4): Add support for HP EliteBook 1040 ForcePads.
wulf [Wed, 31 Jan 2018 21:14:59 +0000 (21:14 +0000)]
psm(4): Add support for HP EliteBook 1040 ForcePads.

ForcePads do not have any physical buttons, instead they detect click
based on finger pressure. Forcepads erroneously report button click
if there are 2 or more fingers on the touchpad breaking multifinger
gestures. To workaround this start reporting a click only after
4 consecutive single touch packets has been received. Skip these packets
in case more contacts appear.

PR: 223369
Reported by: Neel Chauhan <neel@neelc.org>
Tested by: Neel Chauhan <neel@neelc.org>
Reviewed by: gonzo
Approved by: gonzo

6 years agoDon't include long double routines on architectures with small long double.
jhb [Wed, 31 Jan 2018 18:13:33 +0000 (18:13 +0000)]
Don't include long double routines on architectures with small long double.

Reviewed by: emaste
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D13874

6 years agoUpdate limits on makecontext() arguments in the setcontext_link test.
jhb [Wed, 31 Jan 2018 18:03:40 +0000 (18:03 +0000)]
Update limits on makecontext() arguments in the setcontext_link test.

sparc64 and riscv do not support 10 arguments, but MIPS now does.
While here, combine clauses for architectures that support the same
number of arguments to reduce duplication.

Sponsored by: DARPA / AFRL

6 years agoAdd a new set of simple tests for makecontext().
jhb [Wed, 31 Jan 2018 18:02:02 +0000 (18:02 +0000)]
Add a new set of simple tests for makecontext().

In contrast to the existing NetBSD setcontext_link test, these tests
verify that passing from 1 to 6 arguments through to the callback function
work correctly which can be useful for testing ABIs which split arguments
between registers and the stack.

Sponsored by: DARPA / AFRL

6 years agoRemove limitation of 6 arguments for makecontext() on mips.
jhb [Wed, 31 Jan 2018 18:00:23 +0000 (18:00 +0000)]
Remove limitation of 6 arguments for makecontext() on mips.

This implementation spills additional arguments on the stack so works
fine with more than 6 arguments.  I believe the check was just copied
over from sparc64 (which doesn't support spilling onto the stack)

Sponsored by: DARPA / AFRL

6 years agoRemove bogus checks against NCARGS.
jhb [Wed, 31 Jan 2018 17:57:59 +0000 (17:57 +0000)]
Remove bogus checks against NCARGS.

NCARGS isn't a limit on the number of arguments to pass to a function,
but the number of bytes that can be consumed by arguments to exec.  As
such, it is not suitable for a limit on the count of arguments passed
to makecontext().

Sponsored by: DARPA / AFRL

6 years agoClarify that the additional arguments to makecontext() are of type int.
jhb [Wed, 31 Jan 2018 17:56:36 +0000 (17:56 +0000)]
Clarify that the additional arguments to makecontext() are of type int.

MFC after: 1 week
Sponsored by: DARPA / AFRL

6 years agoConsistently use 16-byte alignment for MIPS N32 and N64.
jhb [Wed, 31 Jan 2018 17:36:39 +0000 (17:36 +0000)]
Consistently use 16-byte alignment for MIPS N32 and N64.

- Add a new <machine/abi.h> header to hold constants shared between C
  and assembly such as CALLFRAME_SZ.
- Add a new STACK_ALIGN constant to <machine/abi.h> and use it to
  replace hardcoded constants in the kernel and makecontext().  As a
  result of this, ensure the stack pointer on N32 and N64 is 16-byte
  aligned for N32 and N64 after exec(), after pthread_create(), and
  when sending signals rather than 8-byte aligned.

Reviewed by: jmallett
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D13875

6 years agoWhen switching IBRS on, also enable STIBP (Single Thread Indirect
kib [Wed, 31 Jan 2018 16:56:02 +0000 (16:56 +0000)]
When switching IBRS on, also enable STIBP (Single Thread Indirect
Branch Predictors) mitigation.

DOcument 336996-001 promises that CPUs which implement IBRS but not
STIBP silently ignore setting of the bit instead of trapping.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoExpand IBRS TLA in sysctl help lines.
kib [Wed, 31 Jan 2018 16:54:05 +0000 (16:54 +0000)]
Expand IBRS TLA in sysctl help lines.

Requested by: bz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agozfs_rezget: drop cached pages before doing anything else
avg [Wed, 31 Jan 2018 14:44:51 +0000 (14:44 +0000)]
zfs_rezget: drop cached pages before doing anything else

We did that in the case of success to prevent the use of stale cached
data, but it makes even less sense to keep the cached data when we fail.

Ideally, we should call vgone() on the vnode in the case of zfs_rezget
failure, but the current lock order prevents us from doing that.

The change also rearranges the order of unlinked check and the size
change check.

While there, add missing SET_ERROR in one of the error paths.

MFC after: 2 weeks

6 years agoIBRS support, AKA Spectre hardware mitigation.
kib [Wed, 31 Jan 2018 14:36:27 +0000 (14:36 +0000)]
IBRS support, AKA Spectre hardware mitigation.

It is coded according to the Intel document 336996-001, reading of the
patches posted on lkml, and some additional consultations with Intel.

For existing processors, you need a microcode update which adds IBRS
CPU features, and to manually enable it by setting the tunable/sysctl
hw.ibrs_disable to 0.  Current status can be checked in sysctl
hw.ibrs_active.  The mitigation might be inactive if the CPU feature
is not patched in, or if CPU reports that IBRS use is not required, by
IA32_ARCH_CAP_IBRS_ALL bit.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D14029

6 years agoDo not enable PTI when IA32_ARCH_CAP_RDCL_NO bit is set.
kib [Wed, 31 Jan 2018 14:25:42 +0000 (14:25 +0000)]
Do not enable PTI when IA32_ARCH_CAP_RDCL_NO bit is set.

Intel document 336996-001 claims that this will be the way to inform
about Meltdown correction.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoProperly implement the cond_resched() function macro in the LinuxKPI.
hselasky [Wed, 31 Jan 2018 13:40:36 +0000 (13:40 +0000)]
Properly implement the cond_resched() function macro in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agovmm/svm: post LAPIC interrupts using event injection, not virtual interrupts
avg [Wed, 31 Jan 2018 11:14:26 +0000 (11:14 +0000)]
vmm/svm: post LAPIC interrupts using event injection, not virtual interrupts

The virtual interrupt method uses V_IRQ, V_INTR_PRIO, and V_INTR_VECTOR
fields of VMCB to inject a virtual interrupt into a guest VM.  This
method has many advantages over the direct event injection as it
offloads all decisions of whether and when the interrupt can be
delivered to the guest.  But with a purely software emulated vAPIC the
advantage is also a problem.  The problem is that the hypervisor does
not have any precise control over when the interrupt is actually
delivered to the guest (or a notification about that).  Because of that
the hypervisor cannot update the interrupt vector in IRR and ISR in the
same way as real hardware would.  The hypervisor becomes aware that the
interrupt is being serviced only upon the first VMEXIT after the
interrupt is delivered.  This creates a window between the actual
interrupt delivery and the update of IRR and ISR.  That means that IRR
and ISR might not be correctly set up to the point of the
end-of-interrupt signal.

The described deviation has been observed to cause an interrupt loss in
the following scenario.  vCPU0 posts an inter-processor interrupt to
vCPU1.  The interrupt is injected as a virtual interrupt by the
hypervisor.  The interrupt is delivered to a guest and an interrupt
handler is invoked.  The handler performs a requested action and
acknowledges the request by modifying a global variable.  So far, there
is no VMEXIT and the hypervisor is unaware of the events.  Then, vCPU0
notices the acknowledgment and sends another IPI with the same vector.
The IPI gets collapsed into the previous IPI in the IRR of vCPU1.  Only
after that a VMEXIT of vCPU1 occurs.  At that time the vector is cleared
in the IRR and is set in the ISR.  vCPU1 has vAPIC state as if the
second IPI has never been sent.
The scenario is impossible on the real hardware because IRR and ISR are
updated just before the interrupt handler gets started.

I saw several possibilities of fixing the problem.  One is to intercept
the virtual interrupt delivery to update IRR and ISR at the right
moment.  The other is to deliver the LAPIC interrupts using the event
injection, same as legacy interrupts.  I opted to use the latter
approach for several reasons.  It's equivalent to what VMM/Intel does
(in !VMX case).  It appears to be what VirtualBox and KVM do.  The code
is already there (to support legacy interrupts).

Another possibility was to use a special intermediate state for a vector
after it is injected using a virtual interrupt and before it is known
whether it was accepted or is still pending.
That approach was implemented in https://reviews.freebsd.org/D13828
That method is more complex and does not have any clear advantage.

Please see sections 15.20 and 15.21.4 of "AMD64 Architecture
Programmer's Manual Volume 2: System Programming" (publication 24593,
revision 3.29) for comparison between event injection and virtual
interrupt injection.

PR: 215972
Reported by: ajschot@hotmail.com, grehan
Tested by: anish, grehan,  Nils Beyer <nbe@renzel.net>
Reviewed by: anish, grehan
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D13780

6 years ago[arswitch] Fix ATU programming on the AR8327 switch.
adrian [Wed, 31 Jan 2018 07:37:33 +0000 (07:37 +0000)]
[arswitch] Fix ATU programming on the AR8327 switch.

Doing a flush actually requires setting this bit.

6 years ago[arswitch] Fix ATU flushing on AR8216/AR8316 and most of the later chips.
adrian [Wed, 31 Jan 2018 07:36:51 +0000 (07:36 +0000)]
[arswitch] Fix ATU flushing on AR8216/AR8316 and most of the later chips.

The switch hardware requires this bit to be set in order to kick start the
actual ATU update.  This was being masked on some chips by the learning
programming (what to do when a MAC address moves, hash table collision, etc)
which is currently inconsistent between chips.

Tested:

* AR9344 SoC (AR7240 style switch internal)

6 years ago[arswitch] add a new debug section for upcoming address table management.
adrian [Wed, 31 Jan 2018 07:20:34 +0000 (07:20 +0000)]
[arswitch] add a new debug section for upcoming address table management.

6 years agoPowerNV: fix compilation on non-NV platforms
wma [Wed, 31 Jan 2018 06:42:01 +0000 (06:42 +0000)]
PowerNV: fix compilation on non-NV platforms

Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies

6 years agoUpdate stand.h for changes for strto*l
imp [Wed, 31 Jan 2018 05:07:43 +0000 (05:07 +0000)]
Update stand.h for changes for strto*l

Move prototypes to proper section now that we don't have modified
versions of strtol and strtoul in libsa. Add prototypes for new
strtoll and strtoull. Use prototypes copied from stdlib.h instead of
the old hand-rolled ones.

(I forgot to move this file form my lua branch in r328613)

6 years agoMove libstand.3 to libsa.3. Update libsa.3 to include functions
imp [Wed, 31 Jan 2018 04:29:05 +0000 (04:29 +0000)]
Move libstand.3 to libsa.3. Update libsa.3 to include functions
recently added. More are likely missing.

6 years agoKill copies of strtol and strtoul. Use the ones that are in libc,
imp [Wed, 31 Jan 2018 04:29:00 +0000 (04:29 +0000)]
Kill copies of strtol and strtoul. Use the ones that are in libc,
since they suffice. Create xlocale_private.h which provides the most
minimal locale implementation we can get away with. Add strtoll and
strtoull from libc.

6 years agoMove strtold wrapper from strtol.c to its own strtold.c. This code
imp [Wed, 31 Jan 2018 03:05:14 +0000 (03:05 +0000)]
Move strtold wrapper from strtol.c to its own strtold.c.  This code
was written by theraven@ (David Chisnall) entirely, there's no
original Berkeley code left here so just copy his copyright over.

6 years agoTry to preallocate receive memory early.
mav [Wed, 31 Jan 2018 01:04:36 +0000 (01:04 +0000)]
Try to preallocate receive memory early.

We may not have enough contiguous memory later, when NTB connection get
established.  It is quite likely that NTB windows are symmetric and this
allocation remain, but even if not, we will just reallocate it later.

MFC after: 2 weeks

6 years agoEnsure 'name' is not NULL before passing to strcmp().
jhb [Tue, 30 Jan 2018 23:29:27 +0000 (23:29 +0000)]
Ensure 'name' is not NULL before passing to strcmp().

This avoids a nested page fault when obtaining a stack trace in DDB if
the address from the first frame does not resolve to a known symbol.

MFC after: 1 week
Sponsored by: Chelsio Communications

6 years agoExport tcp_always_keepalive for use by the Chelsio TOM module.
jhb [Tue, 30 Jan 2018 23:01:37 +0000 (23:01 +0000)]
Export tcp_always_keepalive for use by the Chelsio TOM module.

This used to work by accident with ld.bfd even though always_keepalive
was marked as static. LLD honors static more correctly, so export this
variable properly (including moving it into the tcp_* namespace).

Reviewed by: bz, emaste
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D14129

6 years agozfsd: Don't spare a vdev that's being replaced
asomers [Tue, 30 Jan 2018 21:25:43 +0000 (21:25 +0000)]
zfsd: Don't spare a vdev that's being replaced

If a zfs pool contains a replacing vdev (either created manually by "zpool
replace" or by zfsd(8) via autoreplace by physical path) and then new spares
get added to the pool, zfsd shouldn't use one to replace the drive that is
already being replaced.  That's a waste of resources that just slows down
the rebuild.

PR: 225547
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

6 years agoAdd missing non-POWERPC case to give the scr value something non-zero.
sbruno [Tue, 30 Jan 2018 20:00:12 +0000 (20:00 +0000)]
Add missing non-POWERPC case to give the scr value something non-zero.

This fixes the instant reboot of netbooting after r328536 on x86 systems.

Reviewed by: peter
Sponsored by: Limelight Networks

6 years agomakesyscalls: permit a range of syscall numbers for UNIMPL
emaste [Tue, 30 Jan 2018 18:29:38 +0000 (18:29 +0000)]
makesyscalls: permit a range of syscall numbers for UNIMPL

Some ABIs have large gaps in syscall numbers.  Allow gaps to be filled
as ranges of UNIMPL, with an entry like:

248-1023 AUE_NULL UNIMPL unimplemented

Reviewed by: jhb, gnn
Sponsored by: Turing Robotic Industries Inc.
Differential Revision: https://reviews.freebsd.org/D14122

6 years agoPull in r322131 from upstream llvm trunk (by Rafael Espíndola):
emaste [Tue, 30 Jan 2018 16:43:20 +0000 (16:43 +0000)]
Pull in r322131 from upstream llvm trunk (by Rafael Espíndola):

  Use a MCExpr for the size of MCFillFragment.

  This allows the size to be found during ralaxation. This fixes
  [LLVM] pr35858.

Requested by: royger

6 years agoPull in r322123 from upstream llvm trunk (by Rafael Espíndola):
emaste [Tue, 30 Jan 2018 16:42:08 +0000 (16:42 +0000)]
Pull in r322123 from upstream llvm trunk (by Rafael Espíndola):

  Don't create MCFillFragment directly.

  Instead use higher level APIs that take care of most bookkeeping.

6 years agoPull in r322108 from upstream llvm trunk (by Rafael Espíndola):
emaste [Tue, 30 Jan 2018 16:41:38 +0000 (16:41 +0000)]
Pull in r322108 from upstream llvm trunk (by Rafael Espíndola):

  Make one of the emitFill methods non virtual. NFC.

  This is just preparatory work to fix [LLVM] PR35858.

6 years agoChange installer default to not install ports tree
swills [Tue, 30 Jan 2018 16:34:56 +0000 (16:34 +0000)]
Change installer default to not install ports tree

Reviewed by: gjb, dteske, allanjude, bdrewery, mat
Approved by: gjb
Differential Revision: https://reviews.freebsd.org/D14064

6 years agoMove the mlx5 core device pointer first in the mlx5en priv. This help simplify
hselasky [Tue, 30 Jan 2018 12:38:06 +0000 (12:38 +0000)]
Move the mlx5 core device pointer first in the mlx5en priv. This help simplify
checks to recognize own network devices when using mlx5ib. This patch fixes
an issues where mlx5ib fails to recognize mceX network devices for use with
RoCE.

MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoDocument the new hw.usb.template behaviour.
trasz [Tue, 30 Jan 2018 10:10:02 +0000 (10:10 +0000)]
Document the new hw.usb.template behaviour.

MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agoMake the handler routine for the hw.usb.template sysctl trigger the USB
trasz [Tue, 30 Jan 2018 10:08:11 +0000 (10:08 +0000)]
Make the handler routine for the hw.usb.template sysctl trigger the USB
host to reprobe the bus by switching the USB pull up resistors off and
back on.  In other words - when FreeBSD is configured as a USB device,
changing the sysctl will be immediately noticed by the machine it's
connected to.

Reviewed by: hselasky@
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

6 years agonfsstat: Add libxo output
manu [Tue, 30 Jan 2018 09:59:52 +0000 (09:59 +0000)]
nfsstat: Add libxo output

Add libxo output support
Merge exp41_intpr and exp_intpr function. The only difference is to print
NFSV4.1 operations in exp41, add a third arguement to control that.
printtitle was set to 1 and don't have a switch, add a -q options to control it.

Reviewed by: bapt
Sponsored by: Gandi.net
Differential Revision: https://reviews.freebsd.org/D14012

6 years agoUse more verbose panic messages.
mmel [Tue, 30 Jan 2018 04:06:30 +0000 (04:06 +0000)]
Use more verbose panic messages.

MFC after: 2 weeks

6 years agoRevert r328511, it was committed with <patch>.diff instead of <patch>.txt as
mmel [Tue, 30 Jan 2018 04:05:03 +0000 (04:05 +0000)]
Revert r328511, it was committed with <patch>.diff instead of <patch>.txt as
commit log.

6 years agostand/fdt: Remove unused write-only new_fdtp, correct comment
kevans [Tue, 30 Jan 2018 03:31:40 +0000 (03:31 +0000)]
stand/fdt: Remove unused write-only new_fdtp, correct comment

MFC after: 3 days

6 years agolibedit: sort the Makefile in line with NetBSD's version.
pfg [Mon, 29 Jan 2018 22:38:23 +0000 (22:38 +0000)]
libedit: sort the Makefile in line with NetBSD's version.

NetBSD's libedit has been been cleaned-up considerably so the
non--widecharacter version is no longer an option. Re -sorting the
Makefile should make it easier for some brave soul trying to update it.

No functional change intended.

MFC after: 5 days

6 years agoFix mistake in case of zeroed inode check.
fsu [Mon, 29 Jan 2018 22:15:46 +0000 (22:15 +0000)]
Fix mistake in case of zeroed inode check.

Reported by: pho
MFC after: 6 months

6 years agoAdd flex_bg/meta_bg features RW support.
fsu [Mon, 29 Jan 2018 21:54:13 +0000 (21:54 +0000)]
Add flex_bg/meta_bg features RW support.

Reviewed by:    pfg
MFC after:      6 months

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

6 years agoDon't use an .OBJDIR for 'make sysent'.
bdrewery [Mon, 29 Jan 2018 19:14:15 +0000 (19:14 +0000)]
Don't use an .OBJDIR for 'make sysent'.

Reported by: emaste, jhb
Sponsored by: Dell EMC

6 years agoRemove t_grep:mmap_eof_not_eol test
kevans [Mon, 29 Jan 2018 18:50:45 +0000 (18:50 +0000)]
Remove t_grep:mmap_eof_not_eol test

The test was marked as an expected failure in r320414 after r319971's import
of a newer jemalloc removed an essential feature (opt.redzone) for
reproducing the behavior it was testing. Since then, no way has been found
or demonstrated to reliably test the behavior, so remove the test.

PR: 220309

6 years agoDo the book-keeping on release before we release the reference. The
imp [Mon, 29 Jan 2018 18:07:14 +0000 (18:07 +0000)]
Do the book-keeping on release before we release the reference. The
periph was going away on final release, and then returning and we
started dancing in free memory.

Sponsored by: Netflix

6 years agoRemove some duplicated sys/conf/files* entries.
benno [Mon, 29 Jan 2018 17:32:30 +0000 (17:32 +0000)]
Remove some duplicated sys/conf/files* entries.

net80211/ieee80211_ageq.c was present twice in sys/conf/files so leave the
correctly sorted one. dev/wpi/if_wpi.c was present in sys/conf/files as well
as sys/conf/files.amd64 and sys/conf/files.i386 so prefer the sys/conf/files
entry.

Reviewed by: allanjude, rstone

6 years agoND6: Set the correct state for new neighbor cache entries
vangyzen [Mon, 29 Jan 2018 16:12:26 +0000 (16:12 +0000)]
ND6: Set the correct state for new neighbor cache entries

Restore state 6.  Many of the UNH tests end up exercising this
state, where we have a new neighbor cache entry and a new link-layer
entry is being created for it.  The link-layer address is currently
unknown so the initial state of the "llentry" should remain initialized
to ND6_LLINFO_NOSTATE so that the ND code will send a solicitation.
Setting this to ND6_LLINFO_STALE implies that the link-level entry
is valid and can be used (but needs to be refreshed via the Neighbor
Unreachability state machine).

https://forums.freebsd.org/threads/64287/

Submitted by: Farrell Woods <Farrell_Woods@Dell.com>
Reviewed by: mjoras, dab, ae
MFC after: 1 week
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D14059

6 years agopppctl88) Avoid strcpy() copies on overlapping string.
pfg [Mon, 29 Jan 2018 14:23:44 +0000 (14:23 +0000)]
pppctl88) Avoid strcpy() copies on overlapping string.

This may lead to unpredicatable behaviour on different platforms or C
library implementations. Use an intermediate variable.

Obtained from: DragonFlyBSD (git a861a526)

6 years agoawk(1): Don't install tests at all
kevans [Mon, 29 Jan 2018 14:15:44 +0000 (14:15 +0000)]
awk(1): Don't install tests at all

Tests were disconnected so that running `make check` in usr.bin/awk did not
have any effect, but CI runs use installed tests. Fully disconnect tests/
from the build for the time being as a short term solutio

Reported by: lwhsu

6 years agolibregex: Mark gnuext test as an expected fail
kevans [Mon, 29 Jan 2018 14:00:33 +0000 (14:00 +0000)]
libregex: Mark gnuext test as an expected fail

The test was added prematurely as a goal to reach with the GNU extension
functionality, but the functionality has not yet been introduced. Mark it as
an expected fail until that point.

6 years agolld: Put the header in the first PT_LOAD even if that PT_LOAD has a LMAExpr
emaste [Mon, 29 Jan 2018 13:55:50 +0000 (13:55 +0000)]
lld: Put the header in the first PT_LOAD even if that PT_LOAD has a LMAExpr

The root problem is that we were creating a PT_LOAD just for the header.
That was technically valid, but inconvenient: we should not be making
the ELF discontinuous.

The solution is to allow a section with LMAExpr to be added to a PT_LOAD
if that PT_LOAD doesn't already have a LMAExpr.

LLVM PR: 36017
Obtained from: LLVM r323625 by Rafael Espindola

6 years agolld: Move LMAOffset from the OutputSection to the PhdrEntry. NFC.
emaste [Mon, 29 Jan 2018 13:54:51 +0000 (13:54 +0000)]
lld: Move LMAOffset from the OutputSection to the PhdrEntry. NFC.

If two sections are in the same PT_LOAD, their relatives offsets,
virtual address and physical addresses are all the same.

[Rafael] initially wanted to have a single global LMAOffset, on the
assumption that every ELF file was in practiced loaded contiguously in
both physical and virtual memory.

Unfortunately that is not the case. The linux kernel has:

  LOAD           0x200000 0xffffffff81000000 0x0000000001000000 0xced000 0xced000 R E 0x200000
  LOAD           0x1000000 0xffffffff81e00000 0x0000000001e00000 0x15f000 0x15f000 RW  0x200000
  LOAD           0x1200000 0x0000000000000000 0x0000000001f5f000 0x01b198 0x01b198 RW  0x200000
  LOAD           0x137b000 0xffffffff81f7b000 0x0000000001f7b000 0x116000 0x1ec000 RWE 0x200000

The delta for all but the third PT_LOAD is the same:
0xffffffff80000000. [Rafael] thinks the 3rd one is a hack for implementing
per cpu data, but we can't break that.

Obtained from: LLVM r323456 by Rafael Espindola

6 years agolld: Improve LMARegion handling.
emaste [Mon, 29 Jan 2018 13:52:42 +0000 (13:52 +0000)]
lld: Improve LMARegion handling.

This fixes the crash reported at [LLVM] PR36083.

The issue is that we were trying to put all the sections in the same
PT_LOAD and crashing trying to write past the end of the file.

This also adds accounting for used space in LMARegion, without it all
3 PT_LOADs would have the same physical address.

Obtained from: LLVM r323449 by Rafael Espindola

6 years agolld: Simplify. NFC.
emaste [Mon, 29 Jan 2018 13:51:13 +0000 (13:51 +0000)]
lld: Simplify. NFC.

Obtained from: LLVM r323440 by Rafael Espindola

6 years agolld: Remove MemRegionOffset. NFC.
emaste [Mon, 29 Jan 2018 13:50:28 +0000 (13:50 +0000)]
lld: Remove MemRegionOffset. NFC.

We can just use a member variable in MemoryRegion.

Obtained from: LLVM r323399 by Rafael Espindola

6 years agolld: Only lookup LMARegion once. NFC.
emaste [Mon, 29 Jan 2018 13:49:10 +0000 (13:49 +0000)]
lld: Only lookup LMARegion once. NFC.

This is similar to how we handle MemRegion.

Obtained from: LLVM r323396 by Rafael Espindola

6 years agolld: Use lookup instead of find. NFC, just simpler.
emaste [Mon, 29 Jan 2018 13:48:15 +0000 (13:48 +0000)]
lld: Use lookup instead of find. NFC, just simpler.

Obtained from: LLVM r323395 by Rafael Espindola

6 years agoDo not skip scope zone violation check, when mbuf has M_FASTFWD_OURS flag.
ae [Mon, 29 Jan 2018 11:03:29 +0000 (11:03 +0000)]
Do not skip scope zone violation check, when mbuf has M_FASTFWD_OURS flag.

When mbuf has M_FASTFWD_OURS flag, this means that a destination address
is our local, but we still need to pass scope zone violation check,
because protocol level expects that IPv6 link-local addresses have
embedded scope zone indexes. This should fix the problem, when ipfw is
used to forward packets to local address and source address of a packet
is IPv6 LLA.

Reported by: sbruno
MFC after: 3 weeks

6 years agoAssign IPv6 link-local address to loopback interfaces whith unit > 0.
ae [Mon, 29 Jan 2018 10:33:55 +0000 (10:33 +0000)]
Assign IPv6 link-local address to loopback interfaces whith unit > 0.

When an interface has IFF_LOOPBACK flag in6_ifattach() tries to assing
IPv6 loopback address to this interface. It uses in6ifa_ifpwithaddr()
to check, that interface doesn't already have given address and then
uses in6_ifattach_loopback(). If in6_ifattach_loopback() fails, it just
exits and thus skips assignment of IPv6 LLA.
Fix this using in6ifa_ifwithaddr() function. If IPv6 loopback address is
already assigned in the system, do not call in6_ifattach_loopback().

PR: 138678
MFC after: 3 weeks

6 years agoBump date after r328535.
oshogbo [Mon, 29 Jan 2018 09:27:32 +0000 (09:27 +0000)]
Bump date after r328535.

Submitted by: def@

6 years agoPowerNV: move LPCR and LPID altering to cpudep_ap_early_bootstrap
wma [Mon, 29 Jan 2018 09:27:02 +0000 (09:27 +0000)]
PowerNV: move LPCR and LPID altering to cpudep_ap_early_bootstrap

It turns out that under some circumstances we can get DSI or DSE before we set
LPCR and LPID so we should set it as early as possible.

Authored by:           Patryk Duda <pdk@semihalf.com>
Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies

6 years agoloader: support for mixed-endianness ELF/loader and POWER8
wma [Mon, 29 Jan 2018 09:24:28 +0000 (09:24 +0000)]
loader: support for mixed-endianness ELF/loader and POWER8

On POWER8 with current petitpoot, the loader.kboot might be
run as little-endian application. The FreeBSD kernel is
always big-endian, so the load_elf_* routines must be aware
of proper endianness of all fields.

Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D12422

6 years agoFix misspelling of encryptedcore.
def [Mon, 29 Jan 2018 09:21:08 +0000 (09:21 +0000)]
Fix misspelling of encryptedcore.

PR: 223991
Submitted by: Trond Endrestol <Trond.Endrestol@ximalas.info>
Approved by: pjd (mentor)

6 years agoPPC64: use hwref instead of cpuid
wma [Mon, 29 Jan 2018 09:15:38 +0000 (09:15 +0000)]
PPC64: use hwref instead of cpuid

On CHRP and PowerNV, use the interrupt server number in the cpuref and pcpu
hwref field instead of the device-tree phandle and make the CPU IDs reported
to the scheduler dense and with the BSP at 0.

Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D14011

6 years agoPPC64: cleanup APs startup routines
wma [Mon, 29 Jan 2018 08:10:03 +0000 (08:10 +0000)]
PPC64: cleanup APs startup routines

Cleaning up AP startup routines. This is a mix of changes
required to make PowerNV running and to modify the code
to be more robust. Previously, some races were seen if more
than 90CPUs were online.

Authored by:           Patryk Duda <pdk@semihalf.com>
Submitted by:          Wojciech Macek <wma@semihalf.com>
Obtained from:         Semihalf
Sponsored by:          IBM, QCM Technologies
Differential revision: https://reviews.freebsd.org/D14026

6 years agoThe name of the library is exactly the same like one of name the name of the
oshogbo [Mon, 29 Jan 2018 05:29:28 +0000 (05:29 +0000)]
The name of the library is exactly the same like one of name the name of the
functions.

We should not create MLINKS for that one, because it's break a build.

Submitted by: lwhsu@

6 years agoDocument the syslog Casper service.
oshogbo [Mon, 29 Jan 2018 04:38:11 +0000 (04:38 +0000)]
Document the syslog Casper service.

Reviewed by: bcr@
Differential Revision: https://reviews.freebsd.org/D14084

6 years agoRemove hard-coded trap-handling logic involving the segmented memory model
nwhitehorn [Mon, 29 Jan 2018 04:33:41 +0000 (04:33 +0000)]
Remove hard-coded trap-handling logic involving the segmented memory model
used with hashed page tables on AIM and place it into a new, modular pmap
function called pmap_decode_kernel_ptr(). This function is the inverse
of pmap_map_user_ptr(). With POWER9 radix tables, which mapping to use
becomes more complex than just AIM/BOOKE and it is best to have it in
the same place as pmap_map_user_ptr().

Reviewed by: jhibbits

6 years agoFix kernel build after r328523, correct variable names
lwhsu [Mon, 29 Jan 2018 04:04:52 +0000 (04:04 +0000)]
Fix kernel build after r328523, correct variable names

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D14105

6 years agoAdd a NO_GETMAXLUN quirk for the JMicron JMS567 USB to SATA bridge, to
ian [Mon, 29 Jan 2018 03:24:02 +0000 (03:24 +0000)]
Add a NO_GETMAXLUN quirk for the JMicron JMS567 USB to SATA bridge, to
prevent lengthy timeout pauses while probing/attaching drives.

6 years agoFix LINT build after r328508, add forgotten part in format string
lwhsu [Mon, 29 Jan 2018 02:29:08 +0000 (02:29 +0000)]
Fix LINT build after r328508, add forgotten part in format string

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D14089

6 years agoCorrect MD patch in linux64 module Makefile
emaste [Mon, 29 Jan 2018 01:59:04 +0000 (01:59 +0000)]
Correct MD patch in linux64 module Makefile

Reviewed by: imp
Sponsored by: Turing Robotic Industries Inc.
Differential Revision: https://reviews.freebsd.org/D14061

6 years agoftp(1): Use closefrom() instead of individual close()s.
pfg [Mon, 29 Jan 2018 01:05:57 +0000 (01:05 +0000)]
ftp(1): Use closefrom() instead of individual close()s.

Use closefrom(3) instead of manually closing all file descriptors
between 3 and 19.

Obtained from: OpenBSD (CVS 1.80)

6 years agoAdd ISA PNP tables to ISA drivers. Fix a few incidental comments.
imp [Mon, 29 Jan 2018 00:22:30 +0000 (00:22 +0000)]
Add ISA PNP tables to ISA drivers. Fix a few incidental comments.
ACPI ISA PBP tables not tagged, there's bigger issues with them.

6 years agoTag the current round of deprecated drivers.
imp [Mon, 29 Jan 2018 00:14:46 +0000 (00:14 +0000)]
Tag the current round of deprecated drivers.

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

6 years agoCreate deprecation management functions.
imp [Mon, 29 Jan 2018 00:14:39 +0000 (00:14 +0000)]
Create deprecation management functions.

gone_in(majar, msg); If we're running in FreeBSD major, tell
the user this code may be deleted soon.
If we're running in FreeBSD major - 1,
the the user is deprecated and will
be gone in major.
Otherwise say nothing.

gone_in_dev(dev, major, msg) Just like gone_in, except use device_printf.

New tunable / sysctl debug.oboslete_panic: 0 - don't panic,
1 - panic in major or newer , 2 - panic in major - 1 or newer
default: 0

if NO_OBSOLETE_CODE is defined, then both of these turn into compile
time errors when building for major. Add options NO_OBSOLETE_CODE to
kernel build system.

This lets us tag code that's going away so users know it will be gone,
as well as automatically manage things.

Differential Review: https://reviews.freebsd.org/D13818

6 years agoUse atomic load and stores to ensure that the compiler doesn't
imp [Mon, 29 Jan 2018 00:00:52 +0000 (00:00 +0000)]
Use atomic load and stores to ensure that the compiler doesn't
optimize away these loops. Change boolean to int to match what atomic
API supplies. Remove wmb() since the atomic_store_rel() on status.done
ensure the prior writes to status. It also fixes the fact that there
wasn't a rmb() before reading done. This should also be more efficient
since wmb() is fairly heavy weight.

Sponsored by: Netflix
Reviewed by: kib@, jim harris
Differential Revision: https://reviews.freebsd.org/D14053

6 years agoOut of an abundance of caution, NUL out the first byte in the PNP
imp [Sun, 28 Jan 2018 23:58:22 +0000 (23:58 +0000)]
Out of an abundance of caution, NUL out the first byte in the PNP
info.

6 years agoRemove some unused AIM register declarations that existed to support some
nwhitehorn [Sun, 28 Jan 2018 21:30:57 +0000 (21:30 +0000)]
Remove some unused AIM register declarations that existed to support some
CPUs we have never run on. As a side-effect, removes some #ifdef AIM/#else.

6 years agoStart building modules for QORIQ64
jhibbits [Sun, 28 Jan 2018 20:35:48 +0000 (20:35 +0000)]
Start building modules for QORIQ64

There's no reason not to build modules for 64-bit QorIQ devices.  This
config has evolved to be analogous to the AIM GENERIC64 kernel, so will grow
to match it in more ways as well.

6 years agoAvoid implicit gcc nonnull attribute in vwarnx().
pfg [Sun, 28 Jan 2018 19:37:30 +0000 (19:37 +0000)]
Avoid implicit gcc nonnull attribute in vwarnx().

We removed the nonnull attributes from our headers long ago, but still
__printflike() includes it implicitly. This will cause the NULL check to
be optimized away in higher -O levels and it will also trigger a
-Wnonnull-compare warning.

Avoid warning with it in vwarnx().

Obtained from: DragonfLyBSD (git 6329e2f68af73662a1960240675e796ab586bcb1)

6 years agoConsolidate trap instruction checks to a single function
jhibbits [Sun, 28 Jan 2018 19:18:40 +0000 (19:18 +0000)]
Consolidate trap instruction checks to a single function

Summary:
Rather than duplicating the checks for programmatic traps all over the code, put
it all in one function.  This helps to remove some of the #ifdefs between AIM
and Book-E.

Reviewed By: nwhitehorn
Differential Revision: https://reviews.freebsd.org/D14082

6 years agoAssume Always Running APIC Timer for AMD CPU families >= 0x12.
mav [Sun, 28 Jan 2018 18:18:03 +0000 (18:18 +0000)]
Assume Always Running APIC Timer for AMD CPU families >= 0x12.

Fallback to HPET may cause locks congestions on many-core systems.
This change replicates Linux behavior.

MFC after: 1 month

6 years agoPull in r322245 from upstream clang trunk (by Craig Topper):
dim [Sun, 28 Jan 2018 16:10:40 +0000 (16:10 +0000)]
Pull in r322245 from upstream clang trunk (by Craig Topper):

  [X86] Make -mavx512f imply -mfma and -mf16c in the frontend like it
  does in the backend.

  Similarly, make -mno-fma and -mno-f16c imply -mno-avx512f.

  Withou this  "-mno-sse -mavx512f" ends up with avx512f being enabled
  in the frontend but disabled in the backend.

Reported by: pawel
PR: 225488

6 years agoRemove #endif forgotten in r328510.
mmel [Sun, 28 Jan 2018 15:33:32 +0000 (15:33 +0000)]
Remove #endif forgotten in r328510.

Pointy hat: mmel

6 years agodiff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c
mmel [Sun, 28 Jan 2018 15:20:45 +0000 (15:20 +0000)]
diff --git a/sys/dev/extres/clk/clk.c b/sys/dev/extres/clk/clk.c
index c6a1f466ceb..c3708a0ce27 100644
--- a/sys/dev/extres/clk/clk.c
+++ b/sys/dev/extres/clk/clk.c
@@ -642,10 +642,11 @@ clknode_adjust_parent(struct clknode *clknode, int idx)
  if (clknode->parent_cnt == 0)
  return;
  if ((idx == CLKNODE_IDX_NONE) || (idx >= clknode->parent_cnt))
- panic("Invalid clock parent index\n");
+ panic("%s: Invalid parent index %d for clock %s",
+     __func__, idx, clknode->name);

  if (clknode->parents[idx] == NULL)
- panic("%s: Attempt to set invalid parent %d for clock %s",
+ panic("%s: Invalid parent index %d for clock %s",
      __func__, idx, clknode->name);

  /* Remove me from old children list. */
@@ -674,8 +675,8 @@ clknode_init_parent_idx(struct clknode *clknode, int idx)
  if ((idx == CLKNODE_IDX_NONE) ||
      (idx >= clknode->parent_cnt) ||
      (clknode->parent_names[idx] == NULL))
- panic("%s: Invalid clock parent index: %d\n", __func__, idx);
-
+ panic("%s: Invalid parent index %d for clock %s",
+     __func__, idx, clknode->name);
  clknode->parent_idx = idx;
 }

6 years agoFix handling of I-cache sync operations
mmel [Sun, 28 Jan 2018 15:02:49 +0000 (15:02 +0000)]
Fix handling of I-cache sync operations

- pmap_enter_object() can be used for mapping of executable pages, so it's
  necessary to handle I-cache synchronization within it.

- Fix race in I-cache synchronization in pmap_enter(). The current code firstly
  maps given page to target VA and then do I-cache sync on it. This causes
  race, because this mapping become visible to other threads, before I-cache
  is synced.
  Do sync I-cache firstly (by using DMAP VA) and then map it to target VA.

- ARM64 ARM permits implementation of aliased (AIVIVT, VIPT) I-cache, but we
  can use different that final VA for flushing it. So we should use full
  I-cache flush on affected platforms. For now, and as temporary solution,
  use full flush always.

6 years agotools: remove note about diffburst.
eadler [Sun, 28 Jan 2018 05:45:20 +0000 (05:45 +0000)]
tools: remove note about diffburst.

Said tool was removed in 1999 in r51579

6 years agoAdd the DF_SUSPENDED flag to flags that are printed.
imp [Sun, 28 Jan 2018 05:13:17 +0000 (05:13 +0000)]
Add the DF_SUSPENDED flag to flags that are printed.

6 years agoAvoid using \$. It's an unknown escape sequence. Some awks warn about
imp [Sun, 28 Jan 2018 05:13:08 +0000 (05:13 +0000)]
Avoid using \$. It's an unknown escape sequence. Some awks warn about
that. Instead, simply remove the sequence entirely because we never
commit the generated files.

6 years agoRevert r328492:
pfg [Sun, 28 Jan 2018 03:16:54 +0000 (03:16 +0000)]
Revert r328492:
"Fix gcc80 -Wsizeof-pointer-memaccess warning."

The warning is bogus: GCC8 only looks at the size of the destination.
We shouldn't be fixing imaginary problems, so perhaps its better to deal
with this later on by disabling such warnings.

Pointed out by: ed, bde

6 years agostand/fdt: Check /compatible property on overlay if it exists
kevans [Sun, 28 Jan 2018 03:07:22 +0000 (03:07 +0000)]
stand/fdt: Check /compatible property on overlay if it exists

Example overlays seen in other places use a compatible property on root node
of an overlay to specify SOC compatibility. These don't get merged into base
FDT as they're not part of a fragment, but it's expected that consumers of
the overlay may want to check it.

If /compatible on the overlay is missing, just apply it. This is the "I know
what I'm doing" mode for those wanting to whip up a quick overlay and apply
it. An overlay intended for distribution should include /compatible so as
not to break a user's system.

If /compatible on the overlay exists, honor it and cross-check it with
/compatible on the base FDT. If /compatible on the base FDT is missing in
this case, don't apply the overlay rather than risk breaking the system.

Move the COPYOUT of overlay material to before we allocate space for
next_fdtp so that we can avoid the allocation and copy into next_fdtp if we
already know that the overlay can't apply.

This gives way to the possibility of autoloading overlays found in
/boot/overlays, since this provides a means of filtering out overlays not
applicable to the current board.

Reviewed by: gonzo
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D13969

6 years agostand/fdt: Consolidate overlay handling a little further
kevans [Sun, 28 Jan 2018 01:22:15 +0000 (01:22 +0000)]
stand/fdt: Consolidate overlay handling a little further

This should have been done as part of r327350, but due to lack of foresight
it came later. In the different places we apply overlays, we duplicate the
bits that check for fdt_overlays in the environment and supplement that with
any other places we need to check for overlays to load. These "other places"
will be loader specific and are not candidates for consolidation.

Provide an fdt_load_dtb_overlays to capture the common logic, allow passing
in an additional list of overlays to be loaded. This additional list of
overlays is used in practice for ubldr to pull in any fdt_overlays passed to
it from U-Boot environment, but it can be used for any other source of
overlays.

These additional overlays supplement loader.conf(5) fdt_overlays, rather
than replace, so that we're not restricted to specifying overlays in only
one place. This is a change from previous behavior where loader.conf(5)
supplied fdt_overlays would cause us to ignore U-Boot environment, and this
seems nonsensical- user should have sufficient control over both of these
aspects, or lack of control for good reasons.

A knob could be considered in the future to ignore U-Boot supplied overlays,
but the supplemental treatment seems like a good start.

Reviewed by: imp (earlier version), gonzo (earlier version)
Differential Revision: https://reviews.freebsd.org/D13993

6 years agoAdd cap_random.3 to build system.
oshogbo [Sat, 27 Jan 2018 22:57:06 +0000 (22:57 +0000)]
Add cap_random.3 to build system.
This should be done with r328494.

6 years agopfctl(8): Fix two wrong conditions.
pfg [Sat, 27 Jan 2018 22:57:01 +0000 (22:57 +0000)]
pfctl(8): Fix two wrong conditions.

Caught by gcc80's -Wtautological-compare option.

MFC after: 5 days
Approved by: kp
Obtained from: DragonFlyBSD (git e3cdbf6c)
Differential Revision: https://reviews.freebsd.org/D14083

6 years agoFix caspermock - the cap_recv_nvlist should return nvlist.
oshogbo [Sat, 27 Jan 2018 22:53:29 +0000 (22:53 +0000)]
Fix caspermock - the cap_recv_nvlist should return nvlist.