Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp27489568rwd; Tue, 4 Jul 2023 03:50:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGfQXSOoz0clDY+2UT2cORBTa4JWGQVOiQmdyi63dcdwXSj5VMs458stR+idWiANtZMODni X-Received: by 2002:a17:903:182:b0:1b8:944a:a932 with SMTP id z2-20020a170903018200b001b8944aa932mr4023238plg.2.1688467858853; Tue, 04 Jul 2023 03:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688467858; cv=none; d=google.com; s=arc-20160816; b=kR4ec5D+s3a0XmAQkAy5AWXXV4Z3L2rMZMP98oeCJp3/f/dm1fJtzcIFI5mZJ79PPe 6pVN9gzPV/iHYblilMpyEtxnngdu360w9QDQFb1nvAHsqUPFWaNNDdn6MWv+W6sDUt6N S0nV4a5UXAPgc7NpnrCZBSr0zuJ17CD1Wh9uaxPqXzPtc/zhswFAabw+dqwG8QF83Yz6 p8mC+LrLw/ZbUFotrsoxEEi0KxqzE03KHzkCy/JRiYKPPwhQilymdXAlBNwOVKPZHtRu FseUOXVusFiELgiemvBq/z2P4EI+aetFwWcfqtBKwQFDxKBJRDDw7TYb4ELpjbujqMQ2 jjqg== 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=NACau5wNdfF9cBpcRDB4PdaraQX5g3P3BOInJlILPJs=; fh=I6HMivtMMSX6CmdDLC6TNnwxqBVQ3w/+BoY/RwnB+MM=; b=YuEI8GIBgywymzvpHmzyTbM34eNLtjTXXW1GJ1nNYDJzg02AO8y6WQevbLgfuF0Iu1 a9n9pveBl4OH6mBLUPAiYWLJGEg56TQDRORaB+bHlKxMTLvTPTvJCzVMlCsm6wYxQUER HmvmlBCtUtmCitaCJmli9nfUm4xJOPE3l7uUDeesIqtAOT8dtUql8L6XLTL2gOaQ35hU BuQsi+ZE/WMqRDzwxTud8fws97D/AvaGXzfJCF0u9b8Mx/0yRJ/Z/+GG672/S7F5SUh2 0g3Td4vd9j6b4iwtigKgwJ1spNSnIMXO3d68pxcCAyo/IBHSI4rZ3ZxSsjIBIkNhkhnO 9icQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LyoIi8T4; 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 x16-20020a170902ec9000b001b8a8ece50fsi439638plg.413.2023.07.04.03.50.43; Tue, 04 Jul 2023 03:50:58 -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=LyoIi8T4; 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 S231302AbjGDK1U (ORCPT + 99 others); Tue, 4 Jul 2023 06:27:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231666AbjGDK1R (ORCPT ); Tue, 4 Jul 2023 06:27:17 -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 E69B51720 for ; Tue, 4 Jul 2023 03:26:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688466370; 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=NACau5wNdfF9cBpcRDB4PdaraQX5g3P3BOInJlILPJs=; b=LyoIi8T4rldQbisX2sVXN5hJv33RfctidYIxsP8HzraZjcJmBeGeEJMu/f7cvB8RDrm2vC vaWP7tBX6i0Q5a8ReNPPj1fkxYDc7yE/ailRqWCa89l51bG0Zc5Bhwbem2x0s/t1sYo17c 4ccVugiARVUbjIP4UFb/2/Bn2tUuUGA= 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-335--zRALzyFPGCWBK9DpgYJ2g-1; Tue, 04 Jul 2023 06:26:09 -0400 X-MC-Unique: -zRALzyFPGCWBK9DpgYJ2g-1 Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-c4e0342c50dso3135541276.2 for ; Tue, 04 Jul 2023 03:26:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688466369; x=1691058369; 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=NACau5wNdfF9cBpcRDB4PdaraQX5g3P3BOInJlILPJs=; b=GoAgW1EMTi4+RY4GZl99A27lPRY7WK9yo+Lb7kEF5zavGyibfXRN/mk27pkIP8nElK +MpfNsRryjPvWjWJhhhjJo4wUpIOs0Abjciz911jEmom4ZBJzpg8VIEBp7IfN/pLOUH2 Df2Yv6yoIsDvdopOJ+3yN2cflSdU6VxT+86JjjbaGaeMqVT6IZGIDYtj+Lk9vxIrTSjL 9mSjSAC2FYin7yqo+4sBetmYHbxXPjhNdvzQ0bVKBap6liyd0nqpU64vSODXccV+hB8q ayTeYUlmRbAsreDmFMJhqN8jNiLRDiy6sWb57DbFhB/BCxeaPZyQhiTQnYosb+j91pVQ +bZA== X-Gm-Message-State: ABy/qLZAW/S0paliiKqxmEa3viHZ5Qai87B1Q/Oeczg7nvonMFyPgxrm v3UZGA0gVFqA+WHmUSZtyuOTR0wdpIqJF7t368pHrv3aY3c2+sGoSxJJ29+acCIpbc/m8DZHaaY Mc2hiV9KNVnCYFhRM6QSFEc0+bo4AGdkIPO9VqWnYlLX64aZ0 X-Received: by 2002:a25:6814:0:b0:bfe:bf77:64fd with SMTP id d20-20020a256814000000b00bfebf7764fdmr12220354ybc.12.1688466368789; Tue, 04 Jul 2023 03:26:08 -0700 (PDT) X-Received: by 2002:a25:6814:0:b0:bfe:bf77:64fd with SMTP id d20-20020a256814000000b00bfebf7764fdmr12220350ybc.12.1688466368546; Tue, 04 Jul 2023 03:26:08 -0700 (PDT) MIME-Version: 1.0 References: <20230703142218.362549-1-eperezma@redhat.com> <20230703105022-mutt-send-email-mst@kernel.org> In-Reply-To: <20230703105022-mutt-send-email-mst@kernel.org> From: Eugenio Perez Martin Date: Tue, 4 Jul 2023 12:25:32 +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 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 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 will no= t > > 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 fronten= d > > 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 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. 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/gi= t/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@ker= nel.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(features))= ) > > 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_DRI= VER_OK))) > > + parent_features)) > > return -EOPNOTSUPP; > > if ((features & BIT_ULL(VHOST_BACKEND_F_SUSPEND)) && > > !vhost_vdpa_can_suspend(v)) > > -- > > 2.39.3 >