Thread (3 messages) flat view 3 messages, 2 authors, 2021-06-16

Re: Discussion of a possible modern alternate of the removed Sysctl syscall

From: Luís Mendes <hidden>
Date: 2021-06-16 15:37:09

Hi Greg,

Replies follow below.

Thanks,
Luis

On Wed, Jun 16, 2021 at 3:28 PM Greg KH [off-list ref] wrote:
On Wed, Jun 16, 2021 at 02:40:13PM +0100, Luís Mendes wrote:
quoted
Dear Linux kernel maintainers/developers,


I would like to discuss a modern alternate to Sysctl syscall and its
feasibility for armhf and aarch64 for supporting ioperm, iopl, inb,
outb and their siblings APIs emulation in Glibc, or even on an
external library to provide such sys/io.h API compatibility with
x86_64.

The advantage of having ioperm, iopl, inb and outb emulation for armhf
What is "armhf"?
armhf is a common acronym for arm 32-bits with an hardware floating point unit.
quoted
and aarch64 is that they can provide cross-compilation ability of
x86_64 applications and constitutes an easy and practical API for
simple I/O. This was not only useful for old ISA cards as it is today
for PCIe cards with I/O space, like I/O cards, LPT Parallel interface
cards, as well as many other cards that may have PCIe I/O space
(network cards, etc). PCIe LPT interface cards as well as
multi-function cards are still widely available, just search ebay or
amazon, and many suggestions will pop up.

I know for instance that LPT interface cards have their ppdev driver
which already provides an ioctl interface to access the card I/O
lines, but it is not performant for applications like bit-banging an
LPT card to load firmware into a micro-controller, for instance,
Microchip/ATMEL 8-bit micro-controllers. Plus the ioperm, iopl, inb,
outb has a simpler API for doing simple interactions with the I/O
space, like is the case with the IO lines of the LPT parallel
interface card.
You should never use iopl, inb, and outb on modern systems, sorry.
Please use the bus-specific ways to access the devices needed, or mmap
the needed memory ranges into your program and directly access them that
way if you know what you are doing for your specific hardware type (the
UIO api provides this for you.)
I understand that. It is just that since it is allowed and has been
allowed on x86_64 for a long time, and is in use by many
applications... so that for simplicity and cross-compatibility that it
could be made available once again for armhf as it was up until kernel
5.5 and the glibc version available at that time.
If the roadmap for user applications is towards UIO api, while
deprecating the inb, outb, I will have a look at that API for armhf. I
do know that mmap will not work for accessing PCIe IO spaces for
armhf, or at least not consistently across kernel versions, from my
experience. It only worked for PCIe memory regions. I will re-check
all that.
quoted
There are many complaints in the web, like bug reports and
cross-compilation issues/reports regarding sys/io.h removal on armhf.
There are also people wishing for such functionality on aarch64.


I had an application working up to two years ago on two armhf systems
(armv7) on imx6q and mvebu architectures, to be concrete. The
application did and does just that, currently only for x84_64, but it
is able to bit-bang the ports to load the firmware into the chips. I
just didn't got to up-stream these quite small changes, like selecting
(in the kernel configuration):
General setup->Configure standard Kernel features (expert
users)->Sysctl syscall support->Enable
and do:
arch/arm/mach-imx/mach-imx6q.c, function __init imx6q_init_late(void)
and appended:

   register_isa_ports(0xfee0000, 0x1f80000, 0);

Which is the PCIe IO memory region in the imx6q memory map. It was
just a matter of up-streaming the change. It maybe also useful to
rename register_isa_ports to register_pci_ports, or so in the kernel,
to avoid this confusion regarding to ISA bus only applicability.
As I stated above, you can access PCI IO memory regious through the UIO
api and mmap them and talk directly to them if you want to.  There is no
need to do old-style inb commands anymore for stuff like this, and
hasn't been for decades now.
I have tried mmap for PCIe I/O spaces but it didn't work on arhmf. It
only works for memory regions, or at least it was like that, last time
I tried. Regarding UIO I confess I have not tried UIO yet.
quoted
So I would like to have some opinions regarding the introduction of a
modern alternate for the sysctl syscall update in order to achieve
Glibc cross-compatibility for armhf and possibly aarch64 of what
already exists in Glibc for x86_64. What do you say?
sysctl should not have anything to do with i/o accesses.  I don't know
how that got somehow tied together in glibc, but that seems like a glibc
issue, not a kernel one :)
I believe it had to do with user permissions management for accessing
I/O regions. Anyway all that code has been stripped off glibc once the
sysfs syscall was removed.
thanks,

greg k-h
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help