Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp515713ybc; Tue, 19 Nov 2019 05:07:35 -0800 (PST) X-Google-Smtp-Source: APXvYqytoCrvrKIXL85wEIAXVKOTofrJFUcbXb1hbyTSyGBYAvV2YnS+O8Cta1zunohtGkspaPE1 X-Received: by 2002:a2e:b5c4:: with SMTP id g4mr3840171ljn.169.1574168855380; Tue, 19 Nov 2019 05:07:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574168855; cv=none; d=google.com; s=arc-20160816; b=KBnPKfCTytCQCKS8j9Rz4dF4i57PRpwr3syVsKs8QDBL4cZmF+Rin3+0SkqvZCRpX4 kLBsHmMxDf/qcW155w7sWQJLgw3K75a9uVH7Ly6G5LRR700pOjgtmEs2lk4QkJ8j/z7p RajueYdg+/prhHZJRQqFmIke9UoMB03+VVSU3FL4Y/ZiCpdddpI8FOUgmB1nC6NYyBs0 JO0kXhRghjs3dK7yK0SRluix/46mq387uZUVnKABz3LySxjja3YrYJrT6UvXbJtWbiNi GNBruQEfOb+fAtMSTyuAgRjEVCo1xVOMgV4jA1BAnkUog//TXM9a4JeIKRzaBOKuXdBa TOyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:in-reply-to:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature; bh=1u2WSPm0ixutLDhHPQFbAB3e6YssvhaqnOP7EqAOnTM=; b=WFYiZ+VNzpVlzrnA13a47Xmi5a05z/CCHtzHQiRGf0bvOSdqI4yAZEJSTqudsmmLmH S+VUCTNFnhnPF/kIX9M7CkrkW7uCat0QxD4/rokoJNyYn3sZ4Qkmyx8l7mIIeZvdn6aH zlSV71yzQJTdbFbSbjw+J3cdPk27dRr8S/inifi/UKwdpe2dXA4Kc2OJaHQ7gIG775GC MZyqlN6RFh6HBnS4nnmiie+5tAOxeQAgNA8BZZCmcuxzcC6nt2OaYrG8+hd9Rtvjk4KB 0h84frgBfdXOp6L8tfX20xLVVjiWWGYQ9Q2XAZQrzxESsV3osyuOCtxdSlwcnO73AXg3 4H4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b66DK+eq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d20si13735324ejk.173.2019.11.19.05.07.08; Tue, 19 Nov 2019 05:07:35 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=b66DK+eq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727903AbfKSNEl (ORCPT + 99 others); Tue, 19 Nov 2019 08:04:41 -0500 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:29240 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727638AbfKSNEl (ORCPT ); Tue, 19 Nov 2019 08:04:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574168679; 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=1u2WSPm0ixutLDhHPQFbAB3e6YssvhaqnOP7EqAOnTM=; b=b66DK+eq2+StNfml/T+qhpItbk3H8heiQd72aVVVBrLMA/ACwbHvhUqUMSh6VEwXn//wiv ZjWzBUTD7Gc4ZP192g1mQuKqZjoIU8UBvejrZ0EJRYJeB9XtchGOAYvsxRbxYpKMzEN+/o GfxCpXNaqz+8HDqrF3AaHG4MmoKAzqU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-21-5s073ncJMM-AfqiUC9Kk2g-1; Tue, 19 Nov 2019 08:04:38 -0500 Received: by mail-qt1-f197.google.com with SMTP id v92so14530268qtd.18 for ; Tue, 19 Nov 2019 05:04:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wVazQdPSJMsHL4OK3xhjgyvdKos3XKZz6J3/eg1KCyU=; b=DFkoeiKbmWOtH/QoAkYKkaqYOuqJdI3+5UoySB6GvFHwHBKZDzMuv1eeqfDPn6nuG3 gtg7q49lB6WYQ53enKjTFdIV+7PpjS0jOLEnPjmRZnCVp+vx5JQrqTizRAkHefxasv+/ l5d3fxhZzZ8ypUk5svZKuEmgB1Kk66MWrYm9owy/g/2480ENWhcjUakQ4V6lgcG2aARb hwkjfKp/TJjTiZnXfmVfk9OYROPVgQ8uBOc7/ewuxUjufec3PNogG6kuDZhbHC75XMt/ JsG22ypS7a4mCKCCaQkveykYl3tdKdsE3AeGNSaZ1nj85KQD/rYdwQPrB4BQ04cJUWKg y/9w== X-Gm-Message-State: APjAAAW33N7szQdetFGPINCo2wKsl3wi2D5vlJMku47cvlynPOp/GEFg GzlFrGw+CT09bboNM0IU5aGV8WTcRs7EPk072Q/HsMKob+oych62+HAl8/BZWmIu32KXT08R+eb ZFVn1UMFBkaUtlXGPGsgUfrMS X-Received: by 2002:a37:9bc2:: with SMTP id d185mr28179241qke.299.1574168677411; Tue, 19 Nov 2019 05:04:37 -0800 (PST) X-Received: by 2002:a37:9bc2:: with SMTP id d185mr28179213qke.299.1574168677150; Tue, 19 Nov 2019 05:04:37 -0800 (PST) Received: from redhat.com (bzq-79-176-6-42.red.bezeqint.net. [79.176.6.42]) by smtp.gmail.com with ESMTPSA id w30sm12605312qtc.47.2019.11.19.05.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Nov 2019 05:04:36 -0800 (PST) Date: Tue, 19 Nov 2019 08:04:29 -0500 From: "Michael S. Tsirkin" To: Halil Pasic Cc: Jason Wang , virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, 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 Message-ID: <20191119080420-mutt-send-email-mst@kernel.org> References: <20191114124646.74790-1-pasic@linux.ibm.com> <20191119121022.03aed69a.pasic@linux.ibm.com> MIME-Version: 1.0 In-Reply-To: <20191119121022.03aed69a.pasic@linux.ibm.com> X-MC-Unique: 5s073ncJMM-AfqiUC9Kk2g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Will be in the next pull request. On Tue, Nov 19, 2019 at 12:10:22PM +0100, Halil Pasic wrote: > ping >=20 > On Thu, 14 Nov 2019 13:46:46 +0100 > Halil Pasic wrote: >=20 > > Commit 780bc7903a32 ("virtio_ring: Support DMA APIs") makes > > virtqueue_add() return -EIO when we fail to map our I/O buffers. This i= s > > 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. > >=20 > > 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. > >=20 > > 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. > >=20 > > Fixes: 780bc7903a32 ("virtio_ring: Support DMA APIs") > > Signed-off-by: Halil Pasic > > Tested-by: Michael Mueller > > --- > >=20 > > Notes > > =3D=3D=3D=3D=3D > >=20 > > * 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. > >=20 > > * 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. > >=20 > > * 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(-) > >=20 > > 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 virtqu= eue *_vq, > > =09=09kfree(desc); > > =20 > > =09END_USE(vq); > > -=09return -EIO; > > +=09return -ENOMEM; > > } > > =20 > > static bool virtqueue_kick_prepare_split(struct virtqueue *_vq) > > @@ -1085,7 +1085,7 @@ static int virtqueue_add_indirect_packed(struct v= ring_virtqueue *vq, > > =09kfree(desc); > > =20 > > =09END_USE(vq); > > -=09return -EIO; > > +=09return -ENOMEM; > > } > > =20 > > static inline int virtqueue_add_packed(struct virtqueue *_vq,