From patchwork Tue Nov 3 21:48:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 7547271 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 01C7EBEEA4 for ; Tue, 3 Nov 2015 21:51:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 398862078A for ; Tue, 3 Nov 2015 21:51:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 628A2206FB for ; Tue, 3 Nov 2015 21:51:10 +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 1ZtjS2-0008Nj-Ri; Tue, 03 Nov 2015 21:49:10 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtjRt-0008KC-NM for linux-arm-kernel@lists.infradead.org; Tue, 03 Nov 2015 21:49:02 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 1D652A4500; Tue, 3 Nov 2015 21:48:41 +0000 (UTC) Received: from labbott-redhat-machine.redhat.com (ovpn-112-84.phx2.redhat.com [10.3.112.84]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tA3LmaWX003751; Tue, 3 Nov 2015 16:48:39 -0500 From: Laura Abbott To: Catalin Marinas , Will Deacon Subject: [PATCH 1/2] arm64: Get existing page protections in split_pmd Date: Tue, 3 Nov 2015 13:48:34 -0800 Message-Id: <1446587315-18145-2-git-send-email-labbott@fedoraproject.org> In-Reply-To: <1446587315-18145-1-git-send-email-labbott@fedoraproject.org> References: <1446587315-18145-1-git-send-email-labbott@fedoraproject.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151103_134901_906239_256CB90E X-CRM114-Status: GOOD ( 11.07 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Kees Cook , Ard Biesheuvel , linux-kernel@vger.kernel.org, Xishi Qiu , linux-arm-kernel@lists.infradead.org, Laura Abbott 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=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 Rather than always putting the least restrictived permissions (PAGE_KERNEL_EXEC) when spliting a pmd into pages, use the existing permissions from the pmd for the page. Signed-off-by: Laura Abbott Reviewed-by: Ard Biesheuvel --- arch/arm64/mm/mmu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 9211b85..ff41efa 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -75,14 +75,13 @@ static void __init *early_alloc(unsigned long sz) static void split_pmd(pmd_t *pmd, pte_t *pte) { unsigned long pfn = pmd_pfn(*pmd); + unsigned long addr = pfn << PAGE_SHIFT; + pgprot_t prot = __pgprot(pmd_val(*pmd) ^ addr) | PTE_TYPE_PAGE; + int i = 0; do { - /* - * Need to have the least restrictive permissions available - * permissions will be fixed up later - */ - set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC)); + set_pte(pte, pfn_pte(pfn, prot)); pfn++; } while (pte++, i++, i < PTRS_PER_PTE); }