All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: Andy Lutomirski <luto@amacapital.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Oleg Nesterov <oleg@redhat.com>, Li Zefan <lizefan@huawei.com>,
	Steven Rostedt <rostedt@goodmis.org>
Cc: "linux-tip-commits@vger.kernel.org"  <linux-tip-commits@vger.kernel.org>
Subject: Re: [tip:x86/asm] x86/traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP
Date: Fri, 27 Feb 2015 10:21:22 +0800	[thread overview]
Message-ID: <54EFD4A2.2000702@huawei.com> (raw)
In-Reply-To: <CALCETrXxNcyJWOrnqMootBZpjVvxTx7SdKEPDG_PMCQa8cViqw@mail.gmail.com>

On 2015/2/26 23:12, Andy Lutomirski wrote:
> On Thu, Feb 26, 2015 at 5:12 AM, tip-bot for Wang Nan <tipbot@zytor.com> wrote:
>> Commit-ID:  b4d8327024637cb2a1f7910dcb5d0ad7a096f473
>> Gitweb:     http://git.kernel.org/tip/b4d8327024637cb2a1f7910dcb5d0ad7a096f473
>> Author:     Wang Nan <wangnan0@huawei.com>
>> AuthorDate: Thu, 26 Feb 2015 13:49:39 +0800
>> Committer:  Ingo Molnar <mingo@kernel.org>
>> CommitDate: Thu, 26 Feb 2015 12:29:20 +0100
>>
>> x86/traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP
>>
>> Before this patch early_trap_init() installs DEBUG_STACK for
>> X86_TRAP_BP and X86_TRAP_DB. However, DEBUG_STACK doesn't work
>> correctly until cpu_init() <-- trap_init().
>>
>> This patch passes 0 to set_intr_gate_ist() and
>> set_system_intr_gate_ist() instead of DEBUG_STACK to let it use
>> same stack as kernel, and installs DEBUG_STACK for them in
>> trap_init().
>>
> 
> Sorry, I'm late to the party.  This patch, while technically correct
> AFAICT, is really ugly, because the whole point is that it *doesn't*
> use ist.  In other words:
> 
>> +       set_intr_gate_ist(X86_TRAP_DB, &debug, 0);
> 
> That should be set_intr_gate(X86_TRAP_DB, &debug);
> 

I considered this, but found that set_intr_gate() and set_intr_gate_ist(..., 0)
behaviors differently: set_intr_gate() -> _trace_set_gate() requires 'trace_##addr'
to be installed to trace_idt_table, while set_intr_gate_ist(..., 0) puts 'addr'.
into trace_idt_table() through _set_gate().
Therefore, if we want to use set_intr_gate() we need to provide a trace_debug entry
for it, which will be overwritten in trap_init() so it is in fact a useless symbol.

Anyway, I'd like to post a v3 patch follow your advise. Please keep an eye on it.

Thank you!

>>         /* int3 can be called from all */
>> -       set_system_intr_gate_ist(X86_TRAP_BP, &int3, DEBUG_STACK);
>> +       set_system_intr_gate_ist(X86_TRAP_BP, &int3, 0);
> 
> Similarly, this should be set_system_gate.
> 
>>  #ifdef CONFIG_X86_32
>>         set_intr_gate(X86_TRAP_PF, page_fault);
>>  #endif
>> @@ -1005,6 +1013,15 @@ void __init trap_init(void)
>>          */
>>         cpu_init();
>>
>> +       /*
>> +        * X86_TRAP_DB and X86_TRAP_BP have been set
>> +        * in early_trap_init(). However, DEBUG_STACK works only after
>> +        * cpu_init() loads TSS. See comments in early_trap_init().
> 
> It's not that DEBUG_STACK only works after the TSS is loaded; it's
> that the IST mechanism only works after TSS is loaded.
> 
> --Andy
> 



  reply	other threads:[~2015-02-27  2:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26  5:49 [PATCH v2] x86, traps: Enable DEBUG_STACK after cpu_init() for TRAP_DB/BP Wang Nan
2015-02-26 13:12 ` [tip:x86/asm] x86/traps: " tip-bot for Wang Nan
2015-02-26 15:12   ` Andy Lutomirski
2015-02-27  2:21     ` Wang Nan [this message]
2015-02-27  2:33       ` Andy Lutomirski
2015-02-27  3:28         ` [PATCH] x86, traps: early_trap_init() cleanup Wang Nan
2015-02-27 10:11           ` Borislav Petkov
2015-02-27  4:19         ` [PATCH v2] x86, traps: separate set_intr_gate() and cleanup early_trap_init() Wang Nan
2015-03-02  9:55           ` Wang Nan
2015-03-02 17:06           ` Andy Lutomirski
2015-03-04 23:51           ` [tip:x86/asm] x86/traps: Separate set_intr_gate() and clean up early_trap_init() tip-bot for Wang Nan

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=54EFD4A2.2000702@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=luto@amacapital.net \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.