Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp28739074rwd; Wed, 5 Jul 2023 01:50:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlFevjQaq7rS4eXF8bAYhAmAq0RbeR/M5e5hBeRSGdwrpj/NbQsyv0deUnd6Jpq81v/tSZvF X-Received: by 2002:a17:902:dad1:b0:1b8:87dc:3371 with SMTP id q17-20020a170902dad100b001b887dc3371mr8356148plx.67.1688547059271; Wed, 05 Jul 2023 01:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688547059; cv=none; d=google.com; s=arc-20160816; b=o0BRDg9x07fyuG2T213Zrqqdo2vuCR1FXvbXNIK8T71uA2t+OPNzsMuGBtcXFwVQmz //YYFDVuTqutfKITl/WrsJbijteg5D0nM6Gi3RA1wBLUa6cq5y2oQgr0SNIuynwgtsI+ TDgg7H18nuXJhj/MMF6AAnQ4b52J3xS3u26EhyKdRYKM/1K7RQ6Jxc7kjO5RYzuGrfJe 0YCbJjarBKng5xv13ZxveGir2Q4+CWc8B5L8XNiFeOxnfggVQMqW1ygE7lh1FWjDuXPu KXRtb1WpuTRvyyalusYGr+obS2gBXf9BVnMa9+uC7G7/7IcPUzlZepHOR8yraIoUmdA6 m0BA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RMcHS+HYh08mQ8rBNMcHYRimEbsxb6yaJnh1Kb3mgQ0=; fh=42hLWQaMZjTlr2GDGq02xjykG3ETj4Whd4zNCpxFOEU=; b=zDfpwFdtUo7+t9NlENvC7pxVsQN6rjtGZS0NWlOcCYZyDPeXrh4L7Te9//Kfex/jyK 2S4YymhddnmHW5U+sI95dmklrS0dXEX/s0JJvBqtM+tAw7eMcu9Hi5Or0LmmnhhEXvkM omiuJqLL8G104SMJb8EPqzD06ADmXc6TYDLhSGjpcY+O/hdxR4YsR+tZeY7OVKwW+Bhf OkPWalMYraEm3RDd+cPoQm6pKioJdYORvylefVCXY7U7i2Qjheu7oQSw3j9RorS6zGNp nt+IeczX4UJpNO+lubleJhlV6nS/JzKnnqxh7Xr87iPU4eRFg8iWD3TUDj0TQMvS2kgp vP+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FYfxK6T1; 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 y13-20020a17090322cd00b001b86671b3f1si13073195plg.190.2023.07.05.01.50.45; Wed, 05 Jul 2023 01:50:59 -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=FYfxK6T1; 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 S231492AbjGEImJ (ORCPT + 99 others); Wed, 5 Jul 2023 04:42:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbjGEImI (ORCPT ); Wed, 5 Jul 2023 04:42:08 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E53019A2 for ; Wed, 5 Jul 2023 01:41:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688546479; 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=RMcHS+HYh08mQ8rBNMcHYRimEbsxb6yaJnh1Kb3mgQ0=; b=FYfxK6T1gDraYjxAZhyiNOOvgs2RLZEKGipfkdDAnExxOG+znph/NzBvWiWzmsg4TEH1Sa 5jhKjWt5w6okMC1OSLjPxGgm8Xic84lsWKqbjkWrpZ7Wi/A2fxbRXrf/J9Uw0u/P3XOJCz GVywlv+iRXXtrTiZnIOmXKMUy20Wnxs= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-531-MmUd_ucTPW6wvzJvylW9LA-1; Wed, 05 Jul 2023 04:41:18 -0400 X-MC-Unique: MmUd_ucTPW6wvzJvylW9LA-1 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-313e65772d8so6611782f8f.0 for ; Wed, 05 Jul 2023 01:41:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688546477; x=1691138477; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RMcHS+HYh08mQ8rBNMcHYRimEbsxb6yaJnh1Kb3mgQ0=; b=IANI4mmk7eWxawpQNy3ZEZdmNsuJ8HIXVtKojnPOtXS2p7c6M0Osbw2C+hQvOkpuND 8pV18JQM7nrh59Gn0HA8el7cs0Fj63GxnmxIcsfdphM6x0OravnI44RmKBzeOOx5cL13 UrPGTsDKIo7dkDdz5UOsmn8T7cMT6tt5XHJ+YW68fUKBYHxpybLkfRf3fsKdfMZmY+Ab 2ewAC7/xHBSjPKX9LvN+jC4j6e+wC2NEu7VmBJGi5wNJf2wpEer9Wbvg3mQXSaSu403O dm8SYrmV/3JVCoRihkSRjxxD/603HxLq7RdZFdztMJHoO1WxwLcC12FxCi0HNeL7DnuP w1/w== X-Gm-Message-State: ABy/qLY0PFydxKRDFtLoS5SMVh2CBCc8xbqQqy6QNF/SvcxAeoHb87JS eHfMIfVEvQ19n28jmYq7wGpyS9QddSb04lfe/xuagHuHbHLBNfa2bNTPtj0OOVH5n7Pz0B3LrJf HdehEJa+7vVbNmcW98OQDg9MZjKz+JVho X-Received: by 2002:adf:facd:0:b0:311:110d:5573 with SMTP id a13-20020adffacd000000b00311110d5573mr17013460wrs.64.1688546477134; Wed, 05 Jul 2023 01:41:17 -0700 (PDT) X-Received: by 2002:adf:facd:0:b0:311:110d:5573 with SMTP id a13-20020adffacd000000b00311110d5573mr17013442wrs.64.1688546476766; Wed, 05 Jul 2023 01:41:16 -0700 (PDT) Received: from redhat.com ([2.52.13.33]) by smtp.gmail.com with ESMTPSA id c13-20020adfe74d000000b0030ae499da59sm15301643wrn.111.2023.07.05.01.41.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jul 2023 01:41:16 -0700 (PDT) Date: Wed, 5 Jul 2023 04:41:12 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: Eugenio Perez Martin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Shannon Nelson , virtualization@lists.linux-foundation.org, kvm@vger.kernel.org Subject: Re: [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it Message-ID: <20230705043940-mutt-send-email-mst@kernel.org> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 Wed, Jul 05, 2023 at 03:49:58PM +0800, Jason Wang wrote: > On Tue, Jul 4, 2023 at 11:45 PM 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 PM 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 PM Michael S. Tsirkin wrote: > > > > > > > > > > > > On Mon, Jul 03, 2023 at 04:22:18PM +0200, Eugenio Pérez 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 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 driver. > > > > > > > > > > > > > > Fixes: 967800d2d52e ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature") > > > > > > > Signed-off-by: Eugenio Pérez > > > > > > > > > > > > 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 > > > > 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 I don't see what does one have to do with another ... I think with RING_RESET we had another solution, enable rings mapping them to a zero page, then reset and re-enable later. > > > > > > > > > > > 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/kernel/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 = filep->private_data; > > > > > > > struct vhost_dev *d = &v->vdev; > > > > > > > + const struct vdpa_config_ops *ops = v->vdpa->config; > > > > > > > void __user *argp = (void __user *)arg; > > > > > > > u64 __user *featurep = argp; > > > > > > > - u64 features; > > > > > > > + u64 features, parent_features = 0; > > > > > > > long r = 0; > > > > > > > > > > > > > > if (cmd == VHOST_SET_BACKEND_FEATURES) { > > > > > > > if (copy_from_user(&features, featurep, sizeof(features))) > > > > > > > return -EFAULT; > > > > > > > + if (ops->get_backend_features) > > > > > > > + parent_features = 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 > > > > > > > > > > > >