From patchwork Mon Jun 2 07:49:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 31257 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 703582100A for ; Mon, 2 Jun 2014 07:50:34 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id i57sf24012116yha.0 for ; Mon, 02 Jun 2014 00:50:34 -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=frub+FILqyFes+azDnMFopDdPMcytnw47w191GEdj7U=; b=d7mXAn9gNY6YCtxQbMrEhUpDsV6TqbB5tNYYNgVMS7QS0vXRtg4fKVKXN4R3jj20+b mkd6o7KOBXoNkEdQlGV5xtEfzde4I70SMirhByfRUk0GFCaW27gEyzTXpHvzOKXpT3l4 BJIcUq9uzwTD03/MBU8UMZVHxE7t2N5kHamb1eFk+RbCbveQDMbAwuxFglITtKfFKD/H qwapyh4EaiYk5p9/3UO+mFClmceILfyPavaKl0tJhHzuFNf1EJadtOk+7WKoxti8R68D LVc8iK8PSQB2rcBR41rsSIu4Cc8caX85cvqprvRMvnVIEmSjmsY6Q8j9vsZWBwSufBqr M4UA== X-Gm-Message-State: ALoCoQk/POQbI0OYFWKMx933xh2eHuyeXvmoqswBV5V94hT7BkMH/eW1DN5Jk3j7UbRWiz5V/nsA X-Received: by 10.236.140.42 with SMTP id d30mr12366448yhj.2.1401695434236; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.81.145 with SMTP id f17ls1861862qgd.95.gmail; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) X-Received: by 10.58.29.16 with SMTP id f16mr29212844veh.23.1401695434165; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id qc5si7519549vcb.53.2014.06.02.00.50.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id db11so4821728veb.1 for ; Mon, 02 Jun 2014 00:50:34 -0700 (PDT) X-Received: by 10.220.174.137 with SMTP id t9mr29180752vcz.12.1401695434090; Mon, 02 Jun 2014 00:50:34 -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.220.221.72 with SMTP id ib8csp78777vcb; Mon, 2 Jun 2014 00:50:33 -0700 (PDT) X-Received: by 10.180.12.238 with SMTP id b14mr20161606wic.16.1401695431454; Mon, 02 Jun 2014 00:50:31 -0700 (PDT) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx.google.com with ESMTPS id ep7si20037748wic.48.2014.06.02.00.50.30 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:31 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.182 as permitted sender) client-ip=74.125.82.182; Received: by mail-we0-f182.google.com with SMTP id t60so4759883wes.27 for ; Mon, 02 Jun 2014 00:50:30 -0700 (PDT) X-Received: by 10.194.63.196 with SMTP id i4mr47479746wjs.50.1401695430842; Mon, 02 Jun 2014 00:50:30 -0700 (PDT) Received: from midway01-04-00.lavalab ([88.98.47.97]) by mx.google.com with ESMTPSA id je7sm30286772wic.14.2014.06.02.00.50.30 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 00:50:30 -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, christophe.barnichon@st.com, kvmarm@lists.cs.columbia.edu, alex.williamson@redhat.com, agraf@suse.de, peter.maydell@linaro.org, stuart.yoder@freescale.com, a.motakis@virtualopensystems.com, patches@linaro.org Subject: [RFC v3 07/10] Add EXEC_FLAG to VFIO DMA mappings Date: Mon, 2 Jun 2014 08:49:31 +0100 Message-Id: <1401695374-4287-8-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1401695374-4287-1-git-send-email-eric.auger@linaro.org> References: <1401695374-4287-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.170 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 +++++++++ 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 28d29de..8b25380 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -82,6 +82,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 @@ -327,6 +332,10 @@ static int vfio_connect_container(VFIOGroup *group) return -errno; } + 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/hw/vfio/vfio-common.h b/hw/vfio/vfio-common.h index 5412acd..dcd7ddd 100644 --- a/hw/vfio/vfio-common.h +++ b/hw/vfio/vfio-common.h @@ -100,6 +100,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(, VFIOGroup) group_list; diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index ef4815d..e96e14d 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 @@ -399,6 +400,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) */