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: 56581 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1257736lbb; Mon, 16 Nov 2015 03:26:40 -0800 (PST) X-Received: by 10.66.140.79 with SMTP id re15mr53003477pab.127.1447673199635; Mon, 16 Nov 2015 03:26:39 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id zq1si50086868pbc.38.2015.11.16.03.26.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 03:26:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com 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-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:236 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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+patch=linaro.org@lists.infradead.org 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(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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; }