Re: Kernel stack....

Richard B. Johnson (root@chaos.analogic.com)
Tue, 11 Sep 2001 08:15:50 -0400 (EDT)


On Mon, 10 Sep 2001, Raghava Raju wrote:

>
>
> Hi,
>
> 1) I want to know what exactly is the structure
> of kernel stack. Is it some thing like bss,data,text?
>
> 2) I want to access kernel stack(in kernel
> mode). So I am using kernel stack pointer provided in
> thread_struct. So how to access different areas(.i.e
> data,text) in kernel stack.
>
>
> Any pointers will be helpful.
>
> Please mail me as I did't subscribe.
> vraghava_raju@yahoo.com
>
> Thank you.
> Raj.

I am assuming that you want to know how parameters loaded on the
stack are passed to called procedures, i.e., the offset. I assume
that you know that the kernel stack is just like a user stack and
you don't actually manipulate it directly.

Given:
procedure(one, two, three);
where one, two, and three are values of any size up to the length
of a register..

The called procedure gets the values as:

0x04(%esp) = one
0x08(%esp) = two
0x0c(%esp) = three

If, and only if, no registers are saved on the called procedure's
stack. If some register(s) have been saved, the parameters are
offset by the length of the register(s)...

proc: pushl %ebx
pushl %ecx
pushl %edx
pushl %edi # 4 * 4 = 0ffset 16
movl 0x14(%esp), %ebx # One
movl 0x18(%esp), %ecx # Two
movl 0x1c(%esp), %edx # Three

Cheers,
Dick Johnson

Penguin : Linux version 2.4.1 on an i686 machine (799.53 BogoMips).

I was going to compile a list of innovations that could be
attributed to Microsoft. Once I realized that Ctrl-Alt-Del
was handled in the BIOS, I found that there aren't any.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/