[PATCH] arm64: cpufeature: Replace inline with __always_inline for GCS checks
李豪杰
15074444048 at 163.com
Fri Aug 15 23:49:21 PDT 2025
At 2025-08-15 23:38:11, "Mark Brown" <broonie at kernel.org> wrote:
>On Fri, Aug 15, 2025 at 09:19:05AM +0800, 15074444048 at 163.com wrote:
>
>> 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.
>
>> -static inline bool system_supports_gcs(void)
>> +static __always_inline bool system_supports_gcs(void)
>> {
>> return alternative_has_cap_unlikely(ARM64_HAS_GCS);
>> }
>
>If we're doing this for one of the system_supports_foo() functions we
>should do it for all of them consistently, not just for one random one.
Thanks for your advs!
The key point of this issue is that calling preserve_gcs_context and restore_gcs_context illegal,
>>>
@@ -1136,6 +1239,12 @@ static int setup_sigframe(struct rt_sigframe_user_layout *user,
__put_user_error(current->thread.fault_code, &esr_ctx->esr, err);
}
+ if (system_supports_gcs() && err == 0 && user->gcs_offset) {
+ struct gcs_context __user *gcs_ctx =
+ apply_user_offset(user, user->gcs_offset);
+ err |= preserve_gcs_context(gcs_ctx);
+ }
<<<
__always_inline just help optimize undefined func,Of course, this could also be circumvented
by adding CONFIG_ARM64_GCS checks. I'don't think other system_support_foo() functions
should modify, they don't exhibit similar problems.
More information about the linux-arm-kernel
mailing list