Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28704338rwd; Wed, 5 Jul 2023 01:09:37 -0700 (PDT) X-Google-Smtp-Source: APBJJlEsrUZyYi5/qnrnT07qrVE+900kZiAq5HccF0qTfFlLTqcQOjNTLlMlzB89csFVM/Piyo0X X-Received: by 2002:a17:902:ec88:b0:1af:e302:123 with SMTP id x8-20020a170902ec8800b001afe3020123mr2633795plg.3.1688544577225; Wed, 05 Jul 2023 01:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688544577; cv=none; d=google.com; s=arc-20160816; b=aGOyFjp8BMQS/9TlS+U+7Tak7BpP3z5D8NfiMIk/Csveed26aGNxzJroxWHMMTrC5N jxb4IdOBw9pAIvXVe39nJZIzWdRpGwavxINsd0twr+3M0/ML39vuD+gPQA38Ki8zsPyo NMI1WGEIp45LB/F0N0gt17rk+6XdOdQP0u4gctCzQDb6bNiO1tOSof755KXEuUBgvXUz ow5rqzlihqzMIvGKeB19ppMp6u20DBx+Cdij+jt3vQ4rONl60MLxz+XQWQmdvhXGtviW Y7pDIbQxhxYH7QDB4JFRnKK3MhV6qogFwTZV2iJ6JV3PyF96ppJMKjsJdEjvGBq/d737 KLYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=y48ulS/+kKO7p+XK2cdnd8+mcOJFtW4xSVJ9cfRLRCc=; fh=1zvWjPhIkfeVmGTNiby3RxaU6KzXVptc6Ezc8o4+DWI=; b=Y8J9kkFY60N3lXN8IAklNYKzbkDlGZobfn2iiZVx145xNy+MoiLHgia+MrxnyqWjWy 9IgOt3moiVGqzqKs4+iGpZjbVMHpVWhMHZ5MkRFdGTv8YsgpiUecWeJsWX28mhxUA+PW wXhcs5Z+lFQtqcHXNRyQzHX7hDBm7ILozfr0oYktDYmB+AYgAjIUcpU7bApSwmLv1rb+ ohVQr+3ivecKGeL1qBUmvjApId/fQEzqGxIb3bNPmsb6Zv92xqWkphGpDIwWClPgSs1k JhuZlupWvBcQlmK5dZfzCC4c9aWxkOqelQCB3CgrlLScxJgs32eGZVqr5Va94oQcJ0Wd QdVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Dk1UZScp; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a170902bb8a00b001b04c325d66si21248594pls.565.2023.07.05.01.09.25; Wed, 05 Jul 2023 01:09:37 -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=@redhat.com header.s=mimecast20190719 header.b=Dk1UZScp; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232102AbjGEHvD (ORCPT + 99 others); Wed, 5 Jul 2023 03:51:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231744AbjGEHvC (ORCPT ); Wed, 5 Jul 2023 03:51:02 -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 9085A1706 for ; Wed, 5 Jul 2023 00:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688543413; 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: in-reply-to:in-reply-to:references:references; bh=y48ulS/+kKO7p+XK2cdnd8+mcOJFtW4xSVJ9cfRLRCc=; b=Dk1UZScpk7GtS8sD/qYXhdbRtqkYU700Sfo24LQxvNHFgKAbJH8JlgwhxpgXC5z9PrdO4D yjRwOzx6BimeXp3KP4t3APfAf7I0Wl3y8P7JsZDshRH0hKiPaKUqBXspPkhJOMcI6hwNIk seLwmfhGxg9UUa8lUbYfdQP85UHYlE8= 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_256_GCM_SHA384) id us-mta-310-4shj97TJNXSUFl6HzWem5Q-1; Wed, 05 Jul 2023 03:50:12 -0400 X-MC-Unique: 4shj97TJNXSUFl6HzWem5Q-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-40379c9b5f9so2349911cf.1 for ; Wed, 05 Jul 2023 00:50:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688543412; x=1691135412; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=y48ulS/+kKO7p+XK2cdnd8+mcOJFtW4xSVJ9cfRLRCc=; b=jdiSzkkAaqwF1QTx80hquK77dbCKZoyApajQS6yPXdRTvG8mJtYxC/Ijv4iEuzGhlE QFVh86i3Tk007YkVflwp+Sy2vtTCTfvmtWxm52TPKa8bLhjBRtHJQoym3hHRo06UKA3g QiG84kDYkpWoxz20aodWtIwxL/NDx8AEW/cYlEOGE/hlUfriP72En+33m60zTfECpyWn QP0HdGRCNeMI22s6GvlOZpPnUudg2Na4rs7+E3QFIIcx5InC1+fBvQwFUwo1lgbC0Fv1 blm29jhmrcUGxoHRUUWLNVH9Js1laX14CviekVUR8pdDpZQiubRwu+gQlhK9r7Q64/97 Dw/A== X-Gm-Message-State: ABy/qLbthPcRyGPcEchKibBSryXaVTSzKXAwNIe9kYtiG/6d0Pn3coSu P/tvZlKBT7T4PKf/QbxzPtSYO2QeM72ry7YD/BBdGPtin+dPw19yDgT1AJl3OF9pxtY9ZumelAF o8yueYKNYiaoRvkagbAm/gFE3KmufhGX7tbm/YGo1 X-Received: by 2002:a0c:f1ca:0:b0:630:14e0:982e with SMTP id u10-20020a0cf1ca000000b0063014e0982emr1588304qvl.22.1688543412147; Wed, 05 Jul 2023 00:50:12 -0700 (PDT) X-Received: by 2002:a0c:f1ca:0:b0:630:14e0:982e with SMTP id u10-20020a0cf1ca000000b0063014e0982emr1588302qvl.22.1688543411888; Wed, 05 Jul 2023 00:50:11 -0700 (PDT) MIME-Version: 1.0 References: <20230703142218.362549-1-eperezma@redhat.com> <20230703105022-mutt-send-email-mst@kernel.org> <20230704063646-mutt-send-email-mst@kernel.org> <20230704114159-mutt-send-email-mst@kernel.org> In-Reply-To: <20230704114159-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Wed, 5 Jul 2023 15:49:58 +0800 Message-ID: Subject: Re: [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it To: "Michael S. Tsirkin" Cc: Eugenio Perez Martin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Shannon Nelson , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 On Tue, Jul 4, 2023 at 11:45=E2=80=AFPM Michael S. Tsirkin = wrote: > > On Tue, Jul 04, 2023 at 01:36:11PM +0200, Eugenio Perez Martin wrote: > > On Tue, Jul 4, 2023 at 12:38=E2=80=AFPM Michael S. Tsirkin wrote: > > > > > > On Tue, Jul 04, 2023 at 12:25:32PM +0200, Eugenio Perez Martin wrote: > > > > On Mon, Jul 3, 2023 at 4:52=E2=80=AFPM Michael S. Tsirkin wrote: > > > > > > > > > > On Mon, Jul 03, 2023 at 04:22:18PM +0200, Eugenio P=C3=A9rez wrot= e: > > > > > > With the current code it is accepted as long as userland send i= t. > > > > > > > > > > > > Although userland should not set a feature flag that has not be= en > > > > > > offered to it with VHOST_GET_BACKEND_FEATURES, the current code= will not > > > > > > complain for it. > > > > > > > > > > > > Since there is no specific reason for any parent to reject that= backend > > > > > > feature bit when it has been proposed, let's control it at vdpa= frontend > > > > > > level. Future patches may move this control to the parent drive= r. > > > > > > > > > > > > Fixes: 967800d2d52e ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER= _DRIVER_OK backend feature") > > > > > > Signed-off-by: Eugenio P=C3=A9rez > > > > > > > > > > Please do send v3. And again, I don't want to send "after driver = ok" hack > > > > > upstream at all, I merged it in next just to give it some testing= . > > > > > We want RING_ACCESS_AFTER_KICK or some such. > > > > > > > > > > > > > Current devices do not support that semantic. > > > > > > Which devices specifically access the ring after DRIVER_OK but before > > > a kick? > > > > > > > Previous versions of the QEMU LM series did a spurious kick to start > > traffic at the LM destination [1]. When it was proposed, that spurious > > kick was removed from the series because to check for descriptors > > after driver_ok, even without a kick, was considered work of the > > parent driver. > > > > I'm ok to go back to this spurious kick, but I'm not sure if the hw > > will read the ring before the kick actually. I can ask. > > > > Thanks! > > > > [1] https://lists.nongnu.org/archive/html/qemu-devel/2023-01/msg02775.h= tml > > Let's find out. We need to check for ENABLE_AFTER_DRIVER_OK too, no? My understanding is [1] assuming ACCESS_AFTER_KICK. This seems sub-optimal than assuming ENABLE_AFTER_DRIVER_OK. But this reminds me one thing, as the thread is going too long, I wonder if we simply assume ENABLE_AFTER_DRIVER_OK if RING_RESET is supported? Thanks > > > > > > > My plan was to convert > > > > it in vp_vdpa if needed, and reuse the current vdpa ops. Sorry if I > > > > was not explicit enough. > > > > > > > > The only solution I can see to that is to trap & emulate in the vdp= a > > > > (parent?) driver, as talked in virtio-comment. But that complicates > > > > the architecture: > > > > * Offer VHOST_BACKEND_F_RING_ACCESS_AFTER_KICK > > > > * Store vq enable state separately, at > > > > vdpa->config->set_vq_ready(true), but not transmit that enable to h= w > > > > * Store the doorbell state separately, but do not configure it to t= he > > > > device directly. > > > > > > > > But how to recover if the device cannot configure them at kick time= , > > > > for example? > > > > > > > > Maybe we can just fail if the parent driver does not support enabli= ng > > > > the vq after DRIVER_OK? That way no new feature flag is needed. > > > > > > > > Thanks! > > > > > > > > > > > > > > > --- > > > > > > Sent with Fixes: tag pointing to git.kernel.org/pub/scm/linux/k= ernel/git/mst > > > > > > commit. Please let me know if I should send a v3 of [1] instead= . > > > > > > > > > > > > [1] https://lore.kernel.org/lkml/20230609121244-mutt-send-email= -mst@kernel.org/T/ > > > > > > --- > > > > > > drivers/vhost/vdpa.c | 7 +++++-- > > > > > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > > > > > > > > > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > > > > > > index e1abf29fed5b..a7e554352351 100644 > > > > > > --- a/drivers/vhost/vdpa.c > > > > > > +++ b/drivers/vhost/vdpa.c > > > > > > @@ -681,18 +681,21 @@ static long vhost_vdpa_unlocked_ioctl(str= uct file *filep, > > > > > > { > > > > > > struct vhost_vdpa *v =3D filep->private_data; > > > > > > struct vhost_dev *d =3D &v->vdev; > > > > > > + const struct vdpa_config_ops *ops =3D v->vdpa->config; > > > > > > void __user *argp =3D (void __user *)arg; > > > > > > u64 __user *featurep =3D argp; > > > > > > - u64 features; > > > > > > + u64 features, parent_features =3D 0; > > > > > > long r =3D 0; > > > > > > > > > > > > if (cmd =3D=3D VHOST_SET_BACKEND_FEATURES) { > > > > > > if (copy_from_user(&features, featurep, sizeof(fe= atures))) > > > > > > return -EFAULT; > > > > > > + if (ops->get_backend_features) > > > > > > + parent_features =3D ops->get_backend_feat= ures(v->vdpa); > > > > > > if (features & ~(VHOST_VDPA_BACKEND_FEATURES | > > > > > > BIT_ULL(VHOST_BACKEND_F_SUSPEND)= | > > > > > > BIT_ULL(VHOST_BACKEND_F_RESUME) = | > > > > > > - BIT_ULL(VHOST_BACKEND_F_ENABLE_A= FTER_DRIVER_OK))) > > > > > > + parent_features)) > > > > > > return -EOPNOTSUPP; > > > > > > if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND))= && > > > > > > !vhost_vdpa_can_suspend(v)) > > > > > > -- > > > > > > 2.39.3 > > > > > > > > >