Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1688932imm; Tue, 2 Oct 2018 12:15:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV63xi+unnWw97LwFBXqTau2uCJ4mGbPA2mjtvX32VOSbvzZO0eOPAwYVIjQXIvtXxbwrfmOf X-Received: by 2002:a63:e40e:: with SMTP id a14-v6mr9913034pgi.28.1538507737029; Tue, 02 Oct 2018 12:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538507737; cv=none; d=google.com; s=arc-20160816; b=uCAcXlN7a51LgXlOB7EQtR4dcXf4fvWRIFwlWSPx+9ydm0x/NmdRb7zKO7/Nibil+K PD9MTQUD8D567YlzFULWvziVIuLvwZg6PNbp2dUC3clnpOLrMOMSf0iFdQxgrDZeaopa IPrXosXD3ixnlkjPKJJlk0DiB5maPVWH0ycrVhGCzgYcp8MtjGKg+U6zpiPvfTdCB1MV rqpnUmaL1hX+cw75dPMOydKZTIZM2ppxrQO9MN7qyB7RinjzAOK7Hbk3JGqAnRYyuBgi PWGY4VIHFBT09ALpl4ni0BZ+nt1aQ9laQCpEAvLaYecCSlgViFG1Qjad/etqE7fji5kM rfzg== 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=Lx+cQ8abgM0DuW488uZXgfRmWZJICfGXudEUcy4oacfb0ubVw58Ig6rK1d6ydSVi26 5RTtkf19XbXM2D1ORAF/XcE3tGbph1bYX1ab8vlEQiF+kcSCkt0PY75j2bwH8A0xUGut sEz2v4GpTdShaqVY6TTgUyFQfjrNjCOX5Gb9AgTshrqu5r3lPJkgzTfe8TTnYozT2wb6 7ebea4mp/g1pS795nZNCQmXNPKcPlI57ii2W26RpcDsOuis4GqUa4i6LYhF8bOGN0B34 9xAmjp4dhmXQN08keQwLdAcY88h5AH/JK7lG/QsB2OUarlUofJB75XqL/mMGx3lLnxed q8bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@wdc.com header.s=dkim.wdc.com header.b="gfW3hq/s"; 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 r12-v6si917690plo.269.2018.10.02.12.15.21; Tue, 02 Oct 2018 12:15:36 -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="gfW3hq/s"; 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 S1727969AbeJCCAC (ORCPT + 99 others); Tue, 2 Oct 2018 22:00:02 -0400 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:42347 "EHLO esa6.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727614AbeJCCAA (ORCPT ); Tue, 2 Oct 2018 22:00:00 -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=1538507710; x=1570043710; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=IWxrMPP8QxU5skWTKS1CuDJnhG9N0HHk6Ifj0AfIiZA=; b=gfW3hq/sRoWl9lV8L1sceRkSyXA4afKbd6n7rriih68Bg+wN5gkUZe3y cYav0xaSZppGPAQieA3t6TIchhXvjrxS8ljI9V8owmmpH75N1UcDb2xH3 7iq1QaU5eKBtI70OETKgIDxLC5z9XmesyU+eYmhVnsBnkG7UWKLr/+q5T 8Dnwxs+Y5SObmojbHFgnWx8+d5/oCWQe/U0NPI23UXJl6CReCr2uV3sD9 nw5U6ZC/uylBMf5mizEBY9BdZFstCDvGFlCCW1IBXg6j/nGmXbbjJWpte xvuaKJgfzHdq5V0HP5EvOiVGyws//g/NfccGFO6DPyp8RPEU/dIVN9/hy A==; X-IronPort-AV: E=Sophos;i="5.54,332,1534780800"; d="scan'208";a="92732899" Received: from uls-op-cesaip01.wdc.com (HELO uls-op-cesaep01.wdc.com) ([199.255.45.14]) by ob1.hgst.iphmx.com with ESMTP; 03 Oct 2018 03:15:10 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep01.wdc.com with ESMTP; 02 Oct 2018 12:00:50 -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; 02 Oct 2018 12:15:10 -0700 From: Atish Patra To: linux-riscv@lists.infradead.org, palmer@sifive.com Cc: anup@brainfault.org, hch@infradead.org, linux-kernel@vger.kernel.org, atish.patra@wdc.com Subject: [PATCH v6 05/14] RISC-V: Disable preemption before enabling interrupts Date: Tue, 2 Oct 2018 12:14:58 -0700 Message-Id: <1538507707-22299-6-git-send-email-atish.patra@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538507707-22299-1-git-send-email-atish.patra@wdc.com> References: <1538507707-22299-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