Skip to content

Commit

Permalink
arm64/gcs: Provide put_user_gcs()
Browse files Browse the repository at this point in the history
In order for EL1 to write to an EL0 GCS it must use the GCSSTTR instruction
rather than a normal STTR. Provide a put_user_gcs() which does this.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241001-arm64-gcs-v13-10-222b78d87eee@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
  • Loading branch information
Mark Brown authored and Catalin Marinas committed Oct 4, 2024
1 parent dad947c commit d0aa2b4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions arch/arm64/include/asm/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,24 @@ static inline int gcssttr(unsigned long __user *addr, unsigned long val)
return err;
}

static inline void put_user_gcs(unsigned long val, unsigned long __user *addr,
int *err)
{
int ret;

if (!access_ok((char __user *)addr, sizeof(u64))) {
*err = -EFAULT;
return;
}

uaccess_ttbr0_enable();
ret = gcssttr(addr, val);
if (ret != 0)
*err = ret;
uaccess_ttbr0_disable();
}


#endif /* CONFIG_ARM64_GCS */

#endif /* __ASM_UACCESS_H */

0 comments on commit d0aa2b4

Please sign in to comment.