All of lore.kernel.org
 help / color / mirror / Atom feed
From: thibaut@sautereau.fr (Thibaut SAUTEREAU)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Where does kernel stores it's registers while performing a context switch?
Date: Sat, 7 Oct 2017 22:08:10 +0700	[thread overview]
Message-ID: <20171007150809.GA20176@gandi.net> (raw)
In-Reply-To: <CAEcV-6EA34hXD+OvjMg8mcRpmQJHNAg5Sjfy1thxMCXOPw6+kQ@mail.gmail.com>

On Sat, Oct 07, 2017 at 07:22:49PM +0530, Ketan Singh wrote:
> I want to know where the kernel stores it's registers while performing
> a context switch on x86 architecture. In ARM I can see  struct
> cpu_context_save in arch/arm/include/asm/thread_info.h but what about
> x86/x86_64?

Are you talking about context switches between two different threads? If
so, on x86, EIP and other CPU registers are saved onto the kernel stack
of the thread, then ESP is saved in the thread_struct structure which is
itself included in task_struct. The kernel function that handles that is
switch_to(), you might want to take a look at it.

If you were talking about switches between kernel and user modes, on x86
it is managed like interrupts, on x86_64 you should read about the task
state segment (TSS).

Hope this helps,


Thibaut

      reply	other threads:[~2017-10-07 15:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-07 13:52 Where does kernel stores it's registers while performing a context switch? Ketan Singh
2017-10-07 15:08 ` Thibaut SAUTEREAU [this message]

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=20171007150809.GA20176@gandi.net \
    --to=thibaut@sautereau.fr \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.