Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp959596ybj; Fri, 20 Sep 2019 02:49:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1E1AfEyrW5p78A4eTOLrV/zBUt8e7CTVSe+EOreHLvjSQpRcoPla2wna6yPlfXb3m12n4 X-Received: by 2002:a17:906:c47:: with SMTP id t7mr11956810ejf.133.1568972941967; Fri, 20 Sep 2019 02:49:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568972941; cv=none; d=google.com; s=arc-20160816; b=eh1U+MDdAXWa3ZfrmAX9IM7lhP3fIG6Y+Lj8/DTjfi9IkipCFOd3jDpHXYLiyxkWA6 q0L9OsPCDtigOGFDJsp1MI5Z6h5BYL7AwYgIEJihT/D5XmMyxU4SHd8gqsr4vmpFhZtk idbQKXH3sDh2UJx4ROS/wHNrsKK+fd/Homuq5FPHdZel1I+Csi3p4pv/9wMyAmjDHqIi sytpkiZeru/UFysusRkOGakZFZbHyzdrVCqenqCpU75+T490y0CLwWwaiaHk1JUxln/T b+2rHUWq6ZF4LX0pqCxQnMbk99aMbIQNBrllSJ+LoTMRiOg93HiY5nqq2cHgfgZO+aTN mFsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lD8CTKt1SkymZBIp62R9GTSvJVgo6zhc1HzwKenhN9c=; b=do4POqU0dQnXfTsfg5nC39chuTXC7nLWCY3/a60HJrs4C1IPtnxNvnJbBz4zhqHpzc BShKCtX6uMPk2TasULKNTNFSCNuGnpm1JNLlslNIYHRgfCDkzml7vw3TTyVGZUWmcqsh 4G0SCTcIg0WqdRGCAd/Y4n6HPP1SF75kW7lcOPHCpASdWY9+cZ58YKU7lLDYOEm2/txe t7WEcoXkX25Qj8NFiGZlsiKakKMp27buvMfImGIqy+S4X93W/+fvCnoYinAnYL61ef3z 78LJoiJU8Eza6DvhWOmRQaPoZGCRReqmNHiiuixmqUkmSp5now5BegwjMsJaaoHGqNNs 816Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gd47OST5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si958581edy.426.2019.09.20.02.48.39; Fri, 20 Sep 2019 02:49:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gd47OST5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393567AbfISWLV (ORCPT + 99 others); Thu, 19 Sep 2019 18:11:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:49958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393226AbfISWLR (ORCPT ); Thu, 19 Sep 2019 18:11:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A3D7218AF; Thu, 19 Sep 2019 22:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931076; bh=6nwFTGM40OJf3SA3mcvKK+YqV+J1assoWr1tet+7zfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gd47OST5nvU6KJLm35NgCH8MWhUYtir5pnpZ19dLJP5fMjovpI0h2KHGN8/X85ygE r5zEcbozDrOD5Xyh5ZUrs8+Spj4DGAbfaXO9ZBLqLa77a1WV+YwfY2rvj0EGEKt9zN fqXNx6fnp+hXaJw9Y4/mhVeuBw8NgRvagZ/ZwS04= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Will Deacon Subject: [PATCH 5.2 120/124] Revert "arm64: Remove unnecessary ISBs from set_{pte,pmd,pud}" Date: Fri, 20 Sep 2019 00:03:28 +0200 Message-Id: <20190919214823.541658650@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214819.198419517@linuxfoundation.org> References: <20190919214819.198419517@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit d0b7a302d58abe24ed0f32a0672dd4c356bb73db upstream. This reverts commit 24fe1b0efad4fcdd32ce46cffeab297f22581707. Commit 24fe1b0efad4fcdd ("arm64: Remove unnecessary ISBs from set_{pte,pmd,pud}") removed ISB instructions immediately following updates to the page table, on the grounds that they are not required by the architecture and a DSB alone is sufficient to ensure that subsequent data accesses use the new translation: DDI0487E_a, B2-128: | ... no instruction that appears in program order after the DSB | instruction can alter any state of the system or perform any part of | its functionality until the DSB completes other than: | | * Being fetched from memory and decoded | * Reading the general-purpose, SIMD and floating-point, | Special-purpose, or System registers that are directly or indirectly | read without causing side-effects. However, the same document also states the following: DDI0487E_a, B2-125: | DMB and DSB instructions affect reads and writes to the memory system | generated by Load/Store instructions and data or unified cache | maintenance instructions being executed by the PE. Instruction fetches | or accesses caused by a hardware translation table access are not | explicit accesses. which appears to claim that the DSB alone is insufficient. Unfortunately, some CPU designers have followed the second clause above, whereas in Linux we've been relying on the first. This means that our mapping sequence: MOV X0, STR X0, [Xptep] // Store new PTE to page table DSB ISHST LDR X1, [X2] // Translates using the new PTE can actually raise a translation fault on the load instruction because the translation can be performed speculatively before the page table update and then marked as "faulting" by the CPU. For user PTEs, this is ok because we can handle the spurious fault, but for kernel PTEs and intermediate table entries this results in a panic(). Revert the offending commit to reintroduce the missing barriers. Cc: Fixes: 24fe1b0efad4fcdd ("arm64: Remove unnecessary ISBs from set_{pte,pmd,pud}") Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/pgtable.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -214,8 +214,10 @@ static inline void set_pte(pte_t *ptep, * Only if the new pte is valid and kernel, otherwise TLB maintenance * or update_mmu_cache() have the necessary barriers. */ - if (pte_valid_not_user(pte)) + if (pte_valid_not_user(pte)) { dsb(ishst); + isb(); + } } extern void __sync_icache_dcache(pte_t pteval); @@ -453,8 +455,10 @@ static inline void set_pmd(pmd_t *pmdp, WRITE_ONCE(*pmdp, pmd); - if (pmd_valid(pmd)) + if (pmd_valid(pmd)) { dsb(ishst); + isb(); + } } static inline void pmd_clear(pmd_t *pmdp) @@ -512,8 +516,10 @@ static inline void set_pud(pud_t *pudp, WRITE_ONCE(*pudp, pud); - if (pud_valid(pud)) + if (pud_valid(pud)) { dsb(ishst); + isb(); + } } static inline void pud_clear(pud_t *pudp)