Commit Graph

249720 Commits

Author SHA1 Message Date
Mitchell Horne
0d26dae5c3 RISC-V: provide the correct value for kernstart
pmap_bootstrap() expects the kernel's physical load address, but we have
been providing the start of physical memory. This had the nice effect of
protecting the memory used by the SBI runtime firmware, but now that we
have alternate means of achieving that, we should provide the correct
value. This will free up any memory between the SBI firmware and the
kernel for allocation.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D24156
2020-04-19 00:34:49 +00:00
Mitchell Horne
f2566be5ce RISC-V: exclude reserved memory regions
The device tree may contain a "reserved-memory" node, whose purpose is
to communicate sections of physical memory that should not be used for
general allocations. Add the logic to parse and exclude these regions.

The particular motivation for this is protection of the SBI runtime
firmware. Currently, there is no mechanism through which the SBI
can communicate the details of its reserved memory region(s) to
a supervisor payload. There has been some discussion recently on how
this can be achieved [1], and it seems that the path going forward
will be to add an entry to the reserved-memory node.

This hasn't caused any issues for us yet, since we exclude all physical
memory below the kernel's load address from being allocated, and on all
currently supported platforms this covers the SBI firmware region. This
will change in another commit, so as a safety measure, ensure that the
lowest 2MB of memory is excluded if this region has not been reported.

[1] https://github.com/riscv/riscv-sbi-doc/pull/37

Reviewed by:	markj, nick (older version)
Differential Revision:	https://reviews.freebsd.org/D24155
2020-04-19 00:33:05 +00:00
Mitchell Horne
820a3f438d RISC-V: use physmem to manage physical memory
Replace our hand-rolled functions with the generic ones provided by
kern/subr_physmem.c. This greatly simplifies the initialization of
physical memory regions and kernel globals.

Tested by:	nick
Differential Revision:	https://reviews.freebsd.org/D24154
2020-04-19 00:18:16 +00:00
Mitchell Horne
49439183ce Convert arm's physmem interface to MI code
The arm_physmem interface found in arm's MD code provides a convenient
set of routines for adding/excluding physical memory regions and
initializing important kernel globals such as Maxmem, realmem,
phys_avail[], and dump_avail[]. It is especially convenient for FDT
systems, since we can use FDT parsing functions and pass the result
directly to one of these physmem routines. This interface is already in
use on arm and arm64, and can be used to simplify this early
initialization on RISC-V as well.

This requires only a couple trivial changes:
  - Move arm_physmem_kernel_addr to arm/machdep.c. It is unused on arm64,
    and manipulated entirely in arm MD code.
  - Convert arm32_btop/arm64_btop to atop. This is equivalently defined
    on all architectures.
  - Drop the "arm" prefix.

Reviewed by:	manu, emaste ("looks reasonable")
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24153
2020-04-19 00:12:30 +00:00
Rick Macklem
3c49a19fc9 Change the type of "len" to avoid warnings.
The "len" variable is used as the last argument to getsockname(2) and
accept(2). It was declared an "int" and this patch changes it to "socklen_t".
2020-04-18 23:46:58 +00:00
Alan Somers
420a5a2445 zfs-program.8: fix orphan .Xr
Reported by:	phk
Reviewed by:	avg
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24488
2020-04-18 20:55:43 +00:00
Alan Somers
133b8ab5bb cap_dns.3: fix some orphan .Xr links
Reported by:	phk
MFC after:	2 weeks
2020-04-18 20:13:43 +00:00
Alan Somers
27586155ac bectl.8, beinstall.sh.8: fix man page section of beinstall.sh
Reported by:	phk
MFC after:	2 weeks
2020-04-18 19:53:47 +00:00
Alan Somers
35f139130a zfsd.8: fix orphan .Xr
Though ZFS is a kernel module, it has no man page in section 4.

Reported by:	phk
MFC after:	2 weeks
2020-04-18 19:47:38 +00:00
Ed Maste
cdf1703846 hda: remove hda*_lockowned macros
These are not used anywhere.
2020-04-18 18:25:30 +00:00
Hans Petter Selasky
cc224e5381 Set the maximum exit latency to 0 for XHCI USB 3.0 devices, because we
don't implement link power management, LPM.

This fixes error code XHCI_TRB_ERROR_BANDWIDTH for isochronous USB 3.0
transactions.

Submitted by:	Horse Ma <Shichun.Ma@dell.com>
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-04-18 15:05:10 +00:00
Mateusz Piotrowski
93e0e298b9 Use the Ic macro for find(1) primaries consistently
MFC after:	3 days
2020-04-18 13:29:54 +00:00
Alex Richardson
c9c283bd30 Fix various warnings in tests/sys/kqueue and bump WARNS
Reviewed By:	kevans
Differential Revision: https://reviews.freebsd.org/D24296
2020-04-18 12:54:47 +00:00
Alex Richardson
4db3ef4c77 More fixes to build the kernel with a compiler that defaults to -fno-common
Using the same approach as the last commit for the files used by genassym.sh.

Obtained from:	CheriBSD
2020-04-18 12:54:40 +00:00
Alex Richardson
a8976aec45 Allow kernel modules to build with a compiler that defaults to -fno-common
This uses the same approach as r359691.

Reviewed By:	brooks
Differential Revision: https://reviews.freebsd.org/D24405
2020-04-18 12:54:35 +00:00
Hans Petter Selasky
6f80a2c88e Add missing feature descriptions to hci_features2str().
The list of possible features in hccontrol/features2str() is incomplete.
Refer to "Bluetooth Core Specification 5.2 Vol. 2 Part C. 3.3 Feature Mask Definition".

Submitted by:	Marc Veldman <marc@bumblingdork.com>
PR:		245354
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-04-18 08:29:16 +00:00
Kristof Provost
fac24ad7f0 bridge: Simplify mac address generation
Unconditionally use ether_gen_addr() to generate bridge mac addresses.  This
function is now less likely to generate duplicate mac addresses across jails.
The old hand rolled hostid based code adds no value.

Reviewed by:	bz
Differential Revision:	https://reviews.freebsd.org/D24432
2020-04-18 08:00:58 +00:00
Kristof Provost
3f8bc99c4c ethersubr: Make the mac address generation more robust
If we create two (vnet) jails and create a bridge interface in each we end up
with the same mac address on both bridge interfaces.
These very often conflicts, resulting in same mac address in both jails.

Mitigate this problem by including the jail name in the mac address.

Reviewed by:	kevans, melifaro
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24383
2020-04-18 07:50:30 +00:00
Konstantin Belousov
acf65eef23 sendfile: When all io finished, assert that sfio->pa[] is in expected state.
It must contain fully restored contigous run of the wired pages from
the object, except possible trimmed tail.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2020-04-18 03:09:25 +00:00
Konstantin Belousov
e795a04083 The pa argument for sendfile_iodone() is not necessary a slice of sfio->pa.
It is true for zfs, but it is not for e.g. vnode or buffer pagers.
When fixing bogus pages, fix them in both places.  Rely on the fact
that pa[0] must have been invalid so it cannot be bogus.

Reported and tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2020-04-18 03:07:18 +00:00
Warner Losh
5c68be59c8 Add deprecation notice to amr(4) 2020-04-18 02:53:19 +00:00
Warner Losh
a32311eccd twa(4) deprecation notice 2020-04-18 02:53:14 +00:00
Warner Losh
6ccdbb521a Deprecation notice for iir 2020-04-18 02:53:09 +00:00
Warner Losh
5b18755735 Add deprecation notice to mly 2020-04-18 02:53:04 +00:00
Warner Losh
dd6382d1c4 Add deprecation notice for esp(4). 2020-04-18 02:52:59 +00:00
Simon J. Gerraty
0326eec5c3 Define enum for so_qstate outside of struct.
LLVM-9.0 clang++ throws an error for enum defined within
an anonymous struct.

Reviewed by:	jtl, rpokala
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org//D24477
2020-04-18 01:22:41 +00:00
Ed Maste
f64485243f hdac: replace printf for unowned lock with a lock assertion
Reviewed by:	markj, mav
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24479
2020-04-18 01:16:30 +00:00
Greg Lehey
96273f2488 Tidy up syntax and punctuation of some entries. 2020-04-17 23:14:51 +00:00
Rick Macklem
ae070589d3 Replace all instances of the typedef mbuf_t with "struct mbuf *".
The typedef mbuf_t was used for the Mac OS/X port of the code long ago.
Since this port is no longer used and the use of mbuf_t obscures what
the code does (and is not consistent with style(9)), it is no longer needed.
This patch replaces all instances of mbuf_t with "struct mbuf *", so that
it is no longer used.

This patch should not result in any semantic change.
2020-04-17 21:17:51 +00:00
Conrad Meyer
f953e7317a xen-locore: Silence DWARF2 section warning
Silence the "DWARF2 can only represent one section per compilation unit"
warning in amd64 GENERIC builds by disabling Clang's debuginfo generation for
this assembler file (-g0).  The message is replaced by a warning from
ctfconvert that there is no debuginfo to convert (future work).

The file contains some metadata (several ELF notes) and some code.  The code
does not appear to have anything that debuginfo would aid.

I looked at the generated debuginfo (readelf -w xen-locore.o) prior to this
change, and the metadata that would be disabled are things like associated
between binary offset and code line number (not especially useful with a
disassembler), and label metadata for the entry points (not especially useful
as this is already in the symbol table).

Reviewed by:	royger
Differential Revision:	https://reviews.freebsd.org/D24384
2020-04-17 20:20:03 +00:00
Ed Maste
a449a1eb9b hdac: update comment to match function name
snd_hda was rewritten in r230130; one function retained a comment
referencing the previous name.

MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-04-17 19:14:05 +00:00
Mark Johnston
546c117f86 Remove a vestigal reference to kmem_object.
kmem_object has been an alias of kernel_object for a while.

MFC after:	1 week
2020-04-17 19:12:52 +00:00
Kyle Evans
23d5326823 tty: convert tty_lock_assert to tty_assert_locked to hide lock type
A later change, currently being iterated on in D24459, will in-fact change
the lock type to an sx so that TTY drivers can sleep on it if they need to.
Committing this ahead of time to make the review in question a little more
palatable.

tty_lock_assert() is unfortunately still needed for now in two places to
make sure that the tty lock has not been recursed upon, for those scenarios
where it's supplied by the TTY driver and possibly a mutex that is allowed
to recurse.

Suggested by:	markj
2020-04-17 18:34:49 +00:00
John Baldwin
490befd40a Use the right type for 64-bit coprocessor registers.
The use of "int" here caused the compiler to believe that it needs to
insert a "sll $n, $n, 0" to sign extend as part of the implicit cast
to uint64_t.

Submitted by:	Nathaniel Filardo <nwf20@cl.cam.ac.uk>
Reviewed by:	brooks, arichardson
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24457
2020-04-17 18:24:47 +00:00
Alexander V. Chernikov
ae4b62595e Unbreak build by reverting if_bridge part of r360047.
Pointy hat to: melifaro
2020-04-17 18:22:37 +00:00
John Baldwin
5326289d93 Don't try to copyout() to a kernel buffer.
The handle_string callback for the ENCIOC_GET_ENCNAME and
ENCIOC_GETENCID ioctls tries to copy the size of the generated string
out to userland.  However, the callback only has access to the kernel
copy of the structure populated by copyin().  The copyout() call
simply overwrites the value in the kernel's copy preventing the
subsequent overflow prevention logic from working.

Fix this by instead doing a copyout() of the updated length in the
caller after the callback returns.

Reviewed by:	kib
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D24456
2020-04-17 18:19:13 +00:00
Alexander V. Chernikov
6745294280 Finish r191148: replace rtentry with route in if_bridge if_output() callback.
Generic if_output() callback signature was modified to use struct route
 instead of struct rtentry in r191148, back in 2009.

Quoting commit message:

 Change if_output to take a struct route as its fourth argument in order
 to allow passing a cached struct llentry * down to L2

Fix bridge_output() to match this signature and update the remaining
 comment in if_var.h.

Reviewed by:	kp
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D24394
2020-04-17 17:05:58 +00:00
Mark Johnston
6e17fbacea Always compile minidump_machdep.c on arm.
It is not logically dependent on "device mem", and an arm kernel
compiled without that device fails to link since the minidumpsys()
symbol is referenced by kern_dump.c.

MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2020-04-17 16:55:14 +00:00
Olivier Cochard
86686423d5 Skip routing regression tests depending on if_epair if this module isn't installed.
Approved by:	melifaro
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D24468
2020-04-17 16:31:07 +00:00
Conrad Meyer
497cb9259b vmm.h: Add ABI assertions and mark implicit holes
The static assertions were added (with size and offsets from gdb) and verified
with a build prior to marking the holes explicitly.

This is in preparation for a subsequent revision, pending in phabricator, that
makes use of some of these unused bits without impacting the ABI.

Reviewed by:	grehan
Differential Revision:	https://reviews.freebsd.org/D24461
2020-04-17 15:19:42 +00:00
Kristof Provost
3f359bfd47 bridge tests: Test deleting a bridge with members
Reviewed by:	philip, emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D24337
2020-04-17 14:57:15 +00:00
Kristof Provost
95324dc3f4 pf: Do not allow negative ps_len in DIOCGETSTATES
Userspace may pass a negative ps_len value to us, which causes an
assertion failure in malloc().
Treat negative values as zero, i.e. return the required size.

Reported-by:	syzbot+53370d9d0358ee2a059a@syzkaller.appspotmail.com
Reviewed by:	lutz at donnerhacke.de
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D24447
2020-04-17 14:35:11 +00:00
Eugene Grosbein
4e49fbcd37 jail(8): improve manual and usage information with more clear
description for "jail -e" mode to show that it does not take
additional jail name argument.

Reported by:		David Marec <david.marec@davenulle.org>
MFC after:		3 days
2020-04-17 10:12:11 +00:00
Gleb Smirnoff
9edef911e8 Make ZFS depend on xdr.ko only. It doesn't need kernel RPC.
Differential Revision:	https://reviews.freebsd.org/D24408
2020-04-17 06:05:08 +00:00
Gleb Smirnoff
732a02b4e7 Split XDR into separate kernel module. Make krpc depend on xdr.
Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D24408
2020-04-17 06:04:20 +00:00
Gleb Smirnoff
e5c3941009 Move M_RPC malloc type into XDR. Both RPC and XDR libraries use
this type, but since RPC depends on XDR (not vice versa) we need
it defined in XDR to make the module loadable without RPC.

Reviewed by:	rmacklem
Differential Revision:	https://reviews.freebsd.org/D24408
2020-04-17 06:02:13 +00:00
Gleb Smirnoff
2ffded5e53 Don't initialize m->m_data to m->m_pktdat, this is already done by the
mbuf allocator.  That was the last remnant of such code in the kernel.
2020-04-17 05:59:38 +00:00
Kyle Evans
c17dd0e88b tests: kqueue: use a more precise timer for the NOTE_ABSTIME test
Originally noticed while attempting to run the kqueue tests under
qemu-user-static, this apparently just happens sometimes when running in a
jail in general -- the timer will fire off "too early," but it's really just
the result of imprecise measurements (noted by cem).

Kicking this over to NOTE_USECONDS still tests the correct thing while
allowing it to work more consistently; a basic sanity test reveals that we
often end up coming in just less than 200 microseconds after the timer
fired off.

MFC after:	3 days
2020-04-17 02:22:15 +00:00
Rick Macklem
82164bdd76 Add a sanity check for nes_numsecflavor to the NFS server.
Ryan Moeller reported crashes in the NFS server that appear to be
caused by stack corruption in nfsrv_compound(). It appears that
the stack got corrupted just after a NFSv4.1 Lookup that crosses
a server mount point.
Although it is just a "theory" at this point, the most obvious way
the stack could get corrupted would be if nfsvno_checkexp() somehow
acquires an export with a bogus nes_numsecflavor value. This would
cause the copying of the secflavors to run off the end of the array,
which is allocated on the stack below where the corruption occurs.

This sanity check is simple to do and would stop the stack corruption
if the theory is correct. Otherwise, doing the sanity check seems to
be a reasonable safety belt to add to the code.

Reported by:	freqlabs
MFC after:	2 weeks
2020-04-17 02:21:46 +00:00
Kyle Evans
cc62118e65 audit_canon_path_vp: don't panic if cdir == NULL
cdir may have simply failed to resolve (e.g. fget_cap failure in namei
leading to NULL dp passed to AUDIT_ARG_UPATH*_VP); restore the pre-rS358191
behavior of setting cpath[0] = '\0' and bailing out instead of panicking.

This was found by inadvertently running the libc/c063 tests with auditing
enabled, resulting in a panic.

Reviewed by:	mjg (committed version actually his)
Differential Revision:	https://reviews.freebsd.org/D24445
2020-04-17 02:09:31 +00:00