]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoShrink struct sysent from 48 to 32 bytes (on LP64; on ILP32 its probably
Edward Tomasz Napierala [Sun, 27 Sep 2020 18:14:01 +0000 (18:14 +0000)]
Shrink struct sysent from 48 to 32 bytes (on LP64; on ILP32 its probably
from 32 to 28) by shrinking some entries and reordering them.

Reviewed by: kib
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26508

3 years agoCheck the result of the function, not the pointer to it.
Michal Meloun [Sun, 27 Sep 2020 16:15:03 +0000 (16:15 +0000)]
Check the result of the function, not the pointer to it.

3 years agoCleanup, no functional change intended.
Michael Tuexen [Sun, 27 Sep 2020 13:32:02 +0000 (13:32 +0000)]
Cleanup, no functional change intended.

MFC after: 3 days

3 years agoImprove the handling of receiving unordered and unreliable user
Michael Tuexen [Sun, 27 Sep 2020 13:24:01 +0000 (13:24 +0000)]
Improve the handling of receiving unordered and unreliable user
messages using DATA chunks. Don't use fsn_included when not being
sure that it is set to an appropriate value. If the default is
used, which is -1, this can result in SCTP associaitons not
making any user visible progress.

Thanks to Yutaka Takeda for reporting this issue for the the
userland stack in https://github.com/pion/sctp/issues/138.

MFC after: 3 days

3 years agoDon't send a signal with uninitialized 'sig' and 'code' fields.
Michal Meloun [Sun, 27 Sep 2020 11:37:17 +0000 (11:37 +0000)]
Don't send a signal with uninitialized 'sig' and 'code' fields.
We have a few shortcuts in the arm trap code to speed up obvious "must fail"
cases. In these situations, make sure that we fill in the "sig" and "code"
fields of the generated signal.

MFC after: 3 weeks

3 years agoAdd LINUX_BOOT_ABI back to arm64 GENERIC kernel.
Michal Meloun [Sun, 27 Sep 2020 10:15:03 +0000 (10:15 +0000)]
Add LINUX_BOOT_ABI back to arm64 GENERIC kernel.

It was removed in r355289 but forgot to return it back when new u-boot booti
support was committed.  Although booti is not the preferred method of
booting the kernel, it is very useful for the initial phase of porting
FreeBSD to a new platform or booting the kernel on various embedded boards
in an industrial environment.

3 years agoReapply r366193 with proper commit log.
Michal Meloun [Sun, 27 Sep 2020 09:27:39 +0000 (09:27 +0000)]
Reapply r366193 with proper commit log.

Don't map same physical memory multiple times with different cache attributes.
This is explicitly stated as architectural undefined behavior, leading to
coherency issues sooner or later.

3 years agoRevert r366193, it was committed with unsaved commit log.
Michal Meloun [Sun, 27 Sep 2020 09:24:31 +0000 (09:24 +0000)]
Revert r366193, it was committed with unsaved commit log.

3 years agoDon't map same physical memory multiple times with different cache attributes.
Michal Meloun [Sun, 27 Sep 2020 09:14:16 +0000 (09:14 +0000)]
Don't map same physical memory  multiple times with different cache attributes.
This is explicitly stated as architectural undefined behavior, leadint to
coherencz issues sonner or later.

3 years agoDon't try to print EFI memeory map if it doesn't exist.
Michal Meloun [Sun, 27 Sep 2020 09:12:36 +0000 (09:12 +0000)]
Don't try to print EFI memeory map if it doesn't exist.

MFC after: 1 week

3 years agoBjorn reported a problem where the Linux NFSv4.1 client is
Rick Macklem [Sat, 26 Sep 2020 23:05:38 +0000 (23:05 +0000)]
Bjorn reported a problem where the Linux NFSv4.1 client is
using an open_to_lock_owner4 when that lock_owner4 has already
been created by a previous open_to_lock_owner4. This caused the NFS server
to reply NFSERR_INVAL.

For NFSv4.0, this is an error, although the updated NFSv4.0 RFC7530 notes
that the correct error reply is NFSERR_BADSEQID (RFC3530 did not specify
what error to return).

For NFSv4.1, it is not obvious whether or not this is allowed by RFC5661,
but the NFSv4.1 server can handle this case without error.
This patch changes the NFSv4.1 (and NFSv4.2) server to handle multiple
uses of the same lock_owner in open_to_lock_owner so that it now correctly
interoperates with the Linux NFS client.
It also changes the error returned for NFSv4.0 to be NFSERR_BADSEQID.

Thanks go to Bjorn for diagnosing this and testing the patch.
He also provided a program that I could use to reproduce the problem.

Tested by: bj@cebitec.uni-bielefeld.de (Bjorn Fischer)
PR: 249567
Reported by: bj@cebitec.uni-bielefeld.de (Bjorn Fischer)
MFC after: 3 days

3 years agoCheck for the only 32-bit MIPS ABIs we support, rather than !n64
Justin Hibbits [Sat, 26 Sep 2020 21:47:11 +0000 (21:47 +0000)]
Check for the only 32-bit MIPS ABIs we support, rather than !n64

There may be additional 64-bit ABIs supported, so use a positive check rather
than a negative check.
Suggested by: imp
MFC after: 1 week
Sponsored by: Juniper Networks, Inc

3 years agobsdconfig, bsdinstall: Prune dead mirrors
Niclas Zeising [Sat, 26 Sep 2020 16:27:09 +0000 (16:27 +0000)]
bsdconfig, bsdinstall: Prune dead mirrors

Prune dead mirrors from the list of mirrors in bsdconfig and bsdinstall.
All these return NXDOMAIN when trying to resolve them.

Reviewed by: emaste
Approved by: emaste
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26535

3 years agofix typo imorted -> imported.
Warner Losh [Sat, 26 Sep 2020 04:06:16 +0000 (04:06 +0000)]
fix typo imorted -> imported.

Noticed by: Maigurs Stalidzans

3 years agoRevert most of r360179.
John Baldwin [Fri, 25 Sep 2020 21:19:56 +0000 (21:19 +0000)]
Revert most of r360179.

I had failed to notice that sgsendccb() was using cam_periph_mapmem()
and thus was not passing down user pointers directly to drivers.  In
practice this broke requests submitted from userland.

PR: 249395
Reported by: Trenton Schulz <trueos@norwegianrockcat.com>
Reviewed by: scottl
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26550

3 years agoAdjustments to includes for openzfs in _STANDALONE
Warner Losh [Fri, 25 Sep 2020 20:51:07 +0000 (20:51 +0000)]
Adjustments to includes for openzfs in _STANDALONE

Allow the necessary parts of systm.h to be visible in the _STANDALONE
environnment. Limit the reset to only being visible for _KERNEL
builds.  Map KASSERT, etc to printf on failure in the bootloader until
we have more confidence things won't break and leave systems
unbootable. Eventually, this should map to a full panic in the
bootloader, but that also needs some enhancement to be more useful.

Reviewed by: tsoome, jhb
Differential Revision:  https://reviews.freebsd.org/D26543

3 years agoFix mips64 build
Justin Hibbits [Fri, 25 Sep 2020 20:27:36 +0000 (20:27 +0000)]
Fix mips64 build

Original patch was against FreeBSD 12, and a test compile wasn't run against
head.  md_tls_tcb_offset field was moved from mdthread to mdproc in the
meantime.

MFC after: 1 week
Sponsored by: Juniper Networks, Inc.

3 years agomips: Fix compat32 library builds from r366162
Justin Hibbits [Fri, 25 Sep 2020 19:04:03 +0000 (19:04 +0000)]
mips: Fix compat32 library builds from r366162

Re-add the a_ptr and a_fcn fields to Elf32_Auxinfo.

MFC after: 1 week
Sponsored by: Juniper Networks, Inc.

3 years agoDont let kernel and standalone both be defined at the same time
Warner Losh [Fri, 25 Sep 2020 19:02:49 +0000 (19:02 +0000)]
Dont let kernel and standalone both be defined at the same time

_KERNEL and _STANDALONE are different things. They cannot both be true
at the same time. If things that are normally visible only to _KERNEL
are needed for the _STANDALONE environment, you need to also make them
visible to _STANDALONE. Often times, this will be just a subset of the
required things for _KERNEL (eg global variables are but one example).

sys/cdefs.h is included by pretty much everything in both the loader
and the kernel, so is the ideal choke point.

3 years agong_l2tp: Fix callout synchronization in the rexmit timeout handler
Mark Johnston [Fri, 25 Sep 2020 18:55:50 +0000 (18:55 +0000)]
ng_l2tp: Fix callout synchronization in the rexmit timeout handler

A received control packet may cause the transmit queue to be flushed, in
which case ng_l2tp_seq_recv_nr() cancels the transmit timeout handler.
The handler checks to see if it was cancelled before doing anything, but
did so before acquiring the node lock, so a small race window could
cause ng_l2tp_seq_rack_timeout() to attempt to flush an empty queue,
ultimately causing a null pointer dereference.

PR: 241133
Reviewed by: bz, glebius, Lutz Donnerhacke
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC (Netgate)
Differential Revision: https://reviews.freebsd.org/D26548

3 years agoComment out bogus command line entry
Warner Losh [Fri, 25 Sep 2020 18:20:45 +0000 (18:20 +0000)]
Comment out bogus command line entry

Linux implements -d to mean --print-decimal. We don't implement that
and use -d for --device-path. Note that.

3 years agoTweak output of the loader variable
Warner Losh [Fri, 25 Sep 2020 18:20:41 +0000 (18:20 +0000)]
Tweak output of the loader variable

When the DEVICE_PATH is <= 4 that means it's effectively empty. I have
a laptop that has a BIOS that likes to generate these:

8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot2001
0000: 01 00 00 00 04 00 45 00 46 00 49 00 20 00 55 00
0010: 53 00 42 00 20 00 44 00 65 00 76 00 69 00 63 00
0020: 65 00 00 00 7f ff 04 00 52 43

which now decodes as
8be4df61-93ca-11d2-aa0d-00e098032b8c-Boot2001
* EFI USB Device
Empty path
Option:
0000: 52 43

which matches my hand-decode.

Add an extra newline after Option: to make it look nice.

I suspect that these entries really should be VenHw entries instead,
but my ability to change that is NIL, so cope with them as best we can.

efibootmgr(8)'s output is fine and doesn't need adjusting.

3 years agoFix compat32 on mips64
Justin Hibbits [Fri, 25 Sep 2020 17:13:45 +0000 (17:13 +0000)]
Fix compat32 on mips64

Summary:
Two bugs:
* Elf32_Auxinfo is broken, using pointers in the union, which are 64-bits not
  32.
* freebsd32_sysarch() doesn't update the 'user local' register when handling
  MIPS_SET_TLS, leading to a NULL pointer dereference in the 32-bit
  application.

Reviewed by: #mips, brooks
MFC after: 1 week
Sponsored by: Juniper Networks, Inc
Differential Revision: https://reviews.freebsd.org/D26556

3 years agoRefine locking inside of syscon driver.
Michal Meloun [Fri, 25 Sep 2020 16:44:01 +0000 (16:44 +0000)]
Refine locking inside of syscon driver.
In some cases, the syscon driver may be used by consumer requiring better
control about locking (ie. it may be used as registe file provider for clock
driver which needs locked access to multiple registers).
Add fine locking protocol methods together with bunch of helper functions
in syscon driver and implement this functionality in syscon_generic driver.

MFC after: 4 weeks

3 years agoEnable SO_LINGER to the so_reuseport_lb_test regression tests, preventing
Olivier Cochard [Fri, 25 Sep 2020 16:02:13 +0000 (16:02 +0000)]
Enable SO_LINGER to the so_reuseport_lb_test regression tests, preventing
many sockets in TIME_WAIT state at the end of the test.

PR: 249885
Reviewed by: markj
Approved by: markj
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D26549

3 years agoCorrectly handle nodes compatible with "syscon", "simple-bus".
Michal Meloun [Fri, 25 Sep 2020 13:52:31 +0000 (13:52 +0000)]
Correctly handle nodes compatible with "syscon", "simple-bus".
Syscon can also have child nodes that share a registration file with it.
To do this correctly, follow these steps:
- subclass syscon from simplebus and expose it if the node is also
  "simple-bus" compatible.
- block simplebus probe for this compatible string, so it's priority
 (bus pass) doesn't colide with syscon driver.

While I'm in, also block "syscon", "simple-mfd" for the same reason.

MFC after: 4 weeks

3 years agoTCP: send full initial window when timestamps are in use
Richard Scheffenegger [Fri, 25 Sep 2020 10:38:19 +0000 (10:38 +0000)]
TCP: send full initial window when timestamps are in use

The fastpath in tcp_output tries to send out
full segments, and avoid sending partial segments by
comparing against the static t_maxseg variable.
That value does not consider tcp options like timestamps,
while the initial window calculation is using
the correct dynamic tcp_maxseg() function.

Due to this interaction, the last, full size segment
is considered too short and not sent out immediately.

Reviewed by: tuexen
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D26478

3 years agoTCP newreno: improve after_idle ssthresh
Richard Scheffenegger [Fri, 25 Sep 2020 10:23:14 +0000 (10:23 +0000)]
TCP newreno: improve after_idle ssthresh

Adjust ssthresh in after_idle to the maximum of
the prior ssthresh, or 3/4 of the prior cwnd. See
RFC2861 section 2 for an in depth explanation for
the rationale around this.

As newreno is the default "fall-through" reaction,
most tcp variants will benefit from this.

Reviewed by: tuexen
MFC after: 2 weeks
Sponsored by: NetApp, Inc.
Differential Revision: https://reviews.freebsd.org/D22438

3 years agovi(1): Add URL to the vi/ex reference manual in the man page
Fernando Apesteguía [Fri, 25 Sep 2020 10:20:12 +0000 (10:20 +0000)]
vi(1): Add URL to the vi/ex reference manual in the man page

Reported in PR 241985

The manual page references the "vi/ex reference manual" but there is no
information about where to find that document. Add a reference to the manual in
the SEE ALSO section since the Project hosts a copy of it[1].

Change sent upstream[2]

If D26158 gets reviewed and committed, we could close that PR.

[1] https://docs.freebsd.org/44doc/usd/13.viref/paper.pdf).
[2] https://github.com/lichray/nvi2/pull/85

Submitted by: freebsd@tim.thechases.com
Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D26163

3 years agoRegen after r366145.
Edward Tomasz Napierala [Fri, 25 Sep 2020 10:05:38 +0000 (10:05 +0000)]
Regen after r366145.

Sponsored by: DARPA

3 years agoMake simplebus friendlier for subclassing.
Michal Meloun [Fri, 25 Sep 2020 09:56:50 +0000 (09:56 +0000)]
Make simplebus friendlier for subclassing.

MFC after: 1 week

3 years agoMake makesyscalls.lua initialize 'struct sysent' entries using c99
Edward Tomasz Napierala [Fri, 25 Sep 2020 09:34:00 +0000 (09:34 +0000)]
Make makesyscalls.lua initialize 'struct sysent' entries using c99
designated initializers.  This makes it easier to modify 'struct sysent'
layout.

Reviewed by: kevans
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D26530

3 years agopwm(8): fix potential duty overflow, use unsigneds for period and duty
Andriy Gapon [Fri, 25 Sep 2020 07:55:08 +0000 (07:55 +0000)]
pwm(8): fix potential duty overflow, use unsigneds for period and duty

For a long period value and the duty specified as a percentage,
there could be an overflow.
Using unsigned integers aligns the code with struct pwm_state and allows
to safely use periods up to 4 seconds where supported by drivers.

MFC after: 2 weeks

3 years agopwm(8): do not exit with failure after successfully reading configuration
Andriy Gapon [Fri, 25 Sep 2020 07:54:38 +0000 (07:54 +0000)]
pwm(8): do not exit with failure after successfully reading configuration

MFC after: 1 week

3 years agoaw_pwm: add a check and some comments related to long periods
Andriy Gapon [Fri, 25 Sep 2020 07:41:51 +0000 (07:41 +0000)]
aw_pwm: add a check and some comments related to long periods

The hardware supports periods as long as 196 seconds[*] when using the
maximal prescaling of 72000 and maximum cycle count of 2^16.

But the code becomes incorrect when the period length approaches 1 second.
That's because of things like NS_PER_SEC / period.

[*] At the same time I must note that the KPI provides for maximum
period of about 4 seconds (2^32 nanoseconds).

MFC after: 2 weeks

3 years agoaw_pwm: ensure sane configuration, just in case
Andriy Gapon [Fri, 25 Sep 2020 07:40:56 +0000 (07:40 +0000)]
aw_pwm: ensure sane configuration, just in case

Make sure that the hardware is configured to cycle mode and that the
bypass is disabled.

MFC after: 2 weeks

3 years agoaw_pwm: fix programming of the period
Andriy Gapon [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
Andriy Gapon [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
Andriy Gapon [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
Andriy Gapon [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")
Conrad Meyer [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
Alan Somers [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
Alan Somers [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
Gordon Bergling [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
Gordon Bergling [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
Gordon Bergling [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.
Maxim Sobolev [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
Gordon Bergling [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
Fernando Apesteguía [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
Alan Somers [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
Fernando Apesteguía [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
Alan Somers [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
Ed Maste [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.
Michael Tuexen [Thu, 24 Sep 2020 12:26:06 +0000 (12:26 +0000)]
Whitespace changes.

MFC after: 3 days

3 years agoRemove pointless local variable.
Konstantin Belousov [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.
Bjoern A. Zeeb [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 Turner [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 Turner [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
Stefan Eßer [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
Li-Wen Hsu [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.
Michal Meloun [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 Turner [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 Turner [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.
Warner Losh [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 Turner [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 Turner [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
Warner Losh [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.
Stefan Eßer [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
Mateusz Guzik [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
Maxim Sobolev [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
Warner Losh [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
Kyle Evans [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.
Mark Johnston [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.
Mark Johnston [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.
Mark Johnston [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
Warner Losh [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
Toomas Soome [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 O'Brien [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
Konstantin Belousov [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
Conrad Meyer [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
Ed Maste [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
Alex Richardson [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
Alex Richardson [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
Mateusz Guzik [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
Mateusz Guzik [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
Mateusz Guzik [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
Mateusz Guzik [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
Toomas Soome [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.
Xin LI [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.
Xin LI [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.
Brandon Bergren [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.
Brandon Bergren [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
Brandon Bergren [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
Kyle Evans [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
Kyle Evans [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
Brandon Bergren [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.
Brandon Bergren [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.
Brandon Bergren [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.
Brandon Bergren [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.
Brandon Bergren [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.