From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 91BAA34F259 for ; Wed, 8 Jul 2026 03:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783480307; cv=none; b=Ms2lY0/wPd2kixVMzS28HTgHbGsOrqE3ROW6qbcMAIkAmBVvBmEhvRYv5IW7iUvZbidZEA0TNUmLi+ciIwy+E/1+eUOiGpmdiqYPGVmiPPrObo/NqKhNWaPfkURpDfO17LLoX6Ypv3ETEXBAIQPXYQRIVWxC+iA6PvD6isUzxZM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783480307; c=relaxed/simple; bh=AVm9LbiyrGS/CRlPtW/PWaGqvtChHOjCkDQhFChrxZw=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=XSE44Xk7nJpnRPi5+70O8sgl6iZ3jfvfe3j1f8NDRpsSnv3dxJx/AnaatbUotlPtcwAI+CVorKk8MWqEsqogvpaqCLvTW7FqAgmtwkaJiMjamoUAE/sdJAirEodH6obAeS9H2erEbNyoZZJPkqACPuEp0rcnPschdrZr/9xorOA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=KGiyEGOe; arc=none smtp.client-ip=209.85.214.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--jthoughton.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KGiyEGOe" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2cc86a9ef97so6300255ad.3 for ; Tue, 07 Jul 2026 20:11:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1783480299; x=1784085099; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Ibpf6/Yw4Qk7w5nMnSeu5NqKAQPPT11UDasodOvdS4o=; b=KGiyEGOeReze1avvkVNsz27cEYhXWOictT0QKxb9XcALIa5GpJf35Kv/28XHoRd2aJ 0Xj67yLp5HEz5+MFXEEQtkF3m02arP5VRalE2YfqawbkbIrKvmZj90q1Kwks6mTJKD5B 8qhLLovH/3YD9oEqaW9VGcRFwjjIIUA3B/JeY1Q85no0oS9ftk2K+O8lpKWxE4SE5vhL oKYWGRSngGoAK83SO7IORnP4j2TGMUZuFKA4stzasx35Q2EY10o5xvKItXYFBz0XxE31 mMX7NaozlAghv3rkpSS/fYgGOkJu6/oV5AbVqECVePvkbz84zrwtpCJqM/xwo4zyVnSh aovA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783480299; x=1784085099; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ibpf6/Yw4Qk7w5nMnSeu5NqKAQPPT11UDasodOvdS4o=; b=mN64BUViunMc53TrGUfGEldSPKd9aGohbzTipP7fwtGxq573zn2+Bp+1cXZ32fbikq dcbKm5U6OvPKaBYf8+w9N9CubFe7CMTIEb0/EIwa1a5ygQs9ij6LT9EQMLSeYiSscCOz zN/ppr5a2u9/lA2j+quOCLxF7L7+ltSy56j45omBQX9SNQFeNN2EKksCv/f7YBwEf7Vm JY7WE/uLJ8Zj+Zv7cnyEJdkHVXuUwqf6WXIC79COpi/agH9DZHBt+u6LHKLVmGnlonk7 pNzW5wW0oXPzEZFmE/QOeMOH6lxomrr0LDjD4vmX+kSRoooHX9YteeTmxTd1dxLpIqlX mcFg== X-Forwarded-Encrypted: i=1; AHgh+RqysmIJ85eAA6yYD46alRE6HDNbvFyX80gZ0is6f7uHNzhOG4UnAv63ot3hKSCTGfgoXDJXQmHU+aCzCnw=@vger.kernel.org X-Gm-Message-State: AOJu0YwSRZp9Zj50O+oKqT3qI3T7dJMwndn36uR6mOdWrGGInEVmALNm ixm3NvH8KlanSv3oWr5O6HPfUVDiSoUPR7I7Pc7DgpJJgyzBrVPeUFGCuciJrNwUoMGHFO7ixDm RcFQ3LzDQNzuUHXIxnfUuGg== X-Received: from pllg11.prod.google.com ([2002:a17:902:740b:b0:2cc:e845:dd38]) (user=jthoughton job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:fdab:b0:2ca:d666:df72 with SMTP id d9443c01a7336-2ccea39be30mr7195965ad.21.1783480298875; Tue, 07 Jul 2026 20:11:38 -0700 (PDT) Date: Wed, 8 Jul 2026 03:11:16 +0000 In-Reply-To: <20260708031129.3503195-1-jthoughton@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260708031129.3503195-1-jthoughton@google.com> X-Mailer: git-send-email 2.55.0.795.g602f6c329a-goog Message-ID: <20260708031129.3503195-7-jthoughton@google.com> Subject: [PATCH 06/18] arm64: Rename cpu_has_hw_af to system_has_hw_af From: James Houghton To: Will Deacon , Catalin Marinas , Muchun Song , Oscar Salvador Cc: Nikos Nikoleris , Linu Cherian , Mark Rutland , David Hildenbrand , Andrew Morton , Ryan Roberts , Nanyong Sun , Yu Zhao , Frank van der Linden , David Rientjes , James Houghton , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" In a follow-up patch, a new system feature will need to check for the presence of HW AF on each CPU individually. Signed-off-by: James Houghton --- arch/arm64/include/asm/cpufeature.h | 26 ++++++++++++++++++++------ arch/arm64/include/asm/pgtable.h | 4 ++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index a57870fa96db..e818ad1b56e2 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -910,22 +910,36 @@ 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) +static inline bool supports_hw_af(int scope) { u64 mmfr1; if (!IS_ENABLED(CONFIG_ARM64_HW_AFDBM)) return false; - /* - * Use cached version to avoid emulated msr operation on KVM - * guests. - */ - mmfr1 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1); + if (scope == SCOPE_SYSTEM) { + /* + * Use cached version to avoid emulated msr operation on KVM + * guests. + */ + mmfr1 = read_sanitised_ftr_reg(SYS_ID_AA64MMFR1_EL1); + } else { + mmfr1 = read_cpuid(ID_AA64MMFR1_EL1); + } return cpuid_feature_extract_unsigned_field(mmfr1, ID_AA64MMFR1_EL1_HAFDBS_SHIFT); } +static inline bool system_has_hw_af(void) +{ + return supports_hw_af(SCOPE_SYSTEM); +} + +static inline bool cpu_has_hw_af(void) +{ + return supports_hw_af(SCOPE_LOCAL_CPU); +} + 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 27689c62bd25..5f21d3a738ee 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -1598,7 +1598,7 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, * page after fork() + CoW for pfn mappings. We don't always have a * hardware-managed access flag on arm64. */ -#define arch_has_hw_pte_young cpu_has_hw_af +#define arch_has_hw_pte_young system_has_hw_af #ifdef CONFIG_ARCH_HAS_NONLEAF_PMD_YOUNG #define arch_has_hw_nonleaf_pmd_young system_supports_haft @@ -1608,7 +1608,7 @@ static inline void update_mmu_cache_range(struct vm_fault *vmf, * Experimentally, it's cheap to set the access flag in hardware and we * benefit from prefaulting mappings as 'old' to start with. */ -#define arch_wants_old_prefaulted_pte cpu_has_hw_af +#define arch_wants_old_prefaulted_pte system_has_hw_af /* * Request exec memory is read into pagecache in at least 64K folios. This size -- 2.55.0.795.g602f6c329a-goog