Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp173162rwb; Tue, 15 Nov 2022 21:35:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7nNY0gfJxMXopQNSazeLJg9hBEAl0BCObaRdr7h3ykESNaPFJkokyzdLRRKn6OkezQ2KZ0 X-Received: by 2002:a17:902:6a82:b0:186:5613:becf with SMTP id n2-20020a1709026a8200b001865613becfmr7768491plk.46.1668576934052; Tue, 15 Nov 2022 21:35:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668576934; cv=none; d=google.com; s=arc-20160816; b=oTXYkejxpIGMsktgQMfbAy4J+m+O9cyy3toWe+fNB2mASOiI/HGxYwYt68Sd9l3U+/ 091b0C1BB1Eko0UM1e/DeqHU1VPuegraN0Qghx6S1PJaUttSruvt16L5cLDz5OJdp7jr Snb7ajJpcW4CIM8/GGTDBdmbS3bwx+nxdLoSbDBYOJzHp28jgJZ232yDdFpazpIFKyCc tfnpKt/qonWnyz5h6JF/aTOx89m5lkOnMWv4DMiovpnZ+pe3UNCpYzAgkAeyaVD5lafz RTe7toDT2K+HFA++nH/8/mb93KwaYVTfEBMmL0nyoc1yRG432uMUPsQCBoKhqrU87L8m xreQ== 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=O8aDz+hv7AfMPsaEjdP6XVJQrzhr0H1CMMkF6u5NNSc=; b=G6PAYvLiCQRz84Lrtp8hMrc/QEkRltFJCMXGY/k2Q3SovJp6rTqiJbfmOFW+WbN6y6 YWDNnBRfEOlvBFH6RWVo0dUOZHYR/44Eux8opyzznqFIJQB2Wr4nslEGQbLh3zq7koV9 984GLlhHCrbUzKnNP9yxnC3IVVqbg4lCncVWGiaXXzdr91h/sNzFT0dJ24ZFO15Uh+5l t+P5QHb0wWFMN4I9Pcjwh2RBNIYxp01R+CawU6hsVjAe/TflS27xXLBMdtE1opl/D0nT W8RxdqPLqtF1R8oCF3aMUKOsSg+cNBAJ6Gpe1Qmw6COz+6BZ6EVhG3nJPonolDtM4hga AJDw== 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 h18-20020a635312000000b0046ec7beb578si14997992pgb.94.2022.11.15.21.34.58; Tue, 15 Nov 2022 21:35:34 -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 S231708AbiKPFEP (ORCPT + 90 others); Wed, 16 Nov 2022 00:04:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230342AbiKPFEL (ORCPT ); Wed, 16 Nov 2022 00:04:11 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 803381CFD3; Tue, 15 Nov 2022 21:04:10 -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 92D5C13D5; Tue, 15 Nov 2022 21:04:16 -0800 (PST) Received: from [10.162.40.17] (unknown [10.162.40.17]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4AA553F73B; Tue, 15 Nov 2022 21:04:07 -0800 (PST) Message-ID: <9ef95ff6-ea97-847f-55d2-ffb3bdf895f0@arm.com> Date: Wed, 16 Nov 2022 10:34:04 +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 V2 2/2] arm64: errata: Workaround possible Cortex-A715 [ESR|FAR]_ELx corruption Content-Language: en-US To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org Cc: Suzuki K Poulose , James Morse , Jonathan Corbet , Mark Rutland , linux-doc@vger.kernel.org References: <20221113012645.190301-1-anshuman.khandual@arm.com> <20221113012645.190301-3-anshuman.khandual@arm.com> From: Anshuman Khandual In-Reply-To: <20221113012645.190301-3-anshuman.khandual@arm.com> 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/13/22 06:56, Anshuman Khandual wrote: > +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); > + /* > + * 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); > + } > + 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); > +} Will change this __set_pte_at() to set_pte_at() instead like the generic version, which also makes sure that page_table_check_pte_set() gets called on the way, also making it similar to the HugeTLB implementation huge_ptep_modify_prot_commit().