Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27558371rwd; Tue, 4 Jul 2023 04:52:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6PzsUYCbCHMtTjLQowbl56fPBcu5wLWNG0v/gdMDPWj3uT1Sm98kXpwIVho16P9NqVN1tT X-Received: by 2002:a05:6808:2347:b0:3a3:766b:7c31 with SMTP id ef7-20020a056808234700b003a3766b7c31mr8541114oib.35.1688471522590; Tue, 04 Jul 2023 04:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688471522; cv=none; d=google.com; s=arc-20160816; b=Av3tsj76MqSQuL0nU1cAAcAD+166kr4dTVtfAr3ci7SpiSyVmYzCMnMAoRBESRvJMe ndSjrMOukvdV8H6KL0XpAVlnXP6RcALV4+QG5b/udq1RJCIqyo20sBFvdnlmXsYAgDaw d0+WrDrfyjxsh6qUaB/rJhfhZu8064MWx0oDwu4AEZv3otWBhnxod/aUx6+cBaua0KM1 Pu39oFtzyFlneQcKBTTxNhzHtAUohCb1n4QY3iLx982nuAb7azbVMs3MixNXTl1XhxuZ E13IgLMStbljOxNSznSz+wAwIHPs7PqMNctLKfARBGCI9UrqabVkF5yEfGi1ZEE7DikS YNww== 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=KtFnjmuWq7lD4JMUFOEU267nnBV7z7Sf7mPzW1iJGx4=; fh=I6HMivtMMSX6CmdDLC6TNnwxqBVQ3w/+BoY/RwnB+MM=; b=PGD1sthWUU9/U3262f1X+UWuf1xfwxD5Hh1bzwP+OPwecZwFZ138hslQ97fGXd1H5C EV5HJ9xKYrFkPAFrN9puO/ZkuDn/w4DiaYoXZBBxx8LOrANbqb9ClF4+qOjUqP2WuEe8 fwfCWRFvftwjd72vvSdSdbTElydUgQZ1k1EyTrefYrkqYQumlOJxpaDDk4yQaIVMhI03 qaTREMPVvHZnFi+nfc2lNMzPAJ0Pjhw/U2S2cERsGyhe7q+qR8vEKKlDb8bWKiwsGXzn RkwpfXGpXon99PnGCudD3kM4NpIXZPvybbXEPkRkxp5tcy3TnvKgfGRHMW+I6vMbg0HS xzbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SLQC6G2P; 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 lb2-20020a17090b4a4200b002639fe8ff6bsi7439119pjb.44.2023.07.04.04.51.49; Tue, 04 Jul 2023 04:52:02 -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=SLQC6G2P; 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 S230260AbjGDLhp (ORCPT + 99 others); Tue, 4 Jul 2023 07:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230016AbjGDLhn (ORCPT ); Tue, 4 Jul 2023 07:37:43 -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 E552110C1 for ; Tue, 4 Jul 2023 04:36:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688470610; 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=KtFnjmuWq7lD4JMUFOEU267nnBV7z7Sf7mPzW1iJGx4=; b=SLQC6G2PsRf6x+ZIeQVCxKQ6O/cAVefzXIAYA9AByiSNO4KS8PTtqfMtHpOu1g+ZB4OONL 7J5NyrZl4SvNP8TLGAfNz4LGu+PcSOh24XRvWYNeS7zf7GcnP91HVwjtOOrnNKaxgRFUdO b07lAemrr3yAZMvcKL7EmapJuMq6dJ4= Received: from mail-yw1-f199.google.com (mail-yw1-f199.google.com [209.85.128.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-512-1VoREcR7OMul4-V3F1oTqA-1; Tue, 04 Jul 2023 07:36:49 -0400 X-MC-Unique: 1VoREcR7OMul4-V3F1oTqA-1 Received: by mail-yw1-f199.google.com with SMTP id 00721157ae682-573d70da2afso55474537b3.2 for ; Tue, 04 Jul 2023 04:36:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688470608; x=1691062608; 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=KtFnjmuWq7lD4JMUFOEU267nnBV7z7Sf7mPzW1iJGx4=; b=AvVWSIsmIfP4glDhwFFc6A8IgWqDnLywcrb3osdZB/8jOBTI+Kj3jQEKwEzRYgnHNs d69rW53H8fkKBeuYK0trIUweQoNYWMTWsCqUbE6kHKw3mAFoDFZSKEvg7oGyu05lVs+L sdxMXuTNppDNOoIQ5RLT3wgsVTwP3qUJn5rWkWJERre/4ciEWUW3rjOCyTD5I/PEWTkS s/cdabUiitL10gmUbGVWsdurigJokaQYwwz+xhdjOZitkUuUrG0RfLGLcE2YpHhIWIhT bbc8HcIoj9sg0zH8CT+giQzkFZANwepCGFXtrRUEqQQ5OiLzinzO/dbE9GOsbI/KQRzO IgnA== X-Gm-Message-State: ABy/qLYbx0z0ddRZ/3BLR2kg2k3TBKntk/IE6G2RQuZRA5bjVdZf5K+D b7y846tzm7q2UdJ/snj9Hr32K0xvq+pRx4ZtRHkHNRoUV7NhsnE8INqu6yA6u4Vqr8w4K+5OD/i be/ZNJEBGA2bvFv7Q0bWrGreUTPuz3p2dEy///DZH X-Received: by 2002:a25:f905:0:b0:c1d:5719:7c74 with SMTP id q5-20020a25f905000000b00c1d57197c74mr9848268ybe.31.1688470608469; Tue, 04 Jul 2023 04:36:48 -0700 (PDT) X-Received: by 2002:a25:f905:0:b0:c1d:5719:7c74 with SMTP id q5-20020a25f905000000b00c1d57197c74mr9848260ybe.31.1688470608126; Tue, 04 Jul 2023 04:36:48 -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: Eugenio Perez Martin Date: Tue, 4 Jul 2023 13:36:11 +0200 Message-ID: Subject: Re: [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it To: "Michael S. Tsirkin" Cc: Jason Wang , 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=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 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 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? > 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.html > > 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 > > > >