]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agoRefactor core dumping code a bit
Edward Tomasz Napierala [Sat, 22 May 2021 08:58:35 +0000 (09:58 +0100)]
Refactor core dumping code a bit

This makes it possible to use core_write(), core_output(),
and sbuf_drain_core_output(), in Linux coredump code.  Moving
them out of imgact_elf.c is necessary because of the weird way
it's being built.

Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30369

(cherry picked from commit 33621dfc196e317026aa8b9d916567598a1cedcb)

2 years agomips: Add sv_onexec_old and sv_onexit for COMPAT_FREEBSD32.
John Baldwin [Thu, 12 May 2022 17:49:55 +0000 (10:49 -0700)]
mips: Add sv_onexec_old and sv_onexit for COMPAT_FREEBSD32.

This is a direct commit to stable/13 as MIPS is not present in main.

2 years agofusefs: fix FUSE_CREATE with file handles and fuse protocol < 7.9
Alan Somers [Thu, 28 Apr 2022 21:13:09 +0000 (15:13 -0600)]
fusefs: fix FUSE_CREATE with file handles and fuse protocol < 7.9

Prior to fuse protocol version 7.9, the fuse_entry_out structure had a
smaller size.  But fuse_vnop_create did not take that into account when
working with servers that use older protocols.  The bug does not matter
for servers which don't use file handles or open flags (the only fields
affected).

PR: 263625
Submitted by: Ali Abdallah <ali.abdallah@suse.com>

(cherry picked from commit 45825a12f9851213e627cf41398706bacb793f83)

2 years agoctlstat: add prometheus output
Alan Somers [Wed, 21 Apr 2021 22:56:48 +0000 (16:56 -0600)]
ctlstat: add prometheus output

When invoked by inetd, ctlstat -P will now produce output suitable for
ingestion into Prometheus.

It's a drop-in replacement for https://github.com/Gandi/ctld_exporter,
except that it doesn't report the number of initiators per target, and
it does report time and dma_time.

Sponsored by: Axcient
Relnotes: yes
Reviewed by:  bapt, bcr
Differential Revision: https://reviews.freebsd.org/D29901

(cherry picked from commit 1a7f22d9c211f504f6c48a86401469181a67ec34)

2 years agoprometheus_sysctl_exporter: fix metric aliasing
Alan Somers [Mon, 18 Apr 2022 21:29:37 +0000 (15:29 -0600)]
prometheus_sysctl_exporter: fix metric aliasing

When exporting sysctls to Prometheus, the exporter replaces "." with
"_".  This caused several metrics to alias, confusing the Prometheus
server.  Fix it by:

* Renaming the "tcp_log_bucket" UMA zone to "tcp_log_id_bucket".  Also,
  rename "tcp_log_node" to "tcp_log_id_node" for consistency.

* Not exporting sysctls with "(LEGACY)" in the description.  That is
  used by ZFS sysctls that have been replaced by others, many of which
  alias to the same Prometheus metric name (like "vfs.zfs.arc_max" and
  "vfs.zfs.arc.max").

PR: 259607
Reported by: delphij
Sponsored by: Axcient
Reviewed by: delphij,rew,thj
Differential Revision: https://reviews.freebsd.org/D34952

(cherry picked from commit 8c47d8f53854825d8e8591ccd06e32b2c798f81c)

2 years agofusefs: correctly handle servers that report too much data written
Alan Somers [Mon, 18 Apr 2022 23:03:53 +0000 (17:03 -0600)]
fusefs: correctly handle servers that report too much data written

During a FUSE_WRITE, the kernel requests the server to write a certain
amount of data, and the server responds with the amount that it actually
did write.  It is obviously an error for the server to write more than
it was provided, and we always treated it as such, but there were two
problems:

* If the server responded with a huge amount, greater than INT_MAX, it
  would trigger an integer overflow which would cause a panic.

* When extending the file, we wrongly set the file's size before
  validing the amount written.

PR: 263263
Reported by: Robert Morris <rtm@lcs.mit.edu>
Sponsored by: Axcient
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D34955

(cherry picked from commit 3a1b3c6a1e68063330e897a5a5c94518edae4a3b)

2 years agofusefs: validate servers' error values
Alan Somers [Fri, 15 Apr 2022 19:04:24 +0000 (13:04 -0600)]
fusefs: validate servers' error values

Formerly fusefs would pass up the stack any error value returned by the
fuse server.  However, some values aren't valid for userland, but have
special meanings within the kernel.  One of these, EJUSTRETURN, could
cause a kernel page fault if the server returned it in response to
FUSE_LOOKUP.  Fix by validating all errors returned by the server.

Also, fix a data lifetime bug in the FUSE_DESTROY test.

PR: 263220
Reported by: Robert Morris <rtm@lcs.mit.edu>
Sponsored by: Axcient
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D34931

(cherry picked from commit 155ac516c60f20573d15c54bafabfd0e52d21fa6)

2 years agobwn: eliminate dead writes in BWN_GPL_PHY
Greg V [Wed, 4 May 2022 13:32:59 +0000 (09:32 -0400)]
bwn: eliminate dead writes in BWN_GPL_PHY

This fixes the newly Werror'ed useless write warnings with options
BWN_GPL_PHY.

Reviewed by: markj

(cherry picked from commit 12905b7d50289633a58caf34ba77ff318ba4f0c2)

2 years agostand/zfs: Fix const-qual warnings
Mark Johnston [Fri, 29 Apr 2022 13:19:34 +0000 (09:19 -0400)]
stand/zfs: Fix const-qual warnings

The input buffer is read-only, update casts to match.

No functional change intended.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8d20f1560d05ef4c96680cd1a0a0b9ac9054700f)

2 years agocxgbei: Support unmapped I/O requests.
John Baldwin [Thu, 10 Mar 2022 23:50:52 +0000 (15:50 -0800)]
cxgbei: Support unmapped I/O requests.

- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- Add new page pod routines for allocating and writing page pods for
  unmapped bio requests.  Use these new routines for setting up DDP
  for iSCSI tasks with a SCSI I/O CCB which uses CAM_DATA_BIO.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.  This also requires changes in the t4_push_pdus path
  to support unmapped mbufs.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34383

(cherry picked from commit 2beaefe88443f0644d65b3ae0ac2f1ccff51e748)

2 years agoicl_soft: Use PHYS_TO_DMAP instead of pmap_map_io_transient.
John Baldwin [Fri, 11 Mar 2022 02:20:28 +0000 (18:20 -0800)]
icl_soft: Use PHYS_TO_DMAP instead of pmap_map_io_transient.

The latter API is not actually MI but is only supported on amd64,
arm64, and RISC-V.

Sponsored by: Chelsio Communications

(cherry picked from commit 832acea92fc8cdb55859a6a4b1bc38bf766780f1)

2 years agoiscsi: Support unmapped I/O requests in the default initiator.
John Baldwin [Thu, 10 Mar 2022 23:50:26 +0000 (15:50 -0800)]
iscsi: Support unmapped I/O requests in the default initiator.

- Add icl_pdu_append_bio and icl_pdu_get_bio methods.

- When ICL_NOCOPY is used to append data from an unmapped I/O request
  to a PDU, construct unmapped mbufs from the relevant pages backing
  the struct bio.

- Use m_apply with a helper to compute crc32 digests on mbuf chains
  to handle unmapped mbufs.  Since m_apply requires PMAP_HAS_DMAP
  for unmapped mbufs, only support unmapped requests when PMAP_HAS_DMAP
  is true.

Reviewed by: mav
Differential Revision: https://reviews.freebsd.org/D34406

(cherry picked from commit 530e725d8e9ba118ace2f75f010657a4fe4222a6)

2 years agoiscsi: Handle unmapped I/O requests.
John Baldwin [Thu, 10 Mar 2022 23:49:53 +0000 (15:49 -0800)]
iscsi: Handle unmapped I/O requests.

Don't assume that csio->data_ptr is pointer to a data buffer that can
be passed to icl_get_pdu_data and icl_append_data.  For unmapped I/O
requests, csio->data_ptr is instead a pointer to a struct bio as
indicated by CAM_DATA_BIO.  To support these requests, add
icl_pdu_append_bio and icl_pdu_get_bio methods which pass a pointer to
the bio and an offset and length relative to the bio's buffer.

Note that only backends supporting unmapped requests need to implement
these hooks.

Implement simple no-op hooks for the iser backend.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34382

(cherry picked from commit 7aab9c14a462e0871394bbc4e276affb79c8d173)

2 years agoiser: Fix check for opcodes in iser_conn_pdu_append_data.
John Baldwin [Thu, 10 Mar 2022 23:49:37 +0000 (15:49 -0800)]
iser: Fix check for opcodes in iser_conn_pdu_append_data.

Reviewed by: mav
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34487

(cherry picked from commit c6a43f7f10b183469c3804cfb31b29b6d938621b)

2 years agoiscsi: Use ICL_NOCOPY for SCSI command immediate data and R2T.
John Baldwin [Thu, 10 Mar 2022 23:48:20 +0000 (15:48 -0800)]
iscsi: Use ICL_NOCOPY for SCSI command immediate data and R2T.

The associated csio ccb will not be completed via xpt_done() until
after the associated PDUs are transmitted to the other side and either
the original PDU is acked with a SCSI response, or a response is
received for a subsequent abort CCB (which means the earlier PDU has
also been sent since it would have been sent before the abort PDU).

This does assume that once an I/O request has been aborted, no further
PDUs with data payload are queued for that I/O request.

Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D34405

(cherry picked from commit 9c7a4875bce9d0f8308f92a816abf36af8551914)

2 years agolibpmcstat: Fix a few ARM-specific issues with function symbols.
John Baldwin [Thu, 10 Mar 2022 23:39:53 +0000 (15:39 -0800)]
libpmcstat: Fix a few ARM-specific issues with function symbols.

- Refine the checks for ARM mapping symbols and apply them on arm64 as
  well as 32-bit arm.  In particular, mapping symbols can have
  additional characters and are not strictly limited to just "$a" but
  can append additional characters (e.g. "$a.1").  Add "$x" to the
  list of mapping symbol prefixes.

- Clear the LSB of function symbol addresses.  Thumb function
  addresses set the LSB to enable Thumb mode.  However, the actual
  function starts at the aligned address with LSB clear.  Not clearing
  the LSB can cause pmcannotate to pass misaligned addresses to
  objdump when extracting disassembly.

Reviewed by: andrew
Obtained from: CheriBSD
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34416

(cherry picked from commit a6db407f15ab7d0dbfd83a48173343654106510e)

2 years agobhyve: Remove VM_MAXCPU from the userspace API/ABI.
John Baldwin [Wed, 9 Mar 2022 23:39:28 +0000 (15:39 -0800)]
bhyve: Remove VM_MAXCPU from the userspace API/ABI.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34494

(cherry picked from commit f1d450ddee669f1e6fef7aefdf8102fc518eef75)

2 years agobhyve: Use vm_get_topology to query kernel's maximum vCPU count.
John Baldwin [Wed, 9 Mar 2022 23:39:23 +0000 (15:39 -0800)]
bhyve: Use vm_get_topology to query kernel's maximum vCPU count.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34493

(cherry picked from commit c76e4b89d9b87b2450107b29f229d374dc156352)

2 years agobhyve: Don't force an upper bound on vCPUs when parsing pinning.
John Baldwin [Wed, 9 Mar 2022 23:39:16 +0000 (15:39 -0800)]
bhyve: Don't force an upper bound on vCPUs when parsing pinning.

Even today it is possible to specify pinning for a vCPU higher than
the configured number of CPUs but lower than VM_MAXCPU without raising
an error.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34492

(cherry picked from commit fd6f92946f02b451c792bfdbc94259ff65e49969)

2 years agobhyve: Allocate dynamic arrays to hold per-VCPU state.
John Baldwin [Wed, 9 Mar 2022 23:39:08 +0000 (15:39 -0800)]
bhyve: Allocate dynamic arrays to hold per-VCPU state.

This avoids hardcoding VM_MAXCPU in userspace.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34491

(cherry picked from commit 7261f82156fb35d4a5e928769041c5987f700cda)

2 years agobhyve: Make the MADT dynamically sized.
John Baldwin [Wed, 9 Mar 2022 23:38:58 +0000 (15:38 -0800)]
bhyve: Make the MADT dynamically sized.

Use basl_ncpu instead of VM_MAXCPU in MADT_SIZE.  Since several of the
offsets are no longer compile time constants, unroll the loop
generating ACPI tables.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34490

(cherry picked from commit 340a293f9147a37bb71c80a767e37794ca277a28)

2 years agobhyve: Allocate mmio_hint array based on number of guest CPUs.
John Baldwin [Wed, 9 Mar 2022 23:38:49 +0000 (15:38 -0800)]
bhyve: Allocate mmio_hint array based on number of guest CPUs.

This avoids an instance of hardcoding VM_MAXCPU in userspace.

Reviewed by: grehan
Differential Revision: https://reviews.freebsd.org/D34489

(cherry picked from commit 730510dc1ab2049d707706241d9a6e73a6952a4e)

2 years agomodule_test: Fix some assignments to errno intended to be tests.
John Baldwin [Mon, 14 Mar 2022 21:05:05 +0000 (14:05 -0700)]
module_test: Fix some assignments to errno intended to be tests.

Reported by: vangyzen
Reviewed by: vangyzen, markj
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34528

(cherry picked from commit 18207579a26bca553ec285f97a98fbe45316223b)

2 years agoAdd simple kyua tests for the mod* system calls.
John Baldwin [Fri, 4 Mar 2022 01:51:45 +0000 (17:51 -0800)]
Add simple kyua tests for the mod* system calls.

Reviewed by: markj
Obtained from: CheriBSD
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34417

(cherry picked from commit 5a1de9c25defdc0e5d08150d5b1877ac117f43e4)

2 years agoGEOM: Fix regression after 7f16b501e25.
Alexander Motin [Wed, 16 Mar 2022 03:58:09 +0000 (23:58 -0400)]
GEOM: Fix regression after 7f16b501e25.

find_geom() in some classes trim leading "/dev/" from geom names.
Lack of that in geom_gettree_geom() broke some existing scripts.

PR: 262554
MFC after: 2 months

(cherry picked from commit bd0f3d34fa20686bac9a418d3a37a3f59c25ab19)

2 years agoGEOM: Introduce partial confxml API
Alexander Motin [Sat, 12 Mar 2022 16:49:37 +0000 (11:49 -0500)]
GEOM: Introduce partial confxml API

Traditionally the GEOM's primary channel of information from kernel to
user-space was confxml, fetched by libgeom through kern.geom.confxml
sysctl.  It is convenient and informative, representing full state of
GEOM in a single XML document.  But problems start to arise on systems
with hundreds of disks, where the full confxml size reaches many
megabytes, taking significant time to first write it and then parse.

This patch introduces alternative solution, allowing to fetch much
smaller XML document, subset of the full confxml, limited to 64KB and
representing only one specified geom and optionally its parents.  It
uses existing GEOM control interface, extended with new "getxml" verb.
In case of any error, such as the buffer overflow, it just transparently
falls back to traditional full confxml.  This patch uses the new API in
user-space GEOM tools where it is possible.

Reviewed by: imp
MFC after: 2 month
Sponsored by: iXsystems, Inc.
Differential Revision: https://reviews.freebsd.org/D34529

(cherry picked from commit 7f16b501e25b6c792fefc4535e0d1b8363392fe0)

2 years agortsx: Number of tweaks for RTS5260.
Henri Hennebert [Wed, 27 Apr 2022 01:43:17 +0000 (21:43 -0400)]
rtsx: Number of tweaks for RTS5260.

MFC after: 2 weeks

(cherry picked from commit 8290c144201804d3f01ae16eebe1b9a6b221af54)

2 years agoDisable -Wreturn-type on GCC.
John Baldwin [Mon, 14 Feb 2022 19:48:47 +0000 (11:48 -0800)]
Disable -Wreturn-type on GCC.

GCC is more pedantic than clang about warning when a function doesn't
handle undefined enum values (see GCC bug 87950).  Clang's warning
gives a more pragmatic coverage and should find any real bugs, so
disable the warning for GCC rather than adding __unreachable
annotations to appease GCC.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D34147

(cherry picked from commit 2f6a842484675bb8fe9fafd40d90c06f13e02403)

2 years agoCast pointer to uintptr_t to avoid alignment warnings.
John Baldwin [Sat, 12 Feb 2022 00:04:52 +0000 (16:04 -0800)]
Cast pointer to uintptr_t to avoid alignment warnings.

Both struct ip and struct udphdr both have an aligment of 2, but the
cast from struct ip to a uint32_t pointer confused GCC 9 into raising
the required alignment to 4 and then raising a
-Waddress-of-packed-member error when casting to struct udphdr.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31941

(cherry picked from commit dba02df30d536922727a7ea509514462452a247a)

2 years agoktls: Write-lock the INP when changing a transmit TLS session.
John Baldwin [Fri, 11 Feb 2022 23:16:25 +0000 (15:16 -0800)]
ktls: Write-lock the INP when changing a transmit TLS session.

The TCP rate pacing code relies on being able to read this pointer
safely while holding an INP lock.  The initial TLS session pointer is
set while holding the write lock already.

Reviewed by: gallatin, hselasky
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D34086

(cherry picked from commit cd0525f615fe8fea750d2078b61026aabe0d0471)

2 years agolinuxkpi xarray: Correct expression in assertion.
John Baldwin [Fri, 11 Feb 2022 21:59:27 +0000 (13:59 -0800)]
linuxkpi xarray: Correct expression in assertion.

Reported by: GCC -Wparantheses
Reviewed by: wulf, hselasky
Differential Revision: https://reviews.freebsd.org/D34197

(cherry picked from commit b0c1600a8c42fc1b2c90714d5fefd3266385225a)

2 years agolinuxkpi: Add parentheses to pacify -Wparentheses warnings from GCC.
John Baldwin [Mon, 7 Feb 2022 21:43:22 +0000 (13:43 -0800)]
linuxkpi: Add parentheses to pacify -Wparentheses warnings from GCC.

Reviewed by: bz, emaste
Differential Revision: https://reviews.freebsd.org/D34145

(cherry picked from commit 7043ca9140d2bf4c42371e25716298d24da54cd0)

2 years agostand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.
John Baldwin [Wed, 2 Feb 2022 20:18:43 +0000 (12:18 -0800)]
stand/efi: Pass --no-dynamic-linker to ld.bfd >= 2.34.

ld.bfd in binutils 2.34+ now reports an error in more cases for custom
ldscripts that do not place PHDRs in a LOAD segment.  However, EFI
binaries are not dynamic binaries which need PHDRs, so pass
--no-dynamic-linker to disable this check.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D34124

(cherry picked from commit 8bd5e2f15cc9756e7d6b7feb43ec47f18a38e2bf)

2 years agofstyp: Remove __packed from struct exfat_de_label.
John Baldwin [Tue, 1 Feb 2022 01:33:31 +0000 (17:33 -0800)]
fstyp: Remove __packed from struct exfat_de_label.

This fixes a -Waddress-of-packed-member warning about a possibly
unaligned pointer from GCC 9 when calling convert_label().

__packed has to be removed from struct exfat_dirent as well to fix an
alignment warning when casting from a struct exfat_dirent pointer to a
struct exfat_de_label pointer.

Reviewed by: cem
Differential Revision: https://reviews.freebsd.org/D32144

(cherry picked from commit 58862c0bea66139583f830d21c2f1d98fb844bb0)

2 years agoggatec: Use ANSI C definition for init_initial_buffer_size.
John Baldwin [Tue, 1 Feb 2022 01:12:04 +0000 (17:12 -0800)]
ggatec: Use ANSI C definition for init_initial_buffer_size.

This fixes -Wstrict-prototypes and -Wold-style-definition warnings
from GCC 9.

(cherry picked from commit 6c9ed428284e40f28a49eac2680f06ed33b7cca9)

2 years agohyperv storvsc: Don't abuse struct sglist to hold virtual addresses.
John Baldwin [Tue, 1 Feb 2022 01:11:27 +0000 (17:11 -0800)]
hyperv storvsc: Don't abuse struct sglist to hold virtual addresses.

struct sglist is intended for holding S/G lists of physical address
ranges, not virtual address ranges.  GCC 9.x issues several warnings
due to casts between pointers and integers of different sizes as a
result (vm_paddr_t is 64-bits on i386).  Instead, add a local 'struct
hv_sglist' which uses an array of 'struct iovec' to hold the S/G list
of virtual address ranges.

Differential Revision: https://reviews.freebsd.org/D31933

(cherry picked from commit 53e938e408be78a45c82012ca7a7be50b216159b)

2 years agocryptodev: Use a private malloc type (M_CRYPTODEV) instead of M_XDATA.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
cryptodev: Use a private malloc type (M_CRYPTODEV) instead of M_XDATA.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33991

(cherry picked from commit 8f3f3fdf73a98e819d5f73c1da3286bd608e8208)

2 years agoIPsec: Use protocol-specific malloc types instead of M_XDATA.
John Baldwin [Mon, 24 Jan 2022 23:27:39 +0000 (15:27 -0800)]
IPsec: Use protocol-specific malloc types instead of M_XDATA.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D33992

(cherry picked from commit 35d9e00dba8cf0c25fbfdbd41ad4d6d1906eed4b)

2 years agomount: Don't pass a NULL format string to xo_err().
John Baldwin [Sat, 25 Sep 2021 18:51:01 +0000 (11:51 -0700)]
mount: Don't pass a NULL format string to xo_err().

This fixes a -Wformat error from GCC 9.

Fixes: e725ee7eb672 mount: add libxo(3) support
(cherry picked from commit 9d324b5ffc8a783ceff2a78dea19602a1d8f045a)

2 years agobhyve: Add an empty case for event types in mevent_kq_fflags().
John Baldwin [Sat, 25 Sep 2021 18:25:25 +0000 (11:25 -0700)]
bhyve: Add an empty case for event types in mevent_kq_fflags().

This fixes a -Wswitch error raised by GCC 9.

Differential Revision: https://reviews.freebsd.org/D31938

(cherry picked from commit 7ecdfc823798a8f7add245651b26d9d900bc9889)

2 years agokernel: Disable errors for -Walloca-larger-than for GCC.
John Baldwin [Sat, 25 Sep 2021 18:24:35 +0000 (11:24 -0700)]
kernel: Disable errors for -Walloca-larger-than for GCC.

GCC complains about the use of alloca() with variable sizes (for XSAVE
state len) in sendsig() for i386.  Modern XSAVE state is probably
getting a bit large for the i386 kstack, but downgrade the error to a
warning.

Reviewed by: kib, emaste
Differential Revision: https://reviews.freebsd.org/D31934

(cherry picked from commit e72c7e2738ca9f5893ba5e5e9dc120dfc82fabfd)

2 years agoarm64: Fix a logic bug in is_load_instr().
John Baldwin [Wed, 15 Sep 2021 16:03:18 +0000 (09:03 -0700)]
arm64: Fix a logic bug in is_load_instr().

Logical and ('&&') was used to join two conditions instead of logical
or ('||') causing some store instructions to not be recognized.

Reported by: GCC 9 -Wparentheses

Reviewed by: andrew
Differential Revision: https://reviews.freebsd.org/D31949

(cherry picked from commit 8753039a8f231ab04c7f3db9eaa5d9144d73440d)

2 years agoarm64: Pass the right label to END() for handle_empty_exception.
John Baldwin [Wed, 15 Sep 2021 16:03:18 +0000 (09:03 -0700)]
arm64: Pass the right label to END() for handle_empty_exception.

GNU as reported an error for the argument to .size not being a constant.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D31950

(cherry picked from commit 857dc1c0ecfbf40509706b87de832a3f6d7338b2)

2 years agoinfiniband: Disable -Wredundant-decl warnings.
John Baldwin [Wed, 15 Sep 2021 16:03:18 +0000 (09:03 -0700)]
infiniband: Disable -Wredundant-decl warnings.

ib_uverbs_flow_resources_free() is declard in two header files in
upstream OFED.  Disable the warning to avoid introducing diffs to fix
the build on GCC 9.

While here, fix the ibcore module to disable the same warnings
disabled in OFED_CFLAGS.

Reviewed by: hselasky
Differential Revision: https://reviews.freebsd.org/D31943

(cherry picked from commit 44126818d2ec96d8247eafcae9b96905a473a264)

2 years agoAssert that invalid bus widths can't be passed to bus_width_str().
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
Assert that invalid bus widths can't be passed to bus_width_str().

This appeases a -Wreturn-type warning from GCC.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31935

(cherry picked from commit d2bc7754a226c031b76184277e32c4d65a763f67)

2 years ago<linux/overflow.h>: Don't use __has_builtin().
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
<linux/overflow.h>: Don't use __has_builtin().

GCC only added support for __has_builtin in GCC 10.  However, all
supported versions of GCC and clang include these builtins so just use
them unconditionally.

This fixes the build with GCC 9.

Reviewed by: manu, hselasky, imp
Differential Revision: https://reviews.freebsd.org/D31942

(cherry picked from commit 9553c6af881e1f869cecb11b4476279e0ed6c4e0)

2 years agoRemove nonexistent include path for arm64 crypto files.
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
Remove nonexistent include path for arm64 crypto files.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D31932

(cherry picked from commit 828f257277bd7418bbc0431bbd78569a2f609af1)

2 years agoRemove an always-true check.
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
Remove an always-true check.

This fixes a -Wtype-limits error from GCC 9.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D31936

(cherry picked from commit 5ac4ac85ca20ce1f00c84502a65a3291bf416c18)

2 years agotop: Remove a duplicate extern declaration for show_args.
John Baldwin [Wed, 15 Sep 2021 16:03:17 +0000 (09:03 -0700)]
top: Remove a duplicate extern declaration for show_args.

This fixes a -Wnested-extern error with GCC 9.  There is an existing
extern declaration in top.h.

Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D31937

(cherry picked from commit 4c9cb057bd96bd10278f5ce7a735fff4c08e3c30)

2 years agoDisable -Woverflow errors for i386 for GCC 9.
John Baldwin [Mon, 13 Sep 2021 18:00:38 +0000 (11:00 -0700)]
Disable -Woverflow errors for i386 for GCC 9.

GCC 9 warns about floating point constants overflowing for i386.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D26201

(cherry picked from commit 93d6fa53c9951563be3081a347cc4dc1917ad452)

2 years agoUse an ANSI C function declaration for journal_check_space.
John Baldwin [Fri, 23 Jul 2021 22:06:26 +0000 (15:06 -0700)]
Use an ANSI C function declaration for journal_check_space.

GCC6 fails to compile this due to a -Wstrict-prototypes error.

Sponsored by: Chelsio Communications

(cherry picked from commit 58109a87d42b490eba76879f9007a4dbdaf7bb80)

2 years agoiflib: Cast the result of iflib_netmap_txq_init() to void.
John Baldwin [Fri, 19 Feb 2021 20:52:05 +0000 (12:52 -0800)]
iflib: Cast the result of iflib_netmap_txq_init() to void.

This fixes a warning from GCC for kernels without netmap since the
return value is never used.

Reviewed by: vmaffione, erj
Differential Revision: https://reviews.freebsd.org/D28598

(cherry picked from commit 2ccf971ace0bf23a9b27ec886a7f013c47661052)

2 years agoAdd a VA_IS_CLEANMAP() macro.
John Baldwin [Thu, 18 Feb 2021 00:32:11 +0000 (16:32 -0800)]
Add a VA_IS_CLEANMAP() macro.

This macro returns true if a provided virtual address is contained
in the kernel's clean submap.

In CHERI kernels, the buffer cache and transient I/O map are allocated
as separate regions.  Abstracting this check reduces the diff relative
to FreeBSD.  It is perhaps slightly more readable as well.

Reviewed by: kib
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D28710

(cherry picked from commit 67932460c7b6893a637a47d98d5f29d63e92c727)

2 years agoarm64: Handle 32bits breakpoint exception.
Olivier Houchard [Tue, 21 Sep 2021 13:49:45 +0000 (15:49 +0200)]
arm64: Handle 32bits breakpoint exception.

A different exception is raised when we hit a 32bits breakpoint, rather than
a 64bits one, so handle those as well when COMPAT_FREEBSD32 is defined.
This should fix SIGBUS at least when using breakpoints with thumb2 code.

PR: 256468
MFC After: 1 week

(cherry picked from commit 2734050154927eaa63d3b65de5d46d05569b3a5b)

2 years agoxhci(4): Tweak USB port speed checks to allow newer super speed generations.
Hans Petter Selasky [Tue, 3 May 2022 20:20:27 +0000 (22:20 +0200)]
xhci(4): Tweak USB port speed checks to allow newer super speed generations.

This allows setting the U1 and U2 port timeout values.

Sponsored by: NVIDIA Networking

(cherry picked from commit a1c0442b418b39e57d287750147b0aeae5140766)

2 years agoxhci(4): Properly define all basic USB port speeds.
Hans Petter Selasky [Tue, 3 May 2022 20:19:35 +0000 (22:19 +0200)]
xhci(4): Properly define all basic USB port speeds.

Sponsored by: NVIDIA Networking

(cherry picked from commit d730333c80fe8bc60770d093cbf12f473a065ca4)

2 years agomlx5en(4): Use hard-coded 4K page size for RQ/SQ/CQ.
Hans Petter Selasky [Mon, 2 May 2022 15:14:50 +0000 (17:14 +0200)]
mlx5en(4): Use hard-coded 4K page size for RQ/SQ/CQ.

The page size specified for RQ, SQ and CQ is always in units of 4KBytes.
Make sure we subtract MLX5_ADAPTER_PAGE_SHIFT, 12, instead of PAGE_SHIFT
which may vary. This fixes support for using the mlx5en driver on systems
having non-4K page size.

Linux commit:
68cdf5d6e91068c98d6091b193dc7a5ab7dcf5eb

Sponsored by: NVIDIA Networking

(cherry picked from commit d735d604f063617909d98bd0fc36a6f25a14c699)

2 years agolinuxkpi: Mitigate a seqlock livelock
Mark Johnston [Mon, 25 Apr 2022 13:13:03 +0000 (09:13 -0400)]
linuxkpi: Mitigate a seqlock livelock

Disable preemption in seqlock write sections when using the _irqsave
variant.  This ensures that a writer can't be preempted and subsequently
starved by a reader running in a callout handler on the same CPU.

This fixes occasional display hangs seen when using the i915 driver.

Tested by: emaste, wulf
Reviewed by: wulf, hselasky
Sponsored by: The FreeBSD Foundation

(cherry picked from commit efb8f0b8db8747243f7999b874403d5c86e93b74)

2 years agocross-build: fix some redeclaration warnings during bootstrap
Alex Richardson [Mon, 13 Sep 2021 09:11:47 +0000 (10:11 +0100)]
cross-build: fix some redeclaration warnings during bootstrap

MFC after: 3 days

(cherry picked from commit a89410ef91798859f3fd7a5f675184b4d711ade4)

2 years agoAdd missing const after 6c4f95161d6e
Alex Richardson [Mon, 11 Oct 2021 12:20:36 +0000 (13:20 +0100)]
Add missing const after 6c4f95161d6e

I accidentally didn't include hunk in the committed patch.

Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const")
(cherry picked from commit 9017870541daf46358c6cbaa3d4a40e1bffaaaa1)

2 years agovirtio: make the write_config buffer argument const
Alex Richardson [Mon, 11 Oct 2021 10:52:17 +0000 (11:52 +0100)]
virtio: make the write_config buffer argument const

No functional change intended, but noticed that we could add const here
while adding linuxkpi support for virtio.

Reviewed By: bryanv, imp
Differential Revision: https://reviews.freebsd.org/D32370

(cherry picked from commit 6c4f95161d6e38ba3fd50ca1cceee3110cbfa02e)

2 years agolinuxkpi: implement ida_alloc()
Alex Richardson [Fri, 8 Oct 2021 08:36:30 +0000 (09:36 +0100)]
linuxkpi: implement ida_alloc()

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

(cherry picked from commit d98f2712c7f5e4636afa65c8c3875bbb5ff981cf)

2 years agolinuxkpi: Allow BUILD_BUG_ON in if statements without braces
Alex Richardson [Fri, 8 Oct 2021 08:35:31 +0000 (09:35 +0100)]
linuxkpi: Allow BUILD_BUG_ON in if statements without braces

I got a compilation failure in virtio-gpu without this change.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

(cherry picked from commit 6d15ccde4d9579ad2a77f93630695804a7efcbc4)

2 years agolinuxkpi: Add sg_init_one
Alex Richardson [Fri, 8 Oct 2021 08:32:46 +0000 (09:32 +0100)]
linuxkpi: Add sg_init_one

Needed for the virtio-gpu driver.

Reviewed By: #linuxkpi, manu, bz, hselasky
Differential Revision: https://reviews.freebsd.org/D32366

(cherry picked from commit 2686b10db41c79dd1a0a0c33a7e0c0b67e0701cc)

2 years agoAdd missing dep patterns for .pieo
Alex Richardson [Mon, 13 Sep 2021 12:22:07 +0000 (13:22 +0100)]
Add missing dep patterns for .pieo

While adding sanitizer support, I noticed that all other extensions were
handled but .pieo was missing.

Reviewed By: emaste, imp
MFC after: 1 week

Differential Revision: https://reviews.freebsd.org/D31040

(cherry picked from commit 2d78130185b5518e0bdb4a2f3c5d5ede6773312d)

2 years agoAdd a test for https://reviews.freebsd.org/D31858 (PR 258310)
Alex Richardson [Mon, 13 Sep 2021 09:16:05 +0000 (10:16 +0100)]
Add a test for https://reviews.freebsd.org/D31858 (PR 258310)

This test (based on https://github.com/jiixyj/epoll-shim/pull/32#issuecomment-891276654)
fails reproducibly on QEMU with KVM and `-smp 2` prior to D31858 (committed
as 98168a6e6c12dab8f608f6b5f5b0b175d2b87ef0) and passes with the patch applied.

Reviewed By: kib, imp
Differential Revision: https://reviews.freebsd.org/D31862

(cherry picked from commit d7d962ead0b6e5e8a39202d0590022082bf5bfb6)

2 years agoExport _mmap and __sys_mmap from libc.so
Alex Richardson [Thu, 9 Sep 2021 10:46:53 +0000 (11:46 +0100)]
Export _mmap and __sys_mmap from libc.so

Unlike the other syscalls these two symbols were missing from the
version script. I noticed this while looking into the compiler-rt
runtime libraries for CHERI.

Reviewed by: brooks
Obtained from: https://github.com/CTSRD-CHERI/cheribsd/pull/1063
MFC after: 3 days

(cherry picked from commit 395db99f32bc615a3df2cd469e9537938d022c88)

2 years agoRemove stray .Pp from WITH_LOADER_EFI_SECUREBOOT description
Ed Maste [Mon, 2 May 2022 19:42:32 +0000 (15:42 -0400)]
Remove stray .Pp from WITH_LOADER_EFI_SECUREBOOT description

MFC after: 3 days
Fixes: 13ea0450a9c8 ("Extend libsecureboot(old libve) to...")
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 729ee789117026e980487d0de19ce98ad064af1c)

2 years agoCorrect markup in WITH_/WITHOUT_UNIFIED_OBJDIR descriptions
Ed Maste [Sat, 30 Apr 2022 19:39:21 +0000 (15:39 -0400)]
Correct markup in WITH_/WITHOUT_UNIFIED_OBJDIR descriptions

MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 60b08330a503b5a3380b5f68c2aa4c1c4f610a85)

2 years agoUpdate UNIFIED_OBJDIR descriptions
Ed Maste [Mon, 2 May 2022 17:53:30 +0000 (13:53 -0400)]
Update UNIFIED_OBJDIR descriptions

src.conf(5) previously stated they would be removed before FreeBSD 12.0,
but that did not happen.  Change it to "a future version of FreeBSD."

Also pick up LOADER_KBOOT change (enabled on x86) in src.conf regen.

Reported by: jhb
MFC after: 3 days
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b7f53cdcf8d5025bf5bb04f60602e6f2bb4ae7ae)

2 years agoUpdate WITH_PROFILE description as it is yet removed
Ed Maste [Sat, 30 Apr 2022 19:25:35 +0000 (15:25 -0400)]
Update WITH_PROFILE description as it is yet removed

GCC still wants to link against (for example) libc_p.a when -pg is in
use, and it's unclear when and how this will be addressed.  Change the
WITH_PROFILE option description to claim that it may be removed from an
unspecified future version of FreeBSD, rather than FreeBSD 14.

Reported by: Steve Kargl
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f768ecf247b7acd98fd0ee395522e559769e3e51)

2 years agonfs: do not panic on bootpc_init when no interfaces are found
Alfredo Dal'Ava Junior [Thu, 7 Apr 2022 22:33:26 +0000 (19:33 -0300)]
nfs: do not panic on bootpc_init when no interfaces are found

Replaces panic with a warning message to allow kernel continue
when no bootp eligible network interfaces are found.

This avoids having to build a custom kernel when using a local root
file system on targets like powerpcspe that expects bootp/NFS by
default.

Reviewed by: rmacklem
MFC after: 2 weeks
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D34567

(cherry picked from commit 0b1b30d66450b20bf18fb4ab39bc6d4f5a6a28fe)

2 years agoclockcalib: Fix an overflow bug
Mark Johnston [Thu, 20 Jan 2022 13:23:38 +0000 (08:23 -0500)]
clockcalib: Fix an overflow bug

tc_counter_mask is an unsigned int and in the TSC timecounter is equal
to UINT_MAX, so the addition tc->tc_counter_mask + 1 can overflow to 0,
resulting in a hang during boot.

Fixes: c2705ceaeb09 ("x86: Speed up clock calibration")
Reviewed by: cperciva
Sponsored by: The FreeBSD Foundation

(cherry picked from commit c3196306f092e46008d5ffa626fbafe1f8a94848)

2 years agosubr_unit.c: make userspace tests buildable
Konstantin Belousov [Thu, 28 Apr 2022 00:00:14 +0000 (03:00 +0300)]
subr_unit.c: make userspace tests buildable

(cherry picked from commit 6fe78ad434557a713ebf5159ac6ac4052ef3da1c)

2 years agounr(9): allow to avoid internal locking
Konstantin Belousov [Wed, 20 Apr 2022 22:14:37 +0000 (01:14 +0300)]
unr(9): allow to avoid internal locking

(cherry picked from commit e59b940dcb45b887974aeae8d8f86665aed2c913)

2 years agoinit_unrhdr(): make it usable by initializing everything
Konstantin Belousov [Wed, 20 Apr 2022 21:58:22 +0000 (00:58 +0300)]
init_unrhdr(): make it usable by initializing everything

(cherry picked from commit c4be460e84b48f2c76e27768ee8132a1d639ebc2)

2 years agoLinuxKPI: 802.11: fill in two more TODOs
Bjoern A. Zeeb [Sat, 30 Apr 2022 08:00:04 +0000 (08:00 +0000)]
LinuxKPI: 802.11: fill in two more TODOs

Implement ieee80211_is_data_present() and a subset of
ieee80211_is_bufferable_mmpdu() which hopefully is good enough in
the compat code for now.
This is partly in preparation for some TXQ changes coming up soon.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 00614c9c2ddc34f3f9061e87542efb4edbd936a9)

2 years agoLinuxKPI: 802.11: use ieee80211_beacon_miss()
Bjoern A. Zeeb [Sat, 30 Apr 2022 07:57:34 +0000 (07:57 +0000)]
LinuxKPI: 802.11: use ieee80211_beacon_miss()

In ieee80211_beacon_loss() call into net80211::ieee80211_beacon_miss()
rather than manually bouncing our state.  That should give us the
ability to send a probereq and see if the AP is till there rather than
right away going to scan.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 3540911bfdd83ce69d1c436f6773becefef403fa)

2 years agoLinuxKPI: 802.11 ieee80211_sn_sub() fix
Bjoern A. Zeeb [Mon, 25 Apr 2022 11:35:57 +0000 (11:35 +0000)]
LinuxKPI: 802.11 ieee80211_sn_sub() fix

In ieee80211_sn_sub() we need to shift the mask before applying it.
This fixes the logic from 978f25e840fe4975f243e6077a764842f0e9d3eb.

Reported by: J.R. Oldroyd (fbsd opal.com)
Sponsored by: The FreeBSD Foundation

(cherry picked from commit b3e7f403a509c1e643ef14d95562f5d7e329d77e)

2 years agolibpfctl: grow request buffer on ENOSPC
Kristof Provost [Thu, 14 Apr 2022 12:08:53 +0000 (14:08 +0200)]
libpfctl: grow request buffer on ENOSPC

When we issue a request to pf and expect a serialised nvlist as a reply
we have to supply a suitable buffer to the kernel.
The required size for this buffer is difficult to predict, and may be
(slightly) different from request to request.
If it's insufficient the kernel will return ENOSPC. Teach libpfctl to
catch this and send the request again with a larger buffer.

MFC after: 2 weeks
Sponsored by:   Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D34908

(cherry picked from commit 7ed19f5c7780ebe9ec67121f0c5aa19fbc80bf1a)

2 years agopfctl: fix recursive printing of rules
Matteo Riondato [Wed, 13 Apr 2022 07:38:44 +0000 (09:38 +0200)]
pfctl: fix recursive printing of rules

When asked to print rules recursively, correctly recurse for anchors
included in pf.conf with "anchorname/*".

PR: 262590
Reviewed by: kp
MFC after: 3 weeks

(cherry picked from commit d86cf4435021d0abf3f3d65039583ee8cfde1be1)

2 years agoCAM: Keep periph_links when restoring CCB in camperiphdone().
Alexander Motin [Thu, 28 Apr 2022 01:39:50 +0000 (21:39 -0400)]
CAM: Keep periph_links when restoring CCB in camperiphdone().

While recovery command executed, some other commands from the periph
may complete, that may affect periph_links of this CCB.  So restoring
original CCB we must keep current periph_links as more up to date.

I've found this triggering assertions with debug kernel and suspect
some memory corruptions otherwise when spun down disk receives two
or sometimes more concurrent requests.

MFC after: 1 week
Sponsored by: iXsystems, Inc.

(cherry picked from commit 404f001161b975164d8b52d9f404d07ac7584027)

2 years agoOpenSSL: Merge OpenSSL 1.1.1o
Jung-uk Kim [Tue, 3 May 2022 19:12:42 +0000 (15:12 -0400)]
OpenSSL: Merge OpenSSL 1.1.1o

(cherry picked from commit 9a3583bfbd1740a158b3916432286190e0f2bf60)

2 years agoOpenSSL: Merge OpenSSL 1.1.1o
Jung-uk Kim [Tue, 3 May 2022 19:07:06 +0000 (15:07 -0400)]
OpenSSL: Merge OpenSSL 1.1.1o

(cherry picked from commit 34252e89a96c8d498d7537ade16d20602bf2106a)

2 years agoxhci(4): Always add and evaluate the slot context.
Hans Petter Selasky [Tue, 3 May 2022 16:10:49 +0000 (18:10 +0200)]
xhci(4): Always add and evaluate the slot context.

Because the maximum number of endpoint contexts is stored there.

Tested by: ehaupt@
PR: 262882
Approved by: re (gjb, early MFC)
Sponsored by: NVIDIA Networking

(cherry picked from commit 09dd1adfa4c9bb1b49f4ef5524a308732883e132)

2 years agoxhci(4): Only drop BULK and INTERRUPT endpoints to reset data toggle.
Hans Petter Selasky [Tue, 3 May 2022 16:09:17 +0000 (18:09 +0200)]
xhci(4): Only drop BULK and INTERRUPT endpoints to reset data toggle.

Only drop BULK and INTERRUPT endpoints, to reset the data toggle,
because for other endpoint types this is not critical.

While at it fix some whitespace.

Tested by: ehaupt@
PR: 262882
Approved by: re (gjb, early MFC)
Sponsored by: NVIDIA Networking

(cherry picked from commit e276d281503160ba3648bd394cde95736ee53329)

2 years agoteken: color #3 is yellow not brown - use TC_YELLOW as the name
Ed Maste [Fri, 11 Mar 2022 21:37:03 +0000 (16:37 -0500)]
teken: color #3 is yellow not brown - use TC_YELLOW as the name

The console escape code standard (ECMA-48) specifies color #3 (escape
code 33) as yellow.  A brown console color is an artifact of the VGA
palette, which replaces dim (but not bright) yellow with brown.

Reviewed by: adrian, imp
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34531

(cherry picked from commit cf8880d52b8962edeb807a8ee1811d342fafa26d)

2 years agontp: disable format string warnings in libopts
Ed Maste [Sun, 27 Feb 2022 19:21:12 +0000 (14:21 -0500)]
ntp: disable format string warnings in libopts

libopts uses generated format string tables that contain embedded NULs.

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

(cherry picked from commit 1ffe6d7909109e22d5dbd9369b00900b00b1169b)

2 years agoAdd a number of five letter words to the dictionary
Ed Maste [Wed, 16 Feb 2022 13:47:33 +0000 (08:47 -0500)]
Add a number of five letter words to the dictionary

(And a four letter root of one of them.)

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D34299

(cherry picked from commit e49b6ead4114c6c3963111362e7314b9dd73d6ee)

2 years agokcov: use __func__ in KASSERT instead of old function name
Ed Maste [Mon, 7 Mar 2022 14:48:38 +0000 (09:48 -0500)]
kcov: use __func__ in KASSERT instead of old function name

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 080b4e8a0cfce3579a660669967d200064822ca1)

2 years agoClean up warnings in pthread tests
Ed Maste [Wed, 16 Feb 2022 21:10:45 +0000 (16:10 -0500)]
Clean up warnings in pthread tests

I intend to move these into lib/libthr/tests/ and connect to kyua.  This
is a first step to address warnings emitted when building using standard
make infrastructure.

Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34306

(cherry picked from commit ef135466f81bc3f203efa77d1eb81132f7646196)
(cherry picked from commit 7bfe5e45153b3d214cdb09ced8fccdef02337369)

2 years agoDisable subr_physmem_test on mips
Andrew Turner [Tue, 3 May 2022 15:47:33 +0000 (16:47 +0100)]
Disable subr_physmem_test on mips

It doesn't build.

Direct commit as mips doesn't exist in 14.

Sponsored by: The FreeBSD Foundation

2 years agoOnly return a mapped address from efi_phys_to_kva
Andrew Turner [Sat, 9 Apr 2022 11:43:08 +0000 (12:43 +0100)]
Only return a mapped address from efi_phys_to_kva

On some hardware the EFI system table is not in memory mapped in the
DMAP section. Rather than panic the kernel check if it is mapped and
return a failure if not from efi_phys_to_kva.

Reported by: kevans
Differential Revision: https://reviews.freebsd.org/D34858

(cherry picked from commit f3ef799f564515b58a24a328739a4c749a02b110)

2 years agoInclude the EFI Runtime Code in the DMAP
Andrew Turner [Sat, 9 Apr 2022 20:17:43 +0000 (21:17 +0100)]
Include the EFI Runtime Code in the DMAP

Some UEFI implementations place the system table in a runtime code
memory region. Include it in the DMAP so we can read it later.

Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D34861

(cherry picked from commit 57e47ae514b6ab605298b4595e0219048f59ab7a)

2 years agoHave stpncpy tests ask the kernel for the page size
Andrew Turner [Thu, 7 Apr 2022 15:05:57 +0000 (16:05 +0100)]
Have stpncpy tests ask the kernel for the page size

It may be dynamic so we can't rely on PAGE_SIZE being present or
correct.

(cherry picked from commit 748f7c8db756361f3ba43623612fcfd13cece268)

2 years agoHave path_test ask the kernel for the page size
Andrew Turner [Thu, 7 Apr 2022 14:59:38 +0000 (15:59 +0100)]
Have path_test ask the kernel for the page size

It may be dynamic so we can't rely on PAGE_SIZE being present or
correct.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8d40ee599d130a7dcf57eba448d3966a7ce30638)

2 years agoHave the coredump_phnum test ask for the page size
Andrew Turner [Thu, 7 Apr 2022 14:59:32 +0000 (15:59 +0100)]
Have the coredump_phnum test ask for the page size

The page size may be dynamically selected on boot. Have the
coredump_phnum test helper ask the kernel for the correct value.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit df696a2fb640aee06b38ff487985209f97b944aa)

2 years agoHave rtld query the page size from the kernel
Andrew Turner [Mon, 4 Apr 2022 15:05:40 +0000 (16:05 +0100)]
Have rtld query the page size from the kernel

To allow for a dynamic page size on arm64 have the runtime linker
query the kernel for the currentl page size.

Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34765

(cherry picked from commit e85eaa930862d5b4dc917bc31e8d7254a693635d)

2 years agoHandle non-page aligned/sized memory in physmem
Andrew Turner [Mon, 28 Mar 2022 11:37:09 +0000 (12:37 +0100)]
Handle non-page aligned/sized memory in physmem

In some configurations the firmware may pass memory regions that are
not page sized or aligned, e.g. when using 16k pages on arm64. If this
is the case we will calculate many small regions because the alignment
is applied before being inserted. As we round the start up and end down
this will leave a 1 page hole between what should have been a single
region.

Fix by keeping the original alignment until we are just about to insert
the region into the avail array.

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

(cherry picked from commit d8bff5b67c9b6a85f409a7408e45e7e87d39c5a2)

2 years agoPort subr_physmem to userspace and add tests
Andrew Turner [Mon, 28 Mar 2022 10:20:29 +0000 (11:20 +0100)]
Port subr_physmem to userspace and add tests

These give us some confidience we haven't broken anything in early
boot code that may be running before the console.

Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34691

(cherry picked from commit 8c99dfed541263bd51cae943684bcc13768c2a36)

Disable the physmem test for now

It fails to build on at least i386

(cherry picked from commit d8819d88af529974bac1fe49b713dacf1f3d7239)

Enable subr_physmem_test on supported architectures

Only build where it's supported.

While here add support for amd64 to help with testing.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 41e6d2091ce5653d4ace3f0b9cbde1375d458c67)