step.c (498495dba268b20e8eadd7fe93c140c68b6cc9d2) step.c (6342adcaa683c2b705c24ed201dc11b35854c88d)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * x86 single-step support code, common to 32-bit and 64-bit.
4 */
5#include <linux/sched.h>
6#include <linux/sched/task_stack.h>
7#include <linux/mm.h>
8#include <linux/ptrace.h>

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

122 * If enable_single_step() was used last and that is what
123 * set TIF_SINGLESTEP, then both TF and TIF_FORCED_TF are
124 * already set and our bookkeeping is fine.
125 */
126 if (unlikely(test_tsk_thread_flag(child, TIF_SINGLESTEP)))
127 regs->flags |= X86_EFLAGS_TF;
128
129 /*
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * x86 single-step support code, common to 32-bit and 64-bit.
4 */
5#include <linux/sched.h>
6#include <linux/sched/task_stack.h>
7#include <linux/mm.h>
8#include <linux/ptrace.h>

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

122 * If enable_single_step() was used last and that is what
123 * set TIF_SINGLESTEP, then both TF and TIF_FORCED_TF are
124 * already set and our bookkeeping is fine.
125 */
126 if (unlikely(test_tsk_thread_flag(child, TIF_SINGLESTEP)))
127 regs->flags |= X86_EFLAGS_TF;
128
129 /*
130 * Always set TIF_SINGLESTEP - this guarantees that
131 * we single-step system calls etc.. This will also
130 * Always set TIF_SINGLESTEP. This will also
132 * cause us to set TF when returning to user mode.
133 */
134 set_tsk_thread_flag(child, TIF_SINGLESTEP);
135
131 * cause us to set TF when returning to user mode.
132 */
133 set_tsk_thread_flag(child, TIF_SINGLESTEP);
134
135 /*
136 * Ensure that a trap is triggered once stepping out of a system
137 * call prior to executing any user instruction.
138 */
139 set_task_syscall_work(child, SYSCALL_EXIT_TRAP);
140
136 oflags = regs->flags;
137
138 /* Set TF on the kernel stack.. */
139 regs->flags |= X86_EFLAGS_TF;
140
141 /*
142 * ..but if TF is changed by the instruction we will trace,
143 * don't mark it as being "us" that set it, so that we

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

225 /*
226 * Make sure block stepping (BTF) is disabled.
227 */
228 if (test_tsk_thread_flag(child, TIF_BLOCKSTEP))
229 set_task_blockstep(child, false);
230
231 /* Always clear TIF_SINGLESTEP... */
232 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
141 oflags = regs->flags;
142
143 /* Set TF on the kernel stack.. */
144 regs->flags |= X86_EFLAGS_TF;
145
146 /*
147 * ..but if TF is changed by the instruction we will trace,
148 * don't mark it as being "us" that set it, so that we

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

230 /*
231 * Make sure block stepping (BTF) is disabled.
232 */
233 if (test_tsk_thread_flag(child, TIF_BLOCKSTEP))
234 set_task_blockstep(child, false);
235
236 /* Always clear TIF_SINGLESTEP... */
237 clear_tsk_thread_flag(child, TIF_SINGLESTEP);
238 clear_task_syscall_work(child, SYSCALL_EXIT_TRAP);
233
234 /* But touch TF only if it was set by us.. */
235 if (test_and_clear_tsk_thread_flag(child, TIF_FORCED_TF))
236 task_pt_regs(child)->flags &= ~X86_EFLAGS_TF;
237}
239
240 /* But touch TF only if it was set by us.. */
241 if (test_and_clear_tsk_thread_flag(child, TIF_FORCED_TF))
242 task_pt_regs(child)->flags &= ~X86_EFLAGS_TF;
243}