[PATCH] arm64: cpufeature: Replace inline with __always_inline for GCS checks

15074444048 at 163.com 15074444048 at 163.com
Thu Aug 14 18:19:05 PDT 2025


From: lihaojie <lihaojie at kylinos.cn>

Fix error:
aarch64-linux-gnu-ld: arch/arm64/kernel/signal.o: in function `setup_sigframe':
signal.c:(.text+0x16ec): undefined reference to `preserve_gcs_context'
aarch64-linux-gnu-ld: arch/arm64/kernel/signal.o: in function `restore_sigframe':
signal.c:(.text+0x210c): undefined reference to `restore_gcs_context'

When CONFIG_ARM64_GCS is disabled, the compiler reports undefined symbol
errors, that's because of inline hint. __always_inline can resolve this
issue.

When use __always_inline The compiler will almost certainly inline
system_supports_gcs, which allows the compiler to optimize and check
earlier during the compilation phase. If system_supports_gcs() returns
false, then the line of code restore_gcs_context (&user) will not
actually be generated, so the compiler will not report an error.

Signed-off-by: lihaojie <lihaojie at kylinos.cn>
---
 arch/arm64/include/asm/cpufeature.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h
index bf13d676aae2..4eddf6e78d77 100644
--- a/arch/arm64/include/asm/cpufeature.h
+++ b/arch/arm64/include/asm/cpufeature.h
@@ -846,7 +846,7 @@ static inline bool system_supports_poe(void)
 	return alternative_has_cap_unlikely(ARM64_HAS_S1POE);
 }
 
-static inline bool system_supports_gcs(void)
+static __always_inline bool system_supports_gcs(void)
 {
 	return alternative_has_cap_unlikely(ARM64_HAS_GCS);
 }
-- 
2.25.1




More information about the linux-arm-kernel mailing list