Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp47544rwb; Wed, 9 Nov 2022 19:40:37 -0800 (PST) X-Google-Smtp-Source: AMsMyM7jqgZ+12tQ3tXNJdX5AScVG+jSSBT+jAq6MQ5fZ0eLnDHnoZ7NjWlbfxcWkIMj1xczhHt6 X-Received: by 2002:a17:907:c711:b0:7ae:35c9:f07b with SMTP id ty17-20020a170907c71100b007ae35c9f07bmr27196287ejc.423.1668051637253; Wed, 09 Nov 2022 19:40:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668051637; cv=none; d=google.com; s=arc-20160816; b=t7iawfSCA8dKocs7q5C5ADkgY3PjBpyM4dHxJC7sgd8WPEr2382eSekNTLF128GuIr TlLK2tdZSRsG2V3dQ1N/cDxMSjWNZCCAvJlJocghD6FbEeosogbiEmpHMSPTl4RQQVDW OdsR4EP4Eto5R31mMdJW7Nbd75ljsqyM8ddGoWJJSP24XL90JWz3GhzoaM3sTifUQipH D+01v6mjR0Pcfwm4qWmn56kMFBviFx9h5R6tI1wrHHQ/Um8Bls/9pKKosVGF54cjsEsM sM8rElen5SkdzBBxIHP5l2NAyjKliF1g8Vd9X4BstR8Uuu5KkcHPyR43YumAe65GYUm4 y5rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=hoZE7fJ/mc/2DIgvqb2wW06yVzWMteI0kSQOqL2ctMs=; b=IwmBnmFPK5zjh49I4kBjseUtPPfwZLfDydb0NnSq4S0ni9UdQ8Te70GSR9GoCwovUC SEFRHla3RFn4c+M5mM8LFXPD58z2YViVTjuDYsw8/ixFg/VXgdbHfx8GpUrYSa+3DtVR bdAQLTioArA8VxBefhByUSApVDWg5VdI/dKvdr2g/ViTye7LB3MyyAP5SPWqgYAk1kJF w8Pty+H5+kOMbF5gTN83OrnZ+rkAvqd3ugPGOrO2cQm8tm678+4yCuaG8oTzZnrOVt49 IWLJj773UuVmFqatTGXGKtvCHZl2kRoeJ3+MOo1ibL++TQhmELJFtkdKqxZPdqyLvyIc MpdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b15-20020a17090630cf00b0072ef52514f6si13712966ejb.629.2022.11.09.19.40.14; Wed, 09 Nov 2022 19:40:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231512AbiKJDPQ (ORCPT + 92 others); Wed, 9 Nov 2022 22:15:16 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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.