Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: David Daney <ddaney@avtrex.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: Franck Bui-Huu <vagabon.xyz@gmail.com>, linux-mips@linux-mips.org
Subject: Re: Cannot unwind through MIPS signal frames with	ICACHE_REFILLS_WORKAROUND_WAR
Date: Thu, 15 Nov 2007 09:21:10 -0800	[thread overview]
Message-ID: <473C8006.2070902@avtrex.com> (raw)
In-Reply-To: <20071115115351.GA4973@linux-mips.org>

Ralf Baechle wrote:
> On Thu, Nov 15, 2007 at 09:46:25AM +0100, Franck Bui-Huu wrote:
> 
>> Ralf Baechle wrote:
>>> Another reason is to get rid of the classic trampoline the kernel installs
>>> on the stack.  On some multiprocessor systems it requires a cacheflush
>> BTW, could we get rid of the trampoline so easily ? I mean won't we have
>> to keep it for backward compatibility reasons ?

There has to be some way for user code to unwind the call stack through 
signal handler frames.  For Linux/MIPS systems that use GCC as their 
system compiler, this is done by code in libgcc which is part of the GCC 
runtime.

Currently the unwinder examines the code at the signal handler return 
address and if it detects one of the several know trampoline code 
sequences, it makes assumptions about the way the kernel lays out the 
stack.  In particular, it assumes that there is a struct sigcontext at a 
  well known offset from the stack pointer at entry to the signal handler.

The code that handles this is in gcc/config/mips/linux-unwind.h

As of GCC-4.3 the location of the trampoline is unimportant, but the 
location of the sigcontext relative to the value in $sp is important and 
should not be changed unless there really is no other choice.


> 
> The trampolines are an implementation detail.  Little software needs to
> know about it, so while I expect some slight colateral damage from getting
> rid of trampolines it's not going to be painful.  GDB is the primary piece
> of software that will need to change.

And any user code that uses SIGSEGV to detect and handle dereferencing 
null pointers.

> 
> Some of the other architectures have an sa_restorer field in struct
> sigaction but we don't have that on MIPS.
> 
> One way to deal with this would be to do a similar as IRIX where the
> sigaction(2) takes a 4th argument which takes the role of sa_restorer.
> For backward compatibility an SA_RESTORER field.  So if the SA_RESTORER
> is clear we'd be using a classic trampoline, if it's set the value of
> the 4th argument.
> 
> Or slightly crazier, put a kernel address into the $ra register of the
> invoked signal handler.  So the signal handler will cause an address
> error exception which then can be trapped.  Additional advantage - some of
> the "Don't let your children do this ..." sections of code can go away ;-)

I am liking the idea of putting the trampoline code in the (as of yet 
non-existent vdso).  This eliminates the need to flush the icache, but 
maintains the ability of user code to unwind through signal frames.

Putting a .eh_frame section in the vdso would be even better as that 
would eliminate the need for libgcc to do code reading and let the 
kernel use any means desired to return from signal handlers.

David Daney

  reply	other threads:[~2007-11-15 17:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-13  7:52 Cannot unwind through MIPS signal frames with ICACHE_REFILLS_WORKAROUND_WAR David Daney
2007-11-13 11:48 ` Andrew Haley
2007-11-13 12:10   ` Ralf Baechle
2007-11-13 13:14     ` Franck Bui-Huu
2007-11-13 14:00       ` Ralf Baechle
2007-11-13 14:22         ` Franck Bui-Huu
2007-11-13 15:01           ` Ralf Baechle
2007-11-13 22:11             ` Andrew Pinski
2007-11-13 14:37       ` Kevin D. Kissell
2007-11-13 14:37         ` Kevin D. Kissell
2007-11-13 14:49         ` Franck Bui-Huu
2007-11-13 15:08         ` Ralf Baechle
2007-11-13 22:49           ` Cannot unwind through MIPS signal frames withICACHE_REFILLS_WORKAROUND_WAR Kevin D. Kissell
2007-11-13 22:49             ` Kevin D. Kissell
2007-11-13 21:26       ` VDSO on mips (was Re: Cannot unwind through MIPS signal frames with ICACHE_REFILLS_WORKAROUND_WAR) Franck Bui-Huu
2007-11-15  8:46     ` Cannot unwind through MIPS signal frames with ICACHE_REFILLS_WORKAROUND_WAR Franck Bui-Huu
2007-11-15 11:53       ` Ralf Baechle
2007-11-15 17:21         ` David Daney [this message]
2007-11-17  8:38           ` Franck Bui-Huu
2007-11-13 16:12 ` David Daney

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=473C8006.2070902@avtrex.com \
    --to=ddaney@avtrex.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    --cc=vagabon.xyz@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