]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
6 years agomalloc.9: Fix minor typo from rewording in r327796
cem [Wed, 10 Jan 2018 22:20:49 +0000 (22:20 +0000)]
malloc.9: Fix minor typo from rewording in r327796

Sponsored by: Dell EMC Isilon

6 years agoFix minor locking issues in the Power Mac Uninorth PCI bridge driver.
landonf [Wed, 10 Jan 2018 22:19:11 +0000 (22:19 +0000)]
Fix minor locking issues in the Power Mac Uninorth PCI bridge driver.

- Call resource_int_value() once during attach, rather than within the
  pci_(read|write)_config() code path; this avoids taking a blocking mutex
  to read kenv variables.

- Use a spin lock to protect non-atomic config space accesses; this matches
  the behavior of Darwin's AppleMacRiscPCI driver.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D13839

6 years agomallocarray(9): panic if the requested allocation would overflow
cem [Wed, 10 Jan 2018 21:49:45 +0000 (21:49 +0000)]
mallocarray(9): panic if the requested allocation would overflow

Additionally, move the overflow check logic out to WOULD_OVERFLOW() for
consumers to have a common means of testing for overflowing allocations.
WOULD_OVERFLOW() should be a secondary check -- on 64-bit platforms, just
because an allocation won't overflow size_t does not mean it is a sane size
to request.  Callers should be imposing reasonable allocation limits far,
far, below overflow.

Discussed with: emaste, jhb, kp
Sponsored by: Dell EMC Isilon

6 years agoAdd a regression test for r327794.
markj [Wed, 10 Jan 2018 21:40:36 +0000 (21:40 +0000)]
Add a regression test for r327794.

MFC after: 2 weeks

6 years agoFix an off-by-one in dt_opt_setenv().
markj [Wed, 10 Jan 2018 21:37:11 +0000 (21:37 +0000)]
Fix an off-by-one in dt_opt_setenv().

The bug would cause incorrect behaviour when attempting to override
an already set environment variable with -x setenv, as long as the
variable is not the last one in the array.

Reported by: Samuel Lepetit <slepetit@apple.com>
MFC after: 2 weeks

6 years agoDon't store shadow copies of per-process AIO limits.
jhb [Wed, 10 Jan 2018 21:18:46 +0000 (21:18 +0000)]
Don't store shadow copies of per-process AIO limits.

Previously the AIO subsystem would save a snapshot of the currently
configured per-process limits the first time a process used AIO.  The
process would continue to use the snapshotted limits ignoring any
changes to the global limits during the rest of its lifetime.  This
change removes the snapshotted values and changes the AIO code to
always check the global values which can be toggled at runtime.
This means an administrator can now change the effective limits of
existing processes.  This is more consistent with how other limits
configured via sysctl work in FreeBSD.

Reviewed by: asomers, kib
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D13819

6 years agoSet the 'FR' bit in the status register for N32 kernels.
jhb [Wed, 10 Jan 2018 21:08:43 +0000 (21:08 +0000)]
Set the 'FR' bit in the status register for N32 kernels.

This permits N32 hard-float binaries to use 64-bit floating point
registers (which is what N32 binaries expect) matching the N64 ABI.

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

6 years agolinuxkpi: Simplify kmalloc_array.
pfg [Wed, 10 Jan 2018 20:50:06 +0000 (20:50 +0000)]
linuxkpi: Simplify kmalloc_array.

kmalloc_array seems what we call mallocarray(9).

6 years agoMention switch to ld.lld for amd64 in UPDATING
emaste [Wed, 10 Jan 2018 20:49:01 +0000 (20:49 +0000)]
Mention switch to ld.lld for amd64 in UPDATING

Sponsored by: The FreeBSD Foundation

6 years agoregen src.conf.5 after r327783, WITH_LLD_BOOTSTRAP default
emaste [Wed, 10 Jan 2018 20:36:16 +0000 (20:36 +0000)]
regen src.conf.5 after r327783, WITH_LLD_BOOTSTRAP default

(I missed the Reviewed by and review link from r327783.)

Reviewed by: brooks, dim, bapt
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13827

6 years agoEnable ld.lld as bootstrap linker by default on amd64
emaste [Wed, 10 Jan 2018 20:28:01 +0000 (20:28 +0000)]
Enable ld.lld as bootstrap linker by default on amd64

For some time we have been planning to migrate to LLVM's lld linker.
Having a man page was the last blocking issue for using ld.lld to link
the base system kernel + userland, now addressed by r327770.  Link the
kernel and userland libraries and binaries with ld.lld by default, for
additional test coverage.

This has been a long time in the making.  On 2013-04-13 I submitted an
upstream tracking issue in LLVM PR 23214: [META] Using LLD as FreeBSD's
system linker.  Since then 85 individual issues were identified, and
submitted as dependencies.  These have been addressed along with two
and a half years of other lld development and improvement.

I'd like to express deep gratitude to upstream lld developers Rui
Ueyama, Rafael Espindola, George Rimar and Davide Italiano.  They put in
substantial effort in addressing the issues we found affecting
FreeBSD/amd64.

To revert to using ld.bfd as the bootstrap linker, in /etc/src.conf set

    WITHOUT_LLD_BOOTSTRAP=yes

If you need to set this, please follow up with a PR or post to the
freebsd-toolchain mailing list explaining how default WITH_LLD_BOOTSTRAP
failed for your use case.

Note that GNU ld.bfd is still installed as /usr/bin/ld, and will still
be used for linking ports.  ld.lld can be installed as /usr/bin/ld by
setting in /etc/src.conf

    WITH_LLD_IS_LLD=yes

A followup commit will set WITH_LLD_IS_LD by default, possibly after
Clang/LLVM/lld 6.0 is merged to FreeBSD.

Release notes: Yes
Sponsored by: The FreeBSD Foundation

6 years agodev/bxe: make use of mallocarray(9).
pfg [Wed, 10 Jan 2018 20:05:19 +0000 (20:05 +0000)]
dev/bxe: make use of mallocarray(9).

Use mallocarray in a couple of cases where a calloc-like operation is
taking place.

6 years agoUse mallocarray(9) in dirhash.
pfg [Wed, 10 Jan 2018 19:45:38 +0000 (19:45 +0000)]
Use mallocarray(9) in dirhash.

Basic use of mallocarray to prevent overflows. Here allocation is done
with M_NOWAIT so the code is prepared for the possibility of returning
NULL values. Since mallocarray expects unsigned parameters, unsign some
related variables to minimize sign conversions.

Reviewed by: mckusick

6 years agoAdd regression tests for r327779.
markj [Wed, 10 Jan 2018 19:41:05 +0000 (19:41 +0000)]
Add regression tests for r327779.

MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

6 years agoFix handling of read errors during mirror synchronization.
markj [Wed, 10 Jan 2018 19:37:21 +0000 (19:37 +0000)]
Fix handling of read errors during mirror synchronization.

We would previously just free the request BIO, which would either cause
the disk to stay stuck in the SYNCHRONIZING state, or result in
synchronization completing without having copied the block which
returned an error.

With this change, if the disk which returned an error is the only active
disk in the mirror, the synchronizing disk is kicked out. Otherwise, the
read is retried.

Reported and tested by: pho (previous version)
MFC after: 2 weeks
Sponsored by: Dell EMC Isilon

6 years agosrc.conf.5: regen after r325692 and r326888
emaste [Wed, 10 Jan 2018 18:15:00 +0000 (18:15 +0000)]
src.conf.5: regen after r325692 and r326888

Sponsored by: The FreeBSD Foundation

6 years agoMake nullfs properly report MNT_AUTOMOUNTED set on the nullfs mount itself,
trasz [Wed, 10 Jan 2018 17:51:02 +0000 (17:51 +0000)]
Make nullfs properly report MNT_AUTOMOUNTED set on the nullfs mount itself,
instead of copying from the underlying filesystem.

PR: 224851
Reported by: Jamie Landeg-Jones <jamie at dyslexicfish.net>
Tested by: Jamie Landeg-Jones <jamie at dyslexicfish.net>
MFC after: 2 weeks

6 years agoInclude ffsll() on riscv kernels.
jhb [Wed, 10 Jan 2018 17:36:43 +0000 (17:36 +0000)]
Include ffsll() on riscv kernels.

6 years agoamdsbwd: fix handling of timeout values beyond the supported range
avg [Wed, 10 Jan 2018 17:35:00 +0000 (17:35 +0000)]
amdsbwd: fix handling of timeout values beyond the supported range

The driver now fully observes watchdog(9) protocol.
Previously a too large timeout was silently clamped while the correct
behavior is to disable the watchdog and leave the error as is
(i.e. to not report success).

Also, previously a too small value caused the timer to stop while the
correct behavior is to use the minimal supported value.

MFC after: 2 weeks

6 years agoinittodr(0) actually sets the time, so there's no need to call
imp [Wed, 10 Jan 2018 17:25:08 +0000 (17:25 +0000)]
inittodr(0) actually sets the time, so there's no need to call
tc_setclock(). It's redundant. Tweak UPDATING based on code review of
past releases.

Relnotes: yes (for the removal of pmtimer)

6 years agoCatchup to removing this directory
imp [Wed, 10 Jan 2018 16:56:02 +0000 (16:56 +0000)]
Catchup to removing this directory

6 years agoDocuent pmtimer driver removal.
imp [Wed, 10 Jan 2018 16:52:00 +0000 (16:52 +0000)]
Docuent pmtimer driver removal.

6 years agoMove prof_machdep.c to it's more traditional place under i386/i386.
imp [Wed, 10 Jan 2018 16:51:55 +0000 (16:51 +0000)]
Move prof_machdep.c to it's more traditional place under i386/i386.

6 years agolld: introduce basic man page
emaste [Wed, 10 Jan 2018 16:01:25 +0000 (16:01 +0000)]
lld: introduce basic man page

Upstream lld has no man page. Introduce a basic one for FreeBSD based on
ld.lld --help, with a brief introduction and additional detail for some
options.

We'll continue refining this in FreeBSD, and then submit it upstream once
the first round of edits are complete.

Submitted by: krion, Arshan Khanifar, emaste, bjk
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D13813

6 years agoRemove the executable bit from some recently added test scripts.
markj [Wed, 10 Jan 2018 15:55:07 +0000 (15:55 +0000)]
Remove the executable bit from some recently added test scripts.

6 years agoClarify the use of the gmirror flag mask constants.
markj [Wed, 10 Jan 2018 15:21:36 +0000 (15:21 +0000)]
Clarify the use of the gmirror flag mask constants.

MFC after: 1 week
Sponsored by: Dell EMC Isilon

6 years agoRetire pmtimer driver. Move time fixing into apm driver. Move
imp [Wed, 10 Jan 2018 14:59:19 +0000 (14:59 +0000)]
Retire pmtimer driver. Move time fixing into apm driver. Move
Iwasaki-san's copyright over. Remove FIXME code that couldn't possibly
work. Call tc_settime() with our estimate of the delta we've been
alseep (the one we print) to adjust the time. Not sure what to do
about callouts, so keep the small #ifdef in place there.

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

6 years agoRemove vestiges of digi(4) driver, first attempted in r305235 with
imp [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
cem [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'
scottl [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
scottl [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.
markj [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.
oshogbo [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 [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 [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 [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.
jhb [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.
jtl [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.
jhb [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.
jhb [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).
pfg [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
scottl [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
scottl [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
bdrewery [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
asomers [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>
cem [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 [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
nwhitehorn [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
kp [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.
imp [Tue, 9 Jan 2018 16:42:24 +0000 (16:42 +0000)]
Consolidate two identical copies of sysres_ids.

6 years agoFix year.
kib [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.
imp [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 [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 [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
avg [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
avg [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
avg [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.
kib [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
kib [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
kib [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'
eadler [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 [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
cem [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.
scottl [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()
scottl [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
scottl [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.
markj [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
cem [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.
jhb [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.
jhb [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.
jhb [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.
markj [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:
pfg [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.
markj [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.
pfg [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
fabient [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 [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 [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.
oshogbo [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
asomers [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 [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
asomers [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
asomers [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
jhibbits [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 [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 [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()
kp [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()
kp [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()
kp [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
kp [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.
delphij [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
eadler [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
kevans [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
kevans [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
asomers [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
kevans [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
asomers [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
manu [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.
kib [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
eadler [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