From nobody Sat May 4 00:51:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; 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=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1605333466; cv=none; d=zohomail.com; s=zohoarc; b=Gz4jZXAGINTZAb/6zx1V3ywdj98z7Hb2wF7nOhZ9ehikdeXMyBv3iSXr1vH1IWgQj2VVupvmtaOnIhjt4Os+9n97dsDvvVj66sYD3J8PMEuqh2Ss3FwMNPu7rumsOYXyYLNl1RcjFp64vTAHPrXwiBS2S5tVJpM352IJOARJBdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605333466; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DW0w2PUbSz3pHD952Y/eVY4NUlZL8OpvblYZSTFKsPY=; b=DuIuxzt3H4/QYvFiZbNPLTOhQJcj8/RmW/dc5Dyluet2TOL/4CjLK84fu18AwJYOKBxiwjllzR/730KjSiqgu3nDTK+zn2+K6iLI9R/lMMfh+KHpa6FvR4D6BKSGUguw8gyRj888HK2nD3scxvFBXCXDIhtloqAM472MYNr7JTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605333466732387.9134489722927; Fri, 13 Nov 2020 21:57:46 -0800 (PST) Received: from localhost ([::1]:52040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdoZF-00061H-1b for importer@patchew.org; Sat, 14 Nov 2020 00:57:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47614) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdoYV-0005BR-LI for qemu-devel@nongnu.org; Sat, 14 Nov 2020 00:56:59 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:27199) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdoYU-0004LV-1a for qemu-devel@nongnu.org; Sat, 14 Nov 2020 00:56:59 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Nov 2020 13:56:52 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 21:41:32 -0800 Received: from cne130336.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.61.81]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Nov 2020 21:56:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1605333417; x=1636869417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PDGjOCrPcBr55qeG23BqMw3++1CZi6hyle/slqh0rVI=; b=pAzdD9R2DCOj75nO3ZeuCXyUAKwOt2SxhqpsvBpJlEMMk0wqadN0ds+C LetFBDY1gL6YDIdXLij1NjwXDwd1+q1KShAH7jJQvKM8F0Tncd1hF+ob6 bVqyusJkRfiZ7Uo4K2KJWP7Pq9MT4RCoz9rGRmLrKjwwjt2lTndwZlJjL /bwUbClN0bzZrzj8LfqBp4XhlgZYTeOBI4KBtz2tgcDSDJ9u6NQsMmimd Ss+L1a1vXXpxfB7DaBHUrLHbB3WrpYF8+mW/8romUjIC9qMsBqAOuVWPl aKPy7vinsFKyR4bABdB9LG/EwEmHYyNDlxCaPMO/yV88BNurhXSrEOJ6m Q==; IronPort-SDR: +KU2XQxgx/tPxJMjHgV4bIvkP3VLjoOHWkl/V8Np9jTePbka7dnzLXmueTgaovMbyVfuMDumfy DnAt+0zxzKqmTjSR/QCgnBs7x+nM2SyvOpQVU60Gr8SUpzFxPzMgmMFODRGvkTmPDoNe8ixEHh NY7FTxaNxgwvUG/YAGxYvueGZBRRGaw3J2GpPhUoaOzQWvTDwnqiB8jWQ6UWEGsH3mPXZKKI3p hSFQZPL5FsTvGxwC7gIBdsqiZqPU28q/zSErx4plx5i7vrFHzOUjKgar2ah7H2wgauGlLjxWgw o3o= X-IronPort-AV: E=Sophos;i="5.77,477,1596470400"; d="scan'208";a="152517556" IronPort-SDR: rSOJG38a+T54aMzsp0SXWo7IYcKPFXQO5TpW5SkJq3Zsavv39TE81PbkDRB7WoEXiqnL9YNMpK OQuFbAqR5rk4anPukJX9lT1TCItOdQL67X5UHD7Xb+g2bT5ZWa+nlD+24mfaFItKx0d03JCQ81 OHX96pPDibfl6lYgyohKL+Z8DvRm97nmoU+44t1coATL/UnC2qJceOwT7wobAmoEHWBykwSmcs /p2YncTqAJp8Vx8B0hnRM5EUSPSj4xlVvwARPkGmTfl23FYingq33waP18cWFYG19D4CcBBbn4 eeq9SAMX0uf0HL7uxsjmDBUz IronPort-SDR: Qr0EUvK33lzjoN5y/8iK6Zzz8S3mGgY1PaW8PCHLorxx9WMxUHlpGZfsmk8SGu2ZCLkr7NkLes 7cstHwd+9zBlpSuXiLxZ1bcHqyNcxpeuFWm4d9neVFm37l3mc99+ybMNHcpvAEa3IM5mvA/YjS 9WYuwcFgFbmliwbUb9O69aW7uTcSNKtCtGu3a6wojIURJlQtUQ3RYeJG3UDKJtp79ROUPPyK0c gK+6g6NfkjlQKHcSkEGcVhNfc/jaUHe7Nc3yOMMrp0NorZSRmY3F5HyahqWK4i6LWowuEKyfGN sPU= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 1/2] intc/ibex_plic: Fix some typos in the comments Date: Fri, 13 Nov 2020 21:45:08 -0800 Message-Id: <20201114054509.180352-2-alistair.francis@wdc.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201114054509.180352-1-alistair.francis@wdc.com> References: <20201114054509.180352-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=216.71.154.42; envelope-from=prvs=58086a3e2=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/14 00:56:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Alistair Francis Message-id: 22d2fb0d7af5ca316c67ac909926368d1bcb7cf5.1605136387.git.alistai= r.francis@wdc.com --- hw/intc/ibex_plic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index 235e6b88ff..db9e0aa25f 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -45,7 +45,7 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, = int irq, bool level) =20 if (s->claimed[pending_num] & 1 << (irq % 32)) { /* - * The interrupt has been claimed, but not compelted. + * The interrupt has been claimed, but not completed. * The pending bit can't be set. */ return; @@ -133,7 +133,7 @@ static uint64_t ibex_plic_read(void *opaque, hwaddr add= r, int pending_num =3D s->claim / 32; s->pending[pending_num] &=3D ~(1 << (s->claim % 32)); =20 - /* Set the interrupt as claimed, but not compelted */ + /* Set the interrupt as claimed, but not completed */ s->claimed[pending_num] |=3D 1 << (s->claim % 32); =20 /* Return the current claimed interrupt */ --=20 2.29.2 From nobody Sat May 4 00:51:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@wdc.com; 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=fail(p=none dis=none) header.from=wdc.com ARC-Seal: i=1; a=rsa-sha256; t=1605333529; cv=none; d=zohomail.com; s=zohoarc; b=FJUJog8kxxEpCkks3BryX4Py0YBwtdm7t3PS6DuMCDJ8M1IxkQw38G+gzHD5OSUOMkfG/EWYeRa9Y7fk8Rs/hhjsbCYlDDZ6yprWJBZCijwK8VPRrd/m87TaKBTp/uFO2PWRATAEAFmqWdcNa/+1xIk5kpeAS8Qe4Dq81pfQ2fY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1605333529; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TkqcEsduqBKO9wSyhZbOqg26ZCyIF501O5Fun81dkJ8=; b=KXfr7Cq8kbynia/b3awXLWfMdI0v/qFupWVeTANe5QPnuV7hPVB1C6ZzEI2DCM1uabZQrEOgwu+xgqbYMU/OyX8wmhAzMtis3TSGhl8OLqpijs8svavhBsfuBs98osX8vENMlYw48fn9zRsibwoVibYnD9FNauWr3lgni2xkLO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@wdc.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1605333529728620.0719648745813; Fri, 13 Nov 2020 21:58:49 -0800 (PST) Received: from localhost ([::1]:55226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kdoaG-0007LW-Oh for importer@patchew.org; Sat, 14 Nov 2020 00:58:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdoYW-0005Bz-Cx for qemu-devel@nongnu.org; Sat, 14 Nov 2020 00:57:00 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:27201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kdoYU-0004NC-IG for qemu-devel@nongnu.org; Sat, 14 Nov 2020 00:57:00 -0500 Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 14 Nov 2020 13:56:52 +0800 Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2020 21:41:32 -0800 Received: from cne130336.ad.shared (HELO risc6-mainframe.hgst.com) ([10.86.61.81]) by uls-op-cesaip02.wdc.com with ESMTP; 13 Nov 2020 21:56:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1605333418; x=1636869418; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mbxASUWy1fWRJ+jJOEgh3oNl6P0yN/NqGYscLjpSEE0=; b=R5EeRfe/3Clua2W88487a8S2eduLH+d6G0SUjVeXMgQ+NDKMtSiPWEdm L2AsWCnx3qtYS4AQDA6cl3UpMlH2LEYuXrMjnSzl4ur+bl5vYTsMjQvTQ keicjMCvLX2CKCBkXC3xSe0Pf5BsfbY2snoY63HJUgYjg4W/59gOg05Va 0sUAfJLhlaLrZJipVaKBAtp0jcstoUsdvJK4T5C41hvIIYSkD+mfbNRtq 0vYWQhJ26tAyRxAXVHlq9s9mn8J4BpJoekvSaYO4ML8l6ySAXw+smwdlA UBDon7Ns4Y+jc1N/9cF81w8Ulx4pNi1kOPKTUb7YWChqP65f+itL9hYJo w==; IronPort-SDR: yDON+g1rkMEX5ZCXe9EtttXUVDBy/9ZmkbXeipyy/25pzMAAtfZZdw8gg3nbuCrzD4icjhSI6L DTahCDRouy4SIYjaoAo538WOpfatBk63cW5nC6nZnjnpKJnnm0Iz0VqdrQtt1NCYr1jaMlK4d4 pTMJ074Q/NEu9kI9d6Q+VIeNMbE8ummQ7Cd+AvyH1QDDOfAnY2UXJe3Q/MvONATnyyoB/7CaJl TFpIxY+y4TC2bXLQqKj2S8bU/bJo4IJOGp6LmbGIqnTcNBJocX7FXqElpHtjSrsOwwBhoPllqH C/0= X-IronPort-AV: E=Sophos;i="5.77,477,1596470400"; d="scan'208";a="152517557" IronPort-SDR: NkF5h56ophktFhq01VGyWumpQQCIt07rjdLbXJ24I0UGkbxAvyGR4YK91JFnwr+Kvy/gRfTflo yB07gJUafrKSnMExbRacny/hAS4a7u1dAaNzYkTG0U6y37VM028hZVAJSjQKE/N3SBE+kq7JZQ lKwiRBg0Y2HWtQFBhjRet7RA919cGd9stmNxGRzrSqe9xX7q8l5BujOZI+WV271pOYFWZhxAYp wDDkqSfHcxDeGrbRYPl6XaQq5eys+tuYwhhXGpncvLdBCzcqNnv7LRp8RuYcWQoNC4/uQLL4CN 2s3uqUXytujBtsOgIZJ63+GV IronPort-SDR: gOlsNjS9dZdDYJtheMzAI8kgePG/UXn3EcYU+w/kfQWsaFU4WNqvrQSU0cXXFSNcWjOlTJ4Cgk 0pxIRNPX7RJnEqPqPEfwjJv1OSrx1N7snYLFjLCkzmeQZkb59yXwsoZMPsgkMqYHEPzVLxtXMQ dvnYFizUeLQsnBn4zETvpapLNzfcwOBag4HOlYviyjeIp8Lq6goQKItddhe+JKtbVAnVXqrRX3 pEkd165oDkB+qPDPzbjh7ZKJKy2pRp6YAnLQyoPOfcFCf4318PHVBFRYTkGalPoZWj0XsslPLM hXU= WDCIronportException: Internal From: Alistair Francis To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL 2/2] intc/ibex_plic: Ensure we don't loose interrupts Date: Fri, 13 Nov 2020 21:45:09 -0800 Message-Id: <20201114054509.180352-3-alistair.francis@wdc.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201114054509.180352-1-alistair.francis@wdc.com> References: <20201114054509.180352-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=216.71.154.42; envelope-from=prvs=58086a3e2=alistair.francis@wdc.com; helo=esa4.hgst.iphmx.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/14 00:56:52 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If an interrupt occurs between when we claim and complete an interrupt we currently drop the interrupt in ibex_plic_irqs_set_pending(). This somewhat matches hardware that also ignore the interrupt between the claim and complete process. In the case of hardware though the physical interrupt line will still be asserted after we have completed the interrupt. This means we will still act on the interrupt after the complete process. In QEMU we don't and instead we drop the interrupt as it is never recorded. This patch changed the behaviour of the Ibex PLIC so that we save all interrupts that occur while we are between claiming and completing an interrupt so that we can act on them after the completition process. This fixes interrupts being dropped when running Tock on OpenTitain in QEMU. Signed-off-by: Alistair Francis Message-id: e7bcf98c6925b1e6e7828e7c3f85293a09a65b12.1605136387.git.alistai= r.francis@wdc.com --- include/hw/intc/ibex_plic.h | 1 + hw/intc/ibex_plic.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/hw/intc/ibex_plic.h b/include/hw/intc/ibex_plic.h index 37f03356b3..7fc495db99 100644 --- a/include/hw/intc/ibex_plic.h +++ b/include/hw/intc/ibex_plic.h @@ -33,6 +33,7 @@ struct IbexPlicState { MemoryRegion mmio; =20 uint32_t *pending; + uint32_t *hidden_pending; uint32_t *claimed; uint32_t *source; uint32_t *priority; diff --git a/hw/intc/ibex_plic.c b/hw/intc/ibex_plic.c index db9e0aa25f..341c9db405 100644 --- a/hw/intc/ibex_plic.c +++ b/hw/intc/ibex_plic.c @@ -48,6 +48,7 @@ static void ibex_plic_irqs_set_pending(IbexPlicState *s, = int irq, bool level) * The interrupt has been claimed, but not completed. * The pending bit can't be set. */ + s->hidden_pending[pending_num] |=3D level << (irq % 32); return; } =20 @@ -176,8 +177,21 @@ static void ibex_plic_write(void *opaque, hwaddr addr, s->claim =3D 0; } if (s->claimed[value / 32] & 1 << (value % 32)) { + int pending_num =3D value / 32; + /* This value was already claimed, clear it. */ - s->claimed[value / 32] &=3D ~(1 << (value % 32)); + s->claimed[pending_num] &=3D ~(1 << (value % 32)); + + if (s->hidden_pending[pending_num] & (1 << (value % 32))) { + /* + * If the bit in hidden_pending is set then that means we + * received an interrupt between claiming and completing + * the interrupt that hasn't since been de-asserted. + * On hardware this would trigger an interrupt, so let's + * trigger one here as well. + */ + s->pending[pending_num] |=3D 1 << (value % 32); + } } } =20 @@ -239,6 +253,7 @@ static void ibex_plic_realize(DeviceState *dev, Error *= *errp) int i; =20 s->pending =3D g_new0(uint32_t, s->pending_num); + s->hidden_pending =3D g_new0(uint32_t, s->pending_num); s->claimed =3D g_new0(uint32_t, s->pending_num); s->source =3D g_new0(uint32_t, s->source_num); s->priority =3D g_new0(uint32_t, s->priority_num); --=20 2.29.2