linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Mitesh <miteshnet@hotmail.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: Exit points for returning from kernel mode to user mode
Date: Wed, 25 Jun 2008 08:21:51 +1000	[thread overview]
Message-ID: <1214346111.8011.374.camel@pasglop> (raw)
In-Reply-To: <BAY124-DS415CCF7A303D59AD03437BEA10@phx.gbl>

On Tue, 2008-06-24 at 15:22 -0600, Mitesh wrote:
>  I am trying to understand exit points from kernel mode to user mode.
> I believe this happens when the scheduler is invoked, there are
> interrupts, exceptions, or the kernel is executing system call in
> process context. 
>  
> Is there a single function which is called in the ppc kernel when the
> mode is switched back to user mode ? 
>  
> I have linux 2.6.16.21 kernel running on a 4-way p550 IBM pSeries with
> POWER5 processors. Everytime before a process begins executing in user
> mode I want to execute a special SMT thread priority assembler
> instruction. 
>  
> What code files should I be looking at, is there one place this can be
> done? Any tips are appreciated.

You need to look for the code path that returns from an interrupt (ie.
that includes system call exceptions).

There are actually a few flavours of this for 64 bits:

 - If the interrupt is an SLB miss, this is a fairly fast path,
all assembly, all in real mode. However, it doesn't have any existing
code to differenciate return to userspace or return to the kernel. This
is in head_64.S, function slb_miss_realmode.

 - There is similar code for STAB exceptions (pre-POWER4 machines)

 - fast_exception_return, still in head_64.S, is used for short
exceptions that don't change the interrupt or scheduling status of the
task, such as servicing an FP or VMX unavailable interrupt. Note that
this can be used to return to the kernel as well as userspace. There is
some conditional code for user (look at the virt CPU accounting bits)
but it's a fair way before the actual rfid.

 - in entry_64.S, the main syscall exit path when there is no "work"
(ie, no pending signal, no need to schedule, ...) which is some way
after the "syscall_error_cont:" label.

 - same file, some way after the "restore:" label, this is the "main"
path when returning from an interrupt (ie, all the cases not above).


Cheers,
Ben.

      reply	other threads:[~2008-06-24 22:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-24 21:22 Exit points for returning from kernel mode to user mode Mitesh
2008-06-24 22:21 ` Benjamin Herrenschmidt [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=1214346111.8011.374.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=miteshnet@hotmail.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;
as well as URLs for NNTP newsgroup(s).