From: "tiejun.chen" <tiejun.chen@windriver.com>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Alexander Graf <agraf@suse.de>,
"<kvm-ppc@vger.kernel.org>" <kvm-ppc@vger.kernel.org>,
"<kvm@vger.kernel.org> list" <kvm@vger.kernel.org>
Subject: Re: [v1][PATCH 1/1] KVM: PPC: disable preemption when using hard_irq_disable()
Date: Fri, 12 Jul 2013 02:13:39 +0000 [thread overview]
Message-ID: <51DF6653.7010902@windriver.com> (raw)
In-Reply-To: <1373588345.19894.126.camel@pasglop>
On 07/12/2013 08:19 AM, Benjamin Herrenschmidt wrote:
> On Thu, 2013-07-11 at 15:07 +0200, Alexander Graf wrote:
>> Ok, let me quickly explain the problem.
>>
>> We are leaving host context, switching slowly into guest context.
>> During that transition we call get_paca() indirectly (apparently by
>> another call to hard_disable() which sounds bogus, but that's another
>> story).
>>
>> get_paca() warns when we're preemptible. We're only not preemptible
>> when either preempt is disabled or irqs are disabled. Irqs are
>> disabled, but arch_irqs_disabled() doesn't know, because it only
>> checks for soft disabled IRQs.
>>
>> So we can fix this either by setting IRQs as soft disabled as well or
>> by disabling preemption until we enter the guest for real. Any
>> preferences?
>
> Well, if you hard disable first (ie, direct transition from full enabled
> to hard disabled), you know you have nothing lazy pending in
> irq_pending, then it's ok to mess around with local_paca->soft_enabled
> to make it "look disabled".
>
> IE. Call hard_irq_disable(), then only turn local_paca->soft_enabled
> back on late in the process, some time before the final rfi(d).
>
> That works as long as you had a transition from full enabled to full
> disabled and don't hard re-enable in the process. IE, You are certain
> that there is nothing pending in irq_happened.
>
> HOWEVER !
>
> If you do that, you *ALSO* need to clear irq_happened. You must *NEVER*
> leave PACA_IRQ_HARD_DIS set in irq_happened if you are soft-enabled, and
> since the above means that you *will* be seen as soft enabled on the way
> out of the guest, you can kaboom.
>
> BTW. I'm fine with a patch that does:
>
> #define hard_irq_disable() do { \
> u8 _was_enabled = get_paca()->soft_enabled; \
Current problem I met is issued from the above line.
> __hard_irq_disable(); \
> - get_paca()->soft_enabled = 0; \
Not here.
If I'm misunderstanding what you guys means, please correct me since this is a
long discussion thread. I have to reread that carefully.
Tiejun
> + local_paca->soft_enabled = 0; \
>
> In fact we should probably do it anyway.
>
> Cheers,
> Ben.
>
>
>
>
next prev parent reply other threads:[~2013-07-12 2:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 6:02 [v1][PATCH 1/1] KVM: PPC: disable preemption when using hard_irq_disable() Tiejun Chen
2013-07-10 9:49 ` Alexander Graf
2013-07-11 2:48 ` tiejun.chen
2013-07-11 9:49 ` Alexander Graf
2013-07-11 12:28 ` Benjamin Herrenschmidt
2013-07-11 12:47 ` Alexander Graf
2013-07-11 12:54 ` Benjamin Herrenschmidt
2013-07-11 13:07 ` Alexander Graf
2013-07-12 0:19 ` Benjamin Herrenschmidt
2013-07-12 2:13 ` tiejun.chen [this message]
2013-07-12 3:57 ` Benjamin Herrenschmidt
2013-07-12 4:54 ` tiejun.chen
2013-07-14 4:13 ` Benjamin Herrenschmidt
2013-07-15 3:04 ` tiejun.chen
2013-07-10 19:15 ` Scott Wood
2013-07-11 2:59 ` tiejun.chen
[not found] <1373559480.8183.258@snotra>
2013-07-12 0:30 ` Benjamin Herrenschmidt
[not found] ` <FB21594A-C233-4A97-8503-E2A1275F8F17@suse.de>
[not found] ` <1373560585.8183.261@snotra>
2013-07-12 3:22 ` tiejun.chen
[not found] <1373651433.8183.276@snotra>
2013-07-12 23:05 ` Benjamin Herrenschmidt
2013-07-15 2:20 ` tiejun.chen
2013-07-15 2:47 ` Benjamin Herrenschmidt
2013-07-15 3:03 ` tiejun.chen
[not found] ` <1373909248.8183.303@snotra>
2013-07-16 2:15 ` tiejun.chen
2013-07-15 2:25 ` tiejun.chen
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=51DF6653.7010902@windriver.com \
--to=tiejun.chen@windriver.com \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.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