From patchwork Wed Nov 11 01:57:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 7593401 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 840D3C05CA for ; Wed, 11 Nov 2015 02:00:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE53320781 for ; Wed, 11 Nov 2015 02:00:33 +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 CA34020776 for ; Wed, 11 Nov 2015 02:00:31 +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 1ZwKgA-0006Ke-BU; Wed, 11 Nov 2015 01:58:30 +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 1ZwKfw-0006Gm-CU for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2015 01:58:18 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 8490F42E5D7; Wed, 11 Nov 2015 01:57:45 +0000 (UTC) Received: from labbott-redhat-machine.redhat.com (ovpn-112-23.phx2.redhat.com [10.3.112.23]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAB1vdaM029142; Tue, 10 Nov 2015 20:57:43 -0500 From: Laura Abbott To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Zhong Jiang Subject: [PATCHv2 1/2] arm64: Get existing page protections in split_pmd Date: Tue, 10 Nov 2015 17:57:36 -0800 Message-Id: <1447207057-11323-2-git-send-email-labbott@fedoraproject.org> In-Reply-To: <1447207057-11323-1-git-send-email-labbott@fedoraproject.org> References: <1447207057-11323-1-git-send-email-labbott@fedoraproject.org> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151110_175816_918755_15163447 X-CRM114-Status: GOOD ( 11.11 ) 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 , 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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 --- v2: Typo and typechecking fixed I chose not to add the Reviewed-by from Ard here because of the addition of the contiguous bit in split_pmd. Not sure if I should be explicitly carrying it over. --- arch/arm64/mm/mmu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index c2fa6b5..496c3fd 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -76,15 +76,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. Default the new page - * range as contiguous ptes. - */ - set_pte(pte, pfn_pte(pfn, PAGE_KERNEL_EXEC_CONT)); + set_pte(pte, pfn_pte(pfn, prot)); pfn++; } while (pte++, i++, i < PTRS_PER_PTE); }