Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6137100ybv; Tue, 18 Feb 2020 10:37:40 -0800 (PST) X-Google-Smtp-Source: APXvYqyJhOpeSye4E1sUEMHYGVz0PaI1C6zHYV06ccDYtnHMzD/DfFEy2dvBYchT5sSqFRq3/Zcb X-Received: by 2002:aca:4b46:: with SMTP id y67mr2009505oia.122.1582051060493; Tue, 18 Feb 2020 10:37:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582051060; cv=none; d=google.com; s=arc-20160816; b=kbzuUouy1vqBavOKodQq0rCJflRnMdzNuZgpg9LJL7VOjAlFPA+fFSVEfYO778luRl stsf8A/F4C6iOpFuEb1BFGzN7n+gEVDxOje26MjMj371hgeYs7tGFqh4bEyUvGKQeCKi Hs4TFa8rfP1Lqrfn3bH1WtpPzXcMGKtFxtR0891KCWfi+hyve2ovJVTa4dzgjWs80Tfv ETcnqfkX6+razfC72SPLJS8WTgmX0UZzCvfIQp3Ahg6KrDSvSPtpfILQTFFOZarnGgN0 5H+U/CMk4coqmKG1UCxaGvwl3U4seAGmf+va9IN/qIPNAd7p4Y6XnvGLYkwQXLmNXV78 vNlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=deSq0a14rSLUpPG1ENh74nUw4fh0dIpGPEl5kTUgrmw=; b=fruksG1BW6tDKofwBWV/5a8rDDbYZ+AO9lg0Acm2gf1J7N8g1tYrNGNh1Je4IZwXtS aFIBqsR30UWFQmwakIaMuKn8xEuRhXer8FJIHAY6c6wFYgSioqHwKtOMWH9NHxkwNbkG dogrbWEptJJz0pkd1xUSoksKonkQ4bO034ccQeN4SqBvIXctDk/WtWGVQ3c0cMvcfNsI Zc5q7qRpQlFrtEuffGgzHDJwQ2czWEIbblgcec31PrqVLyI7JC0QB38VCfbsjApxOX5z lrjtQwZ0Otxp5suxbGLlDcdaTW+atUhzR/rx1yEfF3REX3mHK/XNT6TxonJrcH5MBBrg HbxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=omEsIjt8; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 24si7565243oip.248.2020.02.18.10.37.28; Tue, 18 Feb 2020 10:37:40 -0800 (PST) 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=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=omEsIjt8; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726422AbgBRSg3 (ORCPT + 99 others); Tue, 18 Feb 2020 13:36:29 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:40585 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbgBRSg3 (ORCPT ); Tue, 18 Feb 2020 13:36:29 -0500 Received: by mail-pl1-f196.google.com with SMTP id y1so8410715plp.7 for ; Tue, 18 Feb 2020 10:36:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=deSq0a14rSLUpPG1ENh74nUw4fh0dIpGPEl5kTUgrmw=; b=omEsIjt8aCcWfGTycR646o4RZaZaKMTiWee69L+h8Fll5DulpeCtdxPisOy8v0kvAM vu/2SlirKz3PFVgerQ+7mQNQVxEZgmSX+NtbNS8r1crMliYrPxUePrcoxH4zF2g3BuaO nefp+B1sAzPMdwKqxU82rlYdguWXyDAiEMndG+3ZRotaL7i8NbwThMLyeQs/ab6AZPXC 506Ja+fL4Mqd1QNcEv6tcQhkhQ5JPNrVVmaNgG/Y6C6Q8033tQlpfDVvMg7Z9mnJLpgy dPMIiQPP6tjBmYU2cZ34bUrQB9figgSStewo8Mg6Cq+4r0QneW73BkVzmlIbsvSffU6W hWDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=deSq0a14rSLUpPG1ENh74nUw4fh0dIpGPEl5kTUgrmw=; b=C1UrmkbOZEN6eXSQ00X5eIqPrfnmeBKNZXk5RQFOxVTaGk7/0d++LFhO6XN90CvYBB rUr2P1FSB2YwL2NY8XNd+TVXIosmHj4Z5pUojgk4/ieyLiVmaom9Th5rOlHB97la/019 zDzPRNvXSuzCagWWws1yvfmnfTa8IQhJbyjKG1JKY3Hj2Jcj8pse1EEli6noNqVywV35 2LeoaNLz/J5hyrVM1dZ9P/5NZDJPNPjFoiuYqsEp+Fab/jWDzTctNQdSfP8vkkEXSwnl NVjSpmTBaddO3lot6rceAYuenZmerKQtSrhw3aDtsFBW4OfbyTOq2SvEs4VfKHED943Z haUg== X-Gm-Message-State: APjAAAVq/wy1+vylewC1ALyvnAVBbqJku9jmhq5k6wsBc5AmXwvOFyMq t0+McU3MvXItQnWQbfQzWDpjgA== X-Received: by 2002:a17:902:426:: with SMTP id 35mr21802232ple.176.1582050988323; Tue, 18 Feb 2020 10:36:28 -0800 (PST) Received: from localhost ([2620:0:1000:2514:23a5:d584:6a92:3e3c]) by smtp.gmail.com with ESMTPSA id z10sm5664511pgf.35.2020.02.18.10.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Feb 2020 10:36:27 -0800 (PST) Date: Tue, 18 Feb 2020 10:36:27 -0800 (PST) X-Google-Original-Date: Tue, 18 Feb 2020 10:36:25 PST (-0800) Subject: Re: [PATCH] RISC-V: Don't enable all interrupts in trap_init() In-Reply-To: CC: Anup Patel , Paul Walmsley , Damien Le Moal , anup@brainfault.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Atish Patra , Alistair Francis , linux-riscv@lists.infradead.org, Christoph Hellwig From: Palmer Dabbelt To: atishp@atishpatra.org Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 02 Feb 2020 03:48:18 PST (-0800), atishp@atishpatra.org wrote: > On Sun, Feb 2, 2020 at 3:06 AM Anup Patel wrote: >> >> Historically, we have been enabling all interrupts for each >> HART in trap_init(). Ideally, we should only enable M-mode >> interrupts for M-mode kernel and S-mode interrupts for S-mode >> kernel in trap_init(). >> >> Currently, we get suprious S-mode interrupts on Kendryte K210 >> board running M-mode NO-MMU kernel because we are enabling all >> interrupts in trap_init(). To fix this, we only enable software >> and external interrupt in trap_init(). In future, trap_init() >> will only enable software interrupt and PLIC driver will enable >> external interrupt using CPU notifiers. I think we should add a proper interrupt controller driver for the per-hart interrupt controllers, as doing this within the other drivers is ugly -- for example, there's no reason an MMIO timer or interrupt controller driver should be toggling these bits. >> Cc: stable@vger.kernel.org >> Fixes: 76d2a0493a17 ("RISC-V: Init and Halt Code) I'd argue this actually fixes the M-mode stuff, since that's the first place this issue shows up. I've queued this with Fixes: a4c3733d32a7 ("riscv: abstract out CSR names for supervisor vs machine mode") instead, as that's the first commit that will actually write to MIE and therefor the first commit that will actually exhibit bad behavior. It also has the advantage of making the patch apply on older trees, which should make life easier for the stable folks. >> Signed-off-by: Anup Patel >> --- >> arch/riscv/kernel/traps.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c >> index f4cad5163bf2..ffb3d94bf0cc 100644 >> --- a/arch/riscv/kernel/traps.c >> +++ b/arch/riscv/kernel/traps.c >> @@ -156,6 +156,6 @@ void __init trap_init(void) >> csr_write(CSR_SCRATCH, 0); >> /* Set the exception vector address */ >> csr_write(CSR_TVEC, &handle_exception); >> - /* Enable all interrupts */ >> - csr_write(CSR_IE, -1); >> + /* Enable interrupts */ >> + csr_write(CSR_IE, IE_SIE | IE_EIE); >> } >> -- >> 2.17.1 >> >> > > Looks good. > Reviewed-by: Atish Patra Tested-by: Palmer Dabbelt [QMEU virt machine with SMP] Reviewed-by: Palmer Dabbelt I consider this a bugfix, so I'm targeting it for RCs. It's on fixes and should go up this week. Thanks!