From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38512) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQW9-0002wE-3a for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOQW4-0002AV-4l for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:17 -0500 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:36932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQW3-0002AF-U4 for qemu-devel@nongnu.org; Wed, 27 Jan 2016 08:52:12 -0500 Received: by mail-wm0-x234.google.com with SMTP id n5so27459042wmn.0 for ; Wed, 27 Jan 2016 05:52:11 -0800 (PST) From: Eric Auger Date: Wed, 27 Jan 2016 13:51:52 +0000 Message-Id: <1453902715-25304-5-git-send-email-eric.auger@linaro.org> In-Reply-To: <1453902715-25304-1-git-send-email-eric.auger@linaro.org> References: <1453902715-25304-1-git-send-email-eric.auger@linaro.org> Subject: [Qemu-devel] [RFC 4/7] hw: vfio: common: introduce vfio_register_reserved_iova List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: eric.auger@st.com, eric.auger@linaro.org, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org, alex.williamson@redhat.com, pranav.sawargaonkar@gmail.com, p.fedin@samsung.com, pbonzini@redhat.com, agraf@suse.de Cc: Bharat.Bhushan@freescale.com, suravee.suthikulpanit@amd.com, christoffer.dall@linaro.org vfio_register_reserved_iova allows to register the reserved IOVA region, typically for MSI frame binding purpose. The kernel allows registering a single reserved IOVA region. Unregistration is handled through legacy vfio_dma_unmap. The function will become static in subsequent patches. However, since there is no user yet, the compiler argues; the function is currently not static and a dummy declaration needs to be added. Signed-off-by: Eric Auger --- hw/vfio/common.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 6797208..247c87b 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -208,6 +208,36 @@ static int vfio_dma_unmap(VFIOContainer *container, return 0; } +/** + * vfio_register_reserved_iova: registers the iova reserved region + * + * @container: container handle + * @iova: base iova of the reserved region + * @size: reserved region size + * + * unregistration is handled using vfio_dma_unmap + */ +int vfio_register_reserved_iova(VFIOContainer *container, hwaddr iova, + ram_addr_t size); +int vfio_register_reserved_iova(VFIOContainer *container, hwaddr iova, + ram_addr_t size) +{ + struct vfio_iommu_type1_dma_map map = { + .argsz = sizeof(map), + .flags = VFIO_DMA_MAP_FLAG_MSI_RESERVED_IOVA, + .iova = iova, + .size = size, + }; + + if (ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map) == 0) { + return 0; + } + + error_report("VFIO_MAP_DMA/MSI_RESERVED_IOVA: %d", -errno); + return -errno; + +} + static int vfio_dma_map(VFIOContainer *container, hwaddr iova, ram_addr_t size, void *vaddr, bool readonly) { -- 1.9.1