HomeFreeBSD

cpuset: Byte swap cpuset for compat32 on big endian architectures

Description

cpuset: Byte swap cpuset for compat32 on big endian architectures

Summary:
BITSET uses long as its basic underlying type, which is dependent on the
compile type, meaning on 32-bit builds the basic type is 32 bits, but on
64-bit builds it's 64 bits. On little endian architectures this doesn't
matter, because the LSB is always at the low bit, so the words get
effectively concatenated moving between 32-bit and 64-bit, but on
big-endian architectures it throws a wrench in, as setting bit 0 in
32-bit mode is equivalent to setting bit 32 in 64-bit mode. To
demonstrate:

32-bit mode:

BIT_SET(foo, 0): 0x00000001

64-bit sees: 0x0000000100000000

cpuset is the only system interface that uses bitsets, so solve this
by swapping the integer sub-components at the copyin/copyout points.

Reviewed by: kib
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D35225

(cherry picked from commit 47a57144af25a7bd768b29272d50a36fdf2874ba)

Details

Provenance
jhibbitsAuthored on May 12 2022, 8:38 PM
Reviewer
kib
Differential Revision
D35225: cpuset: Byte swap cpuset for compat32 on big endian architectures
Parents
rGafe7bd51743e: ipfw.8: MFC: spell "layer2" consistently throughout the manual page
Branches
Unknown
Tags
Unknown