Commit Graph

284209 Commits

Author SHA1 Message Date
Cy Schubert
e6bfd18d21 ntp: import ntp-4.2.8p17
Fixes two small bugs including one regression.

MFC after:	3 days

Merge commit 'ab1f1aa8333369a83ff284848fc3fc2e52d5f29f'
2023-06-06 05:44:51 -07:00
Cy Schubert
ab1f1aa833 ntp: import ntp-4.2.8p17 2023-06-06 05:26:44 -07:00
Andrew Turner
62f9bcf2b4 Switch to contigmalloc in the Hyper-V code
In the Hyper-V drivers we need to allocate buffers shared between the
host and guest. This memory has been allocated with bus_dma, however
it doesn't use this correctly, e.g. it is missing calls to
bus_dmamap_sync. Along with this on arm64 we need this memory to be
mapped with the correct memory type that bus_dma may not use.

Switch to contigmalloc to allocate this memory as this will correctly
allocate cacheable memory.

Reviewed by:	Souradeep Chakrabarti <schakrabarti@microsoft.com>
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D40227
2023-06-06 10:50:59 +01:00
Kristof Provost
657aec455f pf tests: test reassembly in the slow path
Ensure that 'fragment reassemble' works as expected, even in the IP
stack's slow forwarding path. (So not via ip_tryforward())

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40396
2023-06-06 10:03:50 +02:00
Kristof Provost
185c1cddd7 netinet: re-read IP length after PFIL hook
The pfil hook may modify the packet, so before we check its length (to
decide if it needs to be fragmented or not) we should re-read that
length.

This is most likely to happen when pf is reassembling packets. In that
scenario we'd receive the last fragment, which is likely to be a short
packet, pf would reassemble it (likely exceeding the interface MTU) and
then we'd transmit it without fragmenting, because we're comparing the
MTU to the length of the last fragment, not the fully reassembled
packet.

See also:	https://redmine.pfsense.org/issues/14396
Reviewed by:	cy
MFC after:	3 weeks
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40395
2023-06-06 10:01:03 +02:00
Kristof Provost
a9bfd080d0 if_epair: do not transmit packets that exceed the interface MTU
While if_epair has no issues doing this we should drop those packets
anyway, because it improves the fidelity of the automated tests.

Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D40397
2023-06-06 10:00:48 +02:00
Xin LI
1bbdfb0b43 gve: Add PNP info to PCI attachment of gve(4) driver.
Reviewed-by:		imp
Differential Revision:	https://reviews.freebsd.org/D40429
2023-06-05 21:05:55 -07:00
Michael Tuexen
d66540e829 tcp: improve sending of TTL/hoplimit and DSCP
Ensure that a user specified value of TTL/hoplimit and DSCP is
used when sending packets.

Reviewed by:		cc, rscheff
MFC after:		1 week
Sponsored by:		Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D40423
2023-06-05 18:43:06 +02:00
Konstantin Belousov
91880e07f6 rtld: do not allow both dynamic DTV index and static TLS offset
If we are allocating static offset for an object with dynamic index,
return failure.  In the opposite case, if dynamic index is requested for
statically allocated TLS area, directly use the offset instead of
setting the index.

Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c
rev. 1.18.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:18 +03:00
Konstantin Belousov
283a4f4097 rtld: rename tls_done to tls_static
The meaning of the flag is that static TLS allocation was done.

Taken from NetBSD Joerg Sonnenberger change for src/libexec/ld.elf_so/tls.c
rev. 1.18.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:17 +03:00
Konstantin Belousov
a7bca69492 rtld_tls.h: style
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-06-05 22:33:17 +03:00
Dag-Erling Smørgrav
fbc445addf xargs: Consistently use strtonum() to parse arguments.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D40425
2023-06-05 20:50:54 +02:00
Pierre Pronchery
e730066a64 decryptcore: Request the OpenSSL 1.1 API
OPENSSL_API_COMPAT can be used to specify the OpenSSL API version in
use for the purpose of hiding deprecated interfaces and enabling
the appropriate deprecation notices.

This change is a NFC while we're still using OpenSSL 1.1.1 but will
avoid deprecation warnings upon the switch to OpenSSL 3.0.

A future update may migrate to use the OpenSSL 3.0 APIs.

PR:		271615
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
2023-06-05 13:48:05 -04:00
Mark Johnston
6062d9faf2 vm_phys: Change the return type of vm_phys_unfree_page() to bool
This is in keeping with the trend of removing uses of boolean_t, and the
sole caller was implicitly converting it to a "bool".

No functional change intended.

Reviewed by:	dougm, alc, imp, kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D40401
2023-06-05 12:22:11 -04:00
Dag-Erling Smørgrav
6d777389e1 xargs: Fix typo in error message.
MFC after:	1 week
Sponsored by:	Klara, Inc.
2023-06-05 18:11:44 +02:00
Dag-Erling Smørgrav
7ba6119e22 ctags: Don't undercount lines when handling // comments.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D40374
2023-06-05 17:53:45 +02:00
Mateusz Piotrowski
979754a15a nfsstat.1: Add a missing argument to -w
MFC after:	3 days
Sponsored by:	Klara Inc.
2023-06-05 14:33:55 +02:00
Colin Percival
9d6ae1e3c2 Revert "Revert "tslog: Annotate some early boot functions""
Now that <sys/tslog.h> is wrapped in #ifdef _KERNEL, it's safe to have
tslog annotations in files which might be built from userland (i.e. in
subr_boot.c, which is built as part of the boot loader).

This reverts commit 59588a546f.
2023-06-04 22:49:38 -07:00
Colin Percival
1e4b7ab136 tslog.h: Wrap in #ifdef _KERNEL
This is not intended to be used from outside of the kernel; in
particular, the boot loader has its own version of tslog.
2023-06-04 22:49:38 -07:00
Ben Harris
37e3f5b23b Enable support for printing 8-byte integers. For some reason, most of the
code for this was present, but disabled.
This is required for POSIX compliance on platforms with 8-byte longs.

Obtained-From:	NetBSD
PR:		238586
Reported-By:	Mohamed Akram <mohd.akram@outlook.com>
MFC after:	2 weeks
2023-06-04 19:23:35 -07:00
Xin LI
4d779448ad gve: Fix build on i386 and enable LINT builds.
Reviewed-by:	imp
Differential Revision: https://reviews.freebsd.org/D40419
2023-06-04 16:35:00 -07:00
Rick Macklem
6fa30de4d3 nfsuserd.8: Change machines to machine's
Change machines to machine's.

Suggested by:	grahamperrin
Differential Revision:	https://reviews.freebsd.org/D39877
2023-06-04 12:52:04 -07:00
Colin Percival
59588a546f Revert "tslog: Annotate some early boot functions"
The change to subr_boot.c broke the libsa build because the TSLOG
macros have their own definitions for the boot loader -- I didn't
realize that the loader code used subr_boot.c.

I'm currently testing a fix and I'll revert this revert once I'm
satisfied that everything works, but I don't want to leave the
tree broken for too long.

This reverts commit 469cfa3c30.
2023-06-04 11:39:45 -07:00
Colin Percival
45cc8519f5 tslog: Annotate parts of SYSINIT cpu
Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM,
SYSINIT cpu takes roughly 2770 us:
* 2280 us in vm_ksubmap_init
  * 535 us in kmem_malloc
    * 450 us in pmap_zero_page
  * 1720 us in pmap_growkernel
    * 1620 us in pmap_zero_page
* 80 us in bufinit
* 480 us in cpu_setregs
  * 430 us in cpu_setregs calling load_cr0

Much of this is hypervisor overhead: load_cr0 is slow because it traps
to the hypervisor, and 99% of the time in pmap_zero_page is spent when
we first touch the page, presumably due to the host Linux kernel
faulting in backing pages one by one.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D40327
2023-06-04 10:16:35 -07:00
Colin Percival
2404380aac tslog: Optionally instrument pmap_zero_page
Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM,
pmap_zero_page is responsible for 4.6 ms of the 25.0 ms of boot time.
This is not in fact time spent zeroing pages though; almost all of
that time is spent in a first-touch penalty, presumably due to the
host Linux kernel faulting in backing pages one by one.

There's probably a way to improve that by teaching Firecracker to
fault in all the VM's pages from the start rather than having them
faulted in one at a time, but that's outside of FreeBSD's control.

This commit adds a TSLOG_PAGEZERO option which enables TSLOG on the
amd64 pmap_zero_page function; it's a separate option (turned off
by default even if TSLOG is enabled) since zeroing pages happens
enough that it can easily fill the TSLOG buffer and prevent other
timing information from being recorded.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D40326
2023-06-04 10:16:31 -07:00
Colin Percival
469cfa3c30 tslog: Annotate some early boot functions
Booting an amd64 kernel on Firecracker with 1 CPU and 128 MB of RAM,
hammer_time takes roughly 2740 us:
* 55 us in xen_pvh_parse_preload_data
  * 20 us in boot_parse_cmdline_delim
  * 20 us in boot_env_to_howto
* 15 us in identify_hypervisor
* 1320 us in link_elf_reloc
  * 1310 us in relocate_file1 handling ef->rela
* 25 us in init_param1
* 30 us in dpcpu_init
* 355 us in initializecpu
  * 255 us in initializecpu calling load_cr4
* 425 us in getmemsize
  * 280 us in pmap_bootstrap
    * 205 us in create_pagetables
* 10 us in init_param2
* 25 us in pci_early_quirks
* 60 us in cninit
* 90 us in kdb_init
* 105 us in msgbufinit
* 20 us in fpuinit
* 205 us elsewhere in hammer_time

Some of these are unavoidable (e.g. identify_hypervisor uses CPUID and
load_cr4 loads the CR4 register, both of which trap to the hypervisor)
but others may deserve attention.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D40325
2023-06-04 10:16:22 -07:00
Colin Percival
02d9045866 tslog: Handle curthread equal to NULL
Early in the kernel boot, curthread goes through three stages:

1. Kernel crash when you try to access it, because PCPU doesn't exist.
2. NULL, because PCU exists but isn't initialized.
3. &thread0, which is where most of the kernel boot process runs.

This broke TSLOG from inside hammer_time since the scripts which parse
logged records didn't understand that NULL meant &thread0.

Tell tslog to record &thread0 as the active thread if passed NULL.

Sponsored by:	https://www.patreon.com/cperciva
Differential Revision:	https://reviews.freebsd.org/D40324
2023-06-04 10:16:22 -07:00
Mark Johnston
9d5a47e13c ossl: Provide a fallback definition of __uint128_t when needed
This is required on i386.  The patch has no functional change, since
AES-GCM isn't implemented for that platform.

Fixes:	9a3444d91c ("ossl: Add a VAES-based AES-GCM implementation for amd64")
Reported by:	Jenkins
2023-06-04 12:39:44 -04:00
Dmitry Chagin
c8dbef44ff xregs_sig: Add avx registers to test
Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D40384
2023-06-04 12:07:02 +03:00
Dmitry Chagin
0be13a45f7 xregs_sig: Add a ability to handle multiple register banks
While here replace the .global directive by traditionally used .globl.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D40410
2023-06-04 12:06:25 +03:00
Jamie Gritton
086e0149ae jail: Use re-entrant versions of lex & yacc, and lex's yylineno 2023-06-03 20:07:09 -07:00
Jamie Gritton
097db30a8e jail: Allow nested jail definitions.
Make the jail.conf specification recursive, with jail definitions
allowed within a jail's parameter list, just as they are allowed
at the top level.  Such inner jails are part of the outer jail's
hierarchy, as if they were specified with hierarchical names.
2023-06-03 17:45:54 -07:00
Daniel Kolesa
fa6fa98ac7 sh(1): initialize smark to zero in main()
As popstackmark may be called on this without pushstackmark having
been called, we need to initialize it so that we don't get a bogus
comparison inside popstackmark, which would have resulted in a
NULL pointer dereference.

MFC After:	3 days
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D40413
2023-06-03 23:09:31 +02:00
Christos Margiolis
47a5d58e3b kinst: fix kinst_probe_md field indentation
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40411
2023-06-03 23:03:14 +03:00
Christos Margiolis
d434607b3d kinst: use bool where appropriate
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40412
2023-06-03 23:02:53 +03:00
Dmitry Chagin
e5b3cd6100 xregs_sig: Simplify Makefile by using MACHINE_CPUARCH in SRCS
Reviewed by:		kib, jhb
Differential Revision:	https://reviews.freebsd.org/D40383
2023-06-03 20:13:23 +03:00
Dmitry Chagin
1b0d96f3c4 xregs_sig: Finish renaming simd to xregs before adding avx
Reviewed by:		kib, jhb
Differential Revision:	https://reviews.freebsd.org/D40382
2023-06-03 20:11:44 +03:00
Dmitry Chagin
8fdc9ce97c avx_sig: Better naming as the test will include more register banks
Reviewed by:		jhb, kib (early revision)
Differential Revision:	https://reviews.freebsd.org/D40381
2023-06-03 20:10:49 +03:00
Christos Margiolis
9b091f1200 kinst: simplify trampoline fill definitions
Centralize KINST_TRAMP_FILL_PATTERN and KINST_TRAMP_FILL_SIZE to reduce
redefinitions, and use the architecture-dependent kinst_patchval_t as
their size.

Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40406
2023-06-03 20:04:57 +03:00
Christos Margiolis
980746e5cb fbt: simplify arm64 function-prologue parsing
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40364
2023-06-03 20:04:33 +03:00
Christos Margiolis
bab7781e78 dtrace: deduplicate arm64 breakpoint definition
Reviewed by:	markj
Approved by:	markj (mentor)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D40363
2023-06-03 20:04:10 +03:00
Doug Rabson
4a6b92849e pf: Fix tests broken by enabling inet-local filtering
Summary:
Three of the pf dummynet tests were using filter rules which matched
both the intended epair interface as well as lo0 which now receives
PFIL_OUT events for messages delivered to the local network stack (if
enabled). This commit changes the rules to match only for the expected
epair interface.

PR:             268717
Reviewed-by:	kp
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40393
2023-06-03 11:07:56 +01:00
Konstantin Belousov
8dad5ece49 dd(1): neutralize SIGINT while non-async-signal safe code is executing
making the SIGINT handler (the terminate() function) safe to execute at
any interruption moment.  This fixes a race in
5807f35c54 where SIGINT delivered right
after the check_terminate() but before a blocking syscall would not
cause abort.

Do it by setting the in_io flag around potentially blocking io syscalls.
If handler sees the flag, it terminates the program.  Otherwise,
termination is delegated to the before_io/after_io fences.

Reviewed by:	Andrew Gierth <andrew@tao146.riddles.org.uk>
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D40281
2023-06-03 01:06:27 +03:00
Shailend Chand
54dfc97b0b Add gve, the driver for Google Virtual NIC (gVNIC)
gVNIC is a virtual network interface designed specifically for
Google Compute Engine (GCE). It is required to support per-VM Tier_1
networking performance, and for using certain VM shapes on GCE.

The NIC supports TSO, Rx and Tx checksum offloads, and RSS.
It does not currently do hardware LRO, and thus the software-LRO
in the host is used instead. It also supports jumbo frames.

For each queue, the driver negotiates a set of pages with the NIC to
serve as a fixed bounce buffer, this precludes the use of iflib.

Reviewed-by: 		markj
MFC-after:		2 weeks
Differential Revision: https://reviews.freebsd.org/D39873
2023-06-02 14:31:54 -07:00
Mina Galić
0981275c75 rc(8): document how to reload rc's configuration
The fact that rc(8) only reads its configuration once is in the man
page, but how to trigger a reload is only in the code.

Discovered while trying to make cloud-init disable and stop syslogd.

Thanks to RhodiumToad for providing the words.

Reviewed by:           debdrup, grahamperrin
Approved by:           grahamperrin, imp
MFC after:             1 week
Sponsored by:          The FreeBSD Foundation
Differential revision: https://reviews.freebsd.org/D40329
2023-06-02 19:27:37 +01:00
Mark Johnston
556b434922 ossl: Compile newly added files into the kernel if so requested
Fixes:	9a3444d91c ("ossl: Add a VAES-based AES-GCM implementation for amd64")
Fixes:	9b1d87286c ("ossl: Add a fallback AES-GCM implementation using AES-NI")
2023-06-02 13:43:15 -04:00
Mark Johnston
056305d3aa ipsec: Make algorithm tables read-only
No functional change intended.

MFC after:	1 week
2023-06-02 13:43:15 -04:00
Mark Johnston
7266f52498 x86: Mark the CPU idle function table as const
No functional change intended.

MFC after:	1 week
2023-06-02 13:43:15 -04:00
Mark Johnston
67f938c5ff kevent: Make references to filter definitions const
Follow-up revisions can make individual filter definitions const.  No
functional change intended.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35842
2023-06-02 13:43:15 -04:00
John Baldwin
ee06552d62 <sys/memrange.h>: Include <sys/ioccom.h>.
This makes this header more self-contained.

Reviewed by:	imp, markj
Obtained from:	CheriBSD
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D40387
2023-06-02 10:40:46 -07:00