]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agoRemove vestiges of digi(4) driver, first attempted in r305235 with
Warner Losh [Wed, 10 Jan 2018 14:58:58 +0000 (14:58 +0000)]
Remove vestiges of digi(4) driver, first attempted in r305235 with
more in r317426. There's nothing in the tree that references digiio.h
(apart from digictl(8)), so no driver implements it. Since digictl(8)
was only used to control digi(4) devices, it too should go.

6 years agoFinally, fix Zstd kernel build on MIPS and RISC-V
Conrad Meyer [Wed, 10 Jan 2018 06:30:59 +0000 (06:30 +0000)]
Finally, fix Zstd kernel build on MIPS and RISC-V

Add an implementation of the intrinsics invoked by __builtin_ctz{,ll} and
__builtin_clz{,ll}, and include this compilation unit on platforms that lack
assembly intrinsics for those builtins (MIPS and RISC-V).

Future cleanup work might involve bringing these into a mini libcompiler-rt
for the standalone kernel environment.  Or cleaning up the approach upstream
takes for builtins in standalone environments (or just FreeBSD).  For now,
at least this builds, and doesn't require modifying the vendor code.

Reported by: jeff, markj, mizhka
Reviewed by: jhb (earlier version), rpokala (comment text earlier version)
Sponsored by: Dell EMC Isilon

6 years agoRefactor code related to 'camcontrol devlist'
Scott Long [Wed, 10 Jan 2018 05:52:24 +0000 (05:52 +0000)]
Refactor code related to 'camcontrol devlist'

Obtained from: Netflix

6 years agoImplement the ability to query NVME for its controller data so that it will
Scott Long [Wed, 10 Jan 2018 05:29:02 +0000 (05:29 +0000)]
Implement the ability to query NVME for its controller data so that it will
be shown when issueing the 'camcontrol devlist' command.

Obtained from: Netflix

6 years agoAvoid referencing a possibly freed consumer after r327496.
Mark Johnston [Wed, 10 Jan 2018 05:06:21 +0000 (05:06 +0000)]
Avoid referencing a possibly freed consumer after r327496.

g_mirror_regular_request() may free the gmirror consumer for a disk
if that disk is being disconnected, after which we must not dereference
the consumer pointer.

CID: 1384280
X-MFC with: r327496

6 years agoFix markup.
Mariusz Zaborski [Wed, 10 Jan 2018 02:57:22 +0000 (02:57 +0000)]
Fix markup.

6 years agoConvert a collection of unrelated bitwise flags to a collection of boolean
Ian Lepore [Wed, 10 Jan 2018 02:57:03 +0000 (02:57 +0000)]
Convert a collection of unrelated bitwise flags to a collection of boolean
vars in the softc.  It makes the code more compact and readable, and
actually uses less memory too.

6 years agoBugfix: don't lose the am/pm mode flag when setting the time. Unlike most
Ian Lepore [Wed, 10 Jan 2018 02:31:59 +0000 (02:31 +0000)]
Bugfix: don't lose the am/pm mode flag when setting the time.  Unlike most
RTC chips that have a control register bit for am/pm mode, the DS13xx series
uses one of the high bits in the hour register.  Thus, when setting the time
in am/pm mode, the am/pm mode flag has to be ORed into the hour.

6 years agoBugfix: on RTC chips with a 32-bit binary counter, after reading the time,
Ian Lepore [Wed, 10 Jan 2018 02:28:10 +0000 (02:28 +0000)]
Bugfix: on RTC chips with a 32-bit binary counter, after reading the time,
return immediately rather than falling through to the logic that reads
BCD-encoded time.

6 years agoAllow the fast-path for disk AIO requests to fail requests.
John Baldwin [Wed, 10 Jan 2018 00:18:47 +0000 (00:18 +0000)]
Allow the fast-path for disk AIO requests to fail requests.

- If aio_qphysio() returns a non-zero error code, fail the request rather
  than queueing it to the AIO kproc pool to be retried via the slow path.
  Currently this means that if vm_fault_quick_hold_pages() reports an
  error, EFAULT is returned from the fast-path rather than retrying the
  request in the slow path where it will still fail with EFAULT.
- If aio_qphysio() wishes to use the fast path for a device that doesn't
  support unmapped I/O but there are already the maximum number of
  such requests in flight, fail with EAGAIN as we do for other AIO
  resource limits rather than queueing the request to the AIO kproc pool.
- Move the opcode check for aio_qphysio() out of the caller and into
  aio_qphysio() to simplify some logic and remove two goto's while here.
  It also uses a whitelist (only supported for LIO_READ / LIO_WRITE)
  rather than a blacklist (skipped for LIO_SYNC).

PR: 217261
Submitted by: jkim (an earlier version)
MFC after: 2 weeks
Sponsored by: Chelsio Communications

6 years agoFix backwards MD_VERIFY logic for md devices.
Jonathan T. Looney [Wed, 10 Jan 2018 00:08:57 +0000 (00:08 +0000)]
Fix backwards MD_VERIFY logic for md devices.

If the MD_VERIFY flag is set, we should use O_VERIFY. If the MD_VERIFY flag
is not set, we should not.

Reviewed by: stevek
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13814

6 years agoSimplify some logic by merging an if test with a subsequent switch.
John Baldwin [Wed, 10 Jan 2018 00:02:06 +0000 (00:02 +0000)]
Simplify some logic by merging an if test with a subsequent switch.

Specifically, in aio_queue_file() the code was doing this:

   if (opcode == LIO_SYNC) {
       ...
   }

   switch (opcode) {
   ...
   case LIO_SYNC:
       ...
   }

This moves the body of the if statement into the LIO_SYNC case of the
switch statement.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

6 years agoAdd a counter to track in-flight AIO requests using unmapped I/O.
John Baldwin [Tue, 9 Jan 2018 23:57:29 +0000 (23:57 +0000)]
Add a counter to track in-flight AIO requests using unmapped I/O.

MFC after: 2 weeks
Sponsored by: Chelsio Communications

6 years agoUse the __result_use_check attribute also for reallocf(3).
Pedro F. Giffuni [Tue, 9 Jan 2018 22:48:13 +0000 (22:48 +0000)]
Use the __result_use_check attribute also for reallocf(3).

The GCC attribute causes a warning to be emitted if a caller of the
function with this attribute does not use its return value. Unlike the
traditional realloc, with reallocf(3) we don't have to check for NULL
values but we still have to make sure the result is used.

MFC after: 3 days

6 years agoRelease the held refcount on the probe periph when probing is
Scott Long [Tue, 9 Jan 2018 21:24:05 +0000 (21:24 +0000)]
Release the held refcount on the probe periph when probing is
done, now that r327741 lets this happen.

Obtained from: Netflix

6 years agoHold a refcount on the periph while running the allocation
Scott Long [Tue, 9 Jan 2018 21:23:16 +0000 (21:23 +0000)]
Hold a refcount on the periph while running the allocation
queue.  This will allow sub-transports to release their
probe pseudo-device with fewer convoluted restrictions.

Obtained from: Netflix

6 years agoBump version for r327597 adding cpucontrol -e support
Bryan Drewery [Tue, 9 Jan 2018 21:12:53 +0000 (21:12 +0000)]
Bump version for r327597 adding cpucontrol -e support

6 years agoAdd Pull Request to the Subversion commit template
Alan Somers [Tue, 9 Jan 2018 21:02:39 +0000 (21:02 +0000)]
Add Pull Request to the Subversion commit template

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

6 years agoFix Zstd x86 kernel build with -march=<specific>
Conrad Meyer [Tue, 9 Jan 2018 20:53:30 +0000 (20:53 +0000)]
Fix Zstd x86 kernel build with -march=<specific>

Disable Zstd experimental support for __BMI__ intrinsics, when built with
-march=foo supporting such intrinsics, to avoid attempting to include
immintrin.h.  If a later Zstd marks the support non-experimental, we may want
to revisit this approach.

Submitted by: jkim
Reported by: jkim, "Oliver Hartmann" <ohartmann AT walstatt.org>

6 years agoUSNO and possibly others have misinterpreted the maining of the
Cy Schubert [Tue, 9 Jan 2018 20:35:58 +0000 (20:35 +0000)]
USNO and possibly others have misinterpreted the maining of the
leapseconds last-update field and incorrectly increment it when changing
the file even though the leapsecond data has not changed. For instance,
if a leapsecond file is obtained from USNO, when it expires it will not
be replaced by a newer file from other sources because it has an
incorrect later last-update (version).

This corrects r304780.

PR: 225029
Submitted by: ian
MFC after: 3 days

6 years agoAdd XHCI support to powerpc64 GENERIC. This is useful to get input devices
Nathan Whitehorn [Tue, 9 Jan 2018 19:41:10 +0000 (19:41 +0000)]
Add XHCI support to powerpc64 GENERIC. This is useful to get input devices
supported on newer POWER hardware and in graphical VMs run on the same,
which are typically XHCI-only. The 32-bit GENERIC kernel, which
does not run on hardware made in the last decade and is unlikely to
encounter XHCI devices, is left unchanged.

PR: kern/224940
Submitted by: Gustavo Romero
MFC after: 1 week

6 years agopf tests: Fix pft_ping.py to work with scapy 2.3.3
Kristof Provost [Tue, 9 Jan 2018 19:02:42 +0000 (19:02 +0000)]
pf tests: Fix pft_ping.py to work with scapy 2.3.3

Scapy requires the Raw payload to be a string, which was not the case. This
caused the pft_ping.py script to fail, which in turn caused the test to fail.

6 years agoConsolidate two identical copies of sysres_ids.
Warner Losh [Tue, 9 Jan 2018 16:42:24 +0000 (16:42 +0000)]
Consolidate two identical copies of sysres_ids.

6 years agoFix year.
Konstantin Belousov [Tue, 9 Jan 2018 16:28:45 +0000 (16:28 +0000)]
Fix year.

Noted by: oshogbo
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

6 years agoRemove ccbque.h from i386/isa.
Warner Losh [Tue, 9 Jan 2018 16:11:33 +0000 (16:11 +0000)]
Remove ccbque.h from i386/isa.

inline ccbque.h into scsi_low.h. The file isn't MD, so shouldn't live
in i386/isa. It's only used by scsi_low, so move it there so no new
clients accidentally grow. scsi_low may not even still work, and the
locking here is still SPL based. CAM should do the right thing, but
I've received no reports of these cards still working. At least it
compiles still and there's one fewer files in sys/i386/isa. While I'm
here, ansify and de-splize. CCB_MWANTED appears to be a clear-only
flag, but I've not changed that.

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

6 years agoAdd a function to find the PSCI version the firmware implements from
Andrew Turner [Tue, 9 Jan 2018 15:57:09 +0000 (15:57 +0000)]
Add a function to find the PSCI version the firmware implements from
outside the PSCI driver.

MFC after: 1 week
Sponsored by: DARPA, AFRL

6 years agoAdd a framework to install CPU errata on arm64. Each erratum can encode
Andrew Turner [Tue, 9 Jan 2018 14:33:05 +0000 (14:33 +0000)]
Add a framework to install CPU errata on arm64. Each erratum can encode
a mask and value to compare with the Main ID Register. If these match then a
function is called to handle the installation of the erratum workaround.

No errata are currently handled, however this will change soon in a future
commit.

MFC after: 1 week
Sponsored by: DARPA, AFRL

6 years agovmm/svm: contigmalloc of the whole svm_softc is excessive
Andriy Gapon [Tue, 9 Jan 2018 14:22:18 +0000 (14:22 +0000)]
vmm/svm: contigmalloc of the whole svm_softc is excessive

This is a followup to r307903.

struct svm_softc takes more than 200 kilobytes while what we really need
is 3 contiguous pages for I/O permission map and 2 contiguous pages for
MSR permission map.  Other physically mapped structures have a size of
a single page, so a proper alignment is sufficient for their correct
mapping.

Thus, only the permission maps are allocated with contigmalloc now,
the softc is allocated with a regular malloc.

Additionally, this commit adds a check that malloc returns memory with the
expected page alignment and that contigmalloc does not fail.
Unfortunately, at present svm_vminit() is expected to always succeed and
there is no way to report an error.
So, a contigmalloc failure leads to a panic.
We should probably fix this.

MFC after: 2 weeks

6 years agozfs_mount: restore a bit of ifdef-out illumos code
Andriy Gapon [Tue, 9 Jan 2018 13:43:04 +0000 (13:43 +0000)]
zfs_mount: restore a bit of ifdef-out illumos code

And correctly mark the end of the replacement FreeBSD code.

MFC after: 1 week

6 years agousbdevs: add ASMedia vendor ID
Andriy Gapon [Tue, 9 Jan 2018 13:42:08 +0000 (13:42 +0000)]
usbdevs: add ASMedia vendor ID

MFC after: 1 week

6 years agoGeneralize the fix from r322757 and apply it to several more places.
Konstantin Belousov [Tue, 9 Jan 2018 10:51:44 +0000 (10:51 +0000)]
Generalize the fix from r322757 and apply it to several more places.

The code accesses bp->b_dep without owning the ufs mount softdep lock,
which makes it possible for the derefenced workitem to be freed in
parallel.  In particular, the deallocate_dependencies(),
softdep_disk_io_initiation() and softdep_disk_write_complete() are
affected.

Move the code to safely calculate ump from the buffer with
dependencies into the helper softdep_bp_to_mp() and use it for all
found cases.

Tested by: pho (as part of the bigger patch)
Reviewed by: mckusick (as part of the bigger patch)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoWhen handling write completion, take SU lock around calls to
Konstantin Belousov [Tue, 9 Jan 2018 10:44:17 +0000 (10:44 +0000)]
When handling write completion, take SU lock around calls to
handle_written_XXX() in case of processing the buffer with an error.

Tested by: pho (as part of the bigger patch)
Reviewed by: mckusick (as part of the bigger patch)
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoPostpone the disassotiation of the background write buffer with devvp
Konstantin Belousov [Tue, 9 Jan 2018 10:33:11 +0000 (10:33 +0000)]
Postpone the disassotiation of the background write buffer with devvp
so that buf_complete() sees fully constructed buffer.

This is a NOP right now, but will be needed by the forthcoming SU change.

Reported and tested by: pho
Reviewed by: mckusick
Sponsored by: The FreeBSD Foundation
MFC after: 1 week

6 years agoldconfig(8): use .Nm instead of 'ldconfig'
Eitan Adler [Tue, 9 Jan 2018 06:51:41 +0000 (06:51 +0000)]
ldconfig(8): use .Nm instead of 'ldconfig'

6 years agoWhen growing the state, also grow the seed array. Otherwise memory
Cy Schubert [Tue, 9 Jan 2018 06:43:58 +0000 (06:43 +0000)]
When growing the state, also grow the seed array. Otherwise memory
that was not allocated will be accessed.

This necessitated refactoring state seed allocation from
ipf_state_soft_init() into a new common ipf_state_seed_alloc() function
as it is now also used by ipf_state_rehash() when changing the size of
the state hash table in addition to by ipf_state_soft_init() during
initialization.

According to Christos Zoulas <christos@NetBSD.org>:

The bug was encountered by a NetBSD vendor who's customer machines had
large ipfilter states. The bug was reliably triggered by resizing the
state variables using "ipf -T".

Submitted by: Christos Zoulas <christos@NetBSD.org>
Reviewed by: delphij, rgrimes
Obtained from: NetBSD ip_state.c CVS revs r1.9 and r1.10
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D13755

6 years agoFix Zstd kernel build with GCC 4.2
Conrad Meyer [Tue, 9 Jan 2018 03:28:24 +0000 (03:28 +0000)]
Fix Zstd kernel build with GCC 4.2

By disabling the -Winline warning.  Fixes the powerpc and sparc64 build
after r327706.

Note: MIPS and RISCV builds still broken due to absense of __ctzdi2 (aka
__builtin_ctzll) in their libgcc or libcompiler-rt libraries.

Reported by: markj
Sponsored by: Dell EMC Isilon

6 years agoDon't hold the periph locks during dump.
Scott Long [Tue, 9 Jan 2018 00:17:15 +0000 (00:17 +0000)]
Don't hold the periph locks during dump.

Obtained from: Netflix

6 years agoDon't hold the periph lock when calling into cam_periph_runccb()
Scott Long [Tue, 9 Jan 2018 00:10:59 +0000 (00:10 +0000)]
Don't hold the periph lock when calling into cam_periph_runccb()
from the ada and da dump routines.  This avoids difficult locking
problems from needing to be handled.  While it might seem like this
would leave the periphs unprotected during dump, they were aleady
at risk of unexpected removal due to the dump functions not
keeping refcount state across the many calls that come in during
a dump.  This is an exercise for future work.

Obtained from: Netflix

6 years agoProtect against a possible NULL deference from an accessor
Scott Long [Tue, 9 Jan 2018 00:00:55 +0000 (00:00 +0000)]
Protect against a possible NULL deference from an accessor
function.

Obtained from: Netflix

6 years agoGeneralize the gzio API.
Mark Johnston [Mon, 8 Jan 2018 21:27:41 +0000 (21:27 +0000)]
Generalize the gzio API.

We currently use a set of subroutines in kern_gzio.c to perform
compression of user and kernel core dumps. In the interest of adding
support for other compression algorithms (zstd) in this role without
complicating the API consumers, add a simple compressor API which can be
used to select an algorithm.

Also change the (non-default) GZIO kernel option to not enable
compressed user cores by default. It's not clear that such a default
would be desirable with support for multiple algorithms implemented,
and it's inconsistent in that it isn't applied to kernel dumps.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D13632

6 years agoIntegrate zstd into the kernel
Conrad Meyer [Mon, 8 Jan 2018 20:14:16 +0000 (20:14 +0000)]
Integrate zstd into the kernel

Mock userspace headers and include mocked headers first in compilation
command to inject kernel headers and override e.g., malloc(3) with
malloc(9).

Submitted by: allanjude
Reviewed by: imp (earlier version), bapt (earlier version)
Differential Revision: https://reviews.freebsd.org/D10407

6 years agoUse <stand.h> instead of <inttypes.h> and <stdio.h> in boot code.
John Baldwin [Mon, 8 Jan 2018 18:47:35 +0000 (18:47 +0000)]
Use <stand.h> instead of <inttypes.h> and <stdio.h> in boot code.

In the freestanding boot compile environment, standard headers are not
available.  Curiously, only building with clang exposed this as compiles
with external GCC still succeeded.

Sponsored by: DARPA / AFRL

6 years agoFix printf missing format variables warnings.
John Baldwin [Mon, 8 Jan 2018 18:46:10 +0000 (18:46 +0000)]
Fix printf missing format variables warnings.

Include the failing kernel file name for errors in beri_elf64_exec().

Sponsored by: DARPA / AFRL

6 years agoDefine __dmadat after #include'ing ufsread.c.
John Baldwin [Mon, 8 Jan 2018 18:44:36 +0000 (18:44 +0000)]
Define __dmadat after #include'ing ufsread.c.

The __dmadat variable is a statically allocated I/O buffer.  The type is
declared in the ufsread.c source file and clang warns if a variable is
defined before it's type is declared.

Sponsored by: DARPA / AFRL

6 years agoSort and remove unneeded includes.
Mark Johnston [Mon, 8 Jan 2018 15:56:40 +0000 (15:56 +0000)]
Sort and remove unneeded includes.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoRevert r327697:
Pedro F. Giffuni [Mon, 8 Jan 2018 15:54:29 +0000 (15:54 +0000)]
Revert r327697:
malloc(9): drop the __result_use_check attribute for the kernel allocator.

My bad: __result_use_check just checks the for the general and we always
want to make sure allocated memory is used, not only checked for nullness.

Add it to reallocf since that was missing.

6 years agoRelease the queue lock before restarting the worker loop.
Mark Johnston [Mon, 8 Jan 2018 15:41:49 +0000 (15:41 +0000)]
Release the queue lock before restarting the worker loop.

Reported and tested by: pho
MFC after: 3 days
Sponsored by: Dell EMC Isilon

6 years agomalloc(9): drop the __result_use_check attribute for the kernel allocator.
Pedro F. Giffuni [Mon, 8 Jan 2018 15:41:48 +0000 (15:41 +0000)]
malloc(9): drop the __result_use_check attribute for the kernel allocator.

The __result_use_check attribute was brought to the kernel malloc in
r281203 for consistency with the userland malloc.

For the case of the M_WAITOK flag, the kernel malloc(), realloc(), and
reallocf() cannot return NULL so in that case the __result_use_check
attribute makes no sense.

We don't have any way of conditionalizing such attributes so just drop it.

MFC after: 3 days

6 years agoFix uninitialized crp_retw_id when using asynchronous crypto drivers
Fabien Thomas [Mon, 8 Jan 2018 13:43:12 +0000 (13:43 +0000)]
Fix uninitialized crp_retw_id when using asynchronous crypto drivers
with defered callbacks.

Submitted by: emeric.poupon@stormshield.eu
Reported by: mav@
Reviewed by: fabient@

6 years agoOnly install the new pagetable pointer into ttbr0_el1 when it differs from
Andrew Turner [Mon, 8 Jan 2018 11:08:45 +0000 (11:08 +0000)]
Only install the new pagetable pointer into ttbr0_el1 when it differs from
the existing value.

MFC after: 1 week
Sponsored by: DARPA, AFRL

6 years agoMove some of the common thread switching code into C. This will help with
Andrew Turner [Mon, 8 Jan 2018 10:23:31 +0000 (10:23 +0000)]
Move some of the common thread switching code into C. This will help with
future optimisations, e.g. using Address Space IDs (asid).

MFC after: 1 week
Sponsored by: DARPA, AFRL

6 years agoDocument the DNS Casper service.
Mariusz Zaborski [Mon, 8 Jan 2018 09:20:08 +0000 (09:20 +0000)]
Document the DNS Casper service.

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

6 years agogeli: optimize tests
Alan Somers [Mon, 8 Jan 2018 00:10:45 +0000 (00:10 +0000)]
geli: optimize tests

Reduce the geli tests' runtime by about a third:

* In integrity_test:copy, use a file-backed md(4) device instead of a
  malloc'd one.  That way we can corrupt the underlying storage without
  needing to detach and reattach the geli device.

* In integrity_test:{copy, hmac, data} and onetime_test:{onetime,
  onetime_a}, move reads of /dev/random out of the loop.

MFC after: 2 weeks

6 years agoUse mallocarray(9) in CloudABI kernel code where possible.
Ed Schouten [Sun, 7 Jan 2018 22:38:45 +0000 (22:38 +0000)]
Use mallocarray(9) in CloudABI kernel code where possible.

Submitted by: pfg@

6 years agogeli: convert remaining TAP tests to ATF
Alan Somers [Sun, 7 Jan 2018 22:21:07 +0000 (22:21 +0000)]
geli: convert remaining TAP tests to ATF

MFC after: 2 weeks

6 years agoFix typo from r327666
Alan Somers [Sun, 7 Jan 2018 21:57:52 +0000 (21:57 +0000)]
Fix typo from r327666

MFC after: 13 days
X-MFC-With: 327666

6 years agoAdd missing file to gpiobus module
Justin Hibbits [Sun, 7 Jan 2018 20:28:17 +0000 (20:28 +0000)]
Add missing file to gpiobus module

ofw_gpiobus.c is needed when FDT is used.

MFC after: 2 weeks

6 years agoUse EVENTHANDLER_DIRECT_INVOKE for [un]mount events, for better performance.
Ian Lepore [Sun, 7 Jan 2018 18:07:22 +0000 (18:07 +0000)]
Use EVENTHANDLER_DIRECT_INVOKE for [un]mount events, for better performance.

6 years agoUse EVENTHANDLER_DIRECT_INVOKE() for device events, for better performance.
Ian Lepore [Sun, 7 Jan 2018 18:06:30 +0000 (18:06 +0000)]
Use EVENTHANDLER_DIRECT_INVOKE() for device events, for better performance.

6 years agovchiq: Use mallocarray() to provide kcalloc()
Kristof Provost [Sun, 7 Jan 2018 13:41:06 +0000 (13:41 +0000)]
vchiq: Use mallocarray() to provide kcalloc()

This means we now also provide integer overflow protection, like the
Linux kcalloc().

6 years agolinuxkpi: Implement kcalloc() based on mallocarray()
Kristof Provost [Sun, 7 Jan 2018 13:39:12 +0000 (13:39 +0000)]
linuxkpi: Implement kcalloc() based on mallocarray()

This means we now get integer overflow protection, which Linux code
might expect as it is also provided by kcalloc() in Linux.

6 years agopf: Avoid integer overflow issues by using mallocarray() iso. malloc()
Kristof Provost [Sun, 7 Jan 2018 13:35:15 +0000 (13:35 +0000)]
pf: Avoid integer overflow issues by using mallocarray() iso. malloc()

pfioctl() handles several ioctl that takes variable length input, these
include:
- DIOCRADDTABLES
- DIOCRDELTABLES
- DIOCRGETTABLES
- DIOCRGETTSTATS
- DIOCRCLRTSTATS
- DIOCRSETTFLAGS

All of them take a pfioc_table struct as input from userland. One of
its elements (pfrio_size) is used in a buffer length calculation.
The calculation contains an integer overflow which if triggered can lead
to out of bound reads and writes later on.

Reported by: Ilja Van Sprundel <ivansprundel@ioactive.com>

6 years agoIntroduce mallocarray() in the kernel
Kristof Provost [Sun, 7 Jan 2018 13:21:01 +0000 (13:21 +0000)]
Introduce mallocarray() in the kernel

Similar to calloc() the mallocarray() function checks for integer
overflows before allocating memory.
It does not zero memory, unless the M_ZERO flag is set.

Reviewed by: pfg, vangyzen (previous version), imp (previous version)
Obtained from: OpenBSD
Differential Revision: https://reviews.freebsd.org/D13766

6 years agostddef.h is not used by cat.c, remove the include.
Xin LI [Sun, 7 Jan 2018 07:08:59 +0000 (07:08 +0000)]
stddef.h is not used by cat.c, remove the include.

6 years agoldconfig(8): clarify language for files
Eitan Adler [Sun, 7 Jan 2018 05:38:53 +0000 (05:38 +0000)]
ldconfig(8): clarify language for files

The previous language did not make it clear that 'Files' are
the files specified above. Clarify it.

Reported by: dana <dana@dana.is>
Reviewed by: dana <dana@dana.is>
MFC After: 1 week

6 years agoaw_sid(4): Add support for Allwinner H3
Kyle Evans [Sun, 7 Jan 2018 04:59:28 +0000 (04:59 +0000)]
aw_sid(4): Add support for Allwinner H3

The sid controller on the H3 is generally identical in location, size, and
efuse offset to the a64 and the a83t. The main difference is that the H3 has
a silicon bug that sometimes causes the rootkey (at least) to be garbled
unless first read by the prctl registers.

This device is currently not in our DTS and, as of now, is not yet present
in mainline Linux DTS.

Tested on: OrangePi One

6 years agoaw_sid: Add method for reading keys via prctl registers
Kyle Evans [Sun, 7 Jan 2018 03:31:55 +0000 (03:31 +0000)]
aw_sid: Add method for reading keys via prctl registers

Technically supported on the later SoCs, this will only really be used to
add support for the H3 sid. The H3 has a silicon bug that manifests itself
by returning garbled rootkeys unless first read via the prctl registers.

6 years agogeli: fix parallel execution of tests
Alan Somers [Sun, 7 Jan 2018 02:30:08 +0000 (02:30 +0000)]
geli: fix parallel execution of tests

The trick is not to destroy an md(4) device during a test.  That can create
a "double-free" situation, because we also destroy md devices during test
cleanup.

MFC after: 2 weeks

6 years agoFix bogus pass for syscon_generic introduced in r327621
Kyle Evans [Sun, 7 Jan 2018 02:19:54 +0000 (02:19 +0000)]
Fix bogus pass for syscon_generic introduced in r327621

ian@ pointed out that BUS_PASS_DEFAULT + $anything is bogus, given that
BUS_PASS_DEFAULT is defined as __INT_MAX. Instead, we take a page out of
imx6_usbphy's book and use BUS_PASS_DEFAULT - 1000 to achieve the desired
effect of syscon_generic attaching before if_awg and other potential
consumers, but late enough that more specialized implementations should have
no problem attaching instead.

Reported by: ian

6 years agogeli: convert most tests from TAP to ATF
Alan Somers [Sun, 7 Jan 2018 00:44:22 +0000 (00:44 +0000)]
geli: convert most tests from TAP to ATF

I'm leaving readonly_test and nokey_test alone for now. In a future commit
they should be broken up into several smaller test cases and distributed
between multiple files.

Reviewed by: ngie
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D13717

6 years agoarm64: Remove old clock driver for Allwinner 64bit SoC
Emmanuel Vadot [Sat, 6 Jan 2018 20:32:14 +0000 (20:32 +0000)]
arm64: Remove old clock driver for Allwinner 64bit SoC

All the clocks are now handled by the clkng driver.

Tested On: Pine64-LTS (A64)
Tested On: OrangePi PC2 (H5)

6 years agoDocument kern.smp.disabled tunable.
Konstantin Belousov [Sat, 6 Jan 2018 16:29:00 +0000 (16:29 +0000)]
Document kern.smp.disabled tunable.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

6 years agomorse(6): update documentation
Eitan Adler [Sat, 6 Jan 2018 15:52:28 +0000 (15:52 +0000)]
morse(6): update documentation

- bump Dd
- use 'r' instead of 'D' from the original submission

6 years agoMove syscon_generic to attach much later
Kyle Evans [Sat, 6 Jan 2018 14:21:32 +0000 (14:21 +0000)]
Move syscon_generic to attach much later

It still needs to be before if_awg at least in order to be available for
other operations, but it should not be attaching before interrupt
controllers at the very least.

This should make errors involving syscon register space colliding with other
devices a little more innocent, but these conflicts should really be tracked
down and resolved. One such conflict is with the Raspberry Pi 3 local
interrupt controller, noticed by tuexen@

Reported by: tuexen

6 years agoThe source strings are from the password database which guarantees
Warner Losh [Sat, 6 Jan 2018 12:46:04 +0000 (12:46 +0000)]
The source strings are from the password database which guarantees
that the data going into it is sane.  Out of an abundance of caution,
limit the string copies to prevent an overflow.

CID: 1019035

6 years agoSanity check sysconf return value to ensure it's positive before we
Warner Losh [Sat, 6 Jan 2018 12:45:59 +0000 (12:45 +0000)]
Sanity check sysconf return value to ensure it's positive before we
use it. Use proper cast to convert long to size_t (instead of
blksize_t) to preclude sign extension issues.

CID: 1193754

6 years agoSanity check media size and sector counts to ensure that we don't
Warner Losh [Sat, 6 Jan 2018 12:34:03 +0000 (12:34 +0000)]
Sanity check media size and sector counts to ensure that we don't
produce negative sector numbers in the testing algorithm.

CID: 1198994

6 years agoUnbreak build after r327614
Li-Wen Hsu [Sat, 6 Jan 2018 09:48:04 +0000 (09:48 +0000)]
Unbreak build after r327614

Approved by: mjg (on IRC)
Differential Revision: https://reviews.freebsd.org/D13782

6 years agomorse(6): minor nits
Eitan Adler [Sat, 6 Jan 2018 07:48:17 +0000 (07:48 +0000)]
morse(6): minor nits

- Use copyright comment header
- Make it easier to compile on !FreeBSD
- Diff reduction against DragonFlyBSD

6 years agomorse(6): implement support for decoding morse code
Eitan Adler [Sat, 6 Jan 2018 07:02:24 +0000 (07:02 +0000)]
morse(6): implement support for decoding morse code

- Use `-r` for "reverse" mode and to match DragonFlyBSD.
- Move defines around to clear up logic
- use `errx` instead of `fprintf` and `exit`

PR: 35109
Submitted By: philipp.mergenthaler@stud.uni-karlsruhe.de
Submitted on: 2002-02-19
Reviewed by: kevans

6 years agoInvent new #defines for the biospci_{read,write}_config function to
Warner Losh [Sat, 6 Jan 2018 06:00:45 +0000 (06:00 +0000)]
Invent new #defines for the biospci_{read,write}_config function to
specify the width and use them everywhere.

Sponsored by: Netflix

6 years agoThere's no need / benefit from deleting the variable before we set it.
Warner Losh [Sat, 6 Jan 2018 06:00:40 +0000 (06:00 +0000)]
There's no need / benefit from deleting the variable before we set it.

Sponsored by: Netflix

6 years agoFix usage strings. -d and -p were removed before this was committed to
Warner Losh [Sat, 6 Jan 2018 06:00:34 +0000 (06:00 +0000)]
Fix usage strings. -d and -p were removed before this was committed to
FreeBSD, but the strings weren't updated.

Sponsored by: Netflix

6 years agoFix a header inclusion missed in the previous commit.
Jung-uk Kim [Sat, 6 Jan 2018 03:41:35 +0000 (03:41 +0000)]
Fix a header inclusion missed in the previous commit.

Reported by: Michael Butler (imb at protected-networks dot net)

6 years agoHandle misconfigured/nonexistent pcidev for comconsole instead of BTX panic.
Sean Bruno [Fri, 5 Jan 2018 23:50:50 +0000 (23:50 +0000)]
Handle misconfigured/nonexistent pcidev for comconsole instead of BTX panic.

PR: 203319
Reviewed by: imp jhb
MFC after: 2 weeks
Sponsored by: Limelight Networks
Differential Revision: https://reviews.freebsd.org/D13776

6 years agoMerge ACPICA 20180105.
Jung-uk Kim [Fri, 5 Jan 2018 23:21:47 +0000 (23:21 +0000)]
Merge ACPICA 20180105.

6 years agoImport ACPICA 20180105.
Jung-uk Kim [Fri, 5 Jan 2018 23:02:12 +0000 (23:02 +0000)]
Import ACPICA 20180105.

6 years agoRevert r327599. I missed a new file.
Jung-uk Kim [Fri, 5 Jan 2018 22:59:03 +0000 (22:59 +0000)]
Revert r327599.  I missed a new file.

Pointyhat to: jkim

6 years agoImport ACPICA 20180105.
Jung-uk Kim [Fri, 5 Jan 2018 22:51:18 +0000 (22:51 +0000)]
Import ACPICA 20180105.

6 years agoRemove LINK_MAX.
John Baldwin [Fri, 5 Jan 2018 22:26:23 +0000 (22:26 +0000)]
Remove LINK_MAX.

After recent changes to change filesystems to use filesystem-specific
limits, LINK_MAX is no longer used in the base system.  Applications
should in theory be able to cope with a lack of LINK_MAX by using
pathconf().

PR: 224628 (exp-run)
Approved by: imp, kib
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D13658

6 years agoMake it possible to re-evaluate cpu_features.
Konstantin Belousov [Fri, 5 Jan 2018 21:06:19 +0000 (21:06 +0000)]
Make it possible to re-evaluate cpu_features.

Add cpuctl(4) ioctl CPUCTL_EVAL_CPU_FEATURES which forces re-read of
cpu_features, cpu_features2, cpu_stdext_features, and
std_stdext_features2.

The intent is to allow the kernel to see the changes in the CPU
features after micocode update.  Of course, the update is not atomic
across variables and not synchronized with readers.  See the man page
warning as well.

Reviewed by: imp (previous version), jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D13770

6 years agoIn sendfile_iodone() both pru_abort and sorele need to be executed
Gleb Smirnoff [Fri, 5 Jan 2018 20:21:46 +0000 (20:21 +0000)]
In sendfile_iodone() both pru_abort and sorele need to be executed
with proper VNET context set.

Reported by: sbruno
MFC after: 2 weeks

6 years agoFix a couple of comments in AMD Virtual Machine Control Block structure
Andriy Gapon [Fri, 5 Jan 2018 19:15:24 +0000 (19:15 +0000)]
Fix a couple of comments in AMD Virtual Machine Control Block structure

MFC after: 1 week

6 years agoCorrect comment. procfs_doprocfile implements 'file', not 'self'.
John Baldwin [Fri, 5 Jan 2018 18:32:46 +0000 (18:32 +0000)]
Correct comment.  procfs_doprocfile implements 'file', not 'self'.

6 years agoAdd 64bit feature support.
Fedor Uporov [Fri, 5 Jan 2018 10:04:01 +0000 (10:04 +0000)]
Add 64bit feature support.

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

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

6 years agoBuild service tests with Casper support.
Mariusz Zaborski [Fri, 5 Jan 2018 09:31:41 +0000 (09:31 +0000)]
Build service tests with Casper support.

6 years agoFix typo & build
Li-Wen Hsu [Fri, 5 Jan 2018 08:29:32 +0000 (08:29 +0000)]
Fix typo & build

Approved by: kevlo

6 years agoRemove dead code (comma is either 0 or 1 for sure, no need to test).
Warner Losh [Fri, 5 Jan 2018 07:29:02 +0000 (07:29 +0000)]
Remove dead code (comma is either 0 or 1 for sure, no need to test).
Close /dev/pci when we're done with it.

CID: 1007450100744910086151008614

6 years agobits is never null when we call ot. Add an assert to that effect and
Warner Losh [Fri, 5 Jan 2018 07:28:58 +0000 (07:28 +0000)]
bits is never null when we call ot. Add an assert to that effect and
remove test for NULL.

CID: 270774

6 years agoTag 'a' case as one we're intentionally falling through to
Warner Losh [Fri, 5 Jan 2018 07:28:48 +0000 (07:28 +0000)]
Tag 'a' case as one we're intentionally falling through to
the 'F' case.

CID: 1008176