sys/compat/freebsd32: Fix i386 compilation
The compile assertion now failing is due to the change '__int64_t' =>
'__int32_t' as the type of 'time32_t' on i386, which is the correct
value. The use of 'freebsd32.h' on i386 may seem strange, but it comes
from 'kern_umtx.c' including it unconditionally as it needs 'struct
umutex32'.
Fixes: 87632ddf67b0 ("openzfs sys/types32.h: use abi_compat.h for time32_t")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit 07c4eb506be45a4b836665e14ad63034ef3d573a)
dev/mfi: include sys/abi_compat.h unconditionally
not only for COMPAT_FREEBSD32 case. The driver uses INPTR() for
non-compat32 code.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
(cherry picked from commit bf603dbbb2c9964bba3d5bf2ba2371a75a0cc521)
sys/event.h: reduce namespace pollution from sys/abi_compat.h
Split out types definitions into sys/abi_types.h, and only include
abi_types.h into sys/event.h.
Tested and reviewed by: bz
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55202
(cherry picked from commit ecadac729a1b855fe0d77a682ee424c3da1eb3db)
devstat: Provide 32-bit compatibility
If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
translate each struct devstat to its 32-bit equivalent before copying it
out.
Also fix a bug where an early error would be ignored if there were no
devices to report.
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54591
(cherry picked from commit a11d132f6c62f32abe44b19f7527d97ddc239058)
freebsd32: Fix includes
The previous commit added <sys/cdefs.h>, which isn't actually needed.
Conversely, <sys/event.h> is needed (and has been for a long time) but
[7 lines not shown]
sys/compat/freebsd32: FF clock struct: Don't pack, use 'ffcounter32'
Packing 'struct ffclock_estimate32', in absence of substitution of
'ffcounter' (some 'uint64_t') by a 32-bit compatible type, was necessary
on amd64 since 'uint64_t' is 8-byte aligned, which leaves a padding gap
of 4-byte between fields 'update_time' and 'update_ffcount'. This gap
does not exist on i386 (or amd64 32-bit mode), as 'uint64_t' there is
only 4-byte aligned.
Change the type of the 'update_ffcount' and 'leapsec_next' fields to the
recently introduced 'freebsd32_uint64_t', and adapt copy-in and copy-out
accordingly. Using `CP()` previously worked due to the '__packed__'
attribute.
Reviewed by: kib
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D55282
(cherry picked from commit 7c2fc4419db43a8a7d1886b0b8e08aa97bfa31e4)
sys/compat/freebsd32: ki_pd is missing from struct kinfo_proc32
This is missed by the sizeof(struct kinfo_proc32) assert due to another
bug: namely, the use of uint64_t type that has different alignment on
i386 than on amd64 host.
Fixes: 85078b8573332c2c83a79adea8a61b519fb3b6af
Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55135
(cherry picked from commit 154778e3585166f613fd3d2978a0cab2262d1611)
openzfs sys/types32.h: use abi_compat.h for time32_t
The time32_t typedef leaks into openzfs compilation environment
through sys/event.h. Simultaneously, openzfs provides its own
definition that is only correct for amd64 on FreeBSD.
Try to fix it by using sys/abi_compat.h directly. Since toolchain build
from the make buildworld uses host abi_compat.h, add a preprocessor
symbol __HAVE_TIME32_T to signal consumers that time32_t is typedef'ed.
If not defined, fall back to old and wrong time32_t, which is enough for
bootstraping toolchain.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55135
(cherry picked from commit 87632ddf67b01f3d4787d10332afc1eeece52e2d)
sys/abi_compat.h: fix UB for bintime32 handling
Do not cast and then access potentially unaligned uint64_t in the BT_CP()
macro. Use freebsd32_uint64_t type and FU64_CP() for the frac member.
Noted by: des
Reviewed by: des, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54663
(cherry picked from commit be1b2da855cc38531733b5c97891cd4a40a993bc)
sys/abi_compat.h: move freebsd32_uint64_t and FU64_CP() there
Use private names for uintXX_t types.
Remove conflicting (but equal) PTR_IN() definition from dev/mfi.c.
Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D55135
(cherry picked from commit e651c64bcab08c7b12d8ad6e3ad0b1ef3af3b875)
compat32: provide a type and a macro for (u)int64_t handling on non-x86 arches
uint64_t is 4-byte aligned on i386, but is 8-bytes aligned on all other
32bit arches FreeBSD supports. Provide the freebsd32_uint64_t type and
the FU64_CP() macro, which are intended to be used where 32bit ABI uses
(u)int64_t type, and do proper layout and copying for the aggregate type.
Reviewed by: des, emaste
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D54663
(cherry picked from commit 96acaa960023c20e852e04e7cc5c6a5faca36c67)
devstat: Provide 32-bit compatibility
If a 32-bit process running on a 64-bit kernel requests kern.devstat.all,
translate each struct devstat to its 32-bit equivalent before copying it
out.
Also fix a bug where an early error would be ignored if there were no
devices to report.
MFC after: 1 week
Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D54591
(cherry picked from commit a11d132f6c62f32abe44b19f7527d97ddc239058)
freebsd32: Fix includes
The previous commit added <sys/cdefs.h>, which isn't actually needed.
Conversely, <sys/event.h> is needed (and has been for a long time) but
[7 lines not shown]
ixgbe: Fix MRQC register value.
Focus on the MRQE field of the MRQC register, which is 4 bits wide,
and we use these 3 types of values.
- IXGBE_MRQC_RSSEN 0x1 (non VF mode)
- IXGBE_MRQC_VMDQRSS32EN 0xA (less than 33 VFs)
- IXGBE_MRQC_VMDQRSS64EN 0xB (less than 65 VFs)
If we always take a bitwise OR with IXGBE_MRQC_RSSEN,
IXGBE_MRQC_VMDQRSS32EN will never be chosen.
Select these 3 types of values for the proper case.
Signed-off-by: Yuichiro NAITO <naito.yuichiro at gmail.com>
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/2132
kern/amd64/machdep: Replace memset in wrmsr_early_safe_end
GENERIC-KASAN kernel failed to boot on a Dell PowerEdge C6615 with
an AMD EPYC 8224P CPU; UEFI BIOS caught a #GP exception with %RIP
in kasan_memset where %GS relative pointer (curthread->td_pflags2)
was dereferenced. Investigation led to wrmsr_early_safe_end which
calls memset to clear early #GP IDT entry. Replacing memset with
__builtin_memset_inline still resulted in the compiler emitting a
call to the memset resolver in GENERIC-KASAN build and the kernel
stil faulted during boot. This version which has been successfully
tested with both GENERIC and GENERIC-KASAN kernels uses memset_early.
Signed-off-by: Kristofer Peterson <kris at tranception.com>
Reviewed-by: kib
(cherry picked from commit 615f1b9eb17c921bbcb0cce2b9ad61910361325b)
bhyveload: simplify cb_open() and eliminate minor TOCTOU
It's not at all clear why I wrote it like this, but we can do better.
I wouldn't think this really has any meaningful security implications
since the hierarchy in question can't really be modified by the guest
scripts, but it would seem to make it a little more robust.
Reviewed by: bnovkov, markj
(cherry picked from commit 6da9d465c54bf2e3496e83db025c5d22f3b3cc17)
ls: check fts_children() for errors that may not surface otherwise
In particular, if one simply does a non-recursive `ls` on a directory
that is not accessible, there are some classes of errors that may cause
it to fail that wouldn't be surfaced unless we do an fts_read() that
will recurse into the inaccessible directory. Catch those kinds of
errors here since we cannot expect to an FTS_ERR/FTS_DNR entry to follow
up on them.
PR: 287451
Reviewed by: kib
Discusssed with: des
(cherry picked from commit 7bf81e39d83087dc7f984077b5eed5a48df794d4)
release: Pass optional VM_IMAGE_CONFIG to vm-image
`make vm-image` calls mk-vmimage.sh, which supports
`-c CONFFILE`. This file gets sourced before building the image.
One example of how to use it is to define
vm_extra_filter_base_packages() to filter the list of packages
installed into the VM image:
# vm-nodbg32.conf
vm_extra_filter_base_packages() {
grep -v -E '(-dbg|lib32)'
}
$ make VM_IMAGE_CONFIG=path/to/vm-nodbg32.conf \
VMFORMATS=raw \
-DWITH_VMIMAGES \
vm-image
[3 lines not shown]
bectl: Add -E flag to create an empty boot environment
Signed-off-by: Pat Maddox <pat at patmaddox.com>
Reviewed by: kevans
(cherry picked from commit 2e020c84cb5ee1452e448f27ff7a7b6076c0147a)
OptionalObsoleteFiles: Add etc/zfs/compatibility.d
If the world is built and installed with WITHOUT_ZFS, then make
-DBATCH_DELETE_OLD_FILES delete-old-dirs will give the error:
> rmdir: /etc/zfs: Directory not empty
because /etc/zfs/compatibility.d is still there. While we're here,
clean out /usr/share/zfs as well.
Co-authored-by: kevans
(cherry picked from commit 5c9d988d865cc4ce849507173c0a2e2f399d0f62)