From patchwork Wed Aug 24 17:02:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 74627 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp467071qga; Wed, 24 Aug 2016 12:03:51 -0700 (PDT) X-Received: by 10.98.99.67 with SMTP id x64mr8653208pfb.26.1472065431681; Wed, 24 Aug 2016 12:03:51 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b64si10888744pfc.170.2016.08.24.12.03.51; Wed, 24 Aug 2016 12:03:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755700AbcHXTDs (ORCPT + 3 others); Wed, 24 Aug 2016 15:03:48 -0400 Received: from foss.arm.com ([217.140.101.70]:51617 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754637AbcHXTDq (ORCPT ); Wed, 24 Aug 2016 15:03:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CC4C167C; Wed, 24 Aug 2016 12:05:25 -0700 (PDT) Received: from remoulade.event.rightround.com (usa-sjc-mx-foss1.foss.arm.com [217.140.101.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7099E3F220; Wed, 24 Aug 2016 12:03:45 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: Mark Rutland , Ard Biesheuvel , Catalin Marinas , Will Deacon , stable@vger.kernel.org Subject: [PATCH] arm64: avoid TLB conflict with CONFIG_RANDOMIZE_BASE Date: Wed, 24 Aug 2016 18:02:08 +0100 Message-Id: <1472058128-1216-1-git-send-email-mark.rutland@arm.com> X-Mailer: git-send-email 2.7.4 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org When CONFIG_RANDOMIZE_BASE is selected, we modify the page tables to remap the kernel at a newly-chosen VA range. We do this with the MMU disabled, but do not invalidate TLBs prior to re-enabling the MMU with the new tables. Thus the old mappings entries may still live in TLBs, and we risk violating Break-Before-Make requirements, leading to TLB conflicts and/or other issues. We invalidate TLBs when we uninsall the idmap in early setup code, but prior to this we are subject to issues relating to the Break-Before-Make violation. Avoid these issues by invalidating the TLBs before the new mappings can be used by the hardware. Fixes: f80fb3a3d50843a4 ("arm64: add support for kernel ASLR") Signed-off-by: Mark Rutland Cc: Ard Biesheuvel Cc: Catalin Marinas Cc: Will Deacon Cc: stable@vger.kernel.org --- arch/arm64/kernel/head.S | 3 +++ 1 file changed, 3 insertions(+) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Acked-by: Ard Biesheuvel Acked-by: Will Deacon diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S index b77f583..3e7b050 100644 --- a/arch/arm64/kernel/head.S +++ b/arch/arm64/kernel/head.S @@ -757,6 +757,9 @@ ENTRY(__enable_mmu) isb bl __create_page_tables // recreate kernel mapping + tlbi vmalle1 // Remove any stale TLB entries + dsb nsh + msr sctlr_el1, x19 // re-enable the MMU isb ic iallu // flush instructions fetched