From nobody Sat Feb 7 07:30:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1639677328; cv=none; d=zohomail.com; s=zohoarc; b=C2qSdc9LnLGqx2Iua8GcmnT8t1lSbLlOPy/kHeKg/Dn/2F6tPQI27kzUYeQtgNNXxKM50agXPgExTwGK4nIF93WOUK7QrM+7eRDZyYI8ieGGkDHZsYMroc5oTa4cpKJnD5bgR5jB7OPFaEzvSb9EXMqEEM3n9t0X85Lh0ubIqsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1639677328; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=EBEhhvwmrK3INOwJ0KjtvMl1VgesDG36wHzC7bVJ4nc=; b=XGztkE5haQp1Gdbl7Y2unmp3IrY8K6pIfk5wO/MYitEviOGy11IxpWLig/nU9yf2JCL97JRznMk1VfRRA3x7oRGoX8YlUunKhmqT3Wr4iIu7oLv67Mr9JgPC4t2qz+QNMHmZ8fLxguNgmylcCSDrdCpbixahuz1usjXyMU42808= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1639677328567942.8782746956524; Thu, 16 Dec 2021 09:55:28 -0800 (PST) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-148-DV4HSQChN12VpnHEPVnDlA-1; Thu, 16 Dec 2021 12:55:26 -0500 Received: by mail-wm1-f70.google.com with SMTP id b75-20020a1c804e000000b0034569bde713so1602942wmd.9 for ; Thu, 16 Dec 2021 09:55:25 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id w8sm5509969wre.106.2021.12.16.09.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 09:55:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639677327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EBEhhvwmrK3INOwJ0KjtvMl1VgesDG36wHzC7bVJ4nc=; b=Kg+iOy7ECK4wX4yBQQD7NEcrp7cgByqmBDOjhkJiuXjbMLSl6YGrgboxL7la9Hsvnhkewl 1UBnPuO0+TD2BSw59G6yuEtO1uV5pYk0FlZPkGyQye4r1kd6vOfrLh4EO35PKGgq7zVBN/ EX5z0xR5g6Z9c8WftZ4zOcQgDOQCPgU= X-MC-Unique: DV4HSQChN12VpnHEPVnDlA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EBEhhvwmrK3INOwJ0KjtvMl1VgesDG36wHzC7bVJ4nc=; b=dxJaitSW1bJjQ5VZ8YvjKkALDW1M+oAHNByqKFMj5NEVLshb7LLiVtUHble+m9O4CR asr44gbUyfdlbY/0n8J9+YcLC3Fgvi4aeSdib7fI+QFMmS+iZ4l1/rYpMdsPeoNmR8lQ 3yeadMkQo7lDWq6Hc/DQ2U+ZRNJKlx2mp3TzoAiKubsnwBebMiSPvSuLBvhG0Ml1Q7V4 IaXHeqgNH9uMUWJm9JKxeYFNINQrzuqysOFYiAkOXgYQ0xYOaKZDLRhKdTUUI86LvL6W 41zIPtZsgr9q3sWE9dgTxde/K8OeqIqWXVfmDtV+2jcDHSoB6G9vZ/zuf6ivz9IGu/6R b59A== X-Gm-Message-State: AOAM530/MDPW4bkBzRXXq63Li2bmhRRr69RkbfOVLMtOapwp+Q5qBW83 WyzJXNBeCIWx4A1vgbIsG0URxygSPPc7eDUGH3kGVLD7+22LootoI52KU8Ve1lM9JSci5y1oBAO a8/rAlxfW1S66oQ== X-Received: by 2002:a5d:6da2:: with SMTP id u2mr10123205wrs.273.1639677325001; Thu, 16 Dec 2021 09:55:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyKq/OOw3vRa7EiIkjaYarlgIoTYwbR/cYUfPpK/bcCcI/DiN36NRfauduaSSnaUZAePdgY8w== X-Received: by 2002:a5d:6da2:: with SMTP id u2mr10123187wrs.273.1639677324855; Thu, 16 Dec 2021 09:55:24 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Klaus Jensen , Qiuhao Li , "Edgar E . Iglesias" , Keith Busch , Li Qiang , Jason Wang , Bandan Das , David Hildenbrand , qemu-block@nongnu.org, Peter Xu , Mauro Matteo Cascella , Peter Maydell , Alexander Bulekov , Darren Kenny , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/2] hw/nvme/ctrl: Do not ignore DMA access errors Date: Thu, 16 Dec 2021 18:55:09 +0100 Message-Id: <20211216175510.884749-2-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211216175510.884749-1-philmd@redhat.com> References: <20211216175510.884749-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1639677329161100001 dma_buf_read/dma_buf_write() return a MemTxResult type. Do not discard it, propagate the DMA error to the caller. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Keith Busch --- hw/nvme/ctrl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index fa410a179a6..604ed0aea0d 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -1147,15 +1147,16 @@ static uint16_t nvme_tx(NvmeCtrl *n, NvmeSg *sg, ui= nt8_t *ptr, uint32_t len, =20 if (sg->flags & NVME_SG_DMA) { const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; + MemTxResult res; uint64_t residual; =20 if (dir =3D=3D NVME_TX_DIRECTION_TO_DEVICE) { - dma_buf_write(ptr, len, &residual, &sg->qsg, attrs); + res =3D dma_buf_write(ptr, len, &residual, &sg->qsg, attrs); } else { - dma_buf_read(ptr, len, &residual, &sg->qsg, attrs); + res =3D dma_buf_read(ptr, len, &residual, &sg->qsg, attrs); } =20 - if (unlikely(residual)) { + if (unlikely(residual) || res !=3D MEMTX_OK) { trace_pci_nvme_err_invalid_dma(); return NVME_INVALID_FIELD | NVME_DNR; } --=20 2.33.1