All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: astian <astian@memeware.net>
Cc: linux-man <linux-man@vger.kernel.org>,
	libc-alpha@sourceware.org,  Thomas Gleixner <tglx@kernel.org>,
	Andy Lutomirski <luto@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: ioperm(2): confusing terminology
Date: Sun, 13 Sep 2026 00:48:57 +0200	[thread overview]
Message-ID: <aqXWu0bKoK_XMuLT@devuan> (raw)
In-Reply-To: <aqXOgqne-v4GtglY@devuan>

[-- Attachment #1: Type: text/plain, Size: 3792 bytes --]

Oops; I've fixed the mailing list address now.


Cheers,
Alex

> Date: 2026-09-13 00:24:17+0200
> From: Alejandro Colomar <alx@kernel.org>
>
> Hi astian,
> 
> > Date: 2026-09-12 22:00:57+0000
> > From: astian <astian@memeware.net>
> >
> > ioperm(2) says:
> > 
> >   int ioperm(unsigned long from, unsigned long num, int turn_on);
> > 
> >   ioperm() sets the port access permission bits for the calling thread
> >   for num bits starting from port address from.  If turn_on is nonzero,
> >   then permission for the specified bits is enabled; otherwise it is
> >   disabled. [...]
> > 
> > The use of "bits" here is confusing/sloppy.
> > 
> > ioperm is supposed to enable or disable permission to access IO ports
> > for the calling thread.  In this API, the "permission bit" (singular) is
> > really "turn_on": 0 to disable access, non-zero to enable.  However this
> > description refers also "num bits starting from port address from" and
> > "the specified bits".  That seems to suggest that IO ports somehow refer
> > to "bits" and this API controls access permission to them, which is
> > bewildering.
> > 
> > Searching around I have seen that other versions of this manpage used to
> > say "bytes" instead of "bits", which is only slightly less bewildering.
> > Ports/addresses in the IO space refer neither to bits nor to bytes per
> > se, they are an abstract interface, like a syscall number/index.
> > (Architecturally, in some cases, these indices may in fact map to
> > processor registers which may in fact be portions of a contiguous
> > internal memory, so in some cases one could correctly say that the ports
> > refer to "bytes" in such memory, but this is obviously all very
> > low-level and microarchitecture-specific.  I think being aware of such
> > details actually makes this description more confusing.)
> > 
> > Apparently the reason for this confusing description is that for Linux
> > ioperm is a syscall and the kernel implements this syscall using a
> > bitmap with 1 bit (permitted/denied) for each port, in a contiguous
> > sequence.  See ksys_ioperm in "arch/x86/kernel/ioport.c".
> > 
> > Thus "num bits starting from port address from" actually refers to the
> > bits of that bitmap: the bits [from, from+num) are set according to
> > turn_on.
> > 
> > This kind of implicit reference to implementation details is wicked.
> > 
> > Suggested change:
> > 
> >   ioperm() sets the calling thread's access permission for num ports
> >   starting from port address from.  If turn_on is nonzero, then
> >   permission for the specified ports is enabled; otherwise it is
> >   disabled. [...]
> 
> Hmmm, sounds reasonable.  Do you want to send a patch?  Or should
> I write it?  (I don't mind; just asking in case you want to do it.)
> 
> > PS: Oh, also, maybe the title should say "set input/output port
> > permissions" instead of "set port input/output permissions".
> 
> Same here.
> 
> BTW, the manual page also says:
> 
>      This  call  is  mostly for the i386 architecture.  On many
>      other architectures it does not exist or will  always  re‐
>      turn an error.
> 
> Is this still true?
> 
> Another issue:
> 
>      EIO    (on PowerPC) This call is not supported.
> 
> Is this really true?  Where this is not supported, I expect ENOSYS.
> 
> And yet another thing: should we document the parameters as being
> uintptr_t instead of unsigned long?  They are the same exact type
> always, AFAIK.  Or is there any system where they aren't?  If they are
> the same, uintptr_t will better document that they are addresses.
> 
> 
> Have a lovely night!
> Alex
> 
> -- 
> <https://www.alejandro-colomar.es>



-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-09-12 22:49 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 22:00 ioperm(2): confusing terminology astian
2026-09-12 22:24 ` Alejandro Colomar
2026-09-12 22:48   ` Alejandro Colomar [this message]
2026-09-13  6:29   ` astian
2026-09-14 12:56     ` Alejandro Colomar
2026-09-15 15:39       ` Markdown as a "less hairy" source format for man pages (was: ioperm(2): confusing terminology) G. Branden Robinson
2026-09-17  7:05         ` Markdown as a "less hairy" source format for man pages astian
2026-09-17  7:04       ` ioperm(2): confusing terminology astian
2026-09-17 11:00         ` Alejandro Colomar
2026-09-17 19:09           ` astian
2026-09-17 19:34             ` Alejandro Colomar
2026-09-17  6:16   ` [PATCH 1/2] man/man2/ioperm.2: Reword slightly for clarity astian
2026-09-17 11:59     ` Alejandro Colomar
2026-09-17  6:16   ` [PATCH 2/2] man/man2/ioperm.2: wfix astian
2026-09-17 11:59     ` Alejandro Colomar
2026-09-17 12:38       ` ioperm(2): confusing terminology G. Branden Robinson
2026-09-17 13:18         ` Alejandro Colomar
2026-09-17 19:08         ` astian
2026-09-17 23:02           ` G. Branden Robinson
2026-09-17 19:11       ` [PATCH 2/2] man/man2/ioperm.2: wfix astian
2026-09-17 19:58       ` [PATCH] man/man5/proc_ioports.5: wfix astian
2026-09-17 23:09         ` G. Branden Robinson
2026-09-17 23:16           ` Alejandro Colomar
2026-09-18  7:03         ` [PATCH v2] " astian
2026-09-17 19:57     ` [PATCH v2] man/man2/ioperm.2: wfix astian

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aqXWu0bKoK_XMuLT@devuan \
    --to=alx@kernel.org \
    --cc=astian@memeware.net \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-man@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.