2005-04-16 15:20:36 -07:00
/*
2007-10-16 01:27:00 -07:00
* Copyright ( C ) 2003 - 2007 Jeff Dike ( jdike @ { addtoit , linux . intel } . com )
2005-04-16 15:20:36 -07:00
* Copyright 2003 PathScale , Inc .
*
* Licensed under the GPL
*/
2012-09-20 09:28:25 -04:00
# include <linux/sched.h>
2017-02-04 00:16:44 +01:00
# include <linux/sched/mm.h>
2017-03-20 01:16:21 -07:00
# include <linux/syscalls.h>
2015-05-12 00:13:05 +02:00
# include <linux/uaccess.h>
2012-09-20 09:28:25 -04:00
# include <asm/prctl.h> /* XXX This should get the constants from libc */
2021-09-20 21:32:50 +00:00
# include <registers.h>
2012-09-20 09:28:25 -04:00
# include <os.h>
2005-04-16 15:20:36 -07:00
2017-03-20 16:05:35 -07:00
long arch_prctl ( struct task_struct * task , int option ,
2017-03-20 01:16:22 -07:00
unsigned long __user * arg2 )
2005-04-16 15:20:36 -07:00
{
2023-11-10 12:03:46 +01:00
long ret = - EINVAL ;
2007-02-10 01:44:29 -08:00
2017-03-20 01:16:20 -07:00
switch ( option ) {
2007-02-10 01:44:29 -08:00
case ARCH_SET_FS :
2023-11-10 12:03:46 +01:00
current - > thread . regs . regs . gp [ FS_BASE / sizeof ( unsigned long ) ] =
( unsigned long ) arg2 ;
ret = 0 ;
2007-03-07 20:41:26 -08:00
break ;
2007-02-10 01:44:29 -08:00
case ARCH_SET_GS :
2023-11-10 12:03:46 +01:00
current - > thread . regs . regs . gp [ GS_BASE / sizeof ( unsigned long ) ] =
( unsigned long ) arg2 ;
ret = 0 ;
2005-05-28 15:52:03 -07:00
break ;
2005-04-16 15:20:36 -07:00
case ARCH_GET_FS :
2023-11-10 12:03:46 +01:00
ret = put_user ( current - > thread . regs . regs . gp [ FS_BASE / sizeof ( unsigned long ) ] , arg2 ) ;
2007-10-16 01:27:00 -07:00
break ;
2005-04-16 15:20:36 -07:00
case ARCH_GET_GS :
2023-11-10 12:03:46 +01:00
ret = put_user ( current - > thread . regs . regs . gp [ GS_BASE / sizeof ( unsigned long ) ] , arg2 ) ;
2007-10-16 01:27:00 -07:00
break ;
2005-04-16 15:20:36 -07:00
}
2007-02-10 01:44:29 -08:00
return ret ;
2005-04-16 15:20:36 -07:00
}
2017-03-20 01:16:22 -07:00
SYSCALL_DEFINE2 ( arch_prctl , int , option , unsigned long , arg2 )
2005-04-16 15:20:36 -07:00
{
2017-03-20 01:16:22 -07:00
return arch_prctl ( current , option , ( unsigned long __user * ) arg2 ) ;
2005-04-16 15:20:36 -07:00
}
2008-02-04 22:30:49 -08:00
void arch_switch_to ( struct task_struct * to )
2007-02-10 01:44:29 -08:00
{
2023-11-10 12:03:46 +01:00
/*
* Nothing needs to be done on x86_64 .
* The FS_BASE / GS_BASE registers are saved in the ptrace register set .
*/
2005-04-16 15:20:36 -07:00
}
2021-09-20 21:32:48 +00:00
SYSCALL_DEFINE6 ( mmap , unsigned long , addr , unsigned long , len ,
unsigned long , prot , unsigned long , flags ,
unsigned long , fd , unsigned long , off )
{
if ( off & ~ PAGE_MASK )
return - EINVAL ;
return ksys_mmap_pgoff ( addr , len , prot , flags , fd , off > > PAGE_SHIFT ) ;
}