public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Hudec <bulb@ucw.cz>
To: aq <aquynh@gmail.com>
Cc: suthambhara nagaraj <suthambhara@gmail.com>,
	"Dhiman, Gaurav" <gaurav.dhiman@ca.com>,
	main kernel <linux-kernel@vger.kernel.org>,
	kernel <kernelnewbies@nl.linux.org>
Subject: Re: Kernel stack
Date: Tue, 12 Oct 2004 12:27:31 +0200	[thread overview]
Message-ID: <20041012102731.GQ703@vagabond> (raw)
In-Reply-To: <9cde8bff04101203052a711063@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]

On Tue, Oct 12, 2004 at 19:05:52 +0900, aq wrote:
> > There is no SS entry, because SS does not specify the stack. It is siply
> > a segment in which the stack lives. Any segment, that covers all address
> > space will do! IIRC in kernel SS == DS.
> yes, if I am right, in Linux SS, DS and CS all point to the same base
> address ( = 0 ?). To be exact, SS !=DS, since the segment registers in
> protected mode point to segment selectors (in GDT ?), and we should
> compare the value stored GDT entries, not the value of SS and DS in
> this case.

Of course. Though since DS and SS need the same parameters, they might
actualy point to the same GDT entry. I don't know if they actualy do,
though.

By the way, C compilers usualy set SS and DS with same base. They would
have to do conversion when taking pointers to local variables otherwise.

> > The kernel stack is allocated together with the task_struct. Two pages
> > are allocated and task_struct is placed at the start while the stack is
> > placed at the end and grows down towards the task_struct.
> 2 pages of kernel stack or not is optional. Recently version of kernel
> allow you to choose to use 4K or 8K size for kernel stack.

Yes, it does. Few people touch the "Kernel Hacking" though...

> >From what you all discuss, I can say: kernel memory is devided into 2
> part, and the upper part are shared between processes. The below part
> (the kernel stack, or 8K traditionally) is specifict for each process.
> 
> Is that right?

No, it's not. There is just one kernel memory. In it each process has
it's own task_struct + kernel stack (by default 8K). There is no special
address mapping for these, nor are they allocated from a special area.

When a context of some process is entered, esp is pointed to the top of
it's stack. That's exactly all it takes to exchange stacks.

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

  reply	other threads:[~2004-10-12 10:28 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <577528CFDFEFA643B3324B88812B57FE3055B9@inhyms21.ca.com>
2004-10-12  6:51 ` Kernel stack suthambhara nagaraj
2004-10-12  9:41   ` Jan Hudec
2004-10-12 10:05     ` aq
2004-10-12 10:27       ` Jan Hudec [this message]
2004-10-12 12:30         ` aq
2004-10-12 13:11           ` Jan Hudec
2004-10-12 14:30     ` Jon Masters
2004-10-12 14:31       ` Jan Hudec
2004-10-13  5:03 Thekkedath, Gopakumar
  -- strict thread matches above, loose matches on Subject: below --
2004-10-13  4:35 Dhiman, Gaurav
2004-10-14 19:31 ` Denis Vlasenko
2004-10-12  7:51 Thekkedath, Gopakumar
2004-10-12  6:15 kernel stack suthambhara nagaraj
2004-10-12 11:09 ` Neil Horman
2004-10-13  3:29   ` suthambhara nagaraj
2004-10-14  3:15     ` suthambhara nagaraj
2001-09-11 15:53 Kernel stack Richard J Moore
2001-09-10 21:47 Raghava Raju
2001-09-10 21:57 ` Erik Mouw
2001-09-11 10:31   ` Emmanuel Varagnat
2001-09-11 12:15 ` Richard B. Johnson
2001-08-27 22:24 Raghava Raju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041012102731.GQ703@vagabond \
    --to=bulb@ucw.cz \
    --cc=aquynh@gmail.com \
    --cc=gaurav.dhiman@ca.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=suthambhara@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox