From patchwork Fri Jul 12 04:54:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiejun Chen X-Patchwork-Id: 2826798 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 315A19F968 for ; Fri, 12 Jul 2013 04:54:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5DA0B20181 for ; Fri, 12 Jul 2013 04:54:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD5FB2017B for ; Fri, 12 Jul 2013 04:53:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751307Ab3GLExz (ORCPT ); Fri, 12 Jul 2013 00:53:55 -0400 Received: from mail.windriver.com ([147.11.1.11]:57002 "EHLO mail.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751125Ab3GLExy (ORCPT ); Fri, 12 Jul 2013 00:53:54 -0400 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail.windriver.com (8.14.5/8.14.3) with ESMTP id r6C4rjHs009375 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 11 Jul 2013 21:53:45 -0700 (PDT) Received: from [128.224.162.214] (128.224.162.214) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server (TLS) id 14.2.342.3; Thu, 11 Jul 2013 21:53:44 -0700 Message-ID: <51DF8C0A.6070608@windriver.com> Date: Fri, 12 Jul 2013 12:54:34 +0800 From: "tiejun.chen" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130623 Thunderbird/17.0.7 MIME-Version: 1.0 To: Benjamin Herrenschmidt CC: Alexander Graf , "" , " list" Subject: Re: [v1][PATCH 1/1] KVM: PPC: disable preemption when using hard_irq_disable() References: <1373436139-27998-1-git-send-email-tiejun.chen@windriver.com> <62E2724C-EC17-4E36-AC9E-C9FFEDF5C5B7@suse.de> <51DE1CE9.7060406@windriver.com> <1373545684.19894.80.camel@pasglop> <3B36D92F-CD11-49A0-A0F5-CD3E49BD6793@suse.de> <1373547293.19894.99.camel@pasglop> <1373588345.19894.126.camel@pasglop> <51DF6653.7010902@windriver.com> <1373601460.19894.135.camel@pasglop> In-Reply-To: <1373601460.19894.135.camel@pasglop> X-Originating-IP: [128.224.162.214] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 07/12/2013 11:57 AM, Benjamin Herrenschmidt wrote: > On Fri, 2013-07-12 at 10:13 +0800, tiejun.chen wrote: >>> #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. > > Then make it > u8 _was_enabled; > __hard_irq_disable(); > was_enabled = local_paca->.... > > Once you have hard disabled, using local_paca directly *should* be safe > (minus that gcc problem I mentioned). Is the following fine? powerpc: to access local paca after hard irq disabled We can access paca directly after hard interrupt disabled, and this can avoid accessing wrong paca when using get_paca() in preempt case. Signed-off-by: Tiejun Chen --- arch/powerpc/include/asm/hw_irq.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/hw_irq.h b/arch/powerpc/include/asm/hw_irq.h index ba713f1..10be1dd 100644 --- a/arch/powerpc/include/asm/hw_irq.h +++ b/arch/powerpc/include/asm/hw_irq.h @@ -96,10 +96,11 @@ static inline bool arch_irqs_disabled(void) #endif #define hard_irq_disable() do { \ - u8 _was_enabled = get_paca()->soft_enabled; \ + u8 _was_enabled; \ __hard_irq_disable(); \ - get_paca()->soft_enabled = 0; \ - get_paca()->irq_happened |= PACA_IRQ_HARD_DIS; \ + _was_enabled = local_paca->soft_enabled; \ + local_paca->soft_enabled = 0; \ + local_paca->irq_happened |= PACA_IRQ_HARD_DIS; \ if (_was_enabled) \ trace_hardirqs_off(); \ } while(0)