lkml.org 
[lkml]   [2015]   [Feb]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/3] CRISv32: don't attempt syscall restart on irq exit
On Sun, Feb 08, 2015 at 09:45:02PM +0100, Rabin Vincent wrote:
> r9 is used to determine whether syscall restarting must be performed or
> not. Unfortunately, r9 is never set to zero in the non-syscall path,
> and r9 is on top of that a callee-saved register which can be set to
> non-zero by the C functions that are called during IRQ handling.
>
> This means that if r10 (used for the syscall return value) is one of the
> -ERESTART* values when a hardware interrupt occurs which leads to a
> signal being delivered to the process, the kernel will "restart" a
> syscall which never occurred. This will lead to the PC being moved back
> by 2 on return to user space.
>
> Fix the problem by setting r9 to zero in the interrupt path.
>
> Test case (should loop forever but ends up executing the break 8 trap
> instruction):
>
> #include <signal.h>
> #include <stdlib.h>
> #include <sys/time.h>
>
> void f(int n)
> {
> register int r9 asm ("r9") = 1;
> register int r10 asm ("r10") = n;
>
> __asm__ __volatile__(
> "ba 1f \n"
> "nop \n"
> "break 8 \n"
> "1: ba . \n"
> "nop \n"
> :
> : "r" (r9), "r" (r10)
> : "memory");
> }
>
> void handler1(int sig) { }
>
> int main(int argc, char *argv[])
> {
> struct itimerval t1 = { .it_value = {1} };
>
> signal(SIGALRM, handler1);
> setitimer(ITIMER_REAL, &t1, NULL);
>
> f(-513); /* -ERESTARTNOINTR */
>
> return 0;
> }
>
> Signed-off-by: Rabin Vincent <rabin@rab.in>

Nice, added in the CRIS tree for 3.20.

/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com


\
 
 \ /
  Last update: 2015-02-09 11:01    [W:0.089 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site