From patchwork Mon May 22 07:39:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 97165 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1275349vqo; Mon, 22 May 2023 00:53:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7yaKomjPMfTRFXbQrm5j3iHkNKrY6LrxL0P7ZlyZJPuvG/5glCYVAXuv/k15l8CAKD00gW X-Received: by 2002:aa7:8893:0:b0:643:849a:dd06 with SMTP id z19-20020aa78893000000b00643849add06mr13283598pfe.34.1684741980883; Mon, 22 May 2023 00:53:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684741980; cv=none; d=google.com; s=arc-20160816; b=ynU63dCOH5RP7y7wRRqsyu9SLCEw2sxI+PHn1eK+FQCW/Oq23FWc4Tw3zZizt+vbqM 4WqLfPK+TixWr5rlFNNeqwYQ2cFHdiIeHXFDjnPtZIKmcduvUWV9AQ2Tl9b84BbOZ/8a nEWC/fnsIBcGxh71FnMcoUCyMYlcovIdPpxP5np5PF0f+zSmB2qEDqDCyRz6SXWxl4ay gPua8akdnktAg/b6raFhHbmb9J9DjPRGVtFT2RV8nzLKDV+rPSGMOpORvHxU2SERXsPD v4KjStsrzYjnaJ3uy2d187miUe+enW32XqqkFmei3wm6+D0XzhekoBWq7REEvjL3yS4c JagA== 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=igltWeKmorgVWzwhU5OIAduVRvDTNdsf6zEVkCG3inE=; b=CvmU+/N4WK2Dwz+hC1EOVSMdTwACudwtDABJWZ/uW4PXXu+WqhnV8TD2fjT31lFl4x BCSaEGne328zZyW7pHXXzvHKX4khiAhkflTL28vfVIdUZiYnRBjE0+eBcB/mq6QwZipm heCgp5UvmDh2yg4yWam39ScEvAG/UIsbgwc3ilJB/mtNEXLGfASsE0bKbMbCD7WNJnJp NJ4EgwhSiuswS11dCqY8Dzc5yI1xAcNezXD/CFjOc0FWz0y3iqOe2+0MXz/btpHAUe3G Z6eXnvBqqLyaxOdlA6K1CnM7l2+JSnF5r3b/DkZ+V7nXTzBMfbsNktSPJdekOhpI5Z7W iQQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=Z61DpywJ; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o8-20020aa79788000000b0063d2eae52cdsi4342129pfp.224.2023.05.22.00.52.46; Mon, 22 May 2023 00:53:00 -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=Z61DpywJ; 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 S232729AbjEVHpY (ORCPT + 99 others); Mon, 22 May 2023 03:45:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbjEVHot (ORCPT ); Mon, 22 May 2023 03:44:49 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF6CBAC; Mon, 22 May 2023 00:44:47 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 9F45B5FD4A; Mon, 22 May 2023 10:44:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1684741484; bh=igltWeKmorgVWzwhU5OIAduVRvDTNdsf6zEVkCG3inE=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=Z61DpywJ0aT4k7vpr4q4nrwqmpD6kiZ2SfnxKz+zTSGjz8n1yOYZVCaCymWCYnu0I tk/sZtUpfdgvkalLW3u+ICAbImUVU7OCm/VDJsgUSoul2+wv5LyYsMJYD2YKj1AqsL IZflFp3NnZNy8FOQ1PT7O565J8E/eigwsSi6Au/k/TZHTQws9IvO0Sk7QXGgHFE/1i 9XQ8f0ccExKrj7cQqYEMRYVALE0fOkxhctC0gccM8DeSxud/WieJ1Fx7zp8NJcLVF5 C2v22Amx8X0YiR7MtEg9tzQvMMnw/2WDvzQM8AR1CDs7q0cJFzv6w/eKJBSET2HKtu fhu1eC0hUsiyQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 22 May 2023 10:44:44 +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 v3 02/17] vhost/vsock: read data from non-linear skb Date: Mon, 22 May 2023 10:39:35 +0300 Message-ID: <20230522073950.3574171-3-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> References: <20230522073950.3574171-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) 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/05/22 04:49:00 #21364689 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766580007168166737?= X-GMAIL-MSGID: =?utf-8?q?1766580007168166737?= 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. It changes call of 'copy_to_iter()' to 'skb_copy_datagram_iter()'. Second function can read data from non-linear skb. See commit to 'net/vmw_vsock/virtio_transport_common.c' with the same name for more details. Signed-off-by: Arseniy Krasnov --- drivers/vhost/vsock.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 6578db78f0ae..b254aa4b756a 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -156,7 +156,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, } iov_iter_init(&iov_iter, ITER_DEST, &vq->iov[out], in, iov_len); - payload_len = skb->len; + payload_len = skb->len - VIRTIO_VSOCK_SKB_CB(skb)->frag_off; hdr = virtio_vsock_hdr(skb); /* If the packet is greater than the space available in the @@ -197,8 +197,10 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock, break; } - nbytes = copy_to_iter(skb->data, payload_len, &iov_iter); - if (nbytes != payload_len) { + if (skb_copy_datagram_iter(skb, + VIRTIO_VSOCK_SKB_CB(skb)->frag_off, + &iov_iter, + payload_len)) { kfree_skb(skb); vq_err(vq, "Faulted on copying pkt buf\n"); break; @@ -212,13 +214,13 @@ 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); + VIRTIO_VSOCK_SKB_CB(skb)->frag_off += payload_len; total_len += payload_len; /* If we didn't send all the payload we can requeue the packet * to send it with the next available buffer. */ - if (skb->len > 0) { + if (VIRTIO_VSOCK_SKB_CB(skb)->frag_off < skb->len) { hdr->flags |= cpu_to_le32(flags_to_restore); /* We are queueing the same skb to handle