linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Yu Zhao <yuzhao@google.com>, Jia He <justin.he@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>
Cc: Mark Rutland <mark.rutland@arm.com>,
	Will Deacon <will@kernel.org>, Marc Zyngier <maz@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] arm64: mm: fix warning in arch_faults_on_old_pte()
Date: Tue, 15 Jun 2021 11:40:15 +0100	[thread overview]
Message-ID: <55db1c75-91b4-99ed-a0fa-cc9b5d3f35ac@arm.com> (raw)
In-Reply-To: <20210613214728.1695340-1-yuzhao@google.com>

On 13/06/2021 22:47, Yu Zhao wrote:
> cow_user_page() doesn't disable preemption, and it triggers the
> warning in arch_faults_on_old_pte() when CONFIG_PREEMPT_COUNT=y.
> 
> Converting the Access flag support to a system-wide feature to avoid
> reading ID_AA64MMFR1_EL1 on local CPUs when determining the h/w cap.
> 
> Note that though the Access flag support is a non-conflicting feature,
> we require all late CPUs to have it if the boot CPU does. Otherwise
> the feature won't be enabled regardless of the capabilities of late
> CPUs.
> 
> If there are h/w implementations that break this rule, they will have
> to add errata, unless they can provide justifications to switch to the
> less strict ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE.
> 
> Signed-off-by: Yu Zhao <yuzhao@google.com>
> ---
>   arch/arm64/include/asm/cpufeature.h | 20 +++++++-------------
>   arch/arm64/include/asm/pgtable.h    |  4 +---
>   arch/arm64/kernel/cpufeature.c      | 19 +++++++++++++++++++
>   arch/arm64/mm/proc.S                | 12 ------------
>   arch/arm64/tools/cpucaps            |  1 +
>   5 files changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
> index 338840c00e8e..c4336a374920 100644
> --- a/arch/arm64/include/asm/cpufeature.h
> +++ b/arch/arm64/include/asm/cpufeature.h
> @@ -763,6 +763,13 @@ static inline bool system_supports_tlb_range(void)
>   		cpus_have_const_cap(ARM64_HAS_TLB_RANGE);
>   }
>   
> +/* Check whether hardware update of the Access flag is supported. */
> +static inline bool system_has_hw_af(void)
> +{
> +	return IS_ENABLED(CONFIG_ARM64_HW_AFDBM) &&
> +		cpus_have_const_cap(ARM64_HW_AF);
> +}
> +
>   extern int do_emulate_mrs(struct pt_regs *regs, u32 sys_reg, u32 rt);
>   
>   static inline u32 id_aa64mmfr0_parange_to_phys_shift(int parange)
> @@ -786,19 +793,6 @@ static inline u32 id_aa64mmfr0_parange_to_phys_shift(int parange)
>   	}
>   }
>   
> -/* Check whether hardware update of the Access flag is supported */
> -static inline bool cpu_has_hw_af(void)
> -{
> -	u64 mmfr1;
> -
> -	if (!IS_ENABLED(CONFIG_ARM64_HW_AFDBM))
> -		return false;
> -
> -	mmfr1 = read_cpuid(ID_AA64MMFR1_EL1);
> -	return cpuid_feature_extract_unsigned_field(mmfr1,
> -						ID_AA64MMFR1_HADBS_SHIFT);
> -}
> -
>   static inline bool cpu_has_pan(void)
>   {
>   	u64 mmfr1 = read_cpuid(ID_AA64MMFR1_EL1);
> diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
> index 0b10204e72fc..864a2fdeb559 100644
> --- a/arch/arm64/include/asm/pgtable.h
> +++ b/arch/arm64/include/asm/pgtable.h
> @@ -982,9 +982,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
>    */
>   static inline bool arch_faults_on_old_pte(void)
>   {
> -	WARN_ON(preemptible());
> -
> -	return !cpu_has_hw_af();
> +	return !system_has_hw_af();
>   }
>   #define arch_faults_on_old_pte		arch_faults_on_old_pte
>   
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index efed2830d141..afdb6e0336ed 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -1566,6 +1566,14 @@ static bool has_hw_dbm(const struct arm64_cpu_capabilities *cap,
>   	return true;
>   }
>   
> +static void cpu_enable_hw_af(struct arm64_cpu_capabilities const *cap)
> +{
> +	if (has_cpuid_feature(cap, SCOPE_LOCAL_CPU)) {

You don't need this explicit check here. Since the cap is already
ARM64_CPUCAP_SYSTEM_FEATURE, it is guaranteed that all CPUs have
the capability, otherwise this wouldn't get called at all for any
CPUs.

Suzuki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-06-15 14:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-13 21:47 [PATCH] arm64: mm: fix warning in arch_faults_on_old_pte() Yu Zhao
2021-06-14 17:07 ` Catalin Marinas
2021-06-14 18:35   ` Yu Zhao
2021-06-15 10:35     ` Catalin Marinas
2021-06-15 10:48       ` Will Deacon
2021-06-15 10:40 ` Suzuki K Poulose [this message]
2021-06-15 10:52 ` Will Deacon
2021-06-15 13:47   ` Catalin Marinas
2021-06-16  7:27     ` Yu Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55db1c75-91b4-99ed-a0fa-cc9b5d3f35ac@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=justin.he@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=will@kernel.org \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).