freebsd.git
6 years agoTidy some whitespace.
jhb [Thu, 18 Jan 2018 00:23:11 +0000 (00:23 +0000)]
Tidy some whitespace.

6 years agoSave and restore guest debug registers.
jhb [Wed, 17 Jan 2018 23:11:25 +0000 (23:11 +0000)]
Save and restore guest debug registers.

Currently most of the debug registers are not saved and restored
during VM transitions allowing guest and host debug register values to
leak into the opposite context.  One result is that hardware
watchpoints do not work reliably within a guest under VT-x.

Due to differences in SVM and VT-x, slightly different approaches are
used.

For VT-x:

- Enable debug register save/restore for VM entry/exit in the VMCS for
  DR7 and MSR_DEBUGCTL.
- Explicitly save DR0-3,6 of the guest.
- Explicitly save DR0-3,6-7, MSR_DEBUGCTL, and the trap flag from
  %rflags for the host.  Note that because DR6 is "software" managed
  and not stored in the VMCS a kernel debugger which single steps
  through VM entry could corrupt the guest DR6 (since a single step
  trap taken after loading the guest DR6 could alter the DR6
  register).  To avoid this, explicitly disable single-stepping via
  the trace flag before loading the guest DR6.  A determined debugger
  could still defeat this by setting a breakpoint after the guest DR6
  was loaded and then single-stepping.

For SVM:
- Enable debug register caching in the VMCB for DR6/DR7.
- Explicitly save DR0-3 of the guest.
- Explicitly save DR0-3,6-7, and MSR_DEBUGCTL for the host.  Since SVM
  saves the guest DR6 in the VMCB, the race with single-stepping
  described for VT-x does not exist.

For both platforms, expose all of the guest DRx values via --get-drX
and --set-drX flags to bhyvectl.

Discussed with: avg, grehan
Tested by: avg (SVM), myself (VT-x)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D13229

6 years agoRequire the SHF_ALLOC flag for program sections from kernel object modules.
jhb [Wed, 17 Jan 2018 22:51:59 +0000 (22:51 +0000)]
Require the SHF_ALLOC flag for program sections from kernel object modules.

ELF object files can contain program sections which are not supposed
to be loaded into memory (e.g. .comment).  Normally the static linker
uses these flags to decide which sections are allocated to loadable
program segments in ELF binaries and shared objects (including kernels
on all architectures and kernel modules on architectures other than
amd64).

Mapping ELF object files (such as amd64 kernel modules) into memory
directly is a bit of a grey area.  ELF object files are intended to be
used as inputs to the static linker.  As a result, there is not a
standardized definition for what the memory layout of an ELF object
should be (none of the section headers have valid virtual memory
addresses for example).

The kernel and loader were not checking the SHF_ALLOC flag but loading
any program sections with certain types such as SHT_PROGBITS.  As a
result, the kernel and loader would load into RAM some sections that
weren't marked with SHF_ALLOC such as .comment that are not loaded
into RAM for kernel modules on other architectures (which are
implemented as ELF shared objects).  Aside from possibly requiring
slightly more RAM to hold a kernel module this does not affect runtime
correctness as the kernel relocates symbols based on the layout it
uses.

Debuggers such as gdb and lldb do not extract symbol tables from a
running process or kernel.  Instead, they replicate the memory layout
of ELF executables and shared objects and use that to construct their
own symbol tables.  For executables and shared objects this works
fine.  For ELF objects the current logic in kgdb (and probably lldb
based on a simple reading) assumes that only sections with SHF_ALLOC
are memory resident when constructing a memory layout.  If the
debugger constructs a different memory layout than the kernel, then it
will compute different addresses for symbols causing symbols in the
debugger to appear to have the wrong values (though the kernel itself
is working fine).  The current port of mdb does not check SHF_ALLOC as
it replicates the kernel's logic in its existing kernel support.

The bfd linker sorts the sections in ELF object files such that all of
the allocated sections (sections with SHF_ALLOCATED) are placed first
followed by unallocated sections.  As a result, when kgdb composed a
memory layout using only the allocated sections, this layout happened
to match the layout used by the kernel and loader.  The lld linker
does not sort the sections in ELF object files and mixed allocated and
unallocated sections.  This resulted in kgdb composing a different
memory layout than the kernel and loader.

We could either patch kgdb (and possibly in the future lldb) to use
custom handling when generating memory layouts for kernel modules that
are ELF objects, or we could change the kernel and loader to check
SHF_ALLOCATED.  I chose the latter as I feel we shouldn't be loading
things into RAM that the module won't use.  This should mostly be a
NOP when linking with bfd but will allow the existing kgdb to work
with amd64 kernel modules linked with lld.

Note that we only require SHF_ALLOC for "program" sections for types
like SHT_PROGBITS and SHT_NOBITS.  Other section types such as symbol
tables, string tables, and relocations must also be loaded and are not
marked with SHF_ALLOC.

Reported by: np
Reviewed by: kib, emaste
MFC after: 1 month
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D13926

6 years agoConvert ls(1) to not use libxo(3)
cem [Wed, 17 Jan 2018 22:47:34 +0000 (22:47 +0000)]
Convert ls(1) to not use libxo(3)

libxo imposes a large burden on system utilities. In the case of ls, that
burden is difficult to justify -- any language that can interact with json
output can use readdir(3) and stat(2).

Logically, this reverts r291607, r285857, r285803, r285734, r285425,
r284494, r284489, r284252, and r284198.

Kyua tests continue to pass (libxo integration was entirely untested).

Reported by: many
Reviewed by: imp
Discussed with: manu, bdrewery
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13959

6 years agoUse long for the last argument to VOP_PATHCONF rather than a register_t.
jhb [Wed, 17 Jan 2018 22:36:58 +0000 (22:36 +0000)]
Use long for the last argument to VOP_PATHCONF rather than a register_t.

pathconf(2) and fpathconf(2) both return a long.  The kern_[f]pathconf()
functions now accept a pointer to a long value rather than modifying
td_retval directly.  Instead, the system calls explicitly store the
returned long value in td_retval[0].

Requested by: bde
Reviewed by: kib
Sponsored by: Chelsio Communications

6 years agobwn(4): Enable, by default, the opt-in support for bhnd(4) introduced in
landonf [Wed, 17 Jan 2018 22:33:19 +0000 (22:33 +0000)]
bwn(4): Enable, by default, the opt-in support for bhnd(4) introduced in
r326454.

bwn(4)/bhnd(4) has been tested with most chipsets currently supported by
bwn(4), and this change should be transparent to existing bwn(4) users;
please report any regressions that you do encounter.

To revert to using siba_bwn(4) instead of bhnd(4), place the following
lines in loader.conf(5):

  hw.bwn_pci.preferred="0"

Once we're satisfied that the switch to bhnd(4) has seen sufficient broader
testing, bwn(4) will be migrated to use the native bhnd(9) interface
directly, and support for siba_bwn(4) will be dropped (see D13518).

Sponsored by: The FreeBSD Foundation

6 years agoAnnotate a couple of changes from r328083.
markj [Wed, 17 Jan 2018 21:52:12 +0000 (21:52 +0000)]
Annotate a couple of changes from r328083.

Reviewed by: kib
X-MFC with: r328083

6 years agokldxref: additional sytle(9) cleanup
emaste [Wed, 17 Jan 2018 20:43:30 +0000 (20:43 +0000)]
kldxref: additional sytle(9) cleanup

Reported by: kib (via comments in D13957)
Sponsored by: The FreeBSD Foundation

6 years agokldxref: improve style(9)
emaste [Wed, 17 Jan 2018 19:59:43 +0000 (19:59 +0000)]
kldxref: improve style(9)

Address style issues including some previously raised in D13923.

- Use designated initializers for structs
- Always use bracketed return style
- No initialization in declarations
- Align function prototype names
- Remove old commented code/unused includes

Submitted by: Mitchell Horne <mhorne063@gmail.com>
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13943

6 years agoufs: use mallocarray(9).
pfg [Wed, 17 Jan 2018 18:18:33 +0000 (18:18 +0000)]
ufs: use mallocarray(9).

Basic use of mallocarray to prevent overflows: static analyzers are also
likely to perform additional checks.

Since mallocarray expects unsigned parameters, unsign some
related variables to minimize sign conversions.

Reviewed by: mckusick

6 years agoCorrect fsck journal-recovery code to update a cylinder-group
mckusick [Wed, 17 Jan 2018 17:58:24 +0000 (17:58 +0000)]
Correct fsck journal-recovery code to update a cylinder-group
check-hash after making changes to the cylinder group. The problem
was that the journal-recovery code was calling the libufs bwrite()
function instead of the cgput() function. The cgput() function updates
the cylinder-group check-hash before writing the cylinder group.

This change required the additions of the cgget() and cgput() functions
to the libufs API to avoid a gratuitous bcopy of every cylinder group
to be read or written. These new functions have been added to the
libufs manual pages. This was the first opportunity that I have had
to use and document the use of the EDOOFUS error code.

Reviewed by: kib
Reported by: emaste and others

6 years agoRevert r327340, as the workaround for rep prefixes followed by .byte
dim [Wed, 17 Jan 2018 17:14:19 +0000 (17:14 +0000)]
Revert r327340, as the workaround for rep prefixes followed by .byte
directives is no longer needed after r328090.

6 years agoPull in r322623 from upstream llvm trunk (by Andrew V. Tischenko):
dim [Wed, 17 Jan 2018 17:11:55 +0000 (17:11 +0000)]
Pull in r322623 from upstream llvm trunk (by Andrew V. Tischenko):

  Allow usage of X86-prefixes as separate instrs.
  Differential Revision: https://reviews.llvm.org/D42102

This should fix parse errors when x86 prefixes (such as 'lock' and
'rep') are followed by various non-mnemonic tokens, e.g. comments, .byte
directives and labels.

PR: 224669,225054

6 years agoMove setting of CAM_SIM_QUEUED to before we actually submit it to the
imp [Wed, 17 Jan 2018 17:08:26 +0000 (17:08 +0000)]
Move setting of CAM_SIM_QUEUED to before we actually submit it to the
hardware. Setting it after is racy, and we can lose the race on a
heavily loaded system.

Reviewed by: scottl@, gallatin@
Sponsored by: Netflix

6 years agoOnly call flush in pipe mode.
fabient [Wed, 17 Jan 2018 16:55:35 +0000 (16:55 +0000)]
Only call flush in pipe mode.
It fixes a crash with a socket in top mode.

Ex:
# pmcstat -R 127.0.0.1:8080 -T -w1
then
# pmcstat -n1 -Sclock.prof -Slock.failed -O 127.0.0.1:8080

MFC after: 1 week
Sponsored by: Stormshield

6 years agoFix pmcstat exit from kernel introduced by r325275.
fabient [Wed, 17 Jan 2018 16:41:22 +0000 (16:41 +0000)]
Fix pmcstat exit from kernel introduced by r325275.
pmcstat request for close will generate a close event.
This event will be in turn received by pmcstat to close the file.

Reviewed by: kib
Tested by: pho
MFC after: 1 week
Sponsored by: Stormshield

6 years agoUpdate pciids to 2018.01.14
bapt [Wed, 17 Jan 2018 13:25:41 +0000 (13:25 +0000)]
Update pciids to 2018.01.14

MFC after: 3 days

6 years agoFix buildworld after r328075, by also renaming cgget to cglookup in
dim [Wed, 17 Jan 2018 13:19:37 +0000 (13:19 +0000)]
Fix buildworld after r328075, by also renaming cgget to cglookup in
fsdb.

Reported by: ohartmann@walstatt.org,david@catwhisker.org
Pointy hat to: mckusick

6 years agoPTI for amd64.
kib [Wed, 17 Jan 2018 11:44:21 +0000 (11:44 +0000)]
PTI for amd64.

The implementation of the Kernel Page Table Isolation (KPTI) for
amd64, first version. It provides a workaround for the 'meltdown'
vulnerability.  PTI is turned off by default for now, enable with the
loader tunable vm.pmap.pti=1.

The pmap page table is split into kernel-mode table and user-mode
table. Kernel-mode table is identical to the non-PTI table, while
usermode table is obtained from kernel table by leaving userspace
mappings intact, but only leaving the following parts of the kernel
mapped:

    kernel text (but not modules text)
    PCPU
    GDT/IDT/user LDT/task structures
    IST stacks for NMI and doublefault handlers.

Kernel switches to user page table before returning to usermode, and
restores full kernel page table on the entry. Initial kernel-mode
stack for PTI trampoline is allocated in PCPU, it is only 16
qwords.  Kernel entry trampoline switches page tables. then the
hardware trap frame is copied to the normal kstack, and execution
continues.

IST stacks are kept mapped and no trampoline is needed for
NMI/doublefault, but of course page table switch is performed.

On return to usermode, the trampoline is used again, iret frame is
copied to the trampoline stack, page tables are switched and iretq is
executed.  The case of iretq faulting due to the invalid usermode
context is tricky, since the frame for fault is appended to the
trampoline frame.  Besides copying the fault frame and original
(corrupted) frame to kstack, the fault frame must be patched to make
it look as if the fault occured on the kstack, see the comment in
doret_iret detection code in trap().

Currently kernel pages which are mapped during trampoline operation
are identical for all pmaps.  They are registered using
pmap_pti_add_kva().  Besides initial registrations done during boot,
LDT and non-common TSS segments are registered if user requested their
use.  In principle, they can be installed into kernel page table per
pmap with some work.  Similarly, PCPU can be hidden from userspace
mapping using trampoline PCPU page, but again I do not see much
benefits besides complexity.

PDPE pages for the kernel half of the user page tables are
pre-allocated during boot because we need to know pml4 entries which
are copied to the top-level paging structure page, in advance on a new
pmap creation.  I enforce this to avoid iterating over the all
existing pmaps if a new PDPE page is needed for PTI kernel mappings.
The iteration is a known problematic operation on i386.

The need to flush hidden kernel translations on the switch to user
mode make global tables (PG_G) meaningless and even harming, so PG_G
use is disabled for PTI case.  Our existing use of PCID is
incompatible with PTI and is automatically disabled if PTI is
enabled.  PCID can be forced on only for developer's benefit.

MCE is known to be broken, it requires IST stack to operate completely
correctly even for non-PTI case, and absolutely needs dedicated IST
stack because MCE delivery while trampoline did not switched from PTI
stack is fatal.  The fix is pending.

Reviewed by: markj (partially)
Tested by: pho (previous version)
Discussed with: jeff, jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

6 years agoAmd64 user_ldt_deref() is not used outside sys_machdep.c. Mark it as
kib [Wed, 17 Jan 2018 11:21:03 +0000 (11:21 +0000)]
Amd64 user_ldt_deref() is not used outside sys_machdep.c.  Mark it as
static.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoAdd missing assignment to make sure non-first cmsgs are handled as such.
tuexen [Wed, 17 Jan 2018 10:30:49 +0000 (10:30 +0000)]
Add missing assignment to make sure non-first cmsgs are handled as such.

6 years agoPPC64: implement missing busdma ops
wma [Wed, 17 Jan 2018 09:45:18 +0000 (09:45 +0000)]
PPC64: implement missing busdma ops

Add missing little-endian 64-bit read and write. Since there
is no direct ASM opcode for this, perform byte swap if
necessary.

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

6 years agoPPC64: fix copyinout ranges
wma [Wed, 17 Jan 2018 09:36:48 +0000 (09:36 +0000)]
PPC64: fix copyinout ranges

Use current userspace address for segment mapping. Previously,
there was a bug which made the funciton constantly using the userspace
base address which could cause data integrity issues.

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

6 years agoPPC64: add CXGBE and remove AHCI from GENERIC64
wma [Wed, 17 Jan 2018 09:33:16 +0000 (09:33 +0000)]
PPC64: add CXGBE and remove AHCI from GENERIC64

Add CXGBE driver which is required for PowerNV system.
Also, remove AHCI which does not work in BigEndian.

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

6 years agoPowerNV: workaround console on OPAL 5.4
wma [Wed, 17 Jan 2018 08:01:51 +0000 (08:01 +0000)]
PowerNV: workaround console on OPAL 5.4

FreeBSD prints text char-by-char, which is not what OPAL
is designed to. Poll events more frequently to avoid buffer
overflow and loosing data.

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

6 years agoPowerNV: make PowerNV PCIe working on a real hardware
wma [Wed, 17 Jan 2018 07:39:11 +0000 (07:39 +0000)]
PowerNV: make PowerNV PCIe working on a real hardware

Fixes:
- map all devices to PE0
- use 1:1 TCE mapping
- provide the same TCE mapping for all PEs (not only PE0)
- add TCE reset and alignment (required by OPAL)

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

6 years agoRename cgget => cglookup to clear name space for new libufs function cgget.
mckusick [Wed, 17 Jan 2018 06:31:21 +0000 (06:31 +0000)]
Rename cgget => cglookup to clear name space for new libufs function cgget.
No functional change.

6 years agobhndb_pci(4): fix incorrect BHND_PCI_SRSH_PI workaround
landonf [Wed, 17 Jan 2018 03:34:26 +0000 (03:34 +0000)]
bhndb_pci(4): fix incorrect BHND_PCI_SRSH_PI workaround

On a SPROM-less device, the PCI(e) bridge core will be initialized with its
power-on-reset defaults; this can leave the SPROM-derived BHND_PCI_SRSH_PI
value pointing to the wrong backplane address. This value is used by the
PCI core when performing address translation between the static register
windows in BAR0 that map the PCI core's register block, and backplane
address space.

Previously, bhndb_pci(4) incorrectly used the potentially invalid static
BAR0 PCI register windows when attempting to correct the BHND_PCI_SRSH_PI
value in the PCI core's SPROM shadow.

Instead, we now read/update BHND_PCI_SRSH_PI by fetching the PCI core's
backplane address from the core enumeration table, and then using a dynamic
register window to explicitly map the PCI core's register block into BAR0.

Sponsored by: The FreeBSD Foundation

6 years agoSPDX: finish tagging sys/cam.
pfg [Tue, 16 Jan 2018 23:19:57 +0000 (23:19 +0000)]
SPDX: finish tagging sys/cam.

6 years agoRemove redundant critical_enter/exit() calls. The block of code delimited
ian [Tue, 16 Jan 2018 23:18:52 +0000 (23:18 +0000)]
Remove redundant critical_enter/exit() calls.  The block of code delimited
by these calls is now protected by a spin mutex (obscured within the
RTC_LOCK/RTC_UNLOCK macros).

Reported by: bde@

6 years agoMove some code around and rename a couple variables; no functional changes.
ian [Tue, 16 Jan 2018 23:14:12 +0000 (23:14 +0000)]
Move some code around and rename a couple variables; no functional changes.

The static atrtc_set() function was called only from clock_settime(), so
just move its contents entirely into clock_settime() and delete atrtc_set().

Rename the struct bcd_clocktime variables from 'ct' to 'bct'.  I had
originally wanted to emphasize how identical the clocktime and bcd_clocktime
structs were, but things evolved to the point where the structs are not at
all identical anymore, so now emphasizing the difference seems better.

6 years agoscsi_ch.c: Small cleanups to the comments.
pfg [Tue, 16 Jan 2018 23:08:25 +0000 (23:08 +0000)]
scsi_ch.c: Small cleanups to the comments.

Move the the NetBSD tag near to the related licence. Update it to reflect
better the point where we started diverging.

Use grouping parenthesis for the SPDX tag.

No functional change.

6 years agoFix a bug related to fast retransmissions.
tuexen [Tue, 16 Jan 2018 21:58:38 +0000 (21:58 +0000)]
Fix a bug related to fast retransmissions.

When processing a SACK advancing the cumtsn-ack in fast recovery,
increment the miss-indications for all TSN's reported as missing.

Thanks to Fabian Ising for finding the bug and to Timo Voelker
for provinding a fix.

This fix moves also CMT related initialisation of some variables
to a more appropriate place.

MFC after: 1 week

6 years agoUse ln -n instead of -h to allow building the kernel on Linux
arichardson [Tue, 16 Jan 2018 21:43:57 +0000 (21:43 +0000)]
Use ln -n instead of -h to allow building the kernel on Linux

Both flags do the same thing but -n is more widely supported.

Reviewed By: jhb, emaste
Approved By: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D13936

6 years agoAllow xinstall and makefs to be crossbuilt on Linux and Mac
arichardson [Tue, 16 Jan 2018 21:43:46 +0000 (21:43 +0000)]
Allow xinstall and makefs to be crossbuilt on Linux and Mac

I need these tools in order to install the crossbuilt FreeBSD and create a
disk image. Linux does not have a st_flags in struct stat so unfortunately
I need a bunch of ugly ifdefs. The resulting binaries allow me to
sucessfully install a MIPS64 world and create a disk-image that boots.

Reviewed By: brooks, bdrewery, emaste
Approved By: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D13307

6 years agoDon't build share/syscons in build-tools stage if MK_SYSCONS == "no"
arichardson [Tue, 16 Jan 2018 21:43:36 +0000 (21:43 +0000)]
Don't build share/syscons in build-tools stage if MK_SYSCONS == "no"

Reviewed By: emaste, jhb
Approved By: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D12926

6 years agolibnetbsd: Make the function declaration of efopen() match the definition
arichardson [Tue, 16 Jan 2018 21:43:21 +0000 (21:43 +0000)]
libnetbsd: Make the function declaration of efopen() match the definition

In order to crossbuild FreeBSD on Mac/Linux I also need to build libnetbsd
and FILE* is not equal to struct __sFILE on those platforms.

Reviewed By: brooks, emaste
Approved By: jhb (mentor)
Differential Revision: https://reviews.freebsd.org/D13305

6 years agoutf8_to_ucs2() should check for malloc failure
tsoome [Tue, 16 Jan 2018 20:35:54 +0000 (20:35 +0000)]
utf8_to_ucs2() should check for malloc failure

utf8_to_ucs2() is calling malloc() without checking the result.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D13933

6 years agoservice(8): Reset OPTIND properly now that we're parsing args twice
kevans [Tue, 16 Jan 2018 20:14:31 +0000 (20:14 +0000)]
service(8): Reset OPTIND properly now that we're parsing args twice

r328032 introduced a second round of argument parsing to proxy the request
through to a jail as needed, but failed to reset OPTIND before getting to
the second round of parsing to allow other flags to be set.

Reported by: Oleg Ginzburg <olevole olevole ru>

6 years agoImprove the printing of cmgs when the length is 0. Fix error handling.
tuexen [Tue, 16 Jan 2018 20:02:07 +0000 (20:02 +0000)]
Improve the printing of cmgs when the length is 0. Fix error handling.

6 years agoUsing %p already prints "0x", so don't do it explicitly.
tuexen [Tue, 16 Jan 2018 19:57:30 +0000 (19:57 +0000)]
Using %p already prints "0x", so don't do it explicitly.

6 years agoSplit crp_buf into a union.
jhb [Tue, 16 Jan 2018 19:41:18 +0000 (19:41 +0000)]
Split crp_buf into a union.

This adds explicit crp_mbuf and crp_uio pointers of the right type to
replace casts of crp_buf.  This does not sweep through changing existing
code, but new code should use the correct fields instead of casts.

Reviewed by: kib
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D13927

6 years agoext2fs: use mallocarray(9).
pfg [Tue, 16 Jan 2018 19:29:32 +0000 (19:29 +0000)]
ext2fs: use mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). These
are not likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

6 years agoImport tzdata 2018a
philip [Tue, 16 Jan 2018 18:36:25 +0000 (18:36 +0000)]
Import tzdata 2018a

Changes: https://github.com/eggert/tz/blob/2018a/NEWS

MFC after: 3 days

6 years agokldxref: handle modules with md_cval at the end of allocated sections
emaste [Tue, 16 Jan 2018 18:20:12 +0000 (18:20 +0000)]
kldxref: handle modules with md_cval at the end of allocated sections

Attempting to retrieve an md_cval string from a kernel module with
kldxref would throw a offset error for modules created using lld, since
this value would be placed at the end of all allocated sections.

Add an ef_read_seg_string method to the ef interface, to allow reading
strings of varying size without attempting to read beyond the segment's
bounds.

PR: 224875
Submitted by: Mitchell Horne <mhorne063@gmail.com>
Reviewed by: cem, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13923

6 years agoFix bug: increment the value of pmcstat_npmcs instead of moving pointer
br [Tue, 16 Jan 2018 09:31:01 +0000 (09:31 +0000)]
Fix bug: increment the value of pmcstat_npmcs instead of moving pointer
to the next int position.

Bug was introduced in r324959 ("Extract a set of pmcstat functions and
interfaces to the new internal library -- libpmcstat.")

This fixes pmcstat top mode (-T) operation.
Example: pmcstat -n1 -S clock.hard -T

Reported by: Peter Holm <peter@holm.cc>
Sponsored by: DARPA, AFRL

6 years agoPowerNV: XICS support for PowerNV/OPAL
wma [Tue, 16 Jan 2018 06:24:19 +0000 (06:24 +0000)]
PowerNV: XICS support for PowerNV/OPAL

Make XICS to be OPAL-aware.

Created by:            Nathan Whitehorn <nwhitehorn@freebsd.org>
Submitted by:          Wojciech Macek <wma@semihalf.com>
Sponsored by:          FreeBSD Foundation

6 years agoFix build after r328020.
pfg [Tue, 16 Jan 2018 06:04:39 +0000 (06:04 +0000)]
Fix build after r328020.

Should have noticed earlier but the build was already broken by another
change.

Reported by: Ravi Pokala

6 years agoMake fsl_sata driver work on P1022
jhibbits [Tue, 16 Jan 2018 04:50:23 +0000 (04:50 +0000)]
Make fsl_sata driver work on P1022

P1022 SATA controller may set the wrong CCR bit for a command completion.
This would previously cause an interrupt storm.  Solve this by marking all
commands complete, and letting the end_transaction deal with the successes.
Causes no problems on P5020.

While here, fix a minor bug in collision detection.  The Freescale SATA
controller only has 16 slots, not 32.

6 years agoAdd static inline rtcin_locked() and rtcout_locked() functions for doing a
ian [Tue, 16 Jan 2018 03:02:41 +0000 (03:02 +0000)]
Add static inline rtcin_locked() and rtcout_locked() functions for doing a
related series of operations without doing a lock/unlock for each byte.
Use them when reading and writing the entire set of time registers.

The original rtcin() and writertc() functions which do lock/unlock on each
byte still exist, because they are public and called by outside code.

6 years agorandom(4): Add CCP random source definitions
cem [Tue, 16 Jan 2018 02:56:27 +0000 (02:56 +0000)]
random(4): Add CCP random source definitions

The implementation will follow (D12723).  For now, get the changes to
commit-protected files out of the way.

Approved by: secteam (gordon)
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13925

6 years agoRename 'recv' to 'receive' to appease shadow warnings from GCC.
jhb [Tue, 16 Jan 2018 01:21:07 +0000 (01:21 +0000)]
Rename 'recv' to 'receive' to appease shadow warnings from GCC.

6 years agoCheck for GCC first rather than clang in the MIPS lib32 rules.
jhb [Tue, 16 Jan 2018 01:05:04 +0000 (01:05 +0000)]
Check for GCC first rather than clang in the MIPS lib32 rules.

This works around a bug with X_COMPILER_TYPE and permits mips64 to build
again with in-tree gcc as well as clang and external gcc.

Sponsored by: DARPA / AFRL

6 years agoSort the list of flags in newsyslog.conf entries.
jhb [Tue, 16 Jan 2018 00:47:53 +0000 (00:47 +0000)]
Sort the list of flags in newsyslog.conf entries.

Move the 'X' and 'Y' entries into their sorted location in the list
of flags just above 'Z'.

Reviewed by: bcr
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D13904

6 years agoKeep list sorted. Thanks to jhb@ to pointing out that I put it at the
tuexen [Mon, 15 Jan 2018 23:17:12 +0000 (23:17 +0000)]
Keep list sorted. Thanks to jhb@ to pointing out that I put it at the
wrong place in r327919.

6 years agoBump date, which I missed in r328014. Thanks to jhb@ for reporting.
tuexen [Mon, 15 Jan 2018 23:12:54 +0000 (23:12 +0000)]
Bump date, which I missed in r328014. Thanks to jhb@ for reporting.

6 years agoservice(8): Add support for interfacing with services in jails
kevans [Mon, 15 Jan 2018 22:24:11 +0000 (22:24 +0000)]
service(8): Add support for interfacing with services in jails

Provide a -j option that can take a jail name or id. If -j is specified,
check that the jail exists and proxy the service request through to
service(8) in the jail.

This allows for cleaner workflows when updating services in a jail, turning
the following:

pkg -j dns upgrade
jexec dns service named restart

into:

pkg -j dns upgrade
service -j dns named restart

PR: 223325
Submitted by: David O'Rourke (with slight changes)
MFC after: 2 weeks

6 years agoNeed to free uv after we're done using it.
imp [Mon, 15 Jan 2018 22:17:39 +0000 (22:17 +0000)]
Need to free uv after we're done using it.

Reported by: andrew@
Sponsored by: Netflix

6 years agoCheck the return value from utf8_to_ucs2 instead of whether or not uv
imp [Mon, 15 Jan 2018 22:17:34 +0000 (22:17 +0000)]
Check the return value from utf8_to_ucs2 instead of whether or not uv
is NULL. That's more correct and doesn't depend on the error behavior
of utf8_to_ucs2. In practice, we'll never see this though since we
pass utf8_to_ucs2 a well formed string.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13918

6 years agoWhen returning an error and freeing allocated memory from ucs2_to_utf8
imp [Mon, 15 Jan 2018 22:17:15 +0000 (22:17 +0000)]
When returning an error and freeing allocated memory from ucs2_to_utf8
and utf8_to_ucs2, be sure to NULL out the return pointer too, rather
than return a pointer to free memory.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13917

6 years agoDon't provide a (meaningless) cmsg when proving a notification
tuexen [Mon, 15 Jan 2018 21:59:20 +0000 (21:59 +0000)]
Don't provide a (meaningless) cmsg when proving a notification
in a recvmsg() call.

MFC after: 1 week

6 years agowsp(4): Update to reflect new sysctl from r314467
kevans [Mon, 15 Jan 2018 21:53:33 +0000 (21:53 +0000)]
wsp(4): Update to reflect new sysctl from r314467

r314467 introduced hw.usb.wsp.enable_single_tap_clicks to enable/disable
single-tap left click behavior. Update the man page to reflect the new
sysctl.

PR: 196624
MFC after: 3 days
X-MFC-With: r314467

6 years agomisc geom and gnu: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:23:16 +0000 (21:23 +0000)]
misc geom and gnu: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

Differential revision: https://reviews.freebsd.org/D13837

6 years agonet*: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:21:51 +0000 (21:21 +0000)]
net*: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agonetgraph: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:19:21 +0000 (21:19 +0000)]
netgraph: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agokern: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:18:04 +0000 (21:18 +0000)]
kern: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agocam: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:15:25 +0000 (21:15 +0000)]
cam: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agonfsclient: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:14:56 +0000 (21:14 +0000)]
nfsclient: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agomips: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:13:30 +0000 (21:13 +0000)]
mips: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agondis: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:11:38 +0000 (21:11 +0000)]
ndis: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agopowerpc: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:10:40 +0000 (21:10 +0000)]
powerpc: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agoarm: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:09:58 +0000 (21:09 +0000)]
arm: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agox86: make some use of mallocarray(9).
pfg [Mon, 15 Jan 2018 21:08:22 +0000 (21:08 +0000)]
x86: make some use of mallocarray(9).

Focus on code where we are doing multiplications within malloc(9). None of
these ire likely to overflow, however the change is still useful as some
static checkers can benefit from the allocation attributes we use for
mallocarray.

This initial sweep only covers malloc(9) calls with M_NOWAIT. No good
reason but I started doing the changes before r327796 and at that time it
was convenient to make sure the sorrounding code could handle NULL values.

X-Differential revision: https://reviews.freebsd.org/D13837

6 years agoDecode msghdr argument of sendmsg() and recvmsg().
tuexen [Mon, 15 Jan 2018 20:39:42 +0000 (20:39 +0000)]
Decode msghdr argument of sendmsg() and recvmsg().

Sponsored by: Netflix, Inc.

6 years agoAdd support for decoding the nxt_flags, rcv_flags, and snd_flags of
tuexen [Mon, 15 Jan 2018 20:37:11 +0000 (20:37 +0000)]
Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.

6 years agoExit fsck_ffs with non-zero status when file system is not repaired.
dab [Mon, 15 Jan 2018 19:25:11 +0000 (19:25 +0000)]
Exit fsck_ffs with non-zero status when file system is not repaired.

When the fsck_ffs program cannot fully repair a file system, it will
output the message PLEASE RERUN FSCK. However, it does not exit with a
non-zero status in this case (contradicting the man page claim that it
"exits with 0 on success, and >0 if an error occurs."  The fsck
rc-script (when running "fsck -y") tests the status from fsck (which
passes along the exit status from fsck_ffs) and issues a "stop_boot"
if the status fails. However, this is not effective since fsck_ffs can
return zero even on (some) errors. Effectively, it is left to a later
step in the boot process when the file systems are mounted to detect
the still-unclean file system and stop the boot.

This change modifies fsck_ffs so that when it cannot fully repair the
file system and issues the PLEASE RERUN FSCK message it also exits
with a non-zero status.

While here, the fsck_ffs man page has also been updated to document
the failing exit status codes used by fsck_ffs. Previously, only exit
status 7 was documented. Some of these exit statuses are tested for in
the fsck rc-script, so they are clearly depended upon and deserve
documentation.

Reviewed by: mckusick, vangyzen, jilles (manpages)
MFC after: 1 week
Sponsored by: Dell EMC
Differential Revision: https://reviews.freebsd.org/D13862

6 years agoProvide some mitigation against CVE-2017-5715 by clearing registers
tychon [Mon, 15 Jan 2018 18:37:03 +0000 (18:37 +0000)]
Provide some mitigation against CVE-2017-5715 by clearing registers
upon returning from the guest which aren't immediately clobbered by
the host.  This eradicates any remaining guest contents limiting their
usefulness in an exploit gadget.

This was inspired by this linux commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5b6c02f38315b720c593c6079364855d276886aa

Reviewed by: grehan, rgrimes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D13573

6 years agoPull in r322473 from upstream llvm trunk (by Andrei Elovikov):
dim [Mon, 15 Jan 2018 18:20:15 +0000 (18:20 +0000)]
Pull in r322473 from upstream llvm trunk (by Andrei Elovikov):

  [LV] Don't call recordVectorLoopValueForInductionCast for
  newly-created IV from a trunc.

  Summary:
  This method is supposed to be called for IVs that have casts in their
  use-def chains that are completely ignored after vectorization under
  PSE. However, for truncates of such IVs the same InductionDescriptor
  is used during creation/widening of both original IV based on PHINode
  and new IV based on TruncInst.

  This leads to unintended second call to
  recordVectorLoopValueForInductionCast with a VectorLoopVal set to the
  newly created IV for a trunc and causes an assert due to attempt to
  store new information for already existing entry in the map. This is
  wrong and should not be done.

  Fixes PR35773.

  Reviewers: dorit, Ayal, mssimpso

  Reviewed By: dorit

  Subscribers: RKSimon, dim, dcaballe, hsaito, llvm-commits, hiraditya

  Differential Revision: https://reviews.llvm.org/D41913

This should fix "Vector value already set for part" assertions when
building the net/iodine and sysutils/daa2iso ports.

Reported by: jbeich
PR: 224867,224868

6 years agostand/fdt: Don't leak next_fdtp if we fail to open overlay
kevans [Mon, 15 Jan 2018 18:08:01 +0000 (18:08 +0000)]
stand/fdt: Don't leak next_fdtp if we fail to open overlay

MFC after: 1 week
X-MFC-With: r327991

6 years agounits(1): units(1) free savescr in error condition too
eadler [Mon, 15 Jan 2018 17:27:43 +0000 (17:27 +0000)]
units(1): units(1) free savescr in error condition too

CID: 978392
Reviewed by: des
MFC After: 1 week

6 years agoFix booting on some arm64 systems after r327879 by fixing the call to
andrew [Mon, 15 Jan 2018 16:58:07 +0000 (16:58 +0000)]
Fix booting on some arm64 systems after r327879 by fixing the call to
utf8_to_ucs2 in boot1.efi. We need to initialise the ucs2 output string
so it will allocate space, and use the return value to determine if the
call was successful.

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

6 years agoConvert the x86 RTC driver to use new validated BCD<->timespec conversions.
ian [Mon, 15 Jan 2018 16:40:43 +0000 (16:40 +0000)]
Convert the x86 RTC driver to use new validated BCD<->timespec conversions.

New common routines were added to kern/subr_clock.c for converting between
calendrical time expressed in BCD and struct timespec. The new functions
return EINVAL on error, as expected when the clock hardware does not provide
valid time.

PR: 224813
Differential Revision: https://reviews.freebsd.org/D13731 (no reviewers)

6 years agoInstall the SLB miss trap-handling code in the SLB-based MMU driver set up,
nwhitehorn [Mon, 15 Jan 2018 16:08:34 +0000 (16:08 +0000)]
Install the SLB miss trap-handling code in the SLB-based MMU driver set up,
to which it is specific, rather than in the generic AIM startup code. This
will be required to support the radix-table-based MMU introduced with POWER9.

6 years agogeom_disk / scsi_da: deny opening write-protected disks for writing
avg [Mon, 15 Jan 2018 11:20:00 +0000 (11:20 +0000)]
geom_disk / scsi_da: deny opening write-protected disks for writing

Ths change consists of two parts.

geom_disk: deny opening a disk for writing if it's marked as
write-protected.  A new disk(9) flag is added to mark write protected
disks.  A possible alternative could be to add another parameter to d_open,
so that the open mode could be passed to it and the disk drivers could
make the decision internally, but the flag required less churn.

scsi_da: add a new phase of disk probing to query the all pages mode
sense page.  We can determine if the disk is write protected using bit 7
of the device specific field in the mode parameter header returned by
MODE SENSE.

PR: 224037
Reviewed by: mav
MFC after: 4 weeks
Differential Revision: https://reviews.freebsd.org/D13360

6 years agoAdd support for decoding the type of a cmsg.
tuexen [Mon, 15 Jan 2018 10:59:04 +0000 (10:59 +0000)]
Add support for decoding the type of a cmsg.

6 years agoSimplify table generation.
tuexen [Mon, 15 Jan 2018 08:32:49 +0000 (08:32 +0000)]
Simplify table generation.

6 years agoMove the pmap-specific code in copyinout.c that gets pointers to userland
nwhitehorn [Mon, 15 Jan 2018 06:46:33 +0000 (06:46 +0000)]
Move the pmap-specific code in copyinout.c that gets pointers to userland
buffers into a new pmap-module function pmap_map_user_ptr() that can
be implemented by the respective modules. This is required to implement
non-segment-based AIM-ish MMU systems such as the radix-tree page tables
introduced by POWER ISA 3.0 and present on POWER9.

Reviewed by: jhibbits

6 years agostand/fdt: don't send clobbered FDT to the kernel
kevans [Mon, 15 Jan 2018 05:00:26 +0000 (05:00 +0000)]
stand/fdt: don't send clobbered FDT to the kernel

If fdt_overlay_apply fails at some stage to apply the overlay to the base,
both the base and overlay may be in an inconsistent state (some fixups
applied, some phandles adjusted, some symbols merged). These can be bad for
a number of reasons, to include user frustration if some fixups applied and
not others. Fail a little safer by making a clean copy of the base FDT for
every overlay that we can simply discard if things go awry.

This also allows us the luxury of simply discarding overlays if we hit some
kind of memory limit or if they're malformed and extremely large for some
reason. We'll now leave a nice error message indicating that some overlays
could not be applied due to size restrictions and we apply what we can.

I note that our overlay implementation has some flaws that might still leave
your system in an unbootable state even if an overlay applies correctly;
please exercise caution in using overlays until we can swap it out for
libfdt's implementation.

Tested on: BananaPi-M3 (armv7)
Tested on: Pine64 (aarch64)
Differential Revision: https://reviews.freebsd.org/D13709

6 years agoThe vmm(4) man page is conditional on MK_BHYVE.
grehan [Mon, 15 Jan 2018 04:52:12 +0000 (04:52 +0000)]
The vmm(4) man page is conditional on MK_BHYVE.

Submitted by: kevlo

6 years agoallwinner: mmc: Multiple improvement
manu [Sun, 14 Jan 2018 22:05:29 +0000 (22:05 +0000)]
allwinner: mmc: Multiple improvement

  - Add a per compatible configuration struct
  - Not all SoC uses the same size for DMA transfert, add this into the
    configuration data
  - Use new timing mode for some SoC (A64 mmc)
  - Auto calibrate clock for A64 mmc/emmc
  - A64 mmc controller need masking of data0
  - Add support for vmmc/vqmmc regulator
  - Add more capabilities, r/w speed is better for eMMC
  - MMC_CAP_SIGNALING_180 gives weird result so do not enable it for now.
  - Add new register documented in H3/A64 user manual

Tested-On: Pine64-LTS (A64), eMMC still doesn't work
Tested-On: A64-Olinuxino (A64), sd and eMMC are working
Tested-On: NanoPi Neo Plus2 (H5), sd and eMMC are working
Tested-On: OrangePi PC2 (H5), sd only (no eMMC)
Tested-On: OrangePi One (H3), sd only (no eMMC)
Tested-On: BananaPi M2 (A31s), sd only (no eMMC)

6 years agoAdd metadata_csum feature support.
fsu [Sun, 14 Jan 2018 20:46:39 +0000 (20:46 +0000)]
Add metadata_csum feature support.

Reviewed by:   pfg (mentor)
Approved by:   pfg (mentor)
MFC after:     6 months

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

6 years agoAdd a rudimentary PWM driver for the RaspberryPi.
phk [Sun, 14 Jan 2018 20:36:21 +0000 (20:36 +0000)]
Add a rudimentary PWM driver for the RaspberryPi.

Control is through sysctl, only GPIO12 supported.

bootverbose creates sysctls for direct mangling of relevant registers.

Only tested on RPI2

6 years agovmm(4): add to Makefile
eadler [Sun, 14 Jan 2018 20:30:58 +0000 (20:30 +0000)]
vmm(4): add to Makefile

r326281 added the vmm man page, but it needs to be installed.

PR: 205705

6 years agoRemove tst.zonename.d from the list of expected failures.
markj [Sun, 14 Jan 2018 17:56:19 +0000 (17:56 +0000)]
Remove tst.zonename.d from the list of expected failures.

X-MFC with: r327888

6 years agoUse the thread's ucred struct when fetching jid or jailname.
markj [Sun, 14 Jan 2018 17:55:40 +0000 (17:55 +0000)]
Use the thread's ucred struct when fetching jid or jailname.

Reported by: mjg
X-MFC with: r327888

6 years agoAdd RTC clock conversions for BCD values, with non-panic validation.
ian [Sun, 14 Jan 2018 17:01:37 +0000 (17:01 +0000)]
Add RTC clock conversions for BCD values, with non-panic validation.

RTC clock hardware frequently uses BCD numbers.  Currently the low-level
bcd2bin() and bin2bcd() functions will KASSERT if given out-of-range BCD
values.  Every RTC driver must implement its own code for validating the
unreliable data coming from the hardware to avoid a potential kernel panic.

This change introduces two new functions, clock_bcd_to_ts() and
clock_ts_to_bcd().  The former validates its inputs and returns EINVAL if any
values are out of range. The latter guarantees the returned data will be
valid BCD in a known format (4-digit years, etc).

A new bcd_clocktime structure is used with the new functions.  It is similar
to the original clocktime structure, but defines the fields holding BCD
values as uint8_t (uint16_t for year), and adds a PM flag for handling hours
using AM/PM mode.

PR: 224813
Differential Revision: https://reviews.freebsd.org/D13730 (no reviewers)

6 years agoReport CG checksum mismatches. These errors are non-fatal. The
imp [Sun, 14 Jan 2018 16:55:14 +0000 (16:55 +0000)]
Report CG checksum mismatches. These errors are non-fatal. The
previous behavior is preserved (the CG checksum is fixed). We're just
noisy about it now.

Reviewed by: kirk@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13884

6 years agoEnable VIMAGE in i386 GENERIC (revert r327840)
emaste [Sun, 14 Jan 2018 16:04:51 +0000 (16:04 +0000)]
Enable VIMAGE in i386 GENERIC (revert r327840)

We've switched back to ld.bfd on i386 for now.

PR: 225077
Sponsored by: The FreeBSD Foundation

6 years agoRemove trailing whitespace.
bz [Sun, 14 Jan 2018 15:01:25 +0000 (15:01 +0000)]
Remove trailing whitespace.
No functional change.

6 years agoImprove support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
tuexen [Sun, 14 Jan 2018 14:33:22 +0000 (14:33 +0000)]
Improve support for sctp_generic_recvmsg() and sctp_generic_sendmsg()
and add support for sctp_generic_sendmsg_iov().

Handle the struct iovec argument and the struct sctp_sndrcvinfo
arguments.