linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: "Suzuki K. Poulose" <suzuki@in.ibm.com>,
	Kumar Gala <galak@kernel.crashing.org>,
	oleg@redhat.com, ananth@in.ibm.com, srikar@linux.vnet.ibm.com,
	peterz@infradead.org, linux-kernel@vger.kernel.org,
	linuxppc-dev@ozlabs.org, anton@redhat.com, mingo@elte.hu
Subject: Re: [PATCH v2 1/4] kprobes/powerpc: Do not disable External interrupts during single step
Date: Mon, 07 Jan 2013 13:03:40 +0100	[thread overview]
Message-ID: <50EAB99C.6000205@linutronix.de> (raw)
In-Reply-To: <1357274575.2500.23.camel@pasglop>

On 01/04/2013 05:42 AM, Benjamin Herrenschmidt wrote:
> On Tue, 2012-12-11 at 11:18 +0530, Suzuki K. Poulose wrote:
>> On 12/03/2012 08:37 PM, Suzuki K. Poulose wrote:
>>> From: Suzuki K. Poulose<suzuki@in.ibm.com>
>>>
>>> External/Decrement exceptions have lower priority than the Debug Exception.
>>> So, we don't have to disable the External interrupts before a single step.
>>> However, on BookE, Critical Input Exception(CE) has higher priority than a
>>> Debug Exception. Hence we mask them.
>
> I'm not sure about that one ...
>
>> From memory, 4xx has that interesting issue which is that if you have
> single step enabled and an interrupt (of *any kind* occurs), the
> processor *will* step into the first instruction of the interrupt
> handler. (In fact, some silicons have a bug where it can even be the
> *second* instruction of the handler, which can be problematic when the
> first one is a branch).
>
> This is why you may notice that whole business we have in the handling
> of debug/crit interrupts where we try to figure out if that happened,
> and return with DE off if it did.
>
> Now, the above mentioned workaround means we might not need to disable
> EE indeed.
>
> However, in any case, I don't see what your patch fixes or improves, nor
> do I understand what you mean by "it is possible we'd get the single
> step reported for CE". Please explain in more details and describe the
> problematic scenario.

This change is probably my fault to some degree so let me explain. I've
been looking over the patch in first place and noticed that Suzuki
disables EE while enabling single stepping. After looking into the
manual I did not find a reason why this is done.

_If_ an external interrupt is pending and we enable EE and DE at the 
same time (via rfi) then we should never land in the external interrupt 
handler but always in the debug exception handler (and EE is disabled on 
all interrupts by the CPU). So why disable EE here?

_If_ the instruction in problem state triggers an DTLB exception then
we land in the TLB exception handler with DE bit set in MSR. I would say 
that this isn't uncommon (same goes probably for the syscall
opcode). After executing the first in instruction in kernel the CPU
should disable the DE (and CE) bit in the MSR and invoke the critical
exception handler. The critical debug exception handler seems to handle
this case. So disable DE, let the previous handler continue and exit to
problem state with DE enabled. From the uprobe point of view, we won't
stop over kernel code but only know once a problem state instruction is
over.

Based on this I did not see a reason why we should disable EE (or CE)
upfront. And for CE, it should be harmless if the code notices that we
debug problem state and continue the non-critical exception with
DE-disabled.

Now, if you come along with some CPU erratas on the 4xx CPUs where we
have to disable CE/EE because the CPU doesn't do what is expected then
I think that this should be explained in the comment :)

> Cheers,
> Ben.

Sebastian

  reply	other threads:[~2013-01-07 12:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-03 15:07 [PATCH v2 0/4] uprobes/powerpc: Replace ptrace helpers for single stepping Suzuki K. Poulose
2012-12-03 15:07 ` [PATCH v2 1/4] kprobes/powerpc: Do not disable External interrupts during single step Suzuki K. Poulose
2012-12-11  5:48   ` Suzuki K. Poulose
2013-01-04  4:42     ` Benjamin Herrenschmidt
2013-01-07 12:03       ` Sebastian Andrzej Siewior [this message]
2012-12-03 15:08 ` [PATCH v2 2/4] powerpc: Move the single step enable code to a generic path Suzuki K. Poulose
2012-12-10 10:34   ` Ananth N Mavinakayanahalli
2012-12-03 15:09 ` [PATCH v2 3/4] uprobes/powerpc: Introduce routines for save/restore context Suzuki K. Poulose
2012-12-03 15:15   ` Ananth N Mavinakayanahalli
2012-12-03 15:48     ` Suzuki K. Poulose
2012-12-10 10:35   ` Ananth N Mavinakayanahalli
2012-12-03 15:10 ` [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step Suzuki K. Poulose
2012-12-10 10:35   ` Ananth N Mavinakayanahalli
2012-12-14 20:02   ` Oleg Nesterov
2012-12-18  5:11     ` Suzuki K. Poulose
2012-12-18  5:36     ` Ananth N Mavinakayanahalli
2012-12-18 19:10       ` Oleg Nesterov
2012-12-19  4:53         ` Ananth N Mavinakayanahalli

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=50EAB99C.6000205@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=ananth@in.ibm.com \
    --cc=anton@redhat.com \
    --cc=benh@kernel.crashing.org \
    --cc=galak@kernel.crashing.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mingo@elte.hu \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=suzuki@in.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).