]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
14 months agobhyve: add allocation function to E820
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add allocation function to E820

This function makes it easy to allocate new E820 entries. It will be
used to allocate graphics memory for Intel integrated graphic devices.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39547

(cherry picked from commit 5597f564870e94d56111dec638b8859423c936a9)

14 months agobhyve: add common memory holes to E820 table
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add common memory holes to E820 table

The VGA and the ROM memory ranges can't be used as system memory. For
that reason, remove them from the E820 table.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39546

(cherry picked from commit 059af92a300f76653048c042559f7d7d8fd8f99c)

14 months agobhyve: add basic E820 implementation
Corvin Köhne [Thu, 9 Sep 2021 09:37:03 +0000 (11:37 +0200)]
bhyve: add basic E820 implementation

There are some use cases where bhyve has to prepare some special memory
regions. E.g. GPU passthrough for Intel integrated graphic devices needs
to reserve some memory for the graphic device. So, bhyve has to inform
the guest about those memory regions. This information can be passed by
the qemu fwcfg interface. As qemu creates an E820 table, we can reuse
the existing fwcfg item "etc/e820".

This commit is the first one of a series. It only adds a basic
implementation for the creation of the E820 table. Some subsequent
commits will add more items to the E820 table and register it as fwcfg
item.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39545

(cherry picked from commit 9180daa1e34577aaccf3ff64cc63a5179c4f09d8)

14 months agobhyve: make use of qemus acpi table loader
Corvin Köhne [Wed, 6 Apr 2022 09:10:37 +0000 (11:10 +0200)]
bhyve: make use of qemus acpi table loader

Add all acpi tables to qemus acpi table loader. This passes the acpi
tables by fwcfg to the guest.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38439

(cherry picked from commit 7959d80d99ae06ba06cbe7a206ef9bc513e4109b)

14 months agobhyve: add helper struct for qemus acpi table loader
Corvin Köhne [Wed, 6 Apr 2022 09:10:36 +0000 (11:10 +0200)]
bhyve: add helper struct for qemus acpi table loader

The hypervisor is aware of all system properties. For the guest bios
it's hard and complex to detect all system properties. For that reason,
it would be better if the hypervisor creates acpi tables instead of the
guest. Therefore, the hypervisor has to send the acpi tables to the
guest. At the moment, bhyve just copies the acpi tables into the guest
memory. This approach has some restrictions. You have to keep sure that
the guest doesn't overwrite them accidentally. Additionally, the size of
acpi tables is limited.

Providing a plain copy of all acpi tables by fwcfg isn't possible. Acpi
tables have to point to each other. So, if the guest copies the acpi
tables into memory by it's own, it has to patch the tables. Due to
different layouts for different acpi tables, there's no generic way to
do that.  For that reason, qemu created a table loader interface. It
contains commands for the guest for loading specific blobs into guest
memory and patching those blobs.

This commit adds a qemu_loader class which handles the creation of qemu
loader commands. At the moment, the WRITE_POINTER command isn't
implement. It won't be required by bhyve's acpi table generation yet.

Reviewed by: markj
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D38438

(cherry picked from commit f565b4d6303f4798a2cb0dc51ef88de9e4a24047)

14 months agoObsoleteFiles: Complete 20201025: Remove cal data files
Li-Wen Hsu [Thu, 4 May 2023 04:28:52 +0000 (12:28 +0800)]
ObsoleteFiles: Complete 20201025: Remove cal data files

Fixes: d20d6550187a calendar: remove all datafiles except freebsd one
MFC after: 3 days

(cherry picked from commit 5282ada06bbc6727b467d6f6530fa19114143c61)

14 months agoshare/mk/bsd.cpu.mk: add AltiVec / VSX to powerpc*'s MACHINE_CPU
Piotr Kubaj [Fri, 5 May 2023 14:19:19 +0000 (16:19 +0200)]
share/mk/bsd.cpu.mk: add AltiVec / VSX to powerpc*'s MACHINE_CPU

MFC after: 3 days
Approved by: jhibbits
Differential revision: https://reviews.freebsd.org/D39240

(cherry picked from commit 448045e4a7873f4733cebda56df002acabb2aef1)

14 months agotests: Add ATF_REQUIRE_SYSCTL_BOOL
Mark Johnston [Tue, 25 Apr 2023 13:54:23 +0000 (09:54 -0400)]
tests: Add ATF_REQUIRE_SYSCTL_BOOL

Modify a capability mode test to use it for kern.trap_enotcap, to avoid
false positives.

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 8a271827e7b5d5310e06df1f9f49ba0ef9efd263)

14 months agoriscv: Implement bus_describe_intr() for nexus
Mark Johnston [Sun, 23 Apr 2023 17:31:01 +0000 (13:31 -0400)]
riscv: Implement bus_describe_intr() for nexus

Reviewed by: mhorne
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39750

(cherry picked from commit ff13b924751489efed1c6a42dbca8f236902d6fb)

14 months agoarm64: Implement bus_describe_intr() for nexus
Mark Johnston [Sun, 23 Apr 2023 17:30:44 +0000 (13:30 -0400)]
arm64: Implement bus_describe_intr() for nexus

Prompted by a compiler warning introduced by
e582d4a2b09e ("arm64: nexus code tidy-up").

Reviewed by: mhorne, andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39749

(cherry picked from commit 7623cc8f65ab1b28690d4a6580ae87b7926ed008)

14 months agoriscv: Compile instr_size.c into the kernel when DTrace is configured
Mark Johnston [Fri, 21 Apr 2023 13:26:17 +0000 (09:26 -0400)]
riscv: Compile instr_size.c into the kernel when DTrace is configured

Reported by: Jenkins
Fixes: 080e56a6c98c ("dtrace: expose dtrace_instr_size() to userland and implement it for riscv")

(cherry picked from commit 92fa22c6a5c41303e3ad98096c9ebe8202418d81)

14 months agodtrace: add register bindings for RISC-V
Christos Margiolis [Thu, 20 Apr 2023 16:25:37 +0000 (16:25 +0000)]
dtrace: add register bindings for RISC-V

Reviewed by: mhorne, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39611

(cherry picked from commit 1fef7abdc76bd6f0c93775bd0c1b62b523abd20d)

14 months agodtrace: use dtrace_instr_size() in the riscv dtrace_subr.c
Christos Margiolis [Thu, 20 Apr 2023 16:24:03 +0000 (16:24 +0000)]
dtrace: use dtrace_instr_size() in the riscv dtrace_subr.c

No functional change intended.

Reviewed by: mhorne, markj
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39652

(cherry picked from commit 75081b9ed8e67c8443551828f1b5ccf3d449b41b)

14 months agodtrace: expose dtrace_instr_size() to userland and implement it for riscv
Christos Margiolis [Thu, 20 Apr 2023 16:21:46 +0000 (16:21 +0000)]
dtrace: expose dtrace_instr_size() to userland and implement it for riscv

dtrace_instr_size() is needed by the forthcoming RISC-V port of kinst,
as well as by libdtrace in D38825 for both amd64 and RISC-V.

Reviewed by: markj, mhorne
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39489

(cherry picked from commit 080e56a6c98c7e7a241a4260d4c19d3cad5b22af)

14 months agodtrace: get rid of uchar_t types
Christos Margiolis [Thu, 20 Apr 2023 16:19:42 +0000 (16:19 +0000)]
dtrace: get rid of uchar_t types

Callers are specifying uint8_t anyway and this slightly reduces
dependencies on compatibility typedefs.  No functional change intended.

Reviewed by: markj, mhorne
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39490

(cherry picked from commit 1a149d65baed31b90a0b8abe2d6c5a568122a5ec)

14 months agosrc.conf: add WITH_TOOLCHAIN description
Ed Maste [Tue, 2 May 2023 17:27:18 +0000 (13:27 -0400)]
src.conf: add WITH_TOOLCHAIN description

It is not used by the in-tree default configuration, but adding it
allows downstream projects with different defaults to make use of
Cirrus-CI (as the makeman test added in 85e8c2a03490 requires that
there are no missing option descriptions).

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

(cherry picked from commit fc2e2c950d97166ab32ca24134a37986ccaf94ab)

14 months agorelease: Report disk image filename
Ed Maste [Mon, 16 May 2022 18:37:21 +0000 (14:37 -0400)]
release: Report disk image filename

For someone new to the release bits it's not always clear what files are
being created. Report the disk image name explicitly.

Reviewed by: gjb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39953

(cherry picked from commit 4194bbb34c60a5bf0fd0ba28f7bfa20b7842ba3f)

14 months agorenice: Avoid segfault if -n flag is given without argument.
Dag-Erling Smørgrav [Mon, 17 Apr 2023 19:49:13 +0000 (19:49 +0000)]
renice: Avoid segfault if -n flag is given without argument.

Fixes: 65ee0a8495538
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39623

(cherry picked from commit b03311cadd3a6f931e176f97b97bd72be3ef96d4)

renice: Clean up the tests.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D39629

(cherry picked from commit d59dd30cf19bb6df5635b3c896c7c4262917a9b6)

renice: Factor out common code in tests.

Furthermore, prefer test -eq (which ignores whitespace) over a strict string equality test when comparing numerical values.

MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: thj
Differential Revision: https://reviews.freebsd.org/D39650

(cherry picked from commit 1bc6dcc287fa80af74768c4e2b2a1d7511ba1729)

14 months agoIntel DMAR: remove parsing of 6-level paging capability
Jason A. Harmening [Mon, 1 May 2023 16:22:39 +0000 (11:22 -0500)]
Intel DMAR: remove parsing of 6-level paging capability

Early versions of the VT-d spec mentioned 6-level paging support as a
possible value for the SAGAW capability, but later versions removed it
and SAGAW=0x10 is currently listed as a reserved value.

The 6-level (agaw=64) entry in sagaw_bits is furthermore problematic
with clang15 because the attempted comparison against 1ULL << 64 in
dmar_maxaddr2mgaw() causes the compiler to elide the last iteration
of the initial loop, which bypasses the subsequent logic to find the
greatest HW-supported address width.  This results in 5-level paging
always being selected regardless of whether the hardware supports it,
which can result address translation failure due to invalid context-
entry programming.

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D39896

(cherry picked from commit 6f378116e9bf982b8246d033d81cb64d52b24462)

14 months agoauthpf: do not sprintf to a null pointer
Ed Maste [Wed, 3 May 2023 13:26:42 +0000 (09:26 -0400)]
authpf: do not sprintf to a null pointer

The fgetln loop will terminate with buf = NULL at EOF.

Reported by: GCC
Reviewed by: kp
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39947

(cherry picked from commit 81f964e2ffb7cd5d30df0a5c3877900cca4fdd07)

14 months agovfs: Rename vfs_emptydir() to vn_dir_check_empty()
Olivier Certner [Fri, 28 Apr 2023 09:00:11 +0000 (11:00 +0200)]
vfs: Rename vfs_emptydir() to vn_dir_check_empty()

(cherry picked from commit 2544b8e00ca1afea64b00a6ddaf7b584244ade90)

14 months agovfs: vn_dir_next_dirent(): Adapt comments to style(9)
Olivier Certner [Fri, 28 Apr 2023 09:04:16 +0000 (11:04 +0200)]
vfs: vn_dir_next_dirent(): Adapt comments to style(9)

(cherry picked from commit c21d87a88c72804bc4fb86d7b0e8a846230e4ad0)

14 months agovfs: Fix "emptydir" mount option
Olivier Certner [Sat, 22 Apr 2023 16:07:07 +0000 (18:07 +0200)]
vfs: Fix "emptydir" mount option

PR: 270988

(cherry picked from commit 6450e7bbad0c68176f28b51773a3af5d6022c7dd)

14 months agovfs: vn_dir_next_dirent(): Simplify interface and harden
Olivier Certner [Mon, 24 Apr 2023 08:25:15 +0000 (10:25 +0200)]
vfs: vn_dir_next_dirent(): Simplify interface and harden

(cherry picked from commit 3d8450db4c603d18aa45422159170e133c95214d)

14 months agovfs: Export get_next_dirent() as vn_dir_next_dirent()
Olivier Certner [Sun, 23 Apr 2023 07:47:58 +0000 (09:47 +0200)]
vfs: Export get_next_dirent() as vn_dir_next_dirent()

(cherry picked from commit 6bce3f23d0aa045d61c0ec8d27100eb186a33375)

14 months agojedec_dimm(4): Refactor offset adjustment and page0 reset
Ravi Pokala [Thu, 27 Apr 2023 05:03:48 +0000 (22:03 -0700)]
jedec_dimm(4): Refactor offset adjustment and page0 reset

Offsets greater than 255 bytes reside on page1 of the SPD device.
Accessing them requires switching to page1, and adjusting the absolute
offset to be relative to the start of page1. After the access, the page
must be set back to page0. These operations are performed in several
places, so break them out into their own functions.

Also, replace a pair of default cases, which should be impossible due to
earlier checks, with __assert_unreachable().

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

(cherry picked from commit 15d69c840d860a8c0decb063f768ad695427a0d4)

14 months agojedec_dimm(4): Add manufacturing year and week.
Ravi Pokala [Tue, 25 Apr 2023 06:07:39 +0000 (23:07 -0700)]
jedec_dimm(4): Add manufacturing year and week.

DDR3 and DDR4 encode the week and year that the DIMM was manufactured,
as a pair of two-digit binary-coded decimal values. Read the values, and
report them as (uint8_t)s.

Reviewed by: imp, jhb
MFC after: 1 week
Sponsored by: Panasas
Differential Revision: https://reviews.freebsd.org/D39795

(cherry picked from commit de57e0ef5a15c75231191e643d4d1949ddbca92d)

14 months agopkgbase: hide duplicate METALOG directory warnings under verbose
Ed Maste [Mon, 1 May 2023 17:25:18 +0000 (13:25 -0400)]
pkgbase: hide duplicate METALOG directory warnings under verbose

Creating directories multiple times is an inherent side effect of the
way installation is done.  Hide warnings from duplicate directory
entries (with identical metadata) under metalog_reader's verbose mode.

Duplicate file entries are always reported.  They currently generate
warnings but will be switched to errors once the few instances currently
in the tree are fixed.

PR: 244596, 271178
Reviewed by: kevans
Sponsored By: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39898

(cherry picked from commit 2a3bd0870869819354b5ea65761d13e5e2987697)

14 months agoCirrus-CI: set PKG_FORMAT via top level `env:`
Ed Maste [Mon, 1 May 2023 16:45:36 +0000 (12:45 -0400)]
Cirrus-CI: set PKG_FORMAT via top level `env:`

This ensures consistency among different CI scripts, including future
ones for pkgbase work.

Sponsored by: The FreeBSD Foundation

(cherry picked from commit 75baf3765c686547e8e4a5510858f45c23ccdec3)

14 months agologger(1): MFC: fix timestamps in case of long run
Eugene Grosbein [Thu, 27 Apr 2023 16:43:16 +0000 (23:43 +0700)]
logger(1): MFC: fix timestamps in case of long run

An example:

( echo test; sleep 2; echo test2 ) | logger -h /var/run/log

Before fix, logger assigned same timestamp to both records.

Fixes: 65547fb33db901a9f352aacb0ed45ce68b0bd275
Reported by: Vadim Goncharov

(cherry picked from commit 83fd35b3f3fa580d2b99874abd1f67ee61dcb659)

14 months agoCirrus-CI: update stable/13 CI image to 13.1
Ed Maste [Wed, 3 May 2023 20:31:22 +0000 (16:31 -0400)]
Cirrus-CI: update stable/13 CI image to 13.1

We want to ensure that stable/13 still builds on the oldest supported
13.x release, so not updating directly to 13.2.

Sponsored by: The FreeBSD Foundation

14 months agoboolean_t: change to unsigned int to avoid signed bitfield warnings
Dimitry Andric [Tue, 25 Apr 2023 17:52:40 +0000 (19:52 +0200)]
boolean_t: change to unsigned int to avoid signed bitfield warnings

This is the final part, which actually makes boolean_t unsigned. Note
that we do not change its size, nor do we try to change it directly to
bool, since that results in a lot of regressions.

Converting the remaining instances of boolean_t to plain C99 bool can
now be done in a piecemeal fashion, after which boolean_t may hopefully
be retired.

MFC after: 1 week
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D39753

(cherry picked from commit 3029b0b0e9d68eb54e3bdd9e3e49e0f0d2d57835)

14 months agovm: fix a number of functions to match the expected prototypes
Dimitry Andric [Tue, 25 Apr 2023 17:52:26 +0000 (19:52 +0200)]
vm: fix a number of functions to match the expected prototypes

Noticed while attempting to make boolean_t unsigned: some vm-related
function declarations and defintions were using boolean_t where they
should have used int, and vice versa.

MFC after: 1 week
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D39753

(cherry picked from commit f74be55e3045793a507d98127faf9aabd918e1ce)

14 months agozfs: make zfs_vfs_held() definition consistent with declaration
Dimitry Andric [Tue, 25 Apr 2023 17:43:48 +0000 (19:43 +0200)]
zfs: make zfs_vfs_held() definition consistent with declaration

Noticed while attempting to change boolean_t into an actual bool: in
include/sys/zfs_ioctl_impl.h, zfs_vfs_held() is declared to return a
boolean_t, but in module/os/freebsd/zfs/zfs_ioctl_os.c it is defined to
return an int. Make the definition match the declaration.

Obtained from: https://github.com/openzfs/zfs/commit/62cc9d4f6
Reviewed by: jhb
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D39753

(cherry picked from commit 64b5d74fffc8882d915e6e8de7e5fc893c606213)

14 months agoApply clang fix for assertion building emulators/rpcs3
Dimitry Andric [Fri, 28 Apr 2023 14:08:42 +0000 (16:08 +0200)]
Apply clang fix for assertion building emulators/rpcs3

Merge commit a5e1a93ea10f from llvm-project (by Mariya Podchishchaeva):

  [clang] Fix crash when handling nested immediate invocations

  Before this patch it was expected that if there was several immediate
  invocations they all belong to the same expression evaluation context.
  During parsing of non local variable initializer a new evaluation context is
  pushed, so code like this
  ```
  namespace scope {
  struct channel {
      consteval channel(const char* name) noexcept { }
  };
  consteval const char* make_channel_name(const char* name) { return name;}

  channel rsx_log(make_channel_name("rsx_log"));
  }
  ```
  produced a nested immediate invocation whose subexpressions are attached
  to different expression evaluation contexts. The constructor call
  belongs to TU context and `make_channel_name` call to context of
  variable initializer.

  This patch removes this assumption and adds tracking of previously
  failed immediate invocations, so it is possible when handling an
  immediate invocation th check that its subexpressions from possibly another
  evaluation context contains errors and not produce duplicate
  diagnostics.

  Fixes https://github.com/llvm/llvm-project/issues/58207

  Reviewed By: aaron.ballman, shafik

  Differential Revision: https://reviews.llvm.org/D146234

PR: 269489
MFC after: 3 days

(cherry picked from commit 56f2446575c78d962b6dda5e3310bec078622f3d)

14 months agosys: Retire OPENZFS_CWARNFLAGS now that it is empty.
John Baldwin [Wed, 22 Mar 2023 19:35:30 +0000 (12:35 -0700)]
sys: Retire OPENZFS_CWARNFLAGS now that it is empty.

Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D39217

(cherry picked from commit dddb1aec4d54ba949201f4a2e3146cfab4a5870f)

14 months agoFix spelling of NO_WINFINITE_RECURSION.
John Baldwin [Wed, 21 Dec 2022 22:45:29 +0000 (14:45 -0800)]
Fix spelling of NO_WINFINITE_RECURSION.

Reported by: dim
Fixes: 2e08e4b75ea1 zfs: Fix build with GCC 12.

(cherry picked from commit 3266131908914b3a359571dae75194fe6d330c1d)

14 months agozfs: Fix build with GCC 12.
John Baldwin [Wed, 21 Dec 2022 18:49:23 +0000 (10:49 -0800)]
zfs: Fix build with GCC 12.

Silence -Winfinite-recursion for ldo.c in lua and -Wstringop-overread
for nvpair.c.

Reviewed by: mm
Differential Revision: https://reviews.freebsd.org/D37631

(cherry picked from commit 2e08e4b75ea1080c224a33baf62199d893dc322d)

14 months agoatp: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:33:56 +0000 (12:33 -0800)]
atp: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37552

(cherry picked from commit 4eda35b6360762b4a256c33321a917d4b3a5d625)

14 months agoif_rsu: Fix mismatches in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:33:41 +0000 (12:33 -0800)]
if_rsu: Fix mismatches in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37551

(cherry picked from commit 183783d34a6b453137f39eac8a7b42b338c9af60)

14 months agortwn: Fix mismatches in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:33:21 +0000 (12:33 -0800)]
rtwn: Fix mismatches in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37550

(cherry picked from commit 8bc615f5919f027cdf09825764276ab41a38375e)

14 months agoipfilter: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:32:38 +0000 (12:32 -0800)]
ipfilter: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, cy, emaste
Differential Revision: https://reviews.freebsd.org/D37548

(cherry picked from commit 415ccf51122eab7b55978a1db00b484a06ffc84b)

14 months agoaesni: Remove misleading array bounds for aesni_decryt_ecb.
John Baldwin [Wed, 7 Dec 2022 20:32:19 +0000 (12:32 -0800)]
aesni: Remove misleading array bounds for aesni_decryt_ecb.

All the other functions used pointers for from/to instead of
fixed-size array parameters.  More importantly, this function can
accept pointers to buffers of multiple blocks, not just a single
block.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37547

(cherry picked from commit d256a06fe8bda8120a3e22434c53fdef076001d3)

14 months agomlx5: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:32:54 +0000 (12:32 -0800)]
mlx5: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: hselasky, imp, emaste (earlier version)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D37549

(cherry picked from commit 47cc457bd6c16352b47d3fb1288f745482a082af)

14 months agonet80211: Fix mismatches in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:31:53 +0000 (12:31 -0800)]
net80211: Fix mismatches in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste (earlier version)
Differential Revision: https://reviews.freebsd.org/D37546

(cherry picked from commit 1f078120955947c85c54a8c088782ea5e4451eb5)

14 months agosys: Stop enabling -Wnested-externs.
John Baldwin [Wed, 22 Mar 2023 19:35:09 +0000 (12:35 -0700)]
sys: Stop enabling -Wnested-externs.

clang doesn't implement this warning, so violations are only caught by
GCC.  It is also no longer a common practice to use this as it was in
the original BSD code, so the need for the warning is not as important
as when it was used to do cleanups 20 years ago.  A recent commit
(c3179891f897d840f578a5139839fcacb587c96d) triggers this warning on
GCC, but that commit uses nested externs purposefully.

Reviewed by: markj, emaste
Differential Revision: https://reviews.freebsd.org/D39214

(cherry picked from commit 4ffeb3b88ed228e72e13abe1be888c77c6ede95d)

14 months agoocs: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:31:33 +0000 (12:31 -0800)]
ocs: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37545

(cherry picked from commit fb4a86164dc5ded5b42b7511d3bf48ae11ec891e)

14 months agoocs: Remove unused variable.
John Baldwin [Fri, 8 Apr 2022 00:01:27 +0000 (17:01 -0700)]
ocs: Remove unused variable.

(cherry picked from commit afda855350685d994f3fa5702079ce782563ee8f)

14 months agomalo: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:31:16 +0000 (12:31 -0800)]
malo: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37544

(cherry picked from commit 8b45e0c180114e1059767d0920ad6e6bfdeb37ce)

14 months agoiwi: Fix mismatch in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:31:01 +0000 (12:31 -0800)]
iwi: Fix mismatch in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37543

(cherry picked from commit f322a6cef0b142bd65c3750139ea1801513b864a)

14 months agoiwi: Remove write-only status variable.
John Baldwin [Wed, 6 Apr 2022 23:45:27 +0000 (16:45 -0700)]
iwi: Remove write-only status variable.

Skip over unused field from asresp frame header.

(cherry picked from commit 99f65e9198c89e96f935986300b8ee3605d1349f)

14 months agoath: Fix mismatches in array bounds.
John Baldwin [Wed, 7 Dec 2022 20:30:42 +0000 (12:30 -0800)]
ath: Fix mismatches in array bounds.

Reported by: GCC -Warray-parameter
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37542

(cherry picked from commit c1ebd4c98fb8feab6931a536390739fc115e1805)

14 months agoDisable -Wzero-length-bounds for the kernel for GCC 12.
John Baldwin [Wed, 21 Dec 2022 18:47:08 +0000 (10:47 -0800)]
Disable -Wzero-length-bounds for the kernel for GCC 12.

The mlx5 driver and some other OFED bits use a somewhat dubious
pattern of:

  struct foo {
      uint64_t arg[0];
      /* Real members of a struct */
  };

The code then treats 'arg' as if it were really a kind of union
such that foo.arg[N] functions similarly to (uint64_t *)foo[N].
This uses of foo.arg[N] then trigger this warning.

No real bugs were found by this warning though, so just turn it off
globally.

Reviewed by: hselasky, kib
Differential Revision: https://reviews.freebsd.org/D37630

(cherry picked from commit 1aa6d44decb33ce3eab0efe5336b75fa2dfa3733)

14 months agoDisable -Wdangling-pointer for the kernel for GCC 12.
John Baldwin [Wed, 21 Dec 2022 18:46:26 +0000 (10:46 -0800)]
Disable -Wdangling-pointer for the kernel for GCC 12.

Some of the warnings raised in the kernel seem to be outright bugs in
the compiler (e.g. the cases in ata_xpt.c and scsi_xpt.c).  Other
cases are not fatal and it didn't seem to find any legitimate bugs in
the kernel.

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

(cherry picked from commit 2637ed558baacdab7a8cf789dca713bde5843e43)

14 months agoiee80211_hwmp: Don't dereference NULL ni in debug printf.
John Baldwin [Wed, 21 Dec 2022 18:45:45 +0000 (10:45 -0800)]
iee80211_hwmp: Don't dereference NULL ni in debug printf.

In this call to IEEE80211_NOTE, ni is always NULL due to the assignment
a few lines earlier at the start of the function.  If debug traces are
enabled, then this will pass an invalid pointer as the 'mac' pointer to
ieee80211_note_mac.  Use IEEE80211_DPRINTF which doesn't take a 'ni'
argument instead.

Reported by: GCC -Wstringop-overread
Reviewed by: bz, emaste
Differential Revision: https://reviews.freebsd.org/D37626

(cherry picked from commit 95d146592f5ee3fa998496713f28475e65996ff9)

14 months agomrsas: Don't leak a stack pointer value in the softc.
John Baldwin [Wed, 21 Dec 2022 18:45:26 +0000 (10:45 -0800)]
mrsas: Don't leak a stack pointer value in the softc.

mrsas_issue_blocked_cmd stores a pointer to an on-stack variable
in its softc so that the driver can call wakeup() on the correct
pointer.  Once the loop around tsleep() has finished however, the
pointer is no longer needed and any further use would be invalid.
Clear sc->chan to NULL after the loop.

Reported by: GCC -Wdangling-pointer
Differential Revision: https://reviews.freebsd.org/D37628

(cherry picked from commit 9f0c0e6eede6aedb60e12888fc9751c40b364dc9)

14 months agoDisable errors for -Wnonnull for the kernel for GCC 12.
John Baldwin [Wed, 21 Dec 2022 18:46:06 +0000 (10:46 -0800)]
Disable errors for -Wnonnull for the kernel for GCC 12.

The USB code and some other places raise false positives when a NULL
pointer is passed to an inlined function along with a separate length
and the compiler can't determine that the separate length of 0
prevents the use of the NULL pointer.

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

(cherry picked from commit 488c498b099e3f48db4048833d2b0d03d7bed3e1)

14 months agoMove NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.
John Baldwin [Mon, 14 Mar 2022 21:05:25 +0000 (14:05 -0700)]
Move NO_WUNUSED_BUT_SET_VARIABLE clang helper to the right place.

Reviewed by: imp, dim, emaste
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D34537

(cherry picked from commit 2814ba8ef17aa647fa52092106731bcf76a2392d)

14 months agobhyve: Don't return -ENOMEM from qemu_fwcfg_add_file.
John Baldwin [Wed, 22 Mar 2023 19:34:56 +0000 (12:34 -0700)]
bhyve: Don't return -ENOMEM from qemu_fwcfg_add_file.

Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D39212

(cherry picked from commit 7bf44831ca05c67169fd90408b514573ddbbcf9d)

14 months agobhyve: Accept a variable-length string name for qemu_fwcfg_add_file.
John Baldwin [Wed, 22 Mar 2023 19:34:34 +0000 (12:34 -0700)]
bhyve: Accept a variable-length string name for qemu_fwcfg_add_file.

It is illegal (UB?) to pass a shorter array to a function argument
that takes a fixed-length array.  Do a runtime check for names that
are too long via strlen() instead.

Reviewed by: markj
Reported by: GCC -Wstringop-overread
Differential Revision: https://reviews.freebsd.org/D39211

(cherry picked from commit 61482760a0ca198a9310d450133e9ac792b67955)

14 months agoacpica: Quiet a -Wdangling-pointer warning in AcpiUtInitStackPtrTrace.
John Baldwin [Mon, 5 Dec 2022 00:28:59 +0000 (16:28 -0800)]
acpica: Quiet a -Wdangling-pointer warning in AcpiUtInitStackPtrTrace.

This function intentionally saves a pointer to an on-stack variable in
a global as a dubious way of reading the stack pointer.

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

(cherry picked from commit f4432625edd64df94ce7c2a085f256dbc4d2b215)

14 months agopw: Don't return a pointer to an on-stack buffer from grp_set_passwd.
John Baldwin [Mon, 5 Dec 2022 00:28:22 +0000 (16:28 -0800)]
pw: Don't return a pointer to an on-stack buffer from grp_set_passwd.

Make 'line' static to move it to .bss instead as that pattern is used
elsewhere in pw(8) (e.g. the static buffer in pw_pwcrypt).

Reported by: GCC -Wdangling-pointer
Reviewed by: imp, emaste
Differential Revision: https://reviews.freebsd.org/D37534

(cherry picked from commit 1055bedbed42dc176468b45b4f167a752ed8868f)

14 months agofwcontrol: Disable -Wzero-length-bounds warnings.
John Baldwin [Mon, 5 Dec 2022 00:30:20 +0000 (16:30 -0800)]
fwcontrol: Disable -Wzero-length-bounds warnings.

firewire.h includes zero length arrays in unions that trigger this
warning.

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

(cherry picked from commit aa9ce62be54fd9a022b770d36fb1e4f24bfcd223)

14 months agobsd.sys.mk: Add NO_WZERO_LENGTH_BOUNDS helper variable.
John Baldwin [Mon, 5 Dec 2022 00:29:55 +0000 (16:29 -0800)]
bsd.sys.mk: Add NO_WZERO_LENGTH_BOUNDS helper variable.

This variable expands to -Wno-zero-length-bounds on GCC 10+.

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

(cherry picked from commit 9134d9265c54a02257292c32b2144c401a86678f)

14 months agorpcgen: Unindent a line not guarded by if (mtflag).
John Baldwin [Mon, 5 Dec 2022 00:32:03 +0000 (16:32 -0800)]
rpcgen: Unindent a line not guarded by if (mtflag).

mtflag is used to add pthread mutex locking around operations to make
them thread-safe.  Setting the state to _SERVED is not conditional on
locking.

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

(cherry picked from commit 4fa1e855be60f2c95005edb295fdc36cc163ff6b)

14 months agorpcgen: Don't free() a pointer after realloc().
John Baldwin [Mon, 5 Dec 2022 00:31:35 +0000 (16:31 -0800)]
rpcgen: Don't free() a pointer after realloc().

A successful realloc() already frees the old pointer.

Reported by: GCC -Wuse-after-free
Reviewed by: brooks, imp, emaste
Differential Revision: https://reviews.freebsd.org/D37540

(cherry picked from commit f0b58b190107416e813c5db875034c6cfcede523)

14 months agolibsa: Disable -Wdangling-pointer for zfs.c.
John Baldwin [Mon, 5 Dec 2022 00:27:22 +0000 (16:27 -0800)]
libsa: Disable -Wdangling-pointer for zfs.c.

GCC 12 warns about a dangling pointer to 'objid' in
zfs_bootenv_initial().  However, this appears to be a false positive
as the pointer to 'objid' is only passed to zfs_lookup_dataset() but
not saved anywhere that outlives the lifetime of the
zfs_bootenv_initial() function.

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

(cherry picked from commit 0163de282e3195a1845f75b486adb3e1e7580199)

14 months agobsd.sys.mk: Add NO_WDANGLING_POINTER helper variable.
John Baldwin [Mon, 5 Dec 2022 00:26:48 +0000 (16:26 -0800)]
bsd.sys.mk: Add NO_WDANGLING_POINTER helper variable.

This variable expands to -Wno-dangling-pointer on GCC 12+.

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

(cherry picked from commit ad96424e31a8c8c87fac8077fd4304c6fb133e25)

14 months agoExplicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.
John Baldwin [Wed, 30 Nov 2022 22:56:19 +0000 (14:56 -0800)]
Explicitly set CXXSTD to c++11 for old C++ code using std::auto_ptr<>.

GCC 12 defaults to C++17 which removes (not just deprecates)
std::auto_ptr<>.  Trying to use CXXSTD of c++03 doesn't work with
libc++ headers, but c++11 does.

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

(cherry picked from commit 42fb28cef42e883d808c9efadd44016563248817)

14 months agolibefivar: Fix a buffer overread.
John Baldwin [Mon, 3 Oct 2022 23:10:44 +0000 (16:10 -0700)]
libefivar: Fix a buffer overread.

DevPathToTextUsbWWID allocates a separate copy of the SerialNumber
string to append a null terminator if the original string is not
null terminated.  However, by using AllocateCopyPool, it tries to
copy 'Length + 1' words from the existing string containing 'Length'
characters into the target string.  Split the copy out to only
copy 'Length' characters instead.

Reviewed by: imp, emaste
Reported by: GCC 12 -Wstringop-overread
Differential Revision: https://reviews.freebsd.org/D36826

(cherry picked from commit d30a1689f5b37e78ea189232a8b94a7011dc0dc8)

14 months agoSilence GCC warnings when using libc++ headers.
John Baldwin [Wed, 30 Nov 2022 22:50:35 +0000 (14:50 -0800)]
Silence GCC warnings when using libc++ headers.

GCC 12 raises warnings about literal operator suffixes not preceded by
'_' in libc++ headers such as <string_view> as it doesn't recognize
libc++ headers being an implementation of the standard.

GCC 12 also warns about clang-specific pragmas in <locale>.

Disabling these warnings globally for all C++ code is not ideal, but
is a better option than patching libc++ headers to ignore these
warnings.

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

(cherry picked from commit 442295c1fe84b4dc3e4834acdbf4ede75affe3c4)

14 months agoUse __freebsd_kprintf__ with GCC 12+ similar to clang.
John Baldwin [Tue, 22 Nov 2022 16:36:12 +0000 (08:36 -0800)]
Use __freebsd_kprintf__ with GCC 12+ similar to clang.

(cherry picked from commit 5115511ed4941684bc82b8a3c4b95e9a8931b940)

14 months agolibirdma: Drop clang-specific -ferror-limit.
John Baldwin [Mon, 3 Oct 2022 23:10:42 +0000 (16:10 -0700)]
libirdma: Drop clang-specific -ferror-limit.

This could use -fmax-errors on GCC, but tweaking the error limit is
unusual in the tree anyway.  Just remove it.

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

(cherry picked from commit c3a3d1fd6c7007e7088936e14fd9b4944b3a3054)

14 months agoncurses: Backport a few fixes for GCC warnings from version 6.2-20210220.
John Baldwin [Tue, 2 May 2023 23:38:54 +0000 (16:38 -0700)]
ncurses: Backport a few fixes for GCC warnings from version 6.2-20210220.

This is a direct commit to stable/13.

14 months agolibpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.
John Baldwin [Thu, 23 Mar 2023 16:31:29 +0000 (09:31 -0700)]
libpmc: Use LIB_CXX instead of explicit LDADD to link a C++ library.

This uses the C++ compiler as the linker instead of the C compiler
letting the compiler driver pick the right libraries.  This is a no-op
on main and stable/13 but matters for stable/12 where the current
logic breaks for external GCC since it tries to use a non-existent
libstdc++.

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

(cherry picked from commit c6b3f47fedd3f94f74cc4f7c40761b1d0e777f17)

14 months agompr: don't use hardcoded value in debug branch
Mariusz Zaborski [Fri, 21 Apr 2023 07:57:38 +0000 (09:57 +0200)]
mpr: don't use hardcoded value in debug branch

Pointed out by: imp
Sponsored by:   Klara Inc.

(cherry picked from commit 444c6615459efe2b015deb1cffc54fcaa3ea1fca)

14 months agompr: fix copying of event_mask
Mariusz Zaborski [Fri, 21 Apr 2023 07:50:16 +0000 (09:50 +0200)]
mpr: fix copying of event_mask

Before the commit 6cc44223cb6717795afdac4348bbe7e2a968a07d the
field event_mask was fully copied to the EventMasks field.
After this commit the event_mask (uint8_t) is 4 times casted to
EventMask (uint32_t). Because of that 24 bits of each event_mask array
is lost.

This commits brings back simple copying of field, and after words
converting 32 bits field to the requested endian.

I don't think we need more sophisticated method,
as the array is of size 4 (for 32 bits version).

Reviewed by: imp
MFC after: 1 week
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D39562

(cherry picked from commit ea6597c38c77c7bfaae71259d8636cbb89add6a3)

14 months agoipv6: disable RFC 4620 nodeinfo by default
Ed Maste [Mon, 24 Apr 2023 19:41:45 +0000 (15:41 -0400)]
ipv6: disable RFC 4620 nodeinfo by default

RFC 4620 is an experimental RFC that can be used to request information
about a host, including:

- the fully-qualified or single-component name
- some set of the Responder's IPv6 unicast addresses
- some set of the Responder's IPv4 unicast addresses

This is not something that should be made available by default.

PR: 257709
Submitted by: ruben@verweg.com
Reviewed by: melifaro
Relnotes: Yes
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D39778

(cherry picked from commit b73183d1a243d486e3889bd71800e94812f5fa17)

14 months agogeom: use bool for one-bit wide bit-field
Ed Maste [Mon, 17 Apr 2023 18:56:51 +0000 (14:56 -0400)]
geom: use bool for one-bit wide bit-field

A one-bit wide bit-field can take only the values 0 and -1.  Clang 16
introduced a warning that "implicit truncation from 'int' to a one-bit
wide bit-field changes value from 1 to -1".  Fix by using c99 bool.

Reported by: Clang, via dim
Reviewed by: dim
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 00172f341666f2d5535ae6f4630c93593e86a4cb)

14 months agosys/fs: do not report blocks allocated for synthetic file systems
Stefan Eßer [Tue, 25 Apr 2023 07:40:05 +0000 (09:40 +0200)]
sys/fs: do not report blocks allocated for synthetic file systems

The pseudo file systems (devfs, fdescfs, procfs, etc.) report total
and available blocks and inodes despite being synthetic with no
underlying storage device to which those values could be applied.

The current code of these file systems tends to report a fixed number
of total blocks but no free blocks, and in the case of procfs,
libprocfs, linsysfs also no free inodes.

This can be irritating in e.g. the "df" output, since 100% of the
resources seem to be in use, but it can also create warnings in
monitoring tools used for capacity management.

This patch makes these file systems return the same value for the
total and free parameters, leading to 0% in use being displayed by
"df". Since there is no resource that can be exhausted, this appears
to be a sensible result.

Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D39442

(cherry picked from commit 88a795e80c03ff1d960d830ee273589664ab06cc)

14 months agomsdosfs: fix debug print format and parameter
Stefan Eßer [Wed, 8 Mar 2023 16:58:00 +0000 (17:58 +0100)]
msdosfs: fix debug print format and parameter

Building with -DMSDOSFS_DEBUG failed due to a format mismatch and
a variable that has been renamed but not updated in the printf()
parameter list.

(cherry picked from commit 2d8cf575d5778781928699f9b7cfb448bd2f1f8e)

fs/msdosfs: add tracking of free root directory entries

This update implements tallying of free directory entries during
create, delete, or rename operations on FAT12 and FAT16 file systems.

Prior to this change, the total number of root directory entries
was reported as number of inodes, but 0 as the number of free
inodes, causing system health monitoring software to warn about
a suspected disk full issue.

The FAT12 and FAT16 file systems provide a limited number of
root directory entries, e.g. 512 on typical hard disk formats.
The valid range of values is 1 to 65535, but the msdosfs code
will effectively round up "odd" values to the next multiple of 16
(e.g. 513 would allow for 528 root directory entries).

This update implements tracking of directory entries during create,
delete, or rename operations, with initial values determined by
scanning the directory when the file system is mounted.

Total and free directory entries are reported in the f_files and
f_ffree elements of struct statfs, despite differences in semantics
of these values:

- There is no limit on the number of files and directories that can
  be created on a FAT file system. Only the root directory of FAT12
  and FAT16 file systems is limited, any number of files can still be
  created in sub-directories, even when 0 free "inodes" are reported.

- A single file can require 1 to 21 directory entries, depending on
  the character set, structure, and length of the name. The DOS 8.3
  style file name takes up 1 entry, and if the name does not comply
  with the syntax of a DOS 8.3 file name, 1 additional entry is used
  for each 13 characters of the file name. Since all these entries
  have to be contiguous, it is possible that a file or directory with
  a long name can not be created, despite a sufficient total number of
  free directory entries.

- Renaming a file can require more directory entries than currently
  allocated to store its long name, which may prevent an in-place
  update of the name if more entries are needed. This may cause a
  rename operation to fail if no contiguous range of free entries for
  the new name can be found.

- The volume label is stored in a directory entry. An empty FAT file
  system with a volume label will therefore show 1 used "inode" in
  df.

- The perceentage of free inodes shown in df or monitoring tools does
  only represent the state of the root directory of a FAT12 or FAT16
  file system. Neither does a reported value of 0% free inodes does
  prevent files from being created in sub-directories, nor does a
  value of 50% free inodes guarantee that even a single file with
  a "long" name can be created in the root directory (if every other
  directory entry is occupied and there are no 2 contiguous entries).

The statfs(2) and df(1) man pages have been updated with a notice
regarding the possibly different semantics of values reported as
total and free inodes for non-Unix file systems.

PR: 270053
Reported by: Ben Woods <woodsb02@freebsd.org>
Approved by: mckusick
Differential Revision: https://reviews.freebsd.org/D38987

(cherry picked from commit c33db74b5323480fba7adef58e8aa88f6091d134)

fs/msdosfs: Fix potential panic and size calculations

Some combinations of FAT12 file system parameters could cause a kernel
panic due to an unmapped access if the size of the FAT was larger than
the CPU page size. The reason is that FAT12 uses 3 bytes to store
2 FAT pointers, leading to partial FAT pointers at the end of buffers
of a size that is not a multiple of 3.

With a typical page size of 4 KB, this caused the FAT entry at byte
offsets 4095 and 4096 to cross the page boundary, with only the first
page mapped. This was fixed by adjusting the mapping to always cover
both bytes of each FAT entry.

Testing revealed 2 other inconsistencies that are fixed by this commit:

1) The calculation of the size of the data area did not take into
   account the fact that the first two data block numbers are reserved
   and that the data area starts with block 2. This could cause a
   FAT12 file system created with the maximum supported number of
   blocks to be incorrectly identified as FAT16.

2) The root directory does not take up space in the data area of a
   FAT12 or FAT16 file system, since it is placed into a reserved
   area outside of that data area. This commits makes stat() report
   the logical size of the root directory, but with 0 blocks allocated
   from the data area.

PR: 270587
Reviewed by: mckusick
Differential Revision: https://reviews.freebsd.org/D39386

(cherry picked from commit 0728695c63efda298feccefb3615c23cb6682929)

14 months agovn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error
Olivier Certner [Mon, 24 Apr 2023 09:36:09 +0000 (11:36 +0200)]
vn_open_vnode(): fix locking around VOP_CLOSE() on advisory lock error

(cherry picked from commit 6a5e61401502288ec10629beb28be048c1cce34a)

14 months agolookup(): ensure that openat("/", "..", O_RESOLVE_BENEATH) fails
Konstantin Belousov [Sun, 23 Apr 2023 23:21:42 +0000 (02:21 +0300)]
lookup(): ensure that openat("/", "..", O_RESOLVE_BENEATH) fails

PR: 269780

(cherry picked from commit a718431c30a57226bc7c1a9181fc84bab00641a1)

14 months agosqlite3: Vendor import of sqlite3 3.41.2
Cy Schubert [Mon, 17 Apr 2023 16:02:41 +0000 (09:02 -0700)]
sqlite3: Vendor import of sqlite3 3.41.2

Release notes at https://www.sqlite.org/releaselog/3_41_2.html.

Obtained from:  https://www.sqlite.org/2023/sqlite-autoconf-3410200.tar.gz

Merge commit '853a43f7c79218855a6e45a25a00b942972e3fa1'

(cherry picked from commit e7e621f94d9073d620a4d15f13952f1d40685ece)

14 months agomlx4: purge EOL release compatibility
Elliott Mitchell [Thu, 23 Jun 2022 00:53:47 +0000 (17:53 -0700)]
mlx4: purge EOL release compatibility

Remove FreeBSD 10 support code.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560

(cherry picked from commit 026babd427e6511e53478814ce0aa1cc3f7a9988)

14 months agolibc: Add missing object size check to qsort_s(3)
Hans Petter Selasky [Wed, 19 Apr 2023 10:22:11 +0000 (12:22 +0200)]
libc: Add missing object size check to qsort_s(3)

When sorting, both the C11 standard (ISO/IEC 9899:2011, K.3.6.3.2) and
the ISO/IEC JTC1 SC22 WG14 N1172 standard, does not define objects of
zero size as undefined behaviour. However Microsoft's cpp-docs does.

Add proper checks for this. Found while working on bsort(3).

Reviewed by: kib@ and emaste@
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D39687

(cherry picked from commit 27bb0d337c0d82a1a4f310315840236eb239963c)

14 months agolibc: Sorting is not needed when there are less than two elements
Hans Petter Selasky [Wed, 19 Apr 2023 10:18:56 +0000 (12:18 +0200)]
libc: Sorting is not needed when there are less than two elements

If there are less than two elements avoid executing the first
sorting loop. No functional change intended.

Reviewed by: kib@
Sponsored by: NVIDIA Networking
Differential Revision: https://reviews.freebsd.org/D39691

(cherry picked from commit ecb2ce3a51e9b09a57cd42262fc798ae089c0758)

14 months agomlx5: Remove unused debugfs node pointers.
Hans Petter Selasky [Tue, 18 Apr 2023 11:40:22 +0000 (13:40 +0200)]
mlx5: Remove unused debugfs node pointers.

No functional change intended.

Sponsored by: NVIDIA Networking

(cherry picked from commit 80b4ef6d10544d30b6cfeddca12ae28d81816201)

14 months agomlx5: Don't give zero number of pages to the firmware.
Hans Petter Selasky [Tue, 18 Apr 2023 11:22:41 +0000 (13:22 +0200)]
mlx5: Don't give zero number of pages to the firmware.

Can happen when using virtual mlx5_core<N> functions, VFs.

Sponsored by: NVIDIA Networking

(cherry picked from commit 95bf70a4bf7982091bb59200bc2db2cb5cd840d7)

14 months agomlx5: Implement mlx5_core_modify_cq_by_mask().
Hans Petter Selasky [Tue, 18 Apr 2023 11:21:28 +0000 (13:21 +0200)]
mlx5: Implement mlx5_core_modify_cq_by_mask().

Implement one CQ modify function supporting all firmware versions,
instead of having more variants of CQ modify.

Sponsored by: NVIDIA Networking

(cherry picked from commit 273bfac08ff838786c8b48bc7d3d7180b5f6a3be)

14 months agomlx5: Make MLX5_COMP_EQ_SIZE tunable.
Hans Petter Selasky [Tue, 18 Apr 2023 11:11:02 +0000 (13:11 +0200)]
mlx5: Make MLX5_COMP_EQ_SIZE tunable.

When using hardware pacing, this value can be increased, because more SQ's
means more EQ events aswell. Make it tunable, hw.mlx5.comp_eq_size .

Sponsored by: NVIDIA Networking

(cherry picked from commit 3bb3e4768ff854b88ba0a7d129edad49f15d7ce3)

14 months agomlx5: Fix duplicate free of default flow rule in error case.
Hans Petter Selasky [Tue, 18 Apr 2023 11:17:38 +0000 (13:17 +0200)]
mlx5: Fix duplicate free of default flow rule in error case.

Sponsored by: NVIDIA Networking

(cherry picked from commit 2f7e9a8a21367393b613f0f150d49009fa74dd5c)

14 months agomlx5: Make mlx5_del_flow_rule() NULL safe.
Hans Petter Selasky [Tue, 18 Apr 2023 11:16:16 +0000 (13:16 +0200)]
mlx5: Make mlx5_del_flow_rule() NULL safe.

This change factors out repeated NULL checks.

No functional change intended.

Sponsored by: NVIDIA Networking

(cherry picked from commit b0b87d9151456e71fd6a14736e132d67114db4aa)

14 months agomlx5en(4): Don't wait for receive queue to fill up with mbufs during open channels.
Hans Petter Selasky [Tue, 18 Apr 2023 11:42:17 +0000 (13:42 +0200)]
mlx5en(4): Don't wait for receive queue to fill up with mbufs during open channels.

Failure to get mbufs may be transient.
Don't permanently fail to open the channels due to lack of mbufs.
This also makes modifying channel parameters faster.

Sponsored by: NVIDIA Networking

(cherry picked from commit 1943c40cd655b7259b9b21849f328362c97a2657)

14 months agomlx5en(4): Explain why CQE zipping is off.
Hans Petter Selasky [Tue, 18 Apr 2023 11:12:32 +0000 (13:12 +0200)]
mlx5en(4): Explain why CQE zipping is off.

Sponsored by: NVIDIA Networking

(cherry picked from commit 6bd4bb9bdbadb76c5502c7972df9f525b909e2f5)

14 months agomlx5: Implement diagostic counters as sysctl(8) nodes.
Hans Petter Selasky [Tue, 18 Apr 2023 11:38:59 +0000 (13:38 +0200)]
mlx5: Implement diagostic counters as sysctl(8) nodes.

Sponsored by: NVIDIA Networking

(cherry picked from commit aa7bbdabde890676d54a22eeec3af9b7681d19b7)

14 months agoImplement an API for sending a zero-length-packet. The purpose of such a
Hans Petter Selasky [Tue, 6 Jul 2021 10:29:57 +0000 (12:29 +0200)]
Implement an API for sending a zero-length-packet. The purpose of such a
USB packet is to toggle the binary packet counter for USB 1.0/2.0 protocols,
without sending any data, so that the first packet sent after opening
a USB BULK endpoint doesn't get lost. This is for devices not supporting
the USB standard defined clear-stall handling.

Tested by: jmg
Sponsored by: NVIDIA Networking

(cherry picked from commit f83f5d58394db57576bbed6dc7531997cabeb102)
(cherry picked from commit ec97e9ca1fa543a4a803e84706564d41cd492065)

14 months agousb: tiny formatting nit
Warner Losh [Thu, 11 Mar 2021 15:23:32 +0000 (08:23 -0700)]
usb: tiny formatting nit

Format 300 baud like all the others here. No functional change.

(cherry picked from commit 1645a4ae645fa9b9e3571b7512caa92e73b20635)

14 months agoulpt(4): Add support for Epson TM-U220B.
Hans Petter Selasky [Sat, 2 Apr 2022 00:27:48 +0000 (02:27 +0200)]
ulpt(4): Add support for Epson TM-U220B.

Submitted by: Archimedes Gaviola <archimedes.gaviola@gmail.com>
Sponsored by: NVIDIA Networking

(cherry picked from commit 88162f7abd61206c98432f2c0de869a59be13854)

14 months agoMake sure the uftdi(4) driver doesn't start a USB transfer when being cancelled.
Hans Petter Selasky [Wed, 18 Aug 2021 09:41:49 +0000 (11:41 +0200)]
Make sure the uftdi(4) driver doesn't start a USB transfer when being cancelled.

Sponsored by: NVIDIA Networking

(cherry picked from commit 8a46f021c2408c82375a1f5127efb7ac6b78596e)