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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90221C4332F for ; Thu, 10 Nov 2022 03:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbiKJDPR (ORCPT ); Wed, 9 Nov 2022 22:15:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbiKJDPO (ORCPT ); Wed, 9 Nov 2022 22:15:14 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4AFBCDED5; Wed, 9 Nov 2022 19:15:13 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 261531FB; Wed, 9 Nov 2022 19:15:19 -0800 (PST) Received: from [10.162.41.6] (unknown [10.162.41.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B0FE3F73D; Wed, 9 Nov 2022 19:15:10 -0800 (PST) Message-ID: <73c40107-0d7a-d988-c817-7bba6d72c371@arm.com> Date: Thu, 10 Nov 2022 08:45:07 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 2/2] arm64: errata: Workaround possible Cortex-A715 [ESR|FAR]_ELx corruption Content-Language: en-US To: Catalin Marinas 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 References: <20221027023915.1318100-1-anshuman.khandual@arm.com> <20221027023915.1318100-3-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/10/22 00:48, Catalin Marinas wrote: > On Thu, Oct 27, 2022 at 08:09:15AM +0530, Anshuman Khandual wrote: >> +#define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION >> +static inline pte_t ptep_modify_prot_start(struct vm_area_struct *vma, >> + unsigned long addr, >> + pte_t *ptep) >> +{ >> + pte_t pte = ptep_get_and_clear(vma->vm_mm, addr, ptep); >> >> + if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) { >> + /* >> + * 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)) >> + __flush_tlb_range(vma, addr, addr + PAGE_SIZE, PAGE_SIZE, false, 3); > > Why not flush_tlb_page() here? > > But more importantly, can we not use ptep_clear_flush() instead (and Something like ... ptep_modify_prot_start - if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) { if (pte_user_exec(READ_ONCE(*ptep)) && cpus_have_const_cap(ARM64_WORKAROUND_2645198)) return ptep_clear_flush(vma, addr, ptep); } else { return ptep_get_and_clear(vma->vm_mm, addr, ptep); } > huge_ptep_clear_flush())? They return the pte and do the TLBI. huge_ptep_modify_prot_start - if (IS_ENABLED(CONFIG_ARM64_WORKAROUND_2645198)) { if (pte_user_exec(READ_ONCE(*ptep)) && cpus_have_const_cap(ARM64_WORKAROUND_2645198)) return huge_ptep_clear_flush(vma, addr, ptep); } else { return huge_ptep_get_and_clear(vma->vm_mm, addr, ptep); } pte_user_exec(READ_ONCE(*ptep) should identify an user exec mapping even though ptep represents a cont PTE/PMD huge page ? OR should huge_ptep_get() helper be used instead ? Regardless, using [huge_]ptep_clear_flush() here seems better.