iopl - Linux

This is a discussion on iopl - Linux ; Hello, I've been playing with iopl system call and I found out that its code (linux/arch/x86/kernel/ioport_32.c) only sets a few variables. But I couldn't find the code that checks those variables, like iopl variable in the thread struct, for instance. ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: iopl

  1. iopl

    Hello,

    I've been playing with iopl system call and I found out that its code
    (linux/arch/x86/kernel/ioport_32.c) only sets a few variables. But I
    couldn't find the code that checks those variables, like iopl variable
    in the thread struct, for instance. I'm trying to investigate why cli
    and sti instructions segfault if used when iopl level is less than 3,
    but they don't if used with iopl level 3. Could anyone give me some
    pointers?

    []'s
    Rafael

  2. Re: iopl

    On Jan 27, 9:42 am, "Rafael C. Almeida" wrote:

    > I've been playing with iopl system call and I found out that its code
    > (linux/arch/x86/kernel/ioport_32.c) only sets a few variables.


    The variables that it sets are CPU configuration variables.

    > But I
    > couldn't find the code that checks those variables, like iopl variable
    > in the thread struct, for instance.


    The checks are done by the CPU itself.

    > I'm trying to investigate why cli
    > and sti instructions segfault if used when iopl level is less than 3,
    > but they don't if used with iopl level 3. Could anyone give me some
    > pointers?


    Google for "cli sti iopl". The basic idea is that the CPU will fault
    if a sensitive I/O instruction is issued when the CPL (current
    privilege level) is less than the IOPL (I/O Privilege Level).

    http://www.x86.org/articles/pvi1/pvi1.htm
    Read the introduction.

    DS

  3. Re: iopl

    On Sun, 27 Jan 2008 11:55:48 -0800 (PST)
    David Schwartz wrote:

    > On Jan 27, 9:42 am, "Rafael C. Almeida" wrote:
    >
    > > I've been playing with iopl system call and I found out that its code
    > > (linux/arch/x86/kernel/ioport_32.c) only sets a few variables.

    >
    > The variables that it sets are CPU configuration variables.


    Even this one?
    t->iopl = level << 12;
    where
    struct thread_struct *t = &current->thread;
    it seems to just hold the value that will be set to eflags.


    > > But I
    > > couldn't find the code that checks those variables, like iopl variable
    > > in the thread struct, for instance.

    >
    > The checks are done by the CPU itself.
    >
    > > I'm trying to investigate why cli
    > > and sti instructions segfault if used when iopl level is less than 3,
    > > but they don't if used with iopl level 3. Could anyone give me some
    > > pointers?

    >
    > Google for "cli sti iopl". The basic idea is that the CPU will fault
    > if a sensitive I/O instruction is issued when the CPL (current
    > privilege level) is less than the IOPL (I/O Privilege Level).
    >
    > http://www.x86.org/articles/pvi1/pvi1.htm
    > Read the introduction.
    >
    > DS


    That site made things a lot clearer, thanks.

+ Reply to Thread