Skip to content

Commit d0aa2b4

Browse files
brooniectmarinas
authored andcommitted
arm64/gcs: Provide put_user_gcs()
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 <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Signed-off-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent dad947c commit d0aa2b4

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

arch/arm64/include/asm/uaccess.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,24 @@ static inline int gcssttr(unsigned long __user *addr, unsigned long val)
522522
return err;
523523
}
524524

525+
static inline void put_user_gcs(unsigned long val, unsigned long __user *addr,
526+
int *err)
527+
{
528+
int ret;
529+
530+
if (!access_ok((char __user *)addr, sizeof(u64))) {
531+
*err = -EFAULT;
532+
return;
533+
}
534+
535+
uaccess_ttbr0_enable();
536+
ret = gcssttr(addr, val);
537+
if (ret != 0)
538+
*err = ret;
539+
uaccess_ttbr0_disable();
540+
}
541+
542+
525543
#endif /* CONFIG_ARM64_GCS */
526544

527545
#endif /* __ASM_UACCESS_H */

0 commit comments

Comments
 (0)