Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30097086rwd; Thu, 6 Jul 2023 00:26:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlEx5OlCLeR1j8KF6A/1/QCTHkdU8JFfOZqv60dV0e300aXL71YU0VAq9s/6yKr6cFlB7jkZ X-Received: by 2002:a0d:da01:0:b0:570:654f:aa42 with SMTP id c1-20020a0dda01000000b00570654faa42mr2338624ywe.40.1688628371705; Thu, 06 Jul 2023 00:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688628371; cv=none; d=google.com; s=arc-20160816; b=SqbXyvUxdp/jzUA77rY5fd7EP5Sa8kP1GEptpqPhbuEYofZkw+TjmVGoHqMQRLxKYf v9FwGwssxb7dq8hXvl5P3PH5So6M7iICtSPNrHLK3XgA87sn09QDacU+H/TH4wSoMA0u 8S9tcwVlm8JNEMbF9EBqxxkiYmi+vXHwnKUFhP6y2M9sig4+ZzQJcPaMJUbbyUGNb4OR 7v95JcE/x7hTM8CMv8E4ecC3h7qW8KZzsY7+l3kyc7KscystATboRkKQytT1l/vAn+OB xt4vrwHcbt/e0YnK3VR96unImeyStaq16/6Z3dol53lRzdO5d6yAM+7VRjt3uzlxjUlc psOw== 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=POrI2HrupnKR3vfjjFVb4RJeA3XrZk3xd7QFOuOo4BE=; fh=mqigw4XO6os++txBZm5D4QERu26ygVgJWKQ9BZ9aySE=; b=aEX7Jg1MfuhNbFq8KN33LQRwUnJGwzsx/aouPjzKINEYdT4es3u8CoCnAZUnfjBGie gHNt0mNjZSPZLUV+/O66QCWC7lHmpURoiynncPXZVi0B6aZ5n2S1Wwh16rHDAdhxbM4t 2BWbqv4LRrXnU6+jLXCMEOQRfKVL5q1hCdv0XIm1CiZLHNi3jgWyQfZuq5+Nj3n5bRW7 XGhD9w9ZYT8KC0QWe9pM2GmTHsyY9h93Fn83xzlcnP1KiFVd2pEmdbQZbIR6CIWx6xYm obAyeEBRrK3tSRBcQ5pk0p4iVZCuOK36a4BCcAtrTL6bm5FJOHS2Zd0Ygnsr2B6l0+Z1 OAFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=elQIAT3C; 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 x184-20020a6386c1000000b0055ba896f567si929013pgd.585.2023.07.06.00.25.58; Thu, 06 Jul 2023 00:26:11 -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=elQIAT3C; 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 S233608AbjGFHHY (ORCPT + 99 others); Thu, 6 Jul 2023 03:07:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233558AbjGFHHW (ORCPT ); Thu, 6 Jul 2023 03:07:22 -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 220EC1989 for ; Thu, 6 Jul 2023 00:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688627195; 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=POrI2HrupnKR3vfjjFVb4RJeA3XrZk3xd7QFOuOo4BE=; b=elQIAT3COjA7bpRtQJTHHOyBzOsmN8rZRzWDx7i/yF4e27AxkCVpW70Ux/jXPWfjgM4P3h v1HsPY16aAYyukpFd5UP/lTX7VHeTrSmd+nRoEgKAs/fpZk0SnfkjamumJpMx2zDiVptBu UlyeCGDbmV0GJvrBA+/QecIMBNKvdfw= Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-668-ewV86vy4MXiFLYxCB_sWCQ-1; Thu, 06 Jul 2023 03:06:34 -0400 X-MC-Unique: ewV86vy4MXiFLYxCB_sWCQ-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-c5cea5773e8so523313276.1 for ; Thu, 06 Jul 2023 00:06:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688627194; x=1691219194; 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=POrI2HrupnKR3vfjjFVb4RJeA3XrZk3xd7QFOuOo4BE=; b=Wk5kFfU6DMZAkmH6wpBwUozZnR3CWI3D9Zu0nQYLHQyj1dLok4xQowNTS4yuEB0OrS LTu5d7zUymDGxQ+xI+CyzUxToipDMpiFmVaSGRsUQsZG+an45NRm0meIMrfYP0i1pv7O VZAzdc4ImeRwMamzq4K2DfoySgzs1R9Tpp2HAV7YX60dpvyzaGL7Jk/oZLkGYoWk2UM3 iirb6AZwo21/Q9TiaAwLYiM30dtjc0wnxDVypdDxNeJozrlRLK63jZcNaFBYlKsIm9bE vniie+CpuYcwsvtNymcZf+CowL8LJcRqN24ye+x/gOz2tWlmfI0cjkoSKKrJLWa3BZ4b VTdw== X-Gm-Message-State: ABy/qLbSWHbuDqZeXKhWphGs5WVx1F8gnqmSbFBIVDVPbTWmPDLgjUdG Q6yYWsVM78y4Z7prWQmU37MUxtbCMWkyr43dTwxEV2qoLMGd+fXMDwN47MdzVfvhNZlbt+F9Kxn NCon/6OB3NiFaN2XMHmJTkImIaWlaZU1U4tE4NuvS X-Received: by 2002:a25:b944:0:b0:c4d:96a2:5d96 with SMTP id s4-20020a25b944000000b00c4d96a25d96mr2165151ybm.34.1688627193146; Thu, 06 Jul 2023 00:06:33 -0700 (PDT) X-Received: by 2002:a25:b944:0:b0:c4d:96a2:5d96 with SMTP id s4-20020a25b944000000b00c4d96a25d96mr2165135ybm.34.1688627192836; Thu, 06 Jul 2023 00:06:32 -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> <20230705043940-mutt-send-email-mst@kernel.org> In-Reply-To: From: Eugenio Perez Martin Date: Thu, 6 Jul 2023 09:05:56 +0200 Message-ID: Subject: Re: [PATCH] vdpa: reject F_ENABLE_AFTER_DRIVER_OK if backend does not support it To: Jason Wang Cc: "Michael S. Tsirkin" , 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 Thu, Jul 6, 2023 at 3:55=E2=80=AFAM Jason Wang wro= te: > > On Wed, Jul 5, 2023 at 4:41=E2=80=AFPM Michael S. Tsirkin wrote: > > > > On Wed, Jul 05, 2023 at 03:49:58PM +0800, Jason Wang wrote: > > > 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 wrot= e: > > > > > 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=A9re= z 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 curren= t code will not > > > > > > > > > complain for it. > > > > > > > > > > > > > > > > > > Since there is no specific reason for any parent to rejec= t that backend > > > > > > > > > feature bit when it has been proposed, let's control it a= t 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=C3=A9rez > > > > > > > > > > > > > > > > Please do send v3. And again, I don't want to send "after d= river ok" hack > > > > > > > > upstream at all, I merged it in next just to give it some t= esting. > > > > > > > > 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 st= art > > > > > traffic at the LM destination [1]. When it was proposed, that spu= rious > > > > > 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/msg0= 2775.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. > > As discussed before, this seems to have some problems: > > 1) The behaviour is not clarified in the document > 2) zero is a valid IOVA > I think we're not on the same page here. As I understood, rings mapped to a zero page means essentially an avail ring whose avail_idx is always 0, offered to the device instead of the guest's ring. Once all CVQ commands are processed, we use RING_RESET to switch to the right ring, being guest's or SVQ vring. > Thanks > > > > > > > > > > > > > > > > > > > > > > My plan was to convert > > > > > > > it in vp_vdpa if needed, and reuse the current vdpa ops. Sorr= y if I > > > > > > > was not explicit enough. > > > > > > > > > > > > > > The only solution I can see to that is to trap & emulate in t= he vdpa > > > > > > > (parent?) driver, as talked in virtio-comment. But that compl= icates > > > > > > > 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 enabl= e to hw > > > > > > > * Store the doorbell state separately, but do not configure i= t to the > > > > > > > device directly. > > > > > > > > > > > > > > But how to recover if the device cannot configure them at kic= k 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 neede= d. > > > > > > > > > > > > > > Thanks! > > > > > > > > > > > > > > > > > > > > > > > > --- > > > > > > > > > Sent with Fixes: tag pointing to git.kernel.org/pub/scm/l= inux/kernel/git/mst > > > > > > > > > commit. Please let me know if I should send a v3 of [1] i= nstead. > > > > > > > > > > > > > > > > > > [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_ioc= tl(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->conf= ig; > > > > > > > > > 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, siz= eof(features))) > > > > > > > > > return -EFAULT; > > > > > > > > > + if (ops->get_backend_features) > > > > > > > > > + parent_features =3D ops->get_backen= d_features(v->vdpa); > > > > > > > > > if (features & ~(VHOST_VDPA_BACKEND_FEATURE= S | > > > > > > > > > BIT_ULL(VHOST_BACKEND_F_SU= SPEND) | > > > > > > > > > BIT_ULL(VHOST_BACKEND_F_RE= SUME) | > > > > > > > > > - BIT_ULL(VHOST_BACKEND_F_EN= ABLE_AFTER_DRIVER_OK))) > > > > > > > > > + parent_features)) > > > > > > > > > return -EOPNOTSUPP; > > > > > > > > > if ((features & BIT_ULL(VHOST_BACKEND_F_SUS= PEND)) && > > > > > > > > > !vhost_vdpa_can_suspend(v)) > > > > > > > > > -- > > > > > > > > > 2.39.3 > > > > > > > > > > > > > > > > > > > > >