Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24D1FC7EE30 for ; Thu, 2 Mar 2023 11:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbjCBLff (ORCPT ); Thu, 2 Mar 2023 06:35:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229754AbjCBLfZ (ORCPT ); Thu, 2 Mar 2023 06:35:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDE1E12F0A for ; Thu, 2 Mar 2023 03:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677756869; 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; bh=VN5H8jXkUyi7b3gGlXy5t9+JY6Ep4JlnJplI0XClENQ=; b=TfyNVyTq0bd/Hsk9NFkWTNTl7hbnJNoRCbq0nZ5oChb+1pT0T1fNc1jbhC9JKFJ+eZ2Voo Zr32PHjmORyQTtSydm/+fwz8sCTxHrRo9PmU9URFujs4dQsoQIz5J/pR+KbZ/sqdkcRy4d h4PZFtoV3pyZnrJ26WG8qrbcbX4hDew= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-427-1wwjAgUnNl6aEI5t643qPQ-1; Thu, 02 Mar 2023 06:34:28 -0500 X-MC-Unique: 1wwjAgUnNl6aEI5t643qPQ-1 Received: by mail-qt1-f200.google.com with SMTP id g13-20020ac8124d000000b003bfba5d76a3so8301672qtj.15 for ; Thu, 02 Mar 2023 03:34:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677756868; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=VN5H8jXkUyi7b3gGlXy5t9+JY6Ep4JlnJplI0XClENQ=; b=qF9oHjIhARBDXxycn/LgU3/57Wu7EfiDJmk0HzAJsQ2VYqnCAM0NXOQtiONPYWxaCQ 9U1Y1lAyl7YcJ/+NrwJ4klza2W1Bp2W6JAm35Pn7Bd52U4ESws64OXpBRanOsvbVsxP5 Dxzpb7jIYoLozwJYsP9hNh7DxYFn0mFwFTmZCf0be2zYV5++rm3kYoaGspOwYuviKVfy UcC2GD0IsDxgz90LDZdM3fa/eUcQsS6GuIC5ywFlm/JaNUkptfsr2IoKlxqTcavlrR1X 7pHUG3rrQCSeoQvHxjOzCzB9AekvecFmio5fr1B0ncrV7XiPHQuITQTkXb/Wup4zfevO fKYQ== X-Gm-Message-State: AO0yUKWZ4czXgZHB1MJCH3CEUwncs5euKO8zATzkpQx8y2vcePdjKBqr p9R/tSu8kyPToCwpaLtkOKOuX1BbOZl5tnDnFVti7SL3oKUmeOCS0IGMSVBEKyLrsu6d6NmSG71 k9onwM/KMqvSpEqTOGwxWmFMr X-Received: by 2002:ac8:5784:0:b0:3b9:bd05:bde1 with SMTP id v4-20020ac85784000000b003b9bd05bde1mr17927064qta.8.1677756868185; Thu, 02 Mar 2023 03:34:28 -0800 (PST) X-Google-Smtp-Source: AK7set/2/Vd4OA7axFE8KFaebdPNos2qTeW2fYUlVEyXvnFpPWZ0y0QARAa9MZDYbM3lH3FNvX4jMA== X-Received: by 2002:ac8:5784:0:b0:3b9:bd05:bde1 with SMTP id v4-20020ac85784000000b003b9bd05bde1mr17927037qta.8.1677756867876; Thu, 02 Mar 2023 03:34:27 -0800 (PST) Received: from step1.redhat.com (c-115-213.cust-q.wadsl.it. [212.43.115.213]) by smtp.gmail.com with ESMTPSA id o12-20020ac8698c000000b003ba19e53e43sm10084156qtq.25.2023.03.02.03.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 03:34:27 -0800 (PST) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: Andrey Zhadchenko , eperezma@redhat.com, netdev@vger.kernel.org, stefanha@redhat.com, linux-kernel@vger.kernel.org, Jason Wang , "Michael S. Tsirkin" , kvm@vger.kernel.org, Stefano Garzarella Subject: [PATCH v2 0/8] vdpa_sim: add support for user VA Date: Thu, 2 Mar 2023 12:34:13 +0100 Message-Id: <20230302113421.174582-1-sgarzare@redhat.com> X-Mailer: git-send-email 2.39.2 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org v2: - rebased on Linus' tree, commit ae3419fbac84 ("vc_screen: don't clobber return value in vcs_read") - removed `struct task_struct *owner` param (unused for now, maybe  useful to support cgroups) [Jason] - add unbind_mm callback [Jason] - call the new unbind_mm callback during the release [Jason] - avoid to call bind_mm callback after the reset, since the device  is not detaching it now during the reset - added new patch replace kmap_atomic() with kmap_local_page() since  checkpatch.pl complained about deprecation of kmap_atomic() touched  by a patch in this series - fix cast warnings when build with W=1 C=1 - added new patch to replace the spinlock with a mutex [Jason] - `use_va` set to true by default [Eugenio] - supported the new unbind_mm callback [Jason] - removed the unbind_mm call in vdpasim_do_reset() [Jason] - avoided to release the lock while call kthread_flush_work() since  we are now using a mutex to protect the device state RFC v1: https://lore.kernel.org/lkml/20221214163025.103075-1-sgarzare@redhat.com/ This series adds support for the use of user virtual addresses in the vDPA simulator devices. The main reason for this change is to lift the pinning of all guest memory. Especially with virtio devices implemented in software. The next step would be to generalize the code in vdpa-sim to allow the implementation of in-kernel software devices. Similar to vhost, but using vDPA so we can reuse the same software stack (e.g. in QEMU) for both HW and SW devices. For example, we have never merged vhost-blk, and lately there has been interest. So it would be nice to do it directly with vDPA to reuse the same code in the VMM for both HW and SW vDPA block devices. The main problem (addressed by this series) was due to the pinning of all guest memory, which thus prevented the overcommit of guest memory. Thanks, Stefano Stefano Garzarella (8): vdpa: add bind_mm/unbind_mm callbacks vhost-vdpa: use bind_mm/unbind_mm device callbacks vringh: replace kmap_atomic() with kmap_local_page() vringh: support VA with iotlb vdpa_sim: make devices agnostic for work management vdpa_sim: use kthread worker vdpa_sim: replace the spinlock with a mutex to protect the state vdpa_sim: add support for user VA drivers/vdpa/vdpa_sim/vdpa_sim.h | 11 +- include/linux/vdpa.h | 10 ++ include/linux/vringh.h | 5 +- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- drivers/vdpa/vdpa_sim/vdpa_sim.c | 160 ++++++++++++++--- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 10 +- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 10 +- drivers/vhost/vdpa.c | 30 ++++ drivers/vhost/vringh.c | 247 +++++++++++++++++++++------ 9 files changed, 395 insertions(+), 90 deletions(-) -- 2.39.2