From patchwork Mon Nov 16 11:23:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 7624191 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 14BEBBF90C for ; Mon, 16 Nov 2015 11:27:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F3EF20592 for ; Mon, 16 Nov 2015 11:27:08 +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 382082058C for ; Mon, 16 Nov 2015 11:27:07 +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 1ZyHu1-0002ii-B7; Mon, 16 Nov 2015 11:24:53 +0000 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZyHtF-0002Cy-TO for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2015 11:24:06 +0000 Received: by wmec201 with SMTP id c201so114849754wme.1 for ; Mon, 16 Nov 2015 03:23:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SZG6mXJth/hZicb6RUITOUZPBj6VQMPw38FwLUsAakA=; b=jxInMeT2YJGEolnXxalEbiVvFK0cYXbDHNsEE+XL/zO2SfVl52zPBjWD/A6ayVEHu3 MTezFrY69VQ6zhFfsUYmOnPyF+xBf209MMI6esBgCAt+PqmdXnVhZA+9LYC1kWZGmf8N T4TLHgCPFYtI9ZwklKzHlm+zwzdKaq5/N5jeqrDqwrSBIx7W040X3VwSG0u0FWKT0JLY gNPxo5CPlq7Axn7AV+OgfNSI8o28ekZ9ACr0yHp8yi/Qzm7DD+Hp0eqsHc88TA07/8GJ Tjg+B2WQb/m+nbS76FoG45vDLrRRfPUowg+kZfdcsHvH+uF5Zcq5S4J9+Yhbx7c5W4S+ cuRA== 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=SZG6mXJth/hZicb6RUITOUZPBj6VQMPw38FwLUsAakA=; b=JjLOyTyeaPENSg7Aw/Z8HrFVIOBqQMX6A/jFIcnmMoo/OPN1xkhotCiJzPzZd+FfJW 3UcQyE8n7DE2Y8rgaf6f6OVbEBsxky9cYwCR66KdPKj+xDqE1vELubRCz5ldbdgUip7a j4r3OPyc/cUmY1ba2Jr5Di4B9uZ+Imv/lOvdmztEflK1U0+e7kRQY/4nTVgyn9ggEPoZ TVcdvKFFGiUJ7w1KCtHsxluFHEXPFyTGM0+pvPXmgoLWLBeAO7/oaFWQuBvUJ4rfKLVR G4n5A73ErRFI/SR9OOwcqVP2QoNF1Ra4PqJjaP8MZ961Ho6KN5tlJITKys7u15fscbwt rC+g== X-Gm-Message-State: ALoCoQl3g2Dzg/fjenmalzMi/QRx8yyyJQSyTb8ah09oIaJPtsw/iEIk0QKtdzotLEotBNL5B60t X-Received: by 10.28.218.72 with SMTP id r69mr19062581wmg.98.1447673029070; Mon, 16 Nov 2015 03:23:49 -0800 (PST) Received: from localhost.localdomain ([47.53.155.123]) by smtp.gmail.com with ESMTPSA id t126sm18062422wmd.18.2015.11.16.03.23.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 16 Nov 2015 03:23:48 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v3 6/7] arm64: map linear region as non-executable Date: Mon, 16 Nov 2015 12:23:17 +0100 Message-Id: <1447672998-20981-7-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447672998-20981-1-git-send-email-ard.biesheuvel@linaro.org> References: <1447672998-20981-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151116_032406_153011_8FB3C065 X-CRM114-Status: GOOD ( 14.55 ) X-Spam-Score: -2.6 (--) 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: Ard Biesheuvel , suzuki.poulose@arm.com, james.morse@arm.com, labbott@fedoraproject.org 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.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Now that we moved the kernel text out of the linear region, there is no longer a reason to map the linear region as executable. This also allows us to completely get rid of the __map_mem() variant that only maps some of it executable if CONFIG_DEBUG_RODATA is selected. Signed-off-by: Ard Biesheuvel --- arch/arm64/mm/mmu.c | 41 +------------------- 1 file changed, 2 insertions(+), 39 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index c7ba171951c8..526eeb7e1e97 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -357,47 +357,10 @@ static void create_mapping_late(phys_addr_t phys, unsigned long virt, phys, virt, size, prot, late_alloc); } -#ifdef CONFIG_DEBUG_RODATA static void __init __map_memblock(phys_addr_t start, phys_addr_t end) { - /* - * Set up the executable regions using the existing section mappings - * for now. This will get more fine grained later once all memory - * is mapped - */ - unsigned long kernel_x_start = round_down(__pa(_stext), SWAPPER_BLOCK_SIZE); - unsigned long kernel_x_end = round_up(__pa(__init_end), SWAPPER_BLOCK_SIZE); - - if (end < kernel_x_start) { - create_mapping(start, __phys_to_virt(start), - end - start, PAGE_KERNEL); - } else if (start >= kernel_x_end) { - create_mapping(start, __phys_to_virt(start), - end - start, PAGE_KERNEL); - } else { - if (start < kernel_x_start) - create_mapping(start, __phys_to_virt(start), - kernel_x_start - start, - PAGE_KERNEL); - create_mapping(kernel_x_start, - __phys_to_virt(kernel_x_start), - kernel_x_end - kernel_x_start, - PAGE_KERNEL_EXEC); - if (kernel_x_end < end) - create_mapping(kernel_x_end, - __phys_to_virt(kernel_x_end), - end - kernel_x_end, - PAGE_KERNEL); - } - -} -#else -static void __init __map_memblock(phys_addr_t start, phys_addr_t end) -{ - create_mapping(start, __phys_to_virt(start), end - start, - PAGE_KERNEL_EXEC); + create_mapping(start, __phys_to_virt(start), end - start, PAGE_KERNEL); } -#endif struct bootstrap_pgtables { pte_t pte[PTRS_PER_PTE]; @@ -471,7 +434,7 @@ static unsigned long __init bootstrap_region(struct bootstrap_pgtables *reg, SWAPPER_BLOCK_SIZE)); create_mapping(__pa(vstart - va_offset), vstart, vend - vstart, - PAGE_KERNEL_EXEC); + PAGE_KERNEL); return vend; }