From patchwork Fri Mar 24 15:35:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Garzarella X-Patchwork-Id: 13186935 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 4F7CCC6FD20 for ; Fri, 24 Mar 2023 15:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbjCXPhm (ORCPT ); Fri, 24 Mar 2023 11:37:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229938AbjCXPhe (ORCPT ); Fri, 24 Mar 2023 11:37:34 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9A9EE057 for ; Fri, 24 Mar 2023 08:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679672181; 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=Z/Kz7kV+UiInmN3q36fZWIJQ0sjJV/FHyS/DppuKTvQ=; b=g1raZwpw3I/AzdtolaKWO8kGTYrFdcB5nyzAqPR5sQouRAaUGfj1RQlFppoKhW6TGjbohJ vLgvrPcqFLAacdA83nDYj4A9ztKcAFEILOjKIsUD6aSAwIZeKMIH4zA8arCVN/9Vt4486x BXfDCgMbQ0AiYJq0Zdms8npX+g1qcmA= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-372-62KWyMmFPfevexvsWS5fFA-1; Fri, 24 Mar 2023 11:36:18 -0400 X-MC-Unique: 62KWyMmFPfevexvsWS5fFA-1 Received: by mail-ed1-f72.google.com with SMTP id es16-20020a056402381000b004fa3e04c882so3734846edb.10 for ; Fri, 24 Mar 2023 08:36:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679672177; 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=Z/Kz7kV+UiInmN3q36fZWIJQ0sjJV/FHyS/DppuKTvQ=; b=VljSbGf/RDijml5XftiyoMXlY9LmRHhy6HFxidjPu5q6u4ELisXSSboDmhmtBmG/X9 ldeab53kUbIYB8MNAQvFMmTpAIkGKx7cFVJGrdfwyXjDGdc9ujUcsyVDuXUXMYEfGy87 0WqtK7i1IY65OgAmTqpC2BZCcKCRBNuRM16URStgNU/tntlFAJPRzBT8nIALWwLk0nNV 70mp7SwOT09HDhY/Z9LqXScqYNx+paF6alo2ChRoxOXzh4is4S/AxSNF6P9n78B6tAnM U07TB+uG2NSj29q4KRDQ0LBiT/8ujMnhuS3YB4J/0MQCGK8hl8mJjIZLt9NM1mpP29k9 NKSQ== X-Gm-Message-State: AAQBX9cw376jjhD2Xb8BivnQzzBH7cxkBX5geNuFPliKzKxPOjGWPlWR q0ME6kF6FfLQ+ap5/twr3xG9+FGPp73rizvlRQYxlrvluGADAqPqTigajui55a6/BuonL1CRaHD 6YN3vEMlOGcsu X-Received: by 2002:aa7:c6c8:0:b0:4f9:deb4:b986 with SMTP id b8-20020aa7c6c8000000b004f9deb4b986mr2885731eds.7.1679672177752; Fri, 24 Mar 2023 08:36:17 -0700 (PDT) X-Google-Smtp-Source: AKy350ay1iv3SvkhVkCpZgFjlrGDYTHaf4l+WBI3Lkacaxfq08vNdhGScQ/rdLUDCOdmvue3dyREYA== X-Received: by 2002:aa7:c6c8:0:b0:4f9:deb4:b986 with SMTP id b8-20020aa7c6c8000000b004f9deb4b986mr2885714eds.7.1679672177492; Fri, 24 Mar 2023 08:36:17 -0700 (PDT) Received: from localhost.localdomain (host-82-53-134-98.retail.telecomitalia.it. [82.53.134.98]) by smtp.gmail.com with ESMTPSA id a27-20020a509b5b000000b00501dd53dbfbsm5468613edj.75.2023.03.24.08.36.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 08:36:16 -0700 (PDT) From: Stefano Garzarella To: virtualization@lists.linux-foundation.org Cc: stefanha@redhat.com, Jason Wang , linux-kernel@vger.kernel.org, Andrey Zhadchenko , "Michael S. Tsirkin" , kvm@vger.kernel.org, netdev@vger.kernel.org, eperezma@redhat.com, Stefano Garzarella Subject: [PATCH v4 0/9] vdpa_sim: add support for user VA Date: Fri, 24 Mar 2023 16:35:58 +0100 Message-Id: <20230324153607.46836-1-sgarzare@redhat.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Changelog listed in each patch. v3: https://lore.kernel.org/lkml/20230321154228.182769-1-sgarzare@redhat.com/ v2: https://lore.kernel.org/lkml/20230302113421.174582-1-sgarzare@redhat.com/ RFC v1: https://lore.kernel.org/lkml/20221214163025.103075-1-sgarzare@redhat.com/ Stefano Garzarella (9): 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: define the stride used for translation 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 | 9 ++ drivers/vdpa/vdpa_sim/vdpa_sim.c | 161 ++++++++++++++++++++----- drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 10 +- drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 10 +- drivers/vhost/vdpa.c | 34 ++++++ drivers/vhost/vringh.c | 173 ++++++++++++++++++++++----- 8 files changed, 340 insertions(+), 78 deletions(-)