From patchwork Mon Oct 13 13:06:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 5075751 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4A30FC11AC for ; Mon, 13 Oct 2014 13:09:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73E7820138 for ; Mon, 13 Oct 2014 13:09:47 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9172A201F7 for ; Mon, 13 Oct 2014 13:09:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XdfLN-0002RM-0N; Mon, 13 Oct 2014 13:07:21 +0000 Received: from mail-wg0-f50.google.com ([74.125.82.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XdfLH-0002M2-Px for linux-arm-kernel@lists.infradead.org; Mon, 13 Oct 2014 13:07:17 +0000 Received: by mail-wg0-f50.google.com with SMTP id a1so8700709wgh.9 for ; Mon, 13 Oct 2014 06:06:52 -0700 (PDT) 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=6ZFlQelHBw+zojSsN533svbZXlrXCdZDd3Dod7pCncI=; b=KdJEpq52WivqzJS1uA3H/eecZ8hAvtiRVWvx0e9YPzyxW7awam2kvC9+a1/gusW8MY tHFRu9xn6naVOBOolWvhjwteW7oeM7BptgrUimqxyDyTQ6sAnmQauOFCY5eBCKyO9JnW DsdUlWo6CHDHPgX2TQEknEz8fULFfFBN7GQ6DCW4hUvgLzjL5NvaBNt8DPy661oWAK66 cvVQPxjCoM6QqthfKfVF95MVLTUPKefU5kb+UIBt5xd2SWz2akHlw0E6PRkMYCc+LVQU Q3fHOZMOMjXqCwED+jwJx7ZqPI7qA2KHwbr4Iam8JGnI/iJKUP5r2xz2aSL7HNl7gXf8 1iJw== X-Gm-Message-State: ALoCoQmm5lkYvJYlSBlX0ccQID/CaOGmkXvHPApXD+YixNlEAWZhswt05XLPT2HfcM+nE3oIAtUr X-Received: by 10.194.202.138 with SMTP id ki10mr20689007wjc.68.1413205611918; Mon, 13 Oct 2014 06:06:51 -0700 (PDT) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id ky3sm16584837wjb.39.2014.10.13.06.06.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Oct 2014 06:06:50 -0700 (PDT) From: Antonios Motakis To: will.deacon@arm.com, kvmarm@lists.cs.columbia.edu, iommu@lists.linux-foundation.org, jroedel@suse.de Subject: [PATCH 1/3] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC Date: Mon, 13 Oct 2014 15:06:16 +0200 Message-Id: <1413205579-6124-2-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com> References: <1413205579-6124-1-git-send-email-a.motakis@virtualopensystems.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141013_060716_031043_12F53540 X-CRM114-Status: GOOD ( 13.22 ) X-Spam-Score: -0.7 (/) Cc: Thierry Reding , kim.phillips@freescale.com, "Upinder Malhi \(umalhi\)" , eric.auger@linaro.org, marc.zyngier@arm.com, Joerg Roedel , open list , Alexey Kardashevskiy , alex.williamson@redhat.com, "moderated list:ARM SMMU DRIVER" , Antonios Motakis , tech@virtualopensystems.com, christoffer.dall@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Exposing the XN flag of the SMMU driver as IOMMU_NOEXEC instead of IOMMU_EXEC makes it enforceable, since for IOMMUs that don't support the XN flag pages will always be executable. Signed-off-by: Antonios Motakis Acked-by: Joerg Roedel --- drivers/iommu/arm-smmu.c | 9 +++++---- include/linux/iommu.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 60558f7..566c176 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1281,7 +1281,7 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd, unsigned long pfn, int prot, int stage) { pte_t *pte, *start; - pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF | ARM_SMMU_PTE_XN; + pteval_t pteval = ARM_SMMU_PTE_PAGE | ARM_SMMU_PTE_AF; if (pmd_none(*pmd)) { /* Allocate a new set of tables */ @@ -1315,10 +1315,11 @@ static int arm_smmu_alloc_init_pte(struct arm_smmu_device *smmu, pmd_t *pmd, pteval |= ARM_SMMU_PTE_MEMATTR_NC; } + if (prot & IOMMU_NOEXEC) + pteval |= ARM_SMMU_PTE_XN; + /* If no access, create a faulting entry to avoid TLB fills */ - if (prot & IOMMU_EXEC) - pteval &= ~ARM_SMMU_PTE_XN; - else if (!(prot & (IOMMU_READ | IOMMU_WRITE))) + if (!(prot & (IOMMU_READ | IOMMU_WRITE))) pteval &= ~ARM_SMMU_PTE_PAGE; pteval |= ARM_SMMU_PTE_SH_IS; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 379a617..5f6f71c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -27,7 +27,7 @@ #define IOMMU_READ (1 << 0) #define IOMMU_WRITE (1 << 1) #define IOMMU_CACHE (1 << 2) /* DMA cache coherency */ -#define IOMMU_EXEC (1 << 3) +#define IOMMU_NOEXEC (1 << 3) struct iommu_ops; struct iommu_group;