Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp245403pxb; Tue, 2 Feb 2021 04:14:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXd6CO+SfnlHhlI3AQB1jlAlORyN9/quo782lOT/omyXzD71Z2ijpNi2QcOuAL0ZHvW8sY X-Received: by 2002:aa7:c9c9:: with SMTP id i9mr23194690edt.160.1612268083406; Tue, 02 Feb 2021 04:14:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612268083; cv=none; d=google.com; s=arc-20160816; b=io1rL0uOdRFcwDcXcC+sWeBcicedgtbz/glmsw2FsH/gUWDc1umiiSiIET9LSSUIJG G1NT4p3G6vLcuQRXqI8wFN1NcJgtN7vunk/BuwwgH1RCHwFKsPTahMZdbtvO06G8qi2G YRskoqYWYYI6V7MwqVDaTZYS6c+Op5HVAUJxEXWUr+rlzFXyX7ETWVaUoPbVG16NQ2/n LXQF38SEcUY2fzV0kZP+A1c5cr4rV4M82ODhKzCGd/30CwzvHPiHdrHvCUlMCZk0+rD7 EOFPw0ztQs2ZInuFEzX3VjKvg/nGzgygoHuPSVdAgKPqfeDkD6oN1XO6jDVa2XXwnTwL TaqA== 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:from:cc:references:to :subject; bh=9O3ngBn6gjyPf68BLVOhl70lpzkjrJwPxJHSjUe4xVU=; b=JZLnldbUX0MdxAMj+szvsTBEs5U1OvIwk09VODn+nvtUQkWi3Jnq40TaEjVOeeRG4T kUbEf1mbvnpQuQoSD1avamn3gE4fvGhtIEj8S2V4DTfhLYJOpewfvhf904RwtYl4bXAE E6bo6crZHEzwJlA5VC85uBOcvBgZXE7/CPHKwDnPKIShIW/D/0JDf2aaxZkwM6F3BRcW SA8xgXoCOZIaDxDyEmUtZ2lrTeV/XfajuVt30WjNfHnNYndWLgitYx6V4L165QRnpM1a +M7BrshAFNdbFxChkDJ1cUxdGv8qUONRjUg7/GdAajrUteY8HUrG9ZOVTsEPYDc2DCB3 m1pg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o32si14289506edd.357.2021.02.02.04.14.18; Tue, 02 Feb 2021 04:14:43 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231357AbhBBMKZ (ORCPT + 99 others); Tue, 2 Feb 2021 07:10:25 -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