x86 port i/o broken on recent kernel

Richard Weinberger richard.weinberger at gmail.com
Wed Mar 30 12:14:53 CEST 2022


The following test works fine on 5.4.180 (ipipe) but fails on 5.15.9 (dovetail).

$ ./iotest
Segmentation fault
$ dmesg
[Xenomai] switching iotest to secondary mode after exception #13 from
user-space at 0x400b8d (pid 14574)
traps: iotest[14574] general protection fault ip:400b8d
sp:7feb57915e20 error:0 in iotest[400000+1000]

Wild guess, Linux's iopl() emulation might play a role.

* gcc iotest.c `/usr/xenomai/bin/xeno-config --cflags --ldflags
--skin=posix` -Wall -o iotest

#include <assert.h>
#include <pthread.h>
#include <sched.h>
#include <sys/io.h>

static void *tfn(void *d)
       struct sched_param schedp = {0};

       schedp.sched_priority = 1;
       assert(sched_setscheduler(0, SCHED_FIFO, &schedp) == 0);

       outb(0xFF, 0x378);

       return NULL;

int main(void)
       pthread_t t;

       assert(iopl(3) == 0);
       pthread_create(&t, NULL, tfn, NULL);
       pthread_join(t, NULL);

       return 0;


More information about the Xenomai mailing list