From patchwork Fri Jan 19 11:34:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 763931 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a08:0:b0:337:62d3:c6d5 with SMTP id m8csp399480wrq; Fri, 19 Jan 2024 03:43:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHVhGpH7M151RSHoU8oXHY7dTU2mUo/1DhdKCyvKOzoO2RKuRsVKHfKeU9QkkaXtVz/YcRe X-Received: by 2002:a05:622a:3cd:b0:429:f3f5:ac9b with SMTP id k13-20020a05622a03cd00b00429f3f5ac9bmr2721689qtx.54.1705664603497; Fri, 19 Jan 2024 03:43:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705664603; cv=none; d=google.com; s=arc-20160816; b=WBDUtGEXOpA+WfmII/HfWC0ym9gbnH9dnrGaSqN6KC8+yBdVsU5u/Pyzy0Pc2g/WPk N+Sta11ZG8K/c37YGrbm0LIwUQBzRAx2K2u1JKvlfW2r2OBl4SzhG4Rq/UtvXc2DU9HC 4uVmuF04rQQdZzChE8Ox8zQZjlpnTZbZ/SW8RVoc7ox42tpzvkKvDIRGxgZzvlCt3Vwf a+D0PQrq5qbfxZy2mJJ+c3Xf3uX+bpKx8n35QmxYqPaWuRLsFNRXaSvMpqMGm5jHI7eG 7eCJYlsnb0hdd8mik05J8lXZWwejCBGlLh2AQaTKcZyg25fb9KNoKFCL6wd3tgbbvy/Q VTFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dFDI//XvTpn1St0hBV0sdqL1iHcD9DD5+xWDU4qjjTU=; fh=AgN8TvM7pMmL5RKrQhAJxXwOmBywzcClhFxW1SQC+/4=; b=woqp+APejrzgaFgyNbeCnktTqw3eOeLtaH9BAXvA0N9Wx3XlU44GmRerdvrXLwJJXW viQ3Ux7BEYgcfS5d8iuPOcaWTs5wy1PiXWyLBhCudMtyOFK6AbAduv8bVQS+XYlkmaZx FrAO9F9lHvfhlnkvVN7DWWiuCrvjpvpTIxMUWgxZ0v/jhSCsy+PBd/NoWRIaMc0YFuVZ tHb169fHe/a1kaPR6LtpoOYaSmTeyLUSTqERTAxiUsILV5XNuOXbkK9JO58cZ5OkA1lH PgSj9YU3I17nE7t/iy42Xu/cqf+zhER3cPR2Hn/qaKfZR0bZxSk5kRydYuW49G7Ozs2W /4mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdGn9JtO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id b4-20020ac87fc4000000b0042a26a6d43esi971961qtk.101.2024.01.19.03.43.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Jan 2024 03:43:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pdGn9JtO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rQnBe-0006Zh-Kd; Fri, 19 Jan 2024 06:37:26 -0500 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 1rQnBc-0006Fj-96 for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:37:24 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rQnBZ-00030u-2R for qemu-devel@nongnu.org; Fri, 19 Jan 2024 06:37:23 -0500 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40e913e3f03so7593235e9.3 for ; Fri, 19 Jan 2024 03:37:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705664239; x=1706269039; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dFDI//XvTpn1St0hBV0sdqL1iHcD9DD5+xWDU4qjjTU=; b=pdGn9JtO76ViFOkGKsvfbXZ4CWo1qTx3bP39Kqzb9rUhmPkIPIgGISZl/OR85c3ZLB aw3A8+20jAS5p49HNSu7Y8f860kaNvQY//Xs8uG7+yPgOqu94HHPZFEw2KONo3fhG/QA ztyjOcX3oyODeAJfmdbmPLRwAmae/xVbbOd7VjeMqgJlkN2p52XimtI6u7meeu3KCIoB 3lieDp8R2VeAuXJcVG8D+d/h0o5Ei6Cvwkmtlq3IvFWIox3CvivMXOQNAgBfy3q/m1Qe MSnGyXDHmwwm1yqsCKX/SxvAooIvccs80g2TBOWZjh/9OZVxrksr/xUgPAZhzHimYJ6R C1oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705664239; x=1706269039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dFDI//XvTpn1St0hBV0sdqL1iHcD9DD5+xWDU4qjjTU=; b=XGbHnLcjeHCaSIv1yJazXqIqmc8QPVDOUEq+OwUnVdn1GbnmShyx4Vu3UmDfZKe2Ob foz0AfJ1YzN+zgF7PiBZlLcYlGidDZfgicoCY8NccKKo6FMkFb4i4V5kAyH6D8HNWyhP ev1cL0gO9jlFaxXX4LRXO/ky1OKZEedp7ikRLhgZG1URgz8GkOhnlsChCEke1a9d2uwL jZUGhzIPSu/m/gMLjSyndhPqkvGpM0QmSQ0zOMIyrq48OKd0FE5YPb1QF5Xh53mDgJiJ GcNYKxwg+VQgKJZ/28azxBQhLIl3tjDMVox3xXjepPe85a1C8yTBo+e1un7Q7reQi5dh 0MTg== X-Gm-Message-State: AOJu0YynKuICgFfg2KB3Nl3o2bpT+Ud9Ax82Di2MurmD06ydJxiQV8Lz Wfjc9QKE1C0OTbvna0kCu9t7M11ke2oV5lMwDMUGgxf1A0wFTgntCYPv5BtUO7dalLSQnSG8zTO WrS6e0A== X-Received: by 2002:a7b:c311:0:b0:40e:4252:e26 with SMTP id k17-20020a7bc311000000b0040e42520e26mr1417146wmj.69.1705664239333; Fri, 19 Jan 2024 03:37:19 -0800 (PST) Received: from localhost.localdomain (91-163-26-170.subs.proxad.net. [91.163.26.170]) by smtp.gmail.com with ESMTPSA id c11-20020a05600c0a4b00b0040d53588d94sm32738791wmq.46.2024.01.19.03.37.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 19 Jan 2024 03:37:18 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, qemu-s390x@nongnu.org, qemu-block@nongnu.org, qemu-arm@nongnu.org, Mark Cave-Ayland , Guenter Roeck , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Fam Zheng Subject: [PULL 29/36] hw/scsi/esp-pci: use correct address register for PCI DMA transfers Date: Fri, 19 Jan 2024 12:34:58 +0100 Message-ID: <20240119113507.31951-30-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240119113507.31951-1-philmd@linaro.org> References: <20240119113507.31951-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Mark Cave-Ayland The current code in esp_pci_dma_memory_rw() sets the DMA address to the value of the DMA_SPA (Starting Physical Address) register which is incorrect: this means that for each callback from the SCSI layer the DMA address is set back to the starting address. In the case where only a single SCSI callback occurs (currently for transfer lengths < 128kB) this works fine, however for larger transfers the DMA address wraps back to the initial starting address, corrupting the buffer holding the data transferred to the guest. Fix esp_pci_dma_memory_rw() to use the DMA_WAC (Working Address Counter) for the DMA address which is correctly incremented across multiple SCSI layer transfers. Signed-off-by: Mark Cave-Ayland Reviewed-by: Guenter Roeck Tested-by: Guenter Roeck Message-ID: <20240112131529.515642-2-mark.cave-ayland@ilande.co.uk> Signed-off-by: Philippe Mathieu-Daudé --- hw/scsi/esp-pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi/esp-pci.c b/hw/scsi/esp-pci.c index 93b3429e0f..7117725371 100644 --- a/hw/scsi/esp-pci.c +++ b/hw/scsi/esp-pci.c @@ -275,7 +275,7 @@ static void esp_pci_dma_memory_rw(PCIESPState *pci, uint8_t *buf, int len, qemu_log_mask(LOG_UNIMP, "am53c974: MDL transfer not implemented\n"); } - addr = pci->dma_regs[DMA_SPA]; + addr = pci->dma_regs[DMA_WAC]; if (pci->dma_regs[DMA_WBC] < len) { len = pci->dma_regs[DMA_WBC]; }