]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years ago[PowerPC64LE] Add release building script for powerpc64le.
bdragon [Wed, 23 Sep 2020 01:13:29 +0000 (01:13 +0000)]
[PowerPC64LE] Add release building script for powerpc64le.

This was originally part of the initial commit, but after discussion in
D26399, I split it out into its own commit after the kernel config file.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Initial GENERIC64LE kernel config.
bdragon [Wed, 23 Sep 2020 01:07:55 +0000 (01:07 +0000)]
[PowerPC64LE] Initial GENERIC64LE kernel config.

This is slightly stripped down from GENERIC64, as PowerMac G5 machines
are incapable of running in LE mode (so we can skip the Mac drivers.)

While technically POWER6 and POWER7 have the hardware capability of running
in LE mode, they have a tendency to trap excessively when a load/store is
misaligned. (an extremely common occurrence in LE code, and one of the main
reasons I consider BE to be superior, as it turns potential security issues
into immediately obvious mangled numbers.)

Additionally, there was no mechanism to control what endian interrupts
are delivered in, so supporting LE operation on POWER6 and POWER7 involves
some really dirty tricks in the interrupt vectors that I would rather
avoid.

IBM drew the line in the sand at POWER8 some time around 2013, embracing
full support for LE in the platform, and making a push across the board
for LE code to target POWER8 as a minimum requirement. As such, usage of
LE kernels on POWER6 and POWER7 is practically nil, despite it being
technically possible to do.

The so-called "TRUELE" feature bit which is the baseline requirement for
 needed for PowerPC64LE was introduced in POWER8.

Sponsored by: Tag1 Consulting, Inc.

3 years agoWork around cp breakage in current from last week
imp [Wed, 23 Sep 2020 01:04:25 +0000 (01:04 +0000)]
Work around cp breakage in current from last week

There was a small window cp was broken. Work around this by using :>
instead of cp /dev/null. Ideally, we'd keep the cp /dev/null in the
build as a regression test, but doing so breaks people that upgraded
during the cp breakage and this is simpler than bootstrapping a
working cp since there's no good __FreeBSD_version sign posts for
that.

Suggested by: lots of people
Too stubborn for his own good: imp

3 years ago[PowerPC64LE] powernv ILE setup code.
bdragon [Wed, 23 Sep 2020 00:32:50 +0000 (00:32 +0000)]
[PowerPC64LE] powernv ILE setup code.

When running without a hypervisor, we need to set the ILE bit in the LPCR
ourselves.

For the boot processor, handle it in powernv_attach() like we do for other
LPCR bits.

No change for the APs, as they will use the lpcr global to set up their own
LPCR when they do their own cpudep_ap_early_bootstrap() and pick up this
automatically.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] LE opal_call() implementation
bdragon [Wed, 23 Sep 2020 00:28:47 +0000 (00:28 +0000)]
[PowerPC64LE] LE opal_call() implementation

OPAL runs in big endian, so we need to rfid into it to switch endian
atomically when branching to it, and we need to do the
RETURN_TO_NATIVE_ENDIAN dance when it returns to us.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le.
bdragon [Wed, 23 Sep 2020 00:21:51 +0000 (00:21 +0000)]
[PowerPC64LE] Use a shared LIBC_ARCH for powerpc64le.

Given that we have converted to ELFv2 for BE already, endianness is the only
difference between the two ARCHs.

As such, there is no need to differentiate LIBC_ARCH between the two.

Combining them like this lets us avoid needing to have two copies of several
bits for no good reason.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix endianness issues in phyp_vscsi.
bdragon [Wed, 23 Sep 2020 00:13:58 +0000 (00:13 +0000)]
[PowerPC64LE] Fix endianness issues in phyp_vscsi.

Unlike virtio, which in legacy mode is guest endian, the hypervisor vscsi
interface operates in big endian, so we must convert back and forth in several
places.

These changes are enough to attach a rootdisk.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Work around qemu TCG bug in mtmsrd emulation.
bdragon [Wed, 23 Sep 2020 00:09:29 +0000 (00:09 +0000)]
[PowerPC64LE] Work around qemu TCG bug in mtmsrd emulation.

The TCG implementation of mtmsrd in qemu blindly copies the entire register
to the MSR, instead of the specific bit positions listed in the ISA.

This means that qemu will prematurely switch endian out from under the
running code instead of waiting for the rfid, causing an immediate trap
as it attempts to interpret the next instruction in the wrong endianness.

To work around this, ensure PSL_LE is still set before doing the mtmsrd.

In the future, we may wish to just turn off translation and unconditionally
use rfid to switch to the ofmsr instead of quasi-switching to the ofmsr.

Add a new platform option so this can be disabled. (And so that we can
conditonalize additional QEMU-specific hacks in the platform code.)

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix endianness issues in phyp and opal consoles.
bdragon [Wed, 23 Sep 2020 00:06:48 +0000 (00:06 +0000)]
[PowerPC64LE] Fix endianness issues in phyp and opal consoles.

This applies to both pseries and powernv, which were tested at different
points during the patchset development.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Tell the hypervisor to switch interrupts to LE at CHRP attach.
bdragon [Wed, 23 Sep 2020 00:03:35 +0000 (00:03 +0000)]
[PowerPC64LE] Tell the hypervisor to switch interrupts to LE at CHRP attach.

Since we will need to be able to take traps relatively early in the process,
ensure that the hypervisor changes our ILE for us as soon as we are ready.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix endian dependence of ofw_real.c.
bdragon [Tue, 22 Sep 2020 23:59:02 +0000 (23:59 +0000)]
[PowerPC64LE] Fix endian dependence of ofw_real.c.

Since OFW always runs in big endian in practice, we need to convert several
bits back and forth.

This is necessary to communicate with SLOF on LE pseries.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] LE bringup work: locore / machdep / platform
bdragon [Tue, 22 Sep 2020 23:55:34 +0000 (23:55 +0000)]
[PowerPC64LE] LE bringup work: locore / machdep / platform

This is the initial LE changes required in the machdep code to get as far
as platform attachment on qemu pseries.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Set up powerpc.powerpc64le architecture
bdragon [Tue, 22 Sep 2020 23:49:30 +0000 (23:49 +0000)]
[PowerPC64LE] Set up powerpc.powerpc64le architecture

This is the initial set up for PowerPC64LE.

The current plan is for this arch to remain experimental for FreeBSD 13.

This started as a weekend learning project for me and kinda snowballed from
there.

(More to follow momentarily.)

Reviewed by: imp (earlier version), emaste
Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D26399

3 years agoRemove stray line
kib [Tue, 22 Sep 2020 23:39:14 +0000 (23:39 +0000)]
Remove stray line

3 years agoamd64 pmap: More unification for psind = 1 vs 2 in pmap_enter_largepage().
kib [Tue, 22 Sep 2020 23:28:06 +0000 (23:28 +0000)]
amd64 pmap: More unification for psind = 1 vs 2 in pmap_enter_largepage().

Move
  pkru check
  wait for page alloc
  wire accounting update
  asserting allowed updates for valid mappings
out of psind conditions.

Also add assert that psind references supported page size.
Remove not true comment.
Avoid uneccessary page table walks from top level.

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

3 years agoTweak ficl definition from r365724
bdragon [Tue, 22 Sep 2020 23:27:09 +0000 (23:27 +0000)]
Tweak ficl definition from r365724

I had overthought how to do the FICL_TRUE change. We do not need to
explicitly specify how big the 0 is before the cast to the correct size.

The same change was suggested by both imp@ and Gunther Nikl independently.

Tested on powerpc.

Reported by: imp, Gunther Nikl

3 years agoAdd devctl_notify(9) man page
imp [Tue, 22 Sep 2020 23:02:01 +0000 (23:02 +0000)]
Add devctl_notify(9) man page

Document the calls to send messages to userland via devctl.
devctl_notify will create a message for the specified system,
subsystem and type, optionally adding additional information.

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D26520

3 years agoDocument quoting requirements for the devctl protocol
imp [Tue, 22 Sep 2020 23:01:57 +0000 (23:01 +0000)]
Document quoting requirements for the devctl protocol

Belatedly document the quoting requirements for the devctl protocol. I
thought they'd been previously documented.

Also, while I'm here, make igor happy.

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D26520

3 years agoDocument devctl_safe_quote_sb
imp [Tue, 22 Sep 2020 23:01:53 +0000 (23:01 +0000)]
Document devctl_safe_quote_sb

This routine centralizes the knowledge needed for properly quoting
'value' in all key="value" items that appear in devctl messages.

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D26520

3 years agoAdd a devctl_process_running man page.
imp [Tue, 22 Sep 2020 23:01:44 +0000 (23:01 +0000)]
Add a devctl_process_running man page.

Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D26520

3 years agoDocument {O,AT}_RESOLVE_BENEATH and new O_BENEATH behavior for relative paths.
kib [Tue, 22 Sep 2020 22:54:54 +0000 (22:54 +0000)]
Document {O,AT}_RESOLVE_BENEATH and new O_BENEATH behavior for relative paths.

PR: 248335
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoAdd O_RESOLVE_BENEATH and AT_RESOLVE_BENEATH to mimic Linux' RESOLVE_BENEATH.
kib [Tue, 22 Sep 2020 22:48:12 +0000 (22:48 +0000)]
Add O_RESOLVE_BENEATH and AT_RESOLVE_BENEATH to mimic Linux' RESOLVE_BENEATH.

It is like O_BENEATH, but disables to walk out of the subtree rooted
in the starting directory. O_BENEATH does not care if path walks out
if it returned.

Requested by: Dan Gohman <dev@sunfishcode.online>
PR: 248335
Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoChange O_BENEATH to handle relative paths same as absolute.
kib [Tue, 22 Sep 2020 22:43:32 +0000 (22:43 +0000)]
Change O_BENEATH to handle relative paths same as absolute.

Do not care if path walks out of the topping directory if it returns back.

Requested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoOnly clear latch for BENEATH when we walk out of the startdir,
kib [Tue, 22 Sep 2020 22:36:02 +0000 (22:36 +0000)]
Only clear latch for BENEATH when we walk out of the startdir,

not unconditionally on any dotdot component.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoAdd open2nameif()
kib [Tue, 22 Sep 2020 22:23:58 +0000 (22:23 +0000)]
Add open2nameif()

the helper to calculate namei flags both for open(2) and creat(2).

Suggested and reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoAdd at2cnpflags()
kib [Tue, 22 Sep 2020 22:22:29 +0000 (22:22 +0000)]
Add at2cnpflags()

the helper to convert AT_ flags for *at() syscalls to namei flags.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoAdd NIRES_STRICTREL.
kib [Tue, 22 Sep 2020 22:06:20 +0000 (22:06 +0000)]
Add NIRES_STRICTREL.

Stop abusing internal namei flag NI_LCF_STRICTRELATIVE as indicator of
cap-restricted lookup.  Add designated returned flag NIRES_STRICTREL
to inform kern_openat() that lookup was restricted.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agolookup: Track last lookup component if it is directory.
kib [Tue, 22 Sep 2020 21:59:18 +0000 (21:59 +0000)]
lookup: Track last lookup component if it is directory.

This makes open("/a/../a", O_BENEATH) with cwd == "/a" work.

Reviewed by: markj
Reported and tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoImprove comment above nameicap_check_dotdot().
kib [Tue, 22 Sep 2020 21:54:30 +0000 (21:54 +0000)]
Improve comment above nameicap_check_dotdot().

Explain why tracker is needed at all.

Reviewed by: markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D25886

3 years agoFix a bunch of mdoc issues found by mandoc -Tlint.
brueffer [Tue, 22 Sep 2020 21:13:26 +0000 (21:13 +0000)]
Fix a bunch of mdoc issues found by mandoc -Tlint.

3 years agolibnetmap: fix cast from uint64_t to void*
vmaffione [Tue, 22 Sep 2020 20:20:43 +0000 (20:20 +0000)]
libnetmap: fix cast from uint64_t to void*

We use uintptr_t as an intermediate cast to avoid compiler
warnings on 32 bit architectures.

Reported by: adrian
MFC after: 3 days

3 years agoudf: Validate the full file entry length
markj [Tue, 22 Sep 2020 17:05:01 +0000 (17:05 +0000)]
udf: Validate the full file entry length

Otherwise a corrupted file entry containing invalid extended attribute
lengths or allocation descriptor lengths can trigger an overflow when
the file entry is loaded.

admbug: 965
PR: 248613
Reported by: C Turt <ecturt@gmail.com>
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

3 years agoMerge OpenSSL 1.1.1h.
jkim [Tue, 22 Sep 2020 16:18:31 +0000 (16:18 +0000)]
Merge OpenSSL 1.1.1h.

3 years agoftpd: Add missing braces around a statfd check
markj [Tue, 22 Sep 2020 15:54:18 +0000 (15:54 +0000)]
ftpd: Add missing braces around a statfd check

This was harmless but looked incorrect.  No functional change intended.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agotftpd: Check for errors from chdir()
markj [Tue, 22 Sep 2020 15:54:05 +0000 (15:54 +0000)]
tftpd: Check for errors from chdir()

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

3 years agoRISC-V: build SiFive drivers and DTB in GENERIC
mhorne [Tue, 22 Sep 2020 13:00:02 +0000 (13:00 +0000)]
RISC-V: build SiFive drivers and DTB in GENERIC

In the spirit of the GENERIC config, we should include the drivers required to
run on most supported platforms.

Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D26501

3 years agocxgbe(4): let the PF driver use VM work requests for transmit.
np [Tue, 22 Sep 2020 04:16:40 +0000 (04:16 +0000)]
cxgbe(4): let the PF driver use VM work requests for transmit.

This allows the PF interfaces to communicate with the VF interfaces over
the internal switch in the ASIC.  Fix the GL limits for VM work requests
while here.

MFC after: 3 days
Sponsored by: Chelsio Communications

3 years agoAdd missing cylinder group check-hash updates when doing large expansions
mckusick [Tue, 22 Sep 2020 03:57:48 +0000 (03:57 +0000)]
Add missing cylinder group check-hash updates when doing large expansions
of filesystems.

Reported by:  Colin Percival (cperciva@)
Tested by:    Colin Percival (cperciva@)
MFC after:    3 days
Sponsored by: Netflix

3 years agocxgbe(4): add counters for mbuf pullups and defrags.
np [Tue, 22 Sep 2020 03:06:36 +0000 (03:06 +0000)]
cxgbe(4): add counters for mbuf pullups and defrags.

MFC after: 3 days
Sponsored by: Chelsio Communications

3 years agoRemove claim that Allied Forces created "West Germany" in 1953. I can
grog [Mon, 21 Sep 2020 22:55:51 +0000 (22:55 +0000)]
Remove claim that Allied Forces created "West Germany" in 1953.  I can
find no historic substantiation for such a claim.  The Federal
Republic of Germany was created by Germans on 23 May 1949, as also
noted in this file.

3 years agostand/reloc_elf: Handle relative relocations for arm{,64} and riscv
scottph [Mon, 21 Sep 2020 22:24:46 +0000 (22:24 +0000)]
stand/reloc_elf: Handle relative relocations for arm{,64} and riscv

Extend the powerpc relative relocation handling from r240782 to a
handful of other architectures.  This is needed to properly read
dependency information from kernel modules.

Reviewed by: jhb
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26365

3 years agoarm64/pmap: Sparsify pv_table
scottph [Mon, 21 Sep 2020 22:23:57 +0000 (22:23 +0000)]
arm64/pmap: Sparsify pv_table

Reviewed by: markj, kib
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26132

3 years agovm_reserv: Sparsify the vm_reserv_array when VM_PHYSSEG_SPARSE
scottph [Mon, 21 Sep 2020 22:22:53 +0000 (22:22 +0000)]
vm_reserv: Sparsify the vm_reserv_array when VM_PHYSSEG_SPARSE

On an Ampere Altra system, the physical memory is populated
sparsely within the physical address space, with only about 0.4%
of physical addresses backed by RAM in the range [0, last_pa].

This is causing the vm_reserv_array to be over-sized by a few
orders of magnitude, wasting roughly 5 GiB on a system with
256 GiB of RAM.

The sparse allocation of vm_reserv_array is controlled by defining
VM_PHYSSEG_SPARSE, with the dense allocation still remaining for
platforms with VM_PHYSSEG_DENSE.

Reviewed by: markj, alc, kib
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26130

3 years agoSparsify the vm_page_dump bitmap
scottph [Mon, 21 Sep 2020 22:21:59 +0000 (22:21 +0000)]
Sparsify the vm_page_dump bitmap

On Ampere Altra systems, the sparse population of RAM within the
physical address space causes the vm_page_dump bitmap to be much
larger than necessary, increasing the size from ~8 Mib to > 2 Gib
(and overflowing `int` for the size).

Changing the page dump bitmap also changes the minidump file
format, so changes are also necessary in libkvm.

Reviewed by: jhb
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26131

3 years agoMove vm_page_dump bitset array definition to MI code
scottph [Mon, 21 Sep 2020 22:20:37 +0000 (22:20 +0000)]
Move vm_page_dump bitset array definition to MI code

These definitions were repeated by all architectures, with small
variations. Consolidate the common definitons in machine
independent code and use bitset(9) macros for manipulation. Many
opportunities for deduplication remain in the machine dependent
minidump logic. The only intended functional change is increasing
the bit index type to vm_pindex_t, allowing the indexing of pages
with address of 8 TiB and greater.

Reviewed by: kib, markj
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26129

3 years agoWeaken assertions in pmap_l1_to_l2() and pmap_l2_to_l3().
markj [Mon, 21 Sep 2020 22:19:21 +0000 (22:19 +0000)]
Weaken assertions in pmap_l1_to_l2() and pmap_l2_to_l3().

pmap_update_entry() will temporarily clear the valid bit of page table
entries in order to satisfy the arm64 pmap's break-before-make
constraint.  pmap_kextract() may operate concurrently on kernel page
table pages, introducing windows where the assertions added in r365879
may fail incorrectly since they implicitly assert that the valid bit is
set.  Modify the assertions to handle this.

Reviewed by: andrew, mmel (previous version)
Reviewed by: alc, kib
Reported by: mmel, scottph
MFC with: r365879

3 years agobitset: expand bit index type to `long`
scottph [Mon, 21 Sep 2020 22:19:12 +0000 (22:19 +0000)]
bitset: expand bit index type to `long`

An upcoming patch to use the bitset macros for tracking vm page
dump information could conceivably need more than INT_MAX bits.
Expand the bit type to long so that the extra range is available
on 64-bit platforms where it would most likely be needed.

CPUSET_COUNT and DOMAINSET_COUNT are also modified to remain of
type `int`.

Reviewed by: kib, markj
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26190

3 years agovchi: rename bitset macros to avoid collision with bitset(9)
scottph [Mon, 21 Sep 2020 22:18:09 +0000 (22:18 +0000)]
vchi: rename bitset macros to avoid collision with bitset(9)

An upcoming change to include bitset(9) macros from vm_page.h
causes a macro name collision with vchi's custom bitset macros.

This change was performed mechanically by:

  sed -i .orig s/BITSET/VCHI_BITSET/g $(grep -rl BITSET sys/contrib/vchiq)

Reviewed by: andrew
Approved by: scottl (implicit)
MFC after: 1 week
Sponsored by: Ampere Computing, Inc.
Differential Revision: https://reviews.freebsd.org/D26177

3 years agoRework part of routing code to reduce difference to D26449.
melifaro [Mon, 21 Sep 2020 20:02:26 +0000 (20:02 +0000)]
Rework part of routing code to reduce difference to D26449.

* Split rt_setmetrics into get_info_weight() and rt_set_expire_info(),
 as these two can be applied at different entities and at different times.
* Start filling route weight in route change notifications
* Pass flowid to UDP/raw IP route lookups
* Rework nd6_subscription_cb() and sysctl_dumpentry() to prepare for the fact
 that rtentry can contain multiple nexthops.

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

3 years agobsdbox: fix build after recent libifconfig changes
kevans [Mon, 21 Sep 2020 19:50:39 +0000 (19:50 +0000)]
bsdbox: fix build after recent libifconfig changes

libifconfig now generates file(s) into its .OBJDIR that are essential to the
build. Make sure we -I that in, like we already do in the ^/rescue build.

3 years agomkcsmapper: Fix UBSan signed shift error
arichardson [Mon, 21 Sep 2020 19:03:17 +0000 (19:03 +0000)]
mkcsmapper: Fix UBSan signed shift error

usr.bin/mkcsmapper/yacc.y:466:18: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'

3 years agoFix another UBSan error in awk
arichardson [Mon, 21 Sep 2020 19:03:12 +0000 (19:03 +0000)]
Fix another UBSan error in awk

This applies my upstreamed fix: https://github.com/onetrueawk/awk/commit/ad9bd2f40a89ec9533b92254b86a756cf4f40fd4
Found By: UBSan

3 years agoawk: Fix subobject out-of-bounds access
arichardson [Mon, 21 Sep 2020 19:03:07 +0000 (19:03 +0000)]
awk: Fix subobject out-of-bounds access

When matching a regex with ^, it would attempt to access
gototab[NSTATES][NCHARS+2], and therefore access the state for the \002
character instead. This change is required to run awk under CHERI (with
sub-object bounds) and when running with UBSan instrumentation.

This was committed upstream as https://github.com/onetrueawk/awk/commit/cbf924342b63a095a4c6842280c3085b1b63ae45

Found by: CHERI (with subobject bounds enabled)
Obtained from: CheriBSD
Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D26509

3 years agoWhitespace fix after r365948
dab [Mon, 21 Sep 2020 18:34:13 +0000 (18:34 +0000)]
Whitespace fix after r365948

MFC after: 1 week
Sponsored by: Dell EMC Isilon

3 years agoAdd support for Winbond USB CDC modem device found in Tenma power supply.
hselasky [Mon, 21 Sep 2020 18:32:57 +0000 (18:32 +0000)]
Add support for Winbond USB CDC modem device found in Tenma power supply.

PR: 249384
MFC after: 1 week
Submitted by: darius@dons.net.au
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years agoAdd example to ng_bpf(4) showing how ng_bpf(4) can be used to prevent spoofing.
hselasky [Mon, 21 Sep 2020 18:17:01 +0000 (18:17 +0000)]
Add example to ng_bpf(4) showing how ng_bpf(4) can be used to prevent spoofing.

Differential Revision: https://reviews.freebsd.org/D26488
MFC after: 1 week
Reviewed by: pi, bcr (manpages)
Submitted by: lutz_donnerhacke.de (Lutz Donnerhacke)
Sponsored by: Mellanox Technologies // NVIDIA Networking

3 years ago[rcorder] [crunch] Fix C function declarations to include void
adrian [Mon, 21 Sep 2020 17:59:45 +0000 (17:59 +0000)]
[rcorder] [crunch] Fix C function declarations to include void

This fixes a compile issue under gcc6 which complains about
legacy style C function declarations.

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

3 years agofsx: fix build with WARNS=6
asomers [Mon, 21 Sep 2020 17:48:28 +0000 (17:48 +0000)]
fsx: fix build with WARNS=6

* signed/unsigned comparisons
* use standard warn(3)
* Suppress warnings about local vars and funcs not declared static
* const-correctness
* declaration shadows a variable in the global scope

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

3 years agoHide tunable definitions behind _KERNEL
mhorne [Mon, 21 Sep 2020 17:28:41 +0000 (17:28 +0000)]
Hide tunable definitions behind _KERNEL

Some userspace code include sys/kernel.h. Namely, some OpenZFS tests do
this, and it was causing breakage after r365945 due to a lack of bool
typedef. Userspace should not need the TUNABLE_** stuff, so hide it
behind an #ifdef _KERNEL.

Sorry for the breakage.

Reported by: andrew, Michael Butler, Jenkins
Discussed with: kevans, allanjude

3 years agoxargs: add some long options for GNU compatibility
kevans [Mon, 21 Sep 2020 17:06:36 +0000 (17:06 +0000)]
xargs: add some long options for GNU compatibility

These are low-effort to add, so let's just do it.

Reported by: "LukeShu" on Hacker News (-r / --no-run-if-empty)
MFC after: 1 week

3 years agoPull in fix from upstream NetBSD rev. 1.5:
phk [Mon, 21 Sep 2020 16:43:38 +0000 (16:43 +0000)]
Pull in fix from upstream NetBSD rev. 1.5:

    If Unwind_Backtrace is broken, ctx.n will still contain ~0, and we will
    return that which poor behavior for the user, so return 0 instead.
    We could document ~0 to be an error, but that would deviate from the
    Linux behavior which is not desirable. Noted by Poul-Henning Kamp

PR: 209842

3 years agoamd64 pmap: only calculate page table page when needed.
kib [Mon, 21 Sep 2020 15:53:41 +0000 (15:53 +0000)]
amd64 pmap: only calculate page table page when needed.

Noted by: alc
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26499

3 years agoWhen building on Ubuntu bootstrap bmake with bash as the default shell
arichardson [Mon, 21 Sep 2020 15:49:02 +0000 (15:49 +0000)]
When building on Ubuntu bootstrap bmake with bash as the default shell

The Ubuntu /bin/sh (dash) removes all environment variables that contain
characters outside the [a-zA-Z0-9_] range and this breaks the bmake tests that
run as part of bootstrapping bmake.
This can be reverted when the bmake tests have been updated.

3 years agoAdd a tools/build/make.py script that bootstraps bmake and then runs the build
arichardson [Mon, 21 Sep 2020 15:48:57 +0000 (15:48 +0000)]
Add a tools/build/make.py script that bootstraps bmake and then runs the build

This makes it possible to compile on non-FreeBSD systems since make will
usually be GNU make there. Even if they include bmake, it will often
either be a broken version or too old to build FreeBSD.

This should be the last commit needed to compile FreeBSD on Linux+macOS.
After over two years, I've finally managed to upstream all our local CheriBSD
changes to allow building on Linux (and as a result of being reviewed by more
people they are slightly less ugly than they were before).

It should now be possible to run the following to build on Linux+macOS if you
have LLVM/Clang 10 or newer installed:
MAKEOBJDIRPREFIX=/somewhere ./tools/build/make.py TARGET=amd64 TARGET_ARCH=amd64 buildworld

I have only tested macOS 15, Ubuntu 18.04 and openSUSE Leap, but other Linux
distributions might also work (as long as they ship a recent GLibc and compiler).

Reviewed By: emaste (should be fine to commit to tools/)
Differential Revision: https://reviews.freebsd.org/D16767

3 years agoHonor the FWUG value of some drives in nvmecontrol
dab [Mon, 21 Sep 2020 15:45:49 +0000 (15:45 +0000)]
Honor the FWUG value of some drives in nvmecontrol

nvmecontrol tries to upload firmware in chunks as large as it thinks
the device permits. It fails to take into account the FWUG value used
by some drives to advertise the size and alignment limits for firmware
chunks.

  - Use the firwmare update granularity value from the
  - If the granularity is not reported or not restricted, fall back to
    the previously existing logic that calculates the max transfer
    size based on MDTS.
  - Add firmware update granularity to the identify-controller output.

Reviewed by: imp (previous version), chuck
Obtained from: Dell EMC Isilon
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D26390

3 years agoUse getenv_is_true() in init_static_kenv()
mhorne [Mon, 21 Sep 2020 15:44:23 +0000 (15:44 +0000)]
Use getenv_is_true() in init_static_kenv()

A small example of how these functions can be used to simplify checks of
this nature.

Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26271

3 years agoAdd an ioctl to get an NVMe device's maximum transfer size
dab [Mon, 21 Sep 2020 15:41:47 +0000 (15:41 +0000)]
Add an ioctl to get an NVMe device's maximum transfer size

Reviewed by: imp, chuck
Obtained from: Dell EMC Isilon
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D26390

3 years agoAdd getenv(9) boolean parsing functions
mhorne [Mon, 21 Sep 2020 15:24:44 +0000 (15:24 +0000)]
Add getenv(9) boolean parsing functions

This adds the getenv_bool() function, to parse a boolean value from a
kernel environment variable or tunable. This works for traditional
boolean values like "0" and "1", and also "true" and "false"
(case-insensitive). These semantics do not yet apply to sysctls declared
using SYSCTL_BOOL with CTLFLAG_TUN (they still only parse 1 and 0).

Also added are two wrapper functions, getenv_is_true() and
getenv_is_false(). These are slightly simpler for callers wishing to
perform a single check of a configuration variable.

Reviewed by: jhb (slightly earlier version)
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26270

3 years agoaw_usbphy: add support for device mode operation
avg [Mon, 21 Sep 2020 10:02:11 +0000 (10:02 +0000)]
aw_usbphy: add support for device mode operation

OTG mode is not supported still.  It's easy to do it as a one-off
detection, but the proper support requires continuous monitoring and
communicating the current state to the USB layer.

Also, fix phy0_route setting for H3.  Remove duplicate register
definitions.

Tested on Orange Pi PC Plus with dr_mode="peripheral" using
  hw.usb.template=3
  umodem_load="YES"

Reviewed by: manu
MFC after: 5 weeks
Differential Revision: https://reviews.freebsd.org/D26348

3 years agoFix vi build on Linux/macOS
arichardson [Mon, 21 Sep 2020 09:03:42 +0000 (09:03 +0000)]
Fix vi build on Linux/macOS

This absolute include causes a build failure on Linux for me:
.../cheri/freebsd/contrib/nvi/cl/../common/common.h:10:10: fatal error: '/usr/include/db.h' file not found

This change patches the file to use #include <db.h> instead until a
solution has been found upstream. See also https://github.com/lichray/nvi2/issues/69

Reviewed By: bapt
Differential Revision: https://reviews.freebsd.org/D26480

3 years agoFix -Wpointer-sign warnings in usr.bin/grep
arichardson [Mon, 21 Sep 2020 09:03:37 +0000 (09:03 +0000)]
Fix -Wpointer-sign warnings in usr.bin/grep

Reviewed By: kevans
Differential Revision: https://reviews.freebsd.org/D26479

3 years agoPrefer bootstrapped tools when running certctl.sh
arichardson [Mon, 21 Sep 2020 09:03:32 +0000 (09:03 +0000)]
Prefer bootstrapped tools when running certctl.sh

Otherwise we get lots of warnings when building on Linux/macOS during
installworld:
Scanning /local/scratch/alr48/cheri/output/freebsd-x86/usr/share/certs/blacklisted for certificates...
install: invalid option -- 'U'
Try 'install --help' for more information.
install: invalid option -- 'U'
....

Reviewed By: kevans
Differential Revision: https://reviews.freebsd.org/D26481

3 years agoloader: zfs should support bootonce an nextboot
tsoome [Mon, 21 Sep 2020 09:01:10 +0000 (09:01 +0000)]
loader: zfs should support bootonce an nextboot

bootonce feature is temporary, one time boot, activated by
"bectl activate -t BE", "bectl activate -T BE" will reset the bootonce flag.

By default, the bootonce setting is reset on attempt to boot and the next
boot will use previously active BE.

By setting zfs_bootonce_activate="YES" in rc.conf, the bootonce BE will
be set permanently active.

bootonce dataset name is recorded in boot pool labels, bootenv area.

in case of nextboot, the nextboot_enable boolean variable is recorded in
freebsd:nvstore nvlist, also stored in boot pool label bootenv area.
On boot, the loader will process /boot/nextboot.conf if nextboot_enable
is "YES", and will set nextboot_enable to "NO", preventing /boot/nextboot.conf
processing on next boot.

bootonce and nextboot features are usable in both UEFI and BIOS boot.

To use bootonce/nextboot features, the boot loader needs to be updated on disk;
if loader.efi is stored on ESP, then ESP needs to be updated and
for BIOS boot, stage2 (zfsboot or gptzfsboot) needs to be updated
(gpart or other tools).

At this time, only lua loader is updated.

Sponsored by: Netflix, Klara Inc.
Differential Revision: https://reviews.freebsd.org/D25512

3 years agoatomic_common.h: Fix the volatile qualifier placement in atomic_load_ptr
jrtc27 [Sun, 20 Sep 2020 23:20:18 +0000 (23:20 +0000)]
atomic_common.h: Fix the volatile qualifier placement in atomic_load_ptr

This was broken in r357940 which introduced the __typeof use. We need
the volatile qualifier to be on the pointee not the pointer otherwise it
does nothing. This was found by mhorne in D26498, noticing there was a
problem (a spin loop condition was hoisted for RISC-V boot code) but not
the root cause of it.

Reported by: mhorne
Reviewed by: mhorne, mjg
Approved by: mhorne, mjg
Differential Revision: https://reviews.freebsd.org/D26500

3 years agoamd64 pmap: handle cases where pml4 page table page is not allocated.
kib [Sun, 20 Sep 2020 22:16:24 +0000 (22:16 +0000)]
amd64 pmap: handle cases where pml4 page table page is not allocated.

Possible in LA57 pmap config.

Noted by: alc
Reviewed by: alc, markj
Sponsored by: The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D26492

3 years agoRemove unused nhop_ref_any() function.
melifaro [Sun, 20 Sep 2020 21:32:52 +0000 (21:32 +0000)]
Remove unused nhop_ref_any() function.
Remove "opt_mpath.h" header where not needed.

No functional changes.

3 years agoAdjust DMA alignment for USB stack.
mmel [Sun, 20 Sep 2020 17:28:24 +0000 (17:28 +0000)]
Adjust DMA alignment for USB stack.
It should be at least as large as the maximum value of caheline size
for currently known CPUs.

MFC after: 2 weeks

3 years agoarm: allwinner: aw_nmi: Fix wrong logic when we disable the nmi
manu [Sun, 20 Sep 2020 16:11:38 +0000 (16:11 +0000)]
arm: allwinner: aw_nmi: Fix wrong logic when we disable the nmi

MFC after: 1 week

3 years agoAdd missing assignment forgotten in r365899
mmel [Sun, 20 Sep 2020 15:11:52 +0000 (15:11 +0000)]
Add missing assignment forgotten in r365899

Noticed by: mav
MFC after: 1 month
MFC with: r365899

3 years agoFix gw updates / flag updates during route changes.
melifaro [Sun, 20 Sep 2020 12:31:48 +0000 (12:31 +0000)]
Fix gw updates / flag updates during route changes.

* Zero gw_sdl if switching to interface route - the assumption
 that underlying storage is zeroed is incorrect with route changes.
* Apply proper flag mask to rte.

Reported by: vangyzen

3 years agoApply an opimization for the kernels used by cexp(x) and cexpf(x) submitted
se [Sun, 20 Sep 2020 05:32:53 +0000 (05:32 +0000)]
Apply an opimization for the kernels used by cexp(x) and cexpf(x) submitted
by Steve Kargl:

- Use sincos[f] instead of a call to cos[f] and a call to sin[f].

- While here, alphabetize declaration.

Submitted by:   sgk at troutmask.apl.washington.edu (Steve Kargl)

3 years agoApply fix for ld80 and ld128 submitted by Steve Kargl:
se [Sun, 20 Sep 2020 05:28:31 +0000 (05:28 +0000)]
Apply fix for ld80 and ld128 submitted by Steve Kargl:

- Micro-optimization: use sincosl(x) instead of a call to cosl(x) and
  a call to sinl(x).  Argument reduction is done once not twice.

- Use a long double constant instead of an invalid double constant.

- Spell scale2 correctly

He could not test ld128, so that patch is untested.

Submitted by: sgk at troutmask.apl.washington.edu (Steve Kargl)

3 years agoUpdate the libufs cgget() and cgput() interfaces to have a similar
mckusick [Sat, 19 Sep 2020 22:48:30 +0000 (22:48 +0000)]
Update the libufs cgget() and cgput() interfaces to have a similar
API to the sbget() and sbput() interfaces. Specifically they take
a file descriptor pointer rather than the struct uufsd *disk pointer
used by the libufs cgread() and cgwrite() interfaces. Update fsck_ffs
to use these revised interfaces.

No functional changes intended.

Sponsored by: Netflix

3 years agoFix for use of the XHCI driver on Cortex-A72 by adding a missing cache
hselasky [Sat, 19 Sep 2020 22:37:45 +0000 (22:37 +0000)]
Fix for use of the XHCI driver on Cortex-A72 by adding a missing cache
flush operation before writing to the XHCI_ERSTBA_LO/HI register(s).

PR: 237666
Discussed with: Mark Millard <marklmi@yahoo.com>
MFC after: 1 week
Sponsored by: Mellanox Technologies // Nvidia

3 years agoThe fsdb(8) utility uses the fsck_ffs(8) disk I/O interfaces, so
mckusick [Sat, 19 Sep 2020 20:06:12 +0000 (20:06 +0000)]
The fsdb(8) utility uses the fsck_ffs(8) disk I/O interfaces, so
switch from using libufs's bread() to using fsck_ffs's getdatablk()
when importing tools/diag/prtblnos's prtblknos().

Sponsored by: Netflix

3 years agofix integer underflow in getgrnam_r and getpwnam_r
asomers [Sat, 19 Sep 2020 19:08:27 +0000 (19:08 +0000)]
fix integer underflow in getgrnam_r and getpwnam_r

Sometimes nscd(8) will return a 1-byte buffer for a nonexistent entry. This
triggered an integer underflow in grp_unmarshal_func, causing getgrnam_r to
return ERANGE instead of 0.

Fix the user's buffer size check, and add a correct check for a too-small
nscd buffer.

PR: 248932
Event: September 2020 Bugathon
Reviewed by: markj
MFC after: 2 weeks
Sponsored by: Axcient
Differential Revision: https://reviews.freebsd.org/D26204

3 years agoAddress compiler warnings in C code used by the DTrace test suite.
markj [Sat, 19 Sep 2020 16:15:22 +0000 (16:15 +0000)]
Address compiler warnings in C code used by the DTrace test suite.

Reported by: Jenkins
MFC after: 1 week

3 years agoFix some nits in 1G page support in the amd64 pmap.
markj [Sat, 19 Sep 2020 15:22:04 +0000 (15:22 +0000)]
Fix some nits in 1G page support in the amd64 pmap.

- Move assertions out of the main loop to avoid duplicate conditional
  expressions, and improve assertion messages.
- Fix va_next updates.  In some cases we were not doing the wraparound
  check before continuing the loop.
- Use the right va_next.  In pmap_advise() and pmap_copy() we would step
  through 1G pages 2M at a time.
- Copy 1G mappings in pmap_copy().

Reviewed by: alc, kib
MFC with: r365518
Sponsored by: Juniper Networks, Inc., Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26463

3 years agodiskless(8): Correct Sections out of conventional order error
gbe [Sat, 19 Sep 2020 15:10:17 +0000 (15:10 +0000)]
diskless(8): Correct Sections out of conventional order error

Event: September 2020 Bugathon
MFC after: 1 week

3 years agocrypto(7): Correct Sections out of conventional order error
gbe [Sat, 19 Sep 2020 15:08:57 +0000 (15:08 +0000)]
crypto(7): Correct Sections out of conventional order error

Event: September 2020 Bugathon
MFC after: 1 week

3 years agosrc.conf(5): Fix some mandoc issues in source files
gbe [Sat, 19 Sep 2020 14:49:31 +0000 (14:49 +0000)]
src.conf(5): Fix some mandoc issues in source files

- new sentence, new line
- blank line in fill mode

Event: September 2020 Bugathon
MFC after: 1 week

3 years agoCirrus-CI: skip svn_head branch
emaste [Sat, 19 Sep 2020 13:55:26 +0000 (13:55 +0000)]
Cirrus-CI: skip svn_head branch

svn_head has the same content as the master or main branch (it's just
the result of a `git svn` conversion instead of svn2git).

Sponsored by: The FreeBSD Foundation

3 years agoFix dtrace tools bootstrap on non-FreeBSD after OpenZFS import
arichardson [Sat, 19 Sep 2020 12:08:16 +0000 (12:08 +0000)]
Fix dtrace tools bootstrap on non-FreeBSD after OpenZFS import

This required surprisingly few build system changes and only two changes to the
openZFS compat headers which have been upstreamed as
https://github.com/openzfs/zfs/pull/10863

Reviewed By: #zfs, freqlabs
Differential Revision: https://reviews.freebsd.org/D26193

3 years agoImplement workaround for broken access to configuration space.
mmel [Sat, 19 Sep 2020 11:27:16 +0000 (11:27 +0000)]
Implement workaround for broken access to configuration space.
Due to a HW bug in the RockChip PCIe implementation, attempting to access
a non-existent register in the configuration space will throw an exception.
Use new bus functions bus_peek() and bus_poke() to overcomme this limitation.

3 years agoAdd NetBSD compatible bus_space_peek_N() and bus_space_poke_N() functions.
mmel [Sat, 19 Sep 2020 11:06:41 +0000 (11:06 +0000)]
Add NetBSD compatible bus_space_peek_N() and bus_space_poke_N() functions.
One problem with the bus_space_read_N() and bus_space_write_N() family of
functions is that they provide no protection against exceptions which can
occur when no physical hardware or device responds to the read or write
cycles. In such a situation, the system typically would panic due to a
kernel-mode bus error. The bus_space_peek_N() and bus_space_poke_N() family
of functions provide a mechanism to handle these exceptions gracefully
without the risk of crashing the system.

Typical example is access to PCI(e) configuration space in bus enumeration
function on badly implemented PCI(e) root complexes (RK3399 or Neoverse
N1 N1SDP and/or access to PCI(e) register when device is in deep sleep state.

This commit adds a real implementation for arm64 only. The remaining
architectures have bus_space_peek()/bus_space_poke() emulated by using
bus_space_read()/bus_space_write() (without exception handling).

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

3 years agoMove finalize_components_config from get_params to cmd_*.
cperciva [Sat, 19 Sep 2020 02:15:56 +0000 (02:15 +0000)]
Move finalize_components_config from get_params to cmd_*.

This allows us to redirect its output in cmd_cron, so that the
"src component not installed, skipped" message will be treated
the same way as other output from freebsd-update cron: Sent
in an email to root (or other address specified) if there are
updates to install, and silenced otherwise.

PR: 202492
MFC After: 1 week
Differential Revision: https://reviews.freebsd.org/D26432

3 years agocaroot: update base store
kevans [Sat, 19 Sep 2020 01:59:17 +0000 (01:59 +0000)]
caroot: update base store

Count:
- Two (2) removed
- Three (3) added

MFC after: 3 days

3 years agoFix a LOR between the NFS server and server side krpc.
rmacklem [Fri, 18 Sep 2020 23:52:56 +0000 (23:52 +0000)]
Fix a LOR between the NFS server and server side krpc.

Recent testing of the NFS-over-TLS code found a LOR between the mutex lock
used for sessions and the sleep lock used for server side krpc socket
structures in nfsrv_checksequence().  This was fixed by r365789.
A similar bug exists in nfsrv_bindconnsess(), where SVC_RELEASE() is called
while mutexes are held.
This patch applies a fix similar to r365789, moving the SVC_RELEASE() call
down to after the mutexes are released.

This patch fixes the problem by moving the SVC_RELEASE() call in
nfsrv_checksequence() down a few lines to below where the mutex is released.

MFC after: 1 week

3 years agoMFV 2.0-rc2
mmacy [Fri, 18 Sep 2020 23:21:24 +0000 (23:21 +0000)]
MFV 2.0-rc2

- Fixes divide by zero for unusual hz
- remove cryptodev dependency

3 years agoUpdate openzfs to 2.0.0-rc2-g4ce06f
mmacy [Fri, 18 Sep 2020 22:55:05 +0000 (22:55 +0000)]
Update openzfs to 2.0.0-rc2-g4ce06f