Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp281444pxy; Wed, 21 Apr 2021 02:53:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQKzIk4YKKT3K9muzP6adijOyD8+tlMKBnG4UvEvqL2Kj45AJnByB4xBbwttsqXmhnGiV3 X-Received: by 2002:a50:8d8a:: with SMTP id r10mr36197441edh.132.1618998809383; Wed, 21 Apr 2021 02:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618998809; cv=none; d=google.com; s=arc-20160816; b=wQZ3Fk52mRpof3JDRk3Hu9RUlqLcPpw14bYjfJLUoJI5AH5sBb9Hh2eqXdX2yFP7pj 9f1vaAPuaq269tXrRtVeflv5MSTNNq4DqUAL7djdXOyJISIFWoZlqeVD9JigfoXbLncA 9fOiJiFn+2yp3C9da2HaxeNYjBbSSamNF/VQxQ1Xmwkbf+fNGD+0iT1266v7JO6M0MZ/ 75Eqt4cmkFXwDGmqAu4X+FTHQJBnZVgJiTgoM+cnTRNZxxnuKoAXB5QPkRBq128sxiRf yexJTnrdRo2dW/G9yDE0aGcZ7OvTMfg+ED0b1g/QoXhcn/BtqR1+dYWhYtUVv8CRIO0N Ltog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject:dkim-signature; bh=2yN6XcKhbSauKK4BfJl008OKCv6/B7lbDp7G8UqJ3nU=; b=Hax2XhZapsHHMZBP3wb/SdaI0aHF5KrYzUOcmk4Szi4JtzYQ7xd2DwfmC5IG8B00Cd awkMBwknH0EwR/FWaY+rZqJSZ+L1y8MrJwpYaEB9BjXp6IOWKwHQVQJWf9U3JyT650ak pPS5MpPUUHzYy35ONZdKzef3FAEGyXifhhNQYcS1FysJSk9F/G6V8uUolVFnxaTFDpHe vBy/9gwGdl0FduJYD6b25xqlfd+kFAXlWFoV4CWTKm/CVqvHzdO9dDLfPPMud7aGfDgn 4jYlE9f7FR1PHg+Ppr8PPwslbQxWOsVUzFk7XRcopf3GpNjfkDAg2yYHEzvFxZQnx7pw ehAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iq1bx22D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j16si1502519edt.522.2021.04.21.02.53.06; Wed, 21 Apr 2021 02:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iq1bx22D; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237099AbhDUHmW (ORCPT + 99 others); Wed, 21 Apr 2021 03:42:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46081 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235209AbhDUHmW (ORCPT ); Wed, 21 Apr 2021 03:42:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618990909; 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=2yN6XcKhbSauKK4BfJl008OKCv6/B7lbDp7G8UqJ3nU=; b=iq1bx22DiZR6iSSBq6LpediJbIB//2UjN6PJyst70dNlfQBT4sFqpw+UpyawP4lvy3Gj/V KqKxaU0X4YzAAz8N5MCL4PXMghCK/OymYLBwEwc367Z0aBxp460xISUB8Q7bCRyYwhLzgu /8Fk11BrxzvH8P6/DztK7BDyLnyafm0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-588-XujTHFoeOWm6cWS6FymcKA-1; Wed, 21 Apr 2021 03:41:45 -0400 X-MC-Unique: XujTHFoeOWm6cWS6FymcKA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 64A691B2C980; Wed, 21 Apr 2021 07:41:44 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-13-189.pek2.redhat.com [10.72.13.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE94A60C5F; Wed, 21 Apr 2021 07:41:38 +0000 (UTC) Subject: Re: [RFC PATCH] vdpa: mandate 1.0 device From: Jason Wang To: "Michael S. Tsirkin" Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, parav@nvidia.com, elic@nvidia.com, "Zhu, Lingshan" References: <20210408082648.20145-1-jasowang@redhat.com> <20210408115834-mutt-send-email-mst@kernel.org> <20210409115343-mutt-send-email-mst@kernel.org> <42891807-cb24-5352-f8cb-798e9d1a1854@redhat.com> <20210412050730-mutt-send-email-mst@kernel.org> <01918e14-7f7a-abf2-5864-292a32f0233c@redhat.com> Message-ID: Date: Wed, 21 Apr 2021 15:41:36 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <01918e14-7f7a-abf2-5864-292a32f0233c@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2021/4/12 下午5:23, Jason Wang 写道: > > 在 2021/4/12 下午5:09, Michael S. Tsirkin 写道: >> On Mon, Apr 12, 2021 at 02:35:07PM +0800, Jason Wang wrote: >>> 在 2021/4/10 上午12:04, Michael S. Tsirkin 写道: >>>> On Fri, Apr 09, 2021 at 12:47:55PM +0800, Jason Wang wrote: >>>>> 在 2021/4/8 下午11:59, Michael S. Tsirkin 写道: >>>>>> On Thu, Apr 08, 2021 at 04:26:48PM +0800, Jason Wang wrote: >>>>>>> This patch mandates 1.0 for vDPA devices. The goal is to have the >>>>>>> semantic of normative statement in the virtio spec and eliminate >>>>>>> the >>>>>>> burden of transitional device for both vDPA bus and vDPA parent. >>>>>>> >>>>>>> uAPI seems fine since all the vDPA parent mandates >>>>>>> VIRTIO_F_ACCESS_PLATFORM which implies 1.0 devices. >>>>>>> >>>>>>> For legacy guests, it can still work since Qemu will mediate when >>>>>>> necessary (e.g doing the endian conversion). >>>>>>> >>>>>>> Signed-off-by: Jason Wang >>>>>> Hmm. If we do this, don't we still have a problem with >>>>>> legacy drivers which don't ack 1.0? >>>>> Yes, but it's not something that is introduced in this commit. The >>>>> legacy >>>>> driver never work ... >>>> My point is this neither fixes or prevents this. >>>> >>>> So my suggestion is to finally add ioctls along the lines >>>> of PROTOCOL_FEATURES of vhost-user. >>>> >>>> Then that one can have bits for legacy le, legacy be and modern. >>>> >>>> BTW I looked at vhost-user and it does not look like that >>>> has a solution for this problem either, right? >>> >>> Right. >>> >>> >>>> >>>>>> Note 1.0 affects ring endianness which is not mediated in QEMU >>>>>> so QEMU can't pretend to device guest is 1.0. >>>>> Right, I plan to send patches to do mediation in the Qemu to >>>>> unbreak legacy >>>>> drivers. >>>>> >>>>> Thanks >>>> I frankly think we'll need PROTOCOL_FEATURES anyway, it's too >>>> useful ... >>>> so why not teach drivers about it and be done with it? You can't >>>> emulate >>>> legacy on modern in a cross endian situation because of vring >>>> endian-ness ... >>> >>> So the problem still. This can only work when the hardware can support >>> legacy vring endian-ness. >>> >>> Consider: >>> >>> 1) the leagcy driver support is non-normative in the spec >>> 2) support a transitional device in the kenrel may requires the >>> hardware >>> support and a burden of kernel codes >>> >>> I'd rather simply drop the legacy driver support >> >> My point is this patch does not drop legacy support. It merely mandates >> modern support. > > > I am not sure I get here. This patch fails the set_feature if > VERSION_1 is not negotiated. This means: > > 1) vDPA presents a modern device instead of transitonal device > 2) legacy driver can't be probed > > What I'm missing? Hi Michael: Do you agree to find the way to present modern device? We need a conclusion to make the netlink API work to move forward. Thanks > > >> >>> to have a simple and easy >>> abstarction in the kenrel. For legacy driver in the guest, >>> hypervisor is in >>> charge of the mediation: >>> >>> 1) config space access endian conversion >>> 2) using shadow virtqueue to change the endian in the vring >>> >>> Thanks >> I'd like to avoid shadow virtqueue hacks if at all possible. >> Last I checked performance wasn't much better than just emulating >> virtio in software. > > > I think the legacy driver support is just a nice to have. Or do you > see any value to that? I guess for mellanox and intel, only modern > device is supported in the hardware. > > Thanks > > >> >>>> >>>>>> >>>>>> >>>>>> >>>>>>> --- >>>>>>>     include/linux/vdpa.h | 6 ++++++ >>>>>>>     1 file changed, 6 insertions(+) >>>>>>> >>>>>>> diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h >>>>>>> index 0fefeb976877..cfde4ec999b4 100644 >>>>>>> --- a/include/linux/vdpa.h >>>>>>> +++ b/include/linux/vdpa.h >>>>>>> @@ -6,6 +6,7 @@ >>>>>>>     #include >>>>>>>     #include >>>>>>>     #include >>>>>>> +#include >>>>>>>     /** >>>>>>>      * vDPA callback definition. >>>>>>> @@ -317,6 +318,11 @@ static inline int vdpa_set_features(struct >>>>>>> vdpa_device *vdev, u64 features) >>>>>>>     { >>>>>>>             const struct vdpa_config_ops *ops = vdev->config; >>>>>>> +        /* Mandating 1.0 to have semantics of normative >>>>>>> statements in >>>>>>> +         * the spec. */ >>>>>>> +        if (!(features & BIT_ULL(VIRTIO_F_VERSION_1))) >>>>>>> +        return -EINVAL; >>>>>>> + >>>>>>>         vdev->features_valid = true; >>>>>>>             return ops->set_features(vdev, features); >>>>>>>     } >>>>>>> -- >>>>>>> 2.25.1 >