Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11665405rwl; Tue, 3 Jan 2023 02:57:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZL4J9tEY5/Cl1XilfsuO2XpMDsM1hyqv9VdAUsolAkyJ3V9roZqCvYW4xv1W05UmaJLB7 X-Received: by 2002:a05:6402:685:b0:45c:be41:a473 with SMTP id f5-20020a056402068500b0045cbe41a473mr37555191edy.29.1672743456506; Tue, 03 Jan 2023 02:57:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672743456; cv=none; d=google.com; s=arc-20160816; b=CX+LQOtgGKn2vQCRNGkhfAggHfS7bO7IgIT3yXSszQvcwjNgf+fKZgFm9PQoPIBasW oioM1EbRV3ORfydTCzl9swfujk/8x6KKnM8aBhoZKOHDbOfzMUTkIPlEmq0npfoHXG8H nFVrV+ViTpznYXp2vjpy3ds9U5QMaDcYrCR05DbpuIS9mO1hfggVl68S4lPVabHbJEzk F6hCCQ1eoiD0RiXZQa5qrU2kZyPQEC0nF+Vj864QVeou4gc4dyS8wqQ3lGhnyNWrhfpe xQFKtDJ79xiPFAP25bpDbMJ0ToIdG455C+QW4yeX7701/rCQBoexrecj1gGjXaVcR22q 0glA== 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=E5hYtJLaLYD8nZjC1AlQ3IMgWvuOvSL0616tPGzzVqE=; b=ifIqBucoGKtniQtOFPSNWmycW5TRjJbtXQ14vNhEU42mQslb4cNj65Nr9DFcpitXE2 We/tVZYVE0/8uBv/rvlNrLoIoRzVIYjkUawUzne8tvTkiWScBaRuWteD1FCuQ9aIUmkT 53SH1H3+U5zbwxon2PUcvYpq1TrrnNytuCg+MW8UI5aSVnB++X6sneBI+U723CdO7AcB SvC3RyzVATtOSNrLrALncXJ5erU3i3KkDiKpEuw+xgFJwG8gCU2+5EiYt1YvB6tuitaZ 2NEgPFpYkV8iGZXb636JEB+5GWrwwT4bTXnXzF7iM1dI/Tfs9QtvZBDIu4mOIY13vGXy uoPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=PpLoTiiA; 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=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a66-20020a509ec8000000b00468fdd316e6si30513870edf.542.2023.01.03.02.57.21; Tue, 03 Jan 2023 02:57:36 -0800 (PST) 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=@intel.com header.s=Intel header.b=PpLoTiiA; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237429AbjACKwK (ORCPT + 62 others); Tue, 3 Jan 2023 05:52:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237193AbjACKvi (ORCPT ); Tue, 3 Jan 2023 05:51:38 -0500 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 765602FA for ; Tue, 3 Jan 2023 02:51:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672743097; x=1704279097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wwAlVm/7I8ndsWi60dF17HSTriSq8epoPrbPLSohnLw=; b=PpLoTiiAXvPV6Y0VKIgd581nm9AxugWU/N8sDhTYFo0TI/aIuE2wbShk ORfQmkUbA7DKmB/cFQYW9tvBGQi4AoPo11ezZAyzzEZrpxSHrJStaWjJx qKtD9zHglvyKLCFrlElVLMvLiWuHDQlPOMY/cmADgpT/43Wjh6VUrrIS1 dDzYe1CbDVmttZApxjr1njzECMyoeM/gxCSbe2YIyyf5cZEEG/YnFlnMe ecSDYTUNqHvkWOCxEieiuUwDLXCv97W/0IAPeSE9qAuF/cYDngEYzZw1Y OwMRNepXuZF0OlYhHhQNGTuUiDVb4up5vf/i0y7jLVznumuwWhv6Sg4MQ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="301318451" X-IronPort-AV: E=Sophos;i="5.96,296,1665471600"; d="scan'208";a="301318451" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 02:51:37 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10578"; a="604772689" X-IronPort-AV: E=Sophos;i="5.96,296,1665471600"; d="scan'208";a="604772689" Received: from isobansk-mobl1.ger.corp.intel.com (HELO sboeuf-mobl.home) ([10.252.24.246]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Jan 2023 02:51:35 -0800 From: sebastien.boeuf@intel.com To: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: mst@redhat.com, jasowang@redhat.com, eperezma@redhat.com, sebastien.boeuf@intel.com Subject: [PATCH v6 2/4] vhost-vdpa: Introduce RESUME backend feature bit Date: Tue, 3 Jan 2023 11:51:06 +0100 Message-Id: X-Mailer: git-send-email 2.37.2 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,LOTS_OF_MONEY, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_NONE 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 From: Sebastien Boeuf Userspace knows if the device can be resumed or not by checking this feature bit. It's only exposed if the vdpa driver backend implements the resume() operation callback. Userspace trying to negotiate this feature when it hasn't been exposed will result in an error. Acked-by: Jason Wang Signed-off-by: Sebastien Boeuf --- drivers/vhost/vdpa.c | 16 +++++++++++++++- include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index 166044642fd5..833617d00ef6 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -355,6 +355,14 @@ static bool vhost_vdpa_can_suspend(const struct vhost_vdpa *v) return ops->suspend; } +static bool vhost_vdpa_can_resume(const struct vhost_vdpa *v) +{ + struct vdpa_device *vdpa = v->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; + + return ops->resume; +} + static long vhost_vdpa_get_features(struct vhost_vdpa *v, u64 __user *featurep) { struct vdpa_device *vdpa = v->vdpa; @@ -602,11 +610,15 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, if (copy_from_user(&features, featurep, sizeof(features))) return -EFAULT; if (features & ~(VHOST_VDPA_BACKEND_FEATURES | - BIT_ULL(VHOST_BACKEND_F_SUSPEND))) + BIT_ULL(VHOST_BACKEND_F_SUSPEND) | + BIT_ULL(VHOST_BACKEND_F_RESUME))) return -EOPNOTSUPP; if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && !vhost_vdpa_can_suspend(v)) return -EOPNOTSUPP; + if ((features & BIT_ULL(VHOST_BACKEND_F_RESUME)) && + !vhost_vdpa_can_resume(v)) + return -EOPNOTSUPP; vhost_set_backend_features(&v->vdev, features); return 0; } @@ -658,6 +670,8 @@ static long vhost_vdpa_unlocked_ioctl(struct file *filep, features = VHOST_VDPA_BACKEND_FEATURES; if (vhost_vdpa_can_suspend(v)) features |= BIT_ULL(VHOST_BACKEND_F_SUSPEND); + if (vhost_vdpa_can_resume(v)) + features |= BIT_ULL(VHOST_BACKEND_F_RESUME); if (copy_to_user(featurep, &features, sizeof(features))) r = -EFAULT; break; diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 53601ce2c20a..c5690a8992d8 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -163,5 +163,7 @@ struct vhost_vdpa_iova_range { #define VHOST_BACKEND_F_IOTLB_ASID 0x3 /* Device can be suspended */ #define VHOST_BACKEND_F_SUSPEND 0x4 +/* Device can be resumed */ +#define VHOST_BACKEND_F_RESUME 0x5 #endif -- 2.37.2 --------------------------------------------------------------------- Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France Registration Number: 302 456 199 R.C.S. NANTERRE Capital: 5 208 026.16 Euros This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.