From patchwork Tue Sep 23 14:46:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonios Motakis X-Patchwork-Id: 4957151 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 6B099BEEA5 for ; Tue, 23 Sep 2014 14:49:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A5D12022D for ; Tue, 23 Sep 2014 14:49:23 +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 F300720221 for ; Tue, 23 Sep 2014 14:49:20 +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 1XWRMw-00071l-Q9; Tue, 23 Sep 2014 14:47:06 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWRMu-0006we-6f for linux-arm-kernel@lists.infradead.org; Tue, 23 Sep 2014 14:47:04 +0000 Received: by mail-wi0-f178.google.com with SMTP id z2so5241122wiv.5 for ; Tue, 23 Sep 2014 07:46:41 -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=ZWpTYNr96SDl/dPKQIWFydhsoW16IUAik6I1+1QDEzQ=; b=QwtNr5u+8pSBgm9Nf5q849dNI/7nsrc9iMEjhp3Dii/rgD8wc9oewKeGLqi7U4LlmF fo34E7nN2gijFNVXO4FtuPdTSJcTsz1PHp+730lzLHShMIpEc6wjPgPfxKPnoqHVWt5g 2PV22NkSt/jI1uLNbA708zM4C5rQXSuz9TbH8zOLuJkMKcO6lrIOyowPlLJalQA/uDp3 HgOwb5JH+NRjJmZrqIfTEcMrE9CEe4r2h27pMiGiWEaH13Ohv2pKz/fRj6GfTu1KRIW1 y5IrerEkZ7xDxqKtatRs5Ol0N+eP89TftdhjNDxZtfW5Gh9OR0CxXdmcpKxN1voGq2k8 o+6g== X-Gm-Message-State: ALoCoQmRW/j47WLTu4UKOehR3Dpe98jqrTNncw+aKKocd02C6SDXYRdCMxFA4UWmq5f0IPT01cst X-Received: by 10.194.222.136 with SMTP id qm8mr11376774wjc.97.1411483601843; Tue, 23 Sep 2014 07:46:41 -0700 (PDT) Received: from localhost.localdomain (home.tvelocity.eu. [82.67.68.96]) by mx.google.com with ESMTPSA id ic8sm16151809wjb.25.2014.09.23.07.46.39 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Sep 2014 07:46:40 -0700 (PDT) From: Antonios Motakis To: alex.williamson@redhat.com, kvmarm@lists.cs.columbia.edu, iommu@lists.linux-foundation.org Subject: [PATCHv7 01/26] iommu/arm-smmu: change IOMMU_EXEC to IOMMU_NOEXEC Date: Tue, 23 Sep 2014 16:46:00 +0200 Message-Id: <1411483586-29304-2-git-send-email-a.motakis@virtualopensystems.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1411483586-29304-1-git-send-email-a.motakis@virtualopensystems.com> References: <1411483586-29304-1-git-send-email-a.motakis@virtualopensystems.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140923_074704_393497_D813F355 X-CRM114-Status: GOOD ( 12.91 ) X-Spam-Score: -0.7 (/) Cc: Shuah Khan , kim.phillips@freescale.com, "Upinder Malhi \(umalhi\)" , kvm@vger.kernel.org, eric.auger@linaro.org, marc.zyngier@arm.com, Greg Kroah-Hartman , Joerg Roedel , will.deacon@arm.com, open list , Thierry Reding , Alexey Kardashevskiy , "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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 --- 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 a83cc2a..c7cbdda 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -1252,7 +1252,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 */ @@ -1286,10 +1286,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 20f9a52..e1a644c 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;