Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28710917rwd; Wed, 5 Jul 2023 01:16:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlGo8saSA99w5wKSzonh7dm3xbyQg3+KiuPmYo4wnkor4oHSJsPWsKAeZfaxun7lhr5+MwOc X-Received: by 2002:a17:903:110f:b0:1b3:d6c8:7008 with SMTP id n15-20020a170903110f00b001b3d6c87008mr13585678plh.57.1688545012070; Wed, 05 Jul 2023 01:16:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688545012; cv=none; d=google.com; s=arc-20160816; b=KP9kuwQA0ubDoZxMarTA1XjujTnwPFtLTgTOgAL4iIiPNpGXE0q8lZXe5fEF6RacTi vaTNN6CLj5/JK09M+4L7YMbYqBloKBe4PV8nABd9H7bY0pxSNZKX0Waisul5RzzdmFlp 3cYQmFzI0h9wFV394pamaj6aJNOYn2QsHkdU9pI7sb2zk8t/2leSZN3ImrUj2XkmuZXl leA3ES82vAb0nzPJBM7HPfHRh9+NocbGD+EmYa3ywczkFvnShTXMqogfIVXDNazwyzuH qXkoiy8b/+fgRoQDzkN0EjjTBwUiTWgBGMRC2PevWqzjkmTLandYxW/9LGbmEZ+R8Oh0 VXnA== 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=JchDhPT3KR3iSA029I0+obQ1cLL2Ob33e0q6YR+m51M=; fh=1zvWjPhIkfeVmGTNiby3RxaU6KzXVptc6Ezc8o4+DWI=; b=VLgBYkhc7Sjk3/H/KougeGerVfPAWWxdHkoK1lN0OXqi2yz2ZhJSj6s8hRS5iymNVC tm/A/LUZ7ufsk+4Ks1e9lnxUtdoYnHNg3pWdnABdiaSQnan9A8cZ9JM/3ZeGmI2dnmjv xHCFpSk5oxgH4i31LSXbwL7Px8lTXLGlW7L8/qEDWrkiK0z4lM4vR0Kx2im96aU++P7h hEX/l77SFqOEB+TV0+zfW9u3tnfZ5G7d+yUToEBzZmOWxAnWgsZFXnaYq+cY7sXHXyVh R5tb0Tq6vIR9X+3Vus6MVNbSgHeFrAyPil1CNX6HI2+b/wYgMw8Oet5Ftz57Hu/JWCMA mAEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=N64ikZos; 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 s7-20020a170902b18700b001b4f582d796si21333372plr.167.2023.07.05.01.16.39; Wed, 05 Jul 2023 01:16:52 -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=N64ikZos; 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 S231441AbjGEH4h (ORCPT + 99 others); Wed, 5 Jul 2023 03:56:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjGEH4f (ORCPT ); Wed, 5 Jul 2023 03:56:35 -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 ECBAD1711 for ; Wed, 5 Jul 2023 00:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688543739; 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=JchDhPT3KR3iSA029I0+obQ1cLL2Ob33e0q6YR+m51M=; b=N64ikZos5AfatFf9W8bfFfGQi3pl4CAuHqr2kAbV0O1pbRxbDcuDTfzGZVuN6cC7pDktOu WgC9fVE2QCo0tmo/J3jIEKnn3zxv2u/1aZ0dDc2YB9z8y9NgyWGbM5C4INR+7FCPxuK5A/ C/6+m3LLbvekEA+Opu6wbFdByA1weOo= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-56-p8Z-tV2bNASyMV8WZsDuKg-1; Wed, 05 Jul 2023 03:55:38 -0400 X-MC-Unique: p8Z-tV2bNASyMV8WZsDuKg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-635e0889cc5so64670976d6.2 for ; Wed, 05 Jul 2023 00:55:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688543736; x=1691135736; 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=JchDhPT3KR3iSA029I0+obQ1cLL2Ob33e0q6YR+m51M=; b=WSbQL6bW/7RYLllETCCJvH+Zq14T3OZe6xMtxIPqUOJLyTNmylfwP41wazRL+XkeHV KGMBctpPG9v90jxkbsGELToqkU+UwAJv1u57uMSqoLM3DKEObrZIhJ9wM4izCyZ/becb Ok6xDZDd33jyRLf6lZQQd1rSenXJvLXyQKgxa3JpKkIL1ppeWsnKHROGty1sfboluubQ K8LUTfzyFlKyh57q6yy78tkZuy4saIrGSvFWk8tVu7T8dWXvLn1pbDsEldvfgtP5DdCk JpK9MiDkbN8iV+IwN6e0vdIeDydlN+NUp1484RfzYey5C7hSUYP0wPlho400t6/uWjuL f/dw== X-Gm-Message-State: ABy/qLYMKLn+Uolp7M+S70GYEdlNB5Mz3OXM+I0/vPlx718a5k5HxRDg VslsFzB/TnNuCiKc7ZyrA+mE8hlb/WQqDnzOhBPCCvdmF3OvHyJAkmOJATxLhIaQgPWOiPOKi81 OMRLP9K0VPinJvtkoHymh0HLhLkQveGKOhiptdxXjlAfxVOn/rq4= X-Received: by 2002:a0c:e9c7:0:b0:632:301e:62fc with SMTP id q7-20020a0ce9c7000000b00632301e62fcmr14553362qvo.35.1688543736084; Wed, 05 Jul 2023 00:55:36 -0700 (PDT) X-Received: by 2002:a0c:e9c7:0:b0:632:301e:62fc with SMTP id q7-20020a0ce9c7000000b00632301e62fcmr14553352qvo.35.1688543735859; Wed, 05 Jul 2023 00:55:35 -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> In-Reply-To: <20230704063646-mutt-send-email-mst@kernel.org> From: Jason Wang Date: Wed, 5 Jul 2023 15:55:23 +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 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 6: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 wrote: > > > > With the current code it is accepted as long as userland send it. > > > > > > > > Although userland should not set a feature flag that has not been > > > > offered to it with VHOST_GET_BACKEND_FEATURES, the current code wil= l not > > > > complain for it. > > > > > > > > Since there is no specific reason for any parent to reject that bac= kend > > > > feature bit when it has been proposed, let's control it at vdpa fro= ntend > > > > level. Future patches may move this control to the parent driver. > > > > > > > > Fixes: 967800d2d52e ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRI= VER_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? Vhost-net is one example at last. It polls a socket as well, so it starts to access the ring immediately after DRIVER_OK. 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 vdpa > > (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 hw > > * Store the doorbell state separately, but do not configure it to the > > 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 enabling > > 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/kerne= l/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(struct = 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(featur= es))) > > > > return -EFAULT; > > > > + if (ops->get_backend_features) > > > > + parent_features =3D ops->get_backend_features= (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_AFTER= _DRIVER_OK))) > > > > + parent_features)) > > > > return -EOPNOTSUPP; > > > > if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && > > > > !vhost_vdpa_can_suspend(v)) > > > > -- > > > > 2.39.3 > > > >