linuxkpi: Fix an error path in linux_alloc_current()
If the allocation fails we should free the task struct.
While here get rid of a couple of unnecessary assertions.
Reported by: Kevin Day <kevin at your.org>
Reviewed by: emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54671
(cherry picked from commit a4955b0143361900140df640d116891f047f5431)
arm64/iommu: Fix a resource leak in smmu_domain_alloc()
We should free the allocated ASID if smmu_init_cd() fails.
Move the allocation of "domain" to simplify the first error path.
Reported by: Kevin Day <kevin at your.org>
Reviewed by: br
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54676
(cherry picked from commit 6740cccb1eff2a0e1e6d451fa9676a21736937d2)
arm64/vgic_v3: Fix an inverted test when reading GICD_I<C|S>ENABLER
On read, these registers' fields return 1 if forwarding of the
corresponding interrupt is enabled, and 0 otherwise. The test in
read_enabler() was inverted.
Reported by: Kevin Day <kevin at your.org>
Reviewed by: andrew
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54678
(cherry picked from commit 6fef0c9ee64cea1f22b6a33a0c4dd39f605b7465)
linuxkpi: Clean up linux_shmem_file_setup() a bit
- Free the pointer that was returned by the allocator, instead of the
address of the first member. These will be equal in practice, but
it's sketchy and won't work on CHERI with subobject bounds checking.
- Use an anonymous struct, there's no need to name it.
Reviewed by: bz, brooks, emaste
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54673
(cherry picked from commit 251662e5abdd85f5a83766b400e23c2ac5597fb9)
asmc: add per-fan manual mode control via sysctl
Add per-fan manual mode control via dev.asmc.0.fan.N.manual sysctl.
Apple SMCs support manual fan control via the FS! SMC key,
a 16-bit bitmask where each bit controls one fan (0=auto, 1=manual).
This change adds a new sysctl per fan:
dev.asmc.0.fan.N.manual (0=auto, 1=manual)
When set to manual mode (1), the fan runs at the speed set via
dev.asmc.0.fan.N.targetspeed instead of automatic thermal control. When
set to auto mode (0), the SMC controls fan speed automatically.
The FS! key was already defined in asmcvar.h but not accessible.
This exposes it for debugging, testing, and advanced fan control.
Implementation uses read-modify-write to allow independent control of
each fan without affecting others.
[6 lines not shown]
kqueue.2: Fix reference to unexisting kevent1()
kqueue1() was meant.
While here, make the wording in the AUTHORS section more clear.
PR: 291908
Fixes: 9b1585384d53 ("kqueue.2: Editorial pass")
Reviewed by: kib, dab
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D54858
makefs/zfs/tests: Force-destroy md devices
Most of these tests create a md(4) device backed by a makefs-generated
image, then import the pool, using the md device as a pool vdev. When
a test finishes, it destroys the pool, then destroys the md device.
Once in a while md device destruction fails with EBUSY. This happens
when a GEOM consumer is holding the device open; kern_mddetach_locked()
simply fails if any consumers are present. zpool destruction is
synchronous so ZFS is innocent, rather, the problem seems to be that
GEOM re-tastes the device after the zpool reference goes away. This
operation creates a transient reference that causes the spurious
failure.
Use "mdconfig -o force" to work around this.
MFC after: 2 weeks
libc: add posix_spawnattr_{get,set}execfd_np(3)
If execfd is set, the fexecve(2) is used by posix_spawn() instead of the
provided path.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54862
Bump __FreeBSD_version to 1600011 after changes to eventfd
This covers the commits that updated the API and the commit that exposes
that API in linuxkpi for DRM drivers.
Sponsored by: The FreeBSD Foundation
linuxkpi: Add eventfd_*()
Add <linux/eventfd.h> and expose the `eventfd_*()` API. This is used by
DRM drivers for some time, but the code was commented out so far.
Note that Linux uses `struct eventfd_ctx`, but FreeBSD defines `struct
eventfd`. We define `eventfd_ctx` as a synonym to `eventfd`.
Reviewed by: christos, markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50853
eventfd: Add eventfd_signal()
The `eventfd_signal()` function is the equivalent to a write to an
eventfd file descriptor: it bumps the internal counter and wakes up
processes waiting for it.
`eventfd_signal()` is meant to be used by kernel drivers. DRM drivers
will call it through linuxkpi.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50850
eventfd: Add refcounting
An eventfd file descriptor can be used by drivers such as DRM drivers
through linuxkpi. A driver can hold a reference to such a file
regardless of the fact it is used by userland or not.
This patch introduces a refcount in `struct eventfd`, plus the
`eventfd_get()` and `eventfd_put()` functions to acquire and release
references. These functions will be used by DRM drivers for instance.
This structure is internal to `sys/kern/sys_eventfd.c` and not used
anywhere else. Thus it is safe to add a field without breaking anything.
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D50849
lib/libsys, lib/libc: export pdwait
Make pdwait(2) cancellable, same as all other wait*(2) syscalls wrappers.
Reviewed by: asomers, markj
Tested by: pho
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54592