kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* process descriptor address in kernel stack
@ 2020-03-19  8:53 , Samuel
  2020-03-19  9:22 ` Valdis Klētnieks
  0 siblings, 1 reply; 2+ messages in thread
From: , Samuel @ 2020-03-19  8:53 UTC (permalink / raw)
  To: kernelnewbies


[-- Attachment #1.1: Type: text/plain, Size: 882 bytes --]

In this book (understanding Linux kernel),

the kernel can easily obtain the address of the thread_info structure of
the process currently running on a CPU from the value of the esp register.
In fact, if the thread_union structure is 8 KB (213 bytes) long, the kernel
masks out the 13 least significant bits of esp to obtain the base address
of the thread_info structure; on the other hand, if the thread_union struc-
ture is 4 KB long, the kernel masks out the 12 least significant bits of
esp. This is done by the current_thread_info() function, which produces
assembly language instructions like the following:

 movl $0xffffe000,%ecx or 0xfffff000 for 4KB stacks
 andl %esp,%ecx
 movl %ecx,p

Why is *"stack pointer(esp) & 0xffffe000"* equal to the process descriptor
base address?

That means the base address of process descriptor is always *0xXYZ...000*,
right? It is weird.

[-- Attachment #1.2: Type: text/html, Size: 3423 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-19  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-19  8:53 process descriptor address in kernel stack , Samuel
2020-03-19  9:22 ` Valdis Klētnieks

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).