]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
3 years agoAdd FFSV_FORCEINODEDEP flag for ffs_vgetf()
Konstantin Belousov [Wed, 3 Mar 2021 17:40:56 +0000 (19:40 +0200)]
Add FFSV_FORCEINODEDEP flag for ffs_vgetf()

(cherry picked from commit fd97fa64638d810b415af7afcc86634c9709ad12)

3 years agosimplify journal_mount: move the out label after success block
Konstantin Belousov [Thu, 4 Mar 2021 18:55:33 +0000 (20:55 +0200)]
simplify journal_mount: move the out label after success block

(cherry picked from commit 25aac48d2ce322355e7890a1de0f045a15d1cc09)

3 years agomkimg(1): Correct a typo in the usage output
Gordon Bergling [Mon, 9 Aug 2021 11:53:30 +0000 (13:53 +0200)]
mkimg(1): Correct a typo in the usage output

- s/partion/partition/

(cherry picked from commit 6bddade6114abacacb30ef2c28781f1af331c106)

3 years agoncurses: Apply a tputs() fix from patch 20210403
Mark Johnston [Wed, 11 Aug 2021 16:54:29 +0000 (12:54 -0400)]
ncurses: Apply a tputs() fix from patch 20210403

From the (substantially larger) upstream commit:
+ call delay_output_sp to handle BSD-style padding when tputs_sp is
  called, whether directly or internally, to ensure that the SCREEN
  pointer is passed correctly (reports by Henric Jungheim, Juraj
  Lutter).

This fixes bison segfaults observed when colourized output is enabled.
Thanks to jrtc27@ for identifying the upstream fix.

PR: 256731
MFC after: 3 days

(cherry picked from commit b2da1032397e3339fbeebcd57b1f179e1d8a2e19)

3 years agoClean up orphaned indirdep dependency structures after disk failure.
Kirk McKusick [Thu, 29 Jul 2021 23:11:58 +0000 (16:11 -0700)]
Clean up orphaned indirdep dependency structures after disk failure.

(cherry picked from commit 412b5e40a721430adba1b4abae210641f733f976)
(cherry picked from commit a91716efeb684c50289c0e1136f5432f880dc873)

3 years agoipsec_set_policy(3): fix sentence
Konstantin Belousov [Mon, 9 Aug 2021 10:37:41 +0000 (13:37 +0300)]
ipsec_set_policy(3): fix sentence

(cherry picked from commit ba3896e16913fd6f9f227d84038171f1fdf5496b)

3 years agoip(4): Mention IP_IPSEC_POLICY ip-level socket option
Konstantin Belousov [Mon, 9 Aug 2021 11:07:18 +0000 (14:07 +0300)]
ip(4): Mention IP_IPSEC_POLICY ip-level socket option

(cherry picked from commit 4a5a67fe679d6b29957bf87dbf2e7c08ff97bb30)

3 years agonetipsec/key.c: Use ANSI C definition for key_random()
Konstantin Belousov [Tue, 3 Aug 2021 01:24:31 +0000 (04:24 +0300)]
netipsec/key.c: Use ANSI C definition for key_random()

(cherry picked from commit 8b000bf5bcddea30e66e0b4e1158e2d7b328b262)

3 years agonetipsec/keydb.h: fix typo
Konstantin Belousov [Sat, 31 Jul 2021 01:41:13 +0000 (04:41 +0300)]
netipsec/keydb.h: fix typo

(cherry picked from commit fd4751b3892973f3d329f6fb516da6b01be6f71f)

3 years agoFix panic in IPv6 multicast code.
Andrey V. Elsukov [Thu, 5 Aug 2021 08:51:46 +0000 (11:51 +0300)]
Fix panic in IPv6 multicast code.

Add check that ifp supports IPv6 multicasts in in6_getmulti.
This fixes panic when user application tries to join into multicast
group on an interface that doesn't support IPv6 multicasts, like
IFT_PFLOG interfaces.

PR:             257302
Reviewed by: melifaro
Differential Revision: https://reviews.freebsd.org/D31420

(cherry picked from commit d477a7feed177d0ad5c12bc6e2cce804d427ed38)

3 years agocoretemp(4): Switch to smp_rendezvous_cpus().
Alexander Motin [Fri, 30 Jul 2021 03:16:22 +0000 (23:16 -0400)]
coretemp(4): Switch to smp_rendezvous_cpus().

Use of smp_rendezvous_cpus() instead of sched_bind() allows to not
block indefinitely if target CPU is running some thread with higher
priority, while all we need is single rdmsr/wrmsr instruction call.
I guess it should also be much cheaper than full thread migration.

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

(cherry picked from commit 74f80bc1af2ffd56ec290f610c80e46f768731a0)

3 years agoipmi(4): Add more watchdog error checks.
Alexander Motin [Fri, 30 Jul 2021 03:39:04 +0000 (23:39 -0400)]
ipmi(4): Add more watchdog error checks.

Add request submission status checks before checking req->ir_compcode,
otherwise it may be zero just because of initialization.

Add checks for req->ir_compcode errors in ipmi_reset_watchdog() and
ipmi_set_watchdog().  In first case explicitly check for 0x80, which
means timer was not previously set, that I found happening after BMC
cold reset.  This change makes watchdog timer to recover instead of
permanently ignoring reset errors after BMC reset or upgraded.

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

(cherry picked from commit 9d3b47abbba74830661e90206cc0f692b159c432)

3 years agobhyve vtblk: Inform guests of disk resize events.
John Baldwin [Sat, 12 Jun 2021 00:59:46 +0000 (17:59 -0700)]
bhyve vtblk: Inform guests of disk resize events.

Register a resize callback with the blockif interface.  When the
callback fires, update the size of the disk and notify the guest via a
configuration change interrupt.

Reviewed by: grehan, markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30506

(cherry picked from commit 2349cda44fea17c089b026e743ec8f03199019eb)

3 years agobhyve: Split out a lower-level helper for VirtIO interrupts.
John Baldwin [Sat, 12 Jun 2021 00:59:35 +0000 (17:59 -0700)]
bhyve: Split out a lower-level helper for VirtIO interrupts.

This allows device models to assert VirtIO interrupts for reasons
other than publishing changes to a VirtIO ring such as configuration
changes.

Reviewed by: grehan, markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30505

(cherry picked from commit c06676bee3d228ac18c5ed3604304e932eb84c1e)

3 years agobhyve: Add support for handling disk resize events to block_if.
John Baldwin [Sat, 12 Jun 2021 00:59:25 +0000 (17:59 -0700)]
bhyve: Add support for handling disk resize events to block_if.

Allow clients of blockif to register a resize callback handler.  When
a callback is registered, register an EVFILT_VNODE kevent watching the
backing store for a change in the file's attributes.  If the size has
changed when the kevent fires, invoke the clients' callback.

Currently resize detection is limited to backing stores that support
EVFILT_VNODE kevents such as regular files.

Reviewed by: grehan, markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30504

(cherry picked from commit 8794846a91c5429c612ba939c61ebf8f1ff1a628)

3 years agobhyve: Add support for EVFILT_VNODE mevents.
John Baldwin [Sat, 12 Jun 2021 00:59:13 +0000 (17:59 -0700)]
bhyve: Add support for EVFILT_VNODE mevents.

This allows registering an event to watch for changes to a file's
attributes.  This is a bit imperfect as it would be nice to have a way
to determine if an fd can use EVFILT_VNODE successfully.  mevent's
current structure does not permit that and a failure to register a
single kevent impacts several other kevents.

Reviewed by: grehan, markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30503

(cherry picked from commit 67d60dcce62c08250dceedaf761cb48bc74c75a4)

3 years agobhyve: Register new kevents synchronously.
John Baldwin [Sat, 12 Jun 2021 00:58:54 +0000 (17:58 -0700)]
bhyve: Register new kevents synchronously.

Change mevent_add*() to synchronously add the new kevent.  This
permits reporting event registration failures to the caller and avoids
failing the registration of other, unrelated events queued up in the
same batch.

Reviewed by: grehan, markj
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D30502

(cherry picked from commit e8424e2947dd8a0e1d3f08295432941b5c5aafb9)

3 years agolink_elf_obj: Invoke fini callbacks
Mark Johnston [Thu, 29 Jul 2021 13:46:25 +0000 (09:46 -0400)]
link_elf_obj: Invoke fini callbacks

This is required for KASAN: when a module is unloaded, poisoned regions
(e.g., pad areas between global variables) are left as such, so if they
are reused as KLDs are loaded, false positives can arise.

Reported by: pho, Jenkins
Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 9e575fadf491152fb3445d4837d49a9cb87dd6e2)

3 years agoamd64: Set MSR_KGSBASE to 0 during AP startup
Mark Johnston [Thu, 29 Jul 2021 14:14:05 +0000 (10:14 -0400)]
amd64: Set MSR_KGSBASE to 0 during AP startup

There is no reason to initialize it to anything else, and this matches
initialization of the BSP.  No functional change intended.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit e1537450838134daaf584d1f17e661673b2c4c76)

3 years agoamd64: Set GS.base before calling init_secondary() on APs
Mark Johnston [Thu, 29 Jul 2021 14:22:37 +0000 (10:22 -0400)]
amd64: Set GS.base before calling init_secondary() on APs

KMSAN instrumentation requires thread-local storage to track
initialization state for function parameters and return values.  This
buffer is accessed as part of each function prologue.  It is provided by
the KMSAN runtime, which looks up a pointer in the current thread's
structure.

When KMSAN is configured, init_secondary() is instrumented, but this
means that GS.base must be initialized first, otherwise the runtime
cannot safely access curthread.  Work around this by loading GS.base
before calling init_secondary(), so that the runtime can at least check
curthread == NULL and return a pointer to some dummy storage.  Note that
init_secondary() still must reload GS.base after calling lgdt(), which
loads a selector into %gs, which in turn clears the base register.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 4b136ef259cefedc9b6404afc09138aeb8acbd91)

3 years agoAdd vn_lktype_write()
Konstantin Belousov [Wed, 4 Aug 2021 02:34:48 +0000 (05:34 +0300)]
Add vn_lktype_write()

(cherry picked from commit 0ef5eee9d94162ac3cefa0bd8aedf1bfa6f87192)

3 years ago_Exit(3): document implementation
Konstantin Belousov [Thu, 5 Aug 2021 16:04:44 +0000 (19:04 +0300)]
_Exit(3): document implementation

(cherry picked from commit ee62fb2e1e14eab35d4e4e92535bcac9fc91eeb8)

3 years agofork(2): comment about doubtful use of stdio and exit(3) in example
Konstantin Belousov [Thu, 5 Aug 2021 16:03:03 +0000 (19:03 +0300)]
fork(2): comment about doubtful use of stdio and exit(3) in example

(cherry picked from commit 2a51e8823a60180feb534176bc41d5d10e2a01b1)

3 years agofork.2: correct minor typo in manpage.
Ceri Davies [Thu, 5 Aug 2021 18:36:33 +0000 (19:36 +0100)]
fork.2: correct minor typo in manpage.

(cherry picked from commit 383dbdb2ebffabf8c0efadd8928f8ef3e45ab9e5)

3 years agoAdd _Fork()
Konstantin Belousov [Mon, 2 Aug 2021 09:50:32 +0000 (12:50 +0300)]
Add _Fork()

(cherry picked from commit 49ad342cc10cba14b3a40ba26cf8bb2150e2925a)

3 years agoStyle
Konstantin Belousov [Mon, 2 Aug 2021 21:05:11 +0000 (00:05 +0300)]
Style

(cherry picked from commit 2d319ebe5c08f3454c4e76564b88fb921f008185)

3 years agofork.2: Fix a typo in an example
Mateusz Piotrowski [Tue, 20 Apr 2021 08:24:21 +0000 (10:24 +0200)]
fork.2: Fix a typo in an example

(cherry picked from commit ca904beafd925719af998a86cd67a9c787f44255)

3 years agofork.2: Add a simple use pattern
Mateusz Piotrowski [Sat, 17 Apr 2021 21:10:48 +0000 (23:10 +0200)]
fork.2: Add a simple use pattern

(cherry picked from commit c4207d867c201a726aa3157e09262f72166c89c4)

3 years agonanobsd: Correct a typo in a comment
Gordon Bergling [Mon, 9 Aug 2021 11:45:10 +0000 (13:45 +0200)]
nanobsd: Correct a typo in a comment

- s/partion/partition/

(cherry picked from commit 8b9f6d62f75a367459997e5bb27d86d0302aedd2)

3 years agobhyve: change vq_getchain to return iovecs in both directions
Ka Ho Ng [Tue, 30 Mar 2021 08:43:24 +0000 (16:43 +0800)]
bhyve: change vq_getchain to return iovecs in both directions

The old prototype requires callers to inspect flags of each descriptors
to get the starting position of host-writable iovecs.

vq_getchain() is changed to return a virtio request with the number of
host-readable iovecs and host-writable iovecs instead. Callers can avoid
boilerplate code of getting the start offset of host-writable iovecs.

Sponsored by: The FreeBSD Foundation
Reviewed by: afedorov
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D29433

(cherry picked from commit b013912772ec9e135b52aaec5f70bc92a191ebdb)

3 years agobhyve: virtio shares definitions between sys/dev/virtio
Ka Ho Ng [Thu, 12 Aug 2021 06:44:52 +0000 (14:44 +0800)]
bhyve: virtio shares definitions between sys/dev/virtio

Definitions inside usr.sbin/bhyve/virtio.h are thrown away.
Definitions in sys/dev/virtio are used instead.

This reduces code duplication.

Sponsored by: The FreeBSD Foundation
Reviewed by: grehan
Approved by: philip (mentor)
Differential Revision: https://reviews.freebsd.org/D29084

(cherry picked from commit 54ac6f721efccdba5a09aa9f38be0a1c4ef6cf14)

3 years agobhyve: Fix cli regression with NVMe ram
Chuck Tuffli [Tue, 15 Jun 2021 13:59:02 +0000 (06:59 -0700)]
bhyve: Fix cli regression with NVMe ram

The configuration management refactoring inadvertently removed support
for a RAM-backed NVMe Namespace (i.e. -s X,nvme,ram=16384). This adds it
back.

Reported by: andy@omniosce.org
Reviewed by: jhb, andy@omniosce.org
Fixes: 621b5090487d
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30717

(cherry picked from commit 3a4ab18377c86c4588d79c4ca91fe8f4530dc90c)

3 years agobhyve: Gracefully handle virtio-scsi with no conf
Ryan Moeller [Thu, 22 Apr 2021 16:06:08 +0000 (12:06 -0400)]
bhyve: Gracefully handle virtio-scsi with no conf

Fixes segfault with the command `bhyve -s 0,virtio-scsi`, which is used
by some third party software to probe bhyve for virtio-scsi support.

Reviewed by: jhb
MFC after: 1 day
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D29926

(cherry picked from commit 89c3c32647a5099b297af2958e5a939eff0c0ce0)

3 years agobhyve: Be explicit that setting config.dump will not start a VM.
John Baldwin [Tue, 20 Apr 2021 20:33:28 +0000 (13:33 -0700)]
bhyve: Be explicit that setting config.dump will not start a VM.

Suggested by: rpokala
Reviewed by: bcr (manpages)
Differential Revision: https://reviews.freebsd.org/D29738

(cherry picked from commit e15bf05e0abcf4435a09edb8ff8d7e38d1508bb2)

3 years agobhyve: Move the gdb_active check to gdb_cpu_suspend().
John Baldwin [Mon, 12 Apr 2021 18:43:34 +0000 (11:43 -0700)]
bhyve: Move the gdb_active check to gdb_cpu_suspend().

The check needs to be in the public routine (gdb_cpu_suspend()), not
in the internal routine called from various places
(_gdb_cpu_suspend()).  All the other callers of _gdb_cpu_suspend()
already check gdb_active, and this breaks the use of snapshots when
the debug server is not enabled since gdb_cpu_suspend() tries to lock
an uninitialized mutex.

Reported by: Darius Mihai, Elena Mihailescu
Reviewed by: elenamihailescu22_gmail.com
Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb
Differential Revision: https://reviews.freebsd.org/D29538

(cherry picked from commit eacc27affeff17beb3791793ba54458444df7135)

3 years agobhyve: fix regression in legacy virtio-9p config parsing
Roman Bogorodskiy [Thu, 8 Apr 2021 14:44:58 +0000 (18:44 +0400)]
bhyve: fix regression in legacy virtio-9p config parsing

Commit 621b5090487de9fed1b503769702a9a2a27cc7bb introduced a regression
in legacy virtio-9p config parsing by not initializing *sharename to
NULL. As a result, "sharename != NULL" check in the first iteration fails
and bhyve exits with "virtio-9p: more than one share name given".

Fix by adding NULL back.

Approved by: grehan

(cherry picked from commit f2ecc0d1b7d569b4b2c930c7450390c04778ee8a)

3 years agoFix typo in xhci nvlist node name, and also increment device counter.
Peter Grehan [Sat, 3 Apr 2021 04:32:54 +0000 (14:32 +1000)]
Fix typo in xhci nvlist node name, and also increment device counter.

This allows the xhci tablet device to be recognized and a PCI device
instantiated.

Reviewed by: jhb
Fixes: 621b5090487d Refactor configuration management in bhyve.
MFC after: 3 months.

(cherry picked from commit ab899f8937c1c7c79197baf7192b727ddc9cfe54)

3 years agobhyve: Enable virtio-scsi legacy config parsing.
John Baldwin [Mon, 29 Mar 2021 17:25:45 +0000 (10:25 -0700)]
bhyve: Enable virtio-scsi legacy config parsing.

The previous commit added the handler to parse the command line
options for virtio-scsi devices but forgot to set the correct function
pointer to point to the handler.

Reported by: vangyzen
Reviewed by: vangyzen
Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb
Differential Revision: https://reviews.freebsd.org/D29438

(cherry picked from commit 4d5460a720c59a4404eb1df1b768d2f16b2f341a)

3 years agobhyve hostbridge: Rename "device" property to "devid".
John Baldwin [Wed, 24 Mar 2021 16:29:15 +0000 (09:29 -0700)]
bhyve hostbridge: Rename "device" property to "devid".

"device" is already used as the generic PCI-level name of the device
model to use (e.g. "hostbridge").  The result was that parsing
"hostbridge" as an integer failed and the host bridge used a device ID
of 0.  The EFI ROM asserts that the device ID of the hostbridge is not
0, so booting with the current EFI ROM was failing during the ROM
boot.

Fixes: 621b5090487de9fed1b503769702a9a2a27cc7bb

(cherry picked from commit 9f40a3be3d5dbddf782c3d1eeaadcd022a4dad01)

3 years agoRefactor configuration management in bhyve.
John Baldwin [Wed, 26 Jun 2019 20:30:41 +0000 (13:30 -0700)]
Refactor configuration management in bhyve.

Replace the existing ad-hoc configuration via various global variables
with a small database of key-value pairs.  The database supports
heirarchical keys using a MIB-like syntax to name the path to a given
key.  Values are always stored as strings.  The API used to manage
configuation values does include wrappers to handling boolean values.
Other values use non-string types require parsing by consumers.

The configuration values are stored in a tree using nvlists.  Leaf
nodes hold string values.  Configuration values are permitted to
reference other configuration values using '%(name)'.  This permits
constructing template configurations.

All existing command line arguments now set configuration values.  For
devices, the "-s" option parses its option argument to generate a list
of key-value pairs for the given device.

A new '-o' command line option permits setting an individual
configuration variable.  The key name is always given as a full path
of dot-separated components.

A new '-k' command line option parses a simple configuration file.
This configuration file holds a flat list of 'key=value' lines where
the 'key' is the full path of a configuration variable.  Lines
starting with a '#' are comments.

In general, bhyve starts by parsing command line options in sequence
and applying those settings to configuration values.  Once this is
complete, bhyve then begins initializing its state based on the
configuration values.  This means that subsequent configuration
options or files may override or supplement previously given settings.

A special 'config.dump' configuration value can be set to true to help
debug configuration issues.  When this value is set, bhyve will print
out the configuration variables as a flat list of 'key=value' lines.

Most command line argments map to a single configuration variable,
e.g.  '-w' sets the 'x86.strictmsr' value to false.  A few command
line arguments have less obvious effects:

- Multiple '-p' options append their values (as a comma-seperated
  list) to "vcpu.N.cpuset" values (where N is a decimal vcpu number).

- For '-s' options, a pci.<bus>.<slot>.<function> node is created.
  The first argument to '-s' (the device type) is used as the value of
  a "device" variable.  Additional comma-separated arguments are then
  parsed into 'key=value' pairs and used to set additional variables
  under the device node.  A PCI device emulation driver can provide
  its own hook to override the parsing of the additonal '-s' arguments
  after the device type.

  After the configuration phase as completed, the init_pci hook
  then walks the "pci.<bus>.<slot>.<func>" nodes.  It uses the
  "device" value to find the device model to use.  The device
  model's init routine is passed a reference to its nvlist node
  in the configuration tree which it can query for specific
  variables.

  The result is that a lot of the string parsing is removed from
  the device models and centralized.  In addition, adding a new
  variable just requires teaching the model to look for the new
  variable.

- For '-l' options, a similar model is used where the string is
  parsed into values that are later read during initialization.
  One key note here is that the serial ports use the commonly
  used lowercase names from existing documentation and examples
  (e.g. "lpc.com1") instead of the uppercase names previously
  used internally in bhyve.

Reviewed by: grehan
MFC after: 3 months
Differential Revision: https://reviews.freebsd.org/D26035

(cherry picked from commit 621b5090487de9fed1b503769702a9a2a27cc7bb)

3 years agom_dup: Handle unmapped mbufs as an input mbuf.
John Baldwin [Mon, 26 Jul 2021 21:03:28 +0000 (14:03 -0700)]
m_dup: Handle unmapped mbufs as an input mbuf.

Use m_copydata() instead of a direct bcopy() when copying data out of
a source mbuf into a newly-allocated mbuf.

PR:       256610
Reported by:  Niels Bakker <niels=freebsd@bakker.net>
Reviewed by:  markj
MFC after:    2 weeks

(cherry picked from commit be79f30d6c3e353856d4f82227b270abc26be702)

3 years agoPrefer MK_SSP=no to SSP_CFLAGS=
Mitchell Horne [Wed, 4 Aug 2021 18:20:50 +0000 (15:20 -0300)]
Prefer MK_SSP=no to SSP_CFLAGS=

It is more idiomatic. CFLAGS is only augmented with $SSP_CFLAGS when
$MK_SSP != "no".

Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31401

(cherry picked from commit 61ed578ee66648eff206ee5622b66727bfb52e78)

3 years agomk: format some option lists
Mitchell Horne [Wed, 4 Aug 2021 18:17:34 +0000 (15:17 -0300)]
mk: format some option lists

Alphabetize and give each option its own line, ahead of making another
change to these lists. This makes future diffs easier to read.

Reviewed by: imp, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31399

(cherry picked from commit bcd2f41f7d222a942fe0a268614b46d3ec3af4c0)

3 years agohwpmc: disable uncore class on Sandy Bridge and newer
Mitchell Horne [Wed, 4 Aug 2021 17:31:36 +0000 (14:31 -0300)]
hwpmc: disable uncore class on Sandy Bridge and newer

It was written for Nehalem and Westmere, with minor but incomplete
updates for Sandy Bridge in 78d763a29b15. The uncore architecture
changed significantly with this generation, bringing new layouts and
locations for some MSRs.

Misprogramming these MSRs in ucp_start_pmc() may panic the system, and
this is trivially reproducible via pmcstat(8) on at least Broadwell and
Haswell. Disable the class on these CPUs until it can be updated more
completely and leave a TODO comment detailing some of the work required.
Note that the nclasses value for Broadwell was already incorrect and
doesn't need changing.

The result is that any uncore events listed by pmcstat -L will no longer
be allocatable, but this is already the case for newer generations of
Intel CPUs.

PR: 253687
Reported by: Zhenlei Huang <zlei.huang@gmail.com>
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31389

(cherry picked from commit 4f35e8cba232d9256ab1399b8adfb761988e5eff)

3 years agopf: batch critical section for several counters
Mateusz Guzik [Sat, 24 Jul 2021 07:47:40 +0000 (09:47 +0200)]
pf: batch critical section for several counters

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 87c010e6e364e96e2c1546b3c2bbcbef1dcd422f)

3 years agopf: switch rule counters to pf_counter_u64
Mateusz Guzik [Thu, 22 Jul 2021 14:45:14 +0000 (16:45 +0200)]
pf: switch rule counters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 02cf67ccf6538b14677672640e405f7f94044dc3)

3 years agopf: switch kif counters to pf_counter_u64
Mateusz Guzik [Fri, 23 Jul 2021 10:29:46 +0000 (12:29 +0200)]
pf: switch kif counters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d40d4b3ed788b05697541b9ae94b1960ff2cf6f6)

3 years agopf: switch pf_status.fcounters to pf_counter_u64
Mateusz Guzik [Sat, 24 Jul 2021 05:33:52 +0000 (07:33 +0200)]
pf: switch pf_status.fcounters to pf_counter_u64

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit fc4c42ce0b5ce87901b327e25f55b4e3ab4c6cf5)

3 years agopf: add hybrid 32- an 64- bit counters
Mateusz Guzik [Thu, 22 Jul 2021 20:47:24 +0000 (22:47 +0200)]
pf: add hybrid 32- an 64- bit counters

Numerous counters got migrated from straight uint64_t to the counter(9)
API. Unfortunately the implementation comes with a significiant
performance hit on some platforms and cannot be easily fixed.

Work around the problem by implementing a pf-specific variant.

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit defdcdd5648dc1ea789bc54bb45108fcab546a6b)

3 years agopf: drop redundant 'else' in pf_normalize_*
Mateusz Guzik [Sat, 24 Jul 2021 05:17:27 +0000 (07:17 +0200)]
pf: drop redundant 'else' in pf_normalize_*

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 6f1fb6561236fa933835a9a67bd442053fb509e9)

3 years agopf: consistently malloc rules with M_ZERO
Mateusz Guzik [Fri, 23 Jul 2021 15:01:29 +0000 (17:01 +0200)]
pf: consistently malloc rules with M_ZERO

Reviewed by: kp
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 49a7d47235434a300cc57b205e493988fdebf79c)

3 years agopf: hide struct pf_kstatus behind ifdef _KERNEL
Mateusz Guzik [Fri, 23 Jul 2021 17:34:43 +0000 (17:34 +0000)]
pf: hide struct pf_kstatus behind ifdef _KERNEL

Reviewed by:    kp
Sponsored by:   Rubicon Communications, LLC ("Netgate")

(cherry picked from commit d9cc6ea270ea52e860e3cc730876ee4324081586)

3 years agoudp: Fix soroverflow SOCKBUF unlocking
Konstantin Kukushkin [Sun, 1 Aug 2021 14:41:38 +0000 (07:41 -0700)]
udp: Fix soroverflow SOCKBUF unlocking

We hold the SOCKBUF_LOCK so use soroverflow_locked here.
This bug may manifest as a non-killable process stuck in [*so_rcv].

Approved by: scottl
Reviewed by: Roy Marples <roy@marples.name>
Fixes: 7045b1603bdf
MFC after:  10 days
Differential Revision: https://reviews.freebsd.org/D31374

(cherry picked from commit a61c24ddb7d677337d6184ffcee34a6e902d72d7)

3 years agosocket: Implement SO_RERROR
Roy Marples [Wed, 28 Jul 2021 15:46:59 +0000 (08:46 -0700)]
socket: Implement SO_RERROR

SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by: philip (network), kbowling (transport), gbe (manpages)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D26652

(cherry picked from commit 7045b1603bdf054145dd958a4acc17b410fb62a0)

3 years agopf: Validate user string nul-termination before copying
Mark Johnston [Wed, 28 Jul 2021 14:16:42 +0000 (10:16 -0400)]
pf: Validate user string nul-termination before copying

Some pf ioctl handlers use strlcpy() to copy strings when converting
from user structures to their in-kernel representations.  strlcpy()
ensures that the destination will be nul-terminated, but it assumes that
the source is nul-terminated.  In particular, it returns the full length
of the source string, so if the source is not nul-terminated, strlcpy()
will keep scanning until it finds a nul byte, and it may encounter an
unmapped page first.  Add a helper to validate user strings before
copying.

There are also places where we look up a ruleset using a user-provided
anchor string.  In some ioctl handlers we were already nul-terminating
the string, avoiding the same problem, but in other places we were not.
Fix those by nul-terminating as well.  Aside from being consistent,
anchors have a maximum length of MAXPATHLEN - 1 so calling strnlen()
might not be so desirable.

Reported by: syzbot+35a1549b4663e9483dd1@syzkaller.appspotmail.com
Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 64432ad2a2c4b10d3d3411a8ca018e2a35cec97e)

3 years agopf: Initialize arrays before copying out to userland
Mark Johnston [Wed, 28 Jul 2021 14:16:25 +0000 (10:16 -0400)]
pf: Initialize arrays before copying out to userland

A number of pf ioctls populate an array of structures and copy it out.
They have the following structures:
- caller specifies the size of its output buffer
- ioctl handler allocates a kernel buffer of the same size
- ioctl handler populates the buffer, possibly leaving some items
  initialized if the caller provided more space than needed
- ioctl handler copies the entire buffer out to userland

Thus, if more space was provided than is required, we end up copying out
uninitialized kernel memory.  Simply zero the buffer at allocation time
to prevent this.

Reported by: KMSAN
Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2b82c57e399700f5134c47d86d45ef2f2bd465e2)

3 years agoDo not expose to scheduler caches of single CPU.
Alexander Motin [Wed, 28 Jul 2021 20:15:43 +0000 (16:15 -0400)]
Do not expose to scheduler caches of single CPU.

Before this change my dual-Xeon(R) Gold 6242R always reported 3 levels
or topology (root, package/L3 and core/L2).  But with SMT disabled
core/L2 matches thread, so additional topology level only causes more
traversal work.  With this change SMT case is reported same as before,
while non-SMT is reported with only 2 much more simple levels.

MFC after: 2 weeks

(cherry picked from commit 5a49f1914178c5275105f2ab0d23a98118cd585f)

3 years agopf: bound DIOCGETSTATES memory use
Kristof Provost [Mon, 2 Aug 2021 07:46:33 +0000 (09:46 +0200)]
pf: bound DIOCGETSTATES memory use

Similar to what we did earlier for DIOCGETSTATESV2 we only allocate
enough memory for a handful of states and copy those out, bit by bit,
rather than allocating memory for all states in one go.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 600745f1e2260e7ed3c2e6183b24388ff38c916c)

3 years agoloader: tftp client should use server address from rootip
Toomas Soome [Mon, 2 Aug 2021 12:27:38 +0000 (15:27 +0300)]
loader: tftp client should use server address from rootip

servip is set from bootp bp_siaddr (if present) and rootip is
set immediately from servip in tha sane bootp code.

However, the common/dev_net.c does only set rootip (based on
url processing etc). Therefore, we should also use rootip in tftp
reader.

Fixes hung tftp based boot when bp_siaddr is not provided.

MFC after: 1 week

(cherry-picked from commit 1b1bb6f178802a4522824e0268634a99cdbda098)

3 years agoloader: cstyle cleanup of libsa/lseek.c
Toomas Soome [Sun, 1 Aug 2021 07:07:32 +0000 (10:07 +0300)]
loader: cstyle cleanup of libsa/lseek.c

Clean up lseek.c, no functional changes intended. This is pre-patch
for open file list rewrite.

MFC after: 1 week

(cherry-picked from commit bbb539b83ceced2d355893ead5987193737833fd)

3 years agopf tests: test locally originated connections with route-to
Kristof Provost [Wed, 14 Jul 2021 10:33:37 +0000 (12:33 +0200)]
pf tests: test locally originated connections with route-to

PR: 257106
Submitted by: Mark Cammidge <mark@peralex.com>
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D31178

(cherry picked from commit f808bb9b7e5ee2243e5a2aaad2275a78cdbe981b)

3 years agopf: locally originating connections with 'route-to' fail
Kristof Provost [Wed, 14 Jul 2021 10:17:03 +0000 (12:17 +0200)]
pf: locally originating connections with 'route-to' fail

Similar to the REPLY_TO shortcut (6d786845cf) we also can't shortcut
ROUTE_TO. If we do we will fail to apply transformations or update the
state, which can lead to premature termination of the connections.

PR: 257106
MFC after: 3 weeks
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31177

(cherry picked from commit 2c0d115bbc8f8ee3f011a5c4a69bcbf58c4b721f)

3 years agoUPDATING: Document the removal of DIOCGETSTATESNV
Kristof Provost [Wed, 14 Jul 2021 13:51:36 +0000 (15:51 +0200)]
UPDATING: Document the removal of DIOCGETSTATESNV

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 3412900333e659124f61ada6389ef40dd0f3ddd4)

3 years agopf: remove DIOCGETSTATESNV
Kristof Provost [Tue, 6 Jul 2021 11:13:24 +0000 (13:13 +0200)]
pf: remove DIOCGETSTATESNV

While nvlists are very useful in maximising flexibility for future
extensions their performance is simply unacceptably bad for the
getstates feature, where we can easily want to export a million states
or more.

The DIOCGETSTATESNV call has been MFCd, but has not hit a release on any
branch, so we can still remove it everywhere.

Reviewed by: mjg
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D31099

(cherry picked from commit b69019c14cd89a5e699bc6e69941aec5b1041b1e)

3 years agoHide arm64 features that don't have a HWCAP
Andrew Turner [Thu, 15 Jul 2021 23:22:07 +0000 (23:22 +0000)]
Hide arm64 features that don't have a HWCAP

We should only export MSR fields if there is also a HWCAP so it doesn't
matter which software uses.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ae47eecf87b5d8a054bd5d640da12608cc5f126a)

3 years agoAdd virtio_scsi to the arm64 GENERIC config
Andrew Turner [Wed, 14 Jul 2021 20:13:10 +0000 (20:13 +0000)]
Add virtio_scsi to the arm64 GENERIC config

This is needed to boot on the Oracle Cloud VM.Standard.A1.Flex instance

Sponsored by: The FreeBSD Foundation

(cherry picked from commit b644d64e8a4641a6e4c53b3f4be51e08cb17f6cc)

3 years agoAdd virtio comments to the arm64 GENERIC config
Andrew Turner [Wed, 14 Jul 2021 20:08:29 +0000 (20:08 +0000)]
Add virtio comments to the arm64 GENERIC config

Most of these are from the amd64 GENERIC config.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit ab9f9cfda5a77ff511d56cf183f081cb72ada79d)

3 years agoRemove the newline from arm64 trap panics
Andrew Turner [Wed, 14 Jul 2021 19:49:58 +0000 (19:49 +0000)]
Remove the newline from arm64 trap panics

The panic function will already print a newline so there is no need to
add it here.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 2665851086795c61e799fbe57bfb37cabab3cf8c)

3 years agoUpdate the SCTLR_EL1 register definitions
Andrew Turner [Thu, 8 Jul 2021 12:14:56 +0000 (12:14 +0000)]
Update the SCTLR_EL1 register definitions

They are valid as of the ARMv8.7 XML.

While here remove SCTLR_RES0 as it's unused and depends on which CPU
the kernel is running on and switch to shifted values as they are
easier to compare with the documentation.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31120

(cherry picked from commit 5484e6d9cc5801e02cba1bf4b9a03ff2e75fa587)

3 years agoUpdate the arm64 HCR_EL2 registers
Andrew Turner [Wed, 7 Jul 2021 11:51:40 +0000 (11:51 +0000)]
Update the arm64 HCR_EL2 registers

They are valid as of the ARMv8.7 XML.

While here switch to use shifted values as they are easier to compare
with values in the Arm Reference Manual.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31093

(cherry picked from commit 3c1bfadaf93da6ec0291a7dc7dc7690ef6611619)

3 years agoSupport fixed size, variable location acpi resources
Andrew Turner [Thu, 8 Jul 2021 15:25:38 +0000 (15:25 +0000)]
Support fixed size, variable location acpi resources

These have been found in some Arm ACPI tables generated by edk2, e.g.
when describing the pl011 uart on the Arm AEMv8 model.

Reviewed by: imp, jkim
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31110

(cherry picked from commit 1472117a1e1c40f10b9c3a48788fbf8355588ee8)

3 years agoFix the name of the arm64 SCTLR_E0E register
Andrew Turner [Wed, 7 Jul 2021 23:12:50 +0000 (23:12 +0000)]
Fix the name of the arm64 SCTLR_E0E register

The character between the E's was the letter O, however in the Arm
Documentation and XML the character is the number 0 (zero).

Sponsored by: The FreeBSD Foundation

(cherry picked from commit c0edde3021900b80fec4e6360d97ba9d9e50d4fd)

3 years agoSync the arm64 special registers with the Armv8.5 XML
Andrew Turner [Thu, 1 Jul 2021 01:14:09 +0000 (01:14 +0000)]
Sync the arm64 special registers with the Armv8.5 XML

Add the missing macros and decode all the fields as described in the
Arm Architecture System Registers XML corresponding to Armv8.5.

Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30983

(cherry picked from commit a7b05eb16c9d84e1fd59864f5da67d23897ed91c)

3 years agoSwitch the order of the ID_AA64PFR1_EL1 fields
Andrew Turner [Thu, 1 Jul 2021 00:45:39 +0000 (00:45 +0000)]
Switch the order of the ID_AA64PFR1_EL1 fields

This makes them consistent with the fields in other registers.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 244002b48257a8e4d3b4772872981c0d7a467923)

3 years agoAdd more GIC and GICv3 registers
Andrew Turner [Mon, 14 Jun 2021 12:48:53 +0000 (12:48 +0000)]
Add more GIC and GICv3 registers

These aren't used by either driver, however they will be needed by
bhyve on arm64 to emulate a GICv3 interrupt controller.

Sponsored by: Innovate UK

(cherry picked from commit 15fa52a56494d050c4b8e1535d98e2fd416f1944)

3 years agoUse the correct length when copying arm64 vfp registers
Andrew Turner [Mon, 14 Jun 2021 11:01:46 +0000 (11:01 +0000)]
Use the correct length when copying arm64 vfp registers

We passed the wrong length into memcpy in the arm64 get_fpcontext and
set_fpcontext. This caused us to copy two status registers we didn't
expect to copy.

These are safe as they exist in both the source and destination, although
in a different order, and we copy the correct values after the memcpy.

Obtained from: CheriBSD
Sponsored by: Innovate UK

(cherry picked from commit e7f369b1c18ca0377bb0b016b4cab3f0de2a74c5)

3 years agoUse the arm virtual counter in the arm64 loader
Andrew Turner [Wed, 12 May 2021 07:45:09 +0000 (07:45 +0000)]
Use the arm virtual counter in the arm64 loader

It exist on all ARMv8+ CPUs, and other boot loaders rely on it being
present.

Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D30410

(cherry picked from commit 0a0d6ce34d6be89cb356c7815648e455fabe3151)

3 years agovirtio: enable VTNET_LEGACY_TX when ALTQ is enabled.
Luiz Otavio O Souza [Thu, 26 Oct 2017 02:30:54 +0000 (21:30 -0500)]
virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.

ALTQ only works on network drivers which use if_start (rather than
if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default
to that the kernel is built with ALTQ enabled, to reduce user surprise.

MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 5afe81a7b23afd27289ca40e04a6a764134d6273)

3 years agolibc/locale: Use O_CLOEXEC when opening locale tables
Mark Johnston [Thu, 29 Jul 2021 13:14:50 +0000 (09:14 -0400)]
libc/locale: Use O_CLOEXEC when opening locale tables

Reviewed by: kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 98bfb9dac28585fb5629c5fc951ce0d83490d446)

3 years agoAdd missing bsd.linker.mk include after 31ba4ce8898f9dfa5e7f054fdbc26e50a599a6e3
Alex Richardson [Mon, 2 Aug 2021 15:38:39 +0000 (16:38 +0100)]
Add missing bsd.linker.mk include after 31ba4ce8898f9dfa5e7f054fdbc26e50a599a6e3

This is needed for -DWITH_CLEAN builds since the cleandir phase does not
include bsd.linker.mk from bsd.compiler.mk

(cherry picked from commit 9f1db6c5557bd01734ee63afacaf07a37fb3cc60)

3 years agoAllow bootstrapping llvm-tblgen on macOS and Linux
Alex Richardson [Mon, 2 Aug 2021 13:36:03 +0000 (14:36 +0100)]
Allow bootstrapping llvm-tblgen on macOS and Linux

This is needed in order to build various LLVM binutils (e.g. addr2line)
as well as clang/lld/lldb.

Co-authored-by: Jessica Clarke <jrtc27@FreeBSD.org>
Test Plan: Compiles on ubuntu 18.04 and macOS 11.4
Reviewed By: dim
Differential Revision: https://reviews.freebsd.org/D31057

(cherry picked from commit 31ba4ce8898f9dfa5e7f054fdbc26e50a599a6e3)

3 years agoRemove mkcsmapper_static and mkesdb_static from build-tools
Alex Richardson [Mon, 2 Aug 2021 09:49:01 +0000 (10:49 +0100)]
Remove mkcsmapper_static and mkesdb_static from build-tools

Build them as part of the bootstrap-tools phase instead.

Reviewed by: emaste (no objections)
Differential Revision: https://reviews.freebsd.org/D28181

(cherry picked from commit 2de949cf85d0e0b9ff71e1ffd74153814de96175)

3 years agotools/build: Don't redefine open() for the linux bootstrap
Alex Richardson [Mon, 2 Aug 2021 08:45:05 +0000 (09:45 +0100)]
tools/build: Don't redefine open() for the linux bootstrap

This is needed to bootstrap llvm-tblgen on Linux since LLVM calls
`::open(...)` which does not work if open is a statement macro.
Also stop defining O_SHLOCK/O_EXLOCK and update the only bootstrap tools
user of those flags to deal with missing definitions.

Reviewed By: jrtc27
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31226

(cherry picked from commit 5f6c8ce2452da2da233e37bf4c2b6fccde8594b1)

3 years agobsd.linker.mk: Detect LLD when built with PACKAGE_VENDOR
Alex Richardson [Tue, 20 Jul 2021 15:04:56 +0000 (16:04 +0100)]
bsd.linker.mk: Detect LLD when built with PACKAGE_VENDOR

Recent versions of homebrew's LLD are built with PACKAGE_VENDOR (since
https://github.com/Homebrew/homebrew-core/commit/e7c972b6062af753e564104e58d1fa20c0d1ad7a).
This means that the -v output is now
`Homebrew LLD 12.0.1 (compatible with GNU linkers)` and bsd.linker.mk no
longer detects it as LLD since it only checks whether the first word is
LLD. This change allow me to build on macOS again and should unbreak the
GitHub actions CI.

Reviewed By: imp, uqs
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D31224

(cherry picked from commit f8147dad44f1036160a413bb00b4e8b41f7a4a84)

3 years agoDon't build lldb-tablegen if MK_LLDB=no
Alex Richardson [Mon, 5 Jul 2021 17:36:02 +0000 (18:36 +0100)]
Don't build lldb-tablegen if MK_LLDB=no

Split out from D31060.

Reviewed by: emaste

(cherry picked from commit c5d1d88a351abe869c436f4f70c85d4c29e6e98c)

3 years agoAllow building usr.bin/vi with MK_ASAN
Alex Richardson [Mon, 19 Jul 2021 14:04:19 +0000 (15:04 +0100)]
Allow building usr.bin/vi with MK_ASAN

We have to namespace the regex functions to avoid duplicate symbol errors.
This also ensures that vi doesn't define the libc reg* functions with
mismatched signatures.

ld: error: duplicate symbol: regcomp
>>> defined at sanitizer_common_interceptors.inc:7519 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:7519)
>>>            asan_interceptors.o:(__interceptor_regcomp) in archive /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at regcomp.c
>>>            .../regex/regcomp.c.o:(.text+0x0)

ld: error: duplicate symbol: regerror
>>> defined at sanitizer_common_interceptors.inc:7543 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:7543)
>>>            asan_interceptors.o:(__interceptor_regerror) in archive /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at regerror.c
>>>            .../regex/regerror.c.o:(.text+0x0)

ld: error: duplicate symbol: regexec
>>> defined at sanitizer_common_interceptors.inc:7530 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:7530)
>>>            asan_interceptors.o:(__interceptor_regexec) in archive /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at regexec.c
>>>            .../regex/regexec.c.o:(.text+0x0)

ld: error: duplicate symbol: regfree
>>> defined at sanitizer_common_interceptors.inc:7553 (/usr/src/contrib/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:7553)
>>>            asan_interceptors.o:(__interceptor_regfree) in archive /usr/lib/clang/10.0.1/lib/freebsd/libclang_rt.asan-x86_64.a
>>> defined at regfree.c
>>>            .../regex/regfree.c.o:(.text+0x0)

Committed upstream as https://github.com/lichray/nvi2/pull/92

Reviewed By: bapt
Differential Revision: https://reviews.freebsd.org/D31050

(cherry picked from commit 8ef98a8045d4623edd75b91ce76eedeaa4ad3f01)

3 years agobin/ps: Avoid function name conflict with libc uname()
Alex Richardson [Mon, 19 Jul 2021 14:03:38 +0000 (15:03 +0100)]
bin/ps: Avoid function name conflict with libc uname()

This prevents ps from being built with address sanitizer instrumentation.

Reviewed By: trasz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31048

(cherry picked from commit 2423585b1de50dd2daea8478318e94ff80e0e6ec)

3 years agoFix building rescue/rescue when sanitizers are enabled
Alex Richardson [Tue, 6 Jul 2021 11:18:29 +0000 (12:18 +0100)]
Fix building rescue/rescue when sanitizers are enabled

We have to ensure that we don't link any instrumented object files
into rescue as it is a static executable and static binaries can't
use the sanitizer runtime.

Reviewed By: imp
Differential Revision: https://reviews.freebsd.org/D31044

(cherry picked from commit 2eefc1d926430dbba83128d27f8bed3c34199159)

3 years agousr.bin/diff: fix UBSan error in readhash
Alex Richardson [Tue, 6 Jul 2021 11:16:40 +0000 (12:16 +0100)]
usr.bin/diff: fix UBSan error in readhash

UBSan complains about the `sum = sum * 127 + chrtran(t);` line below since
that can overflow an `int`. Use `unsigned int` instead to ensure that
overflow is well-defined.

Reviewed By: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31075

(cherry picked from commit c78f449d85e0b292fe5d942cca99f11c1cd430fa)

3 years agousr.bin/login: send errors to console if syslog isn't running
Alex Richardson [Tue, 6 Jul 2021 09:50:05 +0000 (10:50 +0100)]
usr.bin/login: send errors to console if syslog isn't running

I was debugging why login(1) wasn't working as expected on a minimal
MFS_ROOT disk image. This image doesn't have syslogd running so the
warnings were lost and I had to use GDB to find out why login(1) was
failing (missing PAM libraries) instead of being able to see it in
the console output.

MFC after: 1 week
Reviewed By: pfg
Differential Revision: https://reviews.freebsd.org/D30892

(cherry picked from commit 4d552825ecebecd6c95a995c0b314b09936121b5)

3 years agousr.bin/sort: Avoid UBSan errors
Alex Richardson [Mon, 5 Jul 2021 13:32:48 +0000 (14:32 +0100)]
usr.bin/sort: Avoid UBSan errors

UBSan complains about out-of-bounds accesses for zero-length arrays. To
avoid this we can use flexible array members. However, the C standard does
not allow for structures that only contain flexible array members, so we
move the length parameters into that structure too.

Split out from D28233.

Reviewed By: markj
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D31009

(cherry picked from commit d053fb22f6d3b6bb0f4e47e4507fefc20cbe0e32)

3 years agoSimplify and speed up the kyua build
Alex Richardson [Fri, 2 Jul 2021 08:21:04 +0000 (09:21 +0100)]
Simplify and speed up the kyua build

Instead of having multiple kyua libraries, just include the files as part
of usr.bin/kyua. Previously, we would build each kyua source up to four
times: once as a .o file and once as a .pieo. Additionally, the kyua
libraries might be built again for compat32. As all the kyua libraries
amount to 102 C++ sources the build time is significant (especially when
using an assertions enabled compiler). This change ensures that we build
306 fewer .cpp source files as part of buildworld.

Reviewed By: brooks
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D30967

Remove lib/kyua from the build

I forgot to include this line in 2eb9ad427475190e87d026de4ca7fc296947f2a0.

Reported by: Jenkins CI
MFC after: 1 week
Fixes: 2eb9ad427475190ei ("Simplify and speed up the kyua build")

Revert "Remove lib/kyua from the build"

Accidentally removed it from the wrong file...

This reverts commit 8ec4ba8a76aaf256942ac5996d45cc29022641ae.

Remove lib/kyua from the build

I forgot to include this line in 2eb9ad427475190e87d026de4ca7fc296947f2a0.

Reported by:    Jenkins CI
MFC after:      1 week
Fixes: 2eb9ad427475190ei ("Simplify and speed up the kyua build")
(cherry picked from commit 2eb9ad427475190e87d026de4ca7fc296947f2a0)
(cherry picked from commit 8ec4ba8a76aaf256942ac5996d45cc29022641ae)
(cherry picked from commit 89da04fcaa33f100a60d06770f7424e5b7f1312f)
(cherry picked from commit c951566915886330612bee880d6ece0d65bf9f5d)

3 years agox86 __vdso_gettc: add O_CLOEXEC flag to open
Konstantin Belousov [Thu, 29 Jul 2021 01:26:38 +0000 (04:26 +0300)]
x86 __vdso_gettc: add O_CLOEXEC flag to open

(cherry picked from commit cbf6f55e77a9176572830a20804cf1d005dfea73)

3 years agovmci(4): Shorten interrupt descriptions.
Alexander Motin [Thu, 22 Jul 2021 16:58:10 +0000 (12:58 -0400)]
vmci(4): Shorten interrupt descriptions.

We have no space there for such a long strings.  Also it makes no
sense to set description if there is only one interrupt.

MFC after: 2 weeks

(cherry picked from commit ab38c12b4a488c011ea85252621430ded6e87139)

3 years agonfscl: Send stateid.seqid of 0 for NFSv4.1/4.2 mounts
Rick Macklem [Tue, 20 Jul 2021 00:35:39 +0000 (17:35 -0700)]
nfscl: Send stateid.seqid of 0 for NFSv4.1/4.2 mounts

For NFSv4.1/4.2, the client may set the "seqid" field of the
stateid to 0 in RPC requests.  This indicates to the server that
it should not check the "seqid" or return NFSERR_OLDSTATEID if the
"seqid" value is not up to date w.r.t. Open/Lock operations
on the stateid.  This "seqid" is incremented by the NFSv4 server
for each Open/OpenDowngrade/Lock/Locku operation done on the stateid.

Since a failure return of NFSERR_OLDSTATEID is of no use to
the client for I/O operations, it makes sense to set "seqid"
to 0 for the stateid argument for I/O operations.
This avoids server failure replies of NFSERR_OLDSTATEID,
although I am not aware of any case where this failure occurs.

This makes the FreeBSD NFSv4.1/4.2 client compatible with the
Linux NFSv4.1/4.2 client.

(cherry picked from commit 7685f8344d9a59e9498bdfebb48066f98216fecd)

3 years agosrc.conf.5: regen after 3f244aace29b
Ed Maste [Wed, 4 Aug 2021 17:24:02 +0000 (13:24 -0400)]
src.conf.5: regen after 3f244aace29b

3 years agoUpdate WITHOUT_KERNEL_SYMBOLS description
Ed Maste [Tue, 27 Jul 2021 21:18:41 +0000 (17:18 -0400)]
Update WITHOUT_KERNEL_SYMBOLS description

We have installed kernel debug data under /usr/lib/debug/ for some time
now, so the suggestion to set WITHOUT_KERNEL_SYMBOLS for small root
partitions is no longer valid.

Also call them "debug symbol files" rather than just "symbol files",
since they contain much more than just symbols.  The kernel also
includes (some) symbols, regardless of the setting of this knob.

MFC after: 1 week

(cherry picked from commit 5f946c76c0cc2d1b4fa150f691764da163579d19)

3 years agoCorrect section reference for examples in RFC3542
Tom Jones [Sun, 1 Aug 2021 12:52:07 +0000 (13:52 +0100)]
Correct section reference for examples in RFC3542

Reviewed by: bz, network
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D26272

(cherry picked from commit 44752e92e134167e9a0ecd277e32608a5595e6d1)

3 years agoRevert "arm: remove fslsdma from GENERIC"
Warner Losh [Wed, 4 Aug 2021 02:09:18 +0000 (20:09 -0600)]
Revert "arm: remove fslsdma from GENERIC"

The firmware was already in the tree when I did this commit, and I
missed the message. The bug was obsolete.

This reverts commit 9e3761d126c5c019d6c935e83989928eb1a0e76e.

The commit was f219c053852d82acb9852cd735c815ba315f416d in stable/13.

PR: 237466
Sponsored by: Netflix

(cherry picked from commit e94f1a0a37fdd3252201aaa5a94f46da7f8e740e)

3 years agoRELNOTES: Add entries for commits 9fb6e613373c and 9ec7dbf46b0a
Rick Macklem [Wed, 4 Aug 2021 00:24:23 +0000 (17:24 -0700)]
RELNOTES: Add entries for commits 9fb6e613373c and 9ec7dbf46b0a

This is a direct commit.