Skip to contentSkip to conversation

pid offset into task structre

DISCUSSION Fabiano Ramos 2 participants 2 messages Oct 21, 2004 – Oct 22, 2004

lore
Share & tools
lore
#0 lore raw

Hi All. Some newbie question.

I am writing some assembly code where I need to access the pid that issue
a certain syscall. In entry.S, in the syscall stub, I wrote:

GET_THREAD_INFO(%ebp)
movl TI_task(%ebp), %ebp
movl PID_OFFSET(%ebp), %ebx

Questions are:
1) Considering that I provided the correct value in PID_OFFSET, will
ebx contain the pid of the task that issued the syscall, at the end of the fragment?

2) By taking some address arithmetic (&tsk.pid - &tsk) I got 144. Is this
offset always the same? Is that an easy way to get it directly from assembly code?

TIA,
Fabiano

#1 lore raw
Quoted 4 lines · Fabiano Ramos

Hi All. Some newbie question.
1) Considering that I provided the correct value in PID_OFFSET, will
ebx contain the pid of the task that issued the syscall, at the end of the fragment?

yes

Quoted 3 lines

2) By taking some address arithmetic (&tsk.pid - &tsk) I got 144. Is this
offset always the same? Is that an easy way to get it directly from assembly code?

Generate it from arch/$ARCH/kernel/asm-offset.c with the same mecanism that TI_task uses.

something like:

	OFFSET(TASK_pid, task_struct, pid);
Signature · 1 line
Tab