]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
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.

6 years agoDocument the random Casper service.
oshogbo [Sat, 27 Jan 2018 22:49:34 +0000 (22:49 +0000)]
Document the random Casper service.

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

6 years agolibthr: Fix missing break in switch.
pfg [Sat, 27 Jan 2018 22:27:55 +0000 (22:27 +0000)]
libthr: Fix missing break in switch.

This is also a warning in recent GCC with -Wimplicit-fallthrough.

CID: 1356262
Obtained from: DragonFly (git 0f037c78 - partial)

6 years agoFix gcc80 -Wsizeof-pointer-memaccess warning.
pfg [Sat, 27 Jan 2018 22:16:19 +0000 (22:16 +0000)]
Fix gcc80 -Wsizeof-pointer-memaccess warning.

Obtained from: DragonFlyBSD (git 56267d362d5769c8df07bf26d5e322610e0d24b4)

6 years agoMFV r328490: Update libfdt to github:f1879e1
kevans [Sat, 27 Jan 2018 21:25:45 +0000 (21:25 +0000)]
MFV r328490:   Update libfdt to github:f1879e1

Pulls in a patch, now upstreamed, from nwhitehorn to add limited read-only
support for older (v2 and v3) FDT blobs.

MFC after: 1 week

6 years agoRemove system makefile path directives from env passed to PORTS_MODULES step
jah [Sat, 27 Jan 2018 20:13:36 +0000 (20:13 +0000)]
Remove system makefile path directives from env passed to PORTS_MODULES step

Previously, MAKESYSPATH as well as '-m' directives in MAKEFLAGS would cause
any port rebuilt during the PORTS_MODULES stage to consume system makefiles
from $(SRCROOT)/share/mk instead of those installed under /usr/share/mk.
For kernel modules that need to build against an updated src tree this
makes sense; less so for <bsd.port.mk> or  any userspace library or utility
the port may also happen to install.

Before 11.0, this probably didn't matter much in practice.  But the addition
of src.libnames.mk under $(SRCROOT)/share/mk in 11.0 breaks any consumer of
bsd.prog.mk and DPADD/LDADD during PORTS_MODULES.

Address the build breakage by removing MAKESYSPATH and any occurrence of
'-m' from MAKEFLAGS in the environment created for the port build.
Instead set SYSDIR so that any kmod built by the port will still consume
conf/kmod.mk from the updated src tree, assuming it uses <bsd.kmod.mk>

Reviewed by: bdrewery
MFC after: 2 weeks
Differential Revision:  https://reviews.freebsd.org/D13053

6 years agoWhen using SCTP for sending probe packets, use INIT chunks for payloads
tuexen [Sat, 27 Jan 2018 19:23:42 +0000 (19:23 +0000)]
When using SCTP for sending probe packets, use INIT chunks for payloads
larger than or equal to 32 bytes. For smaller probe packets, keep using
SHUTDOWN-ACK chunks, possibly bundled with a PAD chunk.
Packets with INIT chunks more likely pass through firewalls. Therefore,
use them when possible.

MFC after: 1 week

6 years agopax(1): Honour the restrict in sigaction().
pfg [Sat, 27 Jan 2018 18:24:13 +0000 (18:24 +0000)]
pax(1): Honour the restrict in sigaction().

Use a setup_sig() helper and make it fail when either of sigaction fails.

While there, do not leak fds for "." + minor cleanup.

Obtained from: OpenBSD (through DragonFly git eca362d0f9bd086cc56d6b5bc4f03f09e040b9db)

6 years agofortune(6): Fix gcc80 -Wbool-operation warnings.
pfg [Sat, 27 Jan 2018 17:43:09 +0000 (17:43 +0000)]
fortune(6): Fix gcc80 -Wbool-operation warnings.

Hinted by: Dragonfly (git 4d1086765752f0569497d06460d95117c74f33ac)

6 years agoRevert r328479:
pfg [Sat, 27 Jan 2018 16:34:00 +0000 (16:34 +0000)]
Revert r328479:
{ext2|ufs}_readdir: Set limit on valid ncookies values.

We aren't allowed to set resid like this.

Pointed out by: kib, imp

6 years ago{ext2|ufs}_readdir: Set limit on valid ncookies values.
pfg [Sat, 27 Jan 2018 15:33:52 +0000 (15:33 +0000)]
{ext2|ufs}_readdir: Set limit on valid ncookies values.

Sanitize the values that will be assigned to ncookies so that we ensure
they are sane and we can handle them.

Let ncookies signed as it was before r328346. The valid range is such
that unsigned values are not required and we are not able to avoid at
least one cast anyways.

Hinted by: bde

6 years agoAdd constant for the PAD chunk as defined in RFC 4820.
tuexen [Sat, 27 Jan 2018 13:46:55 +0000 (13:46 +0000)]
Add constant for the PAD chunk as defined in RFC 4820.
This will be used by traceroute and traceroute6 soon.

MFC after: 1 week

6 years agoUpdate references in comments, since the IDs have become an RFC long
tuexen [Sat, 27 Jan 2018 13:43:03 +0000 (13:43 +0000)]
Update references in comments, since the IDs have become an RFC long
time ago. Also cleanup whitespaces. No functional change.

MFC after: 1 week

6 years agoAdd SPDX tags for nv(9).
oshogbo [Sat, 27 Jan 2018 12:58:21 +0000 (12:58 +0000)]
Add SPDX tags for nv(9).

MFC after: 2 weeks

6 years agoAdd SPDX tags for libcasper(3) and services.
oshogbo [Sat, 27 Jan 2018 12:55:34 +0000 (12:55 +0000)]
Add SPDX tags for libcasper(3) and services.

MFC after: 2 weeks

6 years agoDon't truncate name of glabel.
oshogbo [Sat, 27 Jan 2018 12:28:52 +0000 (12:28 +0000)]
Don't truncate name of glabel.
If it's to long just report that.

Reviewed by: trasz@
Differential Revision: https://reviews.freebsd.org/D13746

6 years agoDocument the grp Casper service.
oshogbo [Sat, 27 Jan 2018 11:54:51 +0000 (11:54 +0000)]
Document the grp Casper service.

Reviewed by: brueffer@, bcr@
Differential Revision: https://reviews.freebsd.org/D13821

6 years agoUse PCID to optimize PTI.
kib [Sat, 27 Jan 2018 11:49:37 +0000 (11:49 +0000)]
Use PCID to optimize PTI.

Use PCID to avoid complete TLB shootdown when switching between user
and kernel mode with PTI enabled.

I use the model close to what I read about KAISER, user-mode PCID has
1:1 correspondence to the kernel-mode PCID, by setting bit 11 in PCID.
Full kernel-mode TLB shootdown is performed on context switches, since
KVA TLB invalidation only works in the current pmap. User-mode part of
TLB is flushed on the pmap activations as well.

Similarly, IPI TLB shootdowns must handle both kernel and user address
spaces for each address.  Note that machines which implement PCID but
do not have INVPCID instructions, cause the usual complications in the
IPI handlers, due to the need to switch to the target PCID temporary.
This is racy, but because for PCID/no-INVPCID we disable the
interrupts in pmap_activate_sw(), IPI handler cannot see inconsistent
state of CPU PCID vs PCPU pmap/kcr3/ucr3 pointers.

On the other hand, on kernel/user switches, CR3_PCID_SAVE bit is set
and we do not clear TLB.

I can imagine alternative use of PCID, where there is only one PCID
allocated for the kernel pmap. Then, there is no need to shootdown
kernel TLB entries on context switch. But copyout(3) would need to
either use method similar to proc_rwmem() to access the userspace
data, or (in reverse) provide a temporal mapping for the kernel buffer
into user mode PCID and use trampoline for copy.

Reviewed by: markj (previous version)
Tested by: pho
Discussed with: alc (some aspects)
Sponsored by: The FreeBSD Foundation
MFC after: 3 weeks
Differential revision: https://reviews.freebsd.org/D13985

6 years agoFix native_lapic_ipi_alloc().
kib [Sat, 27 Jan 2018 11:33:21 +0000 (11:33 +0000)]
Fix native_lapic_ipi_alloc().

When PTI is enabled, empty IDT slots point to rsvd_pti.

Reported by: Dexuan-BSD Cui <dexuan.bsd@gmail.com>
Sponsored by: The FreeBSD Foundation
MFC after: 5 days

6 years agoImplement mitigation for Spectre version 2 attacks on ARMv7.
mmel [Sat, 27 Jan 2018 11:19:41 +0000 (11:19 +0000)]
Implement mitigation for Spectre version 2 attacks on ARMv7.

Similarly as we already do for arm64, for mitigation is necessary to
flush branch predictor when we:
- do task switch
- receive prefetch abort on non-userspace address

The user can disable this mitigation by setting 'machdep.disable_bp_hardening'
sysctl variable, or it can check actual system status by reading
'machdep.spectre_v2_safe'

The situation is complicated by fact that:
- for Cortex-A8, the BPIALL instruction is effectively NOP until the IBE bit
  in ACTLR is set.
- for Cortex-A15, the BPIALL is always NOP. The branch predictor can be
  only flushed by doing ICIALLU with special bit (Enable invalidates  of BTB)
  set in ACTLR.

Since access to the ACTLR register is locked to secure monitor/firmware on
most boards, they will also need update of firmware / U-boot.
In worst case, when secure monitor is on-chip ROM (e.g. PandaBoard),
the board is unfixable.

MFC after: 2 weeks
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D13931

6 years agoFix pmap_fault().
mmel [Sat, 27 Jan 2018 09:49:47 +0000 (09:49 +0000)]
Fix pmap_fault().

- special fault handling for break-before-make mechanism should be also
  applied for instruction translation faults, not only for data translation
  faults.

- since arm64_address_translate_...() functions are not atomic,
  use these with disabled interrupts.

6 years agoccp(4): Store IV in output buffer in GCM software fallback when requested
cem [Sat, 27 Jan 2018 07:41:31 +0000 (07:41 +0000)]
ccp(4): Store IV in output buffer in GCM software fallback when requested

Apply r328361 to duplicate copy of ccr_gcm_soft in ccp(4).

Properly honor the lack of the CRD_F_IV_PRESENT flag in the GCM software
fallback case for encryption requests.

6 years agoFinish the incomplete move of CAM_PERIPH_PRINT().
scottl [Sat, 27 Jan 2018 07:18:02 +0000 (07:18 +0000)]
Finish the incomplete move of CAM_PERIPH_PRINT().

Reported by: kevans

6 years agoClarify some comments in the MIPS makecontext().
jhb [Sat, 27 Jan 2018 00:39:49 +0000 (00:39 +0000)]
Clarify some comments in the MIPS makecontext().

- N32 and N64 do not have a $a0-3 gap.
- Use 'sp += 4' to skip over the gap for O32 rather than '+= i'.  It
  doesn't make a functional change, but makes the code match the comment.

Sponsored by: DARPA / AFRL

6 years agoRemove mention of sys/boot/ from hier(7), it doesn't exist anymore.
trasz [Sat, 27 Jan 2018 00:09:43 +0000 (00:09 +0000)]
Remove mention of sys/boot/ from hier(7), it doesn't exist anymore.

MFC after: 2 weeks

6 years agoMove CAM_PERIPH_PRINT() to cam_periph.h
scottl [Fri, 26 Jan 2018 23:56:07 +0000 (23:56 +0000)]
Move CAM_PERIPH_PRINT() to cam_periph.h

6 years agoMove per-operation data out of the csession structure.
jhb [Fri, 26 Jan 2018 23:21:50 +0000 (23:21 +0000)]
Move per-operation data out of the csession structure.

Create a struct cryptop_data which contains state needed for a single
symmetric crypto operation and move that state out of the session. This
closes a race with the CRYPTO_F_DONE flag that can result in use after
free.

While here, remove the 'cse->error' member.  It was just a copy of
'crp->crp_etype' and cryptodev_op() and cryptodev_aead() checked both
'crp->crp_etype' and 'cse->error'.  Similarly, do not check for an
error from mtx_sleep() since it is not used with PCATCH or a timeout
so cannot fail with an error.

PR: 218597
Reviewed by: kib
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D13928

6 years agoFix a sleepable malloc in ndastart. We shouldn't be sleeping
imp [Fri, 26 Jan 2018 23:14:46 +0000 (23:14 +0000)]
Fix a sleepable malloc in ndastart. We shouldn't be sleeping
here. Return ENOMEM when we can't malloc a buffer for the DSM
TRIM. This should fix the WITNESS warnings similar to the following:

uma_zalloc_arg: zone "16" with the following non-sleepable locks held:
exclusive sleep mutex CAM device lock (CAM device lock) r = 0 (0xfffff800080c34d0) locked @ /usr/src/sys/cam/nvme/nvme_da.c:351

Reviewed by: scottl@
Sponsored by: Netflix

6 years agoUse bus_dmamem_alloc(9) KPI instead of contigmalloc(9).
mav [Fri, 26 Jan 2018 22:22:26 +0000 (22:22 +0000)]
Use bus_dmamem_alloc(9) KPI instead of contigmalloc(9).

I suppose it should make this code NUMA-aware with recent NUMA drop-in,
trying to allocate shared memory buffers from domain closer to NT-bridge.

MFC after: 2 weeks

6 years agoTag unreachable places as such. I left the while (1); in place since
imp [Fri, 26 Jan 2018 22:22:21 +0000 (22:22 +0000)]
Tag unreachable places as such. I left the while (1); in place since
in this context we want to busy wait to stop.

Suggested by: pfg@

6 years agoMake exit() never return until host_exit can be written.
imp [Fri, 26 Jan 2018 21:51:13 +0000 (21:51 +0000)]
Make exit() never return until host_exit can be written.

6 years agoBERI isn't BTX, so we don't have to provide exit(). Just remove it
imp [Fri, 26 Jan 2018 21:51:09 +0000 (21:51 +0000)]
BERI isn't BTX, so we don't have to provide exit(). Just remove it
since it's unused.

6 years agoNow that exit is __dead2, we need to tag ub_exit() as __dead2. To do
imp [Fri, 26 Jan 2018 21:50:59 +0000 (21:50 +0000)]
Now that exit is __dead2, we need to tag ub_exit() as __dead2. To do
that, we have to put a while (1); after the syscall that will never
return to fake out the compiler....

6 years agoFix a cut-and-paste error in a panic message
scottl [Fri, 26 Jan 2018 18:42:28 +0000 (18:42 +0000)]
Fix a cut-and-paste error in a panic message

6 years agoFor many years the message "fsync: giving up on dirty" has occationally
mckusick [Fri, 26 Jan 2018 18:17:11 +0000 (18:17 +0000)]
For many years the message "fsync: giving up on dirty" has occationally
appeared on UFS/FFS filesystems. In some cases it was promptly followed
by a panic of "softdep_deallocate_dependencies: dangling deps". This fix
should eliminate both of these occurences.

Submitted by: Andreas Longwitz <longwitz at incore.de>
Reviewed by:  kib
Tested by:    Peter Holm (pho)
PR:           225423
MFC after:    1 week

6 years agoGross hack to omit printing hex floating point when the lua number
imp [Fri, 26 Jan 2018 17:56:20 +0000 (17:56 +0000)]
Gross hack to omit printing hex floating point when the lua number
type is int64. While lua is setup for the representation, it's not
setup to properly print the numbers as ints. This is the least-gross
way around that, and won't affect the bootloader where we do this.

6 years agoAdd support to the imx5/6 watchdog for the external reset signal. Also, if
ian [Fri, 26 Jan 2018 17:55:17 +0000 (17:55 +0000)]
Add support to the imx5/6 watchdog for the external reset signal.  Also, if
the "power down" watchdog used by the ROM boot code is still active when the
regular watchdog is activated, turn off the power-down watchdog.

This adds support for the "fsl,ext-reset-output" FDT property.  When
present, that property indicates that a chip reset is accomplished by
asserting the WDOG1_B external signal, which is supposed to trigger some
external component such as a PMIC to ready the hardware for reset (for
example, adjusting voltages from idle to full-power levels), and assert the
POR signal to SoC when ready.  To guard against misconfiguation leading to a
non-rebootable system, the external reset signal is backstopped by code
that asserts a normal internal chip reset if nothing responds to the
external reset signal within one second.

6 years agoabort() should be marked __dead2 since it won't return.
imp [Fri, 26 Jan 2018 17:40:13 +0000 (17:40 +0000)]
abort() should be marked __dead2 since it won't return.

6 years agoPreserve the original luaconf.h in a convenient place. Clients will
imp [Fri, 26 Jan 2018 17:24:25 +0000 (17:24 +0000)]
Preserve the original luaconf.h in a convenient place. Clients will
almost certainly need to override this, so reinforce that. If that's
not hte case, clients can always do a #include luaconf.h.dist.

6 years agoProvide abs form stdlib.h.
imp [Fri, 26 Jan 2018 17:13:09 +0000 (17:13 +0000)]
Provide abs form stdlib.h.

Sponsored by: Netflix

6 years agoImplement abort() as a call to panic.
imp [Fri, 26 Jan 2018 17:13:04 +0000 (17:13 +0000)]
Implement abort() as a call to panic.

Sponsored by: Netflix

6 years agoSplit panic routine
imp [Fri, 26 Jan 2018 17:13:00 +0000 (17:13 +0000)]
Split panic routine

Split panic routine so that the 'Hit Any Key to continue' behavior can
be overriden.

Sponsored by: Netflix

6 years agoDecouple Linux files from the belonging character device right after open
hselasky [Fri, 26 Jan 2018 10:49:02 +0000 (10:49 +0000)]
Decouple Linux files from the belonging character device right after open
in the LinuxKPI. This is done by calling finit() just before returning a magic
value of ENXIO in the "linux_dev_fdopen" function.

The Linux file structure should mimic the BSD file structure as much as
possible. This patch decouples the Linux file structure from the belonging
character device right after the "linux_dev_fdopen" function has returned.
This fixes an issue which allows a Linux file handle to exist after a
character device has been destroyed and removed from the directory index
of /dev. Only when the reference count of the BSD file handle reaches zero,
the Linux file handle is destroyed. This fixes use-after-free issues related
to accessing the Linux file structure after the character device has been
destroyed.

While at it add a missing NULL check for non-present file operation.
Calling a NULL pointer will result in a segmentation fault.

Reviewed by: kib @
MFC after: 1 week
Sponsored by: Mellanox Technologies

6 years agoPPC: Add place for NULL chars in intrnames
wma [Fri, 26 Jan 2018 09:38:40 +0000 (09:38 +0000)]
PPC: Add place for NULL chars in intrnames

In a corner case we could fall into OOB error.

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

6 years agoo A command line flag for the syslog_facility fixed in the SYNOPSIS.
maxim [Fri, 26 Jan 2018 08:52:28 +0000 (08:52 +0000)]
o A command line flag for the syslog_facility fixed in the SYNOPSIS.

PR: 225441

6 years agoo EMFILE errno documented.
maxim [Fri, 26 Jan 2018 08:38:26 +0000 (08:38 +0000)]
o EMFILE errno documented.

PR: 219209
Submitted by: yuri (with minor adjustment)
Reviewed by: brooks

6 years agoFix LINT build.
lwhsu [Fri, 26 Jan 2018 06:21:24 +0000 (06:21 +0000)]
Fix LINT build.

Approved by: delphij

6 years agodevd: readd virtual
eadler [Fri, 26 Jan 2018 05:03:37 +0000 (05:03 +0000)]
devd: readd virtual

- my C++ knowledge is old and rusty. re-add virtual

6 years agodevd: minor nits
eadler [Fri, 26 Jan 2018 04:40:41 +0000 (04:40 +0000)]
devd: minor nits

- mark usage as noreturn
- config does not need a virtual destructor

6 years agoexample cdev: use make_dev_s
eadler [Fri, 26 Jan 2018 04:24:39 +0000 (04:24 +0000)]
example cdev: use make_dev_s

Make use of make_dev_s in the example cdev. While here, fix warnings.

Reviewed by: rpokala

6 years agodd(1): Use a local swapbytes() function.
eadler [Fri, 26 Jan 2018 03:30:05 +0000 (03:30 +0000)]
dd(1): Use a local swapbytes() function.

swab(3) has restrict qualifiers for src and dst.
Avoid relying on undefined overlapping swab behavior.

Obtained From: OpenBSD

6 years agoRefactoring of reading and writing of the UFS/FFS superblock.
mckusick [Fri, 26 Jan 2018 00:58:32 +0000 (00:58 +0000)]
Refactoring of reading and writing of the UFS/FFS superblock.
Specifically reading is done if ffs_sbget() and writing is done
in ffs_sbput(). These functions are exported to libufs via the
sbget() and sbput() functions which then used in the various
filesystem utilities. This work is in preparation for adding
subperblock check hashes.

No functional change intended.

Reviewed by: kib

6 years agoMinimum changes for ctl to build on architectures with non-matching physical and
jhibbits [Fri, 26 Jan 2018 00:58:02 +0000 (00:58 +0000)]
Minimum changes for ctl to build on architectures with non-matching physical and
virtual address sizes

Summary:
Some architectures use physical addresses larger than virtual.  This is the
minimal changeset needed to get CAM/CTL to build on these targets.  No
functional changes.  More changes would likely be needed for this to be fully
functional on said platforms, but they can be made when needed.

Reviewed By: mav, chuck
Differential Revision: https://reviews.freebsd.org/D14041

6 years agoMinimal change to build linuxkpi on architectures with physical addresses larger
jhibbits [Fri, 26 Jan 2018 00:56:09 +0000 (00:56 +0000)]
Minimal change to build linuxkpi on architectures with physical addresses larger
than virtual

Summary:
Some architectures have physical/bus addresses that are much larger
than virtual addresses.  This change just quiets a warning, as DMAP is not used
on those architectures, and on 64-bit platforms uintptr_t is the same size as
vm_paddr_t and void *.

Reviewed By: hselasky
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D14043