]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoaw_pwm: fix programming of the period
avg [Fri, 25 Sep 2020 07:40:26 +0000 (07:40 +0000)]
aw_pwm: fix programming of the period

The programmed value is biased by one: 0 means 1 cycle,
1 means 2 cycles, etc.

MFC after: 3 weeks

3 years agoaw_pwm: fix selection of the prescaler
avg [Fri, 25 Sep 2020 07:40:02 +0000 (07:40 +0000)]
aw_pwm: fix selection of the prescaler

Prescaling divides the frequency, not multiplies it.

MFC after: 2 weeks

3 years agoaw_pwm: remove the busy bit check
avg [Fri, 25 Sep 2020 07:39:41 +0000 (07:39 +0000)]
aw_pwm: remove the busy bit check

The bit seems to always be set on my hardware, H3.
However, programming the hardware seems to work just fine.

MFC after: 3 weeks

3 years agoaw_pwm: trivially add H3 support
avg [Fri, 25 Sep 2020 07:39:14 +0000 (07:39 +0000)]
aw_pwm: trivially add H3 support

MFC after: 2 weeks

3 years agoamdtemp(4), amdsmn(4): Attach to Ryzen 4000 APU (Zen 2, "Renoir")
cem [Fri, 25 Sep 2020 04:16:28 +0000 (04:16 +0000)]
amdtemp(4), amdsmn(4): Attach to Ryzen 4000 APU (Zen 2, "Renoir")

PR: 249864
Reported by: Florian Millet <florian.millet AT laposte.net>
Tested by: Florian Millet

3 years agolib/libc/tests/iconv: raise WARNS to 6
asomers [Thu, 24 Sep 2020 21:42:44 +0000 (21:42 +0000)]
lib/libc/tests/iconv: raise WARNS to 6

MFC after: 2 weeks

3 years agolib/libc/tests/sys: raise WARNS to 6
asomers [Thu, 24 Sep 2020 21:39:09 +0000 (21:39 +0000)]
lib/libc/tests/sys: raise WARNS to 6

MFC after: 2 weeks

3 years agotcp(4): Add a reference for tcp_bbr(4) man page
gbe [Thu, 24 Sep 2020 19:59:29 +0000 (19:59 +0000)]
tcp(4): Add a reference for tcp_bbr(4) man page

3 years agoAdd missing file (tcp_bbr.4) from r366127
gbe [Thu, 24 Sep 2020 19:35:34 +0000 (19:35 +0000)]
Add missing file (tcp_bbr.4) from r366127

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

3 years agoAdd a manual page for TCP BBR
gbe [Thu, 24 Sep 2020 19:33:48 +0000 (19:33 +0000)]
Add a manual page for TCP BBR

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

3 years agoFix a typo in the 366098.
sobomax [Thu, 24 Sep 2020 19:12:03 +0000 (19:12 +0000)]
Fix a typo in the 366098.

Reported by: 0mp
MFC after: 2 weeks
(along with 366098)

3 years agocrypto_buffer(9): Add a HISTORY and a AUTHORS section
gbe [Thu, 24 Sep 2020 16:50:14 +0000 (16:50 +0000)]
crypto_buffer(9): Add a HISTORY and a AUTHORS section

Reviewed by: jhb
Approved by: jhb
Differential Revision: https://reviews.freebsd.org/D26487

3 years agoFix typo and environment variable macro
fernape [Thu, 24 Sep 2020 16:42:17 +0000 (16:42 +0000)]
Fix typo and environment variable macro

Follow up for r366119

Reported by: xtouqh@mm.st
Differential Revision: https://reviews.freebsd.org/D26182

3 years agofusefs: fix mmap'd writes in direct_io mode
asomers [Thu, 24 Sep 2020 16:27:53 +0000 (16:27 +0000)]
fusefs: fix mmap'd writes in direct_io mode

If a FUSE server returns FOPEN_DIRECT_IO in response to FUSE_OPEN, that
instructs the kernel to bypass the page cache for that file. This feature
is also known by libfuse's name: "direct_io".

However, when accessing a file via mmap, there is no possible way to bypass
the cache completely. This change fixes a deadlock that would happen when
an mmap'd write tried to invalidate a portion of the cache, wrongly assuming
that a write couldn't possibly come from cache if direct_io were set.

Arguably, we could instead disable mmap for files with FOPEN_DIRECT_IO set.
But allowing it is less likely to cause user complaints, and is more in
keeping with the spirit of open(2), where O_DIRECT instructs the kernel to
"reduce", not "eliminate" cache effects.

PR: 247276
Reported by: trapexit@spawn.link
Reviewed by: cem
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26485

3 years agowhich(1): Add EXAMPLES section to manpage
fernape [Thu, 24 Sep 2020 16:11:53 +0000 (16:11 +0000)]
which(1): Add EXAMPLES section to manpage

Add EXAMPLES section showing the use of -a and -s flags and how which(1)
treates duplicates.

Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D26182

3 years agoFix some signed/unsigned comparison warnings in NFS
asomers [Thu, 24 Sep 2020 15:38:01 +0000 (15:38 +0000)]
Fix some signed/unsigned comparison warnings in NFS

Reviewed by: rmacklem
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26533

3 years agomgb.4: add note about experimental status
emaste [Thu, 24 Sep 2020 14:42:22 +0000 (14:42 +0000)]
mgb.4: add note about experimental status

Also remove HISTORY section until it is connected to the build.

3 years agoWhitespace changes.
tuexen [Thu, 24 Sep 2020 12:26:06 +0000 (12:26 +0000)]
Whitespace changes.

MFC after: 3 days

3 years agoRemove pointless local variable.
kib [Thu, 24 Sep 2020 12:14:25 +0000 (12:14 +0000)]
Remove pointless local variable.

Reported by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 6 days

3 years agoProvide MS() and SM() macros for 80211 and wireless drivers.
bz [Thu, 24 Sep 2020 10:57:39 +0000 (10:57 +0000)]
Provide MS() and SM() macros for 80211 and wireless drivers.

We have (two versions) of MS() and SM() macros which we use throughout
the wireless code.  Change all but three places (ath_hal, rtwn, and rsu)
to the newly provided _IEEE80211_MASKSHIFT() and _IEEE80211_SHIFTMASK()
macros.  Also change one internal case using both _S and _M instead of
just _S away from _M (one of the reasons rtwn and rsu were not changed).

This was done semi-mechanically.  No functional changes intended.

Requested by: gnn (D26091)
Reviewed by: adrian (pre line wrap)
MFC after: 2 weeks
Sponsored by: Rubicon Communications, LLC (d/b/a "Netgate")
Differential Revision: https://reviews.freebsd.org/D26539

3 years agoClean up the arm64 bus_dma_run_filter
andrew [Thu, 24 Sep 2020 10:42:28 +0000 (10:42 +0000)]
Clean up the arm64 bus_dma_run_filter

 - We can exit the loop as soon as the filter check passes.
 - The alignment check has already passed so there is no need to also run
   it here.

Sponsored by: Innovate UK

3 years agoEnsure arm64 DMA alignment is passed from parents to children
andrew [Thu, 24 Sep 2020 10:40:49 +0000 (10:40 +0000)]
Ensure arm64 DMA alignment is passed from parents to children

This ensures the alignment check will take these alignments into account.

Sponsored by: Innovate UK

3 years agoAdd danish translations provided by GitHub user scootergriesen
se [Thu, 24 Sep 2020 09:06:04 +0000 (09:06 +0000)]
Add danish translations provided by GitHub user scootergriesen

These translations did already exist in the index files for "vt".

Obtained from: https://github.com/scootergrisen/freebsd/

3 years agoRegen after r365903
lwhsu [Thu, 24 Sep 2020 08:51:23 +0000 (08:51 +0000)]
Regen after r365903

Sponsored by: The FreeBSD Foundation

3 years agoAdd missing declarations of 64-bit variants of bus_peek/bus_poke on amd64.
mmel [Thu, 24 Sep 2020 08:40:32 +0000 (08:40 +0000)]
Add missing declarations of 64-bit variants of bus_peek/bus_poke on amd64.
It fixes GENERIC-KCSAN build.

Reported by: rpokala
MFC after: 1 month
MFC with: r365899

3 years agoBounce in more cases in the arm64 busdma
andrew [Thu, 24 Sep 2020 07:17:05 +0000 (07:17 +0000)]
Bounce in more cases in the arm64 busdma

We need to use a bounce buffer when the memory we are operating on is not
aligned to a cacheline, and not aligned to the maps alignment.

The former is to stop other threads from dirtying the cacheline while we
are performing DMA operations with it. The latter is to check memory
passed in by a driver is correctly aligned for the device.

Reviewed by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26496

3 years agoEnsure we always align and size arm64 busdma allocations to a cacheline
andrew [Thu, 24 Sep 2020 07:13:13 +0000 (07:13 +0000)]
Ensure we always align and size arm64 busdma allocations to a cacheline

This will ensure nothing modifies the cacheline while DMA is in progress
so we won't need to bounce the data.

Reviewed by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26495

3 years agoDon't define _STANDALONE when building kernel modules.
imp [Thu, 24 Sep 2020 07:10:34 +0000 (07:10 +0000)]
Don't define _STANDALONE when building kernel modules.

_STANDALONE is only for the bootloader, not kernel modules. Remove it
from the build. This was harmless before, but sys/malloc.h now does
different things for the standalone environment, triggering the issue.

3 years agoAdd a coherent flag on the arm64 dma map struct
andrew [Thu, 24 Sep 2020 07:07:54 +0000 (07:07 +0000)]
Add a coherent flag on the arm64 dma map struct

Use it to decide if we can skip cache management.

While here remove the DMAMAP_COULD_BOUNCE flag as it's unneeded.

Reviewed by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26494

3 years agoAdd bounce helpers to the arm64 busdma
andrew [Thu, 24 Sep 2020 07:03:26 +0000 (07:03 +0000)]
Add bounce helpers to the arm64 busdma

Add helper functions to the arm64 busdma for common cases of checking if
we may need to bounce, and if we must bounce for a given address.

These will be expanded later as we handle cache-misaligned memory.

Reported by: mmel
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D26493

3 years agoCreate a standalone version of sys/malloc.h
imp [Thu, 24 Sep 2020 06:40:35 +0000 (06:40 +0000)]
Create a standalone version of sys/malloc.h

The ZSTD support for the boot loader will need to include files that
use the kernel's malloc interface. Create a standalone stub version
that's functional enough to allow this to work. There's some
limitations in this interface, and it's not quite a perfect
match. Specifically, M_WAITOK allocations can fail because there's
nothing that can be done we no memory is available.

3 years agoSlightly modify wording to better match nearby entries.
se [Thu, 24 Sep 2020 06:12:57 +0000 (06:12 +0000)]
Slightly modify wording to better match nearby entries.

MFC after: 3 days

3 years agocache: eliminate cache_zap_locked_vnode
mjg [Thu, 24 Sep 2020 03:38:32 +0000 (03:38 +0000)]
cache: eliminate cache_zap_locked_vnode

It is only ever called for negative entries and for those it is
just a wrapper around cache_zap_negative_locked_vnode_kl which
always succeeds.

This also fixes a bug where cache_lookup_fallback should have been
calling cache_zap_locked_bucket instead. Note that in order to trigger
the bug NOCACHE must not be set, which currently only happens when
creating a new coredump (and then the coredump-to-be has to have a
negative entry).

3 years agodd a new option (-H) to daemon(8) to catch SIGHUP and re-open output_file file when
sobomax [Thu, 24 Sep 2020 02:44:58 +0000 (02:44 +0000)]
dd a new option (-H) to daemon(8) to catch SIGHUP and re-open output_file file when
received.

The default system log rotation mechanism (newsyslog(8)) requires ability to send
signal to a daemon in order to properly complete rotation of the logs in an "atomic"
manner without having to making a copy and truncating original file. Unfortunately
our built-in mechanism to convert "dumb" programs into daemons has no way to handle
this rotation properly. This change adds this ability, to be enabled by supplying -H
option in addition to the -o option.

Reviewed by: markj, rpokala (manpages)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26526

3 years agoRemove stray lines
imp [Wed, 23 Sep 2020 22:49:27 +0000 (22:49 +0000)]
Remove stray lines

I snagged the license boiler plate. Fix that. also, it's spelled .Va
not .Vn. Plus " quoting issues.

Noticed by: rgrimes, xtouqh at hotmail dot com

3 years agotests: move the memfd tests over to sys/posixshm
kevans [Wed, 23 Sep 2020 19:54:59 +0000 (19:54 +0000)]
tests: move the memfd tests over to sys/posixshm

memfd_create is implemented on top of posixshm, so this is a logically
correct place for them to be. Moreover, this reduces the number of places to
look to run tests when working in this part of the tree.

Discussed with: kib (to some extent, a while ago)

3 years agoFlag vm_reserv and vm_phys sysctls as MPSAFE.
markj [Wed, 23 Sep 2020 19:36:07 +0000 (19:36 +0000)]
Flag vm_reserv and vm_phys sysctls as MPSAFE.

Nothing in these subsystems relies on Giant.

MFC after: 1 week

3 years agoAdd a vmparam.h constant indicating pmap support for large pages.
markj [Wed, 23 Sep 2020 19:34:21 +0000 (19:34 +0000)]
Add a vmparam.h constant indicating pmap support for large pages.

Enable SHM_LARGEPAGE support on arm64.

Reviewed by: alc, kib
Sponsored by: Juniper Networks, Inc., Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26467

3 years agoAdd largepage support to the arm64 pmap.
markj [Wed, 23 Sep 2020 19:33:47 +0000 (19:33 +0000)]
Add largepage support to the arm64 pmap.

Reviewed by: alc, kib
Sponsored by: Juniper Networks, Inc., Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D26466

3 years agoUse envvar rather than nonstandard hint. lines
imp [Wed, 23 Sep 2020 19:18:53 +0000 (19:18 +0000)]
Use envvar rather than nonstandard hint. lines

The NOTES files have a bunch of hint lines that are removed when
generating LINT. However, we can achieve the same effect by prepending
each of the lines with 'envvar' so the NOTES files become standard
config(8) files. No functional changes as the sed script to generate
the LINT files filters these either way.

Suggested by: kevans

3 years agoloader: fix non-zfs build
tsoome [Wed, 23 Sep 2020 19:15:22 +0000 (19:15 +0000)]
loader: fix non-zfs build

We can not include zfs headers while building without zfs.

Reported by: Oscar Holmlund

3 years agoriscv: Trap cleanup - use nitems()
nick [Wed, 23 Sep 2020 18:54:14 +0000 (18:54 +0000)]
riscv: Trap cleanup - use nitems()

No functional changes, just cleanup.

Reviewed by: kp
Approved by: kp (mentor)
Sponsored by: Axiado

3 years agoDo not leak oldvmspace if image activation failed
kib [Wed, 23 Sep 2020 18:03:07 +0000 (18:03 +0000)]
Do not leak oldvmspace if image activation failed

and current address space is already destroyed, so kern_execve()
terminates the process.

While there, clean up some internals of post_execve() inlined in init_main.

Reported by: Peter <pmc@citylink.dinoex.sub.org>
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D26525

3 years agonextboot(8): Fix behavior on non-ZFS /boot systems
cem [Wed, 23 Sep 2020 17:04:27 +0000 (17:04 +0000)]
nextboot(8): Fix behavior on non-ZFS /boot systems

Fix unquoted test for an empty value, which broke nextboot(8) on non-ZFS /boot
systems after r365938.

Discussed with: allanjude, tsoome
X-MFC-With: r365938

3 years agoremove reference to obsolete arm NOTES files
emaste [Wed, 23 Sep 2020 14:52:43 +0000 (14:52 +0000)]
remove reference to obsolete arm NOTES files

We left these in the clean rule to avoid having stale files remain in
working trees, but enough time has now passed that it's no longer
relevant.

Discussed with: imp

3 years agobyacc: fix UBSan signed shift range error
arichardson [Wed, 23 Sep 2020 12:54:42 +0000 (12:54 +0000)]
byacc: fix UBSan signed shift range error

I've submitted this patch upstream, so apply this to contrib/ until a new
version containing this change has been released.

Reviewed By: jkim
Differential Revision: https://reviews.freebsd.org/D26505

3 years agoAdd github CI for testing cross-building from Linux and macOS
arichardson [Wed, 23 Sep 2020 12:54:37 +0000 (12:54 +0000)]
Add github CI for testing cross-building from Linux and macOS

This builds the kernel-toolchain target and an amd64 GENERIC kernel on
Ubuntu 18.04, 20.04 and the latest macOS to ensure that new changes
don't regress building on non-FreeBSD hosts.

Reviewed By: emaste, lwhsu
Differential Revision: https://reviews.freebsd.org/D26512

3 years agoBump __FreeBSD_version after cache_purgevfs change
mjg [Wed, 23 Sep 2020 11:02:23 +0000 (11:02 +0000)]
Bump __FreeBSD_version after cache_purgevfs change

3 years agocache: drop the force flag from purgevfs
mjg [Wed, 23 Sep 2020 10:46:07 +0000 (10:46 +0000)]
cache: drop the force flag from purgevfs

The optional scan is wasteful, thus it is removed altogether from unmount.

Callers which always want it anyway remain unaffected.

3 years agocache: reimplement purgevfs to iterate vnodes instead of the entire hash
mjg [Wed, 23 Sep 2020 10:44:49 +0000 (10:44 +0000)]
cache: reimplement purgevfs to iterate vnodes instead of the entire hash

The entire cache scan was a leftover from the old implementation.

It is incredibly wasteful in presence of several mount points and does not
win much even for single ones.

3 years agocache: clean up atomic ops on numneg and numcache
mjg [Wed, 23 Sep 2020 10:42:41 +0000 (10:42 +0000)]
cache: clean up atomic ops on numneg and numcache

- use subtract instead of adding -1
- drop the useless _rel fence

Note this should be converted to a scalable scheme.

3 years agoloader: zfs_probe_dev should pick first matching zfs pool
tsoome [Wed, 23 Sep 2020 08:22:14 +0000 (08:22 +0000)]
loader: zfs_probe_dev should pick first matching zfs pool

During devswitch probe, we pick boot pool based on boot disk, if the boot
disk happens to have multiple pools in freebsd-zfs partitions, the current
code does pick last pool from boot disk as boot pool. While there is no
way at that stage to test, the more logical approach would be to pick
first matching pool.

This patch is assuming we do pass pool guid pointer with guid value 0,
this will help us to determine, if the guid value is already set or not.

The general suggestion would be not to share disk between different pools.

Reported by: Alexander Leidinger

3 years agoFix build.
delphij [Wed, 23 Sep 2020 07:27:12 +0000 (07:27 +0000)]
Fix build.

Pointy hat to: delphij
MFC after: 3 days

3 years agosbin/fsck_msdosfs: Fix an integer overflow on 32-bit platforms.
delphij [Wed, 23 Sep 2020 06:52:22 +0000 (06:52 +0000)]
sbin/fsck_msdosfs: Fix an integer overflow on 32-bit platforms.

The purpose of checksize() is to verify that the referenced cluster
chain size matches the recorded file size (up to 2^32 - 1) in the
directory entry. We follow the cluster chain, then multiple the
cluster count by bytes per cluster to get the physical size, then
check it against the recorded size.

When a file is close to 4 GiB (between 4GiB - cluster size and 4GiB,
both non-inclusive), the product of cluster count and bytes per
cluster would be exactly 4 GiB. On 32-bit systems, because size_t
is 32-bit, this would wrap back to 0, which will cause the file be
truncated to 0.

Fix this by using 64-bit physicalSize instead.

This fix is inspired by an Android change request at
https://android-review.googlesource.com/c/platform/external/fsck_msdos/+/1428461

PR: 249533
Reviewed by: kevlo
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26524

3 years ago[PowerPC64LE] Fix RTAS LE calls in pseries.
bdragon [Wed, 23 Sep 2020 04:09:02 +0000 (04:09 +0000)]
[PowerPC64LE] Fix RTAS LE calls in pseries.

Similar to OPAL calls, switch to big endian to do calls to RTAS.

(Missed this one when I was doing the bulk commit of PowerPC64LE support.)

Sponsored by: Tag1 Consulting, Inc.

3 years ago__FreeBSD_version bump for introduction of the powerpc64le arch.
bdragon [Wed, 23 Sep 2020 03:19:20 +0000 (03:19 +0000)]
__FreeBSD_version bump for introduction of the powerpc64le arch.

Although this is technically not a breaking change, I believe it is best
to have a fresh version to use to define where the starting point was
here.

3 years agoarch(7): PowerPC64LE architecture definition
bdragon [Wed, 23 Sep 2020 03:12:58 +0000 (03:12 +0000)]
arch(7): PowerPC64LE architecture definition

Document the new powerpc64le arch's initial specifications.

Certain things are subject to change while this is experimental. The most
likely change is that long double may switch to quad, dependent on POWER8
emulation assistance for __float128 being set up in the compiler (as
POWER8 does not have IEEE-compatible 128-bit hardware float, unlike POWER9.)

Sponsored by: Tag1 Consulting, Inc.

3 years agocp: tests: fix weird 20 insertion
kevans [Wed, 23 Sep 2020 03:02:45 +0000 (03:02 +0000)]
cp: tests: fix weird 20 insertion

This slipped in at the last moment. =(

3 years agocp: add some basic tests
kevans [Wed, 23 Sep 2020 03:01:14 +0000 (03:01 +0000)]
cp: add some basic tests

There are some tests available in the NetBSD test suite, but we don't
currently pass all of those; further investigation will go into that. For
now, just add a basic test as well as a test that copies from /dev/null to a
file.

The /dev/null test confirms that the file gets created if it's empty, then
that it truncates the file if it's non-empty. This matches some usage that
was previously employed in the build and was replaced in r366042 by a
simpler shell construct.

I will also plan on coming back to expand these in due time.

MFC after: 1 week

3 years ago[PowerPC] Fix multiple ntp configuration issues
bdragon [Wed, 23 Sep 2020 02:37:27 +0000 (02:37 +0000)]
[PowerPC] Fix multiple ntp configuration issues

* powerpc time_t is 64 bit, not 32 bit.

* Add definition for powerpc64le.

With this, powerpc64le ntpd and ntpdate operate correctly instead of
corrupting the clock and exiting.

Tested on powerpc64, powerpc64le, and powerpc.

No feedback from cy@.

I am a bit confused as to how SIZEOF_TIME_T being wrong ever worked on
powerpc, it being big endian and all.

Sponsored by: Tag1 Consulting, Inc.
Differential Revision: https://reviews.freebsd.org/D26379

3 years ago[PowerPC64LE] Fix sleeping on POWER8.
bdragon [Wed, 23 Sep 2020 02:28:19 +0000 (02:28 +0000)]
[PowerPC64LE] Fix sleeping on POWER8.

Due to enter_idle_powerx fabricating a MSR from scratch, it is necessary
for it to care about the endianness, so we don't accidentally switch
endian the first time we idle a thread.

Took about five seconds to spot after seeing an unmangled backtrace.

The hard bit was needing to temporarily set up a mutex to sort out the
logjam that happens when every thread simultaneously wakes up in the wrong
endian due to the panic IPI and panics, leaving what I can best describe as
"alphabet soup" on the console.

Luckily, I already had a patch sitting around to do that.

This brings POWER8 up to equivilence with POWER9 on PPC64LE.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Pass our byte order to the sqlite3 build.
bdragon [Wed, 23 Sep 2020 02:17:44 +0000 (02:17 +0000)]
[PowerPC64LE] Pass our byte order to the sqlite3 build.

Due to the sqlite3 endian detection code preferring to check platform defines
instead of checking endian defines, it is necessary to manually set
the endianness on PowerPC64LE.

Unlike other bi-endian platforms, PowerPC64LE relies entirely on the
generic endianness macros like __BYTE_ORDER__ and has no platform-specific
define to denote little endian.

Add -DSQLITE_BYTEORDER=1234 to the CFLAGS when building libsqlite3 on
powerpc64le.

Fixes runtime operation of sqlite on PowerPC64LE.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] libkvm powerpc64le support.
bdragon [Wed, 23 Sep 2020 02:11:24 +0000 (02:11 +0000)]
[PowerPC64LE] libkvm powerpc64le support.

* Add missing _kvm16toh() function.
* Teach libkvm about powerpc64le.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix gdtoa configurations on LE.
bdragon [Wed, 23 Sep 2020 02:05:44 +0000 (02:05 +0000)]
[PowerPC64LE] Fix gdtoa configurations on LE.

gdtoa wins the award for "most outdated endianness naming convention"
with its IEEE_8087 vs IEEE_MC68k defines. I had a good chuckle.

Update softfloat and arith.h to adjust to BE or LE automatically
based on the low level preprocessor defines.

Fixes printf/scanf on PowerPC64LE, although there is still a problem
lurking regarding Signalling NaNs...

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix AP spinup on powernv.
bdragon [Wed, 23 Sep 2020 01:56:26 +0000 (01:56 +0000)]
[PowerPC64LE] Fix AP spinup on powernv.

OPAL unconditionally enters secondary CPUs with only HV and SF set.

I tried writing a secondary entry point instead, but OPAL rejected it
and I am unsure why, so I resorted to making the system reset interrupt
endian-flexible.

This means we take a slight performance hit on wakeup on LE, but it is
a good stopgap until we can figure out a reliable way to make OPAL enter
where we want it to.

It probably makes sense to have it around anyway, because I can imagine
scenarios where the cpu resets itself to BE and does a software reset.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Endian fix for opal_hmi.c
bdragon [Wed, 23 Sep 2020 01:51:01 +0000 (01:51 +0000)]
[PowerPC64LE] Endian fix for opal_hmi.c

Another boring one. We need to endian swap before checking flags.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Get XIVE up and running.
bdragon [Wed, 23 Sep 2020 01:49:37 +0000 (01:49 +0000)]
[PowerPC64LE] Get XIVE up and running.

More endian conversion.

* Install TCEs correctly (i.e. in big endian)

* Convert to big endian and back when setting up queue pages and IRQs.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Endian fix for opal_dev.c.
bdragon [Wed, 23 Sep 2020 01:41:51 +0000 (01:41 +0000)]
[PowerPC64LE] Endian fix for opal_dev.c.

Not much to say here, another missing be64toh() in memory that was written
from OPAL.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Endian fixes for opal_pci.c.
bdragon [Wed, 23 Sep 2020 01:37:01 +0000 (01:37 +0000)]
[PowerPC64LE] Endian fixes for opal_pci.c.

Since OPAL runs in big endian, any data being passed back and forth
via memory instead of registers needs to be byteswapped.

From my notes during development:

"A good way to find candidates is to look for vtophys() in opal_call()
parameters. The memory being passed will be written into in BE."

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Implement endian-independent dword atomic PTE lock.
bdragon [Wed, 23 Sep 2020 01:33:54 +0000 (01:33 +0000)]
[PowerPC64LE] Implement endian-independent dword atomic PTE lock.

It's much easier to implement this in an endian-independent way when we
don't also have to worry about masking half of the dword off.

Given that this code ran on a machine that ran a poudriere bulk with no
kernel oddities, I am relatively certain it is correctly implemented. ;)

This should be a minor performance boost on BE as well.

Sponsored by: Tag1 Consulting, Inc.

3 years ago[PowerPC64LE] Fix endian conversion bugs in moea64.
bdragon [Wed, 23 Sep 2020 01:29:33 +0000 (01:29 +0000)]
[PowerPC64LE] Fix endian conversion bugs in moea64.

For a body of code that had its endian conversion bits written blind without
the ability to test, moea64 was VERY close to being correct.

There were only four instances where the existing code was getting it wrong.

Sponsored by: Tag1 Consulting, Inc.

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