Commit Graph

269467 Commits

Author SHA1 Message Date
Steve Kargl
4f889260c3 sinpi[fl] etc: Fix the ld128 implementations
Mark Murray graciously provided access to an aarch64 system
to test the ld128 implementations.  This patch address
* Misuses of copysignl() in sinpil() and tanpil().
* Redo the splitting of argument 'x' into an integer part and
  remainder.  The remainder must satify 0 <= r < 1.
* Update the reduction of the integer part to something that can
  easily be seen as even or odd, e.g., sin(pi*x) = (-1)^n*sin(pi*r)
  with n <= 2^112 and we an reduce n by subtracting integer powers
  of 2.
* In s_cospil.c, fix typos where 'x' is used where 'ax', the
  remainder, is required.
* In tanpil(), fix the use of an uninitialized variable, ax = fabsl(ax),
  ax should be x in fabsl().

One item of note, in the limited tested on aarch64, the max ULP
for sinpil() and cospil() were less than 1.1 ULP, which is higher
that the desired max ULP less than 1.  This was traced to the
kernel for cosl() in the fundamental interval [0,pi/4].
The coefficients in the minmax polynomial likely need refinement.

PR:	218514
MFC after:	1 week
2021-11-01 04:38:19 +02:00
Rick Macklem
d5d2ce1c85 nfscl: Do pNFS layout return_on_close synchronously
For pNFS servers that specify that Layouts are to be returned
upon close, they may expect that LayoutReturn to happen before
the associated Close.

This patch modifies the NFSv4.1/4.2 pNFS client so that this
is done.  This only affects a pNFS mount against a non-FreeBSD
NFSv4.1/4.2 server that specifies return_on_close in LayoutGet
replies.

Found during a recent IETF NFSv4 working group testing event.

MFC after:	2 weeks
2021-10-31 16:31:31 -07:00
Mateusz Guzik
627d5d1966 geli: eli data -> eli_data for consistency with other geom classes
PR:	259392
Reported by:	dewayne@heuristicsystems.com.au
MFC after:	1 week
2021-10-31 20:36:51 +00:00
Bjoern A. Zeeb
917181dddf net80211: add a driver-private pointer to struct ieee80211_node
Add a void *ni_drv_data field to struct ieee80211_node that drivers
can use to backtrack to their internal state from a net80211 node.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
X-Differential Revision: https://reviews.freebsd.org/D30654 (abandoned)
2021-10-31 19:08:28 +00:00
Xin LI
f38bef2ce4 Bump __FreeBSD_version following the libdialog shared library
version number bump.
2021-10-30 23:09:29 -07:00
Konstantin Belousov
e5248548f9 procfs: return right hardlink from /proc/curproc/file
Use proc_get_binpath() to get the hardlink right.

PR:	248184
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32738
2021-10-31 03:05:14 +02:00
Konstantin Belousov
f34fc6ba06 Extract proc_get_binpath() from sysctl_kern_proc_pathname()
Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32738
2021-10-31 03:05:14 +02:00
Konstantin Belousov
b4c7d45c84 sys/proc.h: put proc_add_orphan() into proper place
Noted by:	markj
Reviewed by:	emaste, markjd
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32738
2021-10-31 03:05:14 +02:00
Rick Macklem
50dcff0816 nfscl: Add setting n_localmodtime to the Write RPC code
Similar to commit 2be417843a, I believe there could be a race between
the NFS client VOP_LOOKUP() and file Writing that could result in stale
file attributes being loaded into the NFS vnode by VOP_LOOKUP().

I have not been able to reproduce a failure due to this race, but
I believe that there are two possibilities:

The Lookup RPC happens while VOP_WRITE() is being executed and loads
stale file attributes after VOP_WRITE() returns when it has already
completed the Write/Commit RPC(s).
--> For this case, setting the local modify timestamp at the end of
  VOP_WRITE() should ensure that stale file attributes are not loaded.

The Lookup RPC occurs after VOP_WRITE() has returned, while
asynchronous Write/Commit RPCs are in progress and then is
blocked by the vnode held by VOP_OPEN/VOP_CLOSE/VOP_FSYNC which
will flush writes via ncl_flush() or ncl_vinvalbuf(), clearing the
NMODIFIED flag (which indicates Writes-in-progress). The VOP_LOOKUP()
then acquires the NFS vnode lock and fills in stale file attributes.
 --> Setting the local modify timestamp in ncl_flsuh() and ncl_vinvalbuf()
   when they clear NMODIFIED should ensure that stale file attributes
   are not loaded.

This patch does the above.

PR:	259071
Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D32677
2021-10-30 17:08:28 -07:00
Rick Macklem
ab87c39c25 nfscl: Set n_localmodtime in Deallocate
Commit 2be417843a added n_localmodtime, which is used by Lookup
and ReaddirPlus to check to see if the file attributes in an RPC
reply might be stale.  This patch sets n_localmodtime in Deallocate.
Done as a separate commit, since Deallocate is not in stable/13.

PR:	259071
Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D32635
2021-10-30 16:46:14 -07:00
Rick Macklem
2be417843a PR#259071 provides a test program that fails for the NFS client.
Testing with it, there appears to be a race between Lookup
and VOPs like Setattr-of-size, where Lookup ends up loading
stale attributes (including what might be the wrong file size)
into the NFS vnode's attribute cache.

The race occurs when the modifying VOP (which holds a lock
on the vnode), blocks the acquisition of the vnode in Lookup,
after the RPC (with now potentially stale attributes).

Here's what seems to happen:
Child                                Parent

does stat(), which does
VOP_LOOKUP(), doing the Lookup
RPC with the directory vnode
locked, acquiring file attributes
valid at this point in time

blocks waiting for locked file       does ftruncate(), which
vnode                                does VOP_SETATTR() of Size,
                                     changing the file's size
                                     while holding an exclusive
                                     lock on the file's vnode
                                     releases the vnode lock
acquires file vnode and fills in
now stale attributes including
the old wrong Size
                                     does a read() which returns
                                     wrong data size

This patch fixes the problem by saving a timestamp in the NFS vnode
in the VOPs that modify the file (Setattr-of-size, Allocate).
Then lookup/readdirplus compares that timestamp with the time just
before starting the RPC after it has acquired the file's vnode.
If the modifying RPC occurred during the Lookup, the attributes
in the RPC reply are discarded, since they might be stale.

With this patch the test program works as expected.

Note that the test program does not fail on a July stable/12,
although this race is in the NFS client code.  I suspect a
fairly recent change to the name caching code exposed this
bug.

PR:	259071
Reviewed by:	asomers
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D32635
2021-10-30 16:35:02 -07:00
Edward Tomasz Napierala
f0d9a6a781 linux: make PTRACE_SETREGS use a correct struct
Note that this is largely untested at this point, as was
the previous version; I'm committing this mostly to get
rid of `struct linux_pt_reg`.

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32735
2021-10-30 10:13:37 +01:00
Edward Tomasz Napierala
8bbc0600cc linux: Add additional ptracestop only if the debugger is Linux
In 6e66030c4c, additional ptracestop was added in order
to implement PTRACE_EVENT_EXEC.  Make it only apply to cases
where the debugger is a Linux processes; native FreeBSD
debuggers can trace Linux processes too, but they don't
expect that additonal ptracestop.

Fixes:		6e66030c4c
Reported By:	kib
Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32726
2021-10-30 09:54:17 +01:00
Stefan Eßer
20f8331aca usr.bin/stat: honour locale for "-t %+"
The man page states that "-t %+" prints time information in the same
format as date with no format specifier.

This was not the case, the format used was always that of date for the
POSIX locale.

The fix suggested by the reporter leads to output that matches the
documentation.

Reported by:	Jamie Landeg-Jones <jamie@catflap.org>
MFC after:	3 days
2021-10-30 09:00:34 +02:00
Rick Macklem
dc6dd769de nfscl: Use NFSMNTP_DELEGISSUED in two more functions
Commit 5e5ca4c8fc added a NFSMNTP_DELEGISSUED flag to indicate when
a delegation has been issued to the mount.  For the common case
where an NFSv4 server is not issuing delegations, this flag
can be checked to avoid acquisition of the NFSCLSTATEMUTEX.

This patch adds checks for NFSMNTP_DELEGISSUED being set
to two more functions.

This change appears to be performance neutral for a small number
of opens, but should reduce lock contention for a large number of opens
for the common case where server is not issuing delegations.

MFC after:	2 week
2021-10-29 20:35:02 -07:00
Randall Stewart
141a53cd58 tcp: Rack might retransmit forever.
If we get a Sacked peer with an MTU change we can retransmit forever if the
last bytes are sacked and the client goes away (think power off). Then we
never see the end condition and continually retransmit.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D32671
2021-10-29 17:37:49 -04:00
Mark Johnston
26f76aea2d timecounter: Load the currently selected tc once in tc_windup()
Reported by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32729
2021-10-29 14:30:15 -04:00
Mark Johnston
e9bfb50d5e sort: Fix random sort
bwsrawdata() is supposed to return the string buffer.

PR:		259451
Reported by:	sigsys@gmail.com
Fixes:		d053fb22f6 ("usr.bin/sort: Avoid UBSan errors")
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2021-10-29 14:29:50 -04:00
Olivier Houchard
74e9b5f29a Merge commit 'ce929fe84f9c453263af379f3b255ff8eca01d48'
Import CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7.
2021-10-29 19:18:03 +02:00
Olivier Houchard
ce929fe84f Import CK as of commit 2265c7846f4ce667f5216456afe2779b23c3e5f7. 2021-10-29 19:01:15 +02:00
Edward Tomasz Napierala
ad0379660d linux: make PTRACE_GETREGS return correct struct
Previously it returned a shorter struct.  I can't find any
modern software that uses it, but tests/ptrace from strace(1)
repo complained.

Differential Revision: https://reviews.freebsd.org/D32601
2021-10-29 16:18:28 +01:00
Edward Tomasz Napierala
f939dccfd7 linux: Make PTRACE_GETREGSET return proper buffer size
This fixes Chrome warning:

[1022/152319.328632:ERROR:ptracer.cc(476)] Unexpected registers size 0 != 216, 68

Reviewed By:	emaste
Sponsored By:	EPSRC
Differential Revision: https://reviews.freebsd.org/D32616
2021-10-29 15:31:33 +01:00
Edward Tomasz Napierala
c8c93b1516 linux: Also translate the signal if the code is CLD_KILLED
This fixes ./waitid.gen.test from the strace(1) test suite.

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32617
2021-10-29 15:28:00 +01:00
Ed Maste
6ce99625ca Do not build libatf-c++ when WITHOUT_CXX
libatf-c++ requires C++ support.

From jrtc27: bit slightly odd this isn't gated by MK_TESTS (which itself
depends on MK_CXX), but this makes sense given the current behaviour.

Reported by:	Michael Dexter, Build Option Survey
Reviewed by:	imp, jrtc27
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D32732
2021-10-29 10:08:24 -04:00
Ed Maste
0e1c864898 src.opts.mk: Add WITHOUT_CXX dependencies
OFED, OPENMP, and PMC depend on C++ support.  Force them off when
building WITHOUT_CXX.

Reported by:	Michael Dexter, Build Option Survey
Reviewed by:	imp, jrtc27
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32730
2021-10-29 10:06:27 -04:00
Ed Maste
ad09e2c8cf Don't build sanitizer runtimes under WITHOUT_CXX
In the past we built the sanitizer runtimes when building Clang
(and using Clang as the compiler) but 7676b388ad changed this to
be conditional only on using Clang, to make the runtimes available
for external Clang.

They fail to build when WITHOUT_CXX is set though, so add MK_CXX
as part of the condition.

Reported by:	Michael Dexter, Build Option Survey
Reviewed by:	imp, jrtc27
Fixes:		7676b388ad ("Always build the sanitizer runtimes...")
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D32731
2021-10-29 10:05:49 -04:00
Edward Tomasz Napierala
6547153e46 linux: Fix ptrace panic with ERESTART
Translate ERESTART into Linux "internal" errno ERESTARTSYS.
This fixes the erestartsys.gen.test from strace(1).

Reviewed By:	kib
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32623
2021-10-29 14:55:59 +01:00
Wojciech Macek
680920237b Revert "qoriq_gpio: Implement interrupt controller functionality"
This reverts commit 027a58aab2.
2021-10-29 12:05:55 +02:00
Peter Holm
97a74bbe38 stress2: Added a regression test 2021-10-29 09:04:49 +00:00
Wojciech Macek
f5639a06b8 mvneta: fix encap property
Fix MVNETA encap property.
2021-10-29 10:56:57 +02:00
Kornel Duleba
027a58aab2 qoriq_gpio: Implement interrupt controller functionality
The pic_* interface was used.
Only edge interrupts are supported by this controller.
Driver mutex had to be converted to a spin lock so that it can
be used in the interrupt filter context.
Two types of intr_map_data are supported - INTR_MAP_DATA_GPIO and
INTR_MAP_DATA_FDT. This way interrupts can be allocated using the
userspace gpio interrupt allocation method, as well as directly from
simplebus. The latter can be used by devices that have its irq routed
to a GPIO pin.

Obtained from: Semihalf
Sponsored by: Alstom Group
Differential revision: https://reviews.freebsd.org/D32587
2021-10-29 10:08:26 +02:00
Kornel Duleba
d88aecce69 felix: Add a sysctl to control timer routine frequency
Driver polls status of all PHYs connected to the switch in a
fixed interval.
Add a sysctl that allows to control frequency of that.
The value is expressed in ticks and defaults to "hz", or 1 second.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-10-29 10:08:26 +02:00
Kornel Duleba
8c5fead105 Remove enetc_mdio driver
It was previously used by felix(4) for PHY communication.
Since that is not the case anymore this driver is now left unused.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-10-29 10:08:26 +02:00
Kornel Duleba
29cf6a79ac felix: Use internal MDIO regs for PHY communication
Previously we would use an external MDIO device found on the PCI bus.
Switch to using MDIO mapped in a separate BAR of the switch device.
It is much easier this way since we don't have to depend on another
driver anymore.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-10-29 10:08:26 +02:00
Kornel Duleba
06e6ca6dd3 dmar: Disable protected memory regions after initialization
Some BIOSes protect memory region they reside in by using DMAR to
prevent devices from doing any DMA transactions to that part of RAM.
AMI refers to this as "DMA Control Guarantee".
Disable the protection when address translation is enabled.
I stumbled upon this while investigation a failing coredump on a device
which has this feature enabled.

Sponsored by:		Stormshield
Obtained from:		Semihalf
Reviewed by:		kib
Differential revision:	https://reviews.freebsd.org/D32591
2021-10-29 10:08:25 +02:00
Kornel Duleba
3c02da8096 dmar: Don't try to reserve PCI regions for non-existing devices
In some cases we might have to create DMAR context before the
corresponding device has been enumerated by the PCI bus.
In that case we get called with NULL dev, because of that trying
to reserve PCI regions causes a NULL pointer dereference in
pci_find_pcie_root_port.

Sponsored by:		Stormshield
Obtained from:		Semihalf
MFC after:		2 weeks
Reviewed by:		kib, rlibby
Differential revision:	https://reviews.freebsd.org/D32589
2021-10-29 10:08:25 +02:00
Wojciech Macek
ccfa9ac5ac NXP: Add ls1028a SPI clock driver
Provide driver for LS1028A and LX2160 SPI clock modules.

Obtained from:		Semihalf
Sponsored by:		Alstom
Differential revision:	https://reviews.freebsd.org/D32689
2021-10-29 09:52:20 +02:00
Randall Stewart
aeda852782 tcp: Rack at times can miscalculate the RTT from what it thinks is a persists probe respone.
Turns out that if a peer sends in a window update right after rack fires off
a persists probe, we can mis-interpret the window update and calculate
a bogus RTT (very short). We still process the window update and send
the data but we incorrectly generate an RTT. We should be only doing
the RTT stuff if the rwnd is still small and has not changed.

Reviewed by: Michael Tuexen
Sponsored by: Netflix Inc.
Differential Revision: https://reviews.freebsd.org/D32717
2021-10-29 03:17:43 -04:00
Kirk McKusick
68bff4a07e Allow GEOM utilities to specify a -v option.
Geom utilities (geli(8), glabel(8), gmirror(8), gpart(8), gmirror(8),
gmountver(8), etc) all use the geom(8) utility as their back end
to process their commands and pass them into the kernel. Creating
a new utility requires no more than filling out a template describing
the commands and arguments that the utility supports. Consider the
specification for the very simple gmountver(8) utility:

struct g_command class_commands[] = {
	{ "create", G_FLAG_VERBOSE | G_FLAG_LOADKLD, NULL,
	    {
		G_OPT_SENTINEL
	    },
	    "[-v] prov ..."
	},
	{ "destroy", G_FLAG_VERBOSE, NULL,
	    {
		{ 'f', "force", NULL, G_TYPE_BOOL },
		G_OPT_SENTINEL
	    },
	    "[-fv] name"
	},
	G_CMD_SENTINEL
};

It has just two commands of its own: "create" and "destroy" along
with the four standard commands "list", "status", "load", and
"unload" provided by the base geom(8) utility. The base geom(8)
utility allows each command to use the G_FLAG_VERBOSE flag to specify
that a command should accept the -v flag and when the -v flag is
given the utility prints "Done." if the command completes successfully.
In the above example, both of the commands set the G_FLAG_VERBOSE,
so have the -v option available. In addition the "destroy" command
accepts the -f boolean flag to force the destruction.

If the "destroy" command wanted to also print out verbose information,
it would need to explicitly declare its intent by adding a line:

		{ 'v', "verbose", NULL, G_TYPE_BOOL },

Before this change, the geom utility would silently ignore the above
line in the configuration file, so it was impossible for the utility
to know that the -v flag had been set on the command. With this
change a geom command can explicitly specify a -v option with a
line as given above and handle it as it would any other option. If
both a -v option and G_FLAG_VERBOSE are specified for a command
then both types of verbose information will be output when that
command is run with -v.

MFC after:    1 week
Sponsored by: Netflix
2021-10-28 22:50:50 -07:00
Cy Schubert
a30e8044aa wpa: Fix WITHOUT_CRYPT build
PASN requires CRYPT and when built WITHOUT_CRYPT buildworld
fails. Only enable PASN when MK_CRYPT is enabled (default).

PR:		259517
Reported by:	emaste
Fixes:		c1d255d3ff
MFC after:	1 week
2021-10-28 19:38:12 -07:00
Steve Kargl
3bfc837685 sinpi,cospi,tanpi: float.h needed for week reference
The patch fixes the omission of '#include <float.h>', which is needed for
the weak reference on systems with LDBL_MANT_DIG == DBL_MANT_DIG.

PR:	218514
MFC after:	1 week
2021-10-29 03:15:19 +03:00
Ed Maste
6940d0e470 Force WITHOUT_OPENSSL_KTLS off when WITHOUT_OPENSSL
Discussed with:	jhb
MFC after:	1 week
Reported by:	Michael Dexter, Build Option Survey
Sponsored by:	The FreeBSD Foundation
2021-10-28 19:04:14 -04:00
Gleb Smirnoff
92b3e07229 Enable net.inet.tcp.nolocaltimewait.
This feature has been used for many years at large sites and
didn't show any pitfalls.
2021-10-28 15:34:00 -07:00
Sebastian Huber
ae750fbac7 kern_tc.c: Scaling/large delta recalculation
This change is a slight performance optimization for systems with a slow
64-bit division.

The th->th_scale and th->th_large_delta values only depend on the
timecounter frequency and the th->th_adjustment. The timecounter
frequency of a timehand only changes when a new timecounter is activated
for the timehand. The th->th_adjustment is only changed by the NTP
second update. The NTP second update is not done for every call of
tc_windup().

Move the code block to recalculate the scaling factor and
the large delta of a timehand to the new helper function
recalculate_scaling_factor_and_large_delta().

Call recalculate_scaling_factor_and_large_delta() when a new timecounter
is activated and a NTP second update occurred.

MFC after:	1 week
2021-10-29 00:31:14 +03:00
Ed Maste
a901f2af58 libradius: fix WITHOUT_OPENSSL build
int alen is used only with SSL.

Reported by:	Michael Dexter, Build Option Survey
MFC after:	3 days
Fixes:		8d5c781306 ("libradius: Fix input validation bugs")
Sponsored by:	The FreeBSD Foundation
2021-10-28 17:05:53 -04:00
Konstantin Belousov
1c69690319 Unmap shared page manually before doing vm_map_remove() on exit or exec
This allows the pmap_remove(min, max) call to see empty pmap and exploit
empty pmap optimization.

Reviewed by:	markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32569
2021-10-28 22:01:59 +03:00
Konstantin Belousov
0b3bc72889 amd64 pmap: adjust the empty pmap optimization in pmap_remove()
to match the added accounting of the top-level page table pages.

Reviewed by:	markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32569
2021-10-28 22:01:58 +03:00
Konstantin Belousov
e93b5adb6b amd64 pmap: account for the top-level pages
both for kernel and user page tables, the later exist in the PTI case.

Reviewed by:	markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D32569
2021-10-28 22:01:58 +03:00
Konstantin Belousov
4d675b80f0 i386: fix struct proc layout asserts after 351d5f7fc5
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2021-10-28 21:56:21 +03:00
Felix Johnson
191c624d95 config(5): Update upper limit for maxusers on 64-bit systems
The limit of 384 maxusers for auto configuration was only imposed on
32-bit systems. Document that maxusers scales above 384 based on memory
for 64-bit systems.

PR:		204938
MFC after:	3 days
Reported by:	David Höppner <0xffea@gmail.com>
2021-10-28 14:15:08 -04:00