From nobody Sun Nov 24 05:57:27 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=1726093823; cv=none; d=zohomail.com; s=zohoarc; b=C8f9QDZoD8mLD4LKXktp4XskBeWy1bX36+FZOC5ogl6W2eCvLH/hP3Klbnj2hZ1SDfqDifCWn7C/R7kw5WeULLArLJr1Nj7/TO4d76PynSrI2+M0ik7YZ87p63Dl7MwyChSAz/K+JNDFlM1I7vqwxWTC3DWkdvTHl5p3s9LlVvE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726093823; 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=HodUyr/hp+rg3csF91JqL92UKhyvVqqksCFoAO8/IwLPHn+SSURqZze/Yt4aGOKzghb4Ucgi+qFa4lR+ZKXLMn5pRbhm5Dab09H9w6kmQ5E7m+XYrk2TIddvSjguCdCzcBAjq+wYpW242CT2ArBqgsB8TqScdHqUXduW6ovesHs= 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 1726093823316915.3277852698855; Wed, 11 Sep 2024 15:30:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soVqW-0000rc-Ey; Wed, 11 Sep 2024 18:30:00 -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 1soP5e-0006CM-7j; Wed, 11 Sep 2024 11:17:16 -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 1soP5b-0001cv-Je; Wed, 11 Sep 2024 11:17:05 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com 43338C0002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1726060771; bh=5W/qhfnBCdxvMNbbU8sTMOE6s1XNy+wv4Jmtt9p3OhQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=uxY21CBPxcLYkwTy1eDcWbp1tEINTCptHYyzTA/yYDEDUoWFfSnofJW/tmh0q9DaT xlzR/HSbe28sL8wMBbtUPEdbld+dPDT1mh8bk7CcWtCddqtvop+WUr9oyNSjzNyF+r nRp8dic+IBB6O8cHTnGK2Ey4vlsuRFspuJ3ZzmRoATEcKMutz/iW7QWkr1trVgRN8c wt2IDevKhfCL17oe28TtDqjfC4Fvagh8k6JIxgdxkKv+la+Vl5DRXYoxXgf/Grx3eR UONMir21Czo8mlYfNHTq4bLPX2Pwa7OIBuhSNnEYL4YwcsZ8x2OwheFEcF7ynH2nke PI/VME6Y6YP2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1726060771; bh=5W/qhfnBCdxvMNbbU8sTMOE6s1XNy+wv4Jmtt9p3OhQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=cgHXzdlZvfPE0HvuiWaqbWp7dddfgiQcYG2mTdkxn0QGXuht0BC60bS8tW8gniABj 9jigXD5LMb1+/nzHytsx6kUdUy5HHEcEtpkT4gOh0jgKY+lmkh9HnIhGf+q+GKDPZb kIPAfmfLauuTkFzh+PdLf4MqWkr9C8WCIAHF8XMc6vnmw5O8gPlqCA2Ye5QWSEPANQ KIn7kjFqHy7H2qt1qBkEmnDdbWOnkZMLdIhKlFJgjcXnewP8fsDpR1pIg+00bH5nqr U0YV24fii9e/W6kIrjF2ObgCUI1yUUVB/yrri3lanhBywnBI8NAK5ewpxaS1Ym1usv 1+txvQWleBqIw== From: Sergey Makarov To: CC: , , , , Subject: [PATCH 1/2] hw/intc: Make zeroth priority register read-only Date: Wed, 11 Sep 2024 16:18:59 +0300 Message-ID: <20240911131900.179648-2-s.makarov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911131900.179648-1-s.makarov@syntacore.com> References: <20240911131900.179648-1-s.makarov@syntacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: T-EXCH-09.corp.yadro.com (172.17.11.59) 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 11 Sep 2024 18:29:04 -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 @syntacore.com) (identity @syntacore.com) X-ZM-MESSAGEID: 1726093824530116600 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 --- 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 Sun Nov 24 05:57:27 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=1726093819; cv=none; d=zohomail.com; s=zohoarc; b=bT97grCQHFU+mBZ5sFfSZp2P+kZU9zto8CN1v/jvF0l2rHfhOmFylWTJQ+n17a75Erbm78Qw9bbkfyvHFgg8E+rXrpbOniVaV0oyRbgpPTzxeRrLJaKUJsehHrDk6gTsTWkh3L0m1fJwee97oUtK9Z5UW/fYGOPKTu89GAO0KEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726093819; 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=meqpDvHOdKYv5pyDhE6mhl1c70PWAuV531TvpHGwS0rXHfxKLE9aGLoGQYN3dkbVQXXdjhjYiCMEB6+ik5g1r01SA/tZDOW1SHCG3Aq7bHel3HNCvG7uslNEZlMmbJw90y80vMOEGYfI4uXwiR/TzcM+EdTvLYWxszJ6EisLQHQ= 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 1726093819827519.0240886346803; Wed, 11 Sep 2024 15:30:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1soVq2-0000W2-Rw; Wed, 11 Sep 2024 18:29:31 -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 1soOJO-00076T-DM; Wed, 11 Sep 2024 10:27:19 -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 1soOJL-0003Gn-Re; Wed, 11 Sep 2024 10:27:14 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 mta-04.yadro.com F2050C0002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-04; t=1726060773; bh=Y7u+ZYWkETAKlOCWN/jUACcmbj4sINmDqk7xJHoZJoI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=P/TrnvxvHblvXz3+bReMoZr4E4IN6/vy8OCbDb9r+lhaf2QvE+BvHLIvyJ8KHngmR 1ywla6wZdwMiIj5S21eF1P/v68H7am5qiaUiQ7wJcjPdy0fp9OcBnGn6aZBUfLVfXR KG3XOkie1bSdE81c4iTKs+z4eQfyeL/0F5CTUat5g5oiIxidSl+dnFppeLmKr8nYAF T/9UsmIgfSM0AOdHydG8teG+MnBHWMEAgfFpav7Kw4pWzIjZpXAQjjMwGErQLLcY6K VlT4PrFD5rSy70AtG2JeFGyefDkcd6R8NYaQiPW8P1LJLEYdCmidJXr0ExFemQXRiW yISNqqxP0v/Vg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syntacore.com; s=mta-03; t=1726060773; bh=Y7u+ZYWkETAKlOCWN/jUACcmbj4sINmDqk7xJHoZJoI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=J24XvOOboKNbhib58AlLfDDocaUocxF8D6gr9EUn7SjElOlDC9ou3Rai/B6pvPFPk kmM8XgJR6OOAwGOPzRScq6T+94A3K86f9NQKIM+eRR+C3VsrHlKCfhJuiRpB9Xrmc+ zvzBEdWMXOOwPaOlD+S8/zi7PdPYW5+6pDkevOhgVW1oPmUjYjD6L/qiw3zm6VPZ1u VX3H/JqBv3xnuAYJkEWvvtChWruyYD9r2PcTVkcKlGKLsFsVxpHTv+vVYdScTFXTKX 9BYyHt2fSfdEgu7eP4AbjPVCNw7n15qZtxZPBRmGzlWx7AcdGXimAk0sjMMvkg2h4o 8VvBtWNOWs0ug== From: Sergey Makarov To: CC: , , , , Subject: [PATCH 2/2] hw/intc: Don't clear pending bits on IRQ lowering Date: Wed, 11 Sep 2024 16:19:00 +0300 Message-ID: <20240911131900.179648-3-s.makarov@syntacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240911131900.179648-1-s.makarov@syntacore.com> References: <20240911131900.179648-1-s.makarov@syntacore.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: T-EXCH-09.corp.yadro.com (172.17.11.59) 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_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, T_SPF_PERMERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 11 Sep 2024 18:29:03 -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 @syntacore.com) (identity @syntacore.com) X-ZM-MESSAGEID: 1726093821238116600 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 --- 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