diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-11-19 19:14:33 -0500 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-11-19 19:14:33 -0500 |
commit | 3079aa262de8a5694d18c76bb6329b1aad2b989e (patch) | |
tree | 7e5e1f90c6ec89519aa7be525206a1b668efd9b5 | |
parent | a87c7c12ae62abe3a3d4bc9ebd5cfc4011cf3afb (diff) |
ICS: implement rollback mechanics
rollback the EIP on return to user space if TIF_ROLLBACK_RCS is set
-rw-r--r-- | arch/i386/kernel/signal.c | 9 | ||||
-rw-r--r-- | include/asm-i386/thread_info.h | 2 | ||||
-rw-r--r-- | include/linux/ics.h | 3 | ||||
-rw-r--r-- | kernel/ics.c | 6 |
4 files changed, 17 insertions, 3 deletions
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c index 65d7620eaa..e4ab40862b 100644 --- a/arch/i386/kernel/signal.c +++ b/arch/i386/kernel/signal.c | |||
@@ -27,6 +27,8 @@ | |||
27 | #include <asm/i387.h> | 27 | #include <asm/i387.h> |
28 | #include "sigframe.h" | 28 | #include "sigframe.h" |
29 | 29 | ||
30 | #include <linux/ics.h> | ||
31 | |||
30 | #define DEBUG_SIG 0 | 32 | #define DEBUG_SIG 0 |
31 | 33 | ||
32 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) | 34 | #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) |
@@ -653,5 +655,12 @@ void do_notify_resume(struct pt_regs *regs, void *_unused, | |||
653 | if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) | 655 | if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK)) |
654 | do_signal(regs); | 656 | do_signal(regs); |
655 | 657 | ||
658 | if (thread_info_flags & _TIF_ROLLBACK_RCS) { | ||
659 | long addr = (long) get_rollback_addr(); | ||
660 | if (addr) | ||
661 | regs->eip = addr; | ||
662 | clear_thread_flag(TIF_ROLLBACK_RCS); | ||
663 | } | ||
664 | |||
656 | clear_thread_flag(TIF_IRET); | 665 | clear_thread_flag(TIF_IRET); |
657 | } | 666 | } |
diff --git a/include/asm-i386/thread_info.h b/include/asm-i386/thread_info.h index 4b187bb377..fd9dd60afe 100644 --- a/include/asm-i386/thread_info.h +++ b/include/asm-i386/thread_info.h | |||
@@ -131,6 +131,7 @@ static inline struct thread_info *current_thread_info(void) | |||
131 | #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ | 131 | #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ |
132 | #define TIF_SECCOMP 8 /* secure computing */ | 132 | #define TIF_SECCOMP 8 /* secure computing */ |
133 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ | 133 | #define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal() */ |
134 | #define TIF_ROLLBACK_RCS 10 /* set EIP to rollback addr */ | ||
134 | #define TIF_MEMDIE 16 | 135 | #define TIF_MEMDIE 16 |
135 | #define TIF_DEBUG 17 /* uses debug registers */ | 136 | #define TIF_DEBUG 17 /* uses debug registers */ |
136 | #define TIF_IO_BITMAP 18 /* uses I/O bitmap */ | 137 | #define TIF_IO_BITMAP 18 /* uses I/O bitmap */ |
@@ -146,6 +147,7 @@ static inline struct thread_info *current_thread_info(void) | |||
146 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) | 147 | #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) |
147 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) | 148 | #define _TIF_SECCOMP (1<<TIF_SECCOMP) |
148 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) | 149 | #define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) |
150 | #define _TIF_ROLLBACK_RCS (1<<TIF_ROLLBACK_RCS) | ||
149 | #define _TIF_DEBUG (1<<TIF_DEBUG) | 151 | #define _TIF_DEBUG (1<<TIF_DEBUG) |
150 | #define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) | 152 | #define _TIF_IO_BITMAP (1<<TIF_IO_BITMAP) |
151 | #define _TIF_FREEZE (1<<TIF_FREEZE) | 153 | #define _TIF_FREEZE (1<<TIF_FREEZE) |
diff --git a/include/linux/ics.h b/include/linux/ics.h index 61dabe9693..f22654fb45 100644 --- a/include/linux/ics.h +++ b/include/linux/ics.h | |||
@@ -14,4 +14,7 @@ struct ics_cb { | |||
14 | int ics_stack[MAX_ICS_NESTING]; | 14 | int ics_stack[MAX_ICS_NESTING]; |
15 | }; | 15 | }; |
16 | 16 | ||
17 | /* get rollback addr for current task */ | ||
18 | void* get_rollback_addr(void); | ||
19 | |||
17 | #endif | 20 | #endif |
diff --git a/kernel/ics.c b/kernel/ics.c index e32693b880..7af33c3692 100644 --- a/kernel/ics.c +++ b/kernel/ics.c | |||
@@ -66,7 +66,7 @@ struct fdso_ops ics_ops = { | |||
66 | }; | 66 | }; |
67 | 67 | ||
68 | 68 | ||
69 | static void* get_rollback(void) | 69 | void* get_rollback_addr(void) |
70 | { | 70 | { |
71 | int err; | 71 | int err; |
72 | void* addr; | 72 | void* addr; |
@@ -114,7 +114,7 @@ static void abort_local_ics_reader(struct ics* ics) | |||
114 | if (!t->ics_cb) | 114 | if (!t->ics_cb) |
115 | return; | 115 | return; |
116 | 116 | ||
117 | rollback_addr = get_rollback(); | 117 | rollback_addr = get_rollback_addr(); |
118 | 118 | ||
119 | if (!rollback_addr) | 119 | if (!rollback_addr) |
120 | return; | 120 | return; |
@@ -129,7 +129,7 @@ static void abort_local_ics_reader(struct ics* ics) | |||
129 | /* garbage on stack */ | 129 | /* garbage on stack */ |
130 | return; | 130 | return; |
131 | if (ics == stacked) { | 131 | if (ics == stacked) { |
132 | arch_do_rollback(rollback_addr); | 132 | set_tsk_thread_flag(t, TIF_ROLLBACK_RCS); |
133 | atomic_inc(&ics->aborted_ctr); | 133 | atomic_inc(&ics->aborted_ctr); |
134 | return; | 134 | return; |
135 | } | 135 | } |