[AD] lsystem.c and the iopl call

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Can anyone explain this?

I have been using the real G2 SDK with allegro and linux.  I have found
that on some RealAudio links (live links) it cause my applications to
crash, with a SIGPIPE.  If I run my app without allegro_init() it does
not crash.  I looked at a strace and also noticed that it was a broken
pipe from a socket.  I also get a X windows error.  It appears the X
server is either going down.  So I looked into the lsystem.c file in the
src/linux/ directory and noticed in the sys_linux_init() function a call
to iopl()?  Below is a code snippet:

 /* This is the only bit that needs root privileges.  First
  * we attempt to set our euid to 0, in case this is the
  * second time we've been called. */
 __al_linux_have_ioperms  = !seteuid (0);
 __al_linux_have_ioperms &= !iopl (3);
 __al_linux_have_ioperms &= !__al_linux_init_memory();


The man page on iopl has an interesting paragraph:


DESCRIPTION
       iopl  changes  the I/O privilege level of the current pro­
       cess, as specified in level.

       This call is necessary to allow 8514-compatible X  servers
       to  run under Linux.  Since these X servers require access
       to all 65536 I/O ports, the ioperm call is not sufficient.

       In addition to granting unrestricted I/O port access, run­
       ning at a higher I/O privilege level also allows the  pro­
       cess  to disable interrupts.  This will probably crash the
       system, and is not recommended.

       Permissions are inherited by fork and exec.

       The I/O privilege level for a normal process is 0.

So I decide to comment the line out with the iopl() call.  My
application no longer crashes.  Is there a reason for setting the iopl
to level 3?  Is it because of the 8514 X Server?

Craig



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/