From patchwork Sat Feb 11 20:23:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 9568149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BDA5E6043D for ; Sat, 11 Feb 2017 20:24:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC340284F6 for ; Sat, 11 Feb 2017 20:24:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F52828567; Sat, 11 Feb 2017 20:24:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id BC10B284F6 for ; Sat, 11 Feb 2017 20:24:15 +0000 (UTC) Received: (qmail 19686 invoked by uid 550); 11 Feb 2017 20:24:13 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 18151 invoked from network); 11 Feb 2017 20:24:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X58n6IBI7Zx9YJcPUbB22iSsT363yv+aXcUMzMxUJKs=; b=M00KC3cISQKD/ThveV2NCH4fEGv0J9PPOTj+cQJ3UJH0BgV1drmcirY1t414wsjYH/ VNAoeG3DTa9cZz4bsKppd2h8uGLp+0QdAhEEROftW3uou3jtUhLYQARW577M01K/ZeZv 213EEFqGzeez7lUJZYKvHvGc0DeD1zp1oBQds= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=X58n6IBI7Zx9YJcPUbB22iSsT363yv+aXcUMzMxUJKs=; b=DgwnW+22qJtbI/JFT/OLEPWJRN2UPTSSKLAPyvga9o1e3BKib629PF3qfFhlTFzTN+ MF4ohc/f4yATrckEoPBXGdsrne85tn78RCKZrqHvemPtZqgHwDDkRc/X20kN+8+Pk2vd bK6kgjMfGQ/VnTTqhDQ4ZgMW7sHpMoLyvzCA8KfAu2AprIvkeL48y4npVy47pMwe3yit PvddKEud5Rc5a01dl4i+xF6hnmSkBxJaq2fAVNODHWkhSufvtW4J8WZ3WMjL8pb89am2 jUzzUs4mvv10oUY/IncC0/hVr+NnnnRxlvi8D1F8mI11GZH8GP/8hwoueCRQkmkImNaU UU7A== X-Gm-Message-State: AMke39n5PV+Q/Il0OgBpwEsysDcZWDyUnJETLux+UTEJZdox5Ki5kB9VHhYBCzhDYJTqodvO X-Received: by 10.223.153.98 with SMTP id x89mr12593054wrb.181.1486844636753; Sat, 11 Feb 2017 12:23:56 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, labbott@fedoraproject.org Cc: kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, andre.przywara@arm.com, Suzuki.Poulose@arm.com, james.morse@arm.com, keescook@chromium.org, kernel-hardening@lists.openwall.com, Ard Biesheuvel Date: Sat, 11 Feb 2017 20:23:03 +0000 Message-Id: <1486844586-26135-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486844586-26135-1-git-send-email-ard.biesheuvel@linaro.org> References: <1486844586-26135-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [kernel-hardening] [PATCH v2 2/5] arm64: mmu: move TLB maintenance from callers to create_mapping_late() X-Virus-Scanned: ClamAV using ClamSMTP In preparation of changing the way we invoke create_mapping_late() (which is currently invoked twice from the same function), move the TLB flushing it performs from the caller into create_mapping_late() itself, and change it to a TLB maintenance by VA rather than a full flush, which is more appropriate here. Signed-off-by: Ard Biesheuvel Reviewed-by: Mark Rutland Tested-by: Mark Rutland --- arch/arm64/mm/mmu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 2131521ddc24..9e0ec1a8cd3b 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -356,6 +356,9 @@ static void create_mapping_late(phys_addr_t phys, unsigned long virt, __create_pgd_mapping(init_mm.pgd, phys, virt, size, prot, NULL, debug_pagealloc_enabled()); + + /* flush the TLBs after updating live kernel mappings */ + flush_tlb_kernel_range(virt, virt + size); } static void __init __map_memblock(pgd_t *pgd, phys_addr_t start, phys_addr_t end) @@ -438,9 +441,6 @@ void mark_rodata_ro(void) create_mapping_late(__pa_symbol(__start_rodata), (unsigned long)__start_rodata, section_size, PAGE_KERNEL_RO); - /* flush the TLBs after updating live kernel mappings */ - flush_tlb_all(); - debug_checkwx(); }