From: "H. Peter Anvin" <hpa@zytor.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Cyrill Gorcunov <gorcunov@gmail.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Thomas Gleixner <tglx@linutronix.de>,
David Miller <davem@davemloft.net>,
"Theodore Ts'o" <tytso@mit.edu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
the arch/x86 maintainers <x86@kernel.org>,
Network Development <netdev@vger.kernel.org>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
Fr??d??ric Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH v2] x86: make DR*_RESERVED unsigned long
Date: Sat, 27 Apr 2013 09:20:28 -0700 [thread overview]
Message-ID: <021d338d-74c4-4c2b-960e-8d9cf78b4141@email.android.com> (raw)
In-Reply-To: <20130427144537.GA24256@redhat.com>
I don't know why this is uapi... finest make a lot of sense to me.
Oleg Nesterov <oleg@redhat.com> wrote:
>On 04/26, Oleg Nesterov wrote:
>
>> 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" ;)
>
>Or we can do the s/reserved/mask/ change and avoid any "unexpected"
>effect of "long &= ~int". This allso allows to kill ifdef(__i386__).
>
>But this is include/uapi, I do not know if I can simply remove the
>old define's.
>
>In short: whatever you prefer, including "leave it alone".
>
>Oleg.
>
>diff --git a/arch/x86/include/uapi/asm/debugreg.h
>b/arch/x86/include/uapi/asm/debugreg.h
>index 3c0874d..2678b23 100644
>--- a/arch/x86/include/uapi/asm/debugreg.h
>+++ b/arch/x86/include/uapi/asm/debugreg.h
>@@ -14,8 +14,7 @@
> which debugging register was responsible for the trap. The other bits
> 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_MASK (0xF00FU) /* Everything else is reserved */
>
> #define DR_TRAP0 (0x1) /* db0 */
> #define DR_TRAP1 (0x2) /* db1 */
>@@ -32,6 +31,8 @@
> and indicates what types of access we trap on, and how large the data
> field is that we are looking at */
>
>+#define DR_CONTROL_MASK (0xFFFF03FFU) /* Everything else is reserved
>*/
>+
> #define DR_CONTROL_SHIFT 16 /* Skip this many bits in ctl register */
> #define DR_CONTROL_SIZE 4 /* 4 control bits per register */
>
>@@ -64,12 +65,6 @@
> We can slow the instruction pipeline for instructions coming via the
>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 */
>-#else
>-#define DR_CONTROL_RESERVED (0xFFFFFFFF0000FC00UL) /* Reserved */
>-#endif
>-
> #define DR_LOCAL_SLOWDOWN (0x100) /* Local slow the pipeline */
> #define DR_GLOBAL_SLOWDOWN (0x200) /* Global slow the pipeline */
>
>diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
>index 7461f50..bc5fb98 100644
>--- a/arch/x86/kernel/ptrace.c
>+++ b/arch/x86/kernel/ptrace.c
>@@ -657,7 +657,7 @@ static int ptrace_write_dr7(struct task_struct
>*tsk, unsigned long data)
> bool second_pass = false;
> int i, rc, ret = 0;
>
>- data &= ~DR_CONTROL_RESERVED;
>+ data &= DR_CONTROL_MASK;
> old_dr7 = ptrace_get_dr7(thread->ptrace_bps);
>
> restore:
>diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
>index 68bda7a..42a635f 100644
>--- a/arch/x86/kernel/traps.c
>+++ b/arch/x86/kernel/traps.c
>@@ -402,7 +402,7 @@ dotraplinkage void __kprobes do_debug(struct
>pt_regs *regs, long error_code)
> get_debugreg(dr6, 6);
>
> /* Filter out all the reserved bits which are preset to 1 */
>- dr6 &= ~DR6_RESERVED;
>+ dr6 &= DR6_MASK;
>
> /*
> * If dr6 has no reason to give us about the origin of this trap,
--
Sent from my mobile phone. Please excuse brevity and lack of formatting.
next prev parent reply other threads:[~2013-04-27 16:20 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CA+55aFwpLu0qNms=hkQr43yqD0K9DgESNm91OEWKT1ZuT8MU6Q@mail.gmail.com>
2013-04-23 0:23 ` Unsigned widening casts of binary "not" operations Linus Torvalds
2013-04-23 8:59 ` David Laight
2013-04-23 14:29 ` Linus Torvalds
2013-04-23 15:24 ` David Laight
2013-04-23 15:42 ` Linus Torvalds
2013-04-23 15:52 ` Theodore Ts'o
2013-04-23 16:05 ` Linus Torvalds
2013-04-23 17:37 ` David Miller
2013-04-23 17:52 ` Linus Torvalds
2013-04-23 17:56 ` David Miller
2013-04-23 18:21 ` Linus Torvalds
2013-04-24 12:36 ` Geert Uytterhoeven
2013-04-23 0:32 ` H. Peter Anvin
2013-04-23 13:00 ` Theodore Ts'o
2013-04-24 7:26 ` Ingo Molnar
2013-04-24 7:47 ` Cyrill Gorcunov
2013-04-25 1:13 ` Lin Ming
2013-04-24 17:07 ` [PATCH] x86: make DR*_RESERVED unsigned long Oleg Nesterov
2013-04-24 18:45 ` H. Peter Anvin
2013-04-25 14:48 ` Oleg Nesterov
2013-04-26 16:38 ` [PATCH v2] " Oleg Nesterov
2013-04-26 16:44 ` H. Peter Anvin
2013-04-26 17:15 ` Oleg Nesterov
2013-04-27 14:45 ` Oleg Nesterov
2013-04-27 16:20 ` H. Peter Anvin [this message]
2013-04-28 0:58 ` Frederic Weisbecker
2013-04-28 17:27 ` Oleg Nesterov
2013-04-28 17:32 ` H. Peter Anvin
2013-04-28 17:39 ` Oleg Nesterov
2013-04-28 17:43 ` H. Peter Anvin
2013-04-24 22:48 ` [PATCH] " Frederic Weisbecker
2013-04-24 23:06 ` H. Peter Anvin
2013-04-24 23:31 ` Frederic Weisbecker
2013-04-25 1:20 ` H. Peter Anvin
2013-04-26 14:20 ` [tip:perf/core] perf/x86/intel/P4: Robistify P4 PMU types tip-bot for Ingo Molnar
2013-04-26 16:13 ` Borislav Petkov
2013-04-26 16:24 ` Cyrill Gorcunov
2013-04-26 16:39 ` Borislav Petkov
2013-04-26 16:46 ` Cyrill Gorcunov
2013-04-27 16:14 ` Borislav Petkov
2013-04-27 16:33 ` Cyrill Gorcunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=021d338d-74c4-4c2b-960e-8d9cf78b4141@email.android.com \
--to=hpa@zytor.com \
--cc=a.p.zijlstra@chello.nl \
--cc=davem@davemloft.net \
--cc=fweisbec@gmail.com \
--cc=gorcunov@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome