From nobody Fri Dec 19 13:27:49 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=yeah.net ARC-Seal: i=1; a=rsa-sha256; t=1753362871; cv=none; d=zohomail.com; s=zohoarc; b=hMVy4Gvx205LQIoACQli9ydWcOI3AaD1eqt5U0AZRbRRdo16CpmN0L8Sv+wt5mG4dmVkx66IQKQ4vdIq99YhzMd3jmWwux+RH2Ps15bHQEK+4EYib7FTNIEq3f95WdSdAS+BtqfnQ2ed+8nhoawmLSQ19pWkn64vgjI8cbdPTKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753362871; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=U+bEyJCRkOOjW2WuDRHjgnixsRl5GRu1j6nn0Pr0hMQ=; b=I/eu8ateFXwG4HxgBENL2zcaoqIo9c8/09r6hgFlU60xyjqAHYeT5nCGrktu3Y4tpESc67Nl9WegTUtdfW5TpWOyRHmJn0e7siHk+hybpIp5kgdNyk+ulI1FynSIM883JwqnniCNn+g3Aoq3xVErANJ9A8KA24QjGOPqGoblVEU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1753362871449908.2806865196263; Thu, 24 Jul 2025 06:14:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uevlY-0002lC-5z; Thu, 24 Jul 2025 09:13:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uesXI-0000OR-JY; Thu, 24 Jul 2025 05:46:48 -0400 Received: from mail-m16.yeah.net ([1.95.21.14]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uesX9-0008DS-5m; Thu, 24 Jul 2025 05:46:47 -0400 Received: from vcore-181.. (unknown []) by gzsmtp1 (Coremail) with SMTP id Mc8vCgD3P93kAIJoQlVNAQ--.8853S2; Thu, 24 Jul 2025 17:46:14 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yeah.net; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=U+ bEyJCRkOOjW2WuDRHjgnixsRl5GRu1j6nn0Pr0hMQ=; b=GE0QmRhyvM7c7TtqMd JzZLTxVNsB/soA6HyzTYo5Bqgh3Mh/h/zcN5fZ/UwLEPI7ltatX451bU2Gap5+5k 8A4ft0YL266FnT6v+syKQkTvq4hHp3r/QohGj/+Gn7APRLAaU/DPipD8Q+UVW+s0 YhBDAtSG8amL4CwAhnDXT1z+A= From: Yang Jialong To: Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei Cc: yangjialong@rvcore.com, Yang Jialong , qemu-riscv@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v1] intc/riscv_aplic: Fix target register read when source is inactive Date: Thu, 24 Jul 2025 17:34:26 +0800 Message-Id: <20250724093426.4179617-1-z_bajeer@yeah.net> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: Mc8vCgD3P93kAIJoQlVNAQ--.8853S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Kr4UAFy3ZFWDKF18AFWDArb_yoW8JFW5pr s3GFsIvrs8tF1UGa1kJr18XF4UGr98Wr98ur1DuryIkwsxtw4FgrykK345Zr48CFy5Cr1Y vFZ0kr13CF4jv3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UeBT5UUUUU= X-Originating-IP: [103.233.53.226] X-CM-SenderInfo: p2betyxhhuq5hhdkh0dhw/1tbiNQbzF2iCAOb+RQAA3g Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=1.95.21.14; envelope-from=z_bajeer@yeah.net; helo=mail-m16.yeah.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 24 Jul 2025 09:13:42 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yeah.net) X-ZM-MESSAGEID: 1753362872859116600 Content-Type: text/plain; charset="utf-8" The RISC-V Advanced interrupt Architecture: 4.5.16. Interrupt targets: If interrupt source i is inactive in this domain, register target[i] is read-only zero. Signed-off-by: Yang Jialong --- hw/intc/riscv_aplic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c index 4fa5f75..cfef69f 100644 --- a/hw/intc/riscv_aplic.c +++ b/hw/intc/riscv_aplic.c @@ -628,7 +628,7 @@ static void riscv_aplic_request(void *opaque, int irq, = int level) =20 static uint64_t riscv_aplic_read(void *opaque, hwaddr addr, unsigned size) { - uint32_t irq, word, idc; + uint32_t irq, word, idc, sm; RISCVAPLICState *aplic =3D opaque; =20 /* Reads must be 4 byte words */ @@ -696,6 +696,10 @@ static uint64_t riscv_aplic_read(void *opaque, hwaddr = addr, unsigned size) } else if ((APLIC_TARGET_BASE <=3D addr) && (addr < (APLIC_TARGET_BASE + (aplic->num_irqs - 1) * 4))) { irq =3D ((addr - APLIC_TARGET_BASE) >> 2) + 1; + sm =3D aplic->sourcecfg[irq] * APLIC_SOURCECFG_SM_MASK; + if (sm =3D=3D APLIC_SOURCECFG_SM_INACTIVE) { + return 0; + } return aplic->target[irq]; } else if (!aplic->msimode && (APLIC_IDC_BASE <=3D addr) && (addr < (APLIC_IDC_BASE + aplic->num_harts * APLIC_IDC_SIZE)))= { --=20 2.34.1