From patchwork Wed May 15 06:15:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng Yang X-Patchwork-Id: 1935268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=JoI0X8Zw; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=foxmail.com header.i=@foxmail.com header.a=rsa-sha256 header.s=s201512 header.b=DKeaDRNG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VfNKl4CBnz1ymw for ; Wed, 15 May 2024 16:16:59 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Date:Subject:Cc:To:From: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=htP0G5X4yY4/wx8lTxL1QoHDmndLjSlVGwHrRlXFJ7E=; b=JoI0X8ZwgiTyya YDDyZmxTq+4aAIABMy0HL5n66DPYd1K56ummW1E7kKi+9aj4POW4g3AYigLYTZ9Diw/35qKVi5Y0x 98or6gy9WZvJFjpTd6DZAZ4ydA3gB7zyau4WxbPJ0zt8MkhGcvkDyCu7r1+ddusbKUUQYBB60x88O opjrttx0GnwYHiJWncEY8Yg1hh3oImc/uY1LWNpMidKQvkEsqmXoZVVd+WNz3KFzHKo7oUzMv3bo4 gvFc8e/vn3lLENkMts+afO6TO9xkUto5rHpKmkeI+bT6kSII2JutAMwVd2pZi0TA4NFp9laiBPha8 s4g79o/ImRUa0HBT5smw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s77wX-00000000cs5-3BHy; Wed, 15 May 2024 06:16:49 +0000 Received: from out203-205-221-235.mail.qq.com ([203.205.221.235]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s77wT-00000000crM-2l6B for opensbi@lists.infradead.org; Wed, 15 May 2024 06:16:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715753797; bh=vPCbSwC+83u5cSbj4gGpwWHLmx0tlNbvDJgfTWtEA74=; h=From:To:Cc:Subject:Date; b=DKeaDRNG3lMTYKWOSMlDxJrJVvNx/wuDJoSK01PedS68NChxCG5aPXL5crRSb/y2I d2agE9oeyt9TKQ9/hY1sx1bg6gcC4QbgZV3mhS9kxZnB43YxudBqMCs65a5wTXtIv5 1+dtQ8Ef6vkUwFrCr2CJzJKnOAVIYuGx5UaSPuYI= Received: from yc-home.taila82bd.ts.net ([2409:8a62:e77:7780:34ff:2448:e498:8027]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id 42403CF3; Wed, 15 May 2024 14:16:36 +0800 X-QQ-mid: xmsmtpt1715753796t6f9op4su Message-ID: X-QQ-XMAILINFO: NC/J3CrDtaBbI7wgjNgBDrPOdak9yX6G+JrScFMbzycY/E9RdEeKs+oRBdca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3WW+NvGbIU= From: Cheng Yang To: opensbi@lists.infradead.org Cc: wxjstz@126.com, anup@brainfault.org, Cheng Yang Subject: [PATCH v6] lib:utils:irqchip: Check before initializing imsic. Date: Wed, 15 May 2024 14:15:14 +0800 X-OQ-MSGID: <20240515061513.735932-1-yangcheng.work@foxmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240514_231646_157756_D33275EB X-CRM114-Status: GOOD ( 11.40 ) X-Spam-Score: 3.4 (+++) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The current mlevel imsic check is only for the platform, which may cause hart without imsic in the platform to trigger an illegal instruction exception when initializing imsic. For example, the platfo [...] Content analysis details: (3.4 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [203.205.221.235 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [yangcheng.work(at)foxmail.com] 0.4 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS 3.2 HELO_DYNAMIC_IPADDR Relay HELO'd using suspicious hostname (IP addr 1) X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org The current mlevel imsic check is only for the platform, which may cause hart without imsic in the platform to trigger an illegal instruction exception when initializing imsic. For example, the platform contains a management hart that only supports wired interrupts. This patch will check if each hart supports Smaia extension before doing imsic initialization to avoid triggering illegal instruction exceptions. Signed-off-by: Cheng Yang Changes V5 -> V6: - Use csr_read_allowed instead of bitmap to simplify checking if hart supports Imsic, suggestion from Anup. Changes V4 -> V5: - Fixed the issue where patch cannot be applied due to the editor automatically removing trailing spaces. Changes V3 -> V4: - Rebase to the latest master branch. Changes V2 -> V3: - Trailing whitespace. - Replace platform.hart_index2id to generic_hart_index2id. Changes V1 -> V2: - Add the processing of plat->hart_index2id be NULL in fdt_check_imsic_mlevel. Reviewed-by: Anup Patel --- lib/utils/irqchip/imsic.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/utils/irqchip/imsic.c b/lib/utils/irqchip/imsic.c index f2a35c6..fad1beb 100644 --- a/lib/utils/irqchip/imsic.c +++ b/lib/utils/irqchip/imsic.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -222,6 +223,7 @@ static void imsic_local_eix_update(unsigned long base_id, void imsic_local_irqchip_init(void) { + struct sbi_trap_info trap = { 0 }; /* * This function is expected to be called from: * 1) nascent_init() platform callback which is called @@ -231,6 +233,11 @@ void imsic_local_irqchip_init(void) * in boot-up path. */ + /* If Smaia not available then do nothing */ + csr_read_allowed(CSR_MTOPI, (ulong)&trap); + if (trap.cause) + return; + /* Setup threshold to allow all enabled interrupts */ imsic_csr_write(IMSIC_EITHRESHOLD, IMSIC_ENABLE_EITHRESHOLD);