aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 12:01:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-23 12:01:41 -0400
commit3a8580f82024e30b31c662aa49346adf7a3bcdb5 (patch)
tree7769a01f152b4081f4e4225e499082fd5c67b184 /arch
parent1d767cae4dbd4116fc3b2cc3251a20760f98339f (diff)
parent2ccf62b36097aa88e0ea152d6ef0c0ca2d3884e6 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml
Pull UML updates from Richard Weinberger: "Most changes are bug fixes and cleanups" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml: um: missing checks of __put_user()/__get_user() return values um: stub_rt_sigsuspend isn't needed these days anymore um/x86: merge (and trim) 32- and 64-bit variants of ptrace.h irq: Remove irq_chip->release() um: Remove CONFIG_IRQ_RELEASE_METHOD um: Remove usage of irq_chip->release() um: Implement um_free_irq() um: Fix __swp_type() um: Implement a custom pte_same() function um: Add BUG() to do_ops()'s error path um: Remove unused variables um: bury unused _TIF_RESTORE_SIGMASK um: wrong sigmask saved in case of multiple sigframes um: add TIF_NOTIFY_RESUME um: ->restart_block.fn needs to be reset on sigreturn
Diffstat (limited to 'arch')
-rw-r--r--arch/um/Kconfig.common5
-rw-r--r--arch/um/defconfig1
-rw-r--r--arch/um/drivers/chan_kern.c9
-rw-r--r--arch/um/drivers/line.c2
-rw-r--r--arch/um/drivers/net_kern.c4
-rw-r--r--arch/um/drivers/port_kern.c2
-rw-r--r--arch/um/drivers/xterm_kern.c2
-rw-r--r--arch/um/include/asm/pgtable.h10
-rw-r--r--arch/um/include/asm/thread_info.h2
-rw-r--r--arch/um/include/shared/irq_kern.h2
-rw-r--r--arch/um/kernel/irq.c9
-rw-r--r--arch/um/kernel/process.c10
-rw-r--r--arch/um/kernel/signal.c14
-rw-r--r--arch/um/kernel/skas/syscall.c2
-rw-r--r--arch/um/kernel/tlb.c1
-rw-r--r--arch/um/os-Linux/skas/mem.c10
-rw-r--r--arch/x86/um/asm/elf.h42
-rw-r--r--arch/x86/um/asm/ptrace.h34
-rw-r--r--arch/x86/um/asm/ptrace_32.h23
-rw-r--r--arch/x86/um/asm/ptrace_64.h26
-rw-r--r--arch/x86/um/shared/sysdep/ptrace.h67
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_32.h92
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_64.h101
-rw-r--r--arch/x86/um/signal.c29
-rw-r--r--arch/x86/um/sys_call_table_64.c1
-rw-r--r--arch/x86/um/syscalls_32.c12
-rw-r--r--arch/x86/um/sysrq_32.c8
-rw-r--r--arch/x86/um/sysrq_64.c8
-rw-r--r--arch/x86/um/tls_32.c2
29 files changed, 201 insertions, 329 deletions
diff --git a/arch/um/Kconfig.common b/arch/um/Kconfig.common
index 20a49ba93cb9..43ef890d292c 100644
--- a/arch/um/Kconfig.common
+++ b/arch/um/Kconfig.common
@@ -56,11 +56,6 @@ config GENERIC_CLOCKEVENTS
56 bool 56 bool
57 default y 57 default y
58 58
59# Used in kernel/irq/manage.c and include/linux/irq.h
60config IRQ_RELEASE_METHOD
61 bool
62 default y
63
64config HZ 59config HZ
65 int 60 int
66 default 100 61 default 100
diff --git a/arch/um/defconfig b/arch/um/defconfig
index fdc97e2c3d73..7823ab12e6a4 100644
--- a/arch/um/defconfig
+++ b/arch/um/defconfig
@@ -12,7 +12,6 @@ CONFIG_LOCKDEP_SUPPORT=y
12CONFIG_GENERIC_CALIBRATE_DELAY=y 12CONFIG_GENERIC_CALIBRATE_DELAY=y
13CONFIG_GENERIC_BUG=y 13CONFIG_GENERIC_BUG=y
14CONFIG_GENERIC_CLOCKEVENTS=y 14CONFIG_GENERIC_CLOCKEVENTS=y
15CONFIG_IRQ_RELEASE_METHOD=y
16CONFIG_HZ=100 15CONFIG_HZ=100
17 16
18# 17#
diff --git a/arch/um/drivers/chan_kern.c b/arch/um/drivers/chan_kern.c
index ca4c7ebfd0aa..45e248c2f43c 100644
--- a/arch/um/drivers/chan_kern.c
+++ b/arch/um/drivers/chan_kern.c
@@ -8,6 +8,7 @@
8#include <linux/tty_flip.h> 8#include <linux/tty_flip.h>
9#include "chan.h" 9#include "chan.h"
10#include "os.h" 10#include "os.h"
11#include "irq_kern.h"
11 12
12#ifdef CONFIG_NOCONFIG_CHAN 13#ifdef CONFIG_NOCONFIG_CHAN
13static void *not_configged_init(char *str, int device, 14static void *not_configged_init(char *str, int device,
@@ -213,9 +214,9 @@ void free_irqs(void)
213 chan = list_entry(ele, struct chan, free_list); 214 chan = list_entry(ele, struct chan, free_list);
214 215
215 if (chan->input && chan->enabled) 216 if (chan->input && chan->enabled)
216 free_irq(chan->line->driver->read_irq, chan); 217 um_free_irq(chan->line->driver->read_irq, chan);
217 if (chan->output && chan->enabled) 218 if (chan->output && chan->enabled)
218 free_irq(chan->line->driver->write_irq, chan); 219 um_free_irq(chan->line->driver->write_irq, chan);
219 chan->enabled = 0; 220 chan->enabled = 0;
220 } 221 }
221} 222}
@@ -234,9 +235,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
234 } 235 }
235 else { 236 else {
236 if (chan->input && chan->enabled) 237 if (chan->input && chan->enabled)
237 free_irq(chan->line->driver->read_irq, chan); 238 um_free_irq(chan->line->driver->read_irq, chan);
238 if (chan->output && chan->enabled) 239 if (chan->output && chan->enabled)
239 free_irq(chan->line->driver->write_irq, chan); 240 um_free_irq(chan->line->driver->write_irq, chan);
240 chan->enabled = 0; 241 chan->enabled = 0;
241 } 242 }
242 if (chan->ops->close != NULL) 243 if (chan->ops->close != NULL)
diff --git a/arch/um/drivers/line.c b/arch/um/drivers/line.c
index 4ab0d9c0911c..acfd0e0fd0c9 100644
--- a/arch/um/drivers/line.c
+++ b/arch/um/drivers/line.c
@@ -699,7 +699,7 @@ struct winch {
699static void __free_winch(struct work_struct *work) 699static void __free_winch(struct work_struct *work)
700{ 700{
701 struct winch *winch = container_of(work, struct winch, work); 701 struct winch *winch = container_of(work, struct winch, work);
702 free_irq(WINCH_IRQ, winch); 702 um_free_irq(WINCH_IRQ, winch);
703 703
704 if (winch->pid != -1) 704 if (winch->pid != -1)
705 os_kill_process(winch->pid, 1); 705 os_kill_process(winch->pid, 1);
diff --git a/arch/um/drivers/net_kern.c b/arch/um/drivers/net_kern.c
index 95f4416e6d9f..0d60c5685c26 100644
--- a/arch/um/drivers/net_kern.c
+++ b/arch/um/drivers/net_kern.c
@@ -195,7 +195,7 @@ static int uml_net_close(struct net_device *dev)
195 195
196 netif_stop_queue(dev); 196 netif_stop_queue(dev);
197 197
198 free_irq(dev->irq, dev); 198 um_free_irq(dev->irq, dev);
199 if (lp->close != NULL) 199 if (lp->close != NULL)
200 (*lp->close)(lp->fd, &lp->user); 200 (*lp->close)(lp->fd, &lp->user);
201 lp->fd = -1; 201 lp->fd = -1;
@@ -835,7 +835,7 @@ static void close_devices(void)
835 spin_lock(&opened_lock); 835 spin_lock(&opened_lock);
836 list_for_each(ele, &opened) { 836 list_for_each(ele, &opened) {
837 lp = list_entry(ele, struct uml_net_private, list); 837 lp = list_entry(ele, struct uml_net_private, list);
838 free_irq(lp->dev->irq, lp->dev); 838 um_free_irq(lp->dev->irq, lp->dev);
839 if ((lp->close != NULL) && (lp->fd >= 0)) 839 if ((lp->close != NULL) && (lp->fd >= 0))
840 (*lp->close)(lp->fd, &lp->user); 840 (*lp->close)(lp->fd, &lp->user);
841 if (lp->remove != NULL) 841 if (lp->remove != NULL)
diff --git a/arch/um/drivers/port_kern.c b/arch/um/drivers/port_kern.c
index e31680e662a4..11866ffd45a9 100644
--- a/arch/um/drivers/port_kern.c
+++ b/arch/um/drivers/port_kern.c
@@ -254,7 +254,7 @@ int port_wait(void *data)
254 * connection. Then we loop here throwing out failed 254 * connection. Then we loop here throwing out failed
255 * connections until a good one is found. 255 * connections until a good one is found.
256 */ 256 */
257 free_irq(TELNETD_IRQ, conn); 257 um_free_irq(TELNETD_IRQ, conn);
258 258
259 if (conn->fd >= 0) 259 if (conn->fd >= 0)
260 break; 260 break;
diff --git a/arch/um/drivers/xterm_kern.c b/arch/um/drivers/xterm_kern.c
index 8bd130f0bda3..b68bbe269e01 100644
--- a/arch/um/drivers/xterm_kern.c
+++ b/arch/um/drivers/xterm_kern.c
@@ -65,7 +65,7 @@ int xterm_fd(int socket, int *pid_out)
65 * isn't set) this will hang... */ 65 * isn't set) this will hang... */
66 wait_for_completion(&data->ready); 66 wait_for_completion(&data->ready);
67 67
68 free_irq(XTERM_IRQ, data); 68 um_free_irq(XTERM_IRQ, data);
69 69
70 ret = data->new_fd; 70 ret = data->new_fd;
71 *pid_out = data->pid; 71 *pid_out = data->pid;
diff --git a/arch/um/include/asm/pgtable.h b/arch/um/include/asm/pgtable.h
index 6a3f9845743e..5888f1b83477 100644
--- a/arch/um/include/asm/pgtable.h
+++ b/arch/um/include/asm/pgtable.h
@@ -273,6 +273,12 @@ static inline void set_pte(pte_t *pteptr, pte_t pteval)
273} 273}
274#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval) 274#define set_pte_at(mm,addr,ptep,pteval) set_pte(ptep,pteval)
275 275
276#define __HAVE_ARCH_PTE_SAME
277static inline int pte_same(pte_t pte_a, pte_t pte_b)
278{
279 return !((pte_val(pte_a) ^ pte_val(pte_b)) & ~_PAGE_NEWPAGE);
280}
281
276/* 282/*
277 * Conversion functions: convert a page and protection to a page entry, 283 * Conversion functions: convert a page and protection to a page entry,
278 * and a page entry and page directory to the page they refer to. 284 * and a page entry and page directory to the page they refer to.
@@ -348,11 +354,11 @@ extern pte_t *virt_to_pte(struct mm_struct *mm, unsigned long addr);
348#define update_mmu_cache(vma,address,ptep) do ; while (0) 354#define update_mmu_cache(vma,address,ptep) do ; while (0)
349 355
350/* Encode and de-code a swap entry */ 356/* Encode and de-code a swap entry */
351#define __swp_type(x) (((x).val >> 4) & 0x3f) 357#define __swp_type(x) (((x).val >> 5) & 0x1f)
352#define __swp_offset(x) ((x).val >> 11) 358#define __swp_offset(x) ((x).val >> 11)
353 359
354#define __swp_entry(type, offset) \ 360#define __swp_entry(type, offset) \
355 ((swp_entry_t) { ((type) << 4) | ((offset) << 11) }) 361 ((swp_entry_t) { ((type) << 5) | ((offset) << 11) })
356#define __pte_to_swp_entry(pte) \ 362#define __pte_to_swp_entry(pte) \
357 ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) }) 363 ((swp_entry_t) { pte_val(pte_mkuptodate(pte)) })
358#define __swp_entry_to_pte(x) ((pte_t) { (x).val }) 364#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
diff --git a/arch/um/include/asm/thread_info.h b/arch/um/include/asm/thread_info.h
index 200c4ab1240c..c04e5ab68f56 100644
--- a/arch/um/include/asm/thread_info.h
+++ b/arch/um/include/asm/thread_info.h
@@ -71,6 +71,7 @@ static inline struct thread_info *current_thread_info(void)
71#define TIF_MEMDIE 5 /* is terminating due to OOM killer */ 71#define TIF_MEMDIE 5 /* is terminating due to OOM killer */
72#define TIF_SYSCALL_AUDIT 6 72#define TIF_SYSCALL_AUDIT 6
73#define TIF_RESTORE_SIGMASK 7 73#define TIF_RESTORE_SIGMASK 7
74#define TIF_NOTIFY_RESUME 8
74 75
75#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE) 76#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
76#define _TIF_SIGPENDING (1 << TIF_SIGPENDING) 77#define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
@@ -78,6 +79,5 @@ static inline struct thread_info *current_thread_info(void)
78#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG) 79#define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
79#define _TIF_MEMDIE (1 << TIF_MEMDIE) 80#define _TIF_MEMDIE (1 << TIF_MEMDIE)
80#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT) 81#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
81#define _TIF_RESTORE_SIGMASK (1 << TIF_RESTORE_SIGMASK)
82 82
83#endif 83#endif
diff --git a/arch/um/include/shared/irq_kern.h b/arch/um/include/shared/irq_kern.h
index b05d22f3d84e..7a5bfa6291b8 100644
--- a/arch/um/include/shared/irq_kern.h
+++ b/arch/um/include/shared/irq_kern.h
@@ -13,6 +13,6 @@ extern int um_request_irq(unsigned int irq, int fd, int type,
13 irq_handler_t handler, 13 irq_handler_t handler,
14 unsigned long irqflags, const char * devname, 14 unsigned long irqflags, const char * devname,
15 void *dev_id); 15 void *dev_id);
16 16void um_free_irq(unsigned int irq, void *dev);
17#endif 17#endif
18 18
diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c
index 71b8c947e5ef..00506c3d5d6e 100644
--- a/arch/um/kernel/irq.c
+++ b/arch/um/kernel/irq.c
@@ -297,6 +297,13 @@ unsigned int do_IRQ(int irq, struct uml_pt_regs *regs)
297 return 1; 297 return 1;
298} 298}
299 299
300void um_free_irq(unsigned int irq, void *dev)
301{
302 free_irq_by_irq_and_dev(irq, dev);
303 free_irq(irq, dev);
304}
305EXPORT_SYMBOL(um_free_irq);
306
300int um_request_irq(unsigned int irq, int fd, int type, 307int um_request_irq(unsigned int irq, int fd, int type,
301 irq_handler_t handler, 308 irq_handler_t handler,
302 unsigned long irqflags, const char * devname, 309 unsigned long irqflags, const char * devname,
@@ -327,7 +334,6 @@ static void dummy(struct irq_data *d)
327/* This is used for everything else than the timer. */ 334/* This is used for everything else than the timer. */
328static struct irq_chip normal_irq_type = { 335static struct irq_chip normal_irq_type = {
329 .name = "SIGIO", 336 .name = "SIGIO",
330 .release = free_irq_by_irq_and_dev,
331 .irq_disable = dummy, 337 .irq_disable = dummy,
332 .irq_enable = dummy, 338 .irq_enable = dummy,
333 .irq_ack = dummy, 339 .irq_ack = dummy,
@@ -335,7 +341,6 @@ static struct irq_chip normal_irq_type = {
335 341
336static struct irq_chip SIGVTALRM_irq_type = { 342static struct irq_chip SIGVTALRM_irq_type = {
337 .name = "SIGVTALRM", 343 .name = "SIGVTALRM",
338 .release = free_irq_by_irq_and_dev,
339 .irq_disable = dummy, 344 .irq_disable = dummy,
340 .irq_enable = dummy, 345 .irq_enable = dummy,
341 .irq_ack = dummy, 346 .irq_ack = dummy,
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 2b73dedb44ca..3a2235e0abc3 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -18,6 +18,7 @@
18#include <linux/seq_file.h> 18#include <linux/seq_file.h>
19#include <linux/tick.h> 19#include <linux/tick.h>
20#include <linux/threads.h> 20#include <linux/threads.h>
21#include <linux/tracehook.h>
21#include <asm/current.h> 22#include <asm/current.h>
22#include <asm/pgtable.h> 23#include <asm/pgtable.h>
23#include <asm/mmu_context.h> 24#include <asm/mmu_context.h>
@@ -114,8 +115,13 @@ void interrupt_end(void)
114{ 115{
115 if (need_resched()) 116 if (need_resched())
116 schedule(); 117 schedule();
117 if (test_tsk_thread_flag(current, TIF_SIGPENDING)) 118 if (test_thread_flag(TIF_SIGPENDING))
118 do_signal(); 119 do_signal();
120 if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME)) {
121 tracehook_notify_resume(&current->thread.regs);
122 if (current->replacement_session_keyring)
123 key_replace_session_keyring();
124 }
119} 125}
120 126
121void exit_thread(void) 127void exit_thread(void)
@@ -190,7 +196,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
190 if (current->thread.forking) { 196 if (current->thread.forking) {
191 memcpy(&p->thread.regs.regs, &regs->regs, 197 memcpy(&p->thread.regs.regs, &regs->regs,
192 sizeof(p->thread.regs.regs)); 198 sizeof(p->thread.regs.regs));
193 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.gp, 0); 199 UPT_SET_SYSCALL_RETURN(&p->thread.regs.regs, 0);
194 if (sp != 0) 200 if (sp != 0)
195 REGS_SP(p->thread.regs.regs.gp) = sp; 201 REGS_SP(p->thread.regs.regs.gp) = sp;
196 202
diff --git a/arch/um/kernel/signal.c b/arch/um/kernel/signal.c
index fb12f4c5e649..187118fbe1bc 100644
--- a/arch/um/kernel/signal.c
+++ b/arch/um/kernel/signal.c
@@ -29,9 +29,6 @@ static int handle_signal(struct pt_regs *regs, unsigned long signr,
29 unsigned long sp; 29 unsigned long sp;
30 int err; 30 int err;
31 31
32 /* Always make any pending restarted system calls return -EINTR */
33 current_thread_info()->restart_block.fn = do_no_restart_syscall;
34
35 /* Did we come from a system call? */ 32 /* Did we come from a system call? */
36 if (PT_REGS_SYSCALL_NR(regs) >= 0) { 33 if (PT_REGS_SYSCALL_NR(regs) >= 0) {
37 /* If so, check system call restarting.. */ 34 /* If so, check system call restarting.. */
@@ -77,15 +74,14 @@ static int kern_do_signal(struct pt_regs *regs)
77{ 74{
78 struct k_sigaction ka_copy; 75 struct k_sigaction ka_copy;
79 siginfo_t info; 76 siginfo_t info;
80 sigset_t *oldset;
81 int sig, handled_sig = 0; 77 int sig, handled_sig = 0;
82 78
83 if (test_thread_flag(TIF_RESTORE_SIGMASK))
84 oldset = &current->saved_sigmask;
85 else
86 oldset = &current->blocked;
87
88 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) { 79 while ((sig = get_signal_to_deliver(&info, &ka_copy, regs, NULL)) > 0) {
80 sigset_t *oldset;
81 if (test_thread_flag(TIF_RESTORE_SIGMASK))
82 oldset = &current->saved_sigmask;
83 else
84 oldset = &current->blocked;
89 handled_sig = 1; 85 handled_sig = 1;
90 /* Whee! Actually deliver the signal. */ 86 /* Whee! Actually deliver the signal. */
91 if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) { 87 if (!handle_signal(regs, sig, &ka_copy, &info, oldset)) {
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
index f5173e1ec3ac..05fbeb480e0b 100644
--- a/arch/um/kernel/skas/syscall.c
+++ b/arch/um/kernel/skas/syscall.c
@@ -34,7 +34,7 @@ void handle_syscall(struct uml_pt_regs *r)
34 result = -ENOSYS; 34 result = -ENOSYS;
35 else result = EXECUTE_SYSCALL(syscall, regs); 35 else result = EXECUTE_SYSCALL(syscall, regs);
36 36
37 REGS_SET_SYSCALL_RETURN(r->gp, result); 37 UPT_SET_SYSCALL_RETURN(r, result);
38 38
39 syscall_trace(r, 1); 39 syscall_trace(r, 1);
40} 40}
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c
index 7f3d4d86431a..f819af951c19 100644
--- a/arch/um/kernel/tlb.c
+++ b/arch/um/kernel/tlb.c
@@ -75,6 +75,7 @@ static int do_ops(struct host_vm_change *hvc, int end,
75 default: 75 default:
76 printk(KERN_ERR "Unknown op type %d in do_ops\n", 76 printk(KERN_ERR "Unknown op type %d in do_ops\n",
77 op->type); 77 op->type);
78 BUG();
78 break; 79 break;
79 } 80 }
80 } 81 }
diff --git a/arch/um/os-Linux/skas/mem.c b/arch/um/os-Linux/skas/mem.c
index c0afff7af4bd..90b310d29179 100644
--- a/arch/um/os-Linux/skas/mem.c
+++ b/arch/um/os-Linux/skas/mem.c
@@ -48,10 +48,6 @@ __initcall(init_syscall_regs);
48 48
49extern int proc_mm; 49extern int proc_mm;
50 50
51int single_count = 0;
52int multi_count = 0;
53int multi_op_count = 0;
54
55static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr) 51static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
56{ 52{
57 int n, i; 53 int n, i;
@@ -64,8 +60,6 @@ static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
64 /* FIXME: Need to look up userspace_pid by cpu */ 60 /* FIXME: Need to look up userspace_pid by cpu */
65 pid = userspace_pid[0]; 61 pid = userspace_pid[0];
66 62
67 multi_count++;
68
69 n = ptrace_setregs(pid, syscall_regs); 63 n = ptrace_setregs(pid, syscall_regs);
70 if (n < 0) { 64 if (n < 0) {
71 printk(UM_KERN_ERR "Registers - \n"); 65 printk(UM_KERN_ERR "Registers - \n");
@@ -126,9 +120,6 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
126{ 120{
127 unsigned long *stack = check_init_stack(mm_idp, *addr); 121 unsigned long *stack = check_init_stack(mm_idp, *addr);
128 122
129 if (done && *addr == NULL)
130 single_count++;
131
132 *stack += sizeof(long); 123 *stack += sizeof(long);
133 stack += *stack / sizeof(long); 124 stack += *stack / sizeof(long);
134 125
@@ -141,7 +132,6 @@ long run_syscall_stub(struct mm_id * mm_idp, int syscall,
141 *stack++ = args[5]; 132 *stack++ = args[5];
142 *stack++ = expected; 133 *stack++ = expected;
143 *stack = 0; 134 *stack = 0;
144 multi_op_count++;
145 135
146 if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) < 136 if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
147 UM_KERN_PAGE_SIZE - 10 * sizeof(long))) { 137 UM_KERN_PAGE_SIZE - 10 * sizeof(long))) {
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index f3b0633b69a1..0e07adc8cbe4 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -34,25 +34,25 @@
34#define ELF_ARCH EM_386 34#define ELF_ARCH EM_386
35 35
36#define ELF_PLAT_INIT(regs, load_addr) do { \ 36#define ELF_PLAT_INIT(regs, load_addr) do { \
37 PT_REGS_EBX(regs) = 0; \ 37 PT_REGS_BX(regs) = 0; \
38 PT_REGS_ECX(regs) = 0; \ 38 PT_REGS_CX(regs) = 0; \
39 PT_REGS_EDX(regs) = 0; \ 39 PT_REGS_DX(regs) = 0; \
40 PT_REGS_ESI(regs) = 0; \ 40 PT_REGS_SI(regs) = 0; \
41 PT_REGS_EDI(regs) = 0; \ 41 PT_REGS_DI(regs) = 0; \
42 PT_REGS_EBP(regs) = 0; \ 42 PT_REGS_BP(regs) = 0; \
43 PT_REGS_EAX(regs) = 0; \ 43 PT_REGS_AX(regs) = 0; \
44} while (0) 44} while (0)
45 45
46/* Shamelessly stolen from include/asm-i386/elf.h */ 46/* Shamelessly stolen from include/asm-i386/elf.h */
47 47
48#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 48#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
49 pr_reg[0] = PT_REGS_EBX(regs); \ 49 pr_reg[0] = PT_REGS_BX(regs); \
50 pr_reg[1] = PT_REGS_ECX(regs); \ 50 pr_reg[1] = PT_REGS_CX(regs); \
51 pr_reg[2] = PT_REGS_EDX(regs); \ 51 pr_reg[2] = PT_REGS_DX(regs); \
52 pr_reg[3] = PT_REGS_ESI(regs); \ 52 pr_reg[3] = PT_REGS_SI(regs); \
53 pr_reg[4] = PT_REGS_EDI(regs); \ 53 pr_reg[4] = PT_REGS_DI(regs); \
54 pr_reg[5] = PT_REGS_EBP(regs); \ 54 pr_reg[5] = PT_REGS_BP(regs); \
55 pr_reg[6] = PT_REGS_EAX(regs); \ 55 pr_reg[6] = PT_REGS_AX(regs); \
56 pr_reg[7] = PT_REGS_DS(regs); \ 56 pr_reg[7] = PT_REGS_DS(regs); \
57 pr_reg[8] = PT_REGS_ES(regs); \ 57 pr_reg[8] = PT_REGS_ES(regs); \
58 /* fake once used fs and gs selectors? */ \ 58 /* fake once used fs and gs selectors? */ \
@@ -130,13 +130,13 @@ do { \
130#define ELF_ARCH EM_X86_64 130#define ELF_ARCH EM_X86_64
131 131
132#define ELF_PLAT_INIT(regs, load_addr) do { \ 132#define ELF_PLAT_INIT(regs, load_addr) do { \
133 PT_REGS_RBX(regs) = 0; \ 133 PT_REGS_BX(regs) = 0; \
134 PT_REGS_RCX(regs) = 0; \ 134 PT_REGS_CX(regs) = 0; \
135 PT_REGS_RDX(regs) = 0; \ 135 PT_REGS_DX(regs) = 0; \
136 PT_REGS_RSI(regs) = 0; \ 136 PT_REGS_SI(regs) = 0; \
137 PT_REGS_RDI(regs) = 0; \ 137 PT_REGS_DI(regs) = 0; \
138 PT_REGS_RBP(regs) = 0; \ 138 PT_REGS_BP(regs) = 0; \
139 PT_REGS_RAX(regs) = 0; \ 139 PT_REGS_AX(regs) = 0; \
140 PT_REGS_R8(regs) = 0; \ 140 PT_REGS_R8(regs) = 0; \
141 PT_REGS_R9(regs) = 0; \ 141 PT_REGS_R9(regs) = 0; \
142 PT_REGS_R10(regs) = 0; \ 142 PT_REGS_R10(regs) = 0; \
diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h
index c8aca8c501b0..950dfb7b8417 100644
--- a/arch/x86/um/asm/ptrace.h
+++ b/arch/x86/um/asm/ptrace.h
@@ -1,5 +1,39 @@
1#ifndef __UM_X86_PTRACE_H
2#define __UM_X86_PTRACE_H
3
1#ifdef CONFIG_X86_32 4#ifdef CONFIG_X86_32
2# include "ptrace_32.h" 5# include "ptrace_32.h"
3#else 6#else
4# include "ptrace_64.h" 7# include "ptrace_64.h"
5#endif 8#endif
9
10#define PT_REGS_AX(r) UPT_AX(&(r)->regs)
11#define PT_REGS_BX(r) UPT_BX(&(r)->regs)
12#define PT_REGS_CX(r) UPT_CX(&(r)->regs)
13#define PT_REGS_DX(r) UPT_DX(&(r)->regs)
14
15#define PT_REGS_SI(r) UPT_SI(&(r)->regs)
16#define PT_REGS_DI(r) UPT_DI(&(r)->regs)
17#define PT_REGS_BP(r) UPT_BP(&(r)->regs)
18#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
19
20#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
21#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
22#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
23#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
24
25#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
26#define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)
27
28#define PT_FIX_EXEC_STACK(sp) do ; while(0)
29
30#define profile_pc(regs) PT_REGS_IP(regs)
31
32#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
33#define UPT_SET_SYSCALL_RETURN(r, res) (UPT_AX(r) = (res))
34
35static inline long regs_return_value(struct uml_pt_regs *regs)
36{
37 return UPT_AX(regs);
38}
39#endif /* __UM_X86_PTRACE_H */
diff --git a/arch/x86/um/asm/ptrace_32.h b/arch/x86/um/asm/ptrace_32.h
index 5d2a59112537..2cf225351b65 100644
--- a/arch/x86/um/asm/ptrace_32.h
+++ b/arch/x86/um/asm/ptrace_32.h
@@ -11,29 +11,6 @@
11#include "linux/compiler.h" 11#include "linux/compiler.h"
12#include "asm/ptrace-generic.h" 12#include "asm/ptrace-generic.h"
13 13
14#define PT_REGS_EAX(r) UPT_EAX(&(r)->regs)
15#define PT_REGS_EBX(r) UPT_EBX(&(r)->regs)
16#define PT_REGS_ECX(r) UPT_ECX(&(r)->regs)
17#define PT_REGS_EDX(r) UPT_EDX(&(r)->regs)
18#define PT_REGS_ESI(r) UPT_ESI(&(r)->regs)
19#define PT_REGS_EDI(r) UPT_EDI(&(r)->regs)
20#define PT_REGS_EBP(r) UPT_EBP(&(r)->regs)
21
22#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
23#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
24#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
25#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
26#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
27#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
28
29#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
30
31#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_EAX(r)
32#define PT_REGS_SYSCALL_RET(r) PT_REGS_EAX(r)
33#define PT_FIX_EXEC_STACK(sp) do ; while(0)
34
35#define profile_pc(regs) PT_REGS_IP(regs)
36
37#define user_mode(r) UPT_IS_USER(&(r)->regs) 14#define user_mode(r) UPT_IS_USER(&(r)->regs)
38 15
39/* 16/*
diff --git a/arch/x86/um/asm/ptrace_64.h b/arch/x86/um/asm/ptrace_64.h
index 706a0d80545c..ea7bff394320 100644
--- a/arch/x86/um/asm/ptrace_64.h
+++ b/arch/x86/um/asm/ptrace_64.h
@@ -15,13 +15,6 @@
15 15
16#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64 16#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
17 17
18#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs)
19#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs)
20#define PT_REGS_RDX(r) UPT_RDX(&(r)->regs)
21#define PT_REGS_RSI(r) UPT_RSI(&(r)->regs)
22#define PT_REGS_RDI(r) UPT_RDI(&(r)->regs)
23#define PT_REGS_RBP(r) UPT_RBP(&(r)->regs)
24#define PT_REGS_RAX(r) UPT_RAX(&(r)->regs)
25#define PT_REGS_R8(r) UPT_R8(&(r)->regs) 18#define PT_REGS_R8(r) UPT_R8(&(r)->regs)
26#define PT_REGS_R9(r) UPT_R9(&(r)->regs) 19#define PT_REGS_R9(r) UPT_R9(&(r)->regs)
27#define PT_REGS_R10(r) UPT_R10(&(r)->regs) 20#define PT_REGS_R10(r) UPT_R10(&(r)->regs)
@@ -31,27 +24,8 @@
31#define PT_REGS_R14(r) UPT_R14(&(r)->regs) 24#define PT_REGS_R14(r) UPT_R14(&(r)->regs)
32#define PT_REGS_R15(r) UPT_R15(&(r)->regs) 25#define PT_REGS_R15(r) UPT_R15(&(r)->regs)
33 26
34#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
35#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
36#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
37#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
38#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
39#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
40
41#define PT_REGS_ORIG_RAX(r) UPT_ORIG_RAX(&(r)->regs)
42#define PT_REGS_RIP(r) UPT_IP(&(r)->regs)
43#define PT_REGS_SP(r) UPT_SP(&(r)->regs)
44
45#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
46
47/* XXX */ 27/* XXX */
48#define user_mode(r) UPT_IS_USER(&(r)->regs) 28#define user_mode(r) UPT_IS_USER(&(r)->regs)
49#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_RAX(r)
50#define PT_REGS_SYSCALL_RET(r) PT_REGS_RAX(r)
51
52#define PT_FIX_EXEC_STACK(sp) do ; while(0)
53
54#define profile_pc(regs) PT_REGS_IP(regs)
55 29
56struct user_desc; 30struct user_desc;
57 31
diff --git a/arch/x86/um/shared/sysdep/ptrace.h b/arch/x86/um/shared/sysdep/ptrace.h
index 2bbe1ec2d96a..6ce2d76eb908 100644
--- a/arch/x86/um/shared/sysdep/ptrace.h
+++ b/arch/x86/um/shared/sysdep/ptrace.h
@@ -1,15 +1,74 @@
1#ifndef __SYSDEP_X86_PTRACE_H 1#ifndef __SYSDEP_X86_PTRACE_H
2#define __SYSDEP_X86_PTRACE_H 2#define __SYSDEP_X86_PTRACE_H
3 3
4#include <generated/user_constants.h>
5#include "sysdep/faultinfo.h"
6
7#define MAX_REG_OFFSET (UM_FRAME_SIZE)
8#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
9
10#define REGS_IP(r) ((r)[HOST_IP])
11#define REGS_SP(r) ((r)[HOST_SP])
12#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
13#define REGS_AX(r) ((r)[HOST_AX])
14#define REGS_BX(r) ((r)[HOST_BX])
15#define REGS_CX(r) ((r)[HOST_CX])
16#define REGS_DX(r) ((r)[HOST_DX])
17#define REGS_SI(r) ((r)[HOST_SI])
18#define REGS_DI(r) ((r)[HOST_DI])
19#define REGS_BP(r) ((r)[HOST_BP])
20#define REGS_CS(r) ((r)[HOST_CS])
21#define REGS_SS(r) ((r)[HOST_SS])
22#define REGS_DS(r) ((r)[HOST_DS])
23#define REGS_ES(r) ((r)[HOST_ES])
24
25#define UPT_IP(r) REGS_IP((r)->gp)
26#define UPT_SP(r) REGS_SP((r)->gp)
27#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
28#define UPT_AX(r) REGS_AX((r)->gp)
29#define UPT_BX(r) REGS_BX((r)->gp)
30#define UPT_CX(r) REGS_CX((r)->gp)
31#define UPT_DX(r) REGS_DX((r)->gp)
32#define UPT_SI(r) REGS_SI((r)->gp)
33#define UPT_DI(r) REGS_DI((r)->gp)
34#define UPT_BP(r) REGS_BP((r)->gp)
35#define UPT_CS(r) REGS_CS((r)->gp)
36#define UPT_SS(r) REGS_SS((r)->gp)
37#define UPT_DS(r) REGS_DS((r)->gp)
38#define UPT_ES(r) REGS_ES((r)->gp)
39
4#ifdef __i386__ 40#ifdef __i386__
5#include "ptrace_32.h" 41#include "ptrace_32.h"
6#else 42#else
7#include "ptrace_64.h" 43#include "ptrace_64.h"
8#endif 44#endif
9 45
10static inline long regs_return_value(struct uml_pt_regs *regs) 46struct syscall_args {
11{ 47 unsigned long args[6];
12 return UPT_SYSCALL_RET(regs); 48};
13} 49
50#define SYSCALL_ARGS(r) ((struct syscall_args) \
51 { .args = { UPT_SYSCALL_ARG1(r), \
52 UPT_SYSCALL_ARG2(r), \
53 UPT_SYSCALL_ARG3(r), \
54 UPT_SYSCALL_ARG4(r), \
55 UPT_SYSCALL_ARG5(r), \
56 UPT_SYSCALL_ARG6(r) } } )
57
58struct uml_pt_regs {
59 unsigned long gp[MAX_REG_NR];
60 unsigned long fp[MAX_FP_NR];
61 struct faultinfo faultinfo;
62 long syscall;
63 int is_user;
64};
65
66#define EMPTY_UML_PT_REGS { }
67
68#define UPT_SYSCALL_NR(r) ((r)->syscall)
69#define UPT_FAULTINFO(r) (&(r)->faultinfo)
70#define UPT_IS_USER(r) ((r)->is_user)
71
72extern int user_context(unsigned long sp);
14 73
15#endif /* __SYSDEP_X86_PTRACE_H */ 74#endif /* __SYSDEP_X86_PTRACE_H */
diff --git a/arch/x86/um/shared/sysdep/ptrace_32.h b/arch/x86/um/shared/sysdep/ptrace_32.h
index befd1df32ed0..b94a108de1dc 100644
--- a/arch/x86/um/shared/sysdep/ptrace_32.h
+++ b/arch/x86/um/shared/sysdep/ptrace_32.h
@@ -6,11 +6,7 @@
6#ifndef __SYSDEP_I386_PTRACE_H 6#ifndef __SYSDEP_I386_PTRACE_H
7#define __SYSDEP_I386_PTRACE_H 7#define __SYSDEP_I386_PTRACE_H
8 8
9#include <generated/user_constants.h> 9#define MAX_FP_NR HOST_FPX_SIZE
10#include "sysdep/faultinfo.h"
11
12#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
13#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14 10
15static inline void update_debugregs(int seq) {} 11static inline void update_debugregs(int seq) {}
16 12
@@ -24,90 +20,16 @@ void set_using_sysemu(int value);
24int get_using_sysemu(void); 20int get_using_sysemu(void);
25extern int sysemu_supported; 21extern int sysemu_supported;
26 22
27#define REGS_IP(r) ((r)[HOST_IP])
28#define REGS_SP(r) ((r)[HOST_SP])
29#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
30#define REGS_EAX(r) ((r)[HOST_AX])
31#define REGS_EBX(r) ((r)[HOST_BX])
32#define REGS_ECX(r) ((r)[HOST_CX])
33#define REGS_EDX(r) ((r)[HOST_DX])
34#define REGS_ESI(r) ((r)[HOST_SI])
35#define REGS_EDI(r) ((r)[HOST_DI])
36#define REGS_EBP(r) ((r)[HOST_BP])
37#define REGS_CS(r) ((r)[HOST_CS])
38#define REGS_SS(r) ((r)[HOST_SS])
39#define REGS_DS(r) ((r)[HOST_DS])
40#define REGS_ES(r) ((r)[HOST_ES])
41#define REGS_FS(r) ((r)[HOST_FS])
42#define REGS_GS(r) ((r)[HOST_GS])
43
44#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
45
46#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
47#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
48
49#ifndef PTRACE_SYSEMU_SINGLESTEP 23#ifndef PTRACE_SYSEMU_SINGLESTEP
50#define PTRACE_SYSEMU_SINGLESTEP 32 24#define PTRACE_SYSEMU_SINGLESTEP 32
51#endif 25#endif
52 26
53struct uml_pt_regs { 27#define UPT_SYSCALL_ARG1(r) UPT_BX(r)
54 unsigned long gp[MAX_REG_NR]; 28#define UPT_SYSCALL_ARG2(r) UPT_CX(r)
55 unsigned long fp[HOST_FPX_SIZE]; 29#define UPT_SYSCALL_ARG3(r) UPT_DX(r)
56 struct faultinfo faultinfo; 30#define UPT_SYSCALL_ARG4(r) UPT_SI(r)
57 long syscall; 31#define UPT_SYSCALL_ARG5(r) UPT_DI(r)
58 int is_user; 32#define UPT_SYSCALL_ARG6(r) UPT_BP(r)
59};
60
61#define EMPTY_UML_PT_REGS { }
62
63#define UPT_IP(r) REGS_IP((r)->gp)
64#define UPT_SP(r) REGS_SP((r)->gp)
65#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
66#define UPT_EAX(r) REGS_EAX((r)->gp)
67#define UPT_EBX(r) REGS_EBX((r)->gp)
68#define UPT_ECX(r) REGS_ECX((r)->gp)
69#define UPT_EDX(r) REGS_EDX((r)->gp)
70#define UPT_ESI(r) REGS_ESI((r)->gp)
71#define UPT_EDI(r) REGS_EDI((r)->gp)
72#define UPT_EBP(r) REGS_EBP((r)->gp)
73#define UPT_ORIG_EAX(r) ((r)->syscall)
74#define UPT_CS(r) REGS_CS((r)->gp)
75#define UPT_SS(r) REGS_SS((r)->gp)
76#define UPT_DS(r) REGS_DS((r)->gp)
77#define UPT_ES(r) REGS_ES((r)->gp)
78#define UPT_FS(r) REGS_FS((r)->gp)
79#define UPT_GS(r) REGS_GS((r)->gp)
80
81#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
82#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
83#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
84#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
85#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
86#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
87
88extern int user_context(unsigned long sp);
89
90#define UPT_IS_USER(r) ((r)->is_user)
91
92struct syscall_args {
93 unsigned long args[6];
94};
95
96#define SYSCALL_ARGS(r) ((struct syscall_args) \
97 { .args = { UPT_SYSCALL_ARG1(r), \
98 UPT_SYSCALL_ARG2(r), \
99 UPT_SYSCALL_ARG3(r), \
100 UPT_SYSCALL_ARG4(r), \
101 UPT_SYSCALL_ARG5(r), \
102 UPT_SYSCALL_ARG6(r) } } )
103
104#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
105
106#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
107#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
108#define UPT_SYSCALL_RET(r) UPT_EAX(r)
109
110#define UPT_FAULTINFO(r) (&(r)->faultinfo)
111 33
112extern void arch_init_registers(int pid); 34extern void arch_init_registers(int pid);
113 35
diff --git a/arch/x86/um/shared/sysdep/ptrace_64.h b/arch/x86/um/shared/sysdep/ptrace_64.h
index 031edc53ac57..919789f1071e 100644
--- a/arch/x86/um/shared/sysdep/ptrace_64.h
+++ b/arch/x86/um/shared/sysdep/ptrace_64.h
@@ -8,22 +8,8 @@
8#ifndef __SYSDEP_X86_64_PTRACE_H 8#ifndef __SYSDEP_X86_64_PTRACE_H
9#define __SYSDEP_X86_64_PTRACE_H 9#define __SYSDEP_X86_64_PTRACE_H
10 10
11#include <generated/user_constants.h> 11#define MAX_FP_NR HOST_FP_SIZE
12#include "sysdep/faultinfo.h"
13 12
14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
16
17#define REGS_IP(r) ((r)[HOST_IP])
18#define REGS_SP(r) ((r)[HOST_SP])
19
20#define REGS_RBX(r) ((r)[HOST_BX])
21#define REGS_RCX(r) ((r)[HOST_CX])
22#define REGS_RDX(r) ((r)[HOST_DX])
23#define REGS_RSI(r) ((r)[HOST_SI])
24#define REGS_RDI(r) ((r)[HOST_DI])
25#define REGS_RBP(r) ((r)[HOST_BP])
26#define REGS_RAX(r) ((r)[HOST_AX])
27#define REGS_R8(r) ((r)[HOST_R8]) 13#define REGS_R8(r) ((r)[HOST_R8])
28#define REGS_R9(r) ((r)[HOST_R9]) 14#define REGS_R9(r) ((r)[HOST_R9])
29#define REGS_R10(r) ((r)[HOST_R10]) 15#define REGS_R10(r) ((r)[HOST_R10])
@@ -32,9 +18,6 @@
32#define REGS_R13(r) ((r)[HOST_R13]) 18#define REGS_R13(r) ((r)[HOST_R13])
33#define REGS_R14(r) ((r)[HOST_R14]) 19#define REGS_R14(r) ((r)[HOST_R14])
34#define REGS_R15(r) ((r)[HOST_R15]) 20#define REGS_R15(r) ((r)[HOST_R15])
35#define REGS_CS(r) ((r)[HOST_CS])
36#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
37#define REGS_SS(r) ((r)[HOST_SS])
38 21
39#define HOST_FS_BASE 21 22#define HOST_FS_BASE 21
40#define HOST_GS_BASE 22 23#define HOST_GS_BASE 22
@@ -58,45 +41,6 @@
58#define GS (HOST_GS * sizeof(long)) 41#define GS (HOST_GS * sizeof(long))
59#endif 42#endif
60 43
61#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
62#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
63#define REGS_DS(r) ((r)[HOST_DS])
64#define REGS_ES(r) ((r)[HOST_ES])
65#define REGS_FS(r) ((r)[HOST_FS])
66#define REGS_GS(r) ((r)[HOST_GS])
67
68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_AX])
69
70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
71
72#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
73#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
74
75#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
76
77#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
78
79#define REGS_TRAP(r) ((r)->trap_type)
80
81#define REGS_ERR(r) ((r)->fault_type)
82
83struct uml_pt_regs {
84 unsigned long gp[MAX_REG_NR];
85 unsigned long fp[HOST_FP_SIZE];
86 struct faultinfo faultinfo;
87 long syscall;
88 int is_user;
89};
90
91#define EMPTY_UML_PT_REGS { }
92
93#define UPT_RBX(r) REGS_RBX((r)->gp)
94#define UPT_RCX(r) REGS_RCX((r)->gp)
95#define UPT_RDX(r) REGS_RDX((r)->gp)
96#define UPT_RSI(r) REGS_RSI((r)->gp)
97#define UPT_RDI(r) REGS_RDI((r)->gp)
98#define UPT_RBP(r) REGS_RBP((r)->gp)
99#define UPT_RAX(r) REGS_RAX((r)->gp)
100#define UPT_R8(r) REGS_R8((r)->gp) 44#define UPT_R8(r) REGS_R8((r)->gp)
101#define UPT_R9(r) REGS_R9((r)->gp) 45#define UPT_R9(r) REGS_R9((r)->gp)
102#define UPT_R10(r) REGS_R10((r)->gp) 46#define UPT_R10(r) REGS_R10((r)->gp)
@@ -105,51 +49,14 @@ struct uml_pt_regs {
105#define UPT_R13(r) REGS_R13((r)->gp) 49#define UPT_R13(r) REGS_R13((r)->gp)
106#define UPT_R14(r) REGS_R14((r)->gp) 50#define UPT_R14(r) REGS_R14((r)->gp)
107#define UPT_R15(r) REGS_R15((r)->gp) 51#define UPT_R15(r) REGS_R15((r)->gp)
108#define UPT_CS(r) REGS_CS((r)->gp)
109#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
110#define UPT_FS(r) REGS_FS((r)->gp)
111#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
112#define UPT_GS(r) REGS_GS((r)->gp)
113#define UPT_DS(r) REGS_DS((r)->gp)
114#define UPT_ES(r) REGS_ES((r)->gp)
115#define UPT_CS(r) REGS_CS((r)->gp)
116#define UPT_SS(r) REGS_SS((r)->gp)
117#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
118
119#define UPT_IP(r) REGS_IP((r)->gp)
120#define UPT_SP(r) REGS_SP((r)->gp)
121
122#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
123#define UPT_SYSCALL_NR(r) ((r)->syscall)
124#define UPT_SYSCALL_RET(r) UPT_RAX(r)
125
126extern int user_context(unsigned long sp);
127 52
128#define UPT_IS_USER(r) ((r)->is_user) 53#define UPT_SYSCALL_ARG1(r) UPT_DI(r)
129 54#define UPT_SYSCALL_ARG2(r) UPT_SI(r)
130#define UPT_SYSCALL_ARG1(r) UPT_RDI(r) 55#define UPT_SYSCALL_ARG3(r) UPT_DX(r)
131#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
132#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
133#define UPT_SYSCALL_ARG4(r) UPT_R10(r) 56#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
134#define UPT_SYSCALL_ARG5(r) UPT_R8(r) 57#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
135#define UPT_SYSCALL_ARG6(r) UPT_R9(r) 58#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
136 59
137struct syscall_args {
138 unsigned long args[6];
139};
140
141#define SYSCALL_ARGS(r) ((struct syscall_args) \
142 { .args = { UPT_SYSCALL_ARG1(r), \
143 UPT_SYSCALL_ARG2(r), \
144 UPT_SYSCALL_ARG3(r), \
145 UPT_SYSCALL_ARG4(r), \
146 UPT_SYSCALL_ARG5(r), \
147 UPT_SYSCALL_ARG6(r) } } )
148
149#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
150
151#define UPT_FAULTINFO(r) (&(r)->faultinfo)
152
153static inline void arch_init_registers(int pid) 60static inline void arch_init_registers(int pid)
154{ 61{
155} 62}
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index 4883b9546016..bb0fb03b9f85 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -156,6 +156,9 @@ static int copy_sc_from_user(struct pt_regs *regs,
156 struct sigcontext sc; 156 struct sigcontext sc;
157 int err, pid; 157 int err, pid;
158 158
159 /* Always make any pending restarted system calls return -EINTR */
160 current_thread_info()->restart_block.fn = do_no_restart_syscall;
161
159 err = copy_from_user(&sc, from, sizeof(sc)); 162 err = copy_from_user(&sc, from, sizeof(sc));
160 if (err) 163 if (err)
161 return err; 164 return err;
@@ -410,9 +413,9 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
410 413
411 PT_REGS_SP(regs) = (unsigned long) frame; 414 PT_REGS_SP(regs) = (unsigned long) frame;
412 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 415 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
413 PT_REGS_EAX(regs) = (unsigned long) sig; 416 PT_REGS_AX(regs) = (unsigned long) sig;
414 PT_REGS_EDX(regs) = (unsigned long) 0; 417 PT_REGS_DX(regs) = (unsigned long) 0;
415 PT_REGS_ECX(regs) = (unsigned long) 0; 418 PT_REGS_CX(regs) = (unsigned long) 0;
416 419
417 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 420 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
418 ptrace_notify(SIGTRAP); 421 ptrace_notify(SIGTRAP);
@@ -460,9 +463,9 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
460 463
461 PT_REGS_SP(regs) = (unsigned long) frame; 464 PT_REGS_SP(regs) = (unsigned long) frame;
462 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 465 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
463 PT_REGS_EAX(regs) = (unsigned long) sig; 466 PT_REGS_AX(regs) = (unsigned long) sig;
464 PT_REGS_EDX(regs) = (unsigned long) &frame->info; 467 PT_REGS_DX(regs) = (unsigned long) &frame->info;
465 PT_REGS_ECX(regs) = (unsigned long) &frame->uc; 468 PT_REGS_CX(regs) = (unsigned long) &frame->uc;
466 469
467 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 470 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
468 ptrace_notify(SIGTRAP); 471 ptrace_notify(SIGTRAP);
@@ -541,8 +544,8 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
541 set->sig[0]); 544 set->sig[0]);
542 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate); 545 err |= __put_user(&frame->fpstate, &frame->uc.uc_mcontext.fpstate);
543 if (sizeof(*set) == 16) { 546 if (sizeof(*set) == 16) {
544 __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]); 547 err |= __put_user(set->sig[0], &frame->uc.uc_sigmask.sig[0]);
545 __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]); 548 err |= __put_user(set->sig[1], &frame->uc.uc_sigmask.sig[1]);
546 } 549 }
547 else 550 else
548 err |= __copy_to_user(&frame->uc.uc_sigmask, set, 551 err |= __copy_to_user(&frame->uc.uc_sigmask, set,
@@ -570,17 +573,17 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
570 } 573 }
571 574
572 PT_REGS_SP(regs) = (unsigned long) frame; 575 PT_REGS_SP(regs) = (unsigned long) frame;
573 PT_REGS_RDI(regs) = sig; 576 PT_REGS_DI(regs) = sig;
574 /* In case the signal handler was declared without prototypes */ 577 /* In case the signal handler was declared without prototypes */
575 PT_REGS_RAX(regs) = 0; 578 PT_REGS_AX(regs) = 0;
576 579
577 /* 580 /*
578 * This also works for non SA_SIGINFO handlers because they expect the 581 * This also works for non SA_SIGINFO handlers because they expect the
579 * next argument after the signal number on the stack. 582 * next argument after the signal number on the stack.
580 */ 583 */
581 PT_REGS_RSI(regs) = (unsigned long) &frame->info; 584 PT_REGS_SI(regs) = (unsigned long) &frame->info;
582 PT_REGS_RDX(regs) = (unsigned long) &frame->uc; 585 PT_REGS_DX(regs) = (unsigned long) &frame->uc;
583 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler; 586 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
584 out: 587 out:
585 return err; 588 return err;
586} 589}
diff --git a/arch/x86/um/sys_call_table_64.c b/arch/x86/um/sys_call_table_64.c
index 9924776f4265..170bd926a69c 100644
--- a/arch/x86/um/sys_call_table_64.c
+++ b/arch/x86/um/sys_call_table_64.c
@@ -31,7 +31,6 @@
31#define stub_fork sys_fork 31#define stub_fork sys_fork
32#define stub_vfork sys_vfork 32#define stub_vfork sys_vfork
33#define stub_execve sys_execve 33#define stub_execve sys_execve
34#define stub_rt_sigsuspend sys_rt_sigsuspend
35#define stub_sigaltstack sys_sigaltstack 34#define stub_sigaltstack sys_sigaltstack
36#define stub_rt_sigreturn sys_rt_sigreturn 35#define stub_rt_sigreturn sys_rt_sigreturn
37 36
diff --git a/arch/x86/um/syscalls_32.c b/arch/x86/um/syscalls_32.c
index 70ca357393b8..b853e8600b9d 100644
--- a/arch/x86/um/syscalls_32.c
+++ b/arch/x86/um/syscalls_32.c
@@ -44,10 +44,10 @@ long sys_sigaction(int sig, const struct old_sigaction __user *act,
44 old_sigset_t mask; 44 old_sigset_t mask;
45 if (!access_ok(VERIFY_READ, act, sizeof(*act)) || 45 if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
46 __get_user(new_ka.sa.sa_handler, &act->sa_handler) || 46 __get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
47 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer)) 47 __get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
48 __get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
49 __get_user(mask, &act->sa_mask))
48 return -EFAULT; 50 return -EFAULT;
49 __get_user(new_ka.sa.sa_flags, &act->sa_flags);
50 __get_user(mask, &act->sa_mask);
51 siginitset(&new_ka.sa.sa_mask, mask); 51 siginitset(&new_ka.sa.sa_mask, mask);
52 } 52 }
53 53
@@ -56,10 +56,10 @@ long sys_sigaction(int sig, const struct old_sigaction __user *act,
56 if (!ret && oact) { 56 if (!ret && oact) {
57 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) || 57 if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)) ||
58 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) || 58 __put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
59 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer)) 59 __put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
60 __put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
61 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
60 return -EFAULT; 62 return -EFAULT;
61 __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
62 __put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask);
63 } 63 }
64 64
65 return ret; 65 return ret;
diff --git a/arch/x86/um/sysrq_32.c b/arch/x86/um/sysrq_32.c
index 171b3e9dc867..2d5cc51e9bef 100644
--- a/arch/x86/um/sysrq_32.c
+++ b/arch/x86/um/sysrq_32.c
@@ -23,12 +23,10 @@ void show_regs(struct pt_regs *regs)
23 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs), 23 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs),
24 print_tainted()); 24 print_tainted());
25 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", 25 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
26 PT_REGS_EAX(regs), PT_REGS_EBX(regs), 26 PT_REGS_AX(regs), PT_REGS_BX(regs),
27 PT_REGS_ECX(regs), 27 PT_REGS_CX(regs), PT_REGS_DX(regs));
28 PT_REGS_EDX(regs));
29 printk("ESI: %08lx EDI: %08lx EBP: %08lx", 28 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
30 PT_REGS_ESI(regs), PT_REGS_EDI(regs), 29 PT_REGS_SI(regs), PT_REGS_DI(regs), PT_REGS_BP(regs));
31 PT_REGS_EBP(regs));
32 printk(" DS: %04lx ES: %04lx\n", 30 printk(" DS: %04lx ES: %04lx\n",
33 0xffff & PT_REGS_DS(regs), 31 0xffff & PT_REGS_DS(regs),
34 0xffff & PT_REGS_ES(regs)); 32 0xffff & PT_REGS_ES(regs));
diff --git a/arch/x86/um/sysrq_64.c b/arch/x86/um/sysrq_64.c
index e8913436d7dc..08258f179969 100644
--- a/arch/x86/um/sysrq_64.c
+++ b/arch/x86/um/sysrq_64.c
@@ -19,15 +19,15 @@ void __show_regs(struct pt_regs *regs)
19 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current), 19 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current),
20 current->comm, print_tainted(), init_utsname()->release); 20 current->comm, print_tainted(), init_utsname()->release);
21 printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff, 21 printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff,
22 PT_REGS_RIP(regs)); 22 PT_REGS_IP(regs));
23 printk(KERN_INFO "RSP: %016lx EFLAGS: %08lx\n", PT_REGS_SP(regs), 23 printk(KERN_INFO "RSP: %016lx EFLAGS: %08lx\n", PT_REGS_SP(regs),
24 PT_REGS_EFLAGS(regs)); 24 PT_REGS_EFLAGS(regs));
25 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n", 25 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
26 PT_REGS_RAX(regs), PT_REGS_RBX(regs), PT_REGS_RCX(regs)); 26 PT_REGS_AX(regs), PT_REGS_BX(regs), PT_REGS_CX(regs));
27 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n", 27 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
28 PT_REGS_RDX(regs), PT_REGS_RSI(regs), PT_REGS_RDI(regs)); 28 PT_REGS_DX(regs), PT_REGS_SI(regs), PT_REGS_DI(regs));
29 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n", 29 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
30 PT_REGS_RBP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs)); 30 PT_REGS_BP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs));
31 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n", 31 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
32 PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs)); 32 PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs));
33 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n", 33 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
index c6c7131e563b..baba84f8ecb8 100644
--- a/arch/x86/um/tls_32.c
+++ b/arch/x86/um/tls_32.c
@@ -219,7 +219,7 @@ int arch_copy_tls(struct task_struct *new)
219 int idx, ret = -EFAULT; 219 int idx, ret = -EFAULT;
220 220
221 if (copy_from_user(&info, 221 if (copy_from_user(&info,
222 (void __user *) UPT_ESI(&new->thread.regs.regs), 222 (void __user *) UPT_SI(&new->thread.regs.regs),
223 sizeof(info))) 223 sizeof(info)))
224 goto out; 224 goto out;
225 225