]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
16 months agolinuxkpi: Update `ww_mutex_trylock()` API for Linux 5.16
Jean-Sébastien Pédron [Mon, 13 Feb 2023 22:22:54 +0000 (23:22 +0100)]
linuxkpi: Update `ww_mutex_trylock()` API for Linux 5.16

It gains new `struct ww_acquire_ctx *` argument we don't use currently.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38568

(cherry picked from commit e6f7fe74a903b4085d60b0054ff75ee677beaf76)

16 months agolinuxkpi: Declare `struct fwnode_handle` in <linux/fwnode.h>
Jean-Sébastien Pédron [Mon, 13 Feb 2023 20:51:00 +0000 (21:51 +0100)]
linuxkpi: Declare `struct fwnode_handle` in <linux/fwnode.h>

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38566

(cherry picked from commit 7d03acf065ed96fd04a54bf8e1c83a032ffed097)

16 months agolinuxkpi: Add `synchronize_shrinkers()`
Jean-Sébastien Pédron [Mon, 13 Feb 2023 20:49:28 +0000 (21:49 +0100)]
linuxkpi: Add `synchronize_shrinkers()`

It takes the lock and release it immediately to make sure no shrinkers
are running in parallel.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38565

(cherry picked from commit 83636727291714c235726da987a02c5b1d51bb54)

16 months agolinuxkpi: Accept NULL as a value in `linux_xarray`
Jean-Sébastien Pédron [Sat, 11 Feb 2023 10:12:08 +0000 (11:12 +0100)]
linuxkpi: Accept NULL as a value in `linux_xarray`

Linux' XArray allows to store a NULL pointer as a value. `xa_load()`
would return NULL for both an unused index and an index set to NULL. But
it impacts `xa_alloc()` which needs to find the next available index.

However, our implementation relies on a radix tree (see `linux_radix.c`)
which does not accept NULL pointers as values. I'm not sure if this is a
limitation or a feature, so to work around this, a NULL value is
replaced by `NULL_VALUE`, an unlikely address, when we pass it to
linux_radix.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38543

(cherry picked from commit 3102ea3b15b6c3ed1ea50716d65980b680375ebc)

16 months agolinuxkpi: Define `cpu_data(cpu)`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 15:38:43 +0000 (16:38 +0100)]
linuxkpi: Define `cpu_data(cpu)`

`cpu_data(cpu)` evaluates to a `struct cpuinfo_x86` filled with
attributes of the given CPU number. The CPU number is an index in the
`__cpu_data[]` array with MAXCPU entries. On FreeBSD, we simply
initialize all of them like we do with `boot_cpu_data`.

While here, we add the `x86_model` field to the `struct cpuinfo_x86`. We
use `CPUID_TO_MODEL()` to set it.

At the same time, we fix the value of `x86` which should have been set
to the CPU family. It was using the same implementation as
`CPUID_TO_MODEL()` before. It now uses `CPUID_TO_FAMILY()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38542

(cherry picked from commit a27902c1838836b3fb00cd660ce37a4f20bd7991)

16 months agolinuxkpi: Add `sg_alloc_table_from_pages_segment()`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 15:37:31 +0000 (16:37 +0100)]
linuxkpi: Add `sg_alloc_table_from_pages_segment()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38541

(cherry picked from commit f3490083b731700f2aa7c17ac6fe159826dc59a5)

16 months agolinuxkpi: Add <linux/stdarg.h> + include it from <linux/string.h>
Jean-Sébastien Pédron [Fri, 10 Feb 2023 10:52:12 +0000 (11:52 +0100)]
linuxkpi: Add <linux/stdarg.h> + include it from <linux/string.h>

The <stdarg.h> header was moved in Linux 5.15.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38540

(cherry picked from commit d91cf060205cfe479675d7fb4ec95d2ed6a9b76c)

16 months agolinuxkpi: Define `IRQ_NOTCONNECTED`
Jean-Sébastien Pédron [Fri, 10 Feb 2023 10:26:17 +0000 (11:26 +0100)]
linuxkpi: Define `IRQ_NOTCONNECTED`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38539

(cherry picked from commit 210e756d4b32f43e8cc5f748456158757892a46a)

16 months agolinuxkpi: Define `lockdep_assert{,_once}()`
Jean-Sébastien Pédron [Thu, 9 Feb 2023 22:04:26 +0000 (23:04 +0100)]
linuxkpi: Define `lockdep_assert{,_once}()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38538

(cherry picked from commit b82bcfb66fa5ef30939f3f5169a07bf4bc139e71)

16 months agolinuxkpi: Move definition of `struct list_head` to <linux/types.h>
Jean-Sébastien Pédron [Thu, 9 Feb 2023 12:11:34 +0000 (13:11 +0100)]
linuxkpi: Move definition of `struct list_head` to <linux/types.h>

This is the case on Linux.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38537

(cherry picked from commit 54606590dffcd23136af1c26da38206f4d3a6269)

16 months agolinuxkpi: Define `FIELD_FIT()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 23:38:22 +0000 (00:38 +0100)]
linuxkpi: Define `FIELD_FIT()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38536

(cherry picked from commit bf6f6650813959ecf3469854ad266c5a5590c754)

16 months agolinuxkpi: Add `i2c_adapter_quirks` support
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:57:32 +0000 (18:57 +0100)]
linuxkpi: Add `i2c_adapter_quirks` support

While here, also declare `I2C_CLASS_HWMON`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38535

(cherry picked from commit 83276e1f952d720c23092ea17e95c03fef8476b7)

16 months agolinuxkpi: Define `xa_is_err()`, `xa_{store,erase}_irq()` and `xa_{,un}lock_irq*()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:55:29 +0000 (18:55 +0100)]
linuxkpi: Define `xa_is_err()`, `xa_{store,erase}_irq()` and `xa_{,un}lock_irq*()`

`xa_is_err()` is synonymous to `IS_ERR()`.

Other introduced functions call their equivalent without the `irq*`
suffix.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38534

(cherry picked from commit 5542309ec6eba3af9e26c50acd654de462181b8e)

16 months agolinuxkpi: Update `vga_client_register()` and add `vga_client_unregister()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:53:57 +0000 (18:53 +0100)]
linuxkpi: Update `vga_client_register()` and add `vga_client_unregister()`

For `vga_client_register()`, the API is modified twice in a row. To keep
the API compatible with all commits in the DRM driver, we introduce two
`LINUXKPI_VERSION` version bumps.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38533

(cherry picked from commit 1c6d8146fdec8267712615c261bf6c8800f8ecfe)

16 months agolinuxkpi: Declare missing `DMI_*` enum entries
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:53:23 +0000 (18:53 +0100)]
linuxkpi: Declare missing `DMI_*` enum entries

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38532

(cherry picked from commit cf5416908658ed0e4f2ae72916dfe1a84d7fd61c)

16 months agolinuxkpi: Define `backlight_get_brightness()` and `backlight_is_blank()`
Jean-Sébastien Pédron [Wed, 8 Feb 2023 17:51:16 +0000 (18:51 +0100)]
linuxkpi: Define `backlight_get_brightness()` and `backlight_is_blank()`

This is not used by the DRM driver yet because we comment out the code
calling them, but they are easy to implement.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38530

(cherry picked from commit a82a8a5e193587d819288c3c27f1c9472178e10e)

16 months agolinuxkpi: list_sort()'s callback now takes list arguments
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:22:07 +0000 (23:22 +0100)]
linuxkpi: list_sort()'s callback now takes list arguments

This change breaks the API of `list_sort()`. `LINUXKPI_VERSION >= 51300`
is used to keep the header compatible with both versions of the
prototype.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38082

(cherry picked from commit a83b3ec719eb6c53658656b7b90607564d3c64d3)

16 months agolinuxkpi: Define `dev_is_platform()` and `to_platform_device()`
Jean-Sébastien Pédron [Sun, 22 Jan 2023 13:46:54 +0000 (14:46 +0100)]
linuxkpi: Define `dev_is_platform()` and `to_platform_device()`

The former returns false and the latter returns NULL.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38163

(cherry picked from commit b9ef0689433d7d08c96695e571c4c262a3ac9007)

16 months agolinuxkpi: Try to solve headers dependencies
Jean-Sébastien Pédron [Fri, 20 Jan 2023 18:08:39 +0000 (19:08 +0100)]
linuxkpi: Try to solve headers dependencies

I'm sure I got it wrong but at least the DRM drivers compile.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38157

(cherry picked from commit 11aaefc9ca8537be0ea5f62a5927dd39a6109e4f)

16 months agolinuxkpi: Add `io_mapping_map_local_wc()` and `io_mapping_unmap_local()`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:53:49 +0000 (18:53 +0100)]
linuxkpi: Add `io_mapping_map_local_wc()` and `io_mapping_unmap_local()`

`io_mapping_map_local_wc()` is synonymous to `io_mapping_map_atomic_wc()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38156

(cherry picked from commit 29d0c85c86347cd3eafe3c8974c693abf8d9ca51)

16 months agolinuxkpi: Add `kmap_local_page_prot()` and `kunmap_local()`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:52:39 +0000 (18:52 +0100)]
linuxkpi: Add `kmap_local_page_prot()` and `kunmap_local()`

They are synonymous to `kmap_atomic_prot()` and `kunmap_atomic()`
respectively.

While here, fix several style(9) issues.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38155

(cherry picked from commit 9dafbd0c69a6aade69b23a649548b6c7133f1091)

16 months agolinuxkpi: Add <linux/pgtable.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:50:39 +0000 (18:50 +0100)]
linuxkpi: Add <linux/pgtable.h>

For now, it's empty. It is included by the DRM drivers but nothing is
missing otherwise. Perhaps something we already defined should be in
`pgtable.h` instead of another header.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38153

(cherry picked from commit 7649b89cc12696d540b20ad2f5896827b102225e)

16 months agolinuxkpi: Add <linux/limits.h>
Jean-Sébastien Pédron [Thu, 19 Jan 2023 17:45:28 +0000 (18:45 +0100)]
linuxkpi: Add <linux/limits.h>

For now, it's empty. It is included by the DRM drivers but nothing is
missing otherwise. Perhaps something we already defined should be in
`limits.h` instead of another header.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38147

(cherry picked from commit 25faccaaca6a0bddd60fbad0033606435a13e6b8)

16 months agolinuxkpi: Define `might_alloc()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 00:15:35 +0000 (01:15 +0100)]
linuxkpi: Define `might_alloc()`

... as a no-op.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38146

(cherry picked from commit 19be627cfda7e509fc3444fd57de8a0a501aee04)

16 months agolinuxkpi: Add `freeram` and `freehigh` to `struct sysinfo`
Jean-Sébastien Pédron [Mon, 2 Jan 2023 20:57:35 +0000 (21:57 +0100)]
linuxkpi: Add `freeram` and `freehigh` to `struct sysinfo`

The struct layout is modified with this commit because new fields are
added in the middle, keeping original Linux order.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37932

(cherry picked from commit e400b695991bf3f336e9cbe39e400943d8b1d676)

16 months agolinuxkpi: Add `pin_user_pages*()` functions
Jean-Sébastien Pédron [Tue, 10 Jan 2023 10:09:56 +0000 (11:09 +0100)]
linuxkpi: Add `pin_user_pages*()` functions

They were defined in the i915 DRM driver. I move the code in linuxkpi so
it can benefit other drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38078

(cherry picked from commit 3d751b7a719fd7934e902a34285ce4e5bbaf1e16)

16 months agolinuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux
Jean-Sébastien Pédron [Tue, 10 Jan 2023 10:10:30 +0000 (11:10 +0100)]
linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux

It now returns a `struct scatterlist *` pointer instead of an error
code only.

The implementation is incomplete because it doesn't use the `prv`
argument.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38077

(cherry picked from commit 3e0856b63fe0e375a0951e05c2ef98bb2ebd9421)

16 months agolinuxkpi: Include `linux/sched/mm.h` from `linux/sched.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:52:54 +0000 (10:52 +0100)]
linuxkpi: Include `linux/sched/mm.h` from `linux/sched.h`

At least one file in the DRM drivers benefits from some namespace
pollution to use `fs_reclaim_acquire()`/`fs_reclaim_release()`. They are
defined in `linux/sched/mm.h` and this header must be included
indirectly into the DRM drivers' source file.

I couldn't find how it was included. Therefore this commit includes
`linux/sched/mm.h` from `linux/sched.h`. This is not the case in Linux
but fixes the issue with the DRM drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37912

(cherry picked from commit 8c46bd9f86911c11c42f780fb233db0505ea94ee)

16 months agolindebugfs: Add `debugfs_create_file_size()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:57:49 +0000 (10:57 +0100)]
lindebugfs: Add `debugfs_create_file_size()`

This is the same as `debugfs_create_file()` but takes the initial size
of the file. In FreeBSD, the given size is ignored and
`debugfs_create_file()` is called.

Reviewed by: emaste, manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37914

(cherry picked from commit a04aa80e773a4bfdc4e72bab85d6e16f0083745e)

16 months agolinuxkpi: Define `PCI_STD_NUM_BARS` in <linux/pci.h>
Jean-Sébastien Pédron [Sun, 22 Jan 2023 13:46:14 +0000 (14:46 +0100)]
linuxkpi: Define `PCI_STD_NUM_BARS` in <linux/pci.h>

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D38162

(cherry picked from commit 66cc55a041ddaf4890239b1fe83632c74957bc03)

16 months agolinuxkpi: Define `pm_suspend_target_state` in <linux/suspend.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 20:13:32 +0000 (21:13 +0100)]
linuxkpi: Define `pm_suspend_target_state` in <linux/suspend.h>

It is set to `PM_SUSPEND_ON`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38161

(cherry picked from commit ccd31b464568ecf5907dbecf255edf0676124735)

16 months agolinuxkpi: Add `msix_cap` to `struct pci_dev`
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:23:59 +0000 (20:23 +0100)]
linuxkpi: Add `msix_cap` to `struct pci_dev`

At the same time, define `PCI_MSIX_FLAGS`and `PCI_MSIX_FLAGS_ENABLE`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38160

(cherry picked from commit 4152ce2139548e3e3c28c1e224747fa5d10ae656)

16 months agolinuxkpi: Add `sysfs_emit_at()` in <linux/sysfs.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:23:17 +0000 (20:23 +0100)]
linuxkpi: Add `sysfs_emit_at()` in <linux/sysfs.h>

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38159

(cherry picked from commit e64afbc21572984ca1249e01ff6b1cab39b679b9)

16 months agolinuxkpi: Define `is_cow_mapping(flags)` as false
Jean-Sébastien Pédron [Fri, 20 Jan 2023 19:22:41 +0000 (20:22 +0100)]
linuxkpi: Define `is_cow_mapping(flags)` as false

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38158

(cherry picked from commit 47877d61af072b6b28cc1bf45bc906bba3618b32)

16 months agolinuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:51:40 +0000 (18:51 +0100)]
linuxkpi: Include <linux/vmalloc.h> from <linux/pagemap.h>

I'm not sure this is correct, but it gives access to the definition of
`PAGE_KERNEL` in `ttm_tt.c` in the DRM drivers.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38154

(cherry picked from commit 3d47e3bf7b3725482d6ae01675db097a6de020b6)

16 months agolinuxkpi: Add `seqcount_ww_mutex_t` in <linux/seqlock.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:20:01 +0000 (18:20 +0100)]
linuxkpi: Add `seqcount_ww_mutex_t` in <linux/seqlock.h>

It is defined as a synonymous to `seqcount_mutex_t`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38152

(cherry picked from commit b34cd67243c39ca55be40b3e7958f3ade290347c)

16 months agolinuxkpi: Define `DEFINE_WD_CLASS(name)` in <linux/ww_mutex.h>
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:19:01 +0000 (18:19 +0100)]
linuxkpi: Define `DEFINE_WD_CLASS(name)` in <linux/ww_mutex.h>

It is defined as a synonymous to `DEFINE_WW_CLASS(name)`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38151

(cherry picked from commit d9f1cb6774f1785544c2fbeba476d4842967e804)

16 months agolinuxkpi: Adds more `SZ_*` macros
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:17:37 +0000 (18:17 +0100)]
linuxkpi: Adds more `SZ_*` macros

`SZ_2K` and `SZ_1G` were defined in irdma. They are removed from this
driver.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38150

(cherry picked from commit 04cbeeb59742a9e88d838e18b84004e9bb89ca00)

16 months agolinuxkpi: Define ENOKEY to 126.
Jean-Sébastien Pédron [Fri, 20 Jan 2023 17:14:25 +0000 (18:14 +0100)]
linuxkpi: Define ENOKEY to 126.

This is the same error code as Linux. This value is unused on FreeBSD.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38149

(cherry picked from commit f27b1399d68585f5edd83645c2a37a1580e7fb93)

16 months agolinuxkpi: Add `pci_device_is_present()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 17:46:37 +0000 (18:46 +0100)]
linuxkpi: Add `pci_device_is_present()`

This calls bus_child_present(9) internally.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38148

(cherry picked from commit 49b6d5ed142d6c59b7a517ff5660165d8647bd01)

16 months agolinuxkpi: Define `dev_dbg_ratelimited()`
Jean-Sébastien Pédron [Thu, 19 Jan 2023 00:15:03 +0000 (01:15 +0100)]
linuxkpi: Define `dev_dbg_ratelimited()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38145

(cherry picked from commit bbff0400c1d7728ae1759d8f740033a0a2f8aeff)

16 months agovt(4): Return errors from `vt_{,de}allocate()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 18:22:56 +0000 (19:22 +0100)]
vt(4): Return errors from `vt_{,de}allocate()`

This is useful to the DRM drivers to let them know if a device is
effectively used by the console.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38089

(cherry picked from commit 29ab19455484be96150fa5e87bd38aefb85c888a)

16 months agolinuxkpi: Fix `atomic_long_sub()` overflow
Jean-Sébastien Pédron [Sun, 15 Jan 2023 14:56:48 +0000 (15:56 +0100)]
linuxkpi: Fix `atomic_long_sub()` overflow

By (ab)using `atomic_long_add_return()`, `atomic_long_sub()` was making
the atomic long overflow. Indeed the underlying FreeBSD atomic is based
on an unsigned long.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38090

(cherry picked from commit 9491ea7c68221ca7bc5e369ebb57660886ef1b13)

16 months agolinuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`
Jean-Sébastien Pédron [Sat, 14 Jan 2023 12:22:19 +0000 (13:22 +0100)]
linuxkpi: Add `io_mapping_map_user()` and `remap_pfn_range()`

The code comes from the i915 DRM driver.

In Linux commits b739f125e4ebd73d10ed30a856574e13649119ed and
b12d691ea5e01db42ccf3b4207e57cb3ce7cfe91 (Linux 5.13), the i915 DRM
driver dropped specific implementations to use Linux generic functions.
Therefore I moved the FreeBSD code from that i915 driver to linuxkpi.

However, these commits were later reverted (also in Linux 5.13) so the
i915 driver doesn't use these functions. But perhaps it will help in the
future.

To sum up, the code comes from the i915 DRM driver but it doesn't use it
(i.e. it continues to use its internal implementation).

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38088

(cherry picked from commit b99bc862324526b3ee6fad335618cbe85ad9e11e)

16 months agolinuxkpi: Add `sysfs_emit()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 23:23:33 +0000 (00:23 +0100)]
linuxkpi: Add `sysfs_emit()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38086

(cherry picked from commit 4fee6659c42c264e17dad7625f8663a45594d46b)

16 months agolinuxkpi: Add `complete` field to `struct dev_pm_ops`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:57 +0000 (23:23 +0100)]
linuxkpi: Add `complete` field to `struct dev_pm_ops`

This change breaks the KBI.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38085

(cherry picked from commit 0d4d9ee6f0f9379f3de6e2c684dab19922eda705)

16 months agolinuxkpi: Add `pm_suspend_via_firmware()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:35 +0000 (23:23 +0100)]
linuxkpi: Add `pm_suspend_via_firmware()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38084

(cherry picked from commit 270a13348065ebf2f02fbf88a02d42fa63a245fc)

16 months agolinuxkpi: Add `pm_runtime_suspended()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 22:23:14 +0000 (23:23 +0100)]
linuxkpi: Add `pm_runtime_suspended()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38083

(cherry picked from commit 710c6084d11025fb3640dc1146ae1b157475333b)

16 months agolinuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 00:48:43 +0000 (01:48 +0100)]
linuxkpi: Define `tasklet_unlock_spin_wait()` as `tasklet_unlock_wait()`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38080

(cherry picked from commit 2272ccaa68c550e0e29801b9d881b2ea5ba12efa)

16 months agolinuxkpi: Define `synchronize_hardirq()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 00:27:40 +0000 (01:27 +0100)]
linuxkpi: Define `synchronize_hardirq()`

It currently does the same as `synchronize_irq()`.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38079

(cherry picked from commit a609ed795943673074b71aeafafabe46d08f1a6d)

16 months agolindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()`
Jean-Sébastien Pédron [Thu, 12 Jan 2023 23:41:32 +0000 (00:41 +0100)]
lindebugfs: Add missing `debugfs_create_u*()` and `debugfs_create_x*()`

The `debugfs_create_x*()` variants are the same as their
`debugfs_create_u*()` equivalent, but they work with lowercase
hexadecimal.

While here, fix a few style(9) issues.

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D38087

(cherry picked from commit 976aa07a885b53e1bc2711082d2f6f113dbdd0bc)

16 months agolindebugfs: Add `debugfs_create_atomic_t()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 10:00:57 +0000 (11:00 +0100)]
lindebugfs: Add `debugfs_create_atomic_t()`

Reviewed by: jfree
Approved by: jfree
Differential Revision: https://reviews.freebsd.org/D37915

(cherry picked from commit f2044a3030fb2a657e59dee4b7e5865acff936bd)

16 months agolinuxkpi: Define `hrtimer_try_to_cancel()`
Jean-Sébastien Pédron [Wed, 11 Jan 2023 01:00:57 +0000 (02:00 +0100)]
linuxkpi: Define `hrtimer_try_to_cancel()`

It is the same as callout_stop(9) but the return values are different.

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

(cherry picked from commit bb651c77f5f71a38dd90b2eee214e7a2224421a7)

16 months agolinuxkpi: Define EBADSLT to 57
Jean-Sébastien Pédron [Mon, 2 Jan 2023 22:48:16 +0000 (23:48 +0100)]
linuxkpi: Define EBADSLT to 57

This is the same error code as Linux.

As emaste@ noted in the review, FreeBSD defines the following errno
values in `sys/errno.h`:
* 56 is `EISCONN`
* 57 is `ENOTCONN`

Reviewed by: manu
Approved by: manu
Differential Revision: https://reviews.freebsd.org/D37935

(cherry picked from commit e8ce32bea30d599b481735a1d1b0a87ac06c5a66)

16 months agolinuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`
Jean-Sébastien Pédron [Mon, 2 Jan 2023 20:59:17 +0000 (21:59 +0100)]
linuxkpi: Add `memalloc_noreclaim_save()` and `memalloc_noreclaim_restore()`

They are no-ops.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37933

(cherry picked from commit cf8f392260bf8e9b4e088f26f81ddb96bd97e91c)

16 months agolinuxkpi: Define `ioremap_cache()`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 10:36:24 +0000 (11:36 +0100)]
linuxkpi: Define `ioremap_cache()`

It uses the `VM_MEMATTR_WRITE_BACK` flag on FreeBSD.

It replaces `ioremap_wb()` which doesn't exist in Linux. Perhaps it
existed in the past and was removed.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37916

(cherry picked from commit ed53e350d703b9e3ab78d137fd59a5a9dfef8b3f)

16 months agolinuxkpi: Add `gfp_mask` field to `struct shrink_control`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:56:46 +0000 (10:56 +0100)]
linuxkpi: Add `gfp_mask` field to `struct shrink_control`

bz@ asked if the KBI breakage is a concern here. My answer was that this
is the first time in the DRM drivers in Linux 5.13 (the version I'm
working on) that this structure is initialized (as a variable local to
the function in this case), so it shouldn't be a problem for the DRM
drivers.

However, I can't speak for other drivers maintained outside of the src
tree.

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37913

(cherry picked from commit 3aa335d00ac860565d106eb47e931206641cd653)

16 months agolinuxkpi: Define `GFP_NOFS` in `linux/gfp.h`
Jean-Sébastien Pédron [Fri, 30 Dec 2022 09:49:08 +0000 (10:49 +0100)]
linuxkpi: Define `GFP_NOFS` in `linux/gfp.h`

Reviewed by: emaste, manu
Approved by: emaste, manu
Differential Revision: https://reviews.freebsd.org/D37910

(cherry picked from commit c0c1c599c0ca7e8a15509503991f8cd97c292bea)

16 months agoAdd ck.h userspace shims for CK_SLIST_
Elliott Mitchell [Thu, 9 Feb 2023 23:27:12 +0000 (16:27 -0700)]
Add ck.h userspace shims for CK_SLIST_

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

(cherry picked from commit cd3193f640e26991d94d87a45ee9b6a953c56fb5)

16 months agotop: fix sorting by pid (-o pid)
Kyle Evans [Mon, 13 Feb 2023 06:39:04 +0000 (00:39 -0600)]
top: fix sorting by pid (-o pid)

The 'pid' order was added, but the equivalent comparator was not back in
8b800d3af2d8c ("Add the PID column to the list of sort keys.").
`ordernames` indices need to match `compares` indices in order for this
to work.

A future commit will restructure all of this to make it less error prone
going forward (see D37083).

Reviewed by: pstef (D37083)

(cherry picked from commit deb63adf945d446ed91a9d84124c71f15ae571d1)

16 months agolibc: popen: slightly simplify cloexec logic
Kyle Evans [Mon, 13 Feb 2023 06:33:52 +0000 (00:33 -0600)]
libc: popen: slightly simplify cloexec logic

No need to check the mode again here; we know that `iop` wraps the
correct fd.

Reviewed by: bapt

(cherry picked from commit f123c6c425d4161b06f237996662496abbd78b94)

16 months agomd5: fix *sum -c with missing files
Kyle Evans [Mon, 13 Feb 2023 06:32:38 +0000 (00:32 -0600)]
md5: fix *sum -c with missing files

If we fail to open one of the files in the file listing, we still need
to advance `rec` along with `argv` so that the checksum we're checking
against lines up with the file we're hashing.

Tests added both for the -c flag, as well as the -b and -t modes of
the *sum programs.

PR: 267722
Reviewed by: emaste (earlier version)

(cherry picked from commit 8d78a0d331ec2c168efe6cb85bbc2da86e9a6124)

16 months agopatch: omit filename if the prompt was ignored
Kyle Evans [Tue, 24 Jan 2023 16:46:01 +0000 (10:46 -0600)]
patch: omit filename if the prompt was ignored

When a file is missing, patch(1) will prompt for a filename to try and
patch it.  If we're doing a dry-run, we'll output that the patch to the
source file was either ignored/failed.  If you ignore the prompt in a
dry-run (i.e. just hit enter), we'll output:

X out of X hunks ignored while patching (null)

Let's improve the aesthetics a bit and just omit the last part if the
prompt was ignored:

X out of X hunks ignored

Unfortunately we can't really test this without expect(1) because both
force and batch mode will use the first best guess, which is wiped out
by the "File to patch:" prompt.  We could record the initially derived
bestguess there and use *that*, but given that this is only possible in
an interactive session I think it's fine to just omit the filename
rather than adding a fair amount of complexity (which could also break
other scenarios I haven't considered yet)..

Reviewed by: des
Sponsored by: Klara, Inc.

(cherry picked from commit 7e688ed493482c5346d969e7667856d8ced8d87a)

16 months agowg: tests: remove an obsolete workaround
Kyle Evans [Mon, 13 Feb 2023 05:59:21 +0000 (23:59 -0600)]
wg: tests: remove an obsolete workaround

PR 254212 was resolved to avoid issues with not having IPv6 addresses
present in the jail, so we can safely drop this workaround now...

Reviewed by: jhb, markj

(cherry picked from commit e63dcbe7a2cb8f6b6932cef48e70f3372f4df737)

16 months agowg: add a test for the home jail socket feature
Kyle Evans [Mon, 13 Feb 2023 05:59:20 +0000 (23:59 -0600)]
wg: add a test for the home jail socket feature

This adds a test for a semantic that we added to mirror a feature of
the Linux implementation w/ netns: if a wg interface is moved into a
jail, we still create the socket in the context of the home vnet.  With
this added, one can actually create vnet jails that only have a wg
tunnel to the outside world providing network connectivity without any
epairs in the setup.

Reviewed by: jhb, markj (both earlier version)

(cherry picked from commit 96f4ab26633a457c52fdb9c45f48dcb052b408a4)

16 months agoamd64 ia32 vdso: always define some __vdso_ symbols
Konstantin Belousov [Sun, 5 Feb 2023 21:41:25 +0000 (23:41 +0200)]
amd64 ia32 vdso: always define some __vdso_ symbols

(cherry picked from commit ee844871206562c6aaaa14ee4576cb20895adb00)

16 months agoamd64: record a dependency of vdso on its linker script
Konstantin Belousov [Sun, 5 Feb 2023 21:40:31 +0000 (23:40 +0200)]
amd64: record a dependency of vdso on its linker script

(cherry picked from commit 5bb807fed4622b17f2b2aa837f5ebd124e08f904)

16 months agosesutil: plug memory leaks
Alan Somers [Wed, 19 Jan 2022 21:57:27 +0000 (14:57 -0700)]
sesutil: plug memory leaks

Sponsored by: Axcient
Reviewed by: bapt
Differential Revision: https://reviews.freebsd.org/D33955

(cherry picked from commit 09f29b03ddf857a366f338145693b5449e6ca5de)

16 months agoirdma: fix LINT-NOIP/NOINET/NOINET6 builds
Mitchell Horne [Mon, 30 May 2022 20:47:32 +0000 (17:47 -0300)]
irdma: fix LINT-NOIP/NOINET/NOINET6 builds

This module depends on the presence of both INET and INET6 options in
order to compile.

Reviewed by: erj
Fixes: cdcd52d41e24 ("irdma: Add RDMA driver for Intel(R) Ethernet...")
Differential Revision: https://reviews.freebsd.org/D35343

(cherry picked from commit acdfbc6cbe0a8a976d446216be84994c8ee8d5c1)

16 months agoloader: always install help files
Mitchell Horne [Thu, 11 Feb 2021 14:29:00 +0000 (10:29 -0400)]
loader: always install help files

Address two issues with current help file logic:

The existing condition prevents the common help file from being
installed when there are no additional help files defined. This results
in no loader.help on EFI platforms, for example.

Second, due to the fact that we build and install multiple loader types,
each successive install will clobber the previous loader.help. The
result is that we could lose type-specific commands, or possibly list
them in loaders that do not have such commands.

Instead, give each loader type a uniquely named help file. The EFI
loader will look for /boot/loader.help.efi, userboot will look for
/boot/loader.help.userboot, etc. The interpreter variant has no effect
on which help file is loaded.

This leaves the old /boot/loader.help unused.

Some credit for the final approach goes to Mathieu <sigsys@gmail.com>
for their version of the fix in https://reviews.freebsd.org/D22951.

PR: 267134
Reported by: Daniel O'Connor <darius@dons.net.au>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D28591

(cherry picked from commit 8859960436f5727f163a7b3468e08710c5e6d874)

16 months agodtrace: implement riscv dtrace_getustackdepth()
Mitchell Horne [Mon, 6 Feb 2023 18:23:42 +0000 (14:23 -0400)]
dtrace: implement riscv dtrace_getustackdepth()

Pretty trivial following other implementations. The existing
dtrace_getustack_common() does most of the work.

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

(cherry picked from commit c6943b44f7d73176acd2e36e0615e1b2ded02c0a)

16 months agodtrace: Fix RISC-V user stack unwinder
Jessica Clarke [Mon, 6 Feb 2023 18:30:57 +0000 (14:30 -0400)]
dtrace: Fix RISC-V user stack unwinder

The unwind logic was copied from AArch64 which follows the peculiar
AACPS (where, unlike typical RISC architectures, its frame pointer
follows an x86/stack machine-like convention where the frame pointer
points at the bottom of the frame record, not the top). Delete the
pointless riscv_frame struct and fix this.

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

(cherry picked from commit 38720107324b3903f342bcb0306c72c4e4235053)

16 months agodtrace_asm.S: properly enter/exit user access
Mitchell Horne [Mon, 6 Feb 2023 18:04:21 +0000 (14:04 -0400)]
dtrace_asm.S: properly enter/exit user access

In order to read or write userspace memory without generating an access
fault, we must first enable the SUM bit in the sstatus CSR.

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

(cherry picked from commit 0e563bde48b1af6bd472e940f04a8d76315749ab)

16 months agodtrace: handle page faults in riscv dtrace_trap()
Mitchell Horne [Mon, 6 Feb 2023 18:08:35 +0000 (14:08 -0400)]
dtrace: handle page faults in riscv dtrace_trap()

We must detect the correct amount to increment sepc, as it may have been
a compressed instruction that triggered the fault.

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

(cherry picked from commit 06faad1de2c9aadcfd606d5f7121b201dbfbaa9d)

16 months agoUse maybe_yield() in a few more places
Mitchell Horne [Thu, 9 Feb 2023 15:42:53 +0000 (11:42 -0400)]
Use maybe_yield() in a few more places

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38186

(cherry picked from commit dc9b13736fce15ec3dc77a87e06d6406c92a0141)

16 months agoBoolify should_yield()
Mitchell Horne [Thu, 9 Feb 2023 15:35:11 +0000 (11:35 -0400)]
Boolify should_yield()

Do this ahead of adding a man page that describes the function. No
functional change.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38181

(cherry picked from commit d570418bd8918980e578ff78a229593766b832bb)

16 months agoUpdate comments referencing create_thread()
Mitchell Horne [Thu, 9 Feb 2023 15:34:38 +0000 (11:34 -0400)]
Update comments referencing create_thread()

The equivalent function is now named thread_create(). Mention
kthread_add() where it is also relevant.

Reviewed by: kib, markj
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D38180

(cherry picked from commit a7a452fedc42d9e260224b7e2cd833df7287319f)

17 months agounbound: Fix config file path
Juraj Lutter [Tue, 17 Jan 2023 17:25:47 +0000 (18:25 +0100)]
unbound: Fix config file path

Commit 1838dec31895fd4752fa8631322ab93be0705a66 changed the
config file path to /usr/local/etc/unbound/unbound.conf which
is wrong for unbound in base.

Reported by: Ihor Antonov <ihor_AT_antonovs_family>
Reviewed by: zlei
Approved by: zlei
Differential Revision: https://reviews.freebsd.org/D38106

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66
(cherry picked from commit 1d577bedbae80ced38ccb834e6835e5fd98bc411)

17 months agounbound: Fix config.h
Cy Schubert [Sun, 15 Jan 2023 06:55:05 +0000 (22:55 -0800)]
unbound: Fix config.h

FreeBSD src does not support HAVE_DECL_EVSIGNAL_ASSIGN. While reviewing
the new config.h after regenerating it, this definition was not removed.

Updating config.h is a manual process of configuring the port and
copying/merging the generated config.h into src. This definition was
missed and not removed (#undef'd).

Fixes: 1838dec31895fd4752fa8631322ab93be0705a66

(cherry picked from commit 06b93ef8cda227d755d7f6cfa95d08c0ccc9dc2d)

17 months agounbound: Vendor import 1.17.1
Cy Schubert [Sun, 15 Jan 2023 05:39:31 +0000 (21:39 -0800)]
unbound: Vendor import 1.17.1

Release notes at
    https://www.nlnetlabs.nl/news/2023/Jan/12/unbound-1.17.1-released/.

Merge commit '7699e1386a16236002b26107ffd2dcbde375e197' into main

(cherry picked from commit 1838dec31895fd4752fa8631322ab93be0705a66)

17 months agoheimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL
Cy Schubert [Tue, 7 Feb 2023 15:46:59 +0000 (07:46 -0800)]
heimdal: Resolve hdb_free_entry() SIGSEGV/SIGILL

When the client sends kadmind a create principal (kadm_create) request
kadm_s_create_principal() returns an error before zeroing out ent (an
hdb entry structure wrapper -- hdb_entry_ex), resulting in a NULL
reference.

Fix obtained from upstream commit 35ea4955a.

PR: 268059
Reported by: Robert Morris <rtm@lcs.mit.edu>
Obtained from: Heimdal commit 35ea4955a

(cherry picked from commit 6a70e0b4cdc606931555cdc59dc6c8d4a3ab4e3e)

17 months agonetlink: add headers installation
Alexander V. Chernikov [Sat, 1 Oct 2022 16:31:58 +0000 (16:31 +0000)]
netlink: add headers installation

(cherry picked from commit 11ca01e9aa479559da240ceba17fdcdf2d1e97c3)

17 months agoahci: increase timout
Mariusz Zaborski [Fri, 10 Feb 2023 15:56:04 +0000 (16:56 +0100)]
ahci: increase timout

For some devices, like Marvell 88SE9230, it takes more time
to connect to the device. This patch introduces a special flag
that extends the timeout from around 100ms to around 500ms.

This change is based on the work of: Peter Eriksson <pen@lysator.liu.se>

PR: 243401
Reviewed by: imp
Tested by: dch
MFC after: 3 days
Sponsored by: Equinix
Sponsored by: SkunkWerks, GmbH
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D38413

(cherry picked from commit f08ac4cb14c1c0740346a4363f82e1e1367c2bad)

17 months agotzcode: Resurrect tzsetwall(3) with a deprecation warning.
Dag-Erling Smørgrav [Thu, 9 Feb 2023 18:35:34 +0000 (19:35 +0100)]
tzcode: Resurrect tzsetwall(3) with a deprecation warning.

This function has been around since 4.4BSD but was dropped upstream in 2020.  This went unnoticed when tzcode was updated.  Bring it back, but prepare for removing it before 14.0 is released.

PR: 269445
MFC after: 3 days
Reported by: val@packett.cool
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D38445

(cherry picked from commit 71e0c8906e1a4ff774f8ae810aeb94af039eedb7)

17 months agossh: update to OpenSSH 9.2p1
Ed Maste [Mon, 6 Feb 2023 21:54:56 +0000 (16:54 -0500)]
ssh: update to OpenSSH 9.2p1

Release notes are available at https://www.openssh.com/txt/release-9.2

OpenSSH 9.2 contains fixes for two security problems and a memory safety
problem.  The memory safety problem is not believed to be exploitable.
These fixes have already been committed to OpenSSH 9.1 in FreeBSD.

Some other notable items from the release notes:

 * ssh(1): add a new EnableEscapeCommandline ssh_config(5) option that
   controls whether the client-side ~C escape sequence that provides a
   command-line is available. Among other things, the ~C command-line
   could be used to add additional port-forwards at runtime.

 * sshd(8): add support for channel inactivity timeouts via a new
   sshd_config(5) ChannelTimeout directive. This allows channels that
   have not seen traffic in a configurable interval to be
   automatically closed. Different timeouts may be applied to session,
   X11, agent and TCP forwarding channels.

 * sshd(8): add a sshd_config UnusedConnectionTimeout option to
   terminate client connections that have no open channels for a
   length of time. This complements the ChannelTimeout option above.

 * sshd(8): add a -V (version) option to sshd like the ssh client has.

 * scp(1), sftp(1): add a -X option to both scp(1) and sftp(1) to
   allow control over some SFTP protocol parameters: the copy buffer
   length and the number of in-flight requests, both of which are used
   during upload/download. Previously these could be controlled in
   sftp(1) only. This makes them available in both SFTP protocol
   clients using the same option character sequence.

 * ssh-keyscan(1): allow scanning of complete CIDR address ranges,
   e.g.  "ssh-keyscan 192.168.0.0/24". If a CIDR range is passed, then
   it will be expanded to all possible addresses in the range
   including the all-0s and all-1s addresses. bz#976

 * ssh(1): support dynamic remote port forwarding in escape
   command-line's -R processing. bz#3499

MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit f374ba41f55c1a127303d92d830dd58eef2f5243)

17 months agolocal-unbound-setup: Use default root certificates
Tijl Coosemans [Thu, 19 Jan 2023 17:13:35 +0000 (18:13 +0100)]
local-unbound-setup: Use default root certificates

Don't force /etc/ssl/cert.pem.  It does not exist by default, only if
security/ca_root_nss is installed.  Just use the default OpenSSL search
locations which are /etc/ssl/cert.pem and /etc/ssl/certs/.

The tls-system-cert option was added in Unbound 1.16.0.

Reviewed by: zlei
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38243

(cherry picked from commit 8932f7ce1783a10e9ba79c61d54077aa7693552e)

17 months agossh: fix SIZEOF_TIME_T #define on i386
Ed Maste [Wed, 8 Feb 2023 18:31:44 +0000 (13:31 -0500)]
ssh: fix SIZEOF_TIME_T #define on i386

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

(cherry picked from commit 1aa9a35f6361cc898e2323e1f2823771eb4161da)

17 months agosbin/ping6: Remove remains of ping6.
Xin LI [Sun, 29 Jan 2023 23:21:25 +0000 (15:21 -0800)]
sbin/ping6: Remove remains of ping6.

(cherry picked from commit 195ec47b478a66fd935d59b2d189705f06f601cf)

17 months agorescue: Add fetch(1) to the rescue tool.
John Grafton [Sun, 29 Jan 2023 23:05:15 +0000 (15:05 -0800)]
rescue: Add fetch(1) to the rescue tool.

After a failed upgrade, having fetch(1) on a system that is
physically unnreachable would be very useful to download files
required to get the OS back up and functional.

On my system this adds 589,824 bytes (3.8%) to the binary size.

PR: 266224
Reported by: Dan Mahoney
Differential Revision: https://reviews.freebsd.org/D38193

(cherry picked from commit ea34aa4780e5a581732520ea579342af94684882)

rescue: Fix link order of SSL libraries and fetch.

ld.bfd requires libraries to be linked in order.  libssl requires
libcrypto.  libfetch requires libssl.  To fix the latter, move fetch
up above tar rather than listing the ssl libraries twice.

Reviewed by: delphij
Fixes: ea34aa4780e5 rescue: Add fetch(1) to the rescue tool.
Differential Revision: https://reviews.freebsd.org/D38304

(cherry picked from commit 0f031350f32b8760e0843a6476d67aa21116103b)

17 months agoFIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation
Konstantin Belousov [Sat, 4 Feb 2023 01:20:19 +0000 (03:20 +0200)]
FIOSEEKHOLE/FIOSEEKDATA: correct consistency for bmap-based implementation

PR: 269261

(cherry picked from commit 3b6056204dd80cc866b7998ef0776247ebc42ce4)

17 months agonetlink: allow to override sb_max for netlink sockets.
Alexander V. Chernikov [Fri, 10 Feb 2023 16:07:17 +0000 (16:07 +0000)]
netlink: allow to override sb_max for netlink sockets.

Netlink sockets sometimes require larger buffers than other sockets.
For example, full-view IPv4 dump sent via netlink may consume 50+ megabytes.
The desired buffer may be bigger than the system maximum `sb_max`.
FreeBSD HEAD has a mechanism for overriding protocol `setsockopt()` handler,
 which netlink  uses to permit buffer reservations beyond `sb_max`.
 This behaviour is handy as it doesn't require system administrator to lift
 the limits for other sockets.
Stable/13 lack such muchanism, so a different approach has to be used.
This diff is a direct commit to stable/13 and it simply copies the logic from
 Netlink in -HEAD for checking if the larger buffer size should be permitted.

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

17 months agoRevert "netlink: allow to override sb_max for netlink sockets"
Alexander V. Chernikov [Fri, 10 Feb 2023 16:05:52 +0000 (16:05 +0000)]
Revert "netlink: allow to override sb_max for netlink sockets"

This reverts commit 4f81fdc0886f623043767866ebe4339bd12edf18.

17 months agonetlink: do not require elevated privileges when reading arp/ndp state.
Alexander V. Chernikov [Thu, 9 Feb 2023 14:12:33 +0000 (14:12 +0000)]
netlink: do not require elevated privileges when reading arp/ndp state.

MFC after: 1 day

(cherry picked from commit 5a5436eb5d960b9e243f8196147c6a51ca4f9dee)

17 months agonetlink: allow to override sb_max for netlink sockets
Alexander V. Chernikov [Thu, 9 Feb 2023 21:36:43 +0000 (21:36 +0000)]
netlink: allow to override sb_max for netlink sockets

17 months agoefiserialio: use port settings (sio->Mode) for initial setup
Toomas Soome [Thu, 2 Feb 2023 14:01:02 +0000 (16:01 +0200)]
efiserialio: use port settings (sio->Mode) for initial setup

Use serial port setup done by system firmware.
ARM64 Hyper-V does hung if we attempt to override the defaults,
therefore we should default to use settings from firmware.

Tested by: schakrabarti@microsoft.com
PR: 266248
MFC after: 1 week

(cherry picked from commit c243de11cf7c4bb3d67bbc1655b149037e5b04f1)

17 months agoPost-13.2-branch updates
Colin Percival [Fri, 10 Feb 2023 00:38:08 +0000 (16:38 -0800)]
Post-13.2-branch updates

Rename stable/13 to -STABLE

Bump __FreeBSD_version

Approved by: re (implicit)
Sponsored by: https://www.patreon.com/cperciva

17 months agousr.sbin/kbdcontrol.c: Add backwards compatibility functions
Stefan Eßer [Mon, 6 Feb 2023 22:56:44 +0000 (23:56 +0100)]
usr.sbin/kbdcontrol.c: Add backwards compatibility functions

This commit allows a kbdcontrol binary built with a version of kbio.h
that supports Unicode characters in dead key maps to load and display
keymaps including the dead key tables on a kernel built with a
previous version of kbio.h (that only supported 8 bit characters in
the dead key map).

This commit is meant as a temporary compatibility shim that will be
reverted when it can be assumed that all relevant systems have been
upgraded to a kernel that uses the updated kbio.h.

MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38388

(cherry picked from commit b92f8e5c0dccd52ea194cabe835b7af0b5e91f09)

17 months agoSupport Unicode characters in keymap dead key tables
Stefan Eßer [Mon, 6 Feb 2023 22:48:47 +0000 (23:48 +0100)]
Support Unicode characters in keymap dead key tables

Support for Unicode characters had been added to the keyboard code,
but there are keymaps that have accented characters accessed via dead
key combinations, and those were still restricted to 8 bit codes.

This update to kbd.c adds support for Unicode characters and
compatibility code that allows a kbdcontrol command built from kbio.h
without these patches to work on a new kernel.

Compatibility code that allows a new kbdcontrol binary running on an
old kernel to load and display the dead key map will be committed in a
separate commit.

Reviewed by: imp, brooks
Approved by: brooks
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D38381

(cherry picked from commit 4972fb9276389fb87a790b415b1161cff395884c)

17 months agocontrib/bc: update to version 6.2.4
Stefan Eßer [Mon, 6 Feb 2023 21:33:56 +0000 (22:33 +0100)]
contrib/bc: update to version 6.2.4

This update contains only documentation changes (new main repository
URL and changed mail address of the program author) and changes to
the build system that do not affect the FreeBSD base system build.

MFC after: 3 days

(cherry picked from commit 4fca8e0f65a8bbbd1242c1f7d8e33b77c479f5de)

17 months agoipfilter: Fix use after free on packet with broken lengths
Cy Schubert [Thu, 2 Feb 2023 00:49:08 +0000 (16:49 -0800)]
ipfilter: Fix use after free on packet with broken lengths

Under the scenario with a packet with length of 67 bytes, a header length
using the default of 20 bytes and a TCP data offset (th_off) of 48 will
cause m_pullup() to fail to make sure bytes are arragned contiguously.
m_pullup() will free the mbuf chain and return a null. ipfilter stores
the resultant mbuf address (or the resulting NULL) in its fr_info_t
structure. Unfortuntely the eroneous packet is not flagged for drop.
This results in a kernel page fault at line 410 of sys/netinet/ip_fastfwd.c
as it tries to use a now previously freed, by m_pullup(), mbuf.

PR: 266442
Reported by: Robert Morris <rtm@lcs.mit.edu>

(cherry picked from commit 79f7745c098a766d34a4e072cdd1a06e6d0829d5)