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 X-Spam-Level: X-Spam-Status: No, score=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49A50C48BDF for ; Sun, 13 Jun 2021 21:49:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0A4A36124B for ; Sun, 13 Jun 2021 21:49:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A4A36124B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=PeB/70RQy6nOPM+I+iZg57GgbbKocLDZnmRlRdMFbWQ=; b=QLH bpVGHtwsnPUHOUVzeO3nYGTKHDTnLPqifoaFvg7VioyP13wQv0F8sl+C8eZ9mZ/XUjZUdBQ781u4H PgT7kHznf/oBxMyaVauQoEaKvZ/F3y5FfOaJjN2s4AXpEkSTNpcS7U+HbNz9VJo24kzrGKex6ObI/ X8Fx99xw42TBk1IWFF1VtJZZOCss2viZBw3IkrNW0lecCHOHtkZagHoBhM30b64IHVYbKF7/GJAUo glPPl3SSxAPYRhZ5UJt6ZBCtZv86sH+zsVOesmr4zcSTS8CjACaqmJoxF3j0epGUHLMiIbYff6E3K vIlkfICx0UDYvruvDEUn/Gk4LCfrssg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsXxE-00BOKz-Tp; Sun, 13 Jun 2021 21:47:41 +0000 Received: from mail-qk1-x749.google.com ([2607:f8b0:4864:20::749]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lsXxA-00BOJp-QL for linux-arm-kernel@lists.infradead.org; Sun, 13 Jun 2021 21:47:38 +0000 Received: by mail-qk1-x749.google.com with SMTP id a193-20020a3766ca0000b02903a9be00d619so25163418qkc.12 for ; Sun, 13 Jun 2021 14:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=lsnSkfq1zwoHwYgigbb2mRzMBkgPJVvpC0XFwzSa81c=; b=lVDVevmrpZ6O1YI3de348aAFnEk/aiyTL/locP+ALwqed4uPJMm7GwvacJ3XwCW7/Q IdTVQs3fKWbsa8NrvLIDDlnrNxpfUlCiuNQDEqIg4BAE+yfYBs0EMVnR1jOdV+FIjv5R 7j3JxCXp+F2BroAECwpSatLaM7ZnWZD7jazGxyjJsMI1VBYxhE5H4P8dIWeE5f9ybPHp ednvzkRGUDkEmyyp3NyBKSp4RjfI5WhogcPBEj1j4x9aj1Cn4V/nJnb7iSNtLeE//l4b i6j3exNACEkAYXibh0qwh207MR8lirfl02qIDhOimpnbPhpGO1VMfBi4NSKDHGZMcp/y bomw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=lsnSkfq1zwoHwYgigbb2mRzMBkgPJVvpC0XFwzSa81c=; b=MplaroUTiEsZf93kiR2dC0J3H7UUS4MAJJwiQn+NNpkHRUepVvTPNSsicVvNRCMJjR 8qATV7swUhCVYpDy3xHawa+zCaJ9EXTXOPoOkmUCeLaWAx+LN0TmO6TA4ZCpmW/hM8yZ 8RGuSjCjZe+Tvn+42R4lkr1Om0cmtI9B0LNqhGH7wmmYcL0pgzFzRGt77nL1O5wHVv/v ksOj01/RnlTHvnkm87E8+FPgg28MLdTsl2VftUFPsIpd6ghIR1yHDzexGxGa/ps4MYb/ dDqN9a+RoLMfunU/tV2zvxOkFfJCQ0ku6F9Mtt8rHRygF5xdimf2WbF6zh4D+Ao5UVZ4 is3A== X-Gm-Message-State: AOAM532HsUCrjwmwwZ0kiD1OtS0qZGFd7wA3AjEd7sfVMN9XTea2Qt+8 QfmM8Vp/K0fxhdhqExsJebppvKF05es= X-Google-Smtp-Source: ABdhPJznwLIGZK0xYBFPGo+6mL+ybRfASk/WZDfAmOFzQO3NQZkwz89k+vZMYNBN/K0wIVbqkMmDRwT6hJ4= X-Received: from yuzhao.bld.corp.google.com ([2620:15c:183:200:5b13:9d01:e993:58c0]) (user=yuzhao job=sendgmr) by 2002:ad4:596c:: with SMTP id eq12mr15601162qvb.30.1623620853445; Sun, 13 Jun 2021 14:47:33 -0700 (PDT) Date: Sun, 13 Jun 2021 15:47:28 -0600 Message-Id: <20210613214728.1695340-1-yuzhao@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.32.0.272.g935e593368-goog Subject: [PATCH] arm64: mm: fix warning in arch_faults_on_old_pte() From: Yu Zhao To: Jia He , Catalin Marinas Cc: Mark Rutland , Will Deacon , Marc Zyngier , Suzuki Poulose , linux-arm-kernel@lists.infradead.org, Yu Zhao X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210613_144736_907085_3748ADDB X-CRM114-Status: GOOD ( 17.57 ) 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 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 --- 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)) { + u64 val = read_sysreg(tcr_el1); + + write_sysreg(val | TCR_HA, tcr_el1); + } +} #endif #ifdef CONFIG_ARM64_AMU_EXTN @@ -2043,6 +2051,17 @@ static const struct arm64_cpu_capabilities arm64_features[] = { .matches = has_hw_dbm, .cpu_enable = cpu_enable_hw_dbm, }, + { + .desc = "Hardware update of the Access flag", + .type = ARM64_CPUCAP_SYSTEM_FEATURE, + .capability = ARM64_HW_AF, + .sys_reg = SYS_ID_AA64MMFR1_EL1, + .sign = FTR_UNSIGNED, + .field_pos = ID_AA64MMFR1_HADBS_SHIFT, + .min_field_value = 1, + .matches = has_cpuid_feature, + .cpu_enable = cpu_enable_hw_af, + }, #endif { .desc = "CRC32 instructions", diff --git a/arch/arm64/mm/proc.S b/arch/arm64/mm/proc.S index 97d7bcd8d4f2..51ee6044748a 100644 --- a/arch/arm64/mm/proc.S +++ b/arch/arm64/mm/proc.S @@ -484,18 +484,6 @@ SYM_FUNC_START(__cpu_setup) * Set the IPS bits in TCR_EL1. */ tcr_compute_pa_size tcr, #TCR_IPS_SHIFT, x5, x6 -#ifdef CONFIG_ARM64_HW_AFDBM - /* - * Enable hardware update of the Access Flags bit. - * Hardware dirty bit management is enabled later, - * via capabilities. - */ - mrs x9, ID_AA64MMFR1_EL1 - and x9, x9, #0xf - cbz x9, 1f - orr tcr, tcr, #TCR_HA // hardware Access flag update -1: -#endif /* CONFIG_ARM64_HW_AFDBM */ msr mair_el1, mair msr tcr_el1, tcr /* diff --git a/arch/arm64/tools/cpucaps b/arch/arm64/tools/cpucaps index 21fbdda7086e..435f7ae1ac81 100644 --- a/arch/arm64/tools/cpucaps +++ b/arch/arm64/tools/cpucaps @@ -34,6 +34,7 @@ HAS_STAGE2_FWB HAS_SYSREG_GIC_CPUIF HAS_TLB_RANGE HAS_VIRT_HOST_EXTN +HW_AF HW_DBM KVM_PROTECTED_MODE MISMATCHED_CACHE_TYPE -- 2.32.0.272.g935e593368-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel