From nobody Sat Nov 15 14:54:45 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 1750227259870727.4275616171457; Tue, 17 Jun 2025 23:14:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2l-00022v-5C; Wed, 18 Jun 2025 02:13:08 -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 1uRm2h-00021k-1l for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:03 -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 1uRm2f-0003x6-8K for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:02 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm18-0007ok-Gj; Wed, 18 Jun 2025 07:11:26 +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=q8LLQNq5WuHGwbudB5H8PvV8YdTw969EMv9g174ty7k=; b=G3NKYmhLgvkdK0yhMZL9lsGQ7e ScCl2KQdOlGK2PwFjwrPCf3ZHTRwz2PDGLXHPiAIzND09EkwfOf3J+9nXXJO9toOVnx92FVOV6wpF n1JRn/LtPYaedJBfSeRBKusXTjfDzIYavC/UUodypVnbJd/La7kOiY7dAUr5PvfM5AXRsMH6btCN6 72sMaooH14LV6oULSgyN/lqIyFtEzqCEKfSxWbTZla8LT29D2juUGr36mNPkWzuFgcCfdwDXgQ5yb FdR2Z4pQ8zAjGzLkZiBhYVKb5XhqJinfL1OVxjwDG3Bkg1Eyf8JfG1DT/FvPXQXEfSimt+0qFdPi9 9+2L3GCfSPVu5/aLbfuvrM145HWaS8lGvC7/ZfJk8n/QewXG7d6dkTowZ16BQEcYf538njSU17vPr zH3LCaYmB3Fs8jkexqhtn6gu4omclmz8KgCDK6LuK5AfU8DyQ061LJjhmdr9kvpxKCGkE4BscIkl9 itRpAuiB9yzNUOlQI26nPx8SIW2uRyXENEGuFgI+JuD1FCE/U7enpCXXiKaDY7ZB86VXu6R4Ki9iy C6ObesQrJE27k1ddEjqsBJeg2UUyzxOtjW6YcnMdMd3Cicydmd+LryFjMjhkKjfkuKrxwKe+Ujq++ LB74QRKrmckc5i/pFSXrXmGo/pnvr9SKqAO5OeHYc=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:43 +0100 Message-Id: <20250618061249.743897-2-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227261733116600 Content-Type: text/plain; charset="utf-8" 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 --- 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 Sat Nov 15 14:54:45 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 175022723079872.13967349907; Tue, 17 Jun 2025 23:13:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2w-00024g-H9; Wed, 18 Jun 2025 02:13:18 -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 1uRm2j-00022C-9Y for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:05 -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 1uRm2g-0003x8-05 for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:04 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm18-0007ok-Qh; Wed, 18 Jun 2025 07:11:26 +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=D9v47uSKLc62w6V16v9gIwfPdnVxFlgtiRE0Zg4WsaQ=; b=vrY3eSS0t4bFLuWPuf+FrcuCAG buNOuViNYdKKAJsm+tPdWqrylgBBC650hdepL4EUu9yskWMJirafYaKYIZYj/dOhObi4aKhyPGkgW 8P3t4IthTXaOhONWoDUzip/5c+1HayWNMJq6rflhirGXYllAKAi24Mo7WxOdaWXMvla20qN6MpxPQ lawE4ZUK4LpnnkN4AGuWouYyxbEoIlz31fH5SUSMdXzlIV9+fHXK+7FMI6Z1HEXoqj+w83UiPGmqt Dfmy6/4fDjtceuMMio5dXCbwbhrUBtIBuMsVwJhKvY3HGbRUBpe8YHwR4xXImWSP68w/6UbDPAPcj PQSzYPYE3rego5dZzINsC3gasuyNDU1G2lPJiCU3N4RvgA1lEQr267F6WAZ9VA023Pz9w6nNeI1BT rBtAUpsLRkeT3x7XAVWUan/rnTl/6+rL0doTo3TaDnkr4aVFWgQ4g4NIsmLni78iY9/ZMt9zEbRLJ wd7RfX+j6Jb/kxpr/s0b1cELBnRWxFJB2p2hoJCc5Q0Je2GdT/mtanY9gOBZobLWK9fU0o0pQGwyL +3UZ1lUeSKuTepePEz2UgPs05bPbBqqkgk048QxEBJsKVXLT1tPdT1WUGXBUqRmJIN88yiuLwIlzI XzD6vstCYWDP71vX/MZw9WbHI5I4ZGpCgEXmdnaWk=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:44 +0100 Message-Id: <20250618061249.743897-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227231437116600 Content-Type: text/plain; charset="utf-8" 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 --- 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 Sat Nov 15 14:54:45 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 1750227302480418.3857412762908; Tue, 17 Jun 2025 23:15:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2v-00023g-56; Wed, 18 Jun 2025 02:13:17 -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 1uRm2j-000229-8r for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:05 -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 1uRm2f-0003x7-Cq for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:04 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm19-0007ok-4E; Wed, 18 Jun 2025 07:11:27 +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=nNbqaq73wvELgQmDX95TXQpt1EGVEYkXwH7FUiKjs7g=; b=MWZL1JlcNbluPRoyP1HW59x1Vp sODclLs4sX6R5zf+PnRUfCOrMbZZwc7/VMFTV3Co3PTlVnpH4nd06p1Sw+dxkVbgiSIKe6n7rGISz DyeDEzpRJJw5uYMNsVuFgYguAmynaHr+Q11xhY7Bu7OBs951XZTf7++X9a33L5DZ+SmIYz3KvbBoa g2pi6Gpp5bDE9qL2IbT587V4Graep7fUmkguYsTbwQsfpMzSinyMiTX8WJVk6cEFnB5j3UivQ3Zri RC1bh9stLmpBgtO4AtKcoIZ2HPI+j6AQ6lZx9jrsdrJnMMDtE8oU4Wm/ih6QVd9Eo3xRhm3nFtyzW S1DHrAK1uKI9CobtRNbVNQ6qWuQIsoij9EN83LGz2dlJrGL346ep1XtjC5nEVK7U530VKc3c50NnD WnjnJ2KkvmcRSUw7S0qOEwwNa7qFCF4e+SdgIHtTSKCh5Rgb/jEc+3tny24mV06Jh4AwzSzJD5Z3x LOjiVtH2Ny9FJAZcqaBIUhLi3e5T+QezCQXmtukdUCW6ukdpj/yl3R27aM1K76JxVdYY/b6YTJNbJ efhL8sbw0XldGJtqyVgnrz4wGK8Par6ff+bnu0DgCFpSR/2xCR5hEWRxoh1n7OvdIamvH37WWBuy/ lkZIeBPaSguzHiA3pPvtcZGtknZh6YfaM3NCV2aB8=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:45 +0100 Message-Id: <20250618061249.743897-4-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227304306116600 Content-Type: text/plain; charset="utf-8" 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 --- 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 Sat Nov 15 14:54:45 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 1750227231008414.81031759937946; Tue, 17 Jun 2025 23:13:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2p-00023b-Hs; Wed, 18 Jun 2025 02:13:11 -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 1uRm2h-00021q-FT for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:04 -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 1uRm2f-0003x9-8E for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:03 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm19-0007ok-EL; Wed, 18 Jun 2025 07:11:27 +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=ODP1MRazS6AOS88cqj6SB7nCEFi/Xtx3gNCTohx08Yk=; b=srWwUtvfEStcfoWHQxiavMtvhk H8MvknHU2VEebJKP38ZyRCFxPU7CUJ/f2HIfCcadxferkk4oFOxHD1Mae2ZqR0fj0DO/DKzKFqfdS 6bMB/dQV/CHI94dEfz8TJdyVg2j3wEaqzZgYJURHtU7qhPQEkwOeP9Spt9iFSdi/JYj0b5QCwFrdj BBSfpT00wJd+FwVxvxFE0Gf6MELX6VenOGvyDMUKrdnbtmjlXc6l0CSiElpiHgmHU406+GeQPHtwh dBUckkP7+7Oruqn5A6zpbd5LeoXOZwWvvYY0l+iCdSqoQXSONk/Nn28qu9pmIuNo9jmQhAjLgsYCe 9bClAVJxGW7ndmNbEu39aM9woRQZPOh6tSAtY06e+QdTkZxWqhXWorfNdAbSiDiJcijjde7Oc8hwf 55j3xn/OvECK2G/8b+AXYqLgU4EQ3ReUyYPfcnO73MADn0d9Uxa8I7IOpmHSy5LOVL79juQKD6jlb pKXQetuOcSm9HxM0fQpKoV4RbncFDONc7Y/fHnf6YzSnDLjxYiMBM+Rl1XQVldmKIUyrPAKNQHIFi bB+XcQmKAtly4xJxDb8vg94EN6TeelZnpoGI9r+QuQGmuDH8q/ZVwfhibZDnwR7T0dpz1gJhpuBlC 7eZnWLCbfoOW6aE4qatgPsSwuCFZQ9ZaH+brL0eeo=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:46 +0100 Message-Id: <20250618061249.743897-5-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227233466116600 Content-Type: text/plain; charset="utf-8" In the cases where mixed DMA/non-DMA transfers are used or no data is available, it is possible to 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 --- 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 Sat Nov 15 14:54:45 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 1750227231620923.4998548965511; Tue, 17 Jun 2025 23:13:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2o-00023E-H5; Wed, 18 Jun 2025 02:13: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 1uRm2j-00022J-CR for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:05 -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 1uRm2g-0003xK-6N for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:05 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm19-0007ok-OI; Wed, 18 Jun 2025 07:11:27 +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=1Hk+cnruCZZ0eODjDssR0hqnYTsJleDpqgxxa3KIy0w=; b=V8Qu7vtx+DZNnVyJm6suMtD0yW 8mCoddRRs1rIkSSOQ+Pt156Jyi3MC0eXMAjdv0G8SkHy16hKOn74NEmnL/iad1MTDsmzcz4mTvj0c pdQ0WRbaaTbuDguaOT7gibDOzkfR89CZfjUvh2n9bqrajyEG2uDAfX8C7jev3X5usYbZ9WRICex7E DmFqhvp6PFEFBpbOMHpEdetkT78Jb/7Bdv6UBNPSF+nYViibslNALZo/XerA6wLmkUpL2xt1wLeYO XkTFOk1TYW9sPmSEbmkoQ/rIu1t2bIEQsPa2Tl5cxYMMw0UcE8Qt+wZuw/oUe2s1lLJy2OEhK+F0j C3sOusLfQld7PzXm20OXGytTDcwbpfjhNyP5+wRO5CjsBLrbTz55NzCRoR0zdNF+j7pZsKn7fR9Lp qyIGCjFs44z3N/C1waFDM09j7eVNdDxv30BFxZswfCauluF300FWAmSnJy8jhWAcd0IOw3G4/iSma qndHIGmgjWvotj19GgFeBuGzomjE5g2Bz1DbK8D7uC7C2kiu3Bno6oAwho/kXhavvGxc604KBNeRy 0r8SzbTkst1kczpJF86T917szxBRRhJauEwS6fyXXuMZsGMZv51vpy3Nu7noktuD4p4b1UMG04ecm IDUorRnWUuyrn6I4Y0+igxWPINsiVw4t0/ZbiOeG8=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:47 +0100 Message-Id: <20250618061249.743897-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227233440116600 Content-Type: text/plain; charset="utf-8" In the cases where mixed DMA/non-DMA transfers are used or no data is available, it is possible to 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 --- 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 Sat Nov 15 14:54:45 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 1750227291209994.9510563503189; Tue, 17 Jun 2025 23:14:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2m-000231-Sn; Wed, 18 Jun 2025 02:13:08 -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 1uRm2j-00022K-HP for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:06 -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 1uRm2f-0003xF-CF for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:05 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm1A-0007ok-12; Wed, 18 Jun 2025 07:11:28 +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=UNJNmitT/l2YN29hvkoI4t1YBG rJxM8kfDHFS9JWNApBdvgzE3XJcBsGSK9GHWQ9IVF5dZmRdd9gtblHxE7iwQxGwy/mzrNyISpiiTF Xa5FbwX7SxaCwbt/FoidjzkL/KV6YzlzpcyqY1uTCZZp35z35fYsViquxsB7iyqlYzYh5YXOo2cBW AcBV4bnw67Sz77+86Ik5LWc2iIr5arh3WTdIk6os/t9OgG0rVvwN0OCrLNMEmM0f9T+3k9O+lDeIb dKNeXeQHohQ2eajL2ufW/viLk9pNMdB0JNvYMztNMbI+qJ6REYPgOdEbXkF2L1BJCsJXLCZ9fLhtz WdV0GHR31SxLnUmXTX2qATBWeMcZYhTDIt0kmd96Oo3FOjqznmUBTC06q25jRSPIW7S7mBEOXqst2 UtZ7xacnTQgukHKfhUv95lFxscCl89VKstSYEwyWBBS2tWgCHiH0TCkoH5GxHPkozJ00bSmk/hRt8 3hSy3aHVDK04Z0N6Zd8YcmctUHGpCLaYZdNSRPSUQgwnNa2cvBBrgkPGU2fq4KQ+cwG+vU0MQH7IU uQKAN/UTCUjKS5goA6QOxZOaTwB8EgxX5emfIQwvqyoHIZn30024XVLYZpqDjS80G6ybFWTAICkJl lgXGucnHM8ik8oY2dudA9kSjKYZcd4kJieFCxiUf4=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:48 +0100 Message-Id: <20250618061249.743897-7-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227292354116600 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 --- 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 Sat Nov 15 14:54:45 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 1750227345157468.42128508374617; Tue, 17 Jun 2025 23:15:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uRm2r-00023f-CM; Wed, 18 Jun 2025 02:13:15 -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 1uRm2m-000233-BZ for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:08 -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 1uRm2g-0003xO-8Q for qemu-devel@nongnu.org; Wed, 18 Jun 2025 02:13:08 -0400 Received: from [2a02:8012:2f01:0:737f:96a4:fe2:308c] (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 1uRm1A-0007ok-FK; Wed, 18 Jun 2025 07:11:28 +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=0OnWTZJMKp+lkn/PhH4PiB08zk siwDtvcbC2c7j3hHURrZX8D03ioJCTt+DsWUINu+cde2jiLntq1qRYPnmCXRSB8SMmyquuKYGhsKF v+N6L825RcGFAO5+q1AwnMr5AOdiAlMls+qMy55z9Hy52687I03+YvVgrnUMZNdDNLh+GGwbK82Oy C8OyAWV+2daBUUYoik0C/p/bYrhibg3mQDeO6D+S/07Xc/AZ+z1rLZfmrjKQYqlhwJRjMu6NEZNtz kumVn/mmuB+YKXe3gotE0rOto5NBeEmst7K6efmQrB5UE4nQqokmK/ovGfkXpXjBxBOVSXEHbCXTO xpYCkcZT5Vr4WVm+uzF/+JA0FD26ifZPdeGzSr6Ux38fhMCioJxL28UsxmJgH+jEQ2PxmsZHX/bGX 2Utw5ufdZmAazRWL82xJFxmSQAmPI+yaprSahjPBMcvHZVl7fsmwAwy4Ux9zlJddmiTYV0NZlbhSS s1OFzgPf2A21ePxWKxulGxU+HojoIcDQpPlI2iHKQD48aPykTUqLSporNyYMrdJNHGn2L5w6EsOLM 2j0kh9suNl1fHIqIy2lbGKoSg5cH7ZASzRkwbcohQ8zsr66eSjoafhyu8qdFvMTHz11XyVyLocksC hAYsXhVaNXlI56DbRh7vdVc/Gb5S3veUXP6pgSzfM=; From: Mark Cave-Ayland To: pbonzini@redhat.com, fam@euphon.net, qemu-devel@nongnu.org Date: Wed, 18 Jun 2025 07:12:49 +0100 Message-Id: <20250618061249.743897-8-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250618061249.743897-1-mark.cave-ayland@ilande.co.uk> References: <20250618061249.743897-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:737f:96a4:fe2:308c X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v2 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: 1750227346807116600 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 --- 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