linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64: cpufeature: fix unused function warning
@ 2020-12-03 22:32 Arnd Bergmann
  2020-12-04  9:59 ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: Arnd Bergmann @ 2020-12-03 22:32 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Mark Rutland
  Cc: Arnd Bergmann, Suzuki K Poulose, Anshuman Khandual,
	Ionela Voinescu, Mark Brown, Amit Daniel Kachhap,
	Kristina Martsenko, linux-arm-kernel, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The __system_matches_cap() function is now only used in an #ifdef
section:

arch/arm64/kernel/cpufeature.c:2649:13: error: unused function '__system_matches_cap' [-Werror,-Wunused-function]

Move it into that #ifdef section.

Fixes: 7cf283c7bd62 ("arm64: uaccess: remove redundant PAN toggling")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/arm64/kernel/cpufeature.c | 36 ++++++++++++++++------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 6bdb03400581..2c4e526c6e78 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -156,8 +156,6 @@ EXPORT_SYMBOL(cpu_hwcap_keys);
 
 static void cpu_enable_cnp(struct arm64_cpu_capabilities const *cap);
 
-static bool __system_matches_cap(unsigned int n);
-
 /*
  * NOTE: Any changes to the visibility of features should be kept in
  * sync with the documentation of the CPU feature register ABI.
@@ -1617,6 +1615,23 @@ static void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused)
 #endif /* CONFIG_ARM64_RAS_EXTN */
 
 #ifdef CONFIG_ARM64_PTR_AUTH
+/*
+ * This helper function is used in a narrow window when,
+ * - The system wide safe registers are set with all the SMP CPUs and,
+ * - The SYSTEM_FEATURE cpu_hwcaps may not have been set.
+ * In all other cases cpus_have_{const_}cap() should be used.
+ */
+static bool __system_matches_cap(unsigned int n)
+{
+	if (n < ARM64_NCAPS) {
+		const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n];
+
+		if (cap)
+			return cap->matches(cap, SCOPE_SYSTEM);
+	}
+	return false;
+}
+
 static bool has_address_auth_cpucap(const struct arm64_cpu_capabilities *entry, int scope)
 {
 	int boot_val, sec_val;
@@ -2640,23 +2655,6 @@ bool this_cpu_has_cap(unsigned int n)
 	return false;
 }
 
-/*
- * This helper function is used in a narrow window when,
- * - The system wide safe registers are set with all the SMP CPUs and,
- * - The SYSTEM_FEATURE cpu_hwcaps may not have been set.
- * In all other cases cpus_have_{const_}cap() should be used.
- */
-static bool __system_matches_cap(unsigned int n)
-{
-	if (n < ARM64_NCAPS) {
-		const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n];
-
-		if (cap)
-			return cap->matches(cap, SCOPE_SYSTEM);
-	}
-	return false;
-}
-
 void cpu_set_feature(unsigned int num)
 {
 	WARN_ON(num >= MAX_CPU_FEATURES);
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cpufeature: fix unused function warning
  2020-12-03 22:32 [PATCH] arm64: cpufeature: fix unused function warning Arnd Bergmann
@ 2020-12-04  9:59 ` Will Deacon
  2020-12-07 18:19   ` Catalin Marinas
  0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2020-12-04  9:59 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Catalin Marinas, Mark Rutland, Arnd Bergmann, Suzuki K Poulose,
	Anshuman Khandual, Ionela Voinescu, Mark Brown,
	Amit Daniel Kachhap, Kristina Martsenko, linux-arm-kernel,
	linux-kernel

On Thu, Dec 03, 2020 at 11:32:11PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The __system_matches_cap() function is now only used in an #ifdef
> section:
> 
> arch/arm64/kernel/cpufeature.c:2649:13: error: unused function '__system_matches_cap' [-Werror,-Wunused-function]
> 
> Move it into that #ifdef section.
> 
> Fixes: 7cf283c7bd62 ("arm64: uaccess: remove redundant PAN toggling")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  arch/arm64/kernel/cpufeature.c | 36 ++++++++++++++++------------------
>  1 file changed, 17 insertions(+), 19 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

We can probably go further and remove the helper altogether as I don't
think it really helps has_generic_auth(), but this should fix the warning.

Will

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cpufeature: fix unused function warning
  2020-12-04  9:59 ` Will Deacon
@ 2020-12-07 18:19   ` Catalin Marinas
  2020-12-08 10:03     ` Will Deacon
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Marinas @ 2020-12-07 18:19 UTC (permalink / raw)
  To: Will Deacon
  Cc: Arnd Bergmann, Mark Rutland, Arnd Bergmann, Suzuki K Poulose,
	Anshuman Khandual, Ionela Voinescu, Mark Brown,
	Amit Daniel Kachhap, Kristina Martsenko, linux-arm-kernel,
	linux-kernel

On Fri, Dec 04, 2020 at 09:59:10AM +0000, Will Deacon wrote:
> On Thu, Dec 03, 2020 at 11:32:11PM +0100, Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> > 
> > The __system_matches_cap() function is now only used in an #ifdef
> > section:
> > 
> > arch/arm64/kernel/cpufeature.c:2649:13: error: unused function '__system_matches_cap' [-Werror,-Wunused-function]
> > 
> > Move it into that #ifdef section.
> > 
> > Fixes: 7cf283c7bd62 ("arm64: uaccess: remove redundant PAN toggling")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>

I already queued a fix from Mark: 701f49065e68 ("arm64: mark
__system_matches_cap as __maybe_unused").

> Acked-by: Will Deacon <will@kernel.org>
> 
> We can probably go further and remove the helper altogether as I don't
> think it really helps has_generic_auth(), but this should fix the warning.

We could replace the ARM64_HAS_GENERIC_AUTH checks with a single helper
function that tests for ARM64_HAS_GENERIC_AUTH_ARCH or
ARM64_HAS_GENERIC_AUTH_IMP_DEF. Or you had a different idea?

-- 
Catalin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arm64: cpufeature: fix unused function warning
  2020-12-07 18:19   ` Catalin Marinas
@ 2020-12-08 10:03     ` Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2020-12-08 10:03 UTC (permalink / raw)
  To: Catalin Marinas
  Cc: Arnd Bergmann, Mark Rutland, Arnd Bergmann, Suzuki K Poulose,
	Anshuman Khandual, Ionela Voinescu, Mark Brown,
	Amit Daniel Kachhap, Kristina Martsenko, linux-arm-kernel,
	linux-kernel

On Mon, Dec 07, 2020 at 06:19:31PM +0000, Catalin Marinas wrote:
> On Fri, Dec 04, 2020 at 09:59:10AM +0000, Will Deacon wrote:
> > On Thu, Dec 03, 2020 at 11:32:11PM +0100, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > > 
> > > The __system_matches_cap() function is now only used in an #ifdef
> > > section:
> > > 
> > > arch/arm64/kernel/cpufeature.c:2649:13: error: unused function '__system_matches_cap' [-Werror,-Wunused-function]
> > > 
> > > Move it into that #ifdef section.
> > > 
> > > Fixes: 7cf283c7bd62 ("arm64: uaccess: remove redundant PAN toggling")
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> I already queued a fix from Mark: 701f49065e68 ("arm64: mark
> __system_matches_cap as __maybe_unused").
> 
> > Acked-by: Will Deacon <will@kernel.org>
> > 
> > We can probably go further and remove the helper altogether as I don't
> > think it really helps has_generic_auth(), but this should fix the warning.
> 
> We could replace the ARM64_HAS_GENERIC_AUTH checks with a single helper
> function that tests for ARM64_HAS_GENERIC_AUTH_ARCH or
> ARM64_HAS_GENERIC_AUTH_IMP_DEF. Or you had a different idea?

I was just thinking something like below, although it's a bit annoying
that we can't use cpucap_multi_entry_cap_matches() here afaict.

Will

--->8

diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
index 39138f6d3ba2..32a138ce0a92 100644
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -155,8 +155,6 @@ EXPORT_SYMBOL(cpu_hwcap_keys);
 
 static void cpu_enable_cnp(struct arm64_cpu_capabilities const *cap);
 
-static bool __system_matches_cap(unsigned int n);
-
 /*
  * NOTE: Any changes to the visibility of features should be kept in
  * sync with the documentation of the CPU feature register ABI.
@@ -1652,8 +1650,13 @@ static bool has_address_auth_metacap(const struct arm64_cpu_capabilities *entry,
 static bool has_generic_auth(const struct arm64_cpu_capabilities *entry,
 			     int __unused)
 {
-	return __system_matches_cap(ARM64_HAS_GENERIC_AUTH_ARCH) ||
-	       __system_matches_cap(ARM64_HAS_GENERIC_AUTH_IMP_DEF);
+	const struct arm64_cpu_capabilities *cap_arch, *cap_impdef;
+
+	cap_arch = cpu_hwcaps_ptrs[ARM64_HAS_GENERIC_AUTH_ARCH];
+	cap_impdef = cpu_hwcaps_ptrs[ARM64_HAS_GENERIC_AUTH_IMP_DEF];
+
+	return cap_arch->matches(cap_arch, SCOPE_SYSTEM) ||
+	       cap_impdef->matches(cap_impdef, SCOPE_SYSTEM);
 }
 #endif /* CONFIG_ARM64_PTR_AUTH */
 
@@ -2637,23 +2640,6 @@ bool this_cpu_has_cap(unsigned int n)
 	return false;
 }
 
-/*
- * This helper function is used in a narrow window when,
- * - The system wide safe registers are set with all the SMP CPUs and,
- * - The SYSTEM_FEATURE cpu_hwcaps may not have been set.
- * In all other cases cpus_have_{const_}cap() should be used.
- */
-static bool __maybe_unused __system_matches_cap(unsigned int n)
-{
-	if (n < ARM64_NCAPS) {
-		const struct arm64_cpu_capabilities *cap = cpu_hwcaps_ptrs[n];
-
-		if (cap)
-			return cap->matches(cap, SCOPE_SYSTEM);
-	}
-	return false;
-}
-
 void cpu_set_feature(unsigned int num)
 {
 	WARN_ON(num >= MAX_CPU_FEATURES);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-12-08 10:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 22:32 [PATCH] arm64: cpufeature: fix unused function warning Arnd Bergmann
2020-12-04  9:59 ` Will Deacon
2020-12-07 18:19   ` Catalin Marinas
2020-12-08 10:03     ` Will Deacon

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).