ptrace.c (d033a308d81ec83908760a15a841c2bd0d5e0ea3) ptrace.c (91d1aa43d30505b0b825db8898ffc80a8eca96c7)
1/* By Ross Biro 1/23/92 */
2/*
3 * Pentium III FXSR, SSE support
4 * Gareth Hughes <gareth@valinux.com>, May 2000
5 */
6
7#include <linux/kernel.h>
8#include <linux/sched.h>

--- 7 unchanged lines hidden (view full) ---

16#include <linux/user.h>
17#include <linux/elf.h>
18#include <linux/security.h>
19#include <linux/audit.h>
20#include <linux/seccomp.h>
21#include <linux/signal.h>
22#include <linux/perf_event.h>
23#include <linux/hw_breakpoint.h>
1/* By Ross Biro 1/23/92 */
2/*
3 * Pentium III FXSR, SSE support
4 * Gareth Hughes <gareth@valinux.com>, May 2000
5 */
6
7#include <linux/kernel.h>
8#include <linux/sched.h>

--- 7 unchanged lines hidden (view full) ---

16#include <linux/user.h>
17#include <linux/elf.h>
18#include <linux/security.h>
19#include <linux/audit.h>
20#include <linux/seccomp.h>
21#include <linux/signal.h>
22#include <linux/perf_event.h>
23#include <linux/hw_breakpoint.h>
24#include <linux/rcupdate.h>
25#include <linux/module.h>
24#include <linux/context_tracking.h>
26
27#include <asm/uaccess.h>
28#include <asm/pgtable.h>
29#include <asm/processor.h>
30#include <asm/i387.h>
31#include <asm/fpu-internal.h>
32#include <asm/debugreg.h>
33#include <asm/ldt.h>

--- 128 unchanged lines hidden (view full) ---

162{
163 return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
164}
165
166#ifdef CONFIG_X86_32
167
168#define FLAG_MASK FLAG_MASK_32
169
25
26#include <asm/uaccess.h>
27#include <asm/pgtable.h>
28#include <asm/processor.h>
29#include <asm/i387.h>
30#include <asm/fpu-internal.h>
31#include <asm/debugreg.h>
32#include <asm/ldt.h>

--- 128 unchanged lines hidden (view full) ---

161{
162 return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
163}
164
165#ifdef CONFIG_X86_32
166
167#define FLAG_MASK FLAG_MASK_32
168
170/*
171 * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
172 * when it traps. The previous stack will be directly underneath the saved
173 * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
174 *
175 * Now, if the stack is empty, '&regs->sp' is out of range. In this
176 * case we try to take the previous stack. To always return a non-null
177 * stack pointer we fall back to regs as stack if no previous stack
178 * exists.
179 *
180 * This is valid only for kernel mode traps.
181 */
182unsigned long kernel_stack_pointer(struct pt_regs *regs)
183{
184 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
185 unsigned long sp = (unsigned long)&regs->sp;
186 struct thread_info *tinfo;
187
188 if (context == (sp & ~(THREAD_SIZE - 1)))
189 return sp;
190
191 tinfo = (struct thread_info *)context;
192 if (tinfo->previous_esp)
193 return tinfo->previous_esp;
194
195 return (unsigned long)regs;
196}
197EXPORT_SYMBOL_GPL(kernel_stack_pointer);
198
199static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
200{
201 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
202 return &regs->bx + (regno >> 2);
203}
204
205static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
206{

--- 1279 unchanged lines hidden (view full) ---

1486/*
1487 * We must return the syscall number to actually look up in the table.
1488 * This can be -1L to skip running any syscall at all.
1489 */
1490long syscall_trace_enter(struct pt_regs *regs)
1491{
1492 long ret = 0;
1493
169static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
170{
171 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
172 return &regs->bx + (regno >> 2);
173}
174
175static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
176{

--- 1279 unchanged lines hidden (view full) ---

1456/*
1457 * We must return the syscall number to actually look up in the table.
1458 * This can be -1L to skip running any syscall at all.
1459 */
1460long syscall_trace_enter(struct pt_regs *regs)
1461{
1462 long ret = 0;
1463
1494 rcu_user_exit();
1464 user_exit();
1495
1496 /*
1497 * If we stepped into a sysenter/syscall insn, it trapped in
1498 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
1499 * If user-mode had set TF itself, then it's still clear from
1500 * do_debug() and we need to set it again to restore the user
1501 * state. If we entered on the slow path, TF was already set.
1502 */

--- 33 unchanged lines hidden (view full) ---

1536out:
1537 return ret ?: regs->orig_ax;
1538}
1539
1540void syscall_trace_leave(struct pt_regs *regs)
1541{
1542 bool step;
1543
1465
1466 /*
1467 * If we stepped into a sysenter/syscall insn, it trapped in
1468 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
1469 * If user-mode had set TF itself, then it's still clear from
1470 * do_debug() and we need to set it again to restore the user
1471 * state. If we entered on the slow path, TF was already set.
1472 */

--- 33 unchanged lines hidden (view full) ---

1506out:
1507 return ret ?: regs->orig_ax;
1508}
1509
1510void syscall_trace_leave(struct pt_regs *regs)
1511{
1512 bool step;
1513
1514 /*
1515 * We may come here right after calling schedule_user()
1516 * or do_notify_resume(), in which case we can be in RCU
1517 * user mode.
1518 */
1519 user_exit();
1520
1544 audit_syscall_exit(regs);
1545
1546 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
1547 trace_sys_exit(regs, regs->ax);
1548
1549 /*
1550 * If TIF_SYSCALL_EMU is set, we only get here because of
1551 * TIF_SINGLESTEP (i.e. this is PTRACE_SYSEMU_SINGLESTEP).
1552 * We already reported this syscall instruction in
1553 * syscall_trace_enter().
1554 */
1555 step = unlikely(test_thread_flag(TIF_SINGLESTEP)) &&
1556 !test_thread_flag(TIF_SYSCALL_EMU);
1557 if (step || test_thread_flag(TIF_SYSCALL_TRACE))
1558 tracehook_report_syscall_exit(regs, step);
1559
1521 audit_syscall_exit(regs);
1522
1523 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
1524 trace_sys_exit(regs, regs->ax);
1525
1526 /*
1527 * If TIF_SYSCALL_EMU is set, we only get here because of
1528 * TIF_SINGLESTEP (i.e. this is PTRACE_SYSEMU_SINGLESTEP).
1529 * We already reported this syscall instruction in
1530 * syscall_trace_enter().
1531 */
1532 step = unlikely(test_thread_flag(TIF_SINGLESTEP)) &&
1533 !test_thread_flag(TIF_SYSCALL_EMU);
1534 if (step || test_thread_flag(TIF_SYSCALL_TRACE))
1535 tracehook_report_syscall_exit(regs, step);
1536
1560 rcu_user_enter();
1537 user_enter();
1561}
1538}