]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
5 years agotests/sys/opencrypto: fix whitespace per PEP8
ngie [Sat, 20 Apr 2019 15:43:28 +0000 (15:43 +0000)]
tests/sys/opencrypto: fix whitespace per PEP8

Replace hard tabs with four-character indentations, per PEP8.

This is being done to separate stylistic changes from the tests from functional
ones, as I accidentally introduced a bug to the tests when I used four-space
indentation locally.

No functional change.

MFC after: 2 months
Approved by: emaste (mentor: implicit blanket approval for trivial fixes)

5 years agoUse symlinks for kernel modules rather than hardlinks
asomers [Sat, 20 Apr 2019 12:51:05 +0000 (12:51 +0000)]
Use symlinks for kernel modules rather than hardlinks

When aliasing a kernel module to a different name (ie if_igb for if_em),
it's better to use symlinks than hard links. kldxref will omit entries for
the links, ensuring that the loaded module has the correct name.

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

5 years agoExport cpu_core from opensolaris.ko.
markj [Sat, 20 Apr 2019 11:34:53 +0000 (11:34 +0000)]
Export cpu_core from opensolaris.ko.

It is referenced by dtrace*.ko.

PR: 191462
Submitted by: me.freebsd@cgf.cx
MFC after: 1 week

5 years agoSpecify using Python2, these .py files have not been converted to use Python3
lwhsu [Sat, 20 Apr 2019 07:32:29 +0000 (07:32 +0000)]
Specify using Python2, these .py files have not been converted to use Python3
yet, but the default Python version in ports has been switched to 3.

Sponsored by: The FreeBSD Foundation

5 years agoStart to reduce the number of #ifdef EFI_ZFS_BOOT
imp [Sat, 20 Apr 2019 05:31:56 +0000 (05:31 +0000)]
Start to reduce the number of #ifdef EFI_ZFS_BOOT

There's a number of EFI_ZFS_BOOT #ifdefs that aren't needed, or can be
eliminated with some trivial #defines. Remove the EFI_ZFS_BOOT ifdefs
that aren't needed. Replace libzfs.h include which is not safe to
include without EFI_ZFS_BOOT with efizfs.h which is and now
conditionally included libzfs.h. Define efizfs_set_preferred away
and define efi_zfs_probe to NULL when ZFS is compiled out.

5 years agoAdd SY8106A Buck Regulator and Allwinner CIR devices to GENERIC arm64 kernel.
ganbold [Sat, 20 Apr 2019 03:21:47 +0000 (03:21 +0000)]
Add SY8106A Buck Regulator and Allwinner CIR devices to GENERIC arm64 kernel.

5 years agocron(8): schedule interval jobs that get loaded during execution
kevans [Sat, 20 Apr 2019 02:54:20 +0000 (02:54 +0000)]
cron(8): schedule interval jobs that get loaded during execution

Jobs using the @<second> syntax currently only get executed if they exist
when cron is started. The simplest reproducer of this is:

echo '@20 root echo "Hello!"' >> /etc/cron.d/myjob

myjob will get loaded at the next second==0, but this echo job will not
run until cron restarts. These jobs are normally handled in
run_reboot_jobs(), which sets e->lastexit of INTERVAL jobs to the startup
time so they run 'n' seconds later.

Fix this by special-casing TargetTime > 0 in the database load. Preexisting
jobs will be handled at startup during run_reboot_jobs as normal, but if
we've reloaded a database during runtime we'll hit this case and set
e->lastexit to the current time when we process it. They will then run every
'n' seconds from that point, and a full restart of cron is no longer
required to make these jobs work.

Reported by: Juraj Lutter (otis_sk.freebsd.org)
Reviewed by: allanjude, bapt, bjk (earlier version), Juraj Lutter
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D19924

5 years agopowerpc64/powernv: Relax flash block write requirements
jhibbits [Sat, 20 Apr 2019 02:44:38 +0000 (02:44 +0000)]
powerpc64/powernv: Relax flash block write requirements

Since writes don't necessarily need to be on erase-block boundaries, we can
relax the block size and alignments down to sector size.  If it needs to be
erased, opalflash_erase() will check proper alignment and size.

5 years agoAdd support for the ModeSetMasked attribute to the NFSv4.1 server.
rmacklem [Fri, 19 Apr 2019 23:35:08 +0000 (23:35 +0000)]
Add support for the ModeSetMasked attribute to the NFSv4.1 server.

I do not know of an extant NFSv4.1 client that currently does a Setattr
operation for the ModeSetMasked, but it has been discussed on the linux-nfs
mailing list.
This patch adds support for doing a Setattr of ModeSetMasked, so that it
will work for any future NFSv4.1 client that chooses to do so.
Tested via a hacked FreeBSD NFSv4.1 client.

MFC after: 2 weeks

5 years agoReplace "vp" with NULL to make the code more readable.
rmacklem [Fri, 19 Apr 2019 23:27:23 +0000 (23:27 +0000)]
Replace "vp" with NULL to make the code more readable.

At the time of this nfsv4_sattr() call, "vp == NULL", so this patch doesn't
change the semantics, but I think it makes the code more readable.
It also makes it consistent with the nfsv4_sattr() call a few lines above
this one. Found during code inspection.

MFC after: 2 weeks

5 years agoTest SHA2-224-HMAC now that OCF supports it.
jhb [Fri, 19 Apr 2019 22:20:42 +0000 (22:20 +0000)]
Test SHA2-224-HMAC now that OCF supports it.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D19882

5 years agoRevert r346410 and r346411
cem [Fri, 19 Apr 2019 22:08:17 +0000 (22:08 +0000)]
Revert r346410 and r346411

libkern in .PATH has too many filename conflicts with libc and my -DNO_CLEAN
tinderbox didn't catch that ahead of time.  Mea culpa.

5 years agoSync cryptographic algorithm constants with current cryptodev.h.
jhb [Fri, 19 Apr 2019 21:58:51 +0000 (21:58 +0000)]
Sync cryptographic algorithm constants with current cryptodev.h.

Reviewed by: cem
MFC after: 2 weeks
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D19881

5 years agoFix copying of overlapping bitmaps. The cases of copying within the
bde [Fri, 19 Apr 2019 20:29:49 +0000 (20:29 +0000)]
Fix copying of overlapping bitmaps.  The cases of copying within the
screen bitmap and within a single MEMBUF were broken when first source
line is before the first destination line and the sub-bitmaps overlap.

The fix just copies horizontal lines in reverse order when the first
source line is before the first destination line.  This switches
directions unnecessarily in some cases, but the switch is about as
fast as doing a precise detection of overlaps.  When the first lines
are the same, there can be undetected overlap in the horizontal
direction.  The old code already handles this mostly accidentally by
using bcopy() for MEMBUFs and by copying through a temporary buffer
for the screen bitmap although the latter is sub-optimal in direct
modes.

5 years agokernel build: Disable unhelpful GCC warning (tripped after r346352)
cem [Fri, 19 Apr 2019 20:08:45 +0000 (20:08 +0000)]
kernel build: Disable unhelpful GCC warning (tripped after r346352)

-Wformat-zero-length does not highlight any particularly wrong code and it
is especially meaningless for device_printf().  Turn it off entirely to
remove a source of false positives.

Sponsored by: Dell EMC Isilon

5 years agoBump __FreeBSD_version after r346410
cem [Fri, 19 Apr 2019 20:06:22 +0000 (20:06 +0000)]
Bump __FreeBSD_version after r346410

5 years agolibkern: Bring in arc4random_uniform(9) from libc
cem [Fri, 19 Apr 2019 20:05:47 +0000 (20:05 +0000)]
libkern: Bring in arc4random_uniform(9) from libc

It is a useful arc4random wrapper in the kernel for much the same reasons as
in userspace.  Move the source to libkern (because kernel build is
restricted to sys/, but userspace can include any file it likes) and build
kernel and libc versions from the same source file.

Copy the documentation from arc4random_uniform(3) to the section 9 page.

While here, add missing arc4random_buf(9) symlink.

Sponsored by: Dell EMC Isilon

5 years agoAdd wrapper functions to convert strings to EFI_DEVICE_PATH
imp [Fri, 19 Apr 2019 19:45:19 +0000 (19:45 +0000)]
Add wrapper functions to convert strings to EFI_DEVICE_PATH

In anticipation of new functionality, create routines to convert char *
and a CHAR16 * to a EFI_DEVICE_PATH
EFI_DEVICE_PATH *efi_name_to_devpath(const char *path);
EFI_DEVICE_PATH *efi_name_to_devpath16(CHAR16 *path);
void efi_devpath_free(EFI_DEVICE_PATH *dp);
The first two return an EFI_DEVICE_PATH for the passed in paths. The
third frees up the storage the first two return when the caller is
done with it.

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

5 years agoAdd UEFI definitions related to converting string to DEVICE_PATH
imp [Fri, 19 Apr 2019 19:45:15 +0000 (19:45 +0000)]
Add UEFI definitions related to converting string to DEVICE_PATH

Add definitions from UEFI 2.7 Errata B standards doc for converting a
text string to a device path. Added clearly missing 'e' at the end of
Device to resolve mismatch in that document in
EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL element names.

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

5 years agoAdd define for CONST.
imp [Fri, 19 Apr 2019 19:44:59 +0000 (19:44 +0000)]
Add define for CONST.

Newer interfaces take CONST parameters, so define CONST to minimize
differences between our headers and the standards docs.

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

5 years agoWhen an IPv6 packet is received for a raw socket which has the
tuexen [Fri, 19 Apr 2019 18:09:37 +0000 (18:09 +0000)]
When an IPv6 packet is received for a raw socket which has the
IPPROTO_IPV6 level socket option IPV6_CHECKSUM enabled and the
checksum check fails, drop the message. Without this fix, an
ICMP6 message was sent indicating a parameter problem.

Thanks to bz@ for suggesting a way to simplify this fix.

Reviewed by: bz@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19969

5 years ago[ath] Fix return value check to not complain.
adrian [Fri, 19 Apr 2019 18:00:33 +0000 (18:00 +0000)]
[ath] Fix return value check to not complain.

Compilers complain more about things, so let's keep them happy.

5 years agoWhen a checksum has to be computed for a received IPv6 packet because it
tuexen [Fri, 19 Apr 2019 17:28:28 +0000 (17:28 +0000)]
When a checksum has to be computed for a received IPv6 packet because it
is requested by the application using the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM on a raw socket, ensure that the packet contains enough
bytes to contain the checksum at the specified offset.

Reported by: syzbot+6295fcc5a8aced81d599@syzkaller.appspotmail.com
Reviewed by: bz@
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19968

5 years agoAvoid a buffer overwrite in rip6_output() when computing the checksum
tuexen [Fri, 19 Apr 2019 17:21:35 +0000 (17:21 +0000)]
Avoid a buffer overwrite in rip6_output() when computing the checksum
as requested by the user via the IPPROTO_IPV6 level socket option
IPV6_CHECKSUM. The check if there are enough bytes in the packet to
store the checksum at the requested offset was wrong by 1.

Reviewed by: bz@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19967

5 years agoImprove input validation for the socket option IPV6_CHECKSUM.
tuexen [Fri, 19 Apr 2019 17:17:41 +0000 (17:17 +0000)]
Improve input validation for the socket option IPV6_CHECKSUM.

When using the IPPROTO_IPV6 level socket option IPV6_CHECKSUM on a raw
IPv6 socket, ensure that the value is either -1 or a non-negative even
number.

Reviewed by: bz@, thj@
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D19966

5 years agorandom.4: Include description of knobs added in r346358
cem [Fri, 19 Apr 2019 17:15:58 +0000 (17:15 +0000)]
random.4: Include description of knobs added in r346358

Reported by: ngie
Sponsored by: Dell EMC Isilon

5 years agoAdd stat counter for ipv6 atomic fragments
thj [Fri, 19 Apr 2019 17:06:43 +0000 (17:06 +0000)]
Add stat counter for ipv6 atomic fragments

Add a stat counter to track ipv6 atomic fragments. Atomic fragments can be
generated in response to invalid path MTU values, but are also a potential
attack vector and considered harmful (see RFC6946 and RFC8021).

While here add tracking of the atomic fragment counter to netstat and systat.

Reviewed by:    tuexen, jtl, bz
Approved by:    jtl (mentor), bz (mentor)
Event:  Aberdeen hackathon 2019
Differential Revision:  https://reviews.freebsd.org/D17511

5 years agoChange the way FreeBSD GID inheritance is hacked.
mav [Fri, 19 Apr 2019 15:44:45 +0000 (15:44 +0000)]
Change the way FreeBSD GID inheritance is hacked.

I believe previous ifdef caused NULL dereference in later zfs_log_create()
on attempt to create file inside directory belonging to ephemeral group
created on illumos, trying to write to log information about GID domain
of the newly created file, inheriting the ephemeral GID.

This patch reuses original illumos SGID code with exception that due to
lack of ID mapping code on FreeBSD ephemeral GID will turn into GID_NOBODY
by another ifdef inside zfs_fuid_map_id().

MFC after: 1 month
Sponsored by: iXsystems, Inc.

5 years agoremove the 4GB boundary requirement on PCI DMA segments
tychon [Fri, 19 Apr 2019 13:43:33 +0000 (13:43 +0000)]
remove the 4GB boundary requirement on PCI DMA segments

Reviewed by: kib
Discussed with: jhb
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19867

5 years agopfctl: Fix ifgroup check
kp [Fri, 19 Apr 2019 10:52:54 +0000 (10:52 +0000)]
pfctl: Fix ifgroup check

We cannot just assume that any name which ends with a letter is a group
That's not been true since we allowed renaming of network interfaces. It's also
not true for things like epair0a.

Try to retrieve the group members for the name to check, since we'll get ENOENT
if the group doesn't exist.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agoClose filedescriptors when done with them.
phk [Fri, 19 Apr 2019 06:49:46 +0000 (06:49 +0000)]
Close filedescriptors when done with them.

5 years agoFix the NFSv4.0 server so that it does not support NFSv4.1 attributes.
rmacklem [Fri, 19 Apr 2019 03:36:22 +0000 (03:36 +0000)]
Fix the NFSv4.0 server so that it does not support NFSv4.1 attributes.

During inspection of a packet trace, I noticed that an NFSv4.0 mount
reported that it supported attributes that are only defined for NFSv4.1.
In practice, this bug appears to be benign, since NFSv4.0 clients will
not use attributes that were added for NFSv4.1.
However, this was not correct and this patch fixes the NFSv4.0 server
so that it only supports attributes defined for NFSv4.0.
It also adds a definition for NFSv4.1 attributes that can only be set,
although it is only defined as 0 for now.
This is anticipation of the addition of support for the NFSv4.1 mode+mask
attribute soon.

MFC after: 2 weeks

5 years agoUpdate to Zstandard 1.4.0
cem [Fri, 19 Apr 2019 02:54:13 +0000 (02:54 +0000)]
Update to Zstandard 1.4.0

The full release notes can be found on Github:

  https://github.com/facebook/zstd/releases/tag/v1.4.0

Relnotes: yes

5 years agopowerpc/powernv: Make erasing before writes optional
jhibbits [Fri, 19 Apr 2019 02:28:04 +0000 (02:28 +0000)]
powerpc/powernv: Make erasing before writes optional

If the OPAL flash driver supports writing without erase, it adds a
'no-erase' property to the flash device node.  Honor that property and don't
bother erasing if it exists.

5 years agoimport zstd 1.4.0
cem [Fri, 19 Apr 2019 00:31:04 +0000 (00:31 +0000)]
import zstd 1.4.0

5 years agoPush down INP_WLOCK slightly in tcp_ctloutput.
jhb [Thu, 18 Apr 2019 23:21:26 +0000 (23:21 +0000)]
Push down INP_WLOCK slightly in tcp_ctloutput.

The inp lock is not needed for testing the V6 flag as that flag is set
once when the inp is created and never changes.  For non-TCP socket
options the lock is immediately dropped after checking that flag.
This just pushes the lock down to only be acquired for TCP socket
options.

This isn't a hot-path, more a cosmetic cleanup I noticed while reading
the code.

Reviewed by: bz
MFC after: 1 month
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19740

5 years agoWhen parsing command line stuff, treat tabs and spaces the same.
imp [Thu, 18 Apr 2019 22:52:12 +0000 (22:52 +0000)]
When parsing command line stuff, treat tabs and spaces the same.

When creating complex config files, people like to use tabs to offset
sections. Treat them the same as spaces for delimiters.

5 years agorandom(4): Restore availability tradeoff prior to r346250
cem [Thu, 18 Apr 2019 20:48:54 +0000 (20:48 +0000)]
random(4): Restore availability tradeoff prior to r346250

As discussed in that commit message, it is a dangerous default.  But the
safe default causes enough pain on a variety of platforms that for now,
restore the prior default.

Some of this is self-induced pain we should/could do better about; for
example, programmatic CI systems and VM managers should introduce entropy
from the host for individual VM instances.  This is considered a future work
item.

On modern x86 and Power9 systems, this may be wholly unnecessary after
D19928 lands (even in the non-ideal case where early /boot/entropy is
unavailable), because they have fast hardware random sources available early
in boot.  But D19928 is not yet landed and we have a host of architectures
which do not provide fast random sources.

This change adds several tunables and diagnostic sysctls, documented
thoroughly in UPDATING and sys/dev/random/random_infra.c.

PR: 230875 (reopens)
Reported by: adrian, jhb, imp, and probably others
Reviewed by: delphij, imp (earlier version), markm (earlier version)
Discussed with: adrian
Approved by: secteam(delphij)
Relnotes: yeah
Security: related
Differential Revision: https://reviews.freebsd.org/D19944

5 years agoImplement flag for telling cuse(3) clients if the peer is running in 32-bit
hselasky [Thu, 18 Apr 2019 19:04:07 +0000 (19:04 +0000)]
Implement flag for telling cuse(3) clients if the peer is running in 32-bit
compat mode or not. This is useful when implementing compatibility ioctl(2)
handlers in userspace.

MFC after: 1 week
Sponsored by: Mellanox Technologies

5 years agoUse correct type name.
kib [Thu, 18 Apr 2019 15:31:03 +0000 (15:31 +0000)]
Use correct type name.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoAdd note that I'm the defacto maintainer of libegacy, our
imp [Thu, 18 Apr 2019 15:19:28 +0000 (15:19 +0000)]
Add note that I'm the defacto maintainer of libegacy, our
compat shims for building bootstrap tools that use new features
on systems too old to have those new features. The world view
for this part of the build is unique to the whole build process
and continuty of design for new compat shims help this library
remain viable.

5 years agoMinor tweak to the debug
imp [Thu, 18 Apr 2019 15:19:19 +0000 (15:19 +0000)]
Minor tweak to the debug

Make it clear we're loading from UFS.

5 years agoCorrect handling of RMRR during early enumeration stages.
kib [Thu, 18 Apr 2019 14:18:06 +0000 (14:18 +0000)]
Correct handling of RMRR during early enumeration stages.

On some machines, DMAR contexts must be created before all devices
under the scope of the corresponding DMAR unit are enumerated.
Current code has two problems with that:
- scope lookup returns NULL device_t, which causes to skip creating a
  context with RMRR, which is fatal for the affected device.
- calculation of the final pci dbsf address fails if any bridge in the
  scope is not yet enumerated, because code relies on pcib_get_bus().

Make creation of contexts work either with device_t, or with DMAR PCI
scope paths.  Scope provides enough information to infer context
address, and it is directly matched against DMAR tables scopes.

When calculating bus addresses for the scope or device, use direct
pci_cfgregread(PCIR_SECBUS_1) to get the secondary bus number, instead
of pcib_get_bus().

The issue was observed on HP Gen servers, where iLO PCI devices are
located behind south bridge switch.  Turning on translation without
satisfying RMRR requests caused iLO to mostly hang, up to the level of
being unusable to control the server.

While there, remove hw.dmar.dmar_match_verbose tunable, and make the
normal logging under bootverbose useful and sufficient to diagnose
DRHD and RMRR parsing and matching.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoRemove witness warning. dmar_bus_dmamap_create() does not sleep.
kib [Thu, 18 Apr 2019 14:03:59 +0000 (14:03 +0000)]
Remove witness warning. dmar_bus_dmamap_create() does not sleep.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agoReduce verbosity, do not announce details of irte programming by default.
kib [Thu, 18 Apr 2019 14:02:33 +0000 (14:02 +0000)]
Reduce verbosity, do not announce details of irte programming by default.

Sponsored by: Mellanox Technologies
MFC after: 1 week

5 years agopf: No need to M_NOWAIT in DIOCRSETTFLAGS
kp [Thu, 18 Apr 2019 11:37:44 +0000 (11:37 +0000)]
pf: No need to M_NOWAIT in DIOCRSETTFLAGS

Now that we don't hold a lock during DIOCRSETTFLAGS memory allocation we can
use M_WAITOK.

MFC after: 1 week
Event: Aberdeen hackathon 2019
Pointed out by: glebius@

5 years agoAdd a bugs section to pflog man page
thj [Thu, 18 Apr 2019 11:06:45 +0000 (11:06 +0000)]
Add a bugs section to pflog man page

FreeBSD does not set the pid field in the pfloghdr struct. This field is
populated on other platforms, document this to save people from trying
to use this field.

Event: Aberdeen hackathon 2019
Reviewed by: kp, bcr, bz
Approved by: bz (mentor)
Differential Revision: https://reviews.freebsd.org/D19952

5 years agopf tests: Fail the test if we can't set the rules
kp [Thu, 18 Apr 2019 10:54:08 +0000 (10:54 +0000)]
pf tests: Fail the test if we can't set the rules

The test should fail if pf rules can't be set. This is helpful both
while writing tests and to verify that pfctl works as expected.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agoAdd efi_delenv
imp [Thu, 18 Apr 2019 05:40:50 +0000 (05:40 +0000)]
Add efi_delenv

Add an interface to remove / delete UEFI variables.

5 years agoAdd a more generic efi_setenv function.
imp [Thu, 18 Apr 2019 05:37:18 +0000 (05:37 +0000)]
Add a more generic efi_setenv function.

efi_setenv allows any UEFI variable to be set.

5 years agoAs an interim measure until a more permanent solution is implemented
cy [Thu, 18 Apr 2019 01:02:00 +0000 (01:02 +0000)]
As an interim measure until a more permanent solution is implemented
workaround the following error:

/usr/src/contrib/elftoolchain/strings/strings.c:198:55: error: use of
undeclared identifier
'FA_OPEN' fa = fileargs_init(argc, argv, O_RDONLY, 0, &rights, FA_OPEN);

Reported by: O. Hartmann <ohartmann@walstatt.org>
Reported by: Michael Butler <imb@protected-networks.net>
Reported by: gjb@ & cy@ (implicit)
Reviewed by: emaste@
Noted by: rgrimes@

5 years agoarm: allwinner: Fix audio for Allwinner H3/H5
manu [Wed, 17 Apr 2019 21:45:19 +0000 (21:45 +0000)]
arm: allwinner: Fix audio for Allwinner H3/H5

Due to three conditions the codec driver for Allwinner A10/A20 and H3/H5 did not work properly here:

    Wrong bit position for the analog audio reset
    Hardware Reset of codec was not de-asserted correctly
    Linux DTS file did not contain the address of the analog register the way as the driver was expecting it.

This patch proposes fixes for those three parts.

Submitted by: freebsdnewbie@freenet.de (Manuel Stühn)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19910

5 years agoofw_graph: Add functions for graph bindings
manu [Wed, 17 Apr 2019 20:09:01 +0000 (20:09 +0000)]
ofw_graph: Add functions for graph bindings

Those functions are helpers to work on graph bindings.
graphs are mostly use with video related devices.
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/devicetree/bindings/graph.txt?id=4436a3711e3249840e0679e92d3c951bcaf25515

MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D19877

5 years agoPut QEMU CI smoke test boot log in /tmp if TMPDIR not set
emaste [Wed, 17 Apr 2019 19:24:41 +0000 (19:24 +0000)]
Put QEMU CI smoke test boot log in /tmp if TMPDIR not set

Sponsored by: The FreeBSD Foundation

5 years agoInstall some entropy for QEMU CI smoke test
emaste [Wed, 17 Apr 2019 19:16:26 +0000 (19:16 +0000)]
Install some entropy for QEMU CI smoke test

See r346250 and followup commits and mailing list discussion.
We currently fail to boot properly in the absense of boot-time entropy.

Sponsored by: The FreeBSD Foundation

5 years agoCompile sha1.c when ether support is included
kevans [Wed, 17 Apr 2019 18:08:28 +0000 (18:08 +0000)]
Compile sha1.c when ether support is included

sha1 is used by ether_gen_addr after r346324. Perhaps in an ideal world we
could detect that the kernel's been compiled without sha1_* bits included
and silently fallback to arc4random instead because these platforms/kernel
configs are far and few between. It's fairly lightweight, though, so just
include it for now.

5 years agoreadelf: use size_t for object counts
emaste [Wed, 17 Apr 2019 17:50:44 +0000 (17:50 +0000)]
readelf: use size_t for object counts

PR: 212539
Reported by: cem
Sponsored by: The FreeBSD Foundation

5 years agoiflib: Use new ether_gen_addr, restricting addresses to that subset
kevans [Wed, 17 Apr 2019 17:19:54 +0000 (17:19 +0000)]
iflib: Use new ether_gen_addr, restricting addresses to that subset

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

5 years agonet: adjust randomized address bits
kevans [Wed, 17 Apr 2019 17:18:43 +0000 (17:18 +0000)]
net: adjust randomized address bits

Give devices that need a MAC a 16-bit allocation out of the FreeBSD
Foundation OUI range. Change the name ether_fakeaddr to ether_gen_addr now
that we're dealing real MAC addresses with a real OUI rather than random
locally-administered addresses.

Reviewed by: bz, rgrimes
Differential Revision: https://reviews.freebsd.org/D19587

5 years agoreadelf: speed up readelf -wo
emaste [Wed, 17 Apr 2019 17:00:16 +0000 (17:00 +0000)]
readelf: speed up readelf -wo

Use an array instead of STAILQ, and sort at the end instead of while
adding new elements.

PR: 212539
Submitted by: Bora Özarslan <borako.ozarslan@gmail.com>
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation

5 years ago[casper] fix compilation when casper is disabled.
adrian [Wed, 17 Apr 2019 16:58:38 +0000 (16:58 +0000)]
[casper] fix compilation when casper is disabled.

This triggers an error in gcc-mips 6.4.0 complaining about unused arguments.

Tested:

* compiled/run on mips32; nothing complained.

5 years agocap_fileargs: fix test after r346318
emaste [Wed, 17 Apr 2019 16:45:42 +0000 (16:45 +0000)]
cap_fileargs: fix test after r346318

Reported by: danfe, mjg
MFC after: 3 weeks
MFC with: r346315
Sponsored by: The FreeBSD Foundation

5 years agopf tests: Try to provoke the panic with invalid DIOCRSETTFLAGS
kp [Wed, 17 Apr 2019 16:45:35 +0000 (16:45 +0000)]
pf tests: Try to provoke the panic with invalid DIOCRSETTFLAGS

There was an issue with copyin() on DIOCRSETTFLAGS, which would panic if
pfrio_buffer was NULL.
Test for the issue fixed in r346319.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agopf: Fix panic on invalid DIOCRSETTFLAGS
kp [Wed, 17 Apr 2019 16:42:54 +0000 (16:42 +0000)]
pf: Fix panic on invalid DIOCRSETTFLAGS

If during DIOCRSETTFLAGS pfrio_buffer is NULL copyin() will fault, which we're
not allowed to do with a lock held.
We must count the number of entries in the table and release the lock during
copyin(). Only then can we re-acquire the lock. Note that this is safe, because
pfr_set_tflags() will check if the table and entries exist.

This was discovered by a local syzcaller instance.

MFC after: 1 week
Event: Aberdeen hackathon 2019

5 years agocap_fileargs: fix GCC build, don't shadow 'stat'
emaste [Wed, 17 Apr 2019 16:31:30 +0000 (16:31 +0000)]
cap_fileargs: fix GCC build, don't shadow 'stat'

Reported by: ci.freebsd.org
MFC after: 3 weeks
MFC with: r346315
Sponsored by: The FreeBSD Foundation

5 years agoAllow this test script to be run from within src/tools/boot dir, and create
ian [Wed, 17 Apr 2019 16:27:43 +0000 (16:27 +0000)]
Allow this test script to be run from within src/tools/boot dir, and create
the temporary image in $TMPDIR.

Allow the script to be run from the src/tools/boot directory by using make
-V SRCTOP to find the top of the tree, because this script is handy for
quick smoke-testing of loader changes, as well as being useful in CI testing.

Also, use a temp directory in $TMPDIR to assemble the boot image, and write
the boot log file to $TMPDIR.  Arrange to have the temporary image clean
itself up, but leave the log file in $TMPDIR for post-mortem analysis of
failures when the script is run interactively.

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

5 years agocap_fileargs: chase r346315, update fileargs_init in consumers
emaste [Wed, 17 Apr 2019 16:18:14 +0000 (16:18 +0000)]
cap_fileargs: chase r346315, update fileargs_init in consumers

Reported by: ci.freebsd.org (8 times so far)
MFC after: 3 weeks
MFC with: r346315
Sponsored by: The FreeBSD Foundation

5 years agocap_fileargs: add fileargs_lstat service
emaste [Wed, 17 Apr 2019 16:02:57 +0000 (16:02 +0000)]
cap_fileargs: add fileargs_lstat service

Add fileargs_lstat function to cap_fileargs casper service to be able to
lstat files while in capability mode.  It can only lstat files given in
fileargs_init.

Submitted by: Bora Özarslan <borako.ozarslan@gmail.com>
Reviewed by: oshogbo, cem (partial)
MFC after: 3 weeks
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D19548

5 years agocap_fileargs.3: typo and markup corrections
emaste [Wed, 17 Apr 2019 16:00:33 +0000 (16:00 +0000)]
cap_fileargs.3: typo and markup corrections

Submitted by: Bora Özarslan" <borako.ozarslan@gmail.com>
MFC after: 1 week
MFC with: r346313
Sponsored by: The FreeBSD Foundation

5 years agocap_fileargs.3: correct 'filerags' typo
emaste [Wed, 17 Apr 2019 15:48:33 +0000 (15:48 +0000)]
cap_fileargs.3: correct 'filerags' typo

Submitted by: Bora Özarslan" <borako.ozarslan@gmail.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agoOnly set up the interrupts that will actually be used in arm generic_timer.
ian [Wed, 17 Apr 2019 15:27:11 +0000 (15:27 +0000)]
Only set up the interrupts that will actually be used in arm generic_timer.

The code previously set up interrupt handlers for all the interrupt
resources available, including for timers that are not in use.  That could
lead to interrupt storms.  For example, if boot firmware enabled the virtual
timer but the kernel is using the physical timer, it could get flooded with
interrupts on the virtual timer which it cannot shut off.  By only setting
up an interrupt handler for the hardware that will actually be used, any
interrupts from other timer units will remain masked in the interrupt
controller.

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

5 years agoAdd orphan mentee.
pfg [Wed, 17 Apr 2019 14:20:55 +0000 (14:20 +0000)]
Add orphan mentee.

5 years agoAdd myself to ports committers.
pfg [Wed, 17 Apr 2019 14:12:11 +0000 (14:12 +0000)]
Add myself to ports committers.

Approved by: pfg (mentor)

5 years agofdt: further consolidate DTB building and revise manpage
kevans [Wed, 17 Apr 2019 03:29:16 +0000 (03:29 +0000)]
fdt: further consolidate DTB building and revise manpage

FDT_DTS_FILE was built separately with a rule in sys/conf/files and
recreated the rules we used in dtb.mk. Now that we have other infrastructure
to build a DTB along with the kernel, fold FDT_DTS_FILE into that since it
doesn't have any special requirements.

fdt(4) never got revised to mention the DTS/DTSO make options, so do that
now.

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D19736

5 years agoarm: allwinner: Makes more device optional
manu [Tue, 16 Apr 2019 22:42:50 +0000 (22:42 +0000)]
arm: allwinner: Makes more device optional

MFC after: 2 weeks

5 years agoiflibtxrx.9: update function descriptions to match implementation
emaste [Tue, 16 Apr 2019 20:41:04 +0000 (20:41 +0000)]
iflibtxrx.9: update function descriptions to match implementation

isc_rxd_refill, isc_rxd_flush return nothing, not void *.

isc_txd_credits_update, isc_rxd_available return int, not int *.

isc_txd_credits_update has a bool as final argument, not a uint32_t.
Prior to r315217 it took four arguments; the final two were
uint32_t, bool.

Reported by: Gerald Aryeetey <aryeeteygerald_rogers.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

5 years agoconfig: Only warn if duplicate option/device comes from the same file
manu [Tue, 16 Apr 2019 20:08:19 +0000 (20:08 +0000)]
config: Only warn if duplicate option/device comes from the same file

This is useful for arm (possibly other arches too) where we want to have
a GENERIC kernel that only include files for the different SoC. Since
multiple SoCs/Board needs the same device we would need to do either :

    Include the device in a generic file
    Include the device in each file that really needs it

Option 1 works but if someone wants to create a specific kernel config
(which isn't uncommon for embedded system), he will need to add a lots
of nodevice to it.

Option 2 also works but produce a lots of warnings.

Reviewed by: kevans
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D19424

5 years agoarm: Order files.arm to have cloudabi and annapurna sections
manu [Tue, 16 Apr 2019 20:06:39 +0000 (20:06 +0000)]
arm: Order files.arm to have cloudabi and annapurna sections

MFC after: 2 weeks

5 years agoarm: Add kern_clocksource.c directly in files.arm
manu [Tue, 16 Apr 2019 20:04:22 +0000 (20:04 +0000)]
arm: Add kern_clocksource.c directly in files.arm

This files is needed and included in all our config so move it to a common
location.

MFC after: 2 weeks

5 years agoFix initial x87 state after r345562.
kib [Tue, 16 Apr 2019 19:46:02 +0000 (19:46 +0000)]
Fix initial x87 state after r345562.

After the referenced commit, we did not set x87 and sse valid bits in
the xstate_bv bitmask for initial fpu state (stored in memory), when
using XSAVE.

The state is loaded into FPU register file to initialize the process
FPU state, and since both bits were clear, the default x87 and SSE
states were loaded.  By chance, FreeBSD ABI SSE2 state is same as FPU
initial state, so the bug is not visible for 64bit processes.  But on
i386, the precision control should be set to double (53bit mantissa),
instead of the default double extended (64bit mantissa). For 32bit
processes on amd64, kernel reloads control word with the right mask,
which only left native i386 and amd64 native but using x87 as
affected.

Fix it by setting minimal required xstate_bv mask.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

5 years agoallwinner: clk: Garbage collect old clock implementation
manu [Tue, 16 Apr 2019 19:38:16 +0000 (19:38 +0000)]
allwinner: clk: Garbage collect old clock implementation

The old clocks are disconneted from the build since r337344.
Remove all those pseudo drivers. The only one remaining is for gmac
(the ethernet controller) so move it to sys/arm/allwinner.
While here remove a83t support from gmacclk as it is unneeded since r326114.

MFC after: 1 month

5 years agostack_protector: Add tunable to bypass random cookies
cem [Tue, 16 Apr 2019 18:47:20 +0000 (18:47 +0000)]
stack_protector: Add tunable to bypass random cookies

This is a stopgap measure to unbreak installer/VM/embedded boot issues
introduced (or at least exposed by) in r346250.

Add the new tunable, "security.stack_protect.permit_nonrandom_cookies," in
order to continue boot with insecure non-random stack cookies if the random
device is unavailable.

For now, enable it by default.  This is NOT safe.  It will be disabled by
default in a future revision.

There is follow-on work planned to use fast random sources (e.g., RDRAND on
x86 and DARN on Power) to seed when the early entropy file cannot be
provided, for whatever reason.  Please see D19928.

Some better hacks may be used to make the non-random __stack_chk_guard
slightly less predictable (from delphij@ and mjg@); those suggestions are
left for a future revision.  I think it may also be plausible to move stack
guard initialization far later in the boot process; potentially it could be
moved all the way to just before userspace is started.

Reported by: many
Reviewed by: delphij, emaste, imp (all w/ caveat: this is a stopgap fix)
Security: yes
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D19927

5 years agorandom(4): Add is_random_seeded(9) KPI
cem [Tue, 16 Apr 2019 17:12:17 +0000 (17:12 +0000)]
random(4): Add is_random_seeded(9) KPI

The imagined use is for early boot consumers of random to be able to make
decisions based on whether random is available yet or not.  One such
consumer seems to be __stack_chk_init(), which runs immediately after random
is initialized.  A follow-up patch will attempt to address that.

Reported by: many
Reviewed by: delphij (except man page)
Approved by: secteam(delphij)
Differential Revision: https://reviews.freebsd.org/D19926

5 years agoReplace cosqos with numa_domain in mbuf pkthdr
gallatin [Tue, 16 Apr 2019 16:49:34 +0000 (16:49 +0000)]
Replace cosqos with numa_domain in mbuf pkthdr

The cosqos field was added nearly 6 years ago in r254804, and it is
still unused by any in-tree consumers.  I have a patchset that I'm
working on which aligns many network resources by NUMA domain,
including inps, inpcb lb group, tcp pacing, lagg output link
selection, backing pages for sendfile, and more.  It reduces
cross-domain traffic by roughly 50% for a real web workload.

This patchset relies on being able to store the numa domain in the
mbuf, and grabbing the unused cosqos field for this purpose is the
first step in starting to usptream it.

Reviewed by: kib, markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D19862

5 years agoSigh, r346279 was also a test version with the reduced size doubled (so
bde [Tue, 16 Apr 2019 15:52:04 +0000 (15:52 +0000)]
Sigh, r346279 was also a test version with the reduced size doubled (so
it was actually double the full size in current kernels where the reduction
is null, so overran the mmapped() buffer).

5 years agoOops, r346278 committed a test version with the change annulled.
bde [Tue, 16 Apr 2019 15:41:45 +0000 (15:41 +0000)]
Oops, r346278 committed a test version with the change annulled.

5 years agoQuick fix for slow clearing and context switches of large frame buffers
bde [Tue, 16 Apr 2019 15:31:23 +0000 (15:31 +0000)]
Quick fix for slow clearing and context switches of large frame buffers
with old kernels, by breaking the support for large frame buffers in the
same way as for current kernels.

Large frame buffers may be too large to map into kva, and the kernel
(syscons) only uses the first screen page anyway, so r203535, r205557
and 248799 limit the buffer size in VESA modes to the first screen
page, apparently without noticing that this breaks applications by
using the same limit for user mappings as for kernel mappings.  In
vgl, this makes the virtual screen the same as the physical screen.

However, this is almost a feature since clearing and switching large
(usually mostly unused) frame buffers takes too long.  E.g., on a 16
year old low-end AGP card it takes about 12 seconds to clear the 128MB
frame buffer in old kernels that map it all and also map it with slow
attributes (e.g., uncacheable).  Older PCI cards are even slower, but
usually have less memory.  Newer PCIe cards are faster, but may have
many GB of memory.  Also, vgl malloc()s a shadow buffer with the same
size as the frame buffer, so large frame buffers are even more wasteful
in applications than in the kernel.

Use the same limit in vgl as in newer kernels.

Virtual screens and panning still work in non-VESA modes that have
more than 1 page.  The reduced buffer size in the kernel also breaks
mmap() of the last physical page in modes where the reduced size is
not a multiple of the physical page size.  The same reduction in vgl
only reduces the virtual screen size.

5 years agoFix a variable name in r346215. Clearing of the right of the screen was
bde [Tue, 16 Apr 2019 14:28:33 +0000 (14:28 +0000)]
Fix a variable name in r346215.  Clearing of the right of the screen was
broken, except it worked accidentally in most cases where the virtual
screen is larger than the physical screen.

5 years agoRemove INDEX-10 reference, as 10.x is now EoL.
gjb [Tue, 16 Apr 2019 14:07:14 +0000 (14:07 +0000)]
Remove INDEX-10 reference, as 10.x is now EoL.

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

5 years agoUpdate and clarify pflog man page
thj [Tue, 16 Apr 2019 13:31:16 +0000 (13:31 +0000)]
Update and clarify pflog man page

The pflog0 interface is created when the module is loaded, this can
be triggered by pf and pflogd being enabled or by kldloading the module.

By default the interface would be pflog0, add the ifconfig stage of the
example to make this example clearer.

Reviewed by: kp, bz, bcr, jtl, 0mp
Approved by: jtl (mentor), bz (mentor)
Differential Revision: https://reviews.freebsd.org/D19861

5 years agocorrect readlinkat(2) return type
emaste [Tue, 16 Apr 2019 13:26:31 +0000 (13:26 +0000)]
correct readlinkat(2) return type

r176215 corrected readlink(2)'s return type and the type of the last
argument.  readlink(2) was introduced in r177788 after being developed
as part of Google Summer of Code 2007; it appears to have inherited the
wrong return type.

Man pages and header files were already ssize_t; update syscalls.master
to match.

PR: 197915
Submitted by: Henning Petersen <henning.petersen@t-online.de>
MFC after: 2 weeks

5 years agoaw_syscon: Add a new compatible
manu [Tue, 16 Apr 2019 12:40:49 +0000 (12:40 +0000)]
aw_syscon: Add a new compatible

Since 5.0 DTS the syscon controller have a new compatible as it
exports new subnodes, we currently only use it as a syscon provider
so just add the new compatible.

Tested On:  H3
MFC after: 1 month

5 years agoaw_rtc: Register the clocks
manu [Tue, 16 Apr 2019 12:39:31 +0000 (12:39 +0000)]
aw_rtc: Register the clocks

Since latest DTS update the rtc is supposed to register two clocks :

- osc32k (the 32k oscillator on the board that the RTC uses directly and
that other peripheral can use)
- iosc (the internal oscillator of the RTC when available which frequency
depend on the SoC revision)

Since we need the RTC before the proper clock control unit (because it uses
those clocks) attach it a BUS_PASS_BUS + MIDDLE and attach the clock control
unit at BUS_PASS_BUS + LAST for the SoC that requires it.

Tested On:      A20, H3, A64

MFC after: 1 month

5 years agoDrop -g from CFLAGS for zfsd(8). No idea why it was ever there.
trasz [Tue, 16 Apr 2019 12:25:15 +0000 (12:25 +0000)]
Drop -g from CFLAGS for zfsd(8).  No idea why it was ever there.

Reviewed by: kib, ngie, asomers
MFC after: 2 weeks
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D19915

5 years agoext2fs: Initial version of DTrace support.
fsu [Tue, 16 Apr 2019 11:37:15 +0000 (11:37 +0000)]
ext2fs: Initial version of DTrace support.

Commit forgotten file.

Reviewed by:    pfg, gnn
MFC after:      1 week

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

5 years agoext2fs: Initial version of DTrace support.
fsu [Tue, 16 Apr 2019 11:20:10 +0000 (11:20 +0000)]
ext2fs: Initial version of DTrace support.

Reviewed by:    pfg, gnn
MFC after:      1 week

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

5 years agoSpecify correct Ethernet phy for RPI-B
peterj [Tue, 16 Apr 2019 09:44:46 +0000 (09:44 +0000)]
Specify correct Ethernet phy for RPI-B

Correct a typo in the RPI-B ethernet config - the RPi-B includes a
SMC LAN9512 USB bridge and Ethernet 10/100 NIC/phy.  The phy part of
this is supported by smscphy.

Tested On: RPi1 Model B

Approved by: grog, jhb (mentors)
MFC after: 3 days

5 years agoFix cpufreq(4) on RPI-B
peterj [Tue, 16 Apr 2019 09:42:42 +0000 (09:42 +0000)]
Fix cpufreq(4) on RPI-B

Since r324184 the root node compatible for the original Raspberry Pi
is "brcm,bcm2835", add it to the compatible list of bcm2835_cpufreq.

Tested On: RPi1 Model B

Note that the default Das U-Boot FDT does not include a cpus clause
so actually adding a bcm2835_cpufreq device requires adding a FDT
overlay defining the cpu.

Approved by: grog, jhb (mentors)
MFC after: 3 days

5 years agoDocument when I received my commit bits.
cy [Tue, 16 Apr 2019 05:11:39 +0000 (05:11 +0000)]
Document when I received my commit bits.

5 years agotcpdump: disable Capsicum if -E option is provided.
oshogbo [Tue, 16 Apr 2019 04:12:41 +0000 (04:12 +0000)]
tcpdump: disable Capsicum if -E option is provided.

The -E is used to provide a secret for decrypting IPsec.
The secret may be provided through command line or as the file.
The problem is that tcpdump doesn't support yet opening files in capability mode
and the file may contain a list of the files to open.

As a workaround, for now, let's just disable capsicum if the -E
the option is provided.

PR: 236819
MFC after: 2 weeks