]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
7 years agoRemove unreferenced global function imx_gpt_get_timerfreq() and do some
Ian Lepore [Sun, 19 Mar 2017 04:03:39 +0000 (04:03 +0000)]
Remove unreferenced global function imx_gpt_get_timerfreq() and do some
cleanups enabled by that:

 - The only thing left in imx_gptvar.h was the softc, which IMO never
   should have been in there at all.  Move it into the driver, and
   delete the header file.

 - Remove several unneeded #includes from the driver.

 - Change imx_gpt_softc from global to static (it's used by DELAY()), and
   don't redundantly static-initialize it to NULL.

7 years agopf: Fix rule evaluation after inet6 route-to
Kristof Provost [Sun, 19 Mar 2017 03:06:09 +0000 (03:06 +0000)]
pf: Fix rule evaluation after inet6 route-to

In pf_route6() we re-run the ruleset with PF_FWD if the packet goes out
of a different interface. pf_test6() needs to know that the packet was
forwarded (in case it needs to refragment so it knows whether to call
ip6_output() or ip6_forward()).

This lead pf_test6() to try to evaluate rules against the PF_FWD
direction, which isn't supported, so it needs to treat PF_FWD as PF_OUT.
Once fwdir is set correctly the correct output/forward function will be
called.

PR: 217883
Submitted by: Kajetan Staszkiewicz
MFC after: 1 week
Sponsored by: InnoGames GmbH

7 years agoTidy up mdoc formatting for "etc.)" at end of line
Benjamin Kaduk [Sun, 19 Mar 2017 01:24:18 +0000 (01:24 +0000)]
Tidy up mdoc formatting for "etc.)" at end of line

man(1) has some logic to use two spaces after a full stop, which is
useful for spotting sentence breaks in monospace fonts.  However,
this logic is very simple, treating almost all '.' characters as
end-of-sentence markers, unless followed by certain other
characters.  For example, '.,' is not end-of-sentence, and neither
is ".) ", but ".)" at the end of a line triggers the sentence-end
detection.

Apply a zero-width space to a few instances of this in share/man,
and also supply a missing full stop for an instance that occurred at
the end of a sentence.

Leave untouched several instances that are at the end of a sentence
or list element.

Reported by: 0mp (ieee80211.9)

7 years agoRegenerate syscall files for r315526
Eric van Gyzen [Sun, 19 Mar 2017 00:54:24 +0000 (00:54 +0000)]
Regenerate syscall files for r315526

Sponsored by: Dell EMC

7 years agoAdd clock_nanosleep()
Eric van Gyzen [Sun, 19 Mar 2017 00:51:12 +0000 (00:51 +0000)]
Add clock_nanosleep()

Add a clock_nanosleep() syscall, as specified by POSIX.
Make nanosleep() a wrapper around it.

Attach the clock_nanosleep test from NetBSD. Adjust it for the
FreeBSD behavior of updating rmtp only when interrupted by a signal.
I believe this to be POSIX-compliant, since POSIX mentions the rmtp
parameter only in the paragraph about EINTR. This is also what
Linux does. (NetBSD updates rmtp unconditionally.)

Copy the whole nanosleep.2 man page from NetBSD because it is complete
and closely resembles the POSIX description. Edit, polish, and reword it
a bit, being sure to keep any relevant text from the FreeBSD page.

Reviewed by: kib, ngie, jilles
MFC after: 3 weeks
Relnotes: yes
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D10020

7 years agoImprove decoding of last arguments to ioctl() and sendto().
John Baldwin [Sun, 19 Mar 2017 00:36:29 +0000 (00:36 +0000)]
Improve decoding of last arguments to ioctl() and sendto().

Decode the last argument to ioctl() as a pointer rather than an int.
Eventually this could use 'int' for the _IOWINT() case and pointers for
all others.

The last argument to sendto() is a socklen_t value, not a pointer.

7 years agoDecode arguments to madvise().
John Baldwin [Sun, 19 Mar 2017 00:31:21 +0000 (00:31 +0000)]
Decode arguments to madvise().

7 years agoAdd a Sizet type for 'size_t' values and use it instead of Int.
John Baldwin [Sun, 19 Mar 2017 00:27:07 +0000 (00:27 +0000)]
Add a Sizet type for 'size_t' values and use it instead of Int.

Various size_t arguments were previously decoded as Int values instead
which would have truncated values above 2^31 on 64-bit systems.

7 years agouse INT3 instead of NOP for x86 binary padding
Ed Maste [Sun, 19 Mar 2017 00:22:13 +0000 (00:22 +0000)]
use INT3 instead of NOP for x86 binary padding

We should never end up executing the inter-function padding, so we
are better off faulting than silently carrying on to whatever function
happens to be next.

Note that LLD will soon do this by default (although it currently pads
with zeros).

Reviewed by: dim, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D10047

7 years agoAvoid unnecessary calls to vm_map_protect() in elf_load_section().
Alan Cox [Sat, 18 Mar 2017 23:37:00 +0000 (23:37 +0000)]
Avoid unnecessary calls to vm_map_protect() in elf_load_section().

Typically, when elf_load_section() unconditionally passed VM_PROT_ALL to
elf_map_insert(), it was needlessly enabling execute access on the
mapping, and it would later have to call vm_map_protect() to correct the
mapping's access rights.  Now, instead, elf_load_section() always passes
its parameter "prot" to elf_map_insert().  So, elf_load_section() must
only call vm_map_protect() if it needs to remove the write access that
was temporarily granted to perform a copyout().

Reviewed by: kib
MFC after: 1 week

7 years agoChange several constants used by the PIE algorithm from unsigned to signed.
Don Lewis [Sat, 18 Mar 2017 23:00:13 +0000 (23:00 +0000)]
Change several constants used by the PIE algorithm from unsigned to signed.

 - PIE_MAX_PROB is compared to variable of int64_t and the type promotion
   rules can cause the value of that variable to be treated as unsigned.
   If the value is actually negative, then the result of the comparsion
   is incorrect, causing the algorithm to perform poorly in some
   situations.  Changing the constant to be signed cause the comparision
   to work correctly.

 - PIE_SCALE is also compared to signed values.  Fortunately they are
   also compared to zero and negative values are discarded so this is
   more of a cosmetic fix.

 - PIE_DQ_THRESHOLD is only compared to unsigned values, but it is small
   enough that the automatic promotion to unsigned is harmless.

Submitted by: Rasool Al-Saadi <ralsaadi@swin.edu.au>
MFC after: 1 week

7 years agosh: Remove unused function declaration for arith_lex_reset().
Jilles Tjoelker [Sat, 18 Mar 2017 20:41:07 +0000 (20:41 +0000)]
sh: Remove unused function declaration for arith_lex_reset().

Reported by: Robert Elz

7 years agonanosleep: plug a kernel memory disclosure
Eric van Gyzen [Sat, 18 Mar 2017 20:16:23 +0000 (20:16 +0000)]
nanosleep: plug a kernel memory disclosure

nanosleep() updates rmtp on EINVAL.  In that case, kern_nanosleep()
has not updated rmt, so sys_nanosleep() updates the user-space rmtp
by copying garbage from its stack frame.  This is not only a kernel
memory disclosure, it's also not POSIX-compliant.  Fix it to update
rmtp only on EINTR.

Reviewed by: jilles (via D10020), dchagin
MFC after: 3 days
Security: possibly
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D10044

7 years agoDecode arguments passed to kldsym() and kldunloadf().
John Baldwin [Sat, 18 Mar 2017 19:59:21 +0000 (19:59 +0000)]
Decode arguments passed to kldsym() and kldunloadf().

This does not currently decode the kld_sym_lookup structure passed to
kldsym().

7 years agoRemove hardcoded bootverbose=1; imx53 systems boot using loader(8) and
Ian Lepore [Sat, 18 Mar 2017 19:54:58 +0000 (19:54 +0000)]
Remove hardcoded bootverbose=1; imx53 systems boot using loader(8) and
users can set verbose if they want to.

7 years agoReorganize RQSTYPE_NOTIFY handling for chips <= 23xx.
Alexander Motin [Sat, 18 Mar 2017 19:27:16 +0000 (19:27 +0000)]
Reorganize RQSTYPE_NOTIFY handling for chips <= 23xx.

There were two copies of the code: one in generic code was half-broken, and
another in platform code was never called.  Leave only one in generic code
and working.

MFC after: 2 weeks

7 years agoGlibc get_nprocs() and get_nprocs_conf() uses the sysfs cpu infrastructure
Dmitry Chagin [Sat, 18 Mar 2017 18:38:12 +0000 (18:38 +0000)]
Glibc get_nprocs() and get_nprocs_conf() uses the sysfs cpu infrastructure
to get number of processors. Implement /sys/devices/system/cpu/.

MFC after: 1 month

7 years agoImplement getrandom() syscall.
Dmitry Chagin [Sat, 18 Mar 2017 18:34:29 +0000 (18:34 +0000)]
Implement getrandom() syscall.
Note. GRND_RANDOM option is not supported for now.

MFC after: 1 month

7 years agoDecode arguments passed to getfsstat().
John Baldwin [Sat, 18 Mar 2017 18:31:45 +0000 (18:31 +0000)]
Decode arguments passed to getfsstat().

Note that this does not yet decode the statfs structures returned by
getfsstat().

7 years agoAs noted by Roel Bouwman Linux allows a large buffer size than the
Dmitry Chagin [Sat, 18 Mar 2017 18:31:04 +0000 (18:31 +0000)]
As noted by Roel Bouwman Linux allows a large buffer size than the
struct ucred size. Fix this.

PR: 102956
Reported by: Roel Bouwman <roel at qsp nl>
MFC after: 1 week

7 years agoDecode flock() operation.
John Baldwin [Sat, 18 Mar 2017 18:26:56 +0000 (18:26 +0000)]
Decode flock() operation.

7 years agoTo reduce code duplication move socket defines to the MI path.
Dmitry Chagin [Sat, 18 Mar 2017 18:23:30 +0000 (18:23 +0000)]
To reduce code duplication move socket defines to the MI path.

MFC after: 1 week

7 years agoDecode file flags passed to *chflags*().
John Baldwin [Sat, 18 Mar 2017 18:21:41 +0000 (18:21 +0000)]
Decode file flags passed to *chflags*().

While here, decode arguments passed to fchflags() and chflagsat().

7 years agoRemove superflous break statment.
Dmitry Chagin [Sat, 18 Mar 2017 18:19:31 +0000 (18:19 +0000)]
Remove superflous break statment.

MFC after: 1 week

7 years agoCheck for negative nanoseconds.
Dmitry Chagin [Sat, 18 Mar 2017 18:14:17 +0000 (18:14 +0000)]
Check for negative nanoseconds.
Linux do that in timespec_valid().

Reported by: vangyzen@
MFC after: 1 week

7 years agoDecode arguments passed to posix_fadvise().
John Baldwin [Sat, 18 Mar 2017 18:12:09 +0000 (18:12 +0000)]
Decode arguments passed to posix_fadvise().

7 years agoDecode the arguments passed to cap_fcntls_get() and cap_fcntls_limit().
John Baldwin [Sat, 18 Mar 2017 18:10:02 +0000 (18:10 +0000)]
Decode the arguments passed to cap_fcntls_get() and cap_fcntls_limit().

7 years agoMake the imx5 clocks driver work with vendor-supplied dts (which does not
Ian Lepore [Sat, 18 Mar 2017 17:50:49 +0000 (17:50 +0000)]
Make the imx5 clocks driver work with vendor-supplied dts (which does not
supply the addresses for the DPLL register blocks) by hard-coding the
addresses in the driver source code.  Yes, this is just as bad an idea as
it sounds, but we have no choice.

In the early days of using fdt data, when we were making up our own data
for each board, we defined 4 sets of memory mapped registers in the data.
The vendor-supplied data only provides the address of the CCM register
block, but not the 3 DPLL blocks.  The linux driver has the DPLL physical
addresses (which differ by SOC type) hard-coded in the driver, and we
have no choice but to do the same thing if we want to run with the vendor-
supplied fdt data.

So now we use bus_space_map() to make the DPLL blocks accessible, choosing
the set of fixed addresses to map based on the soc id.

7 years agoMove RQSTYPE_ABTS_RCVD parsing into generic code.
Alexander Motin [Sat, 18 Mar 2017 17:01:11 +0000 (17:01 +0000)]
Move RQSTYPE_ABTS_RCVD parsing into generic code.

MFC after: 2 weeks

7 years agoExtend nt_lun to full 8 byte.
Alexander Motin [Sat, 18 Mar 2017 16:09:36 +0000 (16:09 +0000)]
Extend nt_lun to full 8 byte.

MFC after: 2 weeks

7 years agosh: Remove unused return value of subevalvar_misc().
Jilles Tjoelker [Sat, 18 Mar 2017 16:09:30 +0000 (16:09 +0000)]
sh: Remove unused return value of subevalvar_misc().

7 years agoRemove dead remnants of SPI target.
Alexander Motin [Sat, 18 Mar 2017 15:42:22 +0000 (15:42 +0000)]
Remove dead remnants of SPI target.

MFC after: 2 weeks

7 years agoptrace_test: eliminate assumption about thread scheduling
Eric Badger [Sat, 18 Mar 2017 15:25:51 +0000 (15:25 +0000)]
ptrace_test: eliminate assumption about thread scheduling

A couple of the ptrace tests make assumptions about which thread in a
multithreaded process will run after a halt. This makes the tests less
portable across branches, and susceptible to future breakage. Instead,
twiddle thread scheduling and priorities to match the tests'
expectation.

X-MFC with: r313992
Sponsored by: Dell EMC

7 years agoUse isp_target_put_entry() in places where it can be.
Alexander Motin [Sat, 18 Mar 2017 13:42:08 +0000 (13:42 +0000)]
Use isp_target_put_entry() in places where it can be.

This unifies the code and removes some duplication.

MFC after: 2 weeks

7 years agoFix bright colors for syscons, and make them work for the first time
Bruce Evans [Sat, 18 Mar 2017 11:13:54 +0000 (11:13 +0000)]
Fix bright colors for syscons, and make them work for the first time
for vt.  Restore syscons' rendering of background (bg) brightness as
foreground (fg) blinking and vice versa, and add rendering of blinking
as background brightness to vt.

Bright/saturated is conflated with light/white in the implementation
and in this description.

Bright colors were broken in all cases, but appeared to work in the
only case shown by "vidcontrol show".  A boldness hack was applied
only in 1 layering-violation place (for some syscons sequences) where
it made some cases seem to work but was undone by clearing bold using
ANSI sequences, and more seriously was not undone when setting
ANSI/xterm dark colors so left them bright.  Move this hack to drivers.

The boldness hack is only for fg brightness.  Restore/add a similar hack
for bg brightness rendered as fg blinking and vice versa.  This works
even better for vt, since vt changes the default text mode to give the
more useful bg brightness instead of fg blinking.

The brightness bit in colors was unnecessarily removed by the boldness
hack.  In other cases, it was lost later by teken_256to8().  Use
teken_256to16() to not lose it.  teken_256to8() was intended to be
used for bg colors to allow finer or bg-specific control for the more
difficult reduction to 8; however, since 16 bg colors actually work
on VGA except in syscons text mode and the conversion isn't subtle
enough to significantly in that mode, teken_256to8() is not used now.

There are still bugs, especially in vidcontrol, if bright/blinking
background colors are set.

Restore XOR logic for bold/bright fg in syscons (don't change OR
logic for vt).  Remove broken ifdef on FG_UNDERLINE and its wrong
or missing bit and restore the correct hard-coded bit.  FG_UNDERLINE
is only for mono mode which is not really supported.

Restore XOR logic for blinking/bright bg in syscons (in vt, add
OR logic and render as bright bg).  Remove related broken ifdef
on BG_BLINKING and its missing bit and restore the correct
hard-coded bit.  The same bit means blinking or bright bg depending
on the mode, and we want to ignore the difference everywhere.

Simplify conversions of attributes in syscons.  Don't pretend to
support bold fonts.  Don't support unusual encodings of brightness.
It is as good as possible to map 16 VGA colors to 16 xterm-16
colors.  E.g., VGA brown -> xterm-16 Olive will be converted back
to VGA brown, so we don't need to convert to xterm-256 Brown.  Teken
cons25 compatibility code already does the same, and duplicates some
small tables.  This is mostly for the sc -> te direction.  The other
direction uses teken_256to16() which is too generic.

7 years agoDo some notify acks cleanup.
Alexander Motin [Sat, 18 Mar 2017 10:34:29 +0000 (10:34 +0000)]
Do some notify acks cleanup.

ISPASYNC_TARGET_NOTIFY_ACK makes no sense without argument.

MFC after: 2 weeks

7 years agoFix right shifts on arches with db_expr_t larger than u_int (LP64 arches
Bruce Evans [Sat, 18 Mar 2017 07:01:18 +0000 (07:01 +0000)]
Fix right shifts on arches with db_expr_t larger than u_int (LP64 arches
in practice).

db_expr_t is a signed type, but right shifts are fudged to evaluate
them in an unsigned type, and the unsigned type was broken by hard-
coding it as 'unsigned', so casting to it lost the top bits on arches
with db_expr_t larger than u_int.

The unsigned type with the same size as db_expr_t is not declared;
assume that db_addr_t gives it.  Fixing this properly is less important
than using the correct type for db_expr_t (originally always long for
C90, but always intmax_t since C99).

7 years agopf: Fix memory leak on vnet shutdown or unload
Kristof Provost [Sat, 18 Mar 2017 01:37:20 +0000 (01:37 +0000)]
pf: Fix memory leak on vnet shutdown or unload

Rules are unlinked in shutdown_pf(), so we must call
pf_unload_vnet_purge(), which frees unlinked rules, after that, not
before.

Reviewed by: eri, bz
Differential Revision: https://reviews.freebsd.org/D10040

7 years agolibc: add reference to two-way algorithm and bad shift table in memmem/strstr
Ed Maste [Sat, 18 Mar 2017 00:53:24 +0000 (00:53 +0000)]
libc: add reference to two-way algorithm and bad shift table in memmem/strstr

Requested by: ed

7 years agolibc: Use musl's O(n) memmem and strstr
Ed Maste [Sat, 18 Mar 2017 00:51:39 +0000 (00:51 +0000)]
libc: Use musl's O(n) memmem and strstr

It is O(n) in the length of the haystack (big) string, and has special
cases for short needle (little) strings, of one to four bytes, to avoid
excessive overhead.

There are a small set of nearly trivial cases where the startup overhead
of the musl implementation makes it slightly slower -- for example, a 31
byte needle that matches the beginning of the haystack.  It's faster for
non-trivial cases, and significantly so for inputs that trigger worst-
case behaviour of the previous implementation.  As an example, in my
tests a 16K needle that matches the end of a 64K haystack is nearly
2000x faster with this implementation.

Reviewed by: bapt (earlier), ed (earlier)
Obtained from: musl (snapshot at commit c718f9fc)
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D2601

7 years agoAgain, fixes regarding style(4), to comments, includes and unused
Marius Strobl [Fri, 17 Mar 2017 22:57:37 +0000 (22:57 +0000)]
Again, fixes regarding style(4), to comments, includes and unused
parameters.

7 years agoAdd MIPS boot support for the BCM4706/Northstar ChipCommon core.
Landon J. Fuller [Fri, 17 Mar 2017 22:02:02 +0000 (22:02 +0000)]
Add MIPS boot support for the BCM4706/Northstar ChipCommon core.

This adds support for matching against a core lookup table when performing
early boot core lookup, and includes the BCM4706/Northstar-specific
ChipCommon core ID in the set of supported ChipCommon cores.

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D10033

7 years agoIntroduce 64-bit PowerPC Book-E support
Justin Hibbits [Fri, 17 Mar 2017 21:40:14 +0000 (21:40 +0000)]
Introduce 64-bit PowerPC Book-E support

Extend the Book-E pmap to support 64-bit operation.  Much of this was taken from
Juniper's Junos FreeBSD port.  It uses a 3-level page table (page directory
list -- PP2D, page directory, page table), but has gaps in the page directory
list where regions will repeat, due to the design of the PP2D hash (a 20-bit gap
between the two parts of the index).  In practice this may not be a problem
given the expanded address space.  However, an alternative to this would be to
use a 4-level page table, like Linux, and possibly reduce the available address
space; Linux appears to use a 46-bit address space.  Alternatively, a cache of
page directory pointers could be used to keep the overall design as-is, but
remove the gaps in the address space.

This includes a new kernel config for 64-bit QorIQ SoCs, based on MPC85XX, with
the following notes:
* The DPAA driver has not yet been ported to 64-bit so is not included in the
  kernel config.
* This has been tested on the AmigaOne X5000, using a MD_ROOT compiled in
  (total size kernel+mdroot must be under 64MB).
* This can run both 32-bit and 64-bit processes, and has even been tested to run
  a 32-bit init with 64-bit children.

Many thanks to stevek and marcel for getting Juniper's FreeBSD patches open
sourced to be used here, and to stevek for reviewing, and providing some
historical contexts on quirks of the code.

Reviewed by: stevek
Obtained from: Juniper (in part)
MFC after: 2 months
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D9433

7 years agoMETA_MODE: Fix not using .depend files when no OBJDIR is present.
Bryan Drewery [Fri, 17 Mar 2017 18:08:36 +0000 (18:08 +0000)]
META_MODE: Fix not using .depend files when no OBJDIR is present.

By default bmake does not allow meta mode to work unless an OBJDIR is
present.  It allows this if curdirok= is set with a value not starting
with [0NnFf], but usually it is "yes".

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

7 years agokmod: Fix building assym.o not building missing dependencies.
Bryan Drewery [Fri, 17 Mar 2017 18:08:33 +0000 (18:08 +0000)]
kmod: Fix building assym.o not building missing dependencies.

For instance, in the dtrace/dtrace module, building dtrace_asm.o wants
to build genassym.o first, but it doesn't build the missing ilinks
and if_*.h headers which are part of the OBJS_DEPEND_GUESS list
of dependencies to build if a .depend file is missing.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agokmod: Fix depending on ILINKS for tracked DEPENDOBJS.
Bryan Drewery [Fri, 17 Mar 2017 18:08:00 +0000 (18:08 +0000)]
kmod: Fix depending on ILINKS for tracked DEPENDOBJS.

The objects that may be in the dependency graph may not match
${OBJS}.  Ensure the ilink link is added as a dependency for
all of them when a .depend file is missing for that objfile.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

7 years agoConstrain IPv6 routes to single FIBs when net.add_addr_allfibs=0
Alan Somers [Fri, 17 Mar 2017 16:50:37 +0000 (16:50 +0000)]
Constrain IPv6 routes to single FIBs when net.add_addr_allfibs=0

sys/netinet6/icmp6.c
Use the interface's FIB for source address selection in ICMPv6 error
responses.

sys/netinet6/in6.c
In in6_newaddrmsg, announce arrival of local addresses on the
interface's FIB only.  In in6_lltable_rtcheck, use a per-fib ND6
cache instead of a single cache.

sys/netinet6/in6_src.c
In in6_selectsrc, use the caller's fib instead of the default fib.
In in6_selectsrc_socket, remove a superfluous check.

sys/netinet6/nd6.c
In nd6_lle_event, use the interface's fib for routing socket
messages.  In nd6_is_new_addr_neighbor, check all FIBs when trying
to determine whether an address is a neighbor.  Also, simplify the
code for point to point interfaces.

sys/netinet6/nd6.h
sys/netinet6/nd6.c
sys/netinet6/nd6_rtr.c
Make defrouter_select fib-aware, and make all of its callers pass in
the interface fib.

sys/netinet6/nd6_nbr.c
When inputting a Neighbor Solicitation packet, consider the
interface fib instead of the default fib for DAD.  Output NS and
Neighbor Advertisement packets on the correct fib.

sys/netinet6/nd6_rtr.c
Allow installing the same host route on different interfaces in
different FIBs.  If rt_add_addr_allfibs=0, only install or delete
the prefix route on the interface fib.

tests/sys/netinet/fibs_test.sh
Clear some expected failures, but add a skip for the newly revealed
BUG217871.

PR: 196361
Submitted by: Erick Turnquist <jhujhiti@adjectivism.org>
Reported by: Jason Healy <jhealy@logn.net>
Reviewed by: asomers
MFC after: 3 weeks
Sponsored by: Spectra Logic Corp
Differential Revision: https://reviews.freebsd.org/D9451

7 years agoImplement get_pid_task(), pid_task() and some other PID helper
Hans Petter Selasky [Fri, 17 Mar 2017 15:40:24 +0000 (15:40 +0000)]
Implement get_pid_task(), pid_task() and some other PID helper
functions in the LinuxKPI. Add a usage atomic to the task_struct
structure to facilitate refcounting the task structure when returned
from get_pid_task(). The get_task_struct() and put_task_struct()
function is used to manage atomic refcounting. After this change the
task_struct should only be freed through put_task_struct().

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

7 years agor308996 broke IP literals by assuming that a colon could only occur as
Dag-Erling Smørgrav [Fri, 17 Mar 2017 14:18:52 +0000 (14:18 +0000)]
r308996 broke IP literals by assuming that a colon could only occur as
a separator between host and port, and using strchr() to search for it.
Rewrite fetch_resolve() so it handles bracketed literals correctly, and
remove similar code elsewhere to avoid passing unbracketed literals to
fetch_resolve().  Remove #ifdef INET6 so we still parse IP literals
correctly even if we do not have the ability to connect to them.

While there, fix an off-by-one error which caused HTTP 400 errors to be
misinterpreted as redirects.

PR: 217723
MFC after: 1 week
Reported by: bapt, bz, cem, ngie

7 years agoDon't access the reserved registers %dr4 and %dr5 on i386.
Bruce Evans [Fri, 17 Mar 2017 13:49:05 +0000 (13:49 +0000)]
Don't access the reserved registers %dr4 and %dr5 on i386.

On the original i386, %dr[4-5] were unimplemented but not very clearly
reserved, so debuggers read them to print them.  i386 was still doing
this.

On the original athlon64, %dr[4-5] are documented as reserved but are
aliased to %dr[6-7] unless CR4_DE is set, when accessing them traps.

On 2 of my systems, accessing %dr[4-5] trapped sometimes.  On my Haswell
system, the apparent randomness was because the boot CPU starts with
CR4_DE set while all other CPUs start with CR4_DE clear.  FreeBSD
doesn't support the data breakpoints enabled by CR4_DE and it never
changes this flag, so the flag remains different across CPUs and
the behaviour seemed inconsistent except while booting when the CPU
doesn't change.

The invalid accesses broke:
- read access for printing the registers in ddb "show watches" on CPUs
  with CR4_DE set
- read accesses in fill_dbregs() on CPUs with CR4_DE set.  This didn't
  implement panic(3) since the user case always skipped %dr[4-5].
- write accesses in set_dbregs().  This also didn't affect userland.
  When it didn't trap, the aliasing made it fragile.

Don't print the dummy (zero) values of %dr[4-5] in "show watches" for
i386 or amd64.  Fix style bugs near this printing.

amd64 also has space in the dbregs struct for the reserved %dr[8-15]
and already didn't print the dummy values for these, and never accessed
any of the 10 reserved debug registers.

Remove cpufuncs for making the invalid accesses.  Even amd64 had these.

7 years agoWhen clearing altsigstack settings on exec, do it to the right thread.
Konstantin Belousov [Fri, 17 Mar 2017 13:37:37 +0000 (13:37 +0000)]
When clearing altsigstack settings on exec, do it to the right thread.

Diagnosed by: smh
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

7 years agoMark the EFI PE header as allocated. While ld.bfd doesn't seem to care
Andrew Turner [Fri, 17 Mar 2017 13:31:24 +0000 (13:31 +0000)]
Mark the EFI PE header as allocated. While ld.bfd doesn't seem to care
about not having this flag ld.lld fails to link without it.

Sponsored by: DARPA, AFRL

7 years agoRemove code for Marvell SoCs that lack a kernel config.
Andrew Turner [Fri, 17 Mar 2017 12:59:16 +0000 (12:59 +0000)]
Remove code for Marvell SoCs that lack a kernel config.

It seems to be old code from the armv6 project branch that never had a
kernel config.

Reviewed by: mmel
Sponsored by: ABT Systems Lrd
Differential Revision: https://reviews.freebsd.org/D7166

7 years agoMake the default FDT implementation of platform_mp_setmaxid use the cpu
Andrew Turner [Fri, 17 Mar 2017 12:45:53 +0000 (12:45 +0000)]
Make the default FDT implementation of platform_mp_setmaxid use the cpu
nodes from the DTB by default. This will allow us to enumerate the CPUs
without hard coding the CPU count into code.

Reviewed by: br
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D9827

7 years agoReduce ARC fragmentation threshold
Steven Hartland [Fri, 17 Mar 2017 12:34:57 +0000 (12:34 +0000)]
Reduce ARC fragmentation threshold

As ZFS can request up to SPA_MAXBLOCKSIZE memory block e.g. during zfs recv,
update the threshold at which we start agressive reclamation to use
SPA_MAXBLOCKSIZE (16M) instead of the lower zfs_max_recordsize which
defaults to 1M.

PR: 194513
Reviewed by: avg, mav
MFC after: 1 month
Sponsored by: Multiplay
Differential Revision: https://reviews.freebsd.org/D10012

7 years agoMove the IMX6 kernels to use PLATFORM_SMP. This is the last SMP config to
Andrew Turner [Fri, 17 Mar 2017 12:34:56 +0000 (12:34 +0000)]
Move the IMX6 kernels to use PLATFORM_SMP. This is the last SMP config to
be migrated to this and will allow the removal of this option.

Reviewed by: ian
Sponsored by: ABT Systems Ltd
Differential Revision: https://reviews.freebsd.org/D9907

7 years agoRevert changes introduced in r314036 on demand by jhb and bapt.
Bartek Rutkowski [Fri, 17 Mar 2017 11:45:46 +0000 (11:45 +0000)]
Revert changes introduced in r314036 on demand by jhb and bapt.

Approved by: bapt, jhb

7 years agoImplement minimalistic memory mapping structure, struct mm_struct, and
Hans Petter Selasky [Fri, 17 Mar 2017 10:30:06 +0000 (10:30 +0000)]
Implement minimalistic memory mapping structure, struct mm_struct, and
some associated helper functions in the LinuxKPI. Let the existing
linux_alloc_current() function allocate and initialize the new
structure and let linux_free_current() drop the refcount on the memory
mapping structure. When the mm_struct's refcount reaches zero, the
structure is freed.

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

7 years agoAdd comment describing the use of pagefault_disable() and
Hans Petter Selasky [Fri, 17 Mar 2017 08:02:46 +0000 (08:02 +0000)]
Add comment describing the use of pagefault_disable() and
pagefault_enable() in the LinuxKPI.

Suggested by:   rpokala@
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoRemove unused vmmeter.
Gleb Smirnoff [Fri, 17 Mar 2017 04:16:14 +0000 (04:16 +0000)]
Remove unused vmmeter.

7 years agoUpdate dtsec man page with correct config requirements.
Justin Hibbits [Fri, 17 Mar 2017 03:14:15 +0000 (03:14 +0000)]
Update dtsec man page with correct config requirements.

7 years agoAdd ZFS compressed ARC stats to top(1)
Allan Jude [Fri, 17 Mar 2017 00:46:50 +0000 (00:46 +0000)]
Add ZFS compressed ARC stats to top(1)

Provides:
amount of compressed data
logical size of compressed data (how much it would have taken uncompressed)
compression ratio (logical size : total ARC size)
Overhead (space consumed for compression headers)

Example output:
ARC: 31G Total, 18G MFU, 9067M MRU, 2236K Anon, 615M Header, 2947M Other
     25G Compressed, 54G Uncompressed, 1.76:1 Ratio, 2265M Overhead

Reviewed by: jpaetzel, smh, imp, jhb (previous version)
MFC after: 2 week
Relnotes: yes
Sponsored by: ScaleEngine Inc.
Differential Revision: https://reviews.freebsd.org/D9829

7 years ago- Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
Marius Strobl [Thu, 16 Mar 2017 22:42:17 +0000 (22:42 +0000)]
- Adds macros for the content of SDHCI_ADMA_ERR and SDHCI_HOST_CONTROL2
  registers.
- Add slot type capability bits. These bits should allow recognizing
  removable card slots, embedded cards and shared buses (shared bus
  supposedly is always comprised of non-removable cards).
- Dump CAPABILITIES2, ADMA_ERR, HOST_CONTROL2 and ADMA_ADDRESS_LO
  registers in sdhci_dumpregs().
- The drive type support flags in the CAPABILITIES2 register are for
  drive types A,C,D, drive type B is the default setting (value 0) of
  the drive strength field in the SDHCI_HOST_CONTROL2 register.

Obtained from: DragonFlyBSD (9e3c8f63455bd1b1)

7 years ago- Add support for eMMC "partitions". Besides the user data area, i. e.
Marius Strobl [Thu, 16 Mar 2017 22:23:04 +0000 (22:23 +0000)]
- Add support for eMMC "partitions". Besides the user data area, i. e.
  the default partition, eMMC v4.41 and later devices can additionally
  provide up to:
  1 enhanced user data area partition
  2 boot partitions
  1 RPMB (Replay Protected Memory Block) partition
  4 general purpose partitions (optionally with a enhanced or extended
    attribute)

  Of these "partitions", only the enhanced user data area one actually
  slices the user data area partition and, thus, gets handled with the
  help of geom_flashmap(4). The other types of partitions have address
  space independent from the default partition and need to be switched
  to via CMD6 (SWITCH), i. e. constitute a set of additional "disks".

  The second kind of these "partitions" doesn't fit that well into the
  design of mmc(4) and mmcsd(4). I've decided to let mmcsd(4) hook all
  of these "partitions" up as disk(9)'s (except for the RPMB partition
  as it didn't seem to make much sense to be able to put a file-system
  there and may require authentication; therefore, RPMB partitions are
  solely accessible via the newly added IOCTL interface currently; see
  also below). This approach for one resulted in cleaner code. Second,
  it retains the notion of mmcsd(4) children corresponding to a single
  physical device each. With the addition of some layering violations,
  it also would have been possible for mmc(4) to add separate mmcsd(4)
  instances with one disk each for all of these "partitions", however.
  Still, both mmc(4) and mmcsd(4) share some common code now e. g. for
  issuing CMD6, which has been factored out into mmc_subr.c.

  Besides simply subdividing eMMC devices, some Intel NUCs having UEFI
  code in the boot partitions etc., another use case for the partition
  support is the activation of pseudo-SLC mode, which manufacturers of
  eMMC chips typically associate with the enhanced user data area and/
  or the enhanced attribute of general purpose partitions.

  CAVEAT EMPTOR: Partitioning eMMC devices is a one-time operation.

- Now that properly issuing CMD6 is crucial (so data isn't written to
  the wrong partition for example), make a step into the direction of
  correctly handling the timeout for these commands in the MMC layer.
  Also, do a SEND_STATUS when CMD6 is invoked with an R1B response as
  recommended by relevant specifications. However, quite some work is
  left to be done in this regard; all other R1B-type commands done by
  the MMC layer also should be followed by a SEND_STATUS (CMD13), the
  erase timeout calculations/handling as documented in specifications
  are entirely ignored so far, the MMC layer doesn't provide timeouts
  applicable up to the bridge drivers and at least sdhci(4) currently
  is hardcoding 1 s as timeout for all command types unconditionally.
  Let alone already available return codes often not being checked in
  the MMC layer ...

- Add an IOCTL interface to mmcsd(4); this is sufficiently compatible
  with Linux so that the GNU mmc-utils can be ported to and used with
  FreeBSD (note that due to the remaining deficiencies outlined above
  SANITIZE operations issued by/with `mmc` currently most likely will
  fail). These latter will be added to ports as sysutils/mmc-utils in
  a bit. Among others, the `mmc` tool of the GNU mmc-utils allows for
  partitioning eMMC devices (tested working).

- For devices following the eMMC specification v4.41 or later, year 0
  is 2013 rather than 1997; so correct this for assembling the device
  ID string properly.

- Let mmcsd.ko depend on mmc.ko. Additionally, bump MMC_VERSION as at
  least for some of the above a matching pair is required.

- In the ACPI front-end of sdhci(4) describe the Intel eMMC and SDXC
  controllers as such in order to match the PCI one.
  Additionally, in the entry for the 80860F14 SDXC controller remove
  the eMMC-only SDHCI_QUIRK_INTEL_POWER_UP_RESET.

OKed by: imp
Submitted by: ian (mmc_switch_status() implementation)

7 years agortld(1): Document that LD_BIND_NOT is unset for setugid processes.
Jilles Tjoelker [Thu, 16 Mar 2017 22:15:43 +0000 (22:15 +0000)]
rtld(1): Document that LD_BIND_NOT is unset for setugid processes.

MFC after: 2 weeks

7 years agosh: Get rid of global variable argbackq.
Jilles Tjoelker [Thu, 16 Mar 2017 21:53:55 +0000 (21:53 +0000)]
sh: Get rid of global variable argbackq.

7 years agoloader: biosdisk should report IO error from INT13
Toomas Soome [Thu, 16 Mar 2017 21:34:14 +0000 (21:34 +0000)]
loader: biosdisk should report IO error from INT13

We should be more verbose about read errors from biosdisk, except filter
out the floppy controller errors, which apparently are resulting from
read attempt from device without the media present.

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

7 years agoMFV r315425:
Pedro F. Giffuni [Thu, 16 Mar 2017 21:32:05 +0000 (21:32 +0000)]
MFV r315425:
one-true-awk: have calloc(3) do the multiplication.

MFC after: 3 days

7 years agoone-true-awk: have calloc(3) do the multiplication.
Pedro F. Giffuni [Thu, 16 Mar 2017 21:26:26 +0000 (21:26 +0000)]
one-true-awk: have calloc(3) do the multiplication.

Recently upstreamed.

7 years agoReplace SOFTFLOAT with __mips_soft_float, which gcc/clang define for us.
Brooks Davis [Thu, 16 Mar 2017 21:05:21 +0000 (21:05 +0000)]
Replace SOFTFLOAT with __mips_soft_float, which gcc/clang define for us.

D8376 extended softfloat/hardfloat support, but used a macro that never
actually gets set except in libc and msun's Makefile.inc.  So libc and libm
got built correctly, but any program including fenv.h itself assumed it was
on a hardfloat systen and emitted inline fpu instructions for
fedisableexcept() and friends.

Using __mips_soft_float makes everything work in all cases, since it's a
compiler-internal macro that is always set correctly for the target

PR: 217845
Submitted by: Dan Nelson <dnelson_1901@yahoo.com>
MFC after: 1 week

7 years agoFix libsysdecode vmprot flag decoding
Steven Hartland [Thu, 16 Mar 2017 20:55:00 +0000 (20:55 +0000)]
Fix libsysdecode vmprot flag decoding

Fix the regex used to find vmprot table entries and add the missing include.

This fixes kdumps output of PFLT arguments which would previously look like:
5202 101546 ktrace   PFLT  0x5ae000 0x2<><invalid>2

They now display correctly:
5202 101546 ktrace   PFLT  0x5ac000 0x2<VM_PROT_WRITE>

MFC after: 1 week

7 years agoUse __LP64__ to detect presence of suword64() to fix linking and
Hans Petter Selasky [Thu, 16 Mar 2017 20:39:31 +0000 (20:39 +0000)]
Use __LP64__ to detect presence of suword64() to fix linking and
loading of the LinuxKPI on 32-bit platforms.

Reported by: lwhsu @
MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoIf ofw_bus_msimap fails don't try to use the invalid MSI/MSI-X parent node.
Andrew Turner [Thu, 16 Mar 2017 17:49:37 +0000 (17:49 +0000)]
If ofw_bus_msimap fails don't try to use the invalid MSI/MSI-X parent node.

Sponsored by: ABT Systems Ltd

7 years agoThe LinuxKPI pagefault disable and enable functions can only be used
Hans Petter Selasky [Thu, 16 Mar 2017 16:53:22 +0000 (16:53 +0000)]
The LinuxKPI pagefault disable and enable functions can only be used
pairwise to support the FreeBSD way of pushing and popping the page
fault flags. Ensure this by requiring every occurrence of pagefault
disable function call to have a corresponding pagefault enable call.

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

7 years agoImplement more userspace memory access functions in the LinuxKPI.
Hans Petter Selasky [Thu, 16 Mar 2017 16:49:27 +0000 (16:49 +0000)]
Implement more userspace memory access functions in the LinuxKPI.

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

7 years agoAdd teken_256to16() to convert xterm-256 256-color codes to xterm 16-color
Bruce Evans [Thu, 16 Mar 2017 16:40:54 +0000 (16:40 +0000)]
Add teken_256to16() to convert xterm-256 256-color codes to xterm 16-color
codes.  This will be used to fix bright colors.

Improve teken_256to8().  Use a lookup table instead of calculations.  The
calculations were inaccurate since they used indexes into the xterm-256
6x6x6 color map instead of actual xterm colors.  Also, change the threshold
for converting to a primary color: require the primary's component to be
2 or more higher instead of just higher.  This affects about 1/5 of the
table entries and gives uniformly distributed colors in the 6x6x6 submap
except for greys (35 entries each for red, green, blue, cyan, brown and
magenta, instead of approx. only 15 each for the mixed colors).  Even
more mixed colors would be better for matching colors, but uniform
distribution is best for preserving contrast.

For teken_256to16(), bright colors are just the ones with luminosity >=
60%.  These are actually light colors (more white instead of more
saturation), while xterm bright colors except for white itself are
actually saturated with no white, so have luminosity only 50%.

These functions are layering violations.  teken cannot do correct
conversions since it shouldn't know the color maps of anything except
xterm.  Translating through xterm-16 colors loses information.  This
gives bugs like xterm-256 near-brown -> xterm-16 red -> VGA red.

7 years agoMore trap_enotcap spelling fixes.
Maxim Konovalov [Thu, 16 Mar 2017 13:19:38 +0000 (13:19 +0000)]
More trap_enotcap spelling fixes.

PR: 217839
Submitted by: tobik

7 years agoDon't clear p_ptevents on normal SIGKILL delivery
Eric Badger [Thu, 16 Mar 2017 13:03:31 +0000 (13:03 +0000)]
Don't clear p_ptevents on normal SIGKILL delivery

The ptrace() user has the option of discarding the signal. In such a
case, p_ptevents should not be modified. If the ptrace() user decides to
send a SIGKILL, ptevents will be cleared in ptracestop(). procfs events
do not have the capability to discard the signal, so continue to clear
the mask in that case.

Reviewed by: jhb (initial revision)
MFC after: 1 week
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D9939

7 years agoUnbreak traceroute on system built without CAPSICUM
Michal Meloun [Thu, 16 Mar 2017 13:01:23 +0000 (13:01 +0000)]
Unbreak traceroute on system built without CAPSICUM

7 years agoDefine some more LinuxKPI task related macros.
Hans Petter Selasky [Thu, 16 Mar 2017 12:33:34 +0000 (12:33 +0000)]
Define some more LinuxKPI task related macros.

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

7 years agoSpell kern.trap_enotcap.
Maxim Konovalov [Thu, 16 Mar 2017 12:16:23 +0000 (12:16 +0000)]
Spell kern.trap_enotcap.

PR: 217836
Submitted by: tobik

7 years agoloader: remove open_disk cache
Toomas Soome [Thu, 16 Mar 2017 12:04:43 +0000 (12:04 +0000)]
loader: remove open_disk cache

As we provide the disk size verification and correction via disk_ioctl
and disk state provided by disk_open(), we can not share the partition
state in disk_devdesc structure. Also the sharing does make a lot of sense
with ufs, as only one partition is open at any given time, but zfs pools
do keep the disk devices open.

To make sure we do get the correct information about the open device,
just remove the cache.

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

7 years agoIndentation for the DragonFlyBSD trunk fixed, EoL whitespace removed.
Maxim Konovalov [Thu, 16 Mar 2017 10:30:40 +0000 (10:30 +0000)]
Indentation for the DragonFlyBSD trunk fixed, EoL whitespace removed.

7 years agoNetBSD 7.1 release added.
Maxim Konovalov [Thu, 16 Mar 2017 10:28:13 +0000 (10:28 +0000)]
NetBSD 7.1 release added.

7 years agoAdd helper function similar to ip_dev_find() to the LinuxKPI to lookup
Hans Petter Selasky [Thu, 16 Mar 2017 10:02:45 +0000 (10:02 +0000)]
Add helper function similar to ip_dev_find() to the LinuxKPI to lookup
a network device by its IPv6 address in the given VNET.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agoAdd basic support for VIMAGE to the LinuxKPI and ibcore.
Hans Petter Selasky [Thu, 16 Mar 2017 09:59:35 +0000 (09:59 +0000)]
Add basic support for VIMAGE to the LinuxKPI and ibcore.

Support is implemented by mapping Linux's "struct net" into FreeBSD's
"struct vnet". Currently only vnet0 is supported by ibcore.

MFC after: 1 week
Sponsored by: Mellanox Technologies

7 years agox86/srat: fix parsing of APIC IDs > MAX_APIC_ID
Roger Pau Monné [Thu, 16 Mar 2017 09:33:36 +0000 (09:33 +0000)]
x86/srat: fix parsing of APIC IDs > MAX_APIC_ID

Ignore them like it's done in the MADT parser. This allows booting on a box
with SRAT and APIC IDs > 255.

Reported by: Wei Liu <wei.liu2@citrix.com>
Tested by: Wei Liu <wei.liu2@citrix.com>
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: Citrix Systems R&D

7 years agoThe previous fix didn't ifdef out enough for sparc64 to actually work.
Bruce Evans [Thu, 16 Mar 2017 07:40:33 +0000 (07:40 +0000)]
The previous fix didn't ifdef out enough for sparc64 to actually work.

Fix this by using more dynamic initialization with simpler ifdefs for
the machine dependencies.  Find a frame buffer address in a more
portable way that at least compiles on sparc64.

7 years agoThe adj_free and max_free values of new_entry will be calculated and
Xin LI [Thu, 16 Mar 2017 05:44:16 +0000 (05:44 +0000)]
The adj_free and max_free values of new_entry will be calculated and
assigned by subsequent vm_map_entry_link(), therefore, remove the
pointless copying.

Submitted by: alc
MFC after: 3 days

7 years agocalloc() and realloc() modernization.
Cy Schubert [Thu, 16 Mar 2017 04:40:07 +0000 (04:40 +0000)]
calloc() and realloc() modernization.

This commit replaces calloc calls, which called calloc() as if it were
malloc() by allocating a multiple of objects as a sizeof multiplied by
the number of objects. The patch rectifies this by calling calloc() as
it was meant to be called.

This commit also replaces realloc() with reallocarray() in a similar
fashion as above. Instead of calculating the memory to reallocated
(changed) by multiplying sizeof by the number of objects, the sizeof
and number are passed as separate arguments to reallocarray(), letting
reallocarray() do the multiplication instead. Like the calloc()
adjustment above, this is approach is cleaner and more elegant than
than the previous code.

This has been tested on my production firewall and a laptop (also
running ipfilter).

Submitted by: pfg
MFC after: 6 weeks

7 years agoTweak r315363 slightly
Enji Cooper [Thu, 16 Mar 2017 03:24:15 +0000 (03:24 +0000)]
Tweak r315363 slightly

I noticed after commit that kvm_dpcpu_setcpu was defined in the manpage.
Thus, the correct macro for the function reference is .Fn, not .Xr.

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

7 years agoHide the AMD MONITORX/MWAITX capability.
Peter Grehan [Thu, 16 Mar 2017 03:21:42 +0000 (03:21 +0000)]
Hide the AMD MONITORX/MWAITX capability.
Otherwise, recent Linux guests will use these instructions, resulting
in #UD exceptions since bhyve doesn't implement MONITOR/MWAIT exits.

This fixes boot-time hangs in recent Linux guests on Ryzen CPUs
(and probably Bulldozer aka AMD FX as well).

Reviewed by: kib
MFC after: 1 week

7 years agoFix manlint errors
Enji Cooper [Thu, 16 Mar 2017 03:20:59 +0000 (03:20 +0000)]
Fix manlint errors

- Add missing comma after kvm_dpcpu_setcpu .Nm macro use (multiple
  .Nm entries should be separated by commas)
- Add missing section for kvm_dpcpu_setcpu Xr.

MFC after: 1 week
Reported by: make manlint
Sponsored by: Dell EMC Isilon

7 years agoCapitalize .Dt macro argument
Enji Cooper [Thu, 16 Mar 2017 03:18:06 +0000 (03:18 +0000)]
Capitalize .Dt macro argument

By convention, per mdoc(7), the document title should be all caps.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoAdd the AMD MONITORX/MWAITX feature definition introduced in
Peter Grehan [Thu, 16 Mar 2017 03:06:50 +0000 (03:06 +0000)]
Add the AMD MONITORX/MWAITX feature definition introduced in
Bulldozer/Ryzen CPUs.

Reviewed by: kib
MFC after: 1 week

7 years agoReturn NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files}
Enji Cooper [Thu, 16 Mar 2017 02:31:42 +0000 (02:31 +0000)]
Return NULL instead of 0 on failure in _kvm_open, kvm_open{,2,files}

This is being done for the following reasons:
- kvm_open(3), etc says they will return NULL.
- NULL by definition is (void*)0 per POSIX, but can be redefined,
  depending on the compiler, etc.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

7 years agoAdd cavium octeon 'bootoctlinux' boot argument support
Alexander Kabaev [Thu, 16 Mar 2017 00:49:59 +0000 (00:49 +0000)]
Add cavium octeon 'bootoctlinux' boot argument support

While there, parse u-boot provided command line arguments
for supported switches and update boothowto appropriately.
Also support setting kenv variables from the kernel comman
line.

PR: 216831 (modified)

7 years agoDisable LD_BIND_NOT for setugid processes.
Konstantin Belousov [Wed, 15 Mar 2017 23:47:19 +0000 (23:47 +0000)]
Disable LD_BIND_NOT for setugid processes.

Requested by: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

7 years agoAutomate the handling of QUAD_ALIGN and QUAD_SLOTS.
John Baldwin [Wed, 15 Mar 2017 23:08:11 +0000 (23:08 +0000)]
Automate the handling of QUAD_ALIGN and QUAD_SLOTS.

Previously, the offset in a system call description specified the
array index of the start of a system call argument.  For most system
call arguments this was the same as the index of the argument in the
function signature.  64-bit arguments (off_t and id_t values) passed
on 32-bit platforms use two slots in the array however.  This was
handled by adding (QUAD_SLOTS - 1) to the slot indicies of any
subsequent arguments after a 64-bit argument (though written as ("{
Quad, 1 }, { Int, 1 + QUAD_SLOTS }" rather than "{ Quad, 1 }, { Int, 2
+ QUAD_SLOTS - 1 }").  If a system call contained multiple 64-bit
arguments (such as posix_fadvise()), then additional arguments would
need to use 'QUAD_SLOTS * 2' but remember to subtract 2 from the
initial number, etc.  In addition, 32-bit powerpc requires 64-bit
arguments to be 64-bit aligned, so if the effective index in the array
of a 64-bit argument is odd, it needs QUAD_ALIGN added to the current
and any subsequent slots.  However, if the effective index in the
array of a 64-bit argument was even, QUAD_ALIGN was omitted.

This approach was messy and error prone.  This commit replaces it with
automated pre-processing of the system call table to do fixups for
64-bit argument offsets.  The offset in a system call description now
indicates the index of an argument in the associated function call's
signature.  A fixup function is run against each decoded system call
description during startup on 32-bit platforms.  The fixup function
maintains an 'offset' value which holds an offset to be added to each
remaining system call argument's index.  Initially offset is 0.  When
a 64-bit system call argument is encountered, the offset is first
aligned to a 64-bit boundary (only on powerpc) and then incremented to
account for the second argument slot used by the argument.  This
modified 'offset' is then applied to any remaining arguments.  This
approach does require a few things that were not previously required:

1) Each system call description must now list arguments in ascending
   order (existing ones all do) without using duplicate slots in the
   register array.  A new assert() should catch any future
   descriptions which violate this rule.

2) A system call description is still permitted to omit arguments
   (though none currently do), but if the call accepts 64-bit
   arguments those cannot be omitted or incorrect results will be
   displated on 32-bit systems.

Tested on: amd64 and i386

7 years agoRemove duplicate argument from linux_stat64() decoding.
John Baldwin [Wed, 15 Mar 2017 22:39:15 +0000 (22:39 +0000)]
Remove duplicate argument from linux_stat64() decoding.