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=-5.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 0AFCFC433E6 for ; Tue, 2 Feb 2021 12:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C132464F66 for ; Tue, 2 Feb 2021 12:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231380AbhBBMJ6 (ORCPT ); Tue, 2 Feb 2021 07:09:58 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:12382 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbhBBMJg (ORCPT ); Tue, 2 Feb 2021 07:09:36 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4DVNq54Kjjz7YvC; Tue, 2 Feb 2021 20:07:29 +0800 (CST) Received: from [10.174.184.42] (10.174.184.42) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Tue, 2 Feb 2021 20:08:46 +0800 Subject: Re: [PATCH v11 03/13] vfio: VFIO_IOMMU_SET_MSI_BINDING To: Eric Auger , , , , , , , , , , References: <20201116110030.32335-1-eric.auger@redhat.com> <20201116110030.32335-4-eric.auger@redhat.com> CC: , , , , , From: Keqian Zhu Message-ID: <635db234-33ff-c079-40cb-2de00c089e7c@huawei.com> Date: Tue, 2 Feb 2021 20:08:45 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <20201116110030.32335-4-eric.auger@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Hi Eric, On 2020/11/16 19:00, Eric Auger wrote: > This patch adds the VFIO_IOMMU_SET_MSI_BINDING ioctl which aim > to (un)register the guest MSI binding to the host. This latter > then can use those stage 1 bindings to build a nested stage > binding targeting the physical MSIs. [...] > +static int vfio_iommu_type1_set_msi_binding(struct vfio_iommu *iommu, > + unsigned long arg) > +{ > + struct vfio_iommu_type1_set_msi_binding msi_binding; > + unsigned long minsz; > + int ret = -EINVAL; > + > + minsz = offsetofend(struct vfio_iommu_type1_set_msi_binding, > + size); > + > + if (copy_from_user(&msi_binding, (void __user *)arg, minsz)) > + return -EFAULT; > + > + if (msi_binding.argsz < minsz) > + return -EINVAL; We can check BIND and UNBIND are not set simultaneously, just like VFIO_IOMMU_SET_PASID_TABLE. > + > + if (msi_binding.flags == VFIO_IOMMU_UNBIND_MSI) { > + vfio_unbind_msi(iommu, msi_binding.iova); > + ret = 0; > + } else if (msi_binding.flags == VFIO_IOMMU_BIND_MSI) { > + ret = vfio_bind_msi(iommu, msi_binding.iova, > + msi_binding.gpa, msi_binding.size); > + } > + return ret; > +} > + Thanks, Keqian