Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1345504
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 06/10] x86/traps: Clear DR6 early in do_debug and improve the comment |
| Date | 2016-02-29 06:40 +0100 |
| Message-ID | <r7oIO-6iS-15@gated-at.bofh.it> (permalink) |
| References | <r7oz8-6aX-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Leaving any bits set in DR6 on return from a debug exception is asking for trouble. Prevent it by writing zero right away and clarify the comment. Signed-off-by: Andy Lutomirski <luto@kernel.org> --- arch/x86/kernel/traps.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 19e6cfa501e3..6dddc220e3ed 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -593,6 +593,18 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) ist_enter(regs); get_debugreg(dr6, 6); + /* + * The Intel SDM says: + * + * Certain debug exceptions may clear bits 0-3. The remaining + * contents of the DR6 register are never cleared by the + * processor. To avoid confusion in identifying debug + * exceptions, debug handlers should clear the register before + * returning to the interrupted task. + * + * Keep it simple: clear DR6 immediately. + */ + set_debugreg(0, 6); /* Filter out all the reserved bits which are preset to 1 */ dr6 &= ~DR6_RESERVED; @@ -616,9 +628,6 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) if ((dr6 & DR_STEP) && kmemcheck_trap(regs)) goto exit; - /* DR6 may or may not be cleared by the CPU */ - set_debugreg(0, 6); - /* Store the virtualized DR6 value */ tsk->thread.debugreg6 = dr6; -- 2.5.0
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Andy Lutomirski <luto@kernel.org> - 2016-02-29 06:40 +0100
[PATCH 06/10] x86/traps: Clear DR6 early in do_debug and improve the comment Andy Lutomirski <luto@kernel.org> - 2016-02-29 06:40 +0100
[PATCH 08/10] x86/entry: Only allocate space for SYSENTER_stack if needed Andy Lutomirski <luto@kernel.org> - 2016-02-29 06:40 +0100
[PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Andy Lutomirski <luto@kernel.org> - 2016-02-29 06:40 +0100
Re: [PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Borislav Petkov <bp@alien8.de> - 2016-02-29 21:40 +0100
Re: [PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Andy Lutomirski <luto@amacapital.net> - 2016-02-29 21:50 +0100
Re: [PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Borislav Petkov <bp@alien8.de> - 2016-02-29 23:10 +0100
Re: [PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Borislav Petkov <bp@alien8.de> - 2016-02-29 23:40 +0100
Re: [PATCH 02/10] x86/entry/compat: In SYSENTER, sink AC clearing below the existing FLAGS test Brian Gerst <brgerst@gmail.com> - 2016-02-29 23:40 +0100
Re: [PATCH 00/10] x86: Various SYSENTER/SYSEXIT/#DB fixes and cleanups Andy Lutomirski <luto@amacapital.net> - 2016-02-29 20:00 +0100
csiph-web