From nobody Sat Dec 21 15:47:19 2024 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=syntacore.com ARC-Seal: i=1; a=rsa-sha256; t=1726668253; cv=none; d=zohomail.com; s=zohoarc; b=gbSWoqJTxWGhFek3b2HG+QC+y/w/gQAqQbmgD+ioboINNFUaTTC/eshflw/0UlEvqbypIFLW7akz2tfM3qj/Xw79jNzcWwAD01zMZ2elth1sS3OHNokkM0utO4opwqz82Ggk1US4QYpGoOnrWCMQwyBCnbP9oObqpP8SnUWtnYI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726668253; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5W/qhfnBCdxvMNbbU8sTMOE6s1XNy+wv4Jmtt9p3OhQ=; b=jk3u3iPk2PVWpbj5OdFsrDBVhjD+yeQqwYD3jmCecNp6MHJeRimHHoUdvnf/I18LBRqkmY0tGVXTrQYlS4ugMtz3rPAp6rJpVDoZN2rn9hdFZe57Rfh+jVXGESwtRkCQv/2bYq+QZdlgMHB0DA66J2w460yAh2nI3WLRNiM6+Vc= 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 1726668253363288.3879085783443; Wed, 18 Sep 2024 07:04:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqvGw-0003HH-H7; Wed, 18 Sep 2024 10:03:10 -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 1sqvGm-0002yP-0l; Wed, 18 Sep 2024 10:03:00 -0400 Received: from mta-04.yadro.com ([89.207.88.248]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqvGk-0002b5-2B; Wed, 18 Sep 2024 10:02:59 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 93970C0002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1726668175; bh=5W/qhfnBCdxvMNbbU8sTMOE6s1XNy+wv4Jmtt9p3OhQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=o2I9OWGlRPvWFrwoJ3l2U4shDBdhHvKfOBH6RJ6wCrYHR/qh4daX12QVEroJvZGg7 Rs/jL2Elhc79PKq+Du5E4u+DE3TrpYJZwLPUcJgAkIUb/tPGrbGpP1nNc3AcnJgm7S fh9DIdv0FUMXR36hu18aKrppq1zlQAHz/Mdc2kXNgkNbavrhcxNMeIE8Rpej+eZ6P1 bMjdbS6Teu1H6J64mAuVe1hMQS+pT6PeUXWreuyJyuhQd6Fl3at7rmNgoqYlGevdAb 23pyX3NJqcqw5nqQCuCLM8k/sVfYYCozos7H2hlr87G/g1lD2/+bSSp6D2zljTlQYZ EftoiFzZE71ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1726668175; bh=5W/qhfnBCdxvMNbbU8sTMOE6s1XNy+wv4Jmtt9p3OhQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=iApSwrVc5Ue/6Wrw3SgaZFcsxNGeLBeRjNRUXoiwChujX90C1qPBpPCgJLedq5sd8 eFzMdO4nSi5ek94g6WUtHjWtcTSDnR9tueocZeq81OEEsQ+YG2j++OZ3CiwRnhV7JF ahFhS75A2OoCXtamZDD5ke3mI+mKqTo/jhy2WJEDlPq9ZSXc63FmszBVLNhr/BC7aC ob1FXcwi6DrzzO88RR+4hTu5BEljagMaOgNm5aFlLL2Q/k+yC25JxBVCYfHxJVcqk8 lQ2FRRPpDo4tBXhkj8Ux119gYyZfBWzlwhwPZ1rC8bzAPZ9X57/H+QWd7vhoNCKljN AZ5Dc2NuH6Sgg== From: Sergey Makarov To: CC: , , , , Subject: [PATCH 1/2] hw/intc: Make zeroth priority register read-only Date: Wed, 18 Sep 2024 17:02:28 +0300 Message-ID: <20240918140229.124329-2-s.makarov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918140229.124329-1-s.makarov@syntacore.com> References: <20240918140229.124329-1-s.makarov@syntacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To T-EXCH-12.corp.yadro.com (172.17.11.143) 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: permerror client-ip=89.207.88.248; envelope-from=s.makarov@syntacore.com; helo=mta-04.yadro.com 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @syntacore.com) (identity @syntacore.com) X-ZM-MESSAGEID: 1726668253554116600 Content-Type: text/plain; charset="utf-8" According to PLIC specification chapter 4, zeroth priority register is reserved. Discard writes to this register. Signed-off-by: Sergey Makarov Reviewed-by: Alistair Francis --- hw/intc/sifive_plic.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index e559f11805..3f3ee96ebc 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -189,8 +189,13 @@ static void sifive_plic_write(void *opaque, hwaddr add= r, uint64_t value, =20 if (addr_between(addr, plic->priority_base, plic->num_sources << 2)) { uint32_t irq =3D (addr - plic->priority_base) >> 2; - - if (((plic->num_priorities + 1) & plic->num_priorities) =3D=3D 0) { + if (irq =3D=3D 0) { + /* IRQ 0 source prioority is reserved */ + qemu_log_mask(LOG_GUEST_ERROR, + "%s: Invalid source priority write 0x%" + HWADDR_PRIx "\n", __func__, addr); + return; + } else if (((plic->num_priorities + 1) & plic->num_priorities) =3D= =3D 0) { /* * if "num_priorities + 1" is power-of-2, make each register b= it of * interrupt priority WARL (Write-Any-Read-Legal). Just filter --=20 2.34.1 From nobody Sat Dec 21 15:47:19 2024 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=syntacore.com ARC-Seal: i=1; a=rsa-sha256; t=1726668249; cv=none; d=zohomail.com; s=zohoarc; b=h7c4eJW4yp+lnAg/CI7N7ISjlQJ6RX3PMlgQaO/Fb9oj2Q+EhIvvtVGD+3dgj9vBXFLphrzwcapc8NAY9hiNvEZzlM7z8Mndbsi2iFTmJGUDc38G/ia7+SYu67ECCkoJ7NF65m/4NtEC+5nuZ9YSRtJ3MYOieulAOQ2+f/Pdy0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726668249; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Y7u+ZYWkETAKlOCWN/jUACcmbj4sINmDqk7xJHoZJoI=; b=ACzAEsLC2XI2uk9PXuzUzPpa+ugiXpoltpsi2wqd/3YGXKPlXt/eLNpydKFPS73Sjtofifr69BsKz2kj6Ze6MHUGuSPQsubW33Bnh1NWCTjgHHZq2LudJdP8k8ZcqOOQ+3pSP1DIRJVdaXFpCji2gwEhLBiam/thNe7SFm5KY4k= 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 172666824936521.14077093700223; Wed, 18 Sep 2024 07:04:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqvGt-0003AO-Tq; Wed, 18 Sep 2024 10:03:09 -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 1sqvGo-0002zy-Cd; Wed, 18 Sep 2024 10:03:02 -0400 Received: from mta-04.yadro.com ([89.207.88.248]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sqvGk-0002b7-1z; Wed, 18 Sep 2024 10:03:00 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 26841C0002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1726668176; bh=Y7u+ZYWkETAKlOCWN/jUACcmbj4sINmDqk7xJHoZJoI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=n8vvmFM71BYbFnY4mRI5ctBOMRZSDBNfSjFYiJC8Wsvt0gZKyuuMdVK7jlkjqAt6K 5QuWa2oQ9UXTBSefKh2C+6kL/GahnnsrjjOgFggPbDPKNltIj+oWZleI8b/lCtJNqF WLklvOkIyvt5GhF1HbpbMocrcx7WxDfQgkpqDX3Fi3k0DI3LFTPeatwEvGRrWJ7wFt EBqMojRYEZuhzGve0roWurdGA1vvCqLTF1PFJumxW3leznI7Ob9IYt/uz0NQFCcp5O LFSlZyY4w03oLGjv1rcmePoUdGdifgFOaKdRc04fnH5o9ZQNbbI+XGqJFqZR95hMR/ eS09xNcTG3FEQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1726668176; bh=Y7u+ZYWkETAKlOCWN/jUACcmbj4sINmDqk7xJHoZJoI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=vWjPTy78Vm3sRvLI+RnVsqnPXBYZP6eWK30ZMZRLrcf8pfjl3xh/dsZepSVDO2UUo E6zRZe3CkW+tQ2axqNeDi8P+EjMaxmFkey+2SqFY9P/SNkWA8zamWe+bDO7X2ZBwZQ ijAfUDe1Pp3LV2h5VFkifj34peyDZVimZYGnZm/KYI/XRoWEgwy0iaXrIAgO8pdYHf K69M88DYK9hHZjZfaYz8bwjenzhwFlJO9c5boU2W/300tJWRuK5S/A1r8Df3/192VQ vR9ARQX25NUR8ffzT5KLmFRaslF7ut8JAwTNUBnEsJXOMBSs/k60mpxt9XMuMK+/D7 FYNcbLhQX0EZw== From: Sergey Makarov To: CC: , , , , Subject: [PATCH 2/2] hw/intc: Don't clear pending bits on IRQ lowering Date: Wed, 18 Sep 2024 17:02:29 +0300 Message-ID: <20240918140229.124329-3-s.makarov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918140229.124329-1-s.makarov@syntacore.com> References: <20240918140229.124329-1-s.makarov@syntacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: T-Exch-05.corp.yadro.com (172.17.10.109) To T-EXCH-12.corp.yadro.com (172.17.11.143) 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: permerror client-ip=89.207.88.248; envelope-from=s.makarov@syntacore.com; helo=mta-04.yadro.com 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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @syntacore.com) (identity @syntacore.com) X-ZM-MESSAGEID: 1726668252318116600 Content-Type: text/plain; charset="utf-8" According to PLIC specification (chapter 5), there is only one case, when interrupt is claimed. Fix PLIC controller to match this behavior. Signed-off-by: Sergey Makarov Reviewed-by: Alistair Francis --- hw/intc/sifive_plic.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index 3f3ee96ebc..deec162630 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -354,8 +354,10 @@ static void sifive_plic_irq_request(void *opaque, int = irq, int level) { SiFivePLICState *s =3D opaque; =20 - sifive_plic_set_pending(s, irq, level > 0); - sifive_plic_update(s); + if (level > 0) { + sifive_plic_set_pending(s, irq, true); + sifive_plic_update(s); + } } =20 static void sifive_plic_realize(DeviceState *dev, Error **errp) --=20 2.34.1