[PATCH 1/2] arm64/gcs: Move gcs_check_locked() out of the header

From: Mark Brown

Date: Thu Sep 17 2026 - 18:27:43 EST


gcs_check_locked() is currently a static inline in the header but there
is no real reason for this, it is not especially performance critical.
Move the implementation into gcs.c to reduce the size of the header and
make future refactoring a little easier, no functional changes.

Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
arch/arm64/include/asm/gcs.h | 15 +--------------
arch/arm64/mm/gcs.c | 13 +++++++++++++
2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/arch/arm64/include/asm/gcs.h b/arch/arm64/include/asm/gcs.h
index bbc22e382cfe..3e6eeeebd282 100644
--- a/arch/arm64/include/asm/gcs.h
+++ b/arch/arm64/include/asm/gcs.h
@@ -62,25 +62,12 @@ static inline bool task_gcs_el0_enabled(struct task_struct *task)
}

void gcs_set_el0_mode(struct task_struct *task);
+int gcs_check_locked(struct task_struct *task, unsigned long new_val);
void gcs_free(struct task_struct *task);
void gcs_preserve_current_state(void);
unsigned long gcs_alloc_thread_stack(struct task_struct *tsk,
const struct kernel_clone_args *args);

-static inline int gcs_check_locked(struct task_struct *task,
- unsigned long new_val)
-{
- unsigned long cur_val = task->thread.gcs_el0_mode;
-
- cur_val &= task->thread.gcs_el0_locked;
- new_val &= task->thread.gcs_el0_locked;
-
- if (cur_val != new_val)
- return -EPERM;
-
- return 0;
-}
-
static inline int gcssttr(unsigned long __user *addr, unsigned long val)
{
register unsigned long __user *_addr __asm__ ("x0") = addr;
diff --git a/arch/arm64/mm/gcs.c b/arch/arm64/mm/gcs.c
index 680749611a9a..84add924dc60 100644
--- a/arch/arm64/mm/gcs.c
+++ b/arch/arm64/mm/gcs.c
@@ -140,6 +140,19 @@ void gcs_set_el0_mode(struct task_struct *task)
write_sysreg_s(gcscre0_el1, SYS_GCSCRE0_EL1);
}

+int gcs_check_locked(struct task_struct *task, unsigned long new_val)
+{
+ unsigned long cur_val = task->thread.gcs_el0_mode;
+
+ cur_val &= task->thread.gcs_el0_locked;
+ new_val &= task->thread.gcs_el0_locked;
+
+ if (cur_val != new_val)
+ return -EPERM;
+
+ return 0;
+}
+
void gcs_free(struct task_struct *task)
{
if (!system_supports_gcs())

--
2.47.3