[Bug 216568] [pcm] SNDCTL_DSP_GETERROR always fails with -m32 on 64bit system

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 12 Sep 2025 16:56:03 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=216568

Damjan Jovanovic <damjan.jov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |damjan.jov@gmail.com

--- Comment #2 from Damjan Jovanovic <damjan.jov@gmail.com> ---
(In reply to Konstantin Belousov from comment #1)

It's much easier than it looks: only 5 ioctls and maybe mmap() need
COMPAT_FREEBSD32 shims.

In sys/sys/soundcard.h only these 9 structs have "long" fields, whose sizes on
32 vs 64 bit FreeBSD will differ (luckily the vast majority of the OSS API uses
"int"):

Struct             | Used in
-------------------+-------------------------------------
snd_chan_param     | AIOGFMT, AIOSFMT
snd_sync_parm      | AIOSYNC
snd_capabilities   | AIOGCAP
struct patch_info  | struct patmgr_info
struct sysex_info  | unused?
struct patmgr_info | SNDCTL_PMGR_ACCESS, SNDCTL_PMGR_IFACE
struct synth_info  | SNDCTL_SYNTH_INFO
struct midi_info   | SNDCTL_MIDI_INFO
audio_errinfo      | SNDCTL_DSP_GETERROR

Also this struct uses a pointer:

typedef struct buffmem_desc {
        caddr_t buffer;
        int size;
} buffmem_desc;

and is used in SNDCTL_DSP_MAPINBUF, SNDCTL_DSP_MAPOUTBUF.

That's a total of 11 ioctls that would have to get COMPAT_FREEBSD32 shims.
However FreeBSD doesn't currently implement SNDCTL_PMGR_ACCESS,
SNDCTL_PMGR_IFACE, SNDCTL_SYNTH_INFO or SNDCTL_MIDI_INFO in any bitness (in
sys/dev/sound/midi/midi.c, midi_ioctl() return ENXIO for everything). FreeBSD
doesn't implement SNDCTL_DSP_MAPINBUF or SNDCTL_DSP_MAPOUTBUF either -
dsp_ioctl() has a comment saying "undocumented" and returns EINVAL.

11 - 6 = 5 ioctls that needs COMPAT_FREEBSD32 shims:
snd_chan_param     | AIOGFMT, AIOSFMT
snd_sync_parm      | AIOSYNC
snd_capabilities   | AIOGCAP
audio_errinfo      | SNDCTL_DSP_GETERROR
and maybe some mmap() changes.

I am going to try implement this.

-- 
You are receiving this mail because:
You are the assignee for the bug.