]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
4 years agoloader: rewrite zfs reader zap code to use malloc
tsoome [Tue, 4 Feb 2020 07:37:55 +0000 (07:37 +0000)]
loader: rewrite zfs reader zap code to use malloc

First step on removing zfs_alloc.

Reviewed by: delphij
Differential Revision: https://reviews.freebsd.org/D23433

4 years agoFix libmemstat_uma build after r357485.
jeff [Tue, 4 Feb 2020 05:27:45 +0000 (05:27 +0000)]
Fix libmemstat_uma build after r357485.

Submitted by: cy

4 years agoFix clock_gettime() and clock_getres() for cpu clocks:
dchagin [Tue, 4 Feb 2020 05:27:05 +0000 (05:27 +0000)]
Fix clock_gettime() and clock_getres() for cpu clocks:
- handle the CLOCK_{PROCESS,THREAD}_CPUTIME_ID specified directly;
- fix thread id calculation as in the Linuxulator we should
  convert the user supplied thread id to struct thread * by linux_tdfind();
- fix CPUCLOCK_SCHED case by using kern_{process,thread}_cputime()
  directly as native get_cputime() used by kern_clock_gettime() uses
  native tdfind()/pfind() to find proccess/thread.

PR: 240990
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23341
MFC after: 2 weeks

4 years agoFor code reuse in Linuxulator rename get_proccess_cputime()
dchagin [Tue, 4 Feb 2020 05:25:51 +0000 (05:25 +0000)]
For code reuse in Linuxulator rename get_proccess_cputime()
and get_thread_cputime() and add prototypes for it to <sys/syscallsubr.h>.

As both functions become a public interface add process lock assert
to ensure that the process is not exiting under it.

Fix whitespace nit while here.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23340
MFC after 2 weeks

4 years agolinux_to_native_clockid() properly initializes nwhich variable (or return error),
dchagin [Tue, 4 Feb 2020 05:23:34 +0000 (05:23 +0000)]
linux_to_native_clockid() properly initializes nwhich variable (or return error),
so don't initialize nwhich in declaration and remove stale comment from r161304.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D23339
MFC after: 2 weeks

4 years agoImplement a deferred write advancement feature that can be used to further
jeff [Tue, 4 Feb 2020 02:44:52 +0000 (02:44 +0000)]
Implement a deferred write advancement feature that can be used to further
amortize shared cacheline writes.

Discussed with: rlibby
Differential Revision: https://reviews.freebsd.org/D23462

4 years agoFix a recursion on the thread lock by acquiring it after call rtp_to_pri().
jeff [Tue, 4 Feb 2020 02:42:54 +0000 (02:42 +0000)]
Fix a recursion on the thread lock by acquiring it after call rtp_to_pri().

Reported by: swills
Reviewed by: kib, markj
Differential Revision: https://reviews.freebsd.org/D23495

4 years agoUse STAILQ instead of TAILQ for bucket lists. We only need FIFO behavior
jeff [Tue, 4 Feb 2020 02:41:24 +0000 (02:41 +0000)]
Use STAILQ instead of TAILQ for bucket lists.  We only need FIFO behavior
and this is more space efficient.

Stop queueing recently used buckets to the head of the list.  If the bucket
goes to a different processor the cache coherency will be more expensive.
We already try to encourage cache-hot behavior in the per-cpu layer.

Reviewed by: rlibby
Differential Revision: https://reviews.freebsd.org/D23493

4 years agocxgbe(4): Add pfil(9) hooks to the driver's rx.
np [Tue, 4 Feb 2020 01:09:02 +0000 (01:09 +0000)]
cxgbe(4): Add pfil(9) hooks to the driver's rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Treat NIC rx as special and run its handler directly and not
np [Tue, 4 Feb 2020 01:01:35 +0000 (01:01 +0000)]
cxgbe(4): Treat NIC rx as special and run its handler directly and not
via the t4_cpl_handler dispatch table.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Retire the allow_mbufs_in_cluster optimization.
np [Tue, 4 Feb 2020 00:51:10 +0000 (00:51 +0000)]
cxgbe(4): Retire the allow_mbufs_in_cluster optimization.

This simplifies the driver's rx fast path as well as the bookkeeping
code that tracks various rx buffer sizes and layouts.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoSet the LMA of the riscv kernel to the OpenSBI jump target by default
arichardson [Tue, 4 Feb 2020 00:06:16 +0000 (00:06 +0000)]
Set the LMA of the riscv kernel to the OpenSBI jump target by default

This allows us to boot FreeBSD RISCV on QEMU using the -kernel command line
options. When using that option, QEMU maps the kernel ELF file to the
addresses specified in the LMAs in the program headers.

Since version 4.2 QEMU ships with OpenSBI fw_jump by default so this allows
booting FreeBSD using the following command line:
qemu-system-riscv64 -bios default -kernel /.../boot/kernel/kernel -nographic -M virt

Without this change the -kernel option cannot be used since the LMAs start
at address zero and QEMU already maps a ROM to these low physical addresses.

For targets that require a different kernel LMA the make variable
KERNEL_LMA can be overwritten in the config file. For example, adding
`makeoptions KERNEL_LMA=0xc0200000` will create an ELF file that will be
loaded at 0xc0200000.

Before:
There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000000000000 0x75e598 0x8be318 RWE 0x1000
  DYNAMIC        0x71fb20 0xffffffc00071eb20 0x000000000071eb20 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x693400 0xffffffc000692400 0x0000000000692400 0x000024 0x000024 R   0x4

After:

There are 4 program headers, starting at offset 64

Program Headers:
  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
  LOAD           0x001000 0xffffffc000000000 0x0000000080200000 0x734198 0x893e18 RWE 0x1000
  DYNAMIC        0x6f7810 0xffffffc0006f6810 0x00000000808f6810 0x000100 0x000100 RW  0x8
  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
  NOTE           0x66ca70 0xffffffc00066ba70 0x000000008086ba70 0x000024 0x000024 R   0x4

Reviewed By: br, mhorne (earlier version)
Differential Revision: https://reviews.freebsd.org/D23436

4 years agocxgbe(4): Avoid ext_arg2 in rxb_free.
np [Mon, 3 Feb 2020 23:50:29 +0000 (23:50 +0000)]
cxgbe(4): Avoid ext_arg2 in rxb_free.

ext_arg2 is the only item in the third cacheline in an mbuf and could be
cold by the time rxb_free runs.  Put the information needed by rxb_free
in the same line as the refcount, which is very likely to be hot given
that rxb_free runs when the refcount is decremented and reaches 0.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoports.7: Update examples with install-missing-packages
0mp [Mon, 3 Feb 2020 23:40:27 +0000 (23:40 +0000)]
ports.7: Update examples with install-missing-packages

The ports framework recently grew support for installing dependencies with
a dedicated target called "install-missing-packages". Let's retire the
carefully constructed one-liner that was used for getting dependencies so
far and use the official ports target instead.

Reviewed by: bcr
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23485

4 years agoReplace *-out with star-out to ease legibility
0mp [Mon, 3 Feb 2020 23:30:47 +0000 (23:30 +0000)]
Replace *-out with star-out to ease legibility

"*-out" is a complex way of phrasing the fact, and it causes
confusion for people.

Submitted by: debdrup
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D23482

4 years agocxgbe(4): Do not use pack boundary > 512B unless it is explicitly
np [Mon, 3 Feb 2020 23:30:39 +0000 (23:30 +0000)]
cxgbe(4): Do not use pack boundary > 512B unless it is explicitly
requested.

This is a tradeoff between PCIe efficiency during large packet rx and
packing efficiency during small packet rx.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Initialize the rx buffer's metadata on first-use and not on
np [Mon, 3 Feb 2020 23:25:12 +0000 (23:25 +0000)]
cxgbe(4): Initialize the rx buffer's metadata on first-use and not on
allocation.

refill_fl doesn't touch any part of a freshly allocated cluster after
this change.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agocxgbe(4): Only checksummed TCP should be considered for LRO.
np [Mon, 3 Feb 2020 23:06:42 +0000 (23:06 +0000)]
cxgbe(4): Only checksummed TCP should be considered for LRO.

This avoids the per-packet nanouptime in tcp_lro_rx for traffic that's
not even TCP.

MFC after: 1 week
Sponsored by: Chelsio Communications

4 years agoFix the !SMP case in sched_add() after r355779.
markj [Mon, 3 Feb 2020 22:49:05 +0000 (22:49 +0000)]
Fix the !SMP case in sched_add() after r355779.

If the thread's lock is already that of the runqueue, don't recurse on
the queue lock.

Reviewed by: jeff, kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23492

4 years agofd: partially unengrish the previous commit
mjg [Mon, 3 Feb 2020 22:34:50 +0000 (22:34 +0000)]
fd: partially unengrish the previous commit

4 years agofd: streamline fget_unlocked
mjg [Mon, 3 Feb 2020 22:32:49 +0000 (22:32 +0000)]
fd: streamline fget_unlocked

clang has the unfortunate property of paying little attention to prediction
hints when faced with a loop spanning the majority of the rotuine.

In particular fget_unlocked has an unlikely corner case where it starts almost
from scratch. Faced with this clang generates a maze of taken jumps, whereas
gcc produces jump-free code (in the expected case).

Work around the problem by providing a variant which only tries once and
resorts to calling the original code if anything goes wrong.

While here note that the 'seq' parameter is almost never passed, thus the
seldom users are redirected to call it directly.

4 years agofd: remove the seq argument from fget_unlocked
mjg [Mon, 3 Feb 2020 22:27:55 +0000 (22:27 +0000)]
fd: remove the seq argument from fget_unlocked

It is almost always NULL.

4 years agofd: remove the seq argument from fget routines
mjg [Mon, 3 Feb 2020 22:27:03 +0000 (22:27 +0000)]
fd: remove the seq argument from fget routines

It is almost always NULL.

4 years agoseqc: provide seqc_read_any
mjg [Mon, 3 Feb 2020 22:26:29 +0000 (22:26 +0000)]
seqc: provide seqc_read_any

4 years agoktrace: provide ktrstat_error
mjg [Mon, 3 Feb 2020 22:26:00 +0000 (22:26 +0000)]
ktrace: provide ktrstat_error

This eliminates a branch from its consumers trading it for an extra call
if ktrace is enabled for curthread. Given that this is almost never true,
the tradeoff is worth it.

4 years agoCouple protocol drain routines (frag6_drain and sctp_drain) may send
glebius [Mon, 3 Feb 2020 20:48:57 +0000 (20:48 +0000)]
Couple protocol drain routines (frag6_drain and sctp_drain) may send
packets.  An unexpected behaviour for memory reclamation routine.
Anyway, we need enter the network epoch for doing that.

4 years agoMinor cleanups to allow handing vast datasets.
phk [Mon, 3 Feb 2020 20:46:31 +0000 (20:46 +0000)]
Minor cleanups to allow handing vast datasets.

Submitted by: dds

4 years agoFix a stray 'e'from my last commit.
imp [Mon, 3 Feb 2020 19:36:24 +0000 (19:36 +0000)]
Fix a stray 'e'from my last commit.

4 years agoDisable the smallest UMA bucket size on 32-bit platforms.
markj [Mon, 3 Feb 2020 19:29:02 +0000 (19:29 +0000)]
Disable the smallest UMA bucket size on 32-bit platforms.

With r357314, sizeof(struct uma_bucket) grew to 16 bytes on 32-bit
platforms, so BUCKET_SIZE(4) is 0.  This resulted in the creation of a
bucket zone for buckets with zero capacity.  A more general fix is
planned, but for now this bandaid allows 32-bit platforms to boot again.

PR: 243837
Discussed with: jeff
Reported by: pho, Jenkins via lwhsu
Tested by: pho
Sponsored by: The FreeBSD Foundation

4 years agoaddr2line: Avoid a name collision.
markj [Mon, 3 Feb 2020 19:08:35 +0000 (19:08 +0000)]
addr2line: Avoid a name collision.

The RB_ macros define functions with a parameter named head, and gcc
warns about this.

MFC with: r357450

4 years agonamei: preserve errors from fget_cap_locked
kevans [Mon, 3 Feb 2020 18:59:07 +0000 (18:59 +0000)]
namei: preserve errors from fget_cap_locked

Most notably, we want to make sure we don't clobber any capabilities-related
errors. This is a regression from r357412 (O_SEARCH) that was picked up by
the capsicum tests.

PR: 243839
Reviewed by: kib (committed form recommended by)
Tested by: lwhsu
Differential Revision: https://reviews.freebsd.org/D23479

4 years agoDynamically select LSE-based atomic(9)s on arm64.
markj [Mon, 3 Feb 2020 18:23:50 +0000 (18:23 +0000)]
Dynamically select LSE-based atomic(9)s on arm64.

Once all CPUs are online, determine if they all support LSE atomics and
set lse_supported to indicate this.  For now the atomic(9)
implementations are still always inlined, though it would be preferable
to create out-of-line functions to avoid text bloat.  This was not done
here since big.little systems exist in which some CPUs implement LSE
while others do not, and ifunc resolution must occur well before this
scenario can be detected.  It does seem unlikely that FreeBSD will
ever run on such platforms, however, so converting atomic(9) to use
ifuncs is probably a good next step.

Add a LSE_ATOMICS arm64 kernel configuration option to unconditionally
select LSE-based atomic(9) implementations when the target system is
known.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23325

4 years agoAdd LSE-based atomic(9) implementations.
markj [Mon, 3 Feb 2020 18:23:35 +0000 (18:23 +0000)]
Add LSE-based atomic(9) implementations.

These make use of the cas*, ld* and swp instructions added in ARMv8.1.
Testing shows them to be significantly more performant than LL/SC-based
implementations.

No functional change here since the wrappers still unconditionally
select the _llsc variants.

Reviewed by: andrew, kib
MFC after: 1 month
Submitted by: Ali Saidi <alisaidi@amazon.com> (original version)
Differential Revision: https://reviews.freebsd.org/D23324

4 years agoAdd wrappers for arm64 atomics.
markj [Mon, 3 Feb 2020 18:23:14 +0000 (18:23 +0000)]
Add wrappers for arm64 atomics.

Add a _llsc suffix for the existing LL/SC-based implementations and add
trivial wrappers.  This is in preparation for supporting LSE-based
atomic(9) implementations.

No functional change intended.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23323

4 years agoProvide a single implementation for each of the arm64 atomic(9) ops.
markj [Mon, 3 Feb 2020 18:22:59 +0000 (18:22 +0000)]
Provide a single implementation for each of the arm64 atomic(9) ops.

Parameterize the macros by type width as well as acq/rel semantics.
This makes modifying the implementations much less tedious and
error-prone and makes it easier to support alternate LSE-based
implementations.  No functional change intended.

Reviewed by: andrew, kib
MFC after: 1 month
Sponsored by: The FreeBSD Foundation, Amazon (hardware)
Differential Revision: https://reviews.freebsd.org/D23322

4 years agoWith INVARIANTS, track all softdep dependency structures centrally
chs [Mon, 3 Feb 2020 17:47:14 +0000 (17:47 +0000)]
With INVARIANTS, track all softdep dependency structures centrally
so that we can find them in dumps.

Approved by: mckusick (mentor)
Sponsored by: Netflix

4 years agoRemove sparc64 kernel support
imp [Mon, 3 Feb 2020 17:35:11 +0000 (17:35 +0000)]
Remove sparc64 kernel support

Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs

4 years agoRemove sparc64 support from the boot loader.
imp [Mon, 3 Feb 2020 17:34:57 +0000 (17:34 +0000)]
Remove sparc64 support from the boot loader.

Remove all the sparc64 specific bits, both files and ifdefs.

4 years agoUnblock kstat.zfs.misc.dbufstats sysctls.
mav [Mon, 3 Feb 2020 17:10:40 +0000 (17:10 +0000)]
Unblock kstat.zfs.misc.dbufstats sysctls.

It is not so much broken to hide it after we wasted time to collect it.

MFC after: 2 weeks
Sponsored by: iXsystems, Inc.

4 years agocapsicum: faster cap_rights_contains
mjg [Mon, 3 Feb 2020 17:08:11 +0000 (17:08 +0000)]
capsicum: faster cap_rights_contains

Instead of doing a 2 iteration loop (determined at runeimt), take advantage
of the fact that the size is already known.

While here provdie cap_check_inline so that fget_unlocked does not have to
do a function call.

Verified with the capsicum suite /usr/tests.

4 years agotmpfs: inline tmpfs_update
mjg [Mon, 3 Feb 2020 17:06:21 +0000 (17:06 +0000)]
tmpfs: inline tmpfs_update

It was generated to be just a jumping off point to tmpfs_itimes.

While here provide a dedicated variant for getattr since we normally don't
expect to need to the update from that caller.

4 years agoaddr2line: Cache CU DIEs upon a successful address lookup.
markj [Mon, 3 Feb 2020 16:41:40 +0000 (16:41 +0000)]
addr2line: Cache CU DIEs upon a successful address lookup.

Previously, addr2line would sequentially search all CUs for each input
address.  For some uses, notably syzkaller's code coverage map generator,
this was extremely slow.  Add a CU cache into which entries are added
following a successful lookup, and search the cache before falling back
to a scan.  When translating a large number of addresses this yields
slightly better performance than GNU addr2line.

Garbage-collect an unused hash table which appears to have been intended
for the same purpose.  A hash table doesn't seem particularly suitable
since each CU spans a range of addresses.

Submitted by: Tiger Gao <tig@freebsdfoundation.org>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D23418

4 years agounits(1): Refactor the manual page and update usage information
0mp [Mon, 3 Feb 2020 15:22:46 +0000 (15:22 +0000)]
units(1): Refactor the manual page and update usage information

Changes to units.1:

- Change the description to a more descriptive "conversion calculator".
- Sort options.
- Split the description into sections to make it easier to navigate the
  manual page.
- Improve the description of various options.
- Document the default value of the output format.
- Use more mdoc macros for better readability.
- Document the behavior of the PATH environmental variable.
- Improve examples.
- Add sections: EXIT STATUS, DIAGNOSTICS, and HISTORY.
- Document that units(1) cannot convert negative values and it handles long
  unit lists poorly.
- Update the documentation of the -V flag to match the implementation.
  units(1) prints its version and the units data file instead of its
  version and usage information.

Changes to units.c:

- Update usage information.
- Sort longopts elements.

This commit does not attempts to change the current behavior of units(1).
What's left to do is probably defining a better versioning (at the moment
units(1) always reports "FreeBSD units" as its version) and changing the
behavior of the -V flag to only print version.

Reviewed by: allanjude (earlier version), bcr
Approved by: bcr (mentor)
Differential Revision: https://reviews.freebsd.org/D18977

4 years agoRemove the GICv3 ITS irq and replace it with an ID
andrew [Mon, 3 Feb 2020 14:38:19 +0000 (14:38 +0000)]
Remove the GICv3 ITS irq and replace it with an ID

In r357324 most of the use of gi_irq was moved to gi_lpi. Complete this
with the last few places we need the IRQ value and create gi_id for the
per-device value we need.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agofd: fix f_count acquire in fget_unlocked
mjg [Mon, 3 Feb 2020 14:28:31 +0000 (14:28 +0000)]
fd: fix f_count acquire in fget_unlocked

The code was using a hand-rolled fcmpset loop, while in other places the same
count is manipulated with the refcount API.

This transferred from a stylistic issue into a bug after the API got extended
to support flags. As a result the hand-rolled loop could bump the count high
enough to set the bit flag. Another bump + refcount_release would then free
the file prematurely.

The bug is only present in -CURRENT.

4 years agoFix up various vnode-related asserts which did not dump the used vnode
mjg [Mon, 3 Feb 2020 14:25:32 +0000 (14:25 +0000)]
Fix up various vnode-related asserts which did not dump the used vnode

4 years agoUse a unique name for the GICv3 ITS vmem
andrew [Mon, 3 Feb 2020 13:50:55 +0000 (13:50 +0000)]
Use a unique name for the GICv3 ITS vmem

When there are multiple GICv3 ITS devices we don't know which vmem is for
which device. Use device_get_nameunit to get a per-device name.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agoremove stale gnu/lib/csu directory
emaste [Mon, 3 Feb 2020 13:50:15 +0000 (13:50 +0000)]
remove stale gnu/lib/csu directory

As of r357338 gnu/lib/csu is never used.

4 years agoDisable the use of the quantum cache in the GICv3 ITS
andrew [Mon, 3 Feb 2020 13:47:41 +0000 (13:47 +0000)]
Disable the use of the quantum cache in the GICv3 ITS

This uses UMA to allocate space. It causes issues when there are multiple
ITS devices in the system where interrupts are not allocated from a low
address on some interrupt controllers. Disabling the quantum cache fixes
this on the Neoverse N1 SDP.

MFC after: 2 weeks
Sponsored by: DARPA, AFRL

4 years agoloader: bc_add can not use any other probes than ah=0x4b
tsoome [Mon, 3 Feb 2020 11:33:33 +0000 (11:33 +0000)]
loader: bc_add can not use any other probes than ah=0x4b

CD boot is broken for some systems since bioscd and biosdisk merge. The issue is that we can not use anything else than int 13 ah=0x4b to query cd information.

The patch does restore the same probe as was originally used in bioscd.c. Additionally extra buffer padding is used to avoid memory corruption caused by some systems.

PR: 234031
Reported by: ultramage and others
MFC after: 1 day

4 years agoOn powerpc, we use ofw_syscons for device sc. That references the default
imp [Mon, 3 Feb 2020 05:38:45 +0000 (05:38 +0000)]
On powerpc, we use ofw_syscons for device sc. That references the default
fonts. As a workaround, remove the static. vt is default on powerpc, but there's
a few old macs that still fail with vt. sc is used as a work arouond for those
machines, and the kernel fails to build w/o it.

4 years agonetinet/libalias: Fix typo in debug message
cem [Mon, 3 Feb 2020 05:19:44 +0000 (05:19 +0000)]
netinet/libalias: Fix typo in debug message

No functional change.

PR: 243831
Submitted by: Neel Chauhan <neel AT neelc DOT org>
Differential Revision: https://reviews.freebsd.org/D23365

4 years agotypo: Registration.
pfg [Mon, 3 Feb 2020 02:02:13 +0000 (02:02 +0000)]
typo: Registration.

Pointed by: Dikshie Fauzie

4 years agoethernet: Minor cleanup.
pfg [Mon, 3 Feb 2020 01:08:15 +0000 (01:08 +0000)]
ethernet: Minor cleanup.
Consistently use uppercase for ethertype hex numbers.

4 years agoacpi_ibm: remove superfluous cast
emaste [Sun, 2 Feb 2020 20:56:18 +0000 (20:56 +0000)]
acpi_ibm: remove superfluous cast

Reported by: kib

4 years agoDiff reduction against NetBSD, no functional change.
delphij [Sun, 2 Feb 2020 20:53:31 +0000 (20:53 +0000)]
Diff reduction against NetBSD, no functional change.

MFC after: 1 week

4 years agoRemove unused include.
delphij [Sun, 2 Feb 2020 20:51:28 +0000 (20:51 +0000)]
Remove unused include.

MFC after: 2 weeks

4 years agolibc: provide fputc_unlocked
kevans [Sun, 2 Feb 2020 19:45:12 +0000 (19:45 +0000)]
libc: provide fputc_unlocked

Among the same justification as the other stdio _unlocked; in addition to an
inline version in <stdio.h>, we must provide a function in libc as well for
the functionality. This fixes the lang/gcc* builds, which want to use the
symbol from libc.

PR: 243810
Reported by: antoine, swills, Michael <michael.adm gmail com>
X-MFC-With: r357284

4 years ago[PowerPC] Fix feholdexcept() on powerpc referencing the wrong struct member
bdragon [Sun, 2 Feb 2020 19:16:52 +0000 (19:16 +0000)]
[PowerPC] Fix feholdexcept() on powerpc referencing the wrong struct member

In r355656, endianness handling of the floating point environment was fixed
in the PowerPC code to work as intended.

However, one bit got missed, causing feholdexcept() to mis-save the fenv.

Submitted by: Renato Riolino <renato.riolino@eldorado.org.br>
Differential Revision: https://reviews.freebsd.org/D23382

4 years agostyle(9): Fix spaces after #define.
pfg [Sun, 2 Feb 2020 19:02:07 +0000 (19:02 +0000)]
style(9): Fix spaces after #define.

No functional change.

4 years agoacpi_ibm: whitespace and wrapping cleanup
emaste [Sun, 2 Feb 2020 19:01:16 +0000 (19:01 +0000)]
acpi_ibm: whitespace and wrapping cleanup

4 years agoethernet: add some more Ethertypes.
pfg [Sun, 2 Feb 2020 18:33:20 +0000 (18:33 +0000)]
ethernet: add some more Ethertypes.

Sort ETHERTYPE_FCOE, from r357414.

4 years agoethernet: add some more Ethertypes.
pfg [Sun, 2 Feb 2020 18:27:37 +0000 (18:27 +0000)]
ethernet: add some more Ethertypes.

Add some types based on other BSDs and also add EtherCat and PROFINET, which
are IEC standards.

There is a public list (CSV format) at:
https://standards.ieee.org/products-services/regauth/

MFC after: 2 weeks

4 years agoacpi_ibm: whitespace fixup
emaste [Sun, 2 Feb 2020 18:07:47 +0000 (18:07 +0000)]
acpi_ibm: whitespace fixup

4 years agoProvide O_SEARCH
kevans [Sun, 2 Feb 2020 16:34:57 +0000 (16:34 +0000)]
Provide O_SEARCH

O_SEARCH is defined by POSIX [0] to open a directory for searching, skipping
permissions checks on the directory itself after the initial open(). This is
close to the semantics we've historically applied for O_EXEC on a directory,
which is UB according to POSIX. Conveniently, O_SEARCH on a file is also
explicitly undefined behavior according to POSIX, so O_EXEC would be a fine
choice. The spec goes on to state that O_SEARCH and O_EXEC need not be
distinct values, but they're not defined to be the same value.

This was pointed out as an incompatibility with other systems that had made
its way into libarchive, which had assumed that O_EXEC was an alias for
O_SEARCH.

This defines compatibility O_SEARCH/FSEARCH (equivalent to O_EXEC and FEXEC
respectively) and expands our UB for O_EXEC on a directory. O_EXEC on a
directory is checked in vn_open_vnode already, so for completeness we add a
NOEXECCHECK when O_SEARCH has been specified on the top-level fd and do not
re-check that when descending in namei.

[0] https://pubs.opengroup.org/onlinepubs/9699919799/

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D23247

4 years agozfs: light refactor to indicate cachedlookup in zfs_lookup
kevans [Sun, 2 Feb 2020 16:10:33 +0000 (16:10 +0000)]
zfs: light refactor to indicate cachedlookup in zfs_lookup

If we come from VOP_CACHEDLOOKUP, we must skip the VEXEC check as it will
have been done in the caller (vfs_cache_lookup). This is a part of D23247,
which may skip the earlier VEXEC check as well if the root fd was opened
with O_SEARCH.

This one required slightly more work as zfs_lookup may also be called
indirectly as VOP_LOOKUP or a couple of other places where we must do the
check.

4 years agopseudofs: don't do VEXEC check in VOP_CACHEDLOOKUP
kevans [Sun, 2 Feb 2020 15:36:12 +0000 (15:36 +0000)]
pseudofs: don't do VEXEC check in VOP_CACHEDLOOKUP

VOP_CACHEDLOOKUP should assume that the appropriate VEXEC check has been
done in the caller (vfs_cache_lookup), so it does not belong here.

4 years agoMove ce enable to SOURCELESS_HOST
emaste [Sun, 2 Feb 2020 14:41:09 +0000 (14:41 +0000)]
Move ce enable to SOURCELESS_HOST

ce contains obfuscated code that runs on the host's processor

4 years agoPer the firm plan, start to remove sparc64
imp [Sun, 2 Feb 2020 11:37:27 +0000 (11:37 +0000)]
Per the firm plan, start to remove sparc64

The sparc64 architecture is being removed from FreeBSD 13, starting
now. This removes it from the top level only. It is the only
architecture that didn't see substantial work after the call to get
things working with the external toolchain.

4 years agofd: sprinkle some predits around fget
mjg [Sun, 2 Feb 2020 09:38:40 +0000 (09:38 +0000)]
fd: sprinkle some predits around fget

clang inlines fget -> _fget into kern_fstat and eliminates several checkes,
but prior to this change it would assume fget_unlocked was likely to fail
and consequently avoidable jumps got generated.

4 years agofd: use atomic_load_ptr instead of hand-rolled cast through volatile
mjg [Sun, 2 Feb 2020 09:37:16 +0000 (09:37 +0000)]
fd: use atomic_load_ptr instead of hand-rolled cast through volatile

No change in assembly.

4 years agovfs: remove the now empty vop_unlock_post
mjg [Sun, 2 Feb 2020 09:36:32 +0000 (09:36 +0000)]
vfs: remove the now empty vop_unlock_post

4 years agovfs: remove the never set VDESC_VPP_WILLRELE flag
mjg [Sun, 2 Feb 2020 09:35:48 +0000 (09:35 +0000)]
vfs: remove the never set VDESC_VPP_WILLRELE flag

4 years agoMove font.h generation to conf/files from conf/files.*
imp [Sun, 2 Feb 2020 08:27:26 +0000 (08:27 +0000)]
Move font.h generation to conf/files from conf/files.*

Use ${SRCTOP} instead of /usr/share.
Prefer to depend on option sc_dflt_fnt instead of sc.
gc the 4 otherwise identical instances in the tree.
Platforms that don't need this won't included it.

4 years agoFix old-style build
imp [Sun, 2 Feb 2020 08:27:20 +0000 (08:27 +0000)]
Fix old-style build

Fix the old-style build by using ${SRCTOP} instead of a weird
construct that only works for new-style build.
Simplify the building of keymap files by using macros
Move atkbdmap.h in files.x86
This has been broken since r296899 which removed the implicit
dependency on /usr/share.

4 years agoKill old armv4 busdma
imp [Sun, 2 Feb 2020 08:27:14 +0000 (08:27 +0000)]
Kill old armv4 busdma

Move to having one busdma option for arm: the armv6/v7 one.
Kill now-unused option ARM_USE_V6_BUSDMA too.
Fixup files.arm to match rename.

4 years agoMove arm back to having one LINT
imp [Sun, 2 Feb 2020 08:27:08 +0000 (08:27 +0000)]
Move arm back to having one LINT

Now that armv5 is gone, we no longer need multiple LINT files. Kill
the odd-ball support here. From now on, we just have LINT built from
notes like all the other platforms. Keep the removal of LINT-V5/7
to remove stale files for a while still..

4 years agoRemove old boardid/mach-types support.
imp [Sun, 2 Feb 2020 06:52:10 +0000 (06:52 +0000)]
Remove old boardid/mach-types support.

This has been long obsolete in linux and now that all armv4/5 support
is gone, it can be retired too.

4 years agoRemove armv5 marvell support.
imp [Sun, 2 Feb 2020 06:52:04 +0000 (06:52 +0000)]
Remove armv5 marvell support.

Per plans to remove armv5 support, remove the armv5 marvell discovery,
kirkwood and orion families.

4 years agoRemove Ralink RT1310 support
imp [Sun, 2 Feb 2020 06:51:42 +0000 (06:51 +0000)]
Remove Ralink RT1310 support

This armv5 SoC is being removed consistent with the removal of
armv5 support, per discussions in arm@ mailing list.

4 years agoRemove vpo.4
imp [Sun, 2 Feb 2020 04:53:27 +0000 (04:53 +0000)]
Remove vpo.4

The Parallel Port SCSI adapter was interesting for 100MB ZIP drives, but is no
longer used or maintained. Remove it from the tree.

The Parallel Port microsequencer (microseq.9) is now mostly unused in the tree,
but remains. PPI still refrences it, but doesn't use its full functionality.

Relnotes: Yes
Reviewed by: rgrimes@, Ihor Antonov
Discussed on: arch@
Differential Revision:  https://reviews.freebsd.org/D23389

4 years agoAdd deprecation notice to vpo.4
imp [Sun, 2 Feb 2020 04:52:28 +0000 (04:52 +0000)]
Add deprecation notice to vpo.4

This driver has seen no real changes for almost 20 years. It's for
hardware that's 25 years old. It has no reports of active use, nor
has it been seen in the NYCBug dmesg database at all. Schedule
its removal for 13.0.

Reviewed by: rgrimes@ (earlier version)
Relnote: Yes
MFC After: 3 days
Differential Revision: https://reviews.freebsd.org/D23403

4 years agoFix a bug in r356776 where the page allocator was not properly restored to
jeff [Sat, 1 Feb 2020 23:46:30 +0000 (23:46 +0000)]
Fix a bug in r356776 where the page allocator was not properly restored to
the percpu page allocator after it had been temporarily overridden by
startup_alloc.

Reported by: pho, bdragon

4 years agoFix build.
kib [Sat, 1 Feb 2020 23:16:30 +0000 (23:16 +0000)]
Fix build.

Sponsored by: The FreeBSD Foundation

4 years agoIn dmar_gas_lowermatch, skip searching a subtree if all its addresses are greater...
dougm [Sat, 1 Feb 2020 21:47:34 +0000 (21:47 +0000)]
In dmar_gas_lowermatch, skip searching a subtree if all its addresses are greater than lowaddr.
In dmar_gas_uppermatch, skip searching a subtree if all its gaps-between-alloctions are too small.

Reviewed by: kib
Tested by: pho
Differential Revision: https://reviews.freebsd.org/D23391

4 years agoAmend r357367 by using register values from the TPM datasheet.
dim [Sat, 1 Feb 2020 21:43:45 +0000 (21:43 +0000)]
Amend r357367 by using register values from the TPM datasheet.

As Ian Lepore noted, writing ~1 to a register might have a completely
different effect than doing a regular read-modify-write operation.

Follow the TCG_PC_Client_Platform_TPM_Profile_PTP_2.0_r1.03_v22
datasheet instead, and use the actual values mentioned there:
(uint32_t)1 to cancel the command, (uint32_t)0 to clear the field.

MFC after: 3 days

4 years agocache: replace kern___getcwd with vn_getcwd
mjg [Sat, 1 Feb 2020 20:38:38 +0000 (20:38 +0000)]
cache: replace kern___getcwd with vn_getcwd

The previous routine was resulting in extra data copies most notably in
linux_getcwd.

4 years agotpm(4): Fix 'go ready' in TPM 2.0 TIS driver
cem [Sat, 1 Feb 2020 20:38:22 +0000 (20:38 +0000)]
tpm(4): Fix 'go ready' in TPM 2.0 TIS driver

tpmtis_go_ready() read the value of the TPM_STS register, ORed
TPM_STS_CMD_READY with it, and wrote it back.  However, the TPM Profile
(PTP) specification states that only one bit in the write request value may
be set to 1, or else the entire write request is ignored.

Fix by just writing TPM_STS_CMD_READY.

Similarly, remove the call which clears the TPM_STS_CMD_READY flag in the
same function.  It was being ignored for the same reason.

Submitted by: Darrick Lew <darrick.freebsd AT gmail.com>
Reviewed by: vangyzen, myself
MFC after: if you care about stable, you might want to do so
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D23081

4 years agocache: return the total length from vn_fullpath1
mjg [Sat, 1 Feb 2020 20:37:11 +0000 (20:37 +0000)]
cache: return the total length from vn_fullpath1

This removes strlen from getcwd.

4 years agocache: remove vnode -> path lookup disablement
mjg [Sat, 1 Feb 2020 20:36:35 +0000 (20:36 +0000)]
cache: remove vnode -> path lookup disablement

It seems to be of little to no use even when debugging.

Interested parties can resurrect it and gate compilation with a macro.

4 years agovfs: consistently use size_t for buflen around VOP_VPTOCNP
mjg [Sat, 1 Feb 2020 20:34:43 +0000 (20:34 +0000)]
vfs: consistently use size_t for buflen around VOP_VPTOCNP

4 years agorand(3): Replace implementation with one backed by random(3) algorithm
cem [Sat, 1 Feb 2020 20:33:23 +0000 (20:33 +0000)]
rand(3): Replace implementation with one backed by random(3) algorithm

rand(3)'s standard C API is extremely limiting, but we can do better
than the historical 32-bit state Park-Miller LCG we've shipped since
2001: r73156.

The justification provided at the time for not using random(3) was that
rand_r(3) could not be made to use the same algorithm.  That is still
true.  However, the irrelevance of rand_r(3) is increasingly obvious.
Since that time, POSIX has marked the interface obsolescent.  rand_r(3)
never became part of the standard C library.  If not for API
compatibility reasons, I would just remove rand_r(3) entirely.

So, I do not believe it is a problem for rand_r(3) and rand(3) to
diverge.

The 12 ABI is maintained with compatibility definitions, but this
revision does subtly change the API of rand(3).  The sequences of
pseudorandom numbers produced in programs built against new versions of
libc will differ from programs built against prior versions of libc.

Reviewed by: kevans, markm
MFC after: no
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D23290

4 years agohwpstate_intel(4): Save admin-set EPP/EPB and restore after suspend
cem [Sat, 1 Feb 2020 20:12:02 +0000 (20:12 +0000)]
hwpstate_intel(4): Save admin-set EPP/EPB and restore after suspend

4 years agohwpstate_intel(4): Print failure message only on failure
cem [Sat, 1 Feb 2020 20:11:25 +0000 (20:11 +0000)]
hwpstate_intel(4): Print failure message only on failure

X-MFC-With: r357379

4 years agohwpstate_intel(4): Detect and support PKG variant
cem [Sat, 1 Feb 2020 19:50:10 +0000 (19:50 +0000)]
hwpstate_intel(4): Detect and support PKG variant

If package-level control is present, we default to using it.  Per-core
software control may be enabled by setting the machdep.hwpstate_pkg_ctrl
tunable to "0" in loader.conf(5).

4 years agohwpstate_intel(4): Add fallback EPP using PERF_BIAS MSR
cem [Sat, 1 Feb 2020 19:49:13 +0000 (19:49 +0000)]
hwpstate_intel(4): Add fallback EPP using PERF_BIAS MSR

Per Intel SDM (Vol 3b Part 2), if HWP indicates EPP (energy-performance
preference) is not supported, the hardware instead uses the ENERGY_PERF_BIAS
MSR.  In the epp sysctl handler, fall back to that MSR if HWP does not
support EPP and CPUID indicates the ENERGY_PERF_BIAS MSR is supported.

4 years agox86: Add/amend some power-management comments/macros
cem [Sat, 1 Feb 2020 19:46:02 +0000 (19:46 +0000)]
x86: Add/amend some power-management comments/macros

No functional change.

4 years agohwpstate_intel(4): Error check epp sysctl & bail if HW does not support feature
cem [Sat, 1 Feb 2020 19:45:27 +0000 (19:45 +0000)]
hwpstate_intel(4): Error check epp sysctl & bail if HW does not support feature

4 years agotests: epair: Don't fail if we load if_epair
kp [Sat, 1 Feb 2020 19:40:11 +0000 (19:40 +0000)]
tests: epair: Don't fail if we load if_epair

kldload() returns a positive integer when it loads a ko, so check that the
return value is -1 to detect error cases, not that it's different from zero.

MFC after: 3 days
X-MFC-With: r357234

4 years agoRemove a couple of lingering usages of the page lock.
markj [Sat, 1 Feb 2020 18:23:51 +0000 (18:23 +0000)]
Remove a couple of lingering usages of the page lock.

Update vm_page_scan_contig() and vm_page_reclaim_run() to stop using
vm_page_change_lock().  It has no use after r356157.  Remove
vm_page_change_lock() now that it has no users.

Remove an unncessary check for wirings in vm_page_scan_contig(), which
was previously checking twice.  The check is racy until
vm_page_reclaim_run() ensures that the page is unmapped, so one check is
sufficient.

Reviewed by: jeff, kib (previous versions)
Tested by: pho (previous version)
Differential Revision: https://reviews.freebsd.org/D23279