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 9DBA7C433E0 for ; Tue, 2 Feb 2021 12:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66FA764F63 for ; Tue, 2 Feb 2021 12:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbhBBMKf (ORCPT ); Tue, 2 Feb 2021 07:10:35 -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: linux-kernel@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 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,URIBL_BLOCKED,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 DEFE1C433DB for ; Tue, 2 Feb 2021 12:09:13 +0000 (UTC) Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7977664F64 for ; Tue, 2 Feb 2021 12:09:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7977664F64 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 29A628555A; Tue, 2 Feb 2021 12:09:13 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2rT06PBldKu3; Tue, 2 Feb 2021 12:09:04 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 470BE85310; Tue, 2 Feb 2021 12:08:53 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 34C79C0FA7; Tue, 2 Feb 2021 12:08:53 +0000 (UTC) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id C4EF1C013A for ; Tue, 2 Feb 2021 12:08:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B36A8851AA for ; Tue, 2 Feb 2021 12:08:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JY245aYNa3Rw for ; Tue, 2 Feb 2021 12:08:50 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by fraxinus.osuosl.org (Postfix) with ESMTPS id 1872C8506A for ; Tue, 2 Feb 2021 12:08:50 +0000 (UTC) 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> 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> X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Cc: jean-philippe@linaro.org, vivek.gautam@arm.com, zhangfei.gao@linaro.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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,URIBL_BLOCKED,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 81A50C433E0 for ; Tue, 2 Feb 2021 12:08:56 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 8006D64F65 for ; Tue, 2 Feb 2021 12:08:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8006D64F65 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B64614B14A; Tue, 2 Feb 2021 07:08:54 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NWCG53DNcINH; Tue, 2 Feb 2021 07:08:53 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A6CEF4B194; Tue, 2 Feb 2021 07:08:53 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4DF374B14A for ; Tue, 2 Feb 2021 07:08:52 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TDSq95IIzZ9F for ; Tue, 2 Feb 2021 07:08:50 -0500 (EST) Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 6CA914B13C for ; Tue, 2 Feb 2021 07:08:50 -0500 (EST) 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> 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> X-Originating-IP: [10.174.184.42] X-CFilter-Loop: Reflected Cc: jean-philippe@linaro.org, jacob.jun.pan@linux.intel.com, nicoleotsuka@gmail.com, vivek.gautam@arm.com, yi.l.liu@intel.com, zhangfei.gao@linaro.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu 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 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm