diff options
Diffstat (limited to 'arch/x86/kernel/kprobes_64.c')
-rw-r--r-- | arch/x86/kernel/kprobes_64.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/arch/x86/kernel/kprobes_64.c b/arch/x86/kernel/kprobes_64.c index 5df19a9f9239..10d66e323c7d 100644 --- a/arch/x86/kernel/kprobes_64.c +++ b/arch/x86/kernel/kprobes_64.c | |||
@@ -256,8 +256,21 @@ static void __kprobes set_current_kprobe(struct kprobe *p, struct pt_regs *regs, | |||
256 | kcb->kprobe_saved_rflags &= ~IF_MASK; | 256 | kcb->kprobe_saved_rflags &= ~IF_MASK; |
257 | } | 257 | } |
258 | 258 | ||
259 | static __always_inline void clear_btf(void) | ||
260 | { | ||
261 | if (test_thread_flag(TIF_DEBUGCTLMSR)) | ||
262 | wrmsrl(MSR_IA32_DEBUGCTLMSR, 0); | ||
263 | } | ||
264 | |||
265 | static __always_inline void restore_btf(void) | ||
266 | { | ||
267 | if (test_thread_flag(TIF_DEBUGCTLMSR)) | ||
268 | wrmsrl(MSR_IA32_DEBUGCTLMSR, current->thread.debugctlmsr); | ||
269 | } | ||
270 | |||
259 | static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) | 271 | static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) |
260 | { | 272 | { |
273 | clear_btf(); | ||
261 | regs->eflags |= TF_MASK; | 274 | regs->eflags |= TF_MASK; |
262 | regs->eflags &= ~IF_MASK; | 275 | regs->eflags &= ~IF_MASK; |
263 | /*single step inline if the instruction is an int3*/ | 276 | /*single step inline if the instruction is an int3*/ |
@@ -527,6 +540,7 @@ static void __kprobes resume_execution(struct kprobe *p, | |||
527 | 540 | ||
528 | regs->rip = orig_rip + (regs->rip - copy_rip); | 541 | regs->rip = orig_rip + (regs->rip - copy_rip); |
529 | no_change: | 542 | no_change: |
543 | restore_btf(); | ||
530 | 544 | ||
531 | return; | 545 | return; |
532 | } | 546 | } |