Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4756374rwr; Sun, 23 Apr 2023 12:32:29 -0700 (PDT) X-Google-Smtp-Source: AKy350atB6iKGnFmC41Rw4EqPMLLIebbi3qkzVhqWY1Ula2jH8YSd+93fEFavzYSPV6tRA48QzwW X-Received: by 2002:a17:90b:f89:b0:247:13f5:47de with SMTP id ft9-20020a17090b0f8900b0024713f547demr11605073pjb.44.1682278348842; Sun, 23 Apr 2023 12:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682278348; cv=none; d=google.com; s=arc-20160816; b=Tvib1PgyfEXqlirZaWa5PGFyq8x2rbbR/qY7q3KJ9SqMaElTcptfISpHieZh3BRpgg 24KF9yI4NJz/NToKR88flhJNTHPrEYXDRxbIfEx9cgBdDYjiMA5VKoC7BC5s72elTKwt K7C9VLPdnRlcxHt90uTJp6K0/UHx19MpbFF4JdnX4tKk5Fx92G18uYWILi5lTP+dZKSU EZJKP7xKX0B4epLVW3BR96hmYODcKLly3t8QJLo3jxVqW+gsFn6c6G2tKJxkRXAiVEhy 1B03BUb4QLIwdIMO+fqcVVPYrGya4CXcmJEZv8nXV+OQCmkS7ilVJr0PptGdyXoxVU7j f3tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=XExB9Kow9SS0d9XJh7TqIuND1hr0gu/engpR4A64Lyc=; b=ixJrxTRM/A4WD4aVd2vYSdm4ZvZwAIRk/4ZAN5nR/CMonUs/e5qvnnl20RlU4+8LHQ E1Yp12mrTe4fb87ckJJquI0L0SkwSUcHPGcX9OzzpNJLcZjn1CapGJS+8vemCGtmXmRx XlQTk+0mYuH5FUsZmmVLBcflXg8FDuc66b1JwF6ESztslT+0SxCPUtuver/++JdyZYhZ YzTR9Tg4pPQG2htVYRhmidnVbHis8F7Sg4mxUd2vaWVkHH7hH3U+WQEGq+Oe2gSWqrPp vuWR/0zc+mQlsLBtDdCfQufZPqxumNpjLbmCy8SzLqkicL6gVIxdSJXtiXjcKBCATA2T zDFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b="X/bZIwe5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a17090b010d00b002496cedea8esi9584485pjz.24.2023.04.23.12.32.14; Sun, 23 Apr 2023 12:32:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b="X/bZIwe5"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230227AbjDWTbp (ORCPT + 99 others); Sun, 23 Apr 2023 15:31:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbjDWTb0 (ORCPT ); Sun, 23 Apr 2023 15:31:26 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37358E68; Sun, 23 Apr 2023 12:31:23 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 2E8365FD0C; Sun, 23 Apr 2023 22:31:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1682278279; bh=XExB9Kow9SS0d9XJh7TqIuND1hr0gu/engpR4A64Lyc=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=X/bZIwe55jdH2NExosg3J+Iw19MR3DHcCjmw8Ea0ezbbSGk3vvZNJQiAHa5iouzCH qK5dAjXFLqfOK1VWkggxaFPc74VJktlv52Sec955qL7FN5f9w61RVNKzmGxO3QtI/T MmJ9b/7kyZv+9Cmol3FLkMSohtakkdXyEaHa033WJwK0pKMthZBbPj/3eWL442Ww10 KEl2bLvVwKQRalZix6K1HuCwhBek+fyCAGr0XvGatGNDMI6QqM6HXkpkFNlhcvGw9L hfQ7DZyQeIEF/Otf8fJAXABkKAhwW2nopclEq03uNA973L95EtQ0HPE7BU1pzEEr6N 29fsQVpCHpSFw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sun, 23 Apr 2023 22:31:19 +0300 (MSK) From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v2 02/15] vhost/vsock: non-linear skb handling support Date: Sun, 23 Apr 2023 22:26:30 +0300 Message-ID: <20230423192643.1537470-3-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230423192643.1537470-1-AVKrasnov@sberdevices.ru> References: <20230423192643.1537470-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH01.sberdevices.ru (172.16.1.4) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/04/23 16:01:00 #21150277 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds copying to guest's virtio buffers from non-linear skbs. Such skbs are created by protocol layer when MSG_ZEROCOPY flags is used. Signed-off-by: Arseniy Krasnov --- drivers/vhost/vsock.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 6578db78f0ae..1e70aa390e44 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -197,11 +197,20 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, break; } - nbytes = copy_to_iter(skb->data, payload_len, &iov_iter); - if (nbytes != payload_len) { - kfree_skb(skb); - vq_err(vq, "Faulted on copying pkt buf\n"); - break; + if (skb_is_nonlinear(skb)) { + if (virtio_transport_nl_skb_to_iov(skb, &iov_iter, + payload_len, + false)) { + vq_err(vq, "Faulted on copying pkt buf from page\n"); + break; + } + } else { + nbytes = copy_to_iter(skb->data, payload_len, &iov_iter); + if (nbytes != payload_len) { + kfree_skb(skb); + vq_err(vq, "Faulted on copying pkt buf\n"); + break; + } } /* Deliver to monitoring devices all packets that we @@ -212,7 +221,9 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, vhost_add_used(vq, head, sizeof(*hdr) + payload_len); added = true; - skb_pull(skb, payload_len); + if (!skb_is_nonlinear(skb)) + skb_pull(skb, payload_len); + total_len += payload_len; /* If we didn't send all the payload we can requeue the packet -- 2.25.1