From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF27DC433E6 for ; Wed, 17 Mar 2021 03:59:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5DB564F7F for ; Wed, 17 Mar 2021 03:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229613AbhCQD7Y (ORCPT ); Tue, 16 Mar 2021 23:59:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57328 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231151AbhCQD7I (ORCPT ); Tue, 16 Mar 2021 23:59:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615953547; 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=7ndZ/EPGx75V6OcMRIv9fS1gIYZrKaTsBexZg2LyBVk=; b=T51uTlvEkD3nNPDWaApXyskyH1dkRosd32/pNBt46VQVwVggG/eQ8MaX2SrcQNLp13ufMJ jFkUJC99Ce7QzJlBZ3/O1RrWiZ1qUOQ7LuORru8BDDIV4SR3ez0F+vhb75MkH9+v7lq09w xvwfx6GLJvvpW8yHNOhT5OsLTjUJKmQ= 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-56-clyX9_PcOj2OvZ5sHHJCgg-1; Tue, 16 Mar 2021 23:59:05 -0400 X-MC-Unique: clyX9_PcOj2OvZ5sHHJCgg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9B2F363A1; Wed, 17 Mar 2021 03:59:03 +0000 (UTC) Received: from wangxiaodeMacBook-Air.local (ovpn-12-188.pek2.redhat.com [10.72.12.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id E32CC19706; Wed, 17 Mar 2021 03:58:57 +0000 (UTC) Subject: Re: [PATCH V4 6/7] vDPA/ifcvf: verify mandatory feature bits for vDPA To: Zhu Lingshan , mst@redhat.com, lulu@redhat.com, leonro@nvidia.com Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20210315074501.15868-1-lingshan.zhu@intel.com> <20210315074501.15868-7-lingshan.zhu@intel.com> From: Jason Wang Message-ID: <3188205d-250f-8dfe-c271-50be5c1e2e58@redhat.com> Date: Wed, 17 Mar 2021 11:58:56 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210315074501.15868-7-lingshan.zhu@intel.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ÔÚ 2021/3/15 ÏÂÎç3:45, Zhu Lingshan дµÀ: > vDPA requres VIRTIO_F_ACCESS_PLATFORM as a must, this commit > examines this when set features. > > Signed-off-by: Zhu Lingshan > --- > drivers/vdpa/ifcvf/ifcvf_base.c | 12 ++++++++++++ > drivers/vdpa/ifcvf/ifcvf_base.h | 1 + > drivers/vdpa/ifcvf/ifcvf_main.c | 5 +++++ > 3 files changed, 18 insertions(+) > > diff --git a/drivers/vdpa/ifcvf/ifcvf_base.c b/drivers/vdpa/ifcvf/ifcvf_base.c > index ea6a78791c9b..4f257c4b2f76 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_base.c > +++ b/drivers/vdpa/ifcvf/ifcvf_base.c > @@ -224,6 +224,18 @@ u64 ifcvf_get_features(struct ifcvf_hw *hw) > return hw->hw_features; > } > > +int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features) > +{ > + struct ifcvf_adapter *ifcvf = vf_to_adapter(hw); > + > + if (!(features & BIT_ULL(VIRTIO_F_ACCESS_PLATFORM)) && features) { > + IFCVF_ERR(ifcvf->pdev, "VIRTIO_F_ACCESS_PLATFORM not negotiated\n"); Should be "is not negotiated". Otherwise: Acked-by: Jason Wang > + return -EINVAL; > + } > + > + return 0; > +} > + > void ifcvf_read_net_config(struct ifcvf_hw *hw, u64 offset, > void *dst, int length) > { > diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h > index dbb8c10aa3b1..f77239fc1644 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_base.h > +++ b/drivers/vdpa/ifcvf/ifcvf_base.h > @@ -123,6 +123,7 @@ void io_write64_twopart(u64 val, u32 *lo, u32 *hi); > void ifcvf_reset(struct ifcvf_hw *hw); > u64 ifcvf_get_features(struct ifcvf_hw *hw); > u64 ifcvf_get_hw_features(struct ifcvf_hw *hw); > +int ifcvf_verify_min_features(struct ifcvf_hw *hw, u64 features); > u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid); > int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num); > struct ifcvf_adapter *vf_to_adapter(struct ifcvf_hw *hw); > diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c > index 25fb9dfe23f0..ea93ea7fd5df 100644 > --- a/drivers/vdpa/ifcvf/ifcvf_main.c > +++ b/drivers/vdpa/ifcvf/ifcvf_main.c > @@ -179,6 +179,11 @@ static u64 ifcvf_vdpa_get_features(struct vdpa_device *vdpa_dev) > static int ifcvf_vdpa_set_features(struct vdpa_device *vdpa_dev, u64 features) > { > struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev); > + int ret; > + > + ret = ifcvf_verify_min_features(vf, features); > + if (ret) > + return ret; > > vf->req_features = features; >