]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agousr.sbin/bhyve: only unassign a pt device after obtaining bus/slot/func
seanc [Fri, 12 Jul 2019 18:33:58 +0000 (18:33 +0000)]
usr.sbin/bhyve: only unassign a pt device after obtaining bus/slot/func

Coverity CID: 119430211943031194304
Approved by: jhb, markj
Differential Revision: https://reviews.freebsd.org/D20933

4 years agousr.sbin/bhyve: free resources when erroring out of pci_vtcon_sock_add()
seanc [Fri, 12 Jul 2019 18:20:56 +0000 (18:20 +0000)]
usr.sbin/bhyve: free resources when erroring out of pci_vtcon_sock_add()

Coverity CID: 1362880
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20916

4 years agousr.sbin/bhyve: prevent use-after-free in virtio scsi request handling
seanc [Fri, 12 Jul 2019 18:17:35 +0000 (18:17 +0000)]
usr.sbin/bhyve: prevent use-after-free in virtio scsi request handling

Coverity CID: 1393377
Approved by: araujo, jhb
Differential Revision: https://reviews.freebsd.org/D20915

4 years agousr.sbin/bhyve: don't leak a FD if the device is not a tty
seanc [Fri, 12 Jul 2019 18:13:58 +0000 (18:13 +0000)]
usr.sbin/bhyve: don't leak a FD if the device is not a tty

Coverity CID: 1194193
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20934

4 years agoApply some light cleanup to uses of pmap_pte_dirty().
markj [Fri, 12 Jul 2019 15:24:25 +0000 (15:24 +0000)]
Apply some light cleanup to uses of pmap_pte_dirty().

- Check for ATTR_SW_MANAGED before anything else.
- Use pmap_pte_dirty() in pmap_remove_pages().

No functional change intended.

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

4 years agoadd back the comment around the pending DSACK fixes.
rrs [Fri, 12 Jul 2019 11:45:42 +0000 (11:45 +0000)]
add back the comment around the pending DSACK fixes.

4 years agoDo not modify cmd pointer if it is already last opcode in the rule.
ae [Fri, 12 Jul 2019 09:59:21 +0000 (09:59 +0000)]
Do not modify cmd pointer if it is already last opcode in the rule.

MFC after: 1 week

4 years agoCorrectly truncate the rule in case when it has several action opcodes.
ae [Fri, 12 Jul 2019 09:48:42 +0000 (09:48 +0000)]
Correctly truncate the rule in case when it has several action opcodes.

It is possible, that opcode at the ACTION_PTR() location is not real
action, but action modificator like "log", "tag" etc. In this case we
need to check for each opcode in the loop to find O_EXTERNAL_ACTION.

Obtained from: Yandex LLC
MFC after: 1 week
Sponsored by: Yandex LLC

4 years agoSupport multiple serial ports per device.
phk [Fri, 12 Jul 2019 09:02:12 +0000 (09:02 +0000)]
Support multiple serial ports per device.

Enable this for the NovAtel OEMv2 GPS receiver.

Not fixed:  The receiver shows up as "<Interface 0>" in the device
tree, because that is literally what the descriptor-string is.

Reviewed by: hselasky@

4 years agoRetire the -DRELEASE_CRUNCH define.
imp [Fri, 12 Jul 2019 06:19:25 +0000 (06:19 +0000)]
Retire the -DRELEASE_CRUNCH define.

The RELEASE_CRUNCH ifdefs save about 100 bytes of text space. The
complexity is not worth it as they eliminate error messages.

Left the RELEASE_CRUNCH ifdef to eliminate a lot of stuff in place.
That saves an interesting amount of space and change some behaviors,
so absent a more detailed analysis, maintain the status quo.

4 years agousr.sbin/bhyve: unconditionally initialize the NVMe completion status
seanc [Fri, 12 Jul 2019 05:53:13 +0000 (05:53 +0000)]
usr.sbin/bhyve: unconditionally initialize the NVMe completion status

Follow-up work to improve the handling of unsupported/invalid opcodes
is being developed by chuck@.

Coverity CID: 1398928
Reviewed by: chuck
Approved by: araujo, imp
Differential Revision: https://reviews.freebsd.org/D20914

4 years agoRetire support for -DMINIMALISTIC
imp [Fri, 12 Jul 2019 05:35:45 +0000 (05:35 +0000)]
Retire support for -DMINIMALISTIC

We've not used this in years since we retired sysinstall, and it
hasn't compiled in at least a year. A full camcontrol is only 180k, so
making it smaller is not as important as it once was.

OK'd by: ken@, scottl@

4 years agousr.sbin/bhyve: free resources when erroring out of pci_vtnet_init()
seanc [Fri, 12 Jul 2019 05:19:37 +0000 (05:19 +0000)]
usr.sbin/bhyve: free resources when erroring out of pci_vtnet_init()

Coverity CID: 1402978
Approved by: vmaffione
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D20912

4 years agoThere is no SMALLER define anymore here
imp [Fri, 12 Jul 2019 05:19:06 +0000 (05:19 +0000)]
There is no SMALLER define anymore here

Stop defining SMALLER. Since we replaced cpio with libarchive version,
there's no options to make it smaller. Also, the comment about the
FreeBSD installer is obsolete. Remove them both.

4 years agoRemove unused defines since r147075
imp [Fri, 12 Jul 2019 04:44:50 +0000 (04:44 +0000)]
Remove unused defines since r147075

When the OpenBSD dhclient was brought in 14 years ago, we stopped
supporting building a reduced sized dhclient, yet retained the options
here.  Also, the OpenBSD dhclient doesn't need lint defined, so it can
go too.

4 years agoMove the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
cy [Fri, 12 Jul 2019 01:59:08 +0000 (01:59 +0000)]
Move the new ipf_pcksum6() function from ip_fil_freebsd.c to fil.c.
The reason for this is that ipftest(8), which still works on FreeBSD-11,
fails to link to it, breaking stable/11 builds.

ipftest(8) was broken (segfault) sometime during the FreeBSD-12 cycle.
glebius@ suggested we disable building it until I can get around to
fixing it. Hence this was not caught in -current.

The intention is to fix ipftest(8) as it is used by the netbsd-tests
(imported by ngie@ many moons ago) for regression testing.

MFC after: immediately

4 years agoAllow efi loader to get network params from uboot
jhibbits [Fri, 12 Jul 2019 00:54:20 +0000 (00:54 +0000)]
Allow efi loader to get network params from uboot

Summary:
efi loader does not work with static network parameters. It always uses
BOOTP/DHCP and also uses RARP as a fallback.  Problems with DHCP servers can
cause the loader to fail to populate network parameters.

Submitted by: Siddharth Tuli <siddharthtuli_gmail.com>
Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D20811

4 years agousr.sbin/bhyve: send an initialized value to wake up blocking kqueue
seanc [Thu, 11 Jul 2019 23:54:50 +0000 (23:54 +0000)]
usr.sbin/bhyve: send an initialized value to wake up blocking kqueue

This is a no-op initialization because nothing reads this value.  "This
wasn't wrong previously, but this is more correct now." -imp

Coverity CID: 1194307
Approved by: markj, imp, scottl
Differential Revision: https://reviews.freebsd.org/D20921

4 years agolibsecureboot: avoid recusion in ve_trust_init
sjg [Thu, 11 Jul 2019 22:06:59 +0000 (22:06 +0000)]
libsecureboot: avoid recusion in ve_trust_init

set our guard value immediately.
also replace call to ve_trust_init in opgp_sig.c:initialize with
call to openpgp_trust_init.

Reported by: mindal@semihalf.com
Reviewed by: jhibbits obrien
MFC after: 1 week

4 years agoAddress problems in blist_alloc introduced in r349777. The swap block allocator...
dougm [Thu, 11 Jul 2019 20:52:39 +0000 (20:52 +0000)]
Address problems in blist_alloc introduced in r349777.  The swap block allocator could become corrupted
if a retry to allocate swap space, after a larger allocation attempt failed, allocated a smaller set of free blocks
that ended on a 32- or 64-block boundary.

Add tests to detect this kind of failure-to-extend-at-boundary and prevent the associated accounting screwup.

Reported by: pho
Tested by: pho
Reviewed by: alc
Approved by: markj (mentor)
Discussed with: kib
Differential Revision: https://reviews.freebsd.org/D20893

4 years agousr.sbin/bhyve: commit miss from r349918
seanc [Thu, 11 Jul 2019 19:51:33 +0000 (19:51 +0000)]
usr.sbin/bhyve: commit miss from r349918

Submitted by: markj
Approved by: markj
Differential Revision: https://reviews.freebsd.org/D20918

4 years agousr.sbin/bhyve: free leaked memory during option parsing
seanc [Thu, 11 Jul 2019 19:41:14 +0000 (19:41 +0000)]
usr.sbin/bhyve: free leaked memory during option parsing

Also update to use strsep(3) instead of strtok(3).

Most of this commit inadvertently ended up in r349914.

Coverity CID: 1357337
Approved by: markj
PR: 233038
Differential Revision: https://reviews.freebsd.org/D20918

4 years agoRemove a tautological test for adding a rule in the block that
cy [Thu, 11 Jul 2019 19:36:18 +0000 (19:36 +0000)]
Remove a tautological test for adding a rule in the block that
adds rules.

MFC after: 1 week

4 years agoCorrect r349898. The default is add a rule.
cy [Thu, 11 Jul 2019 19:36:14 +0000 (19:36 +0000)]
Correct r349898. The default is add a rule.

MFC after: 1 week
X-MFC with: r349898

4 years agousr.sbin/bhyve: initialize return value in xhci device interrupt handler
seanc [Thu, 11 Jul 2019 19:26:35 +0000 (19:26 +0000)]
usr.sbin/bhyve: initialize return value in xhci device interrupt handler

Coverity CID: 1357340
Approved by: scottl, markj
Differential Revision: https://reviews.freebsd.org/D20917

4 years agousr.sbin/bhyve: free resources if there is an initialization error in rfb
seanc [Thu, 11 Jul 2019 19:07:45 +0000 (19:07 +0000)]
usr.sbin/bhyve: free resources if there is an initialization error in rfb

Coverity CID: 1357335
Approved by: markj, jhb
Differential Revision: https://reviews.freebsd.org/D20919

4 years agoEnsure that mds_handler always points to a valid method.
kib [Thu, 11 Jul 2019 16:22:49 +0000 (16:22 +0000)]
Ensure that mds_handler always points to a valid method.

Depending on system configuration, version, and architecture,
mds_handler might be dereferenced from doreti before
hw_mds_recalculate_boot() initialized it.  Statically assign void
method to cover all cases.

Reported by: "Schuendehuette, Matthias (LDA IT PLM)" <matthias.schuendehuette@siemens.com>
Sponsored by: The FreeBSD Foundation
MFC after: 3 days

4 years agoRestore ability to pass NULL name argument to pthread_set_name_np(3)
kib [Thu, 11 Jul 2019 16:19:33 +0000 (16:19 +0000)]
Restore ability to pass NULL name argument to pthread_set_name_np(3)
to clear the thread name.

PR: 239142
Submitted by: Lewis Donzis <lew@perftech.com>
MFC after: 3 days

4 years agoFix some ISS bit definitions for data aborts.
markj [Thu, 11 Jul 2019 15:36:59 +0000 (15:36 +0000)]
Fix some ISS bit definitions for data aborts.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agoMore fully implement the state machine.
imp [Thu, 11 Jul 2019 06:22:15 +0000 (06:22 +0000)]
More fully implement the state machine.

When a command is finished running, we must transition it from INQUEUE
to busy state. We were failing to do that, so we hit a panic when the
commands were freed. This only affects mpr, mps already did simmilar
things. Now both the polling and interrupt paths properly set BUSY as
appropriate.

4 years agoUpdate to jhb's other suggestion, use #error when
rrs [Thu, 11 Jul 2019 04:40:58 +0000 (04:40 +0000)]
Update to jhb's other suggestion, use #error when
we are missing  HPTS.

4 years agoUpdate copyright per JBH's suggestions.. thanks.
rrs [Thu, 11 Jul 2019 04:38:33 +0000 (04:38 +0000)]
Update copyright per JBH's suggestions.. thanks.

4 years agopowerpc: Only worry about the lower 32 bits of SP in a 32-bit process
jhibbits [Thu, 11 Jul 2019 03:29:25 +0000 (03:29 +0000)]
powerpc: Only worry about the lower 32 bits of SP in a 32-bit process

Summary:
Running a 32-bit process on a 64-bit POWER CPU may still use all 64-bits
in calculations, while ignoring the upper 32 bits for addressing
storage.  It so happens that some processes end up with r1 (SP) having
bit 31 set in some cases (33-bit address).  Writing out to this 33-bit
address obviosly fails.  Since the CPU ignores the upper bits, we should
as well.

sendsig() and cpu_fetch_syscall_args() appear to be the only functions
that actually rely on userspace register values for copy in/out, and
cpu_fetch_syscall_args() doesn't seem to be bitten in practice yet.

Reviewed By: luporl
Differential Revision: https://reviews.freebsd.org/D20896

4 years agoAccording to Section D5.10.3 "Maintenance requirements on changing System
alc [Thu, 11 Jul 2019 02:43:23 +0000 (02:43 +0000)]
According to Section D5.10.3 "Maintenance requirements on changing System
register values" of the architecture manual, an isb instruction should be
executed after updating ttbr0_el1 and before invalidating the TLB.  The
lack of this instruction in pmap_activate() appears to be the reason why
andrew@ and I have observed an unexpected TLB entry for an invalid PTE on
entry to pmap_enter_quick_locked().  Thus, we should now be able to revert
the workaround committed in r349442.

Reviewed by: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20904

4 years agoAdd vm_page_hold.9 to ObsoleteFiles.inc.
markj [Thu, 11 Jul 2019 02:15:50 +0000 (02:15 +0000)]
Add vm_page_hold.9 to ObsoleteFiles.inc.

Add a missing .gz suffix to pwm.9 while here.

4 years agoipfilter commands, in this case ipf(8), passes its operations and rules
cy [Thu, 11 Jul 2019 00:08:46 +0000 (00:08 +0000)]
ipfilter commands, in this case ipf(8), passes its operations and rules
via an ioctl interface. Rules can be added or removed and stats and
counters can be zeroed out. As the ipfilter interprets these
instructions or operations they are stored in an integer called
addrem (add/remove). 1 is add, 2 is remove, and 3 is clear stats and
counters. Much of this is not documented. This commit documents these
operations by replacing simple integers with a self documenting
enum along with a few basic comments.

MFC after: 1 week

4 years agoRename pmap_page_dirty() to pmap_pte_dirty().
markj [Wed, 10 Jul 2019 22:52:26 +0000 (22:52 +0000)]
Rename pmap_page_dirty() to pmap_pte_dirty().

This is a precursor to implementing dirty bit management.

Discussed with: alc
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

4 years agotelnet: fix minor style violation
philip [Wed, 10 Jul 2019 22:36:14 +0000 (22:36 +0000)]
telnet: fix minor style violation

While here also fix a very unlikely NULL pointer dereference.

Submitted by: Shawn Webb <shawn.webb@hardenedbsd.org>

4 years agoEnforce a 4GB DMA boundary on isci(4)
imp [Wed, 10 Jul 2019 22:23:59 +0000 (22:23 +0000)]
Enforce a 4GB DMA boundary on isci(4)

This device cannot cross a 4GB boundary with DMA.  Removing the
boundary in r346386 resulted in low frequency memory corruption on
machines with isci(4) controllers.

Submitted by: gallatin@
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20910

4 years agoThis commit updates rack to what is basically being used at NF as
rrs [Wed, 10 Jul 2019 20:40:39 +0000 (20:40 +0000)]
This commit updates rack to what is basically being used at NF as
well as sets in some of the groundwork for committing BBR. The
hpts system is updated as well as some other needed utilities
for the entrance of BBR. This is actually part 1 of 3 more
needed commits which will finally complete with BBRv1 being
added as a new tcp stack.

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

4 years agoInherit P2_PROTMAX_{ENABLE,DISABLE} across fork().
markj [Wed, 10 Jul 2019 19:57:48 +0000 (19:57 +0000)]
Inherit P2_PROTMAX_{ENABLE,DISABLE} across fork().

Thus, when using proccontrol(1) to disable implicit application of
PROT_MAX within a process, child processes will inherit this setting.

Discussed with: kib
MFC with: r349609
Sponsored by: The FreeBSD Foundation

4 years agoReorganize the SRCS lists as one file per line, and then alphabetize them.
ian [Wed, 10 Jul 2019 19:32:50 +0000 (19:32 +0000)]
Reorganize the SRCS lists as one file per line, and then alphabetize them.
No functional changes.

4 years agotelnet: fix a couple of snprintf() buffer overflows
philip [Wed, 10 Jul 2019 17:42:04 +0000 (17:42 +0000)]
telnet: fix a couple of snprintf() buffer overflows

Obtained from: Juniper Networks
MFC after: 1 week

4 years agoFix compile errors with the CI20
imp [Wed, 10 Jul 2019 17:21:59 +0000 (17:21 +0000)]
Fix compile errors with the CI20

Fix mutex includes and fix a typo. The CI20 kernel is not built as
part of universe.

PR: 239115
Submitted by: Kai Nacke

4 years agoDe-pollute arm's sysarch.h.
ian [Wed, 10 Jul 2019 14:34:52 +0000 (14:34 +0000)]
De-pollute arm's sysarch.h.

Instead of including stdint.h for uintptr_t, include sys/_types.h and use
__types for everything that isn't a native C keyword type.

Remove the #include of cdefs.h.  It appears after the include of armreg.h
which has a precondition of cdefs.h being included before it, so everyone
including sysarch.h is already including cdefs.h.  (When armv5 support
goes away, there will be no need include armreg.h here either.)

Unfortunately, the unprefixed struct member names "addr" and "len" cannot
be changed, because 3rd-party software is relying on them (libcompiler_rt
is one known consumer).

4 years agolinuxcommon: add module version
avg [Wed, 10 Jul 2019 13:47:10 +0000 (13:47 +0000)]
linuxcommon: add module version

MFC after: 2 weeks

4 years ago[PPC64] pseries: fix realmaxaddr calculation
luporl [Wed, 10 Jul 2019 13:36:17 +0000 (13:36 +0000)]
[PPC64] pseries: fix realmaxaddr calculation

On POWER9/pseries, QEMU passes several regions of memory,
instead of a single region containing all memory, as the
code was expecting.

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

4 years agoowc_gpiobus: small formatting cleanup
avg [Wed, 10 Jul 2019 12:40:07 +0000 (12:40 +0000)]
owc_gpiobus: small formatting cleanup

MFC after: 1 week

4 years agoLet linuxulator mprotect mask unsupported bits before calling kern_mprotect.
tijl [Wed, 10 Jul 2019 08:19:33 +0000 (08:19 +0000)]
Let linuxulator mprotect mask unsupported bits before calling kern_mprotect.

After r349240 kern_mprotect returns EINVAL for unsupported bits in the prot
argument.  Linux rtld uses PROT_GROWSDOWN and PROT_GROWS_UP when marking the
stack executable.  Mask these bits like kern_mprotect used to do.  For other
unsupported bits EINVAL is returned like Linux does.

Reviewed by: trasz, brooks
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20864

4 years agoApply a workaround to be able to build clang 8.0.0 headers with clang
dim [Wed, 10 Jul 2019 05:57:37 +0000 (05:57 +0000)]
Apply a workaround to be able to build clang 8.0.0 headers with clang
3.4.1, which is still in the stable/10 branch.

It looks like clang 3.4.1 implements static_asserts by instantiating a
temporary static object, and if those are in an anonymous union, it
results in "error: anonymous union can only contain non-static data
members".

To work around this implementation limitation, move the static_asserts
in question out of the anonymous unions.

This should make building the latest stable/11 from stable/10 possible
again.

Reported by: Mike Tancsa <mike@sentex.net>
MFC after: 3 days

4 years agoAdd support for RTL8156, 2.5GbE USB network controller, to if_cdce(4).
hrs [Wed, 10 Jul 2019 05:45:50 +0000 (05:45 +0000)]
Add support for RTL8156, 2.5GbE USB network controller, to if_cdce(4).
This chip can be found in Planex USB-LAN2500R.

4 years agopowerpc: Clamp 32-bit binaries to 32-bit MAXUSER
jhibbits [Wed, 10 Jul 2019 04:09:15 +0000 (04:09 +0000)]
powerpc: Clamp 32-bit binaries to 32-bit MAXUSER

sv_maxuser specifies the maximum addressable space for user space.  Presently
this is all 64-bits worth, which is impossible for a 32-bit process.

This bug has existed since the initial import of powerpc64 in 2010.

MFC after: 2 weeks

4 years agoAdd pwm.9, it was also deleted during the big round of pwm changes.
ian [Wed, 10 Jul 2019 03:45:23 +0000 (03:45 +0000)]
Add pwm.9, it was also deleted during the big round of pwm changes.

4 years agoCorrect definitions in sys.opencrypto.runtests.main for 32bit platform
lwhsu [Wed, 10 Jul 2019 01:08:08 +0000 (01:08 +0000)]
Correct definitions in sys.opencrypto.runtests.main for 32bit platform

Reviewed by: cem, jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20894

4 years agoUse 'retval' label for first error in syscallenter().
jhb [Tue, 9 Jul 2019 23:58:12 +0000 (23:58 +0000)]
Use 'retval' label for first error in syscallenter().

This is more consistent with the rest of the function and lets us
unindent most of the function.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20897

4 years agocxgbe(4): Clear the freelist statistics in the clearstats ioctl.
np [Tue, 9 Jul 2019 22:24:22 +0000 (22:24 +0000)]
cxgbe(4): Clear the freelist statistics in the clearstats ioctl.

Move all clearstats code into its own function while here.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoupdate calendar.freebsd
vmaffione [Tue, 9 Jul 2019 22:11:15 +0000 (22:11 +0000)]
update calendar.freebsd

MFC after: 1 week

4 years agobhyve: net_backends.c: add missing __FBSDID
vmaffione [Tue, 9 Jul 2019 22:05:58 +0000 (22:05 +0000)]
bhyve: net_backends.c: add missing __FBSDID

Reviewed by: jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20883

4 years agobhyve: add missing license identifiers in net_utils and net_backend
vmaffione [Tue, 9 Jul 2019 22:04:33 +0000 (22:04 +0000)]
bhyve: add missing license identifiers in net_utils and net_backend

Reviewed by: jhb, markj, imp
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20874

4 years agoIntroduce pmap_clear(), which zeroes a page table entry, and use it, instead
alc [Tue, 9 Jul 2019 20:28:53 +0000 (20:28 +0000)]
Introduce pmap_clear(), which zeroes a page table entry, and use it, instead
of pmap_load_clear(), in places where we don't care about the page table
entry's prior contents.

Eliminate an unnecessary pmap_load() from pmap_remove_all().  Instead, use
the value returned by the pmap_load_clear() on the very next line.  (In the
future, when we support "hardware dirty bit management", using the value
from the pmap_load() rather than the pmap_load_clear() would have actually
been an error because the dirty bit could potentially change between the
pmap_load() and the pmap_load_clear().)

A KASSERT() in pmap_enter(), which originated in the amd64 pmap, was meant
to check the value returned by the pmap_load_clear() on the previous line.
However, we were ignoring the value returned by the pmap_load_clear(), and
so the KASSERT() was not serving its intended purpose.  Use the value
returned by the pmap_load_clear() in the KASSERT().

MFC after: 2 weeks

4 years agocxgbe(4): Use the simplest configuration possible when falling back from
np [Tue, 9 Jul 2019 19:32:31 +0000 (19:32 +0000)]
cxgbe(4): Use the simplest configuration possible when falling back from
the default configuration.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoMFV: r349861
jkim [Tue, 9 Jul 2019 18:02:36 +0000 (18:02 +0000)]
MFV: r349861

Import ACPICA 20190703.

4 years agohyperv/vmbus: Fix the wrong size in ndis_offload structure
whu [Tue, 9 Jul 2019 08:21:14 +0000 (08:21 +0000)]
hyperv/vmbus: Fix the wrong size in ndis_offload structure

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

4 years agohyperv/vmbus: Update VMBus version 4.0 and 5.0 support.
whu [Tue, 9 Jul 2019 07:24:18 +0000 (07:24 +0000)]
hyperv/vmbus: Update VMBus version 4.0 and 5.0 support.

Add VMBus protocol version 4.0. and 5.0 to support Windows 10 and newer HyperV hosts.

For VMBus 4.0 and newer HyperV, the netvsc gpadl teardown must be done after vmbus close.

Submitted by: whu
MFC after: 2 weeks
Sponsored by: Microsoft

4 years agomld6query: Fix typo s/linkocal/linklocal/
meta [Mon, 8 Jul 2019 22:20:25 +0000 (22:20 +0000)]
mld6query: Fix typo s/linkocal/linklocal/

PR: 239039
Approved by: markj

4 years agoPut USB ACPI code into own module, uacpi.ko.
hselasky [Mon, 8 Jul 2019 20:53:25 +0000 (20:53 +0000)]
Put USB ACPI code into own module, uacpi.ko.
The code needs more testing before being enabled by default.

Sponsored by: Mellanox Technologies

4 years agoRestore the ability for i2c slave devices to do IO from their probe method.
ian [Mon, 8 Jul 2019 20:26:56 +0000 (20:26 +0000)]
Restore the ability for i2c slave devices to do IO from their probe method.

r348164 added code to iicbus_request_bus/iicbus_release_bus to automatically
call device_busy()/device_unbusy() as part of aquiring exclusive use of the
bus (so modules can't be unloaded while the bus is exclusively owned and/or
IO is in progress).  That broke the ability to do i2c IO from a slave device
probe method, because the slave isn't attached yet, so calling device_busy()
triggers a sanity-check panic for trying to busy a non-attached device.

Now we check whether the device status is < DS_ATTACHING, and if so we busy
the iicbus rather than the slave device.  I think this leaves a small window
where a module could be unloaded while probing is in progress.  But I think
that's true of all devices, and probably should be fixed by introducing a
DS_PROBING state for devices, and handling that at various points in the
newbus code.

4 years agoFix bugs in recovery path and improve cm tracking
imp [Mon, 8 Jul 2019 20:20:01 +0000 (20:20 +0000)]
Fix bugs in recovery path and improve cm tracking

Eliminate the TIMEDOUT state. This state really conveyed two different
concepts: I timed out during recovery (and my command got put on the
recovery queue), and I timed out diring discovery (which doesn't).
Separate those two concepts into two flags. Use the TIMEDOUT flag to
fail requests as timed out. Use the on queue flag to remove them from
the queue.

In mps_intr_locked for MPI2_RPY_DESCRIPT_FLAGS_ADDRESS_REPLY message
type, when completing commands, ignore the ones that are not in state
INQUEUE. They were already completed as part of the recovery
process. When we complete them twice, we wind up with entries on the
free queue that are marked as busy, trigging asserts.

Reviewed by: scottl (earlier version, just for mpr)
Differential Revision: https://reviews.freebsd.org/D20785

4 years ago- Fix gcc build for superio(4)
lwhsu [Mon, 8 Jul 2019 20:01:28 +0000 (20:01 +0000)]
- Fix gcc build for superio(4)
- Change string mapping of SUPERIO_DEV_NONE to distinguish from SUPERIO_DEV_MAX

Reviewed by: imp
Discussed with: avg, imp, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20880

4 years agoFix gcc build for cxgbe(4)
lwhsu [Mon, 8 Jul 2019 19:59:15 +0000 (19:59 +0000)]
Fix gcc build for cxgbe(4)

Reviewed by: jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20879

4 years agoMerge the vm_page hold and wire mechanisms.
markj [Mon, 8 Jul 2019 19:46:20 +0000 (19:46 +0000)]
Merge the vm_page hold and wire mechanisms.

The hold_count and wire_count fields of struct vm_page are separate
reference counters with similar semantics.  The remaining essential
differences are that holds are not counted as a reference with respect
to LRU, and holds have an implicit free-on-last unhold semantic whereas
vm_page_unwire() callers must explicitly determine whether to free the
page once the last reference to the page is released.

This change removes the KPIs which directly manipulate hold_count.
Functions such as vm_fault_quick_hold_pages() now return wired pages
instead.  Since r328977 the overhead of maintaining LRU for wired pages
is lower, and in many cases vm_fault_quick_hold_pages() callers would
swap holds for wirings on the returned pages anyway, so with this change
we remove a number of page lock acquisitions.

No functional change is intended.  __FreeBSD_version is bumped.

Reviewed by: alc, kib
Discussed with: jeff
Discussed with: jhb, np (cxgbe)
Tested by: pho (previous version)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19247

4 years agoWork around devices which return all zeros for reads of existing MSI-X
imp [Mon, 8 Jul 2019 19:38:49 +0000 (19:38 +0000)]
Work around devices which return all zeros for reads of existing MSI-X
table VCTRL registers.

Unconditionally program the MSI-X vector control Mask field for MSI-X
table entries without regarud for Mask's previous value. Some devices
return all zeros on reads of the VCTRL registers, which would cause us
to skip disabling interrupts. This fixes the Samsung SM961/PM961 SSDs
which are return zero starting from offset 0x3084 within the memory
region specified by BAR0, even when they are active MSI-X vectors.

The Illumos kernel writes these unconditionally to 0 or 1. However,
section 6.8.2.9 of the PCI Local Bus 3.0 spec (dated Feb 3, 2004)
states for bits 31::01:
After reset, the state of these bits must be 0. However, for
potential future use, software must preserve the value of
these reserved bits when modifying the value of other Vector
Control bits. If software modifies the value of these reserved
bits, the result is undefined."
so we always set or clear the Mask bit, but otherwise preserves the
old value.

PR: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211713
Reviewed By: imp, jhb
Submitted by: Ka Ho Ng
MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D20873

4 years agoMinor code cleanup of USB ACPI code after r349161.
hselasky [Mon, 8 Jul 2019 19:26:05 +0000 (19:26 +0000)]
Minor code cleanup of USB ACPI code after r349161.

While at it fix an invalid memory access issue when attaching external
USB HUBs, which are not mapped by ACPI, due to missing status check
when calling AcpiGetObjectInfo() from acpi_usb_hub_port_probe_cb().

Sponsored by: Mellanox Technologies

4 years agoUpdate frtuc struct comments. It not only defines TCP things we are
cy [Mon, 8 Jul 2019 19:11:49 +0000 (19:11 +0000)]
Update frtuc struct comments. It not only defines TCP things we are
interested in but also UDP.

While at it document the source and destination port variables.

MFC after: 3 days

4 years agoCorrect the description for the low port in the port compare struct.
cy [Mon, 8 Jul 2019 19:11:35 +0000 (19:11 +0000)]
Correct the description for the low port in the port compare struct.

Adjust the high port description to match that of the low port
description.

MFC after: 3 days

4 years agoElide the vm_reserv_free_page() call when PG_PCPU_CACHE is set.
markj [Mon, 8 Jul 2019 19:02:40 +0000 (19:02 +0000)]
Elide the vm_reserv_free_page() call when PG_PCPU_CACHE is set.

Pages with PG_PCPU_CACHE set cannot have been allocated from a
reservation, so as an optimization, skip the call to
vm_reserv_free_page() in this case.  Otherwise, the access of
the corresponding reservation structure often results in a cache
miss.

Reviewed by: alc, kib
Discussed with: jeff
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20859

4 years agoAdd a per-CPU page cache per VM free pool.
markj [Mon, 8 Jul 2019 18:56:30 +0000 (18:56 +0000)]
Add a per-CPU page cache per VM free pool.

Some workloads benefit from having a per-CPU cache for
VM_FREEPOOL_DIRECT pages.

Reviewed by: dougm, kib
Discussed with: alc, jeff
MFC after: 2 weeks
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D20858

4 years agoCall device_unbusy() on the error exit path, because if iicbus_request_bus()
ian [Mon, 8 Jul 2019 18:29:37 +0000 (18:29 +0000)]
Call device_unbusy() on the error exit path, because if iicbus_request_bus()
returns an error, iicbus_release_bus() is not going to be called.

4 years agoIgnore kern.vt.splash_cpu without graphics
vangyzen [Mon, 8 Jul 2019 13:46:26 +0000 (13:46 +0000)]
Ignore kern.vt.splash_cpu without graphics

When the system has no graphical console, such as bhyve in common
configurations, ignore kern.vt.splash_cpu, instead of panicking
on INVARIANTS kernels.

Reviewed by: cem dumbbell
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D20877

4 years ago[PPC] Add missing SLB allocation KASSERT
luporl [Mon, 8 Jul 2019 13:01:54 +0000 (13:01 +0000)]
[PPC] Add missing SLB allocation KASSERT

Although PPC SLB code doesn't handle allocation failures,
which are rare, in most places it asserts that the pointer
returned by uma_zalloc() is not NULL, making it easier to
identify the failure and avoiding an invalid pointer dereference.

This change simply adds a missing KASSERT in SLB code.

4 years agoEliminate spurious periodic.daily error message for rotating accounting log.
ian [Sun, 7 Jul 2019 17:15:45 +0000 (17:15 +0000)]
Eliminate spurious periodic.daily error message for rotating accounting log.

In 2011, r218961 removed local code for rotating logs in favor of using the
rotate_log command in etc/rc.d/accounting.  If the accounting service is
activated then subsequently de-activated in rc.conf but still remains active
in periodic.conf, then you get an error message every day in the periodic
jobs about being unable to rotate the logs.

With this change to use "onerotate_log", the log rotation will happen the
first time periodic daily runs after accounting was disabled but periodic
accounting was left enabled.  After that happens once, the /var/account/acct
will no longer exist, which results in a different path through the periodic
code and no more error messages will appear (unless daily_show_badconfig is
set, in which case the admin will be told that periodic security processing
is enabled but the accounting file is not present).

This is only a partial fix for the problems reported in PR 202203.

PR: 202203

4 years agobhyve: abstraction for network backends
vmaffione [Sun, 7 Jul 2019 12:15:24 +0000 (12:15 +0000)]
bhyve: abstraction for network backends

Bhyve can currently emulate two virtual NICs, namely virtio-net and e1000,
and connect to the host network through two backends, namely tap and netmap.
However, there is no interface between virtual NIC functionalities and
backend functionalities. As a result, the backend code is duplicated between
the two virtual NIC implementations and also within the same virtual NIC.
Also, e1000 cannot currently use netmap as a backend.
This patch introduces a network backend API between virtio-net/e1000 and
tap/netmap, to improve code reuse and add missing functionalities.
Virtual NICs and backends can negotiate virtio-net features, such as checksum
offload and TSO. If the backend supports the features, it will propagate this
information to the guest, so that the latter can make use of them. Currently,
only netmap VALE ports support the features, but support should be added to
tap in the future.

Reviewed by: jhb, bryanv
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D20659

4 years agoAdd additional check for 'blocks per group' and 'fragments per group' superblock...
fsu [Sun, 7 Jul 2019 08:58:02 +0000 (08:58 +0000)]
Add additional check for 'blocks per group' and 'fragments per group' superblock fields.

These fields will not be equal only in case if bigalloc filesystem feature is turned on.
This feature is not supported for now.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-27-EXT2-12: Denial of Service in openat-0 (vm_fault_hold/ext2_clusteracct)

MFC after: 2 weeks

4 years agoRemove ufs fragments logic.
fsu [Sun, 7 Jul 2019 08:56:13 +0000 (08:56 +0000)]
Remove ufs fragments logic.

The ext2fs fragments are different from ufs fragments.
In case of ext2fs the fragment should be equal or more then block size.
The values more than block size are used only in case of bigalloc feature, which is does not supported for now.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-22-EXT2-9: Denial of service in ftruncate-0 (ext2_balloc)

MFC after: 2 weeks

4 years agoRemove unneeded mount point unlock call.
fsu [Sun, 7 Jul 2019 08:53:52 +0000 (08:53 +0000)]
Remove unneeded mount point unlock call.

Reported by:    Christopher Krah, Thomas Barabosch, and Jan-Niclas Hilgert of Fraunhofer FKIE
Reported as:    FS-11-EXT2-6: Denial Of Service in write-1 (ext2_balloc)

MFC after: 2 weeks

4 years agoA style-related change, r349791, made unclear the meaning of a
dougm [Sun, 7 Jul 2019 06:57:04 +0000 (06:57 +0000)]
A style-related change, r349791, made unclear the meaning of a
comment. Rewrite that comment to improve its clarity.

Reported by: cem
Reviewed by: alc, cem
Approved by: kib, markj (mentors, implicit)
Differential Revision: https://reviews.freebsd.org/D20871

4 years agoThree changes to pmap_enter():
alc [Sun, 7 Jul 2019 06:06:48 +0000 (06:06 +0000)]
Three changes to pmap_enter():

1. Use _pmap_alloc_l3() instead of pmap_alloc_l3() in order to handle the
possibility that a superpage mapping for "va" was created while we slept.
(This is derived from the amd64 version.)

2. Eliminate code for allocating kernel page table pages.  Kernel page
table pages are preallocated by pmap_growkernel().

3. Eliminate duplicated unlock operations when KERN_RESOURCE_SHORTAGE is
returned.

MFC after: 2 weeks

4 years agoDocument atomicity for read(2) and write(2).
kib [Sat, 6 Jul 2019 20:31:37 +0000 (20:31 +0000)]
Document atomicity for read(2) and write(2).

Take part of the text from POSIX 2018 edition and describe the
atomicity requirements for read and write syscalls.  See p1003.1-2018,
Vol.2, 2.9.7 Threads interaction with Regular File Operations.

Reviewed by: asomers
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Differential revision: https://reviews.freebsd.org/D20867

4 years agoUpgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
dim [Sat, 6 Jul 2019 18:02:29 +0000 (18:02 +0000)]
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt, libc++,
libunwind and openmp to the upstream release_80 branch r364487
(effectively, 8.0.1 rc3).  The 8.0.1 release will most likely
have no further changes.

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

4 years agoFix style(9) violations involving division by PAGE_SIZE.
dougm [Sat, 6 Jul 2019 15:55:16 +0000 (15:55 +0000)]
Fix style(9) violations involving division by PAGE_SIZE.

Reviewed by: alc
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20847

4 years agoChange blist_next_leaf_alloc so that it can examine more than one leaf
dougm [Sat, 6 Jul 2019 06:15:03 +0000 (06:15 +0000)]
Change blist_next_leaf_alloc so that it can examine more than one leaf
after the one where the possible block allocation begins, and allocate
a larger number of blocks than the current limit. This does not affect
the limit on minimum allocation size, which still cannot exceed
BLIST_MAX_ALLOC.

Use this change to modify swp_pager_getswapspace and its callers, so
that they can allocate more than BLIST_MAX_ALLOC blocks if they are
available.

Tested by: pho
Approved by: markj (mentor)
Differential Revision: https://reviews.freebsd.org/D20579

4 years agoRestructure cache_handle_range to avoid repeated barriers. Specifically,
alc [Fri, 5 Jul 2019 20:01:06 +0000 (20:01 +0000)]
Restructure cache_handle_range to avoid repeated barriers.  Specifically,
restructure cache_handle_range so that all of the data cache operations are
performed before any instruction cache operations.  Then, we only need one
barrier between the data and instruction cache operations and one barrier
after the instruction cache operations.

On an Amazon EC2 a1.2xlarge instance, this simple change reduces the time
for a "make -j8 buildworld" by 9%.

Reviewed by: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20848

4 years agoBased on work posted at https://reviews.freebsd.org/D13484, change
dougm [Fri, 5 Jul 2019 16:49:34 +0000 (16:49 +0000)]
Based on work posted at https://reviews.freebsd.org/D13484, change
swap_pager_swapoff_object and swp_pager_force_pagein so that they can
page in multiple pages at a time to a swap device, rather than doing
one I/O operation for each page.

Tested by: pho
Submitted by: ota_j.email.ne.jp (Yoshihiro Ota)
Reviewed by: alc, markj, kib
Approved by: kib, markj (mentors)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D20635

4 years agoMerge r349526 from amd64. When we protect an L3 entry, we only call
alc [Fri, 5 Jul 2019 05:23:23 +0000 (05:23 +0000)]
Merge r349526 from amd64.  When we protect an L3 entry, we only call
vm_page_dirty() when, in fact, we are write protecting the page and the L3
entry has PTE_D set.  However, pmap_protect() was always calling
vm_page_dirty() when an L2 entry has PTE_D set.  Handle L2 entries the
same as L3 entries so that we won't perform unnecessary calls to
vm_page_dirty().

Simplify the loop calling vm_page_dirty() on L2 entries.

4 years agonetmap: Remove pointer leakage in netmap_mem2.c
vmaffione [Thu, 4 Jul 2019 21:31:49 +0000 (21:31 +0000)]
netmap: Remove pointer leakage in netmap_mem2.c

PR: 238641
Submitted by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed by: vmaffione
MFC after: 1 week

4 years agonetmap: fix kernel pointer printing in netmap_generic.c
vmaffione [Thu, 4 Jul 2019 21:11:45 +0000 (21:11 +0000)]
netmap: fix kernel pointer printing in netmap_generic.c

Print the adapter name rather than the address of the adapter
to avoid kernel address leakage.

PR: Bug 238642
Submitted by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed by: vmaffione
MFC after: 1 week

4 years agoUpdate Linux compat version to 2.6.36
emaste [Thu, 4 Jul 2019 20:42:08 +0000 (20:42 +0000)]
Update Linux compat version to 2.6.36

New system calls between 2.6.32 and 2.6.26 are already implemented.

This should be mostly NFC as far as contemporary Linux applications are
concerned though, as Linux kernel 3.2 is the oldest supported by a
number of popular distros today; work is in progress by others to enable
support for those applications.

Discussed with: trasz
MFC after: 1 month

4 years agoReturn ENOTSUP for Linux FS_IOC_FIEMAP ioctl.
trasz [Thu, 4 Jul 2019 20:16:04 +0000 (20:16 +0000)]
Return ENOTSUP for Linux FS_IOC_FIEMAP ioctl.

Linux man(1) calls it for no good reason; this avoids the console spam
(eg '(man): ioctl fd=4, cmd=0x660b ('f',11) is not implemented').

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20690

4 years agoAdd support for PTRACE_O_TRACEEXIT to linuxulator ptrace(2).
trasz [Thu, 4 Jul 2019 19:46:58 +0000 (19:46 +0000)]
Add support for PTRACE_O_TRACEEXIT to linuxulator ptrace(2).
This fixes strace 4.25 from Ubuntu 19.04.

Reviewed by: emaste
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20689

4 years agoImplement PTRACE_GETSIGINFO. This makes Linux strace(1) quieter
trasz [Thu, 4 Jul 2019 19:44:13 +0000 (19:44 +0000)]
Implement PTRACE_GETSIGINFO.  This makes Linux strace(1) quieter
in some cases (strace -f man id > /dev/null).

Reviewed by: dchagin
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20691