From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3FA8FC433FE for ; Tue, 15 Nov 2022 14:03:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ukiHQlJDpD9yDzENNxfz2wCEfWleg8XZJh2BGLyxVyc=; b=jv0EzXXpUtKBci 4wSag2cjUGYTJNVagvjYe1acByR1Fxy3qYcHOKDfsQeGLerdEerm6oQV3QkJVvj4y2F1AKFRp2nNp bjmhVJNMXz6pA/mU5YVpH0HabB/zVfb4/5TFmUYIBFgvLLepQ70xek4zWzeYIzV4ZB007R8MQAjGI WjoQRzndpdUf4GYlRwm2KPkuCFKqRfMfz74kHjBUgKRpoFflV++P/VRZUZ4bLRSKv6udAPH8ilQEQ IhSf2h3zvOCUT/TsN2UPT52GuKcn5Om8XX2YOpTO3HMzwaIdLb6qDWdzr5NbloOLdbpGQnePnim9B Rr4L44Fxbpn/yFdIVr8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouwW3-00BjjJ-M6; Tue, 15 Nov 2022 14:02:19 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouwVz-00BjgF-V1 for linux-arm-kernel@lists.infradead.org; Tue, 15 Nov 2022 14:02:17 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 22B40B818CA; Tue, 15 Nov 2022 14:02:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1CB0C433C1; Tue, 15 Nov 2022 14:02:04 +0000 (UTC) Date: Tue, 15 Nov 2022 14:02:00 +0000 From: Catalin Marinas To: Anshuman Khandual Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will@kernel.org, Suzuki K Poulose , James Morse , Jonathan Corbet , Mark Rutland , linux-doc@vger.kernel.org Subject: Re: [PATCH V2 2/2] arm64: errata: Workaround possible Cortex-A715 [ESR|FAR]_ELx corruption Message-ID: References: <20221113012645.190301-1-anshuman.khandual@arm.com> <20221113012645.190301-3-anshuman.khandual@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221113012645.190301-3-anshuman.khandual@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221115_060216_170931_AD744BCE X-CRM114-Status: GOOD ( 20.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Nov 13, 2022 at 06:56:45AM +0530, Anshuman Khandual wrote: > diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c > index 35e9a468d13e..6552947ca7fa 100644 > --- a/arch/arm64/mm/hugetlbpage.c > +++ b/arch/arm64/mm/hugetlbpage.c > @@ -559,3 +559,24 @@ bool __init arch_hugetlb_valid_size(unsigned long size) > { > return __hugetlb_valid_size(size); > } > + > +pte_t huge_ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) > +{ > + if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) { > + pte_t pte = READ_ONCE(*ptep); Not sure whether the generated code would be any different but we should probably add the check for the CPU capability in the 'if' condition above, before the READ_ONCE (which expands to some asm volatile): if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198) && cpus_have_const_cap(ARM64_WORKAROUND_2645198)) { pte_t pte = ... ... } > + /* > + * Break-before-make (BBM) is required for all user space mappings > + * when the permission changes from executable to non-executable > + * in cases where cpu is affected with errata #2645198. > + */ > + if (pte_user_exec(pte) && cpus_have_const_cap(ARM64_WORKAROUND_2645198)) > + return huge_ptep_clear_flush(vma, addr, ptep); > + } > + return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); > +} > + > +void huge_ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, > + pte_t old_pte, pte_t pte) > +{ > + set_huge_pte_at(vma->vm_mm, addr, ptep, pte); > +} > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c > index 9a7c38965154..c1fb0ce1473c 100644 > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -1702,3 +1702,24 @@ static int __init prevent_bootmem_remove_init(void) > } > early_initcall(prevent_bootmem_remove_init); > #endif > + > +pte_t ptep_modify_prot_start(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep) > +{ > + if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) { > + pte_t pte = READ_ONCE(*ptep); > + /* > + * Break-before-make (BBM) is required for all user space mappings > + * when the permission changes from executable to non-executable > + * in cases where cpu is affected with errata #2645198. > + */ > + if (pte_user_exec(pte) && cpus_have_const_cap(ARM64_WORKAROUND_2645198)) > + return ptep_clear_flush(vma, addr, ptep); > + } Same here. > + return ptep_get_and_clear(vma->vm_mm, addr, ptep); > +} > + > +void ptep_modify_prot_commit(struct vm_area_struct *vma, unsigned long addr, pte_t *ptep, > + pte_t old_pte, pte_t pte) > +{ > + __set_pte_at(vma->vm_mm, addr, ptep, pte); > +} -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel