From patchwork Mon Oct 23 08:29:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Lu X-Patchwork-Id: 156740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp1151253vqx; Mon, 23 Oct 2023 01:31:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu4DypgI4CFIaGl8dxdSVysHi7JnrYb5LXZNog2cRj7D/HrMBsEtCc2X3Hez7aCjV12Z1Q X-Received: by 2002:a05:6a00:939a:b0:68a:586a:f62 with SMTP id ka26-20020a056a00939a00b0068a586a0f62mr7478134pfb.4.1698049895349; Mon, 23 Oct 2023 01:31:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698049895; cv=none; d=google.com; s=arc-20160816; b=qckXnS9EcC5maOM9MBJse2mukO0FBDR+4t0rSjlLTkbhuEkP+m2aKEcxDCE2sbuCSw kWjRm0fnVcSPlcjnTtGzZ+Yw3d64UsW58hnhfF7JlNmBy53AFYf+D+hRsSx8WBMQWOTU HbWyOtHOps7RtlWuu/4nQmvOdhJaOnrkUI54ZCujb7s4POPKPELMo9CisjPmMlnyVQo8 9/Fsm40v/TBhOhz0bpIAJ1tF3fAzDTwYjN29A9LuDsgZ8BgwrqJ0rg6MDVNGBtTzN8LC fa9gQwaPQMA7gGEoYrUd3GVLPeFR83jKVjy+TnGWP8MCARmlXkRfBRyOGN4TcJqemwNQ s12Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tFjJUDD1OgrURVFCNfyqhpsKd5+0kFPMkXoyM2g55XE=; fh=O4eOVhHjKTyaSORSQqoF+Vv6GYDagG+8LotEUwhRqvg=; b=BH09iC9X4uC3TRWVFVMx0rdhxdPkqkQGugMbl6GyvjMv0wtkSfxy19siBjQkZFIJ/U /5bZn8sHOZpUidEwh/tVBjVEmktXHZJsT056C1Vyr+WkT8TqMSUUww8LRYeENf4eeY0F OthuSKGW6vy8hyc9J9jqUFB3l5nuQ1zwST/U9sdX6remGvZn6/AwOOq5O3YWClQHsDoK mf6a7ZWBV9LvUI2ZX/+2q0WEwh212h2pNlnWneYHtA97cRRQNFFl/TwZQmSJRSy41raf Ds3C/UEwh3YEYbeZtpsNiB29APwSl8Yaa5VwSh80rD0nI9QeJYjK8dXXA1ZfCFuNgiXt uoNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kACoJMEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p28-20020a056a000a1c00b0068e37843a1bsi6197946pfh.162.2023.10.23.01.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 01:31:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=kACoJMEK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 880B3809B9C0; Mon, 23 Oct 2023 01:31:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233206AbjJWIaw (ORCPT + 26 others); Mon, 23 Oct 2023 04:30:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233145AbjJWIaf (ORCPT ); Mon, 23 Oct 2023 04:30:35 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58A4188 for ; Mon, 23 Oct 2023 01:30:07 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1c9e072472bso18124415ad.2 for ; Mon, 23 Oct 2023 01:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1698049806; x=1698654606; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tFjJUDD1OgrURVFCNfyqhpsKd5+0kFPMkXoyM2g55XE=; b=kACoJMEKjIPMrZ4Kknmviad8kSSliwgMgQYkJPgoxtR6vhlBtJJA6uZN+aHqgK2p+L 2QsN5+EsN/32NDecwdcuhWQfc39gw7samaX1KHnKlYMvVcz2ikw4fiMrdPt1dayKlxoQ uB1QTi/siS4x0+kubKEsBJF1mcPh/faReofT3PNNCO7T6CFUjvcT+gH5quZAEm28omiP nnw0H4yOBkvHz4q7/9nK+FhnExrxz7Ijh8VP4Iy2AJkHY+VdvaJu4tXFvdhEFgeHZi9o blgFvnwKOT8piy4+YxB4/0YY60Jg96rPt+XufaRWmb/PU9+ZhE9jcnWMEvDtOqHAJGt5 Hc4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698049806; x=1698654606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tFjJUDD1OgrURVFCNfyqhpsKd5+0kFPMkXoyM2g55XE=; b=csy5dY4RkgYOwAhuMdFElYp38jVRDLhIz8pZvfuTMheMaRzGrGIVIiMrtQy0Mn1+In o41I0WK64Ad8TIAFc0bJj9zlhWItvl1xnPnCmfk6Lc1ILWKfFcGHVxTMLXn0T6lrHpEG +NWU7LuUcp6rk6FKYEqTOzYd13Jo8nOF/AXHoiQGiXAyz3J4JM1/Ea5gF2qpNyzSXRtK t+4eoI2vC85f4BZQmkuXMNb7LYJxLa4IMK+2JJuhqH10S5hxGuNxiueBzrTObF2BxF8p Ysg7HqUNoTT9EXmrUfP2FZaGEWxtOy3wJvliRTx9UFjMmXVVbBFI7W3AykUdXjKsAvJ6 ifZg== X-Gm-Message-State: AOJu0YzUsagKoOuHjYmi0uXjXuH84t0/vP30oaOIPm1bepkF7IBCdEya +WdHsXzyIIgMlin7CwUoU79MO9yZcs6BknaKPp0= X-Received: by 2002:a17:902:ecc6:b0:1c9:cc41:76e4 with SMTP id a6-20020a170902ecc600b001c9cc4176e4mr5988168plh.10.1698049806521; Mon, 23 Oct 2023 01:30:06 -0700 (PDT) Received: from J9GPGXL7NT.bytedance.net ([203.208.167.147]) by smtp.gmail.com with ESMTPSA id d15-20020a170903230f00b001b8b07bc600sm5415805plh.186.2023.10.23.01.30.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 23 Oct 2023 01:30:06 -0700 (PDT) From: Xu Lu To: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, tglx@linutronix.de, maz@kernel.org, anup@brainfault.org, atishp@atishpatra.org Cc: dengliang.1214@bytedance.com, liyu.yukiteru@bytedance.com, sunjiadong.lff@bytedance.com, xieyongji@bytedance.com, lihangjing@bytedance.com, chaiwen.cc@bytedance.com, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Xu Lu Subject: [RFC 08/12] riscv: Enable NMIs during irqs disabled context Date: Mon, 23 Oct 2023 16:29:07 +0800 Message-Id: <20231023082911.23242-9-luxu.kernel@bytedance.com> X-Mailer: git-send-email 2.39.3 (Apple Git-145) In-Reply-To: <20231023082911.23242-1-luxu.kernel@bytedance.com> References: <20231023082911.23242-1-luxu.kernel@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 23 Oct 2023 01:31:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780534366866219898 X-GMAIL-MSGID: 1780534366866219898 This commit allows NMIs to happen even when irqs are disabled. When disabling irqs, we mask all normal irqs via clearing corresponding bits in CSR_IE while leaving NMI bits alone. Signed-off-by: Xu Lu --- arch/riscv/include/asm/irqflags.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h index 9700a17a003a..42f7803582df 100644 --- a/arch/riscv/include/asm/irqflags.h +++ b/arch/riscv/include/asm/irqflags.h @@ -54,13 +54,13 @@ static inline void arch_local_irq_enable(void) /* unconditionally disable interrupts */ static inline void arch_local_irq_disable(void) { - csr_clear(CSR_IE, irqs_enabled_ie); + csr_clear(CSR_IE, ~ALLOWED_NMI_MASK); } /* get status and disable interrupts */ static inline unsigned long arch_local_irq_save(void) { - return csr_read_clear(CSR_IE, irqs_enabled_ie); + return csr_read_clear(CSR_IE, ~ALLOWED_NMI_MASK); } /* test flags */