From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 078D8C63685 for ; Thu, 13 Sep 2018 18:37:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BA8C320881 for ; Thu, 13 Sep 2018 18:37:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="dRkeTcOG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA8C320881 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbeIMXrv (ORCPT ); Thu, 13 Sep 2018 19:47:51 -0400 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:26981 "EHLO esa4.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728031AbeIMXru (ORCPT ); Thu, 13 Sep 2018 19:47:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1536863828; x=1568399828; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=IWxrMPP8QxU5skWTKS1CuDJnhG9N0HHk6Ifj0AfIiZA=; b=dRkeTcOG4N732zcaDa4+QnQAzpxhGmkIA8CCgomvhrN6wUXWuzkjdawN qyc2wA1+9nsp34bjOphBa/9aiQ+8glI1hQoe66w0SfucG+WHbSrjZweFL q3ZvABT9pmXUBl06MbXko8s+fbRKadEK5riyXQte4d2QeFEkm8UtQ/7Og bKJpyDySVhAwfoOa30qTf1uOuq3JtPYrsZAFxsEeReRBv4eGF6JQdZdet WDGbK9QceNxMf6xZSeviUsiyxRjlZ/qETjBybAtjiNsXrw21YPzcFUIH3 cGWOE92VB7pt177/Z7RzXRG95XRgovIVmotIKgtd/an8FNuNeDVevXwAu g==; X-IronPort-AV: E=Sophos;i="5.53,370,1531756800"; d="scan'208";a="89712017" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 14 Sep 2018 02:37:08 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 13 Sep 2018 11:23:38 -0700 Received: from jedi-01.sdcorp.global.sandisk.com (HELO jedi-01.int.fusionio.com) ([10.11.143.218]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Sep 2018 11:37:08 -0700 From: Atish Patra To: palmer@sifive.com, linux-riscv@lists.infradead.org, hch@infradead.org, anup@brainfault.org Cc: mark.rutland@arm.com, atish.patra@wdc.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, Damien.LeMoal@wdc.com, marc.zyngier@arm.com, jeremy.linton@arm.com, gregkh@linuxfoundation.org, jason@lakedaemon.net, catalin.marinas@arm.com, dmitriy@oss-tech.org, ard.biesheuvel@linaro.org, schwab@linux-m68k.org Subject: [PATCH v5 05/12] RISC-V: Disable preemption before enabling interrupts Date: Thu, 13 Sep 2018 11:36:58 -0700 Message-Id: <1536863825-66808-6-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536863825-66808-1-git-send-email-atish.patra@wdc.com> References: <1536863825-66808-1-git-send-email-atish.patra@wdc.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, irq is enabled before preemption disabling happens. If the scheduler fired right here and cpu is scheduled then it may blow up. Signed-off-by: Palmer Dabbelt [Atish: Commit text and code comment formatting update] Signed-off-by: Atish Patra Reviewed-by: Christoph Hellwig --- arch/riscv/kernel/smpboot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/riscv/kernel/smpboot.c b/arch/riscv/kernel/smpboot.c index 712e9ca8..670749ec 100644 --- a/arch/riscv/kernel/smpboot.c +++ b/arch/riscv/kernel/smpboot.c @@ -111,7 +111,11 @@ asmlinkage void __init smp_callin(void) * a local TLB flush right now just in case. */ local_flush_tlb_all(); - local_irq_enable(); + /* + * Disable preemption before enabling interrupts, so we don't try to + * schedule a CPU that hasn't actually started yet. + */ preempt_disable(); + local_irq_enable(); cpu_startup_entry(CPUHP_AP_ONLINE_IDLE); } -- 2.7.4