From patchwork Wed Jan 27 13:51:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 60626 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2596021lbb; Wed, 27 Jan 2016 05:56:43 -0800 (PST) X-Received: by 10.141.7.9 with SMTP id j9mr36289858qhd.71.1453903003838; Wed, 27 Jan 2016 05:56:43 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id d90si6688764qge.72.2016.01.27.05.56.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 27 Jan 2016 05:56:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro.org Received: from localhost ([::1]:50681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOQaR-0001mj-Ed for patch@linaro.org; Wed, 27 Jan 2016 08:56:43 -0500 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=m/sUPWwI+V6iWVZQmd7TY0OLyRNcL7ZsnZzsKZVuYhc=; b=OBe3xWAk6WXym0Mn6hQ5fwB8Rqx/6ByYHeO+UKEvSb7YDPiKqFZfbgf0SwbARTmYYs VJSQJaLidhEu9QB3vezq4b/culRaXQP8vhvuKG31QC+fJFiMcAubxX0PHNQM/H00l+/f 3xmWrFA+H0JvgPPS4SATl4d8F+utCkpfuD8/Y= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=m/sUPWwI+V6iWVZQmd7TY0OLyRNcL7ZsnZzsKZVuYhc=; b=apF104a6USN65iOZWZGACI7qBcY8iRTbX7jd0HOYwNNSY25Ox6+ty1ga4lZ1N9P0ls OstoUjM42jAyh8JVb2eEKkt1WcKeJ8pn4NVygKZ8mB266YV/zb2En2GdkmH/wug2V9Bx SWgWTz6paAbHbZJUGEELJ6N04M6C50mO4t3kZBLUYRoYCyqUan7i6M/g3sHYZoTXl4bF SZXcFDq262N10GFcudA9Eqjmxqfd+CdL4uYNyhIgfFuyZh6zDgzr+n/cjWUmFLQF7S0R JAeBaZR8SKa1Aqpqubpl048Qsf+4c47buC79wdhOSe1vIDylLKyKcZjRLAE3uX9UrCYT UtYA== X-Gm-Message-State: AG10YOS5o7BVEAqFomDKy4Xji86xcMYCrk5qz9trRS9gWExB4NMCa5Y88i4HSO/tfWp5IKxs X-Received: by 10.28.173.208 with SMTP id w199mr28699707wme.45.1453902731211; Wed, 27 Jan 2016 05:52:11 -0800 (PST) Received: from new-host-8.home (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id t9sm6345866wjf.33.2016.01.27.05.52.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 27 Jan 2016 05:52:09 -0800 (PST) From: Eric Auger 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 Date: Wed, 27 Jan 2016 13:51:52 +0000 Message-Id: <1453902715-25304-5-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1453902715-25304-1-git-send-email-eric.auger@linaro.org> References: <1453902715-25304-1-git-send-email-eric.auger@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::234 Cc: Bharat.Bhushan@freescale.com, suravee.suthikulpanit@amd.com, christoffer.dall@linaro.org Subject: [Qemu-devel] [RFC 4/7] hw: vfio: common: introduce vfio_register_reserved_iova X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.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(+) -- 1.9.1 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) {