Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I'm running a 2.6.2.14-72.fc6 i586 kernel and I'm tring to figure out how it calculates the the current value in a kernel module. I took a objdump of a ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    current macro


    Hi,

    I'm running a 2.6.2.14-72.fc6 i586 kernel and I'm tring to figure out how it calculates the the current value in a kernel module. I took a objdump of a kernel module with the current marco and it produced this:

    Code:
    mov %fs:0x0, %eax
    mov %eax, 0xc
    and checking the %eax register I found it contained the current value but this is no help since I don't know what or how 0x0 (from %fs:0x0) is calculated

    The only info I have on the current macro is from an old book and it states that the current value is arrived at by masking the %esp register with 0xffffe000 but an example of the values I get from my kernel module are:

    current->0xc3608600
    esp------>0xc2ef2e94

    which doesn't compute...Thanks Gerard4143

  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Location
    Canada, Prince Edward Island
    Posts
    714

    Found the answer

    Found the answer at this web page:

    http://kernelnewbis.org/faq/current

    essentially the struct task_struct is now included in a struct thread_info that resides at the bottom of the user kernel stack and my code for accessing it

    Code:
    struct thread_info *myti = 0;
    
    void somefunc(void)
    {
    __asm__ __volatile__ 
    (
    "pushl %eax\n\t"
    "movl %esp, %eax\n\t"
    "andl $0xfffff000, %eax\n\t"
    "movl %eax, myti\n\t"
    "popl %eax\n\t"
    )
    
    printk("myti->task->pid->%d\n", myti->task->pid);
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •