]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoAdding SIOCGIFNAME support in Linuxulator. This should silence the console warning...
Tai-hwa Liang [Sun, 9 Apr 2017 15:27:04 +0000 (15:27 +0000)]
Adding SIOCGIFNAME support in Linuxulator.  This should silence the console warning associated
with linux-opera:
linux: pid 23492 (opera): ioctl fd=5, cmd=0x8910 ('\M^I',16) is not implemented
linux: pid 23492 (opera): ioctl fd=28, cmd=0x8910 ('\M^I',16) is not implemented
...

Reviewed by: kib, marcel, dchagin
Tested with: linux-opera-12.16_3
MFC after: 1 month

7 years agoMake setkey(8) more clear about anti-replay window size option semantics.
Benedict Reuschling [Sun, 9 Apr 2017 15:17:55 +0000 (15:17 +0000)]
Make setkey(8) more clear about anti-replay window size option semantics.

PR: 172913
Submitted by: john@saltant.com
Reviewed by: ae@
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D10304

7 years agoFix compilation of LinuxKPI for PowerPC.
Hans Petter Selasky [Sun, 9 Apr 2017 14:31:41 +0000 (14:31 +0000)]
Fix compilation of LinuxKPI for PowerPC.

Found by: emaste @
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoFix parsing failure for NFSv4 Setattr operation for failed case.
Rick Macklem [Sun, 9 Apr 2017 12:32:22 +0000 (12:32 +0000)]
Fix parsing failure for NFSv4 Setattr operation for failed case.

If an operation that preceeds a Setattr in an NFSv4 compound fails,
there is no bitmap of attributes to parse. Without this patch, the
parsing would fail and return EBADRPC instead of the correct failure
error. This could break recovery from a server crash/reboot.

Tested by: cperciva
PR: 215883
MFC after: 2 weeks

7 years agoloader: r316585 did miss userboot update
Toomas Soome [Sun, 9 Apr 2017 11:16:16 +0000 (11:16 +0000)]
loader: r316585 did miss userboot update

The work to implement zfs reader to inspect all pool label copies did
miss the userboot, this update does correct this issue.

Since userboot is already using common/disk.c API (disk_open() etc),
the fix is quite simple - we only need to make sure the userdisk_iocl()
will call disk_ioctl(). In addition, the diskioctl callback does return
int, not pointer.

Note, the review request is actually addressing the sparc and userboot,
but as testing the fix for sparc will take some more time, I am posting the
userboot fix now.

This patch is part of the implementation presented in review:
https://reviews.freebsd.org/D10302

Once we have the sparc part tested, we will have the complete fix
for the issue.

Reviewed by: imp

7 years agoFix few minor issues found by Clang Analyzer.
Alexander Motin [Sun, 9 Apr 2017 07:54:39 +0000 (07:54 +0000)]
Fix few minor issues found by Clang Analyzer.

MFC after: 2 weeks

7 years agoFix few minor issues found by Clang Analyzer.
Alexander Motin [Sun, 9 Apr 2017 07:53:31 +0000 (07:53 +0000)]
Fix few minor issues found by Clang Analyzer.

MFC after: 2 weeks

7 years agoAdd missing double quote to fix r316635 commit.
Alexander Kabaev [Sun, 9 Apr 2017 03:50:48 +0000 (03:50 +0000)]
Add missing double quote to fix r316635 commit.

7 years agoCorrected misspelled versions of rendezvous.
Patrick Kelsey [Sun, 9 Apr 2017 02:00:03 +0000 (02:00 +0000)]
Corrected misspelled versions of rendezvous.

The MFC will include a compat definition of smp_no_rendevous_barrier()
that calls smp_no_rendezvous_barrier().

Reviewed by: gnn, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D10313

7 years agoIntroduce LLD_BOOTSTRAP to control lld as bootstrap linker
Ed Maste [Sun, 9 Apr 2017 01:35:19 +0000 (01:35 +0000)]
Introduce LLD_BOOTSTRAP to control lld as bootstrap linker

Add WITH_LLD_BOOTSTRAP and WITHOUT_LLD_BOOTSTRAP knobs, similar to the
Clang bootstrap knobs.

Reviewed by: dim
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10249

7 years agosh: Add test for unaliasing an alias that is currently in use.
Jilles Tjoelker [Sat, 8 Apr 2017 21:57:59 +0000 (21:57 +0000)]
sh: Add test for unaliasing an alias that is currently in use.

This already works correctly.

7 years agoUnconditionally include arm64 in make universe / tinderbox
Ed Maste [Sat, 8 Apr 2017 16:14:30 +0000 (16:14 +0000)]
Unconditionally include arm64 in make universe / tinderbox

As of r316629 FreeBSD/arm64 uses the in-tree LLD linker by default, and
does not require an external an aarch64-binutils port or package.

Sponsored by: The FreeBSD Foundation

7 years agoTrying to be more compatible with Linux if.h definitions:
Tai-hwa Liang [Sat, 8 Apr 2017 14:41:39 +0000 (14:41 +0000)]
Trying to be more compatible with Linux if.h definitions:
- renaming l_ifreq::ifru_metric to l_ifreq::ifru_ivalue;
- adding a definition for ifr_ifindex which points to l_ifreq::ifru_ivalue.

A quick search indicates that Linux already got the above changes since 2.1.14.

Reviewed by: kib, marcel, dchagin
MFC after: 1 week

7 years agouse msr 0xc001100c to discover multi-node AMD processors
Andriy Gapon [Sat, 8 Apr 2017 14:16:42 +0000 (14:16 +0000)]
use msr 0xc001100c to discover multi-node AMD processors

This is applicable only to the older processors that do not have the AMD
Topology extension.
Opteron 6100-series "Magny-Cours" processors had multiple nodes within a
package and didn't have the Topology extension.  Without this change
FreeBSD would assume that those processors have a single L3 cache shared
by all cores while, in fact, each node has its own L3 cache.

Many thanks to Freddie Cash <fjwcash@gmail.com> for providing valuable
hardware information.

MFC after: 2 weeks

7 years agoQuick fix for removal of the mouse cursor in vga direct graphics modes
Bruce Evans [Sat, 8 Apr 2017 10:00:39 +0000 (10:00 +0000)]
Quick fix for removal of the mouse cursor in vga direct graphics modes
(that is, in all supported 8, 15, 16 and 24-color modes).  Moving the
mouse cursor while holding down a button (giving cut marking) left a
trail of garbage from misremoved mouse cursors (usually colored
rectangles and not cursor shapes).  Cases with a button not held down
worked better and may even have worked.

No renderer support for removing (software) mouse cursors is needed
(and many renderers don't have any), since sc_remove_mouse_image()
marks for update the region containing the image and usually much
more.  The mouse cursor can be (partially) over as many as 4 character
cells, and removing it in only the 1-4 cells occupied by it would be
best for efficiency and for avoiding flicker.  However,
sc_remove_mouse_image() can only mark a single linear region and
usually marks a full row of cells and 1 more to be sure to cover the
4 cells.  It always does this, so using the special rendering method
just wastes even more time and gives even more flicker.  The special
methods will be removed soon.

The general method always works.  vga_pxlmouse_direct() appeared to
defer to it by returning immediately if !on.  However,
vga_pxlmouse_direct() actually did foot-shooting using a disguised
saveunder method.  Normal order near a mouse move is:
  (1) remove the mouse cursor in the renderer (optional)
  (2) remove the mouse cursor again and refresh the screen over the
      mouse cursor and much more from the vtb.  When the mouse has
      actually moved and a button is down, many attributes in this
      region are changed to be up to date with the new cut marking
  (3) draw the keyboard cursor again if it was clobbered by the update
  (4) draw the mouse cursor image in its new position.
The bug was to remove the mouse cursor again in step (4), before the
drawing it again in (4), using a saveunder that was valid in step (1)
at best.  The quick fix is to use the saveunder in step (1) and not
in step (4).  Using it in step (4) also used it before it was
initialized, initially and after  mode and screen switches.

7 years agoadd a stub --speed-large-files for compatibility with GNU diff
Baptiste Daroussin [Sat, 8 Apr 2017 08:46:02 +0000 (08:46 +0000)]
add a stub --speed-large-files for compatibility with GNU diff

There is no intention to implement it, but lots of scripts/tools using
diff(1) passes GNU diff option

7 years agoRemove a useless loop over the long options before passing through some
Baptiste Daroussin [Sat, 8 Apr 2017 08:42:25 +0000 (08:42 +0000)]
Remove a useless loop over the long options before passing through some
options to diff(1)

7 years agoWhen passingthrough from sdiff to diff the -H/--speed-large-files
Baptiste Daroussin [Sat, 8 Apr 2017 08:41:05 +0000 (08:41 +0000)]
When passingthrough from sdiff to diff the -H/--speed-large-files
options rename it to the long version as GNU diff only support the long
version of the option not the short version

7 years agoFix removal of the keyboard cursor image in text mode, especially
Bruce Evans [Sat, 8 Apr 2017 08:24:25 +0000 (08:24 +0000)]
Fix removal of the keyboard cursor image in text mode, especially
in the vga renderer.  Removal used stale attributes and didn't try to
merge with the current attribute for cut marking, so special rendering
of cut marking was lost in many cases.  The gfb renderer is too broken
to support special rendering of cut marking at all, so this change is
supposed to be just a style fix for it.  Remove all traces of the
saveunder method which was used to implement this bug.

Fix drawing of the cursor image in text mode, only in the vga
renderer.  This used a stale attribute from the frame buffer instead
of from the saveunder, but did merge with the current attribute for
cut marking so it caused less obvious bugs (subtle misrendering for
the character under the cursor).

The saveunder method may be good in simpler drivers, but in syscons
the 'under' is already saved in a better way in the vtb.  Just redraw
it from there, with visible complications for cut marking and
invisible complications for mouse cursors.  Almost all drawing
requests are passed a flag 'flip' which currently means to flip to
reverse video for characters in the cut marking region, but should
mean that the the characters are in the cut marking regions so should
be rendered specially, preferably using something better than reverse
video.  The gfb renderer always ignores this flag.  The vga renderer
ignored it for removal of the text cursor -- the saveunder gave the
stale rendering at the time the cursor was drawn.  Mouse cursors need
even more complicated methods.  They are handled by drawing them last
and removing them first.  Removing them usually redraws many other
characters with the correct cut marking (but transiently loses the
keyboard cursor, which is redrawn soon).  This tended to hide the
saveunder bug for forward motions of the keyboard cursor.  But slow
backward motions of the keyboard cursor always lost the cut marking,
and fast backwards motions lost in for about 4 in every 5 characters,
depending on races with the scrn_update() timeout handler.  This is
because the forward motions are usually into the region redrawn for
the mouse cursor, while backwards motions rarely are.

Text cursor drawing in the vga renderer used also used a
possibly-stale copy of the character and its attribute.  The vga
render has the "optimization" of sometimes reading characters from the
screen instead of from the vtb (this was not so good even in 1990 when
main memory was only a few times faster than video RAM).  Due to care
in update orders, the character is never stale, but its attribute
might be (just the cut marking part, again due to care in order).

gfb doesn't have the scp->scr pointer used for the "optimization", and
vga only uses this pointer for text mode.  So most cases have to
refresh from the vtb, and we can be sure that the ordering of vtb
updates and drawing is as required for this to work.

7 years agoEnable 16-bit longest_match for x86.
Xin LI [Sat, 8 Apr 2017 06:39:13 +0000 (06:39 +0000)]
Enable 16-bit longest_match for x86.

This gives a ~2% improvement in compression tests.

MFC after: 2 weeks

7 years agoFixed typo in comment found while reading commit email for fix of
Patrick Kelsey [Sat, 8 Apr 2017 04:50:50 +0000 (04:50 +0000)]
Fixed typo in comment found while reading commit email for fix of
other typo in same comment.

ned -> need

MFC after: 3 days

7 years agoFixed typo in comment.
Patrick Kelsey [Sat, 8 Apr 2017 04:45:52 +0000 (04:45 +0000)]
Fixed typo in comment.

patckets -> packets

MFC after: 3 days

7 years agoFixed typo.
Patrick Kelsey [Sat, 8 Apr 2017 04:41:46 +0000 (04:41 +0000)]
Fixed typo.

CSUM_COALESED -> CSUM_COALESCED

MFC after: 3 days

7 years agoFix typo in comment.
Patrick Kelsey [Sat, 8 Apr 2017 04:37:01 +0000 (04:37 +0000)]
Fix typo in comment.

logest -> longest

MFC after: 3 days

7 years agoFix typo.
Patrick Kelsey [Sat, 8 Apr 2017 04:34:18 +0000 (04:34 +0000)]
Fix typo.

hist -> hint

MFC after: 3 days

7 years agodo not require binutils port when using lld as ld
Ed Maste [Fri, 7 Apr 2017 23:37:22 +0000 (23:37 +0000)]
do not require binutils port when using lld as ld

r279908 added logic to Makefile.inc1 to automatically set
CROSS_BINUTILS_PREFIX for architectures not supported by the in-tree
binutils: arm64 when first introduced, and later riscv64 as well.

LLVM's LLD linker is now included in the base system, and is enabled by
default for arm64 and capable of linking world and kernel. Thus, avoid
automatically setting CROSS_BINUTILS_PREFIX and requiring the binutils
port if WITH_LLD_IS_LD is true.

Reviewed by: kan
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10310

7 years agoSilence GCC warning by initializing the local variable.
Alexander Kabaev [Fri, 7 Apr 2017 22:58:34 +0000 (22:58 +0000)]
Silence GCC warning by initializing the local variable.

GCC 6.3 is unable to trace all code paths that lead to
this variable being left uninitialized and correlate that
to function return values.

7 years agoUse int to receive the return value of getopt function.
Alexander Kabaev [Fri, 7 Apr 2017 22:58:31 +0000 (22:58 +0000)]
Use int to receive the return value of getopt function.

getopt returns int and not char, so assigning the value to
char is not ideal, especially on platforms with unsigned
chars.

7 years agoDefine 'lr' as x30 on aarch64
Alexander Kabaev [Fri, 7 Apr 2017 22:58:28 +0000 (22:58 +0000)]
Define 'lr' as x30 on aarch64

GNU toolchain does not recognize LR as standard register alias,
but clang does. Use of #define will work on both. Place the
definition into central machine/asm.h instead of patching every
affected file, as requested by plaftorm maintainers.

Reviews by: andrew, emaste, imp
Differential Revision: https://reviews.freebsd.org/D10307

7 years agoDo not use -msoft-float with intention of disabling FP on aarch64
Alexander Kabaev [Fri, 7 Apr 2017 22:58:25 +0000 (22:58 +0000)]
Do not use -msoft-float with intention of disabling FP on aarch64

GNU GCC does does recognise it as a valid option and we already
use -mgeneral-regs-only that has the desired effect.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D10306

7 years agoDo not use b.cs instruction to jump to cerror.
Alexander Kabaev [Fri, 7 Apr 2017 22:58:20 +0000 (22:58 +0000)]
Do not use b.cs instruction to jump to cerror.

The conditional jump can only be performed to targets up to 1MB in
either direction and does not work too well when linker places cerror
further that that from the caller. In that case linker will complain
about relocation overflows.

Reviewed by: emaste, andrew
Differential Revision:  https://reviews.freebsd.org/D10305

7 years agoRevert previous change to sys/conf/options & associated notes so builds can
Sevan Janiyan [Fri, 7 Apr 2017 21:06:50 +0000 (21:06 +0000)]
Revert previous change to sys/conf/options & associated notes so builds can
resume while I investigate what I had missed.

7 years agoExplicitly set the desired MIPS ABI in toolchain flags.
John Baldwin [Fri, 7 Apr 2017 20:02:01 +0000 (20:02 +0000)]
Explicitly set the desired MIPS ABI in toolchain flags.

Specifically, set '-mabi=XX' in AFLAGS, CFLAGS, and LDFLAGS.  This permits
building MIPS worlds and binaries with a toolchain whose default output
does not match the desired TARGET_ARCH.

_LDFLAGS (which is used with LD instead of with CC) required an update as
LD does not accept the -mabi flags (so they must be stripped from LDFLAGS
when generating _LDFLAGS).  For bare uses of LD (rather than linking via
CC), the desired ABI must be set by setting an explicit linker emulation
as done in r316514 for kernels and kernel modules.

Reviewed by: imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoDon't set the MIPS endianness flags in both ACFLAGS and CFLAGS.
John Baldwin [Fri, 7 Apr 2017 19:56:12 +0000 (19:56 +0000)]
Don't set the MIPS endianness flags in both ACFLAGS and CFLAGS.

This should no longer be necessary after r316620 as all places that
use ACFLAGS should already be using CFLAGS.

Reviewed by: imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoRework r234502 to include a modified CFLAGS along with ACFLAGS.
John Baldwin [Fri, 7 Apr 2017 19:53:14 +0000 (19:53 +0000)]
Rework r234502 to include a modified CFLAGS along with ACFLAGS.

On most architectures crt objects are compiled in a multiple-step process
so that sed can be run on the generated assembly.  As the final step,
the C compiler generates an object file from the modified assembly output.
Currently this last step uses $CC with only $ACFLAGS.  However, for other
uses in the tree, $ACFLAGS is meant to include assembly-specific compiler
flags that are in addition to $CFLAGS (see default .S.o rules
bsd.suffixes.mk).  In particular, external toolchains may require
additional flags to select a non-default target which will be present
in CFLAGS but not ACFLAGS.  To support this while still mitigating the
issue with CFLAGS described in r234502, include a modified CFLAGS that
excludes "-g" when assembling the modified assembly files.

Note that normally an assembler ($AS) is used to assemble .s flags to
object files (see bsd.suffixes.mk).  However, llvm-based toolchains do
not currently have a stand-alone assembler.

Reviewed by: imp
Sponsored by: DARPA / AFRL
Differential Revision: https://reviews.freebsd.org/D10085

7 years agoRemove support for long gone oldnfs.
Brooks Davis [Fri, 7 Apr 2017 18:31:31 +0000 (18:31 +0000)]
Remove support for long gone oldnfs.

The code was calling nmount with an fstype of everything in the program
name after the last '_'. This was there to support mount_nfs being
linked to mount_oldnfs. Support for the link was removed in 2015 with
r281691.

Reviewed by: rmacklem
Obtained from: CheriBSD
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10301

7 years ago- Increase the image size for RPI2 and IMX6-based boards from 1G
Glen Barber [Fri, 7 Apr 2017 16:55:13 +0000 (16:55 +0000)]
- Increase the image size for RPI2 and IMX6-based boards from 1G
  to 1.5G.
- Use the 'conv=sync' dd(1) option to fix writing the u-boot.imx
  file to the md(4) device for IMX6-based boards.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

7 years agobnxt(4): add support for WOL Magic.
Sean Bruno [Fri, 7 Apr 2017 16:15:50 +0000 (16:15 +0000)]
bnxt(4): add support for WOL Magic.

Submitted by: venkatkumar.duvvuru@broadcom.com
Differential Revision: https://reviews.freebsd.org/D10124

7 years agoRemove the last vestiges of FDC_DEBUG & FD_DEBUG
Sevan Janiyan [Fri, 7 Apr 2017 16:14:25 +0000 (16:14 +0000)]
Remove the last vestiges of FDC_DEBUG & FD_DEBUG
FDC_DEBUG is not referenced in any c or header files but traces of it
still remain in other files.

PR: 105608
Reported by: Eugene Grosbein <ports AT grosbein DOT net>
Reviewed by: imp
Approved by: bcr (mentor)
MFC after: 7 days
Differential Revision: https://reviews.freebsd.org/D10303

7 years agoIn r298230 the value of HEAP_MIN was changed from 3MB to 64MB. Correct a
Benno Rice [Fri, 7 Apr 2017 15:41:49 +0000 (15:41 +0000)]
In r298230 the value of HEAP_MIN was changed from 3MB to 64MB. Correct a
comment that was still referencing the 3MB value.

Sponsored by: Dell EMC Isilon
Discussed with: jhb

7 years agosbin/mount: strcpy -> strlcpy
Alan Somers [Fri, 7 Apr 2017 15:39:41 +0000 (15:39 +0000)]
sbin/mount: strcpy -> strlcpy

Reported by: Coverity
CID: 10111731011174
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

7 years agousr.bin/netstat: strcpy -> strlcpy
Alan Somers [Fri, 7 Apr 2017 15:15:10 +0000 (15:15 +0000)]
usr.bin/netstat: strcpy -> strlcpy

Reported by: Coverity
CID: 10067411006744
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp

7 years agoCreate the LinuxKPI current task structure on the fly if it doesn't
Hans Petter Selasky [Fri, 7 Apr 2017 14:43:28 +0000 (14:43 +0000)]
Create the LinuxKPI current task structure on the fly if it doesn't
exist when the current macro is used.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoAdd -fPIC to the standalone build flags on arm64. This is needed as
Andrew Turner [Fri, 7 Apr 2017 14:30:51 +0000 (14:30 +0000)]
Add -fPIC to the standalone build flags on arm64. This is needed as
loader.efi is position independend, however we were not building it as
such causing a build failure when building with lld.

Sponsored by: DARPA, AFRL

7 years agoFix linking with lld by marking OPENSSL_armcap_P as hidden.
Andrew Turner [Fri, 7 Apr 2017 12:41:57 +0000 (12:41 +0000)]
Fix linking with lld by marking OPENSSL_armcap_P as hidden.

Linking with lld fails as it contains a relative address, however the data
this address is for may be relocated from the shared object to the main
executable.

Fix this by adding the hidden attribute. This stops moving this value to
the main executable. It seems this is implicit upstream as it uses a
version script.

Approved by: jkim
Sponsored by: DARPA, AFRL

7 years agoThe __stringify() macro in the LinuxKPI should expand any macros
Hans Petter Selasky [Fri, 7 Apr 2017 12:27:49 +0000 (12:27 +0000)]
The __stringify() macro in the LinuxKPI should expand any macros
before stringifying.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoMETA_MODE: add additional reachover relative paths to DIRDEPS_BUILD
Enji Cooper [Fri, 7 Apr 2017 07:46:21 +0000 (07:46 +0000)]
META_MODE: add additional reachover relative paths to DIRDEPS_BUILD

These additional entries are being added, after their addition to the
source tree.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agopmc_read(3): fix manlint error
Enji Cooper [Fri, 7 Apr 2017 06:06:55 +0000 (06:06 +0000)]
pmc_read(3): fix manlint error

Remove spurious trailing comma from last .Nm entry in NAME section.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agopmc.atomsilvermont(3): fix manlint warnings
Enji Cooper [Fri, 7 Apr 2017 06:00:19 +0000 (06:00 +0000)]
pmc.atomsilvermont(3): fix manlint warnings

Start new sentences on new lines.

Sentences affected by the change are wrapped at <80 columns. Other
potentially offending lines have been left alone to reduce churn.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agopmc(3): add additional references for libpmc functions in the SEE ALSO section
Enji Cooper [Fri, 7 Apr 2017 05:46:45 +0000 (05:46 +0000)]
pmc(3): add additional references for libpmc functions in the SEE ALSO section

These functions are already referenced throughout the manpage -- this makes their
presence more apparent.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoPrevent ushort values overflow when convert new Linux 64-bit ipc
Dmitry Chagin [Fri, 7 Apr 2017 05:37:08 +0000 (05:37 +0000)]
Prevent ushort values overflow when convert new Linux 64-bit ipc
struct to the old Linux ipc struct.

Reported by: PVS-Studio
XMFC with: r314866

MFC after: 3 days

7 years agokern_descrip: Move kinfo_ofile size assert under COMPAT_FREEBSD7
Conrad Meyer [Fri, 7 Apr 2017 05:00:09 +0000 (05:00 +0000)]
kern_descrip: Move kinfo_ofile size assert under COMPAT_FREEBSD7

The size and structure are not used outside of FreeBSD 7 compatibility ABIs.

Sponsored by: Dell EMC Isilon

7 years agomakefs: Sync with NetBSD (fix unused variable warnings)
Ed Maste [Fri, 7 Apr 2017 02:31:55 +0000 (02:31 +0000)]
makefs: Sync with NetBSD (fix unused variable warnings)

NetBSD revs:
cd9660.c 1.45
cd9660/cd9660_write.c 1.17

Obtained from: NetBSD

7 years agoMove pause frame counter out of struct if_ctx and into struct if_softc_ctx_t
Sean Bruno [Fri, 7 Apr 2017 00:33:03 +0000 (00:33 +0000)]
Move pause frame counter out of struct if_ctx and into struct if_softc_ctx_t
so that we can use it in iflib to detect pause frames.

The igb(4) driver definitely used to use this in its old timer function and
I see no reason to restrict it to that driver only.

Sponsored by: Limelight Networks

7 years agoRegen after r316594.
Brooks Davis [Thu, 6 Apr 2017 23:40:51 +0000 (23:40 +0000)]
Regen after r316594.

7 years agoChange the size argument of __getcwd() to size_t.
Brooks Davis [Thu, 6 Apr 2017 23:40:13 +0000 (23:40 +0000)]
Change the size argument of __getcwd() to size_t.

This matches the getcwd() definition.

This is technically an ABI change, but that would only effect 64-bit
big-endian platforms that pass arguments on the stack. We have none of
those.

Reviewed by: jhb
Obtained from: CheriABI
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D9428

7 years agoPoint out that -F probably does not do what the user expects.
Brooks Davis [Thu, 6 Apr 2017 23:35:10 +0000 (23:35 +0000)]
Point out that -F probably does not do what the user expects.

Users attempting to create images from mtree METALOG files created by
installworld often use -F when they should be passing the METALOG file
in place of a directory. This is often produces difficult to debug
error reports.

Reviewed by: emaste
MFC after: 1 week
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D10038

7 years agoIntroduce libxo support to arp(8)
Renato Botelho [Thu, 6 Apr 2017 22:50:28 +0000 (22:50 +0000)]
Introduce libxo support to arp(8)

Reviewed by: wblock, gnn, allanjude, phil
Approved by: allanjude
MFC after: 1 week
Sponsored by: Rubicon Communications (Netgate)
Differential Revision: https://reviews.freebsd.org/D9563

7 years agoRemove dead code.
David E. O'Brien [Thu, 6 Apr 2017 22:21:49 +0000 (22:21 +0000)]
Remove dead code.
The #ifdef __FreeBSD__ section within the OpenBSD tpm_attach() implementation
can never be active.

7 years agolibstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory
Toomas Soome [Thu, 6 Apr 2017 20:12:39 +0000 (20:12 +0000)]
libstand/dosfs: cache FAT32 in 128 Kb blocks to save loader memory

Current implementation of dosfs in libstand reads full File Allocation Table to
the RAM in the initialization code. In the extreme case of FAT32 filesystem,
this structure will take up to 256-1024 Mb of loader memory, depending on the
cluster size.

Proposed patch reduces libstands/dosfs memory requirements to 128 Kb for all
variants of dosfs filesystem. For FAT12 and FAT16 filesystems, File Allocation
Table is cached in full, as before. For FAT32, File Allocation Table is broken
into the equal blocks of 128 Kilobytes (32768 entries), and only current block
is cached.

Because per-filesystem context is now small, global FAT cache (for all
instances of dosfs filesystem) is replaced by local per-instance cache.

Submitted by: Mikhail.Kupchik_gmail.com
Reviewed by: tsoome, allanjude
Differential Revision: https://reviews.freebsd.org/D9547

7 years agoUnify capitalization.
Edward Tomasz Napierala [Thu, 6 Apr 2017 19:17:20 +0000 (19:17 +0000)]
Unify capitalization.

MFC after: 2 weeks

7 years agoUpdate hier(7) by removing files and directories that no longer
Edward Tomasz Napierala [Thu, 6 Apr 2017 19:10:16 +0000 (19:10 +0000)]
Update hier(7) by removing files and directories that no longer
exist and doing a few random tweaks.

MFC after: 2 weeks

7 years agoMETA_MODE: Fix build-tools still sometimes rebuilding during target build.
Bryan Drewery [Thu, 6 Apr 2017 18:21:59 +0000 (18:21 +0000)]
META_MODE: Fix build-tools still sometimes rebuilding during target build.

In a cross-build, the build-tools are native host binaries.  We do not
want to rebuild them when building for the target.  Bmake previously
did not support checking .NOMETA on an existing target, so .NOMETA_CMP
was used here.  However, .NOMETA_CMP still triggers meta mode conditions
if the number of commands or the command changes.  In r312467 the paths
to build ncurses files were modified and thus triggered meta mode to
rebuild the build tools (make_keys, make_hash) in ncurses during the
target build.  Bmake 20160604 committed in r301462 changed .NOMETA to
also skip meta mode logic for an existing .meta file as well, thus it
is now the proper fix here.

I explored moving the build-tools output to WORLDTMP/tools with
relatively good success, but have concerns that doing so would be
problematic for downstream vendors who use LOCAL_TOOL_DIRS and
expect the tools to be in current OBJDIR for the target.  It also
adds more complexity into finding the tools during target build
and handling of where they are for rescue/rescue and
mkcsmapper_static/mkesdb_static which should really not be connected in
build-tools anyway.

MFC after: 2 weeks
Reported by: many
Sponsored by: Dell EMC Isilon

7 years agoloader: zfs reader should check all labels
Toomas Soome [Thu, 6 Apr 2017 18:17:29 +0000 (18:17 +0000)]
loader: zfs reader should check all labels

The current zfs reader is only checking first label from each device, however,
we do have 4 labels on device and we should check all 4 to be protected
against disk failures and incomplete label updates.

The difficulty is about the fact that 2 label copies are in front of the
pool data, and 2 are at the end, which means, we have to know the size of
the pool data area.

Since we have now the mechanism from common/disk.c to use the partition
information, it does help us in this task; however, there are still some
corner cases.

Namely, if the pool is created without partition, directly on the disk,
and firmware will give us the wrong size for the disk, we only can check
the first two label copies.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D10203

7 years agosmbfs: Fix an indentation level
Conrad Meyer [Thu, 6 Apr 2017 17:31:58 +0000 (17:31 +0000)]
smbfs: Fix an indentation level

Based on the change in r242386, it seems clear that scred was intended to
be released in all paths at exit.

No functional change.  This line's indent was just the result of a bad copy
paste from the previous free() in an early exit path.

Reported by: PVS-Studio
Sponsored by: Dell EMC Isilon

7 years agoremove archaic register keyword from ixgb and ex
Ed Maste [Thu, 6 Apr 2017 17:16:41 +0000 (17:16 +0000)]
remove archaic register keyword from ixgb and ex

Reviewed by: sbruno

7 years agobwn(4): Fix trivial null dereference
Conrad Meyer [Thu, 6 Apr 2017 17:08:59 +0000 (17:08 +0000)]
bwn(4): Fix trivial null dereference

Reported by: PVS-Studio
Sponsored by: Dell EMC Isilon

7 years agotx and rx interrupts are not combined in bnxt(4) and should be handled
Sean Bruno [Thu, 6 Apr 2017 16:22:54 +0000 (16:22 +0000)]
tx and rx interrupts are not combined in bnxt(4) and should be handled
independantly.

Submitted by: venkatkumar.duvvuru@broadcom.com>
Differential Revision: https://reviews.freebsd.org/D10297

7 years agocxgbe/iw_cxgbe: Remove another bad cast. This should have been
Navdeep Parhar [Thu, 6 Apr 2017 16:19:19 +0000 (16:19 +0000)]
cxgbe/iw_cxgbe: Remove another bad cast.  This should have been
included in r316571.

MFC after: 3 days
Sponsored by: Chelsio Communications

7 years agomakefs: use emalloc and friends
Ed Maste [Thu, 6 Apr 2017 16:18:42 +0000 (16:18 +0000)]
makefs: use emalloc and friends

The emalloc set of error-checking memory allocation routines were added
to libnetbsd in r316572. Use them in makefs to reduce differences with
NetBSD.

NetBSD revs:
cd9660.c 1.39
ffs.c 1.56
makefs.c 1.42
walk.c 1.27
cd9660/cd9660_archimedes.c 1.2
cd9660/cd9660_eltorito.c 1.20
cd9660/cd9660_write.c 1.16
cd9660/iso9660_rrip.c 1.12
ffs/buf.c 1.17
ffs/mkfs.c 1.26

Obtained from: NetBSD

7 years agoloader: want mechanism to avoid RA with bcache
Toomas Soome [Thu, 6 Apr 2017 15:57:53 +0000 (15:57 +0000)]
loader: want mechanism to avoid RA with bcache

While we have mechanisms in place to protect ourselves against the read
behind the disk end, there is still one corner case. As the GPT
partition table has backup table at the end of the disk, and we yet
do not know the size of the disk (if the wrong size is provided by the
firmware/bios), we need to limit the reads to avoid read ahead in such case.

Note: this update does add constant into stand.h, so the incremental build
will need to get local stand.h updated first.

Reviewed by: allanjude
Differential Revision: https://reviews.freebsd.org/D10187

7 years agoloader: part.c cstyle cleanup
Toomas Soome [Thu, 6 Apr 2017 15:42:12 +0000 (15:42 +0000)]
loader: part.c cstyle cleanup

The description tells it all, as an side note, I am using uint8_t instead of
u_char as the partition table data really is handled as byte stream, not
char array.

Reviewed by: allanjude, imp
Differential Revision: https://reviews.freebsd.org/D10180

7 years agocxgbe/iw_cxgbe: Replace a magic constant with something more readable
Navdeep Parhar [Thu, 6 Apr 2017 14:50:15 +0000 (14:50 +0000)]
cxgbe/iw_cxgbe: Replace a magic constant with something more readable
(and accurate).

T4 and later have an extra bit for page shift so the maximum page size
is 8TB (shift of 12 + 31) instead of 128MB (12 + 15).  This saves space
in the chip's PBL (physical buffer list) when registering very large
memory regions.

MFC after: 3 days
Sponsored by: Chelsio Communications

7 years agolibnetbsd: add emalloc and friends
Ed Maste [Thu, 6 Apr 2017 14:36:08 +0000 (14:36 +0000)]
libnetbsd: add emalloc and friends

These are error-checked versions of memory allocation routines used by
NetBSD code, and are being added to facilitate updates to makefs.

Reviewed by: ngie
Differential Revision: https://reviews.freebsd.org/D10291

7 years agocxgbe/iw_cxgbe: Remove bad cast that resulted in incorrect length for
Navdeep Parhar [Thu, 6 Apr 2017 13:58:59 +0000 (13:58 +0000)]
cxgbe/iw_cxgbe: Remove bad cast that resulted in incorrect length for
memory regions larger than 4GB.

MFC after: 3 days
Sponsored by: Chelsio Communications

7 years agoCleanup the bitmap_xxx() functions in the LinuxKPI:
Hans Petter Selasky [Thu, 6 Apr 2017 13:30:31 +0000 (13:30 +0000)]
Cleanup the bitmap_xxx() functions in the LinuxKPI:

- Move all bitmap related functions from bitops.h to bitmap.h, similar
  to what Linux does.

- Apply some minor code cleanup and simplifications to optimize the
  generated code when using static inline functions.

- Implement the following list of bitmap functions which are needed by
  drm-next and ibcore:
  - bitmap_find_next_zero_area_off()
  - bitmap_find_next_zero_area()
  - bitmap_or()
  - bitmap_and()
  - bitmap_xor()

- Add missing include directives to the qlnxe driver
  (davidcs@ has been notified)

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoRevert r316487. It is broken, causing boot to fail due to line 25 in
Cy Schubert [Thu, 6 Apr 2017 12:52:05 +0000 (12:52 +0000)]
Revert r316487. It is broken, causing boot to fail due to line 25 in
etc/rc.d/dhclient unconditionally testing true when called by a devd
rule during boot, ignoring statically assigned IP addresses in rc.conf.

Requested by: des@

7 years agoRemove spl*() calls from the nfsclient code. Style adjustments in the
Konstantin Belousov [Thu, 6 Apr 2017 12:44:34 +0000 (12:44 +0000)]
Remove spl*() calls from the nfsclient code.  Style adjustments in the
related lines in ncl_writebp().

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

7 years agoDefine VM_READ, VM_WRITE and VM_EXEC in the LinuxKPI.
Hans Petter Selasky [Thu, 6 Apr 2017 10:52:52 +0000 (10:52 +0000)]
Define VM_READ, VM_WRITE and VM_EXEC in the LinuxKPI.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoImplement need_resched() in the LinuxKPI.
Hans Petter Selasky [Thu, 6 Apr 2017 10:29:54 +0000 (10:29 +0000)]
Implement need_resched() in the LinuxKPI.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoFix implementation of task_pid_group_leader() in the LinuxKPI.
Hans Petter Selasky [Thu, 6 Apr 2017 10:26:03 +0000 (10:26 +0000)]
Fix implementation of task_pid_group_leader() in the LinuxKPI.

In FreeBSD thread IDs and procedure IDs have distinct number
spaces. When asking for the group leader task ID in the LinuxKPI,
return the procedure ID and let this resolve to the first task in the
procedure having a valid LinuxKPI task structure pointer.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoImplement proper support for memory map operations in the LinuxKPI,
Hans Petter Selasky [Thu, 6 Apr 2017 09:34:54 +0000 (09:34 +0000)]
Implement proper support for memory map operations in the LinuxKPI,
like open, close and fault using the character device pager.

Some notes about the implementation:

1) Linux drivers set the vm_ops and vm_private_data fields during a
mmap() call to indicate that the driver wants to use the LinuxKPI VM
operations. Else these operations are not used.

2) The vm_private_data pointer is associated with a VM area structure
and inserted into an internal LinuxKPI list. If the vm_private_data
pointer already exists, the existing VM area structure is used instead
of the allocated one which gets freed.

3) The LinuxKPI's vm_private_data pointer is used as the callback
handle for the FreeBSD VM object. The VM subsystem in FreeBSD has a
similar list to identify equal handles and will only call the
character device pager's close function once.

4) All LinuxKPI VM operations are serialized through the mmap_sem
sempaphore, which is per procedure, which prevents simultaneous access
to the shared VM area structure when receiving page faults.

Obtained from: kmacy @
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoBefore registering a new mm_struct in the LinuxKPI check if other
Hans Petter Selasky [Thu, 6 Apr 2017 09:07:01 +0000 (09:07 +0000)]
Before registering a new mm_struct in the LinuxKPI check if other
tasks in the belonging procedure already have a valid mm_struct and
reference that instead.

The mm_struct in the LinuxKPI should be shared among all tasks
belonging to the same procedure. This has to do with with the mmap_sem
semaphore which should serialize all VM operations inside a given
procedure. Linux based drivers depend on this behaviour.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoUse __FBSDID instead of the license agreement to embed the $FreeBSD$ RCS keyword
Enji Cooper [Thu, 6 Apr 2017 05:36:35 +0000 (05:36 +0000)]
Use __FBSDID instead of the license agreement to embed the $FreeBSD$ RCS keyword

Reminded by a comment made by markj w.r.t. using __FBSDID in .c files ala a
past Phabricator review.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agosbuf(3): add some basic functional tests for the library
Enji Cooper [Thu, 6 Apr 2017 05:29:28 +0000 (05:29 +0000)]
sbuf(3): add some basic functional tests for the library

Areas not covered still [positive functionality wise] are:
- sbuf_{clear,get,set}_flags
- sbuf_new (in particular, with fixed buffers, etc).

Some basic negative testing has been added, but more will be added in the
future.

This work was in part to validate work done by cem in r288223, and ian
before that.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agosbuf(9): add MLINKS for sbuf_{clear,get,set}_flags(9)
Enji Cooper [Thu, 6 Apr 2017 05:02:03 +0000 (05:02 +0000)]
sbuf(9): add MLINKS for sbuf_{clear,get,set}_flags(9)

These functions were added in r279992.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agosbuf(3): expose sbuf_{clear,get,set}_flags(3) via libsbuf
Enji Cooper [Thu, 6 Apr 2017 04:58:51 +0000 (04:58 +0000)]
sbuf(3): expose sbuf_{clear,get,set}_flags(3) via libsbuf

These functions were added to sbuf(9) in r279992, but never
exposed to userspace. Expose them now so they can be used/tested.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoatf-c: fix documentation description for atf_utils_wait(3)
Enji Cooper [Thu, 6 Apr 2017 03:50:58 +0000 (03:50 +0000)]
atf-c: fix documentation description for atf_utils_wait(3)

atf_utils_wait(3) should be used in combination with atf_utils_fork(3),
not itself (atf_utils_wait(3)).

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agosbuf(9): clarify kernel-only APIs
Enji Cooper [Thu, 6 Apr 2017 02:46:09 +0000 (02:46 +0000)]
sbuf(9): clarify kernel-only APIs

- move sbuf_bcopyin(9) and sbuf_copyin(9) near sbuf_new_for_sysctl(9), as
  all three functions are kernel-only APIs.
- add #ifdef _KERNEL around sbuf_*copyin and sbuf_new_for_sysctl(9) to
  make it visually clear that they are kernel-only APIs.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agosbuf(9): convert SYNOPSIS section from .Fn entries to .Fo/.Fa/.Fc entries
Enji Cooper [Thu, 6 Apr 2017 02:40:52 +0000 (02:40 +0000)]
sbuf(9): convert SYNOPSIS section from .Fn entries to .Fo/.Fa/.Fc entries

This shortens the column count on many lines considerably.

While here, add "(void)" to sbuf_new_auto(3) for consistency with style(9)
recommendations.

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoAdd sys/types.h #include to EXAMPLE to provide a complete functional
Enji Cooper [Thu, 6 Apr 2017 02:03:35 +0000 (02:03 +0000)]
Add sys/types.h #include to EXAMPLE to provide a complete functional
standalone example program

MFC after: 2 months
Sponsored by: Dell EMC Isilon

7 years agoQuiet 450.status-security when *_inline="YES"
Alan Somers [Thu, 6 Apr 2017 01:37:03 +0000 (01:37 +0000)]
Quiet 450.status-security when *_inline="YES"

Previously, 450.status-security would always set rc=3 in inline mode,
because it doesn't know whether "periodic security" is going to find
anything interesting. But this annoyingly results in daily reports that
simply say "Security check: \n\n-- End of daily output --".

This change fixes that by testing whether "periodic security" printed
anything, and setting 450.status-security's exit status to 3 if it did. An
alternative would be to change the exit status of periodic(8) to be the
worst of its scripts' exit statuses, but that would be a more intrusive
change.

Reviewed by: brian
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D10267

7 years ago[net80211] refactor out the A-MPDU dispatch routine.
Adrian Chadd [Thu, 6 Apr 2017 01:35:42 +0000 (01:35 +0000)]
[net80211] refactor out the A-MPDU dispatch routine.

The "dispatch a frame from the A-MPDU reorder buffer" code is essentially
duplicated in a couple of places.  This refactors it out into a single
place in preparation for A-MSDU in A-MPDU offload support, where multiple
A-MSDUs are decap'ed in hardware to 802.3/802.11 frames, but with the
same sequence number.

Reviewed by: avos
Differential Revision: https://reviews.freebsd.org/D10240

7 years agoRevert r316516. des@ asked that r316516 be reverted so that he can spend
Cy Schubert [Thu, 6 Apr 2017 00:15:18 +0000 (00:15 +0000)]
Revert r316516. des@ asked that r316516 be reverted so that he can spend
a little more time getting r316487 right.

Requested by: des@

7 years agomakefs: zero memory
Ed Maste [Thu, 6 Apr 2017 00:07:11 +0000 (00:07 +0000)]
makefs: zero memory

NetBSD revs:
ffs/buf.c 1.14

Obtained from: NetBSD

7 years agoDon't overrite vf->flags variable at the end of ixgbe(4) ixgbe_add_vf().
Sean Bruno [Wed, 5 Apr 2017 22:01:49 +0000 (22:01 +0000)]
Don't overrite vf->flags variable at the end of ixgbe(4) ixgbe_add_vf().

Found by PVS-Studio Static code analyzer.

PR: 217748
Submitted by: razmyslov@viva64.com
MFC after: 1 week

7 years agobsdgrep: Handle special case of single-byte NUL pattern
Ed Maste [Wed, 5 Apr 2017 20:11:05 +0000 (20:11 +0000)]
bsdgrep: Handle special case of single-byte NUL pattern

PR: 202022
Submitted by: Kyle Evans <kevans91 at ksu.edu>
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D10102

7 years agoFix a double free in ixgbe_rxeof()
Sean Bruno [Wed, 5 Apr 2017 19:52:49 +0000 (19:52 +0000)]
Fix a double free in ixgbe_rxeof()

Submitted by: rstone
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D10255

7 years agoFix the linker emulation setting for riscv.
John Baldwin [Wed, 5 Apr 2017 18:59:58 +0000 (18:59 +0000)]
Fix the linker emulation setting for riscv.

Reported by: lwhsu
MFC after: 1 week
Sponsored by: DARPA / AFRL

7 years agobsdgrep: create additional tests for coverage on recent fixes
Ed Maste [Wed, 5 Apr 2017 18:41:44 +0000 (18:41 +0000)]
bsdgrep: create additional tests for coverage on recent fixes

Create additional tests to cover regressions that were discovered by
PRs linked to reviews D10098, D10102, and D10104.

It is worth noting that neither bsdgrep(1) nor gnugrep(1) in the base
system currently pass all of these tests, and gnugrep(1) not quite being
up to snuff was also noted in at least one of the PRs.

PR: 175314 202022 195763 180990 197555 197531 181263 209116
Submitted by: Kyle Evans <kevans91@ksu.edu>
Reviewed by: cem, ngie, emaste
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D10112