1
votes

I'd like to know the address range of kernel stack. For user-space process, we can use /proc/pid/maps to see the stack address range by keyword [stack], but do not know which one is kernel stack. For kernel thread, usually /proc/pid/maps is empty.

So how can I know the kernel stack address range, in user-space process and kernel thread for FreeBSD?


Edit:

It seems that kernel allocates two pages (IA-32) for each kernel thread, how could we find the address of these two pages under x86_64? (Maybe x86_64 is a little different)

2
FreeBSD or Linux? Pick one. They work rather differently. - user149341

2 Answers

0
votes

The kernel's stack is not (as far as I know) mapped into the address space of user processes at all.

0
votes

Under Linux kernel 3.10, a kernel thread can get its stack starting point by current->stack, where current is a pointer of struct task_struct.