Re: Getting "current" task's pointer in 2.6

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi jon,

I was trying out your module.

i have a makefile in my working dir which has just one line

obj-m := threadinfo_test.o

i compile the module with the following command

$ make -C /usr/src/linux-2.6.9 M=$PWD modules
make: Entering directory `/usr/src/linux-2.6.9'
  CC [M]  /home/msandhu/test/threadinfo_test.o
include/linux/time.h: In function `jiffies_to_timespec':
include/linux/time.h:257: invalid register name `r4' for register variable
include/linux/time.h:257: invalid register name `r0' for register variable
include/linux/time.h:257: invalid register name `r2' for register variable
include/linux/time.h:257: invalid register name `r1' for register variable
include/linux/time.h:257: unknown register name `lr' in `asm'
include/linux/time.h:257: unknown register name `ip' in `asm'
include/linux/time.h: In function `jiffies_to_timeval':
include/linux/time.h:295: invalid register name `r4' for register variable
include/linux/time.h:295: invalid register name `r0' for register variable
include/linux/time.h:295: invalid register name `r2' for register variable
include/linux/time.h:295: invalid register name `r1' for register variable
include/linux/time.h:295: unknown register name `lr' in `asm'
include/linux/time.h:295: unknown register name `ip' in `asm'
include/asm/semaphore.h: In function `down':
include/asm/semaphore.h:77: unknown register name `lr' in `asm'
include/asm/semaphore.h:77: unknown register name `ip' in `asm'
include/asm/semaphore.h: In function `down_interruptible':
include/asm/semaphore.h:87: unknown register name `lr' in `asm'
include/asm/semaphore.h:87: unknown register name `ip' in `asm'
include/asm/semaphore.h: In function `down_trylock':
include/asm/semaphore.h:92: unknown register name `lr' in `asm'
include/asm/semaphore.h:92: unknown register name `ip' in `asm'
include/asm/semaphore.h: In function `up':
include/asm/semaphore.h:103: unknown register name `lr' in `asm'
include/asm/semaphore.h:103: unknown register name `ip' in `asm'
make[1]: *** [/home/msandhu/test/threadinfo_test.o] Error 1
make: *** [_module_/home/msandhu/test] Error 2
make: Leaving directory `/usr/src/linux-2.6.9'


my running kernel is a 2.6.4 and the source i'm using is that of 2.6.9
(that should'nt cause any problems right....?)

Why is it picking up all those RISC registers....!! :(

Thanks and a happy new year to you.

-mandeep


On Mon, 2005-01-03 at 09:03, Jon Masters wrote:
> On Thu, 30 Dec 2004 12:03:24 +0530, Mandeep Sandhu
> <Mandeep_Sandhu@xxxxxxxxxxx> wrote:
> 
> > I was going through RML's book (ch. 2). There he mentions that
> > having the new structure "thread_info" helps in calculating the
> > offsets using assembly code rather easily. How does having a struct
> > (which has a pointer to task_struct) stored on the top a process
> > kernel stack be more advantageous than storing a pointer to
> > task_struct itself on the same location!?
> 
> He's referring to the fact that thread_info contains a few very useful
> elements that we might want to access quickly - for other stuf we need
> to resort to the task_struct itself. As rml also notes, the current
> task is often available for indirection access via a specific register
> when in kernel mode - r2 on PowerPC (sorry rml, for once thinking that
> was incorrect).
> 
> > Furthermore the assembly code used to get a pointer to thread_info
> > masks the lower 13 bits to obtain the pointer.
> 
> It masks out the kernel mode stack to get at the thread_info at the bottom.
> 
> > I was trying to
> > do a "sizeof" of struct thread_info from a sample prog. but was
> > getting errors when i tried to include linux/thread_info.h.....so
> > i thought i'll ask here! :)
> 
> Don't include that directly in userspace, copy the struct define and
> use that if needed. Perhaps also just write a very simple LKM to do it
> for you:
> 
> /*
>  * threadinfo_test.c - A simple test LKM.
>  *
>  */
> 
> #include <linux/module.h>        /* module macros */
> #include <linux/init.h>          /* init macros */
> 
> #include <linux/config.h>
> #include <linux/errno.h>
> #include <linux/kernel.h>
> 
> int __init threadinfo_init(void)
> {
> 
>         printk("The size of thread_info is %d bytes.\n",
>                 sizeof(struct thread_info));
> 
>         return 0;
> }
> 
> void __exit threadinfo_exit(void)
> {
> }
> 
> module_init(threadinfo_init);
> module_exit(threadinfo_exit);
> 
> MODULE_AUTHOR("Jon Masters <jcm@xxxxxxxxxxxxxx>");
> MODULE_LICENSE("GPL");
> 
> Cheers,
> 
> Jon.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux