Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1038177imm; Thu, 13 Sep 2018 11:38:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZaycY3s8OSFSAIinE9i5Se5PDvworzp3sXsNWn2iJplwvyySbK9f7ybvTajqOsOOu0nxdf X-Received: by 2002:a62:868b:: with SMTP id x133-v6mr8701839pfd.252.1536863896197; Thu, 13 Sep 2018 11:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536863896; cv=none; d=google.com; s=arc-20160816; b=teoMeD4D2yujhaQH0evjWK8cGQc2OEY36O4n/c14IoUsBFI+3iESFE+WxoQMbheIOl P4Y8So+3T0i+73eLBOHsH98U87YAW1Y6zAdyMgK220o4FMYnI0RtUYGSQN2uvGdxL4Bx EKDTYOZauEyflWclSblGwqRqR4+zLajuNPEfzY4azGh4Z1TwTMzlMIzEq8dxSlcQCizN QttwE/5wLiQhW1ZZpvn6aEI/SnQhTxbflqh74enLWuq2TH20h6IihM2/qrKo5Blnq/9G ep5my8vZqwkxtShD9c/0xU3Akgkl9gWRV4n9xKWEJOmPnWRfPHS2pfMYPC+Y3uUL3yEq s4jA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=xRFUQLoU+NQb0VL47rXVJbg0SIYkBdfhuSBQYJCgi/w=; b=ETdnv2ymqPsrQh0wYHonO6p3mZA/xfypRltnJdTRtpxICRM02/DwDiWdU0IbyMUuh8 umGTpeF06Mlh6hSXlah+1TuZg2q5P0ff9YKpvJhr72JihH+p1aBsnJ0rJgbmX5iG+shY AgHv9nvUw9Ph6EKUTfXjS481Na4R8azCQxxqqyRPB9JBDdqvHg1JOFO9ybfXgjKqWOHZ cX+zUlWnjq3CTvFVOiXZy3HIv9x1dLdp8jT3inBGedU0eR/ciw2MCO5WHlj6bZAvne+a Aqq9h3MKSuEomxlBg/+VHDiLQ+4ObV4Kczf7Lvc+0aPYBitKNrY5rWVC6clOrxP1kwmN 8UoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dRkeTcOG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m1-v6si4308749plb.348.2018.09.13.11.38.01; Thu, 13 Sep 2018 11:38:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b=dRkeTcOG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=wdc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728178AbeIMXru (ORCPT + 99 others); Thu, 13 Sep 2018 19:47:50 -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