Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp396660ybc; Tue, 19 Nov 2019 03:13:05 -0800 (PST) X-Google-Smtp-Source: APXvYqzEIqarvgsvGZ3TaaHzhyOMe/ByZ64W+pmKsTyHQfoYYKcsExuG18wWQFkKw20DO3c/4TLs X-Received: by 2002:a17:906:5c06:: with SMTP id e6mr31451956ejq.195.1574161985119; Tue, 19 Nov 2019 03:13:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574161985; cv=none; d=google.com; s=arc-20160816; b=nLst5VFzPviBMB0ca84u/ccEICQJbrvhCCVhLXoob9qADiHzzZxYCozyIhHD1VvJ89 b3mNEW2jLvCSNIvh7DzoQZX70OcE7+xsl+Vs2Q34JkT3d8nrV9kv0NdOSBt9Jf9girx4 LiJcE9Ye0ZnqVwi3A1D1moDyeldoRf0GsiiJw6M0caEdmY5gTFaK09Q/wpUTp57D3JgI /80BBQnQzqQLvC9re9KGhcw653HJYuCrp+PVrq5HAuo5fwwKq61EsBlH4OJq8phNeoi5 YpPuiIbly8Ek6suBztNC5PIibOaFdA+xpsJwRCw5LCT/Ljy/qJYsHmJzl9pXCA8gLklr xiGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:organization:references:in-reply-to:subject:cc:to:from :date; bh=cR2Vu8XY3rHcsLC51DoaXQ1xYBiNKOWeFkRD7LqQdVE=; b=wZqhTxz4UsFOaHZ7Hv9Nlq8fcDdZOiPH2Vepw07+MpyMPG1YPbKLP3vAtaW3IlRGVq 4EiZ18+l4ZfhRoFjO3aWs3nmyc0E8KNbLMAtf0TDJvEqXBdciwP+g5kaNU8XwKTk4rhI RJ8QelqakxlUR4gcBwCeeSUhtJ+2urjY+n1eWrDGCuTaU0h1fXNpNkU+MQNVa3DEbQwB 1ETQhvMQNcm1o4lPJ5BnsgFRwTe7hAjibkEEJ1wcjsy1eyy4fQG9bWhKWAlrff/wm6sq dNHYEJY8zflJuhAemp9Qd3m8m6G5kAopy9yvdLJ2F6gg52+hJx801NUustSDg40v5MRw Wo2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si13977766ejt.404.2019.11.19.03.12.40; Tue, 19 Nov 2019 03:13:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfKSLKd (ORCPT + 99 others); Tue, 19 Nov 2019 06:10:33 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:4774 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726000AbfKSLKc (ORCPT ); Tue, 19 Nov 2019 06:10:32 -0500 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xAJB7llh051686 for ; Tue, 19 Nov 2019 06:10:31 -0500 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2wcf58ghmn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 19 Nov 2019 06:10:31 -0500 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 19 Nov 2019 11:10:29 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 19 Nov 2019 11:10:25 -0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xAJBAOfh45744278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 19 Nov 2019 11:10:24 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A019DAE06C; Tue, 19 Nov 2019 11:10:23 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 39272AE061; Tue, 19 Nov 2019 11:10:23 +0000 (GMT) Received: from oc2783563651 (unknown [9.152.224.42]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 19 Nov 2019 11:10:23 +0000 (GMT) Date: Tue, 19 Nov 2019 12:10:22 +0100 From: Halil Pasic To: "Michael S. Tsirkin" , Jason Wang , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: Cornelia Huck , linux-s390@vger.kernel.org, Michael Mueller , Christian Borntraeger , Janosch Frank , Christoph Hellwig , Ram Pai , Thiago Jung Bauermann , "Lendacky, Thomas" , Andy Lutomirski Subject: Re: [PATCH 1/1] virtio_ring: fix return code on DMA mapping fails In-Reply-To: <20191114124646.74790-1-pasic@linux.ibm.com> References: <20191114124646.74790-1-pasic@linux.ibm.com> Organization: IBM X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19111911-0012-0000-0000-00000367F12E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19111911-0013-0000-0000-000021A37ACA Message-Id: <20191119121022.03aed69a.pasic@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-11-19_03:2019-11-15,2019-11-19 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 lowpriorityscore=0 priorityscore=1501 adultscore=0 clxscore=1015 bulkscore=0 spamscore=0 mlxscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1911190105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping On Thu, 14 Nov 2019 13:46:46 +0100 Halil Pasic wrote: > Commit 780bc7903a32 ("virtio_ring: Support DMA APIs") makes > virtqueue_add() return -EIO when we fail to map our I/O buffers. This is > a very realistic scenario for guests with encrypted memory, as swiotlb > may run out of space, depending on it's size and the I/O load. > > The virtio-blk driver interprets -EIO form virtqueue_add() as an IO > error, despite the fact that swiotlb full is in absence of bugs a > recoverable condition. > > Let us change the return code to -ENOMEM, and make the block layer > recover form these failures when virtio-blk encounters the condition > described above. > > Fixes: 780bc7903a32 ("virtio_ring: Support DMA APIs") > Signed-off-by: Halil Pasic > Tested-by: Michael Mueller > --- > > Notes > ===== > > * When out of descriptors (which might regarded as a similar out of > resources condition) virtio uses -ENOSPC, this however seems wrong, > as ENOSPC is defined as -ENOSPC. Thus I choose -ENOMEM over -ENOSPC. > > * In virtio_queue_rq() in virtio_blk.c both -ENOMEM and -ENOSPC are > handled as BLK_STS_DEV_RESOURCE. Returning BLK_STS_RESOURCE however > seems more appropriate for dma mapping failed as we are talking about > a global, and not a device local resource. Both seem to do the trick. > > * Mimu tested the patch with virtio-blk and virtio-net (thanks!). We > should look into how other virtio devices behave when DMA mapping fails. > --- > drivers/virtio/virtio_ring.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index a8041e451e9e..867c7ebd3f10 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -583,7 +583,7 @@ static inline int virtqueue_add_split(struct virtqueue *_vq, > kfree(desc); > > END_USE(vq); > - return -EIO; > + return -ENOMEM; > } > > static bool virtqueue_kick_prepare_split(struct virtqueue *_vq) > @@ -1085,7 +1085,7 @@ static int virtqueue_add_indirect_packed(struct vring_virtqueue *vq, > kfree(desc); > > END_USE(vq); > - return -EIO; > + return -ENOMEM; > } > > static inline int virtqueue_add_packed(struct virtqueue *_vq,