From patchwork Mon Jul 7 12:27:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 33151 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f72.google.com (mail-qg0-f72.google.com [209.85.192.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3DBE20C88 for ; Mon, 7 Jul 2014 12:31:05 +0000 (UTC) Received: by mail-qg0-f72.google.com with SMTP id q107sf10998037qgd.11 for ; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ZVT6olYzcJTwaIHjmrXesA0Sungd5bjLz5DW56FzIEM=; b=hZTWmkW5dtdFCbN3J37//9DNbf2xqQ8ur9AIwbegRiVyEDm2lW6ThaJ3hSfSxFFdnU Q4vSS5B5CSCueUy2/EskQjX2ZXulIlEKNT6y74dhN5fQYAeqwoD1rrh6LjOq3AqZbcYF 5DIda9FbSluU9m1URlFGhA195EkD0rXkT7Xws9hjUOb1ZGeczPFeLNUxeK3g2GQRF+QE C4/XrXDzDbrGXoHagmhMurSm7rw5ZUBTr5V/hDbNi4PAoAIRAGssHe1Z29ExE9/ozAvE yCI9TQ+F9vjW/M3EollxKnsElKEDrFp1A1ALflH/ZaaaGA4lY8LvaFgf3Fe3w87zklc3 SgiQ== X-Gm-Message-State: ALoCoQmMnNBhzAe92qe2wokLfZkPe7fy9qwF8zkwj8ezjqxeeegf+AFRJjYM6goHyaMZwVh+s1iO X-Received: by 10.236.47.163 with SMTP id t23mr11970277yhb.41.1404736265589; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.237 with SMTP id u100ls1158506qga.36.gmail; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) X-Received: by 10.52.118.99 with SMTP id kl3mr23153927vdb.18.1404736265530; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id y5si18729036vcl.35.2014.07.07.05.31.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 05:31:05 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id sa20so3898804veb.24 for ; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) X-Received: by 10.58.37.106 with SMTP id x10mr27621272vej.2.1404736265444; Mon, 07 Jul 2014 05:31:05 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp662463vcb; Mon, 7 Jul 2014 05:31:04 -0700 (PDT) X-Received: by 10.195.11.34 with SMTP id ef2mr2995599wjd.123.1404736264444; Mon, 07 Jul 2014 05:31:04 -0700 (PDT) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id lz3si32954284wic.30.2014.07.07.05.31.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 05:31:04 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.178 as permitted sender) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id n15so6611472wiw.11 for ; Mon, 07 Jul 2014 05:31:02 -0700 (PDT) X-Received: by 10.180.83.202 with SMTP id s10mr77593890wiy.25.1404736262878; Mon, 07 Jul 2014 05:31:02 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id ec8sm95805182wic.10.2014.07.07.05.31.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Jul 2014 05:31:02 -0700 (PDT) From: Eric Auger To: eric.auger@st.com, christoffer.dall@linaro.org, qemu-devel@nongnu.org, kim.phillips@freescale.com, a.rigo@virtualopensystems.com Cc: eric.auger@linaro.org, will.deacon@arm.com, kvmarm@lists.cs.columbia.edu, alex.williamson@redhat.com, Bharat.Bhushan@freescale.com, agraf@suse.de, peter.maydell@linaro.org, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, patches@linaro.org Subject: [RFC v4 08/13] hw/vfio/common: Add EXEC_FLAG to VFIO DMA mappings Date: Mon, 7 Jul 2014 13:27:18 +0100 Message-Id: <1404736043-22900-9-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1404736043-22900-1-git-send-email-eric.auger@linaro.org> References: <1404736043-22900-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Alvise Rigo The flag is mandatory for the ARM SMMU so we always add it if the MMIO handles it. Signed-off-by: Alvise Rigo --- hw/vfio/common.c | 9 +++++++++ include/hw/vfio/vfio-common.h | 1 + linux-headers/linux/vfio.h | 2 ++ 3 files changed, 12 insertions(+) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index ed93cf3..e22f326 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -233,6 +233,11 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova, map.flags |= VFIO_DMA_MAP_FLAG_WRITE; } + /* add exec flag */ + if (container->iommu_data.has_exec_cap) { + map.flags |= VFIO_DMA_MAP_FLAG_EXEC; + } + /* * Try the mapping, if it fails with EBUSY, unmap the region and try * again. This shouldn't be necessary, but we sometimes see it in @@ -688,6 +693,10 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as) goto free_container_exit; } + if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_IOMMU_PROT_EXEC)) { + container->iommu_data.has_exec_cap = true; + } + container->iommu_data.type1.listener = vfio_memory_listener; container->iommu_data.release = vfio_listener_release; diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index d19622b..e670ae3 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -76,6 +76,7 @@ typedef struct VFIOContainer { union { VFIOType1 type1; }; + bool has_exec_cap; /* support of exec capability by the IOMMU */ void (*release)(struct VFIOContainer *); } iommu_data; QLIST_HEAD(, VFIOGuestIOMMU) giommu_list; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index 26c218e..b13f7d3 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -30,6 +30,7 @@ */ #define VFIO_DMA_CC_IOMMU 4 +#define VFIO_IOMMU_PROT_EXEC 5 /* * The IOCTL interface is designed for extensibility by embedding the * structure length (argsz) and flags into structures passed between @@ -398,6 +399,7 @@ struct vfio_iommu_type1_dma_map { __u32 flags; #define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device */ #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */ +#define VFIO_DMA_MAP_FLAG_EXEC (1 << 2) /* executable from device */ __u64 vaddr; /* Process virtual address */ __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */