Message ID | 20130426163802.GA30351@redhat.com |
---|---|
State | New, archived |
Headers | show |
On 04/26/2013 09:38 AM, Oleg Nesterov wrote: > DR6_RESERVED and DR_CONTROL_RESERVED are used to clear the set > bits in the "unsigned long" data, make them long to ensure that > "&~" doesn't clear the upper bits. > > This is only cleanup, the usage of ~DR*_RESERVED is safe but > doesn't look clean and the pattern is error prone. > > - do_debug: > > dr6 &= ~DR6_RESERVED; > > this also wrongly clears 32-63 bits. Fortunately these > bits are reserved and must be zero. > I don't think this is wrongly at all. The whole point is to mask out the bits that the handler doesn't want to deal with, so masking out the reserved bits [63:32] seems reasonable to me. The comment should probably be corrected, though. -hpa -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 04/26, H. Peter Anvin wrote: > > On 04/26/2013 09:38 AM, Oleg Nesterov wrote: > > > > - do_debug: > > > > dr6 &= ~DR6_RESERVED; > > > > this also wrongly clears 32-63 bits. Fortunately these > > bits are reserved and must be zero. > > I don't think this is wrongly at all. OK, I meant that it also clears the bits that are not specified in DR6_RESERVED mask. > The whole point is to mask out > the bits that the handler doesn't want to deal with, so masking out the > reserved bits [63:32] seems reasonable to me. Then we should do - #define DR6_RESERVED 0xFFFF0FF0 + #define DR6_RESERVED 0xFFFFFFFFFFFF0FF0 ? or what? (just in case, I will happily agree with "do nothing" ;) > The comment should probably be corrected, though. Which one? /* Define reserved bits in DR6 which are always set to 1 */ #define DR6_RESERVED (0xFFFF0FF0UL) /* Filter out all the reserved bits which are preset to 1 */ dr6 &= ~DR6_RESERVED; I guess both should be updated then. But if I read the doc correctly the lower reserved bits are set to 1. However do_debug() does set_debugreg(0, 6) and this looks correct, the doc says "debug handlers should clear the register before returning to the interrupted task". Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/include/uapi/asm/debugreg.h b/arch/x86/include/uapi/asm/debugreg.h index 3c0874d..c0c1b89 100644 --- a/arch/x86/include/uapi/asm/debugreg.h +++ b/arch/x86/include/uapi/asm/debugreg.h @@ -15,7 +15,7 @@ are either reserved or not of interest to us. */ /* Define reserved bits in DR6 which are always set to 1 */ -#define DR6_RESERVED (0xFFFF0FF0) +#define DR6_RESERVED (0xFFFF0FF0UL) #define DR_TRAP0 (0x1) /* db0 */ #define DR_TRAP1 (0x2) /* db1 */ @@ -65,7 +65,7 @@ gdt or the ldt if we want to. I am not sure why this is an advantage */ #ifdef __i386__ -#define DR_CONTROL_RESERVED (0xFC00) /* Reserved by Intel */ +#define DR_CONTROL_RESERVED (0xFC00UL) /* Reserved by Intel */ #else #define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL) /* Reserved */ #endif
DR6_RESERVED and DR_CONTROL_RESERVED are used to clear the set bits in the "unsigned long" data, make them long to ensure that "&~" doesn't clear the upper bits. This is only cleanup, the usage of ~DR*_RESERVED is safe but doesn't look clean and the pattern is error prone. - do_debug: dr6 &= ~DR6_RESERVED; this also wrongly clears 32-63 bits. Fortunately these bits are reserved and must be zero. - ptrace_write_dr7: data &= ~DR_CONTROL_RESERVED; on __i386__ this mixes long/int but sizeof should be the same. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Oleg Nesterov <oleg@redhat.com> --- arch/x86/include/uapi/asm/debugreg.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)