From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752266865233397.63852313919347; Fri, 11 Jul 2025 13:47:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKed-0003ah-D5; Fri, 11 Jul 2025 16:47:35 -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 1uaKdt-0003Jg-ST for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdp-0003ib-SC for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:49 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcC-000Bmy-2V; Fri, 11 Jul 2025 21:45:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=2csROVQZI1m/Xv7Ap0gy16ro6mTRFLG2FbzahoL7710=; b=QWtUG62MqlO3cTpLnltApzOSPn ihVSS6pl6aYvySC5ucdQuSaUSkY8yfCFKaVBPlnsygLlFrO+Ui8by8FosRHkz1p+Uyfn/4Mh+v7rZ F1HasNtn3JiP4+x3xdSEkVmPY7RcvKLfla4z0458krzQGt7s1i+cRnuD6KdoWyOY18OPALeYZmSKG k0r/Vq4fCnyDB1kH1kktpDZ8VjfwecNQqW3bHN3+WBOucQGyneMLYzIe8NqldPgTKjM294PbGUXIC BiGQWD/gwx+/TJHP+9ITboO4NBOEhyjA3TC9EhqhTUeKSX/rvxUSx6ADssWcbYYRi/RxzVXDOIe5L e8MlX39FlfFW6ja7euMkydMLOyh0WKwLjqhfpqiHbzRLxJYetJ8OgcC9vnUF46s0r5V2nmvBaG7ym fEfhjBxswgvvKf4eCO72ofOPvxDe1B0wg5eW4UZrzjdmTp5vPUqiGh9DRBNb5gtPJWg0BKliO7djd CqQ8xDIUScE1Iyxu9EJ2YnmpRXcBZEGvW+9tlcPmwh4rtMO3TP28t+JiMcLN2C8paLXR74njzjS06 7BsuC0JobfjEFXIsar3TKd56CCLPMCD1wnoQ25VKQzM9LOlTWigB9N4G9QndVQy+SrCLSS9DsDVeX sB/6uJ3erMxG8p7ioYr9Ah5+0Z1JW39FNlyNfP9Bc=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:30 +0100 Message-Id: <20250711204636.542964-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 1/7] esp.c: only raise IRQ in esp_transfer_data() for CMD_SEL, CMD_SELATN and CMD_TI commands X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752266866775116600 Clarify the logic in esp_transfer_data() to ensure that the deferred interr= upt code can only be triggered for CMD_SEL, CMD_SELATN and CMD_TI commands. This sho= uld already be the case, but make it explicit to ensure the logic isn't triggered unexp= ectedly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index f24991fd16..9181c8810f 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1012,6 +1012,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) */ s->rregs[ESP_RINTR] |=3D INTR_BS | INTR_FC; s->rregs[ESP_RSEQ] =3D SEQ_CD; + esp_raise_irq(s); break; =20 case CMD_SELATNS | CMD_DMA: @@ -1022,6 +1023,7 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) */ s->rregs[ESP_RINTR] |=3D INTR_BS; s->rregs[ESP_RSEQ] =3D SEQ_MO; + esp_raise_irq(s); break; =20 case CMD_TI | CMD_DMA: @@ -1032,10 +1034,9 @@ void esp_transfer_data(SCSIRequest *req, uint32_t le= n) */ s->rregs[ESP_CMD] =3D 0; s->rregs[ESP_RINTR] |=3D INTR_BS; + esp_raise_irq(s); break; } - - esp_raise_irq(s); } =20 /* --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752267119059761.0917153540753; Fri, 11 Jul 2025 13:51:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKed-0003ai-D7; Fri, 11 Jul 2025 16:47:35 -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 1uaKdv-0003Jx-7J for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003iy-Co for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:50 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcC-000Bmy-IV; Fri, 11 Jul 2025 21:45:04 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=DaL2mqf1oOve9B6MZryX4sutK73zfpe2Dc7xtYjrFJs=; b=ZYrybVF1RBK1cuFdvY7qR20nyt to/TQsd0mZRwQehxRvsJ+8So2bgVm8quY8kuspVrgDpod3A7v0C0LKXn0TnZpQe77GGpi1xWEZONm ZMdI4/Vz9bQBi7Gr1BOKU/0B81rtZH0rI2oN0nwUtV+Hxb27QssJb6PSz4tu7RcG+l6BQxJQu6mO+ lwDE5S6EDPra5TDzvAPHvirKjUIBd/wqYmy4wo7ihBDCLQwHsnfNvI28Cmnz6a+RYimFpEZc0CBiY /J4b21ng8kcb4kUVyf1I/C2WokFWgUCM5wmdWKxZzcFF/Vai4+qY8KZDYLTHAKbBsefAwUe0HXDAg CJPrf9HYO7QQIPIVXtQLGxXwcxkmFoP+kK8sGjJqe3ZfmBmO5CurwU3j2oCxNplW9xzEQwahKFNcT uf8lIYP6HNDnTmXb+QnnlQ4wou8858LhQJlqzUFNCgIoyVRcKSvveZq8hchljsSVSUQNXpU4n53/U PhlvUdp3sQ2Z9esY89yl5zE15KDtjgA8dl/jRCU4PAR9uKn8g1Rps+e4npv8Xqy1vieUkkl/7Rv9d 08nzkKovZMrf2zXObk8a2fW0rsqO1XaHyY635nZPjcDbzDQzcgWca4LR+nD3Go3PYSu0eLv199mJ2 WRkS5/5rZ4PPcuY3JWBuOj1N48u5b17I+Lx/fyUqc=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:31 +0100 Message-Id: <20250711204636.542964-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 2/7] esp.c: improve comment in esp_transfer_data() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752267119354116600 Whilst working on the previous patch, the existing comment was not enough to document when the TI command codepath was being used. Update and improve the comment accordingly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 9181c8810f..62ba406149 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1029,8 +1029,9 @@ void esp_transfer_data(SCSIRequest *req, uint32_t len) case CMD_TI | CMD_DMA: case CMD_TI: /* - * Bus service interrupt raised because of initial change to - * DATA phase + * If the final COMMAND phase data was transferred using a TI + * command, clear ESP_CMD to terminate the TI command and raise + * the completion interrupt */ s->rregs[ESP_CMD] =3D 0; s->rregs[ESP_RINTR] |=3D INTR_BS; --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175226717365234.49361373545764; Fri, 11 Jul 2025 13:52:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKfO-0004Rq-CQ; Fri, 11 Jul 2025 16:48:25 -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 1uaKdt-0003Ji-Ux for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003jI-AL for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:49 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcC-000Bmy-ST; Fri, 11 Jul 2025 21:45:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=+pg3U2MlgD5Mm9wqpVaAXbSZ7dQrwSODtzqh3LXUiqc=; b=gqum/FqlYUyLYXezRAi8VdbkVG XEbF/fyrjVSVZCAo8e/kV7I32Di9glLoROef3ppa/Ql7Na1MzvWDz2VlHvbTgR/i7jO0QCu5QPdey 83mHh7oltPZC3MBa8sOcuHgy8+aMnnmzqXKqIcswvqLl+xfRUUvic/YdzQuJBUyG7yq+fuVJ+BVXI 9U1QAHmcNaLlQfLBJ+6iaKoZoMNhWWZKhWXhSctzTicOSSpTYBCPJHX8RjXBhi00lmgJ3r6wde8Iw Mwe/Ic22foeuD7w8MxMxGc/Ty/R32tudj2CWjfl1SjfiEce8RTApjHPEO1ATFUoUCtMUoBcpHQnto WckpWKdaC+Q/jdJwd692jAZD8cecbwVlXs1FEWWAdFtZjn2K5GFAjkNeJsuHICK2quNfoEYsxGgOY ggKnGilCYSHNJ87XBu1wGNQJqehzgATipfMKhfpjyyjTE72e/nORzsV9nC/clC7OViIiwXxyoOTYS cDL98xPALQ3la/JRwshz5F3JTAQQhtyys3GmVFize1jXaAw9o6vGZkaCMeRz4vwdZfZ6Si3oxA7eQ v5l5KHrJu4ziIqjmGgNnmNfFjlL7Vp5U7OKgbSPWDmaIJfh/QXNo1q24UtVXow8AFEEYwmJV29JRF 5j2C+09y0CvARHHhvq/GMiaMRxi5ndxsCM8CO07Lg=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:32 +0100 Message-Id: <20250711204636.542964-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 3/7] esp.h: remove separate ESPState typedef X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752267175908116600 This is not needed as it is now handled by the OBJECT_DECLARE_SIMPLE_TYPE()= macro. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/scsi/esp.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 533d856aa3..c9afcb7cac 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -14,8 +14,6 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, u= int8_t *buf, int len); #define ESP_FIFO_SZ 16 #define ESP_CMDFIFO_SZ 32 =20 -typedef struct ESPState ESPState; - #define TYPE_ESP "esp" OBJECT_DECLARE_SIMPLE_TYPE(ESPState, ESP) =20 --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752267054854736.6790074196333; Fri, 11 Jul 2025 13:50:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKfb-0004ck-5d; Fri, 11 Jul 2025 16:48:36 -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 1uaKdv-0003Jv-7Y for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003jU-Bo for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:50 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcD-000Bmy-G4; Fri, 11 Jul 2025 21:45:05 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=qc/LoTY52HXjHlsY1qwQ5usYvq5PbqVKt8sXaXF6GIU=; b=xCPaDlxyIoEba5gZ+kmexWnX+V CJjuf6f8LMx9gzmGs16r5ISDCdE+qfrgfRgIQwW1/LZVOlL3fW3Ht/gF+c2NwThRzFWZ4E8alLKNx CSjquKRNZS+sbgHi3pdoa6J1XHUaGMnUZOdAXJZ7jz+g7beINUDFLebkwhUvYckVSf6YMYrRldZMp BVbUUviKB9lUH4+a5mFkxd0lnYf/EtszCDSAfCrlXxx+NxKQqurWgqCu+JNxFphrNT3BYC96w+ecY xfvRlRigyvLcqrD8DgSGadtCFBA9YG/7UX9iljXYuqna2NaWZwG6aO9CBO33t9HsKuRMiTPZo4kUv Awv4VbpuTP937iEUkx4wAakZKAXbbaH9YBDIy+3KCndyZqBhKpEEGoARaSgb7XjVRLZ4ItUqyRVKI p6cLCArkR0iqWlTx08hZKgtT8kBfrHG+/DxrafLTnU6+BZi2oFx/9F8wON2PsjE1hCxiMHknfCwKG OqLtdQrXjpwFGFTO4PpnKGBQyG/5ZXGAymBGanj/EYKrzost8aVdPOsuGTxNa3iJVdlwYPMzzxfGF 9xsPKiRyLMlvsNXJJlfAEPmyTSeUokUMr6+beN1zkR0tPqSDwMrNdtX+9fn6YJliaPNmACTAETGUX QCnJy05g2vxnDOnvqAvADkq6caNxa8YmD6pQVsnGY=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:33 +0100 Message-Id: <20250711204636.542964-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 4/7] esp.c: only call dma_memory_read function if transfer length is non-zero X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752267056708116600 In the cases where mixed DMA/non-DMA transfers are used or no data is available, it is possible for the calculated transfer length to be zero. Only call the dma_memory_read function where the transfer length is non-zero to avoid invoking the DMA engine for a zero length transfer which can have side-effects (along with generating additional tracing noise). Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 62ba406149..ec9fcbeddf 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -487,8 +487,10 @@ static void esp_do_dma(ESPState *s) case STAT_MO: if (s->dma_memory_read) { len =3D MIN(len, fifo8_num_free(&s->cmdfifo)); - s->dma_memory_read(s->dma_opaque, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); + if (len) { + s->dma_memory_read(s->dma_opaque, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } } else { len =3D esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len =3D MIN(fifo8_num_free(&s->cmdfifo), len); @@ -541,9 +543,11 @@ static void esp_do_dma(ESPState *s) trace_esp_do_dma(cmdlen, len); if (s->dma_memory_read) { len =3D MIN(len, fifo8_num_free(&s->cmdfifo)); - s->dma_memory_read(s->dma_opaque, buf, len); - fifo8_push_all(&s->cmdfifo, buf, len); - esp_set_tc(s, esp_get_tc(s) - len); + if (len) { + s->dma_memory_read(s->dma_opaque, buf, len); + fifo8_push_all(&s->cmdfifo, buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } } else { len =3D esp_fifo_pop_buf(s, buf, fifo8_num_used(&s->fifo)); len =3D MIN(fifo8_num_free(&s->cmdfifo), len); @@ -572,8 +576,10 @@ static void esp_do_dma(ESPState *s) switch (s->rregs[ESP_CMD]) { case CMD_TI | CMD_DMA: if (s->dma_memory_read) { - s->dma_memory_read(s->dma_opaque, s->async_buf, len); - esp_set_tc(s, esp_get_tc(s) - len); + if (len) { + s->dma_memory_read(s->dma_opaque, s->async_buf, len); + esp_set_tc(s, esp_get_tc(s) - len); + } } else { /* Copy FIFO data to device */ len =3D MIN(s->async_len, ESP_FIFO_SZ); --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752267108603415.6131711260857; Fri, 11 Jul 2025 13:51:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKhA-0006qs-2I; Fri, 11 Jul 2025 16:50:12 -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 1uaKdv-0003Jw-7x for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:55 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003jZ-C3 for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:50 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcD-000Bmy-TH; Fri, 11 Jul 2025 21:45:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:Content-Type: MIME-Version:References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To: Cc:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID; bh=+iLnFnSkF1ih5/T5mQynKA+eHeYjoDfaR/4447dv4kI=; b=SoiMInGzyWXsfXSgSkJzpSLJyW egF2VgrFd/CZPcrqmfnRbWnf7dV5hF5LXzho8rbvockRbjg13ggO+2OERSqULK/VYCJXNoO2q7pSV oRvOtpjWzZ7UL99P638movMvKWfNE7NWVkRRUe/TFjnaIrAiP4ya9mEwFKp5exCFbldeYpCIQSjvy Ue4OeZXJsD9sDv93MCASAoaI8T3WdexPgkZ1lXuqQxreo19iLAlz79x54MjGekLyp90f9x9AZ9bP+ N7/uYX2osZxA2wo087Q31kdrZP/VFeR5ekWEGcxIqW5KjpNqwMe7QvuqsfIzMx61adVvDPasixHzk QaWcZG52RXEbP8IXdjRCK0/uxxJgCcfaGiWpoNmPAjFT1xySX9J1L1KalJRxuXp12N5Y4XvXIjQ19 uyoW2qL8783EI59AGs2oZHRu/MuNAlpnoYHn9Wlpmlmn33s1rHcREXJBNfcdaWS/YSWhNu5ooJS09 tig1omYUGAwVQLQHJP9a/z1ta7LSpaMmldXjQE0c1/QL2d28f3fG9SoxkHMs09O5LcXkZiYNKUxOT 90yGQZDzE27drSaUuQR0ZAjs34YsywYjb7QLQo+2X/TW7IPMfxio1mPCITH2j7/sMtNYEg/Ed7rwk gvNMMN55pOmKNWaIIwUpljT/50wZ0LuB7SdRiM3SQ=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:34 +0100 Message-Id: <20250711204636.542964-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 5/7] esp.c: only call dma_memory_write function if transfer length is non-zero X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752267109238116600 In the cases where mixed DMA/non-DMA transfers are used or no data is available, it is possible for the calculated transfer length to be zero. Only call the dma_memory_write function where the transfer length is non-zero to avoid invoking the DMA engine for a zero length transfer which can have side-effects (along with generating additional tracing noise). Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index ec9fcbeddf..1c7bad8fc0 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -631,7 +631,9 @@ static void esp_do_dma(ESPState *s) switch (s->rregs[ESP_CMD]) { case CMD_TI | CMD_DMA: if (s->dma_memory_write) { - s->dma_memory_write(s->dma_opaque, s->async_buf, len); + if (len) { + s->dma_memory_write(s->dma_opaque, s->async_buf, len); + } } else { /* Copy device data to FIFO */ len =3D MIN(len, fifo8_num_free(&s->fifo)); @@ -681,6 +683,7 @@ static void esp_do_dma(ESPState *s) buf[0] =3D s->status; =20 if (s->dma_memory_write) { + /* Length already non-zero */ s->dma_memory_write(s->dma_opaque, buf, len); } else { esp_fifo_push_buf(s, buf, len); @@ -715,6 +718,7 @@ static void esp_do_dma(ESPState *s) buf[0] =3D 0; =20 if (s->dma_memory_write) { + /* Length already non-zero */ s->dma_memory_write(s->dma_opaque, buf, len); } else { esp_fifo_push_buf(s, buf, len); --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752267069795793.9713676730267; Fri, 11 Jul 2025 13:51:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKf2-000445-39; Fri, 11 Jul 2025 16:48: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 1uaKdv-0003Jy-Ag for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:58 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003jh-D1 for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:51 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcE-000Bmy-AJ; Fri, 11 Jul 2025 21:45:06 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=nXwCnPGmX9a3zqk6iwrJik3YP0RNhYwsicjQY7T/rpA=; b=YI23fv1z0bOUkQ6xwnumSvZe4q YFCXM/HWgVoA+gVChK6XyFxXFLtvgj+Z4iDZ/1UzDseBuLZPEdIGrm/2+WnY5sh661sXZtUngyfRZ aqqS2atEDOAPqJ+mmedQoSee/Or3rKIGqXOEyHxMr7392BP81EVzr067GoAg8e6e559HBOSNa4Max XOc+YkwYIS7NBFWj99BeuBIH/DKjKoFwerIa+p5OQ3Y13vDMFXt350+xPnQ9Jw8nR3SmfzFsIFDct C9Ur5rKPdylSki2WMkY4bbUTVSMFgyIE0VcjswvZpSk3YlP99PwwBPRrupK42nWDGMEEx9KzSJbjP uIPJNf18qfu/FSwNwqhw1DS3ldZBmDcAFYH+JHVtNQYcklCExpJ4Ve64kh5RzO+GBpZ52LaTyveSC Low29sF3tghGmfp0/RZXESpQySbF9QeEife9AnIB3HGgTbmh6Pj2iZNxR1cZ8++mvNtlcjCFtCCpl l94PeLYSS8I0cdqRu70R+5zZVjC6OhFuDWXTJ4/LoE0FNwUsKO2rnA3f14VhU0UQwsm6NzWz2jRvw L6i6YiYIYighfsdvKoGwf/Uqd6SD/0fBdq8I+ny9r5vlJq6JICPQOeWLfPFAhim/Eh87G/D25BUX9 YdjzS0IdCuDyZ9ZTHIzDEKk3m9cpnuvrqrhgLjHPs=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:35 +0100 Message-Id: <20250711204636.542964-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 6/7] esp.c: add asc_mode property to indicate the current ESP mode X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752267070873116600 Content-Type: text/plain; charset="utf-8" Add a new asc_mode property to ESPState which indicates the current mode of the ESP and update the ESP state machine accordingly. Bump the vmstate version and include migration logic to ensure that asc_mode is set to initiator mode such that any commands in progress will always continue. Signed-off-by: Mark Cave-Ayland Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 21 ++++++++++++++++++++- include/hw/scsi/esp.h | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 1c7bad8fc0..4aa58f9e48 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -275,6 +275,7 @@ static int esp_select(ESPState *s) if (!s->current_dev) { /* No such drive */ s->rregs[ESP_RSTAT] =3D 0; + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] =3D INTR_DC; esp_raise_irq(s); return -1; @@ -284,6 +285,7 @@ static int esp_select(ESPState *s) * Note that we deliberately don't raise the IRQ here: this will be do= ne * either in esp_transfer_data() or esp_command_complete() */ + s->asc_mode =3D ESP_ASC_MODE_INI; return 0; } =20 @@ -308,6 +310,7 @@ static void do_command_phase(ESPState *s) if (!current_lun) { /* No such drive */ s->rregs[ESP_RSTAT] =3D 0; + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] =3D INTR_DC; s->rregs[ESP_RSEQ] =3D SEQ_0; esp_raise_irq(s); @@ -1102,6 +1105,7 @@ void esp_hard_reset(ESPState *s) fifo8_reset(&s->cmdfifo); s->dma =3D 0; s->dma_cb =3D NULL; + s->asc_mode =3D ESP_ASC_MODE_DIS; =20 s->rregs[ESP_CFG1] =3D 7; } @@ -1170,6 +1174,7 @@ static void esp_run_cmd(ESPState *s) break; case CMD_MSGACC: trace_esp_mem_writeb_cmd_msgacc(cmd); + s->asc_mode =3D ESP_ASC_MODE_DIS; s->rregs[ESP_RINTR] |=3D INTR_DC; s->rregs[ESP_RSEQ] =3D 0; s->rregs[ESP_RFLAGS] =3D 0; @@ -1337,6 +1342,14 @@ static bool esp_is_between_version_5_and_6(void *opa= que, int version_id) return version_id >=3D 5 && version_id <=3D 6; } =20 +static bool esp_is_version_8(void *opaque, int version_id) +{ + ESPState *s =3D ESP(opaque); + + version_id =3D MIN(version_id, s->mig_version_id); + return version_id >=3D 8; +} + int esp_pre_save(void *opaque) { ESPState *s =3D ESP(object_resolve_path_component( @@ -1368,13 +1381,18 @@ static int esp_post_load(void *opaque, int version_= id) } } =20 + if (version_id < 8) { + /* Assume initiator mode to allow all commands to continue */ + s->asc_mode =3D ESP_ASC_MODE_INI; + } + s->mig_version_id =3D vmstate_esp.version_id; return 0; } =20 const VMStateDescription vmstate_esp =3D { .name =3D "esp", - .version_id =3D 7, + .version_id =3D 8, .minimum_version_id =3D 3, .post_load =3D esp_post_load, .fields =3D (const VMStateField[]) { @@ -1406,6 +1424,7 @@ const VMStateDescription vmstate_esp =3D { esp_is_between_version_5_and_6), VMSTATE_UINT8_TEST(lun, ESPState, esp_is_version_6), VMSTATE_BOOL(drq_state, ESPState), + VMSTATE_UINT8_TEST(asc_mode, ESPState, esp_is_version_8), VMSTATE_END_OF_LIST() }, }; diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index c9afcb7cac..6327060c7c 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -14,6 +14,12 @@ typedef void (*ESPDMAMemoryReadWriteFunc)(void *opaque, = uint8_t *buf, int len); #define ESP_FIFO_SZ 16 #define ESP_CMDFIFO_SZ 32 =20 +enum ESPASCMode { + ESP_ASC_MODE_DIS =3D 0, /* Disconnected */ + ESP_ASC_MODE_INI =3D 1, /* Initiator */ + ESP_ASC_MODE_TGT =3D 2 /* Target */ +}; + #define TYPE_ESP "esp" OBJECT_DECLARE_SIMPLE_TYPE(ESPState, ESP) =20 @@ -38,6 +44,7 @@ struct ESPState { uint8_t cmdfifo_cdb_offset; uint8_t lun; uint32_t do_cmd; + uint8_t asc_mode; =20 bool data_ready; int dma_enabled; --=20 2.39.5 From nobody Fri Dec 19 22:07:38 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=ilande.co.uk Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752266867791849.9094261273984; Fri, 11 Jul 2025 13:47:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uaKeh-0003dy-5E; Fri, 11 Jul 2025 16:47:39 -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 1uaKdv-0003KG-ME for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:58 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uaKdr-0003jr-NG for qemu-devel@nongnu.org; Fri, 11 Jul 2025 16:46:51 -0400 Received: from [2a02:8012:2f01:0:d1ff:478a:c096:2d0c] (helo=localhost.localdomain) by mail.ilande.co.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1uaKcE-000Bmy-NQ; Fri, 11 Jul 2025 21:45:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ilande.co.uk; s=20220518; h=Subject:Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=6FGpWyYgGDQDVT6MYWvX20DRvG0NRanL7OzhHiswAbE=; b=GtoEbVKLN1X6oQNAx07u5OZyqD jNHh0bTPDXuPSDvYV3+PlstFAh5QhCpqVH4cz0noKai7OUZosmCLR3JZAmex7IHH2R5D+1+gQhHyA uHxtt6xV+MFi7ZNALgxiCfJPJGBuk/Fx3IN7t6moNIU1DURxaRpt2qQoo0YAXTrj2/SVHgwOLYQQk IAHzV3Boz8xzOoGwLHxrWcl9tKFI0nbafhjt21CDGNqiaTMvivizMiRPwxEL3mrkxa0fBzvwoZu0i 15N7Qi24ufv5nDWzAn/NwDG6FQoVLdkI/VQfN975z/k2HOXzywnh0CJoq5F37RJExEwm3A5Z4NF5N XbBH13kRJrmiYdYtVhoJIc2w0Zxm7gmaQEKDJB7PCn4OUL2wtuHVmZXQJWZGVu+3AhtFaKAlZbxNI ZxCkj6E352nQE/L3zKYYb/ZqlMZQXMglIu43dQ/96+ykfzWeayvrVqYN/3rTZmGxBE1GeK5wfpGVe oGCjUofftHcMocreCsqqGEi2MVsqmlbs/dQMLZWVBlTQIrMkW7fXXdQUDrMRx209ZTl9Q04zkiGcT mf94muof3DNsRKJ5RNgsZZauuimN2vvqWxL5+Ma7TQQihcZnb41jxfq/YgVe/GWPdC6lQV5xqSdzx 04vRK/aYU/lOfnBx8ZBLGEP2s51pFfauPJ0Xr4q9U=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Fri, 11 Jul 2025 21:46:36 +0100 Message-Id: <20250711204636.542964-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> References: <20250711204636.542964-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a02:8012:2f01:0:d1ff:478a:c096:2d0c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 7/7] esp.c: only allow ESP commands permitted in the current asc_mode X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.ilande.co.uk) 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=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.ilande.co.uk 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, SPF_HELO_NONE=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.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: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752266868462116600 Content-Type: text/plain; charset="utf-8" If an ESP command is issued in an incorrect mode then an illegal command interrupt should be generated. Add a new esp_cmd_is_valid() function to indicate whether the ESP command is valid for the current mode, and if not then raise the illegal command interrupt. This fixes WinNT MIPS which issues ICCS after a Chip Reset which is not permitted, but will fail with an INACCESSIBLE_BOOT_DEVICE error unless an interrupt is generated. Signed-off-by: Mark Cave-Ayland Fixes: 83428f7a97 ("esp.c: move write_response() non-DMA logic to esp_do_no= dma()") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2464 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/scsi/esp.c | 37 +++++++++++++++++++++++++++++++++++++ hw/scsi/trace-events | 1 + include/hw/scsi/esp.h | 8 ++++++++ 3 files changed, 46 insertions(+) diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c index 4aa58f9e48..1d264c40e5 100644 --- a/hw/scsi/esp.c +++ b/hw/scsi/esp.c @@ -1129,6 +1129,38 @@ static void parent_esp_reset(ESPState *s, int irq, i= nt level) } } =20 +static bool esp_cmd_is_valid(ESPState *s, uint8_t cmd) +{ + uint8_t cmd_group =3D (cmd & CMD_GRP_MASK) >> 4; + + /* Always allow misc commands */ + if (cmd_group =3D=3D CMD_GRP_MISC) { + return true; + } + + switch (s->asc_mode) { + case ESP_ASC_MODE_DIS: + /* Disconnected mode: only allow disconnected commands */ + if (cmd_group =3D=3D CMD_GRP_DISC) { + return true; + } + break; + + case ESP_ASC_MODE_INI: + /* Initiator mode: allow initiator commands */ + if (cmd_group =3D=3D CMD_GRP_INIT) { + return true; + } + break; + + default: + g_assert_not_reached(); + } + + trace_esp_invalid_cmd(cmd, s->asc_mode); + return false; +} + static void esp_run_cmd(ESPState *s) { uint8_t cmd =3D s->rregs[ESP_CMD]; @@ -1285,6 +1317,11 @@ void esp_reg_write(ESPState *s, uint32_t saddr, uint= 64_t val) break; case ESP_CMD: s->rregs[saddr] =3D val; + if (!esp_cmd_is_valid(s, s->rregs[saddr])) { + s->rregs[ESP_RSTAT] |=3D INTR_IL; + esp_raise_irq(s); + break; + } esp_run_cmd(s); break; case ESP_WBUSID ... ESP_WSYNO: diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events index f0f2a98c2e..6c2788e202 100644 --- a/hw/scsi/trace-events +++ b/hw/scsi/trace-events @@ -198,6 +198,7 @@ esp_mem_writeb_cmd_ensel(uint32_t val) "Enable selectio= n (0x%2.2x)" esp_mem_writeb_cmd_dissel(uint32_t val) "Disable selection (0x%2.2x)" esp_mem_writeb_cmd_ti(uint32_t val) "Transfer Information (0x%2.2x)" esp_set_phase(const char *phase) "setting bus phase to %s" +esp_invalid_cmd(uint8_t cmd, uint8_t asc_mode) "command 0x%x asc_mode 0x%x" =20 # esp-pci.c esp_pci_error_invalid_dma_direction(void) "invalid DMA transfer direction" diff --git a/include/hw/scsi/esp.h b/include/hw/scsi/esp.h index 6327060c7c..3526bad746 100644 --- a/include/hw/scsi/esp.h +++ b/include/hw/scsi/esp.h @@ -111,6 +111,13 @@ struct SysBusESPState { #define CMD_DMA 0x80 #define CMD_CMD 0x7f =20 +#define CMD_GRP_MASK 0x70 + +#define CMD_GRP_MISC 0x00 +#define CMD_GRP_INIT 0x01 +#define CMD_GRP_TRGT 0x02 +#define CMD_GRP_DISC 0x04 + #define CMD_NOP 0x00 #define CMD_FLUSH 0x01 #define CMD_RESET 0x02 @@ -145,6 +152,7 @@ struct SysBusESPState { #define INTR_FC 0x08 #define INTR_BS 0x10 #define INTR_DC 0x20 +#define INTR_IL 0x40 #define INTR_RST 0x80 =20 #define SEQ_0 0x0 --=20 2.39.5