2005-04-17 02:20:36 +04:00
/ *
* Compatibility m o d e s y s t e m c a l l e n t r y p o i n t f o r x86 - 6 4 .
*
* Copyright 2 0 0 0 - 2 0 0 2 A n d i K l e e n , S u S E L a b s .
* /
# include < a s m / d w a r f2 . h >
# include < a s m / c a l l i n g . h >
2005-09-09 23:28:48 +04:00
# include < a s m / a s m - o f f s e t s . h >
2005-04-17 02:20:36 +04:00
# include < a s m / c u r r e n t . h >
# include < a s m / e r r n o . h >
# include < a s m / i a32 _ u n i s t d . h >
# include < a s m / t h r e a d _ i n f o . h >
# include < a s m / s e g m e n t . h >
2006-07-03 11:24:45 +04:00
# include < a s m / i r q f l a g s . h >
2005-04-17 02:20:36 +04:00
# include < l i n u x / l i n k a g e . h >
2008-06-24 12:13:31 +04:00
/* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
# include < l i n u x / e l f - e m . h >
# define A U D I T _ A R C H _ I 3 8 6 ( E M _ 3 8 6 | _ _ A U D I T _ A R C H _ L E )
# define _ _ A U D I T _ A R C H _ L E 0 x40 0 0 0 0 0 0
# ifndef C O N F I G _ A U D I T S Y S C A L L
2009-09-30 14:22:11 +04:00
# define s y s e x i t _ a u d i t i a32 _ r e t _ f r o m _ s y s _ c a l l
# define s y s r e t l _ a u d i t i a32 _ r e t _ f r o m _ s y s _ c a l l
2008-06-24 12:13:31 +04:00
# endif
2011-03-07 21:10:39 +03:00
.section .entry .text , " ax"
2006-04-07 21:50:31 +04:00
# define I A 3 2 _ N R _ s y s c a l l s ( ( i a32 _ s y s c a l l _ e n d - i a32 _ s y s _ c a l l _ t a b l e ) / 8 )
2005-04-17 02:20:36 +04:00
.macro IA32_ARG_FIXUP noebp=0
movl % e d i ,% r8 d
.if \ noebp
.else
movl % e b p ,% r9 d
.endif
xchg % e c x ,% e s i
movl % e b x ,% e d i
movl % e d x ,% e d x / * z e r o e x t e n s i o n * /
.endm
/* clobbers %eax */
2009-09-30 14:22:11 +04:00
.macro CLEAR_RREGS offset=0 , _ r9 =rax
2005-04-17 02:20:36 +04:00
xorl % e a x ,% e a x
2009-09-30 14:22:11 +04:00
movq % r a x ,\ o f f s e t + R 1 1 ( % r s p )
movq % r a x ,\ o f f s e t + R 1 0 ( % r s p )
movq % \ _ r9 ,\ o f f s e t + R 9 ( % r s p )
movq % r a x ,\ o f f s e t + R 8 ( % r s p )
2005-04-17 02:20:36 +04:00
.endm
2008-07-09 13:38:07 +04:00
/ *
* Reload a r g r e g i s t e r s f r o m s t a c k i n c a s e p t r a c e c h a n g e d t h e m .
* We d o n ' t r e l o a d % e a x b e c a u s e s y s c a l l _ t r a c e _ e n t e r ( ) r e t u r n e d
2010-09-14 23:22:58 +04:00
* the % r a x v a l u e w e s h o u l d s e e . I n s t e a d , w e j u s t t r u n c a t e t h a t
* value t o 3 2 b i t s a g a i n a s w e d i d o n e n t r y f r o m u s e r m o d e .
* If i t ' s a n e w v a l u e s e t b y u s e r _ r e g s e t d u r i n g e n t r y t r a c i n g ,
* this m a t c h e s t h e n o r m a l t r u n c a t i o n o f t h e u s e r - m o d e v a l u e .
* If i t ' s - 1 t o m a k e u s p u n t t h e s y s c a l l , t h e n ( u 3 2 ) - 1 i s s t i l l
* an a p p r o p r i a t e l y i n v a l i d v a l u e .
2008-07-09 13:38:07 +04:00
* /
2008-08-29 16:21:11 +04:00
.macro LOAD_ARGS32 offset, _ r9 =0
.if \ _ r9
2007-09-21 18:16:18 +04:00
movl \ o f f s e t + 1 6 ( % r s p ) ,% r9 d
2008-08-29 16:21:11 +04:00
.endif
2007-09-21 18:16:18 +04:00
movl \ o f f s e t + 4 0 ( % r s p ) ,% e c x
movl \ o f f s e t + 4 8 ( % r s p ) ,% e d x
movl \ o f f s e t + 5 6 ( % r s p ) ,% e s i
movl \ o f f s e t + 6 4 ( % r s p ) ,% e d i
2010-09-14 23:22:58 +04:00
movl % e a x ,% e a x / * z e r o e x t e n s i o n * /
2007-09-21 18:16:18 +04:00
.endm
2006-01-12 00:41:59 +03:00
.macro CFI_STARTPROC32 simple
CFI_ S T A R T P R O C \ s i m p l e
CFI_ U N D E F I N E D r8
CFI_ U N D E F I N E D r9
CFI_ U N D E F I N E D r10
CFI_ U N D E F I N E D r11
CFI_ U N D E F I N E D r12
CFI_ U N D E F I N E D r13
CFI_ U N D E F I N E D r14
CFI_ U N D E F I N E D r15
.endm
2008-06-25 08:19:28 +04:00
# ifdef C O N F I G _ P A R A V I R T
ENTRY( n a t i v e _ u s e r g s _ s y s r e t 3 2 )
swapgs
sysretl
ENDPROC( n a t i v e _ u s e r g s _ s y s r e t 3 2 )
ENTRY( n a t i v e _ i r q _ e n a b l e _ s y s e x i t )
swapgs
sti
sysexit
ENDPROC( n a t i v e _ i r q _ e n a b l e _ s y s e x i t )
# endif
2005-04-17 02:20:36 +04:00
/ *
* 3 2 bit S Y S E N T E R i n s t r u c t i o n e n t r y .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx A r g 2
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp u s e r s t a c k
* 0 ( % ebp) A r g 6
*
* Interrupts o f f .
*
* This i s p u r e l y a f a s t p a t h . F o r a n y t h i n g c o m p l i c a t e d w e u s e t h e i n t 0 x80
* path b e l o w . S e t u p a c o m p l e t e h a r d w a r e s t a c k f r a m e t o s h a r e c o d e
* with t h e i n t 0 x80 p a t h .
* /
ENTRY( i a32 _ s y s e n t e r _ t a r g e t )
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2005-09-12 20:49:24 +04:00
CFI_ D E F _ C F A r s p ,0
CFI_ R E G I S T E R r s p ,r b p
2008-06-26 18:28:51 +04:00
SWAPGS_ U N S A F E _ S T A C K
2009-01-18 18:38:58 +03:00
movq P E R _ C P U _ V A R ( k e r n e l _ s t a c k ) , % r s p
addq $ ( K E R N E L _ S T A C K _ O F F S E T ) ,% r s p
2006-07-03 11:24:45 +04:00
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s , h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2008-06-25 08:19:29 +04:00
ENABLE_ I N T E R R U P T S ( C L B R _ N O N E )
2005-04-17 02:20:36 +04:00
movl % e b p ,% e b p / * z e r o e x t e n s i o n * /
2011-02-28 18:54:40 +03:00
pushq_ c f i $ _ _ U S E R 3 2 _ D S
2005-09-12 20:49:24 +04:00
/*CFI_REL_OFFSET ss,0*/
2011-02-28 18:54:40 +03:00
pushq_ c f i % r b p
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r s p ,0
2011-02-28 18:54:40 +03:00
pushfq_ c f i
2005-09-12 20:49:24 +04:00
/*CFI_REL_OFFSET rflags,0*/
2011-11-29 15:17:45 +04:00
movl T I _ s y s e n t e r _ r e t u r n + T H R E A D _ I N F O ( % r s p ,3 * 8 - K E R N E L _ S T A C K _ O F F S E T ) ,% r10 d
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r10
2011-02-28 18:54:40 +03:00
pushq_ c f i $ _ _ U S E R 3 2 _ C S
2005-09-12 20:49:24 +04:00
/*CFI_REL_OFFSET cs,0*/
2005-04-17 02:20:36 +04:00
movl % e a x , % e a x
2011-02-28 18:54:40 +03:00
pushq_ c f i % r10
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r i p ,0
2011-02-28 18:54:40 +03:00
pushq_ c f i % r a x
2005-04-17 02:20:36 +04:00
cld
2011-06-01 00:21:52 +04:00
SAVE_ A R G S 0 ,1 ,0
2005-04-17 02:20:36 +04:00
/ * no n e e d t o d o a n a c c e s s _ o k c h e c k h e r e b e c a u s e r b p h a s b e e n
3 2 bit z e r o e x t e n d e d * /
2008-08-29 16:21:11 +04:00
1 : movl ( % r b p ) ,% e b p
2005-04-17 02:20:36 +04:00
.section _ _ ex_ t a b l e ," a "
.quad 1 b,i a32 _ b a d a r g
.previous
2011-11-29 15:17:45 +04:00
orl $ T S _ C O M P A T ,T I _ s t a t u s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
testl $ _ T I F _ W O R K _ S Y S C A L L _ E N T R Y ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2005-09-12 20:49:24 +04:00
CFI_ R E M E M B E R _ S T A T E
2005-04-17 02:20:36 +04:00
jnz s y s e n t e r _ t r a c e s y s
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2006-04-07 21:50:31 +04:00
ja i a32 _ b a d s y s
2008-07-09 13:38:07 +04:00
sysenter_do_call :
2008-08-29 16:21:11 +04:00
IA3 2 _ A R G _ F I X U P
2008-06-24 12:13:31 +04:00
sysenter_dispatch :
2005-04-17 02:20:36 +04:00
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 )
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
2008-06-25 08:19:29 +04:00
DISABLE_ I N T E R R U P T S ( C L B R _ N O N E )
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O F F
2011-11-29 15:17:45 +04:00
testl $ _ T I F _ A L L W O R K _ M A S K ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2008-06-24 12:13:31 +04:00
jnz s y s e x i t _ a u d i t
sysexit_from_sys_call :
2011-11-29 15:17:45 +04:00
andl $ ~ T S _ C O M P A T ,T I _ s t a t u s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2005-04-17 02:20:36 +04:00
/* clear IF, that popfq doesn't enable interrupts early */
andl $ ~ 0 x20 0 ,E F L A G S - R 1 1 ( % r s p )
2008-01-30 15:30:43 +03:00
movl R I P - R 1 1 ( % r s p ) ,% e d x / * U s e r % e i p * /
CFI_ R E G I S T E R r i p ,r d x
2011-06-01 00:21:53 +04:00
RESTORE_ A R G S 0 ,2 4 ,0 ,0 ,0 ,0
2009-09-30 14:22:11 +04:00
xorq % r8 ,% r8
xorq % r9 ,% r9
xorq % r10 ,% r10
xorq % r11 ,% r11
2011-02-28 18:54:40 +03:00
popfq_ c f i
2005-09-12 20:49:24 +04:00
/*CFI_RESTORE rflags*/
2011-02-28 18:54:40 +03:00
popq_ c f i % r c x / * U s e r % e s p * /
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r s p ,r c x
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O N
2008-06-25 08:19:28 +04:00
ENABLE_ I N T E R R U P T S _ S Y S E X I T 3 2
2005-04-17 02:20:36 +04:00
2008-06-24 12:13:31 +04:00
# ifdef C O N F I G _ A U D I T S Y S C A L L
.macro auditsys_entry_common
movl % e s i ,% r9 d / * 6 t h a r g : 4 t h s y s c a l l a r g * /
movl % e d x ,% r8 d / * 5 t h a r g : 3 r d s y s c a l l a r g * /
/* (already in %ecx) 4th arg: 2nd syscall arg */
movl % e b x ,% e d x / * 3 r d a r g : 1 s t s y s c a l l a r g * /
movl % e a x ,% e s i / * 2 n d a r g : s y s c a l l n u m b e r * /
movl $ A U D I T _ A R C H _ I 3 8 6 ,% e d i / * 1 s t a r g : a u d i t a r c h * /
call a u d i t _ s y s c a l l _ e n t r y
movl R A X - A R G O F F S E T ( % r s p ) ,% e a x / * r e l o a d s y s c a l l n u m b e r * /
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2008-06-24 12:13:31 +04:00
ja i a32 _ b a d s y s
movl % e b x ,% e d i / * r e l o a d 1 s t s y s c a l l a r g * /
movl R C X - A R G O F F S E T ( % r s p ) ,% e s i / * r e l o a d 2 n d s y s c a l l a r g * /
movl R D X - A R G O F F S E T ( % r s p ) ,% e d x / * r e l o a d 3 r d s y s c a l l a r g * /
movl R S I - A R G O F F S E T ( % r s p ) ,% e c x / * r e l o a d 4 t h s y s c a l l a r g * /
movl R D I - A R G O F F S E T ( % r s p ) ,% r8 d / * r e l o a d 5 t h s y s c a l l a r g * /
.endm
2009-10-26 18:20:29 +03:00
.macro auditsys_exit exit
2011-11-29 15:17:45 +04:00
testl $ ( _ T I F _ A L L W O R K _ M A S K & ~ _ T I F _ S Y S C A L L _ A U D I T ) ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2009-09-30 14:22:11 +04:00
jnz i a32 _ r e t _ f r o m _ s y s _ c a l l
2008-06-24 12:13:31 +04:00
TRACE_ I R Q S _ O N
sti
movl % e a x ,% e s i / * s e c o n d a r g , s y s c a l l r e t u r n v a l u e * /
cmpl $ 0 ,% e a x / * i s i t < 0 ? * /
setl % a l / * 1 i f s o , 0 i f n o t * /
movzbl % a l ,% e d i / * z e r o - e x t e n d t h a t i n t o % e d i * /
inc % e d i / * f i r s t a r g , 0 - > 1 ( A U D I T S C _ S U C C E S S ) , 1 - > 2 ( A U D I T S C _ F A I L U R E ) * /
call a u d i t _ s y s c a l l _ e x i t
movl R A X - A R G O F F S E T ( % r s p ) ,% e a x / * r e l o a d s y s c a l l r e t u r n v a l u e * /
movl $ ( _ T I F _ A L L W O R K _ M A S K & ~ _ T I F _ S Y S C A L L _ A U D I T ) ,% e d i
cli
TRACE_ I R Q S _ O F F
2011-11-29 15:17:45 +04:00
testl % e d i ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2009-09-30 14:22:11 +04:00
jz \ e x i t
CLEAR_ R R E G S - A R G O F F S E T
jmp i n t _ w i t h _ c h e c k
2008-06-24 12:13:31 +04:00
.endm
sysenter_auditsys :
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E _ S T A T E
2008-06-24 12:13:31 +04:00
auditsys_ e n t r y _ c o m m o n
movl % e b p ,% r9 d / * r e l o a d 6 t h s y s c a l l a r g * /
jmp s y s e n t e r _ d i s p a t c h
sysexit_audit :
auditsys_ e x i t s y s e x i t _ f r o m _ s y s _ c a l l
# endif
sysenter_tracesys :
# ifdef C O N F I G _ A U D I T S Y S C A L L
2011-11-29 15:17:45 +04:00
testl $ ( _ T I F _ W O R K _ S Y S C A L L _ E N T R Y & ~ _ T I F _ S Y S C A L L _ A U D I T ) ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2008-06-24 12:13:31 +04:00
jz s y s e n t e r _ a u d i t s y s
# endif
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
CLEAR_ R R E G S
2008-03-19 04:23:50 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2007-09-21 18:16:18 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2008-03-19 04:23:50 +03:00
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * s y s e n t e r _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
2005-04-17 02:20:36 +04:00
jmp s y s e n t e r _ d o _ c a l l
CFI_ E N D P R O C
2006-06-26 15:56:55 +04:00
ENDPROC( i a32 _ s y s e n t e r _ t a r g e t )
2005-04-17 02:20:36 +04:00
/ *
* 3 2 bit S Y S C A L L i n s t r u c t i o n e n t r y .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx r e t u r n E I P
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp A r g 2 [ n o t e : n o t s a v e d i n t h e s t a c k f r a m e , s h o u l d n o t b e t o u c h e d ]
* % esp u s e r s t a c k
* 0 ( % esp) A r g 6
*
* Interrupts o f f .
*
* This i s p u r e l y a f a s t p a t h . F o r a n y t h i n g c o m p l i c a t e d w e u s e t h e i n t 0 x80
* path b e l o w . S e t u p a c o m p l e t e h a r d w a r e s t a c k f r a m e t o s h a r e c o d e
* with t h e i n t 0 x80 p a t h .
* /
ENTRY( i a32 _ c s t a r _ t a r g e t )
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2009-01-18 18:38:58 +03:00
CFI_ D E F _ C F A r s p ,K E R N E L _ S T A C K _ O F F S E T
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r c x
/*CFI_REGISTER rflags,r11*/
2008-06-26 18:28:51 +04:00
SWAPGS_ U N S A F E _ S T A C K
2005-04-17 02:20:36 +04:00
movl % e s p ,% r8 d
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r s p ,r8
2009-01-18 18:38:58 +03:00
movq P E R _ C P U _ V A R ( k e r n e l _ s t a c k ) ,% r s p
2006-07-03 11:24:45 +04:00
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s a n d h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2008-06-25 08:19:29 +04:00
ENABLE_ I N T E R R U P T S ( C L B R _ N O N E )
2011-06-01 00:21:52 +04:00
SAVE_ A R G S 8 ,0 ,0
2005-04-17 02:20:36 +04:00
movl % e a x ,% e a x / * z e r o e x t e n s i o n * /
movq % r a x ,O R I G _ R A X - A R G O F F S E T ( % r s p )
movq % r c x ,R I P - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r i p ,R I P - A R G O F F S E T
2005-04-17 02:20:36 +04:00
movq % r b p ,R C X - A R G O F F S E T ( % r s p ) / * t h i s l i e s s l i g h t l y t o p t r a c e * /
movl % e b p ,% e c x
movq $ _ _ U S E R 3 2 _ C S ,C S - A R G O F F S E T ( % r s p )
movq $ _ _ U S E R 3 2 _ D S ,S S - A R G O F F S E T ( % r s p )
movq % r11 ,E F L A G S - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
/*CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
2005-04-17 02:20:36 +04:00
movq % r8 ,R S P - A R G O F F S E T ( % r s p )
2005-09-12 20:49:24 +04:00
CFI_ R E L _ O F F S E T r s p ,R S P - A R G O F F S E T
2005-04-17 02:20:36 +04:00
/ * no n e e d t o d o a n a c c e s s _ o k c h e c k h e r e b e c a u s e r8 h a s b e e n
3 2 bit z e r o e x t e n d e d * /
/* hardware stack frame is complete now */
1 : movl ( % r8 ) ,% r9 d
.section _ _ ex_ t a b l e ," a "
.quad 1 b,i a32 _ b a d a r g
.previous
2011-11-29 15:17:45 +04:00
orl $ T S _ C O M P A T ,T I _ s t a t u s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
testl $ _ T I F _ W O R K _ S Y S C A L L _ E N T R Y ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2005-09-12 20:49:24 +04:00
CFI_ R E M E M B E R _ S T A T E
2005-04-17 02:20:36 +04:00
jnz c s t a r _ t r a c e s y s
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ I A 3 2 _ N R _ s y s c a l l s - 1 ,% r a x
2006-04-07 21:50:31 +04:00
ja i a32 _ b a d s y s
2008-08-29 16:21:11 +04:00
cstar_do_call :
2005-04-17 02:20:36 +04:00
IA3 2 _ A R G _ F I X U P 1
2008-06-24 12:13:31 +04:00
cstar_dispatch :
2005-04-17 02:20:36 +04:00
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 )
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
2008-06-25 08:19:29 +04:00
DISABLE_ I N T E R R U P T S ( C L B R _ N O N E )
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O F F
2011-11-29 15:17:45 +04:00
testl $ _ T I F _ A L L W O R K _ M A S K ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2008-06-24 12:13:31 +04:00
jnz s y s r e t l _ a u d i t
sysretl_from_sys_call :
2011-11-29 15:17:45 +04:00
andl $ ~ T S _ C O M P A T ,T I _ s t a t u s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2011-06-01 00:21:53 +04:00
RESTORE_ A R G S 0 ,- A R G _ S K I P ,0 ,0 ,0
2005-04-17 02:20:36 +04:00
movl R I P - A R G O F F S E T ( % r s p ) ,% e c x
2005-09-12 20:49:24 +04:00
CFI_ R E G I S T E R r i p ,r c x
2005-04-17 02:20:36 +04:00
movl E F L A G S - A R G O F F S E T ( % r s p ) ,% r11 d
2005-09-12 20:49:24 +04:00
/*CFI_REGISTER rflags,r11*/
2009-09-30 14:22:11 +04:00
xorq % r10 ,% r10
xorq % r9 ,% r9
xorq % r8 ,% r8
2006-07-03 11:24:45 +04:00
TRACE_ I R Q S _ O N
2005-04-17 02:20:36 +04:00
movl R S P - A R G O F F S E T ( % r s p ) ,% e s p
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E r s p
2008-06-25 08:19:28 +04:00
USERGS_ S Y S R E T 3 2
2005-04-17 02:20:36 +04:00
2008-06-24 12:13:31 +04:00
# ifdef C O N F I G _ A U D I T S Y S C A L L
cstar_auditsys :
2005-09-12 20:49:24 +04:00
CFI_ R E S T O R E _ S T A T E
2008-06-24 12:13:31 +04:00
movl % r9 d ,R 9 - A R G O F F S E T ( % r s p ) / * r e g i s t e r t o b e c l o b b e r e d b y c a l l * /
auditsys_ e n t r y _ c o m m o n
movl R 9 - A R G O F F S E T ( % r s p ) ,% r9 d / * r e l o a d 6 t h s y s c a l l a r g * /
jmp c s t a r _ d i s p a t c h
sysretl_audit :
2009-10-26 18:20:29 +03:00
auditsys_ e x i t s y s r e t l _ f r o m _ s y s _ c a l l
2008-06-24 12:13:31 +04:00
# endif
cstar_tracesys :
# ifdef C O N F I G _ A U D I T S Y S C A L L
2011-11-29 15:17:45 +04:00
testl $ ( _ T I F _ W O R K _ S Y S C A L L _ E N T R Y & ~ _ T I F _ S Y S C A L L _ A U D I T ) ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2008-06-24 12:13:31 +04:00
jz c s t a r _ a u d i t s y s
# endif
2007-11-07 18:48:39 +03:00
xchgl % r9 d ,% e b p
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
2009-09-30 14:22:11 +04:00
CLEAR_ R R E G S 0 , r9
2008-03-19 04:23:50 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2008-08-29 16:21:11 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T , 1 / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
2007-11-07 18:48:39 +03:00
xchgl % e b p ,% r9 d
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2008-03-19 04:23:50 +03:00
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * c s t a r _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
2005-04-17 02:20:36 +04:00
jmp c s t a r _ d o _ c a l l
2006-06-26 15:56:55 +04:00
END( i a32 _ c s t a r _ t a r g e t )
2005-04-17 02:20:36 +04:00
ia32_badarg :
movq $ - E F A U L T ,% r a x
jmp i a32 _ s y s r e t
CFI_ E N D P R O C
/ *
* Emulated I A 3 2 s y s t e m c a l l s v i a i n t 0 x80 .
*
* Arguments :
* % eax S y s t e m c a l l n u m b e r .
* % ebx A r g 1
* % ecx A r g 2
* % edx A r g 3
* % esi A r g 4
* % edi A r g 5
* % ebp A r g 6 [ n o t e : n o t s a v e d i n t h e s t a c k f r a m e , s h o u l d n o t b e t o u c h e d ]
*
* Notes :
* Uses t h e s a m e s t a c k f r a m e a s t h e x86 - 6 4 v e r s i o n .
* All r e g i s t e r s e x c e p t % e a x m u s t b e s a v e d ( b u t p t r a c e m a y v i o l a t e t h a t )
* Arguments a r e z e r o e x t e n d e d . F o r s y s t e m c a l l s t h a t w a n t s i g n e x t e n s i o n a n d
* take l o n g a r g u m e n t s a w r a p p e r i s n e e d e d . M o s t c a l l s c a n j u s t b e c a l l e d
* directly.
* Assumes i t i s o n l y c a l l e d f r o m u s e r s p a c e a n d e n t e r e d w i t h i n t e r r u p t s o f f .
* /
ENTRY( i a32 _ s y s c a l l )
2007-07-21 19:10:20 +04:00
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2005-09-12 20:49:24 +04:00
CFI_ D E F _ C F A r s p ,S S + 8 - R I P
/*CFI_REL_OFFSET ss,SS-RIP*/
CFI_ R E L _ O F F S E T r s p ,R S P - R I P
/*CFI_REL_OFFSET rflags,EFLAGS-RIP*/
/*CFI_REL_OFFSET cs,CS-RIP*/
CFI_ R E L _ O F F S E T r i p ,R I P - R I P
2008-07-09 02:06:28 +04:00
PARAVIRT_ A D J U S T _ E X C E P T I O N _ F R A M E
2008-06-25 08:19:29 +04:00
SWAPGS
2006-07-03 11:24:45 +04:00
/ *
* No n e e d t o f o l l o w t h i s i r q s o n / o f f s e c t i o n : t h e s y s c a l l
* disabled i r q s a n d h e r e w e e n a b l e i t s t r a i g h t a f t e r e n t r y :
* /
2008-06-25 08:19:29 +04:00
ENABLE_ I N T E R R U P T S ( C L B R _ N O N E )
2005-04-17 02:20:36 +04:00
movl % e a x ,% e a x
2011-02-28 18:54:40 +03:00
pushq_ c f i % r a x
2005-04-17 02:20:36 +04:00
cld
/ * note t h e r e g i s t e r s a r e n o t z e r o e x t e n d e d t o t h e s f .
this c o u l d b e a p r o b l e m . * /
2011-06-01 00:21:52 +04:00
SAVE_ A R G S 0 ,1 ,0
2011-11-29 15:17:45 +04:00
orl $ T S _ C O M P A T ,T I _ s t a t u s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
testl $ _ T I F _ W O R K _ S Y S C A L L _ E N T R Y ,T I _ f l a g s + T H R E A D _ I N F O ( % r s p ,R I P - A R G O F F S E T )
2005-04-17 02:20:36 +04:00
jnz i a32 _ t r a c e s y s
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2009-02-07 05:15:18 +03:00
ja i a32 _ b a d s y s
ia32_do_call :
2005-04-17 02:20:36 +04:00
IA3 2 _ A R G _ F I X U P
call * i a32 _ s y s _ c a l l _ t a b l e ( ,% r a x ,8 ) # x x x : r i p r e l a t i v e
ia32_sysret :
movq % r a x ,R A X - A R G O F F S E T ( % r s p )
2009-09-30 14:22:11 +04:00
ia32_ret_from_sys_call :
CLEAR_ R R E G S - A R G O F F S E T
2005-04-17 02:20:36 +04:00
jmp i n t _ r e t _ f r o m _ s y s _ c a l l
ia32_tracesys :
SAVE_ R E S T
2007-07-21 19:10:20 +04:00
CLEAR_ R R E G S
2008-03-17 07:57:41 +03:00
movq $ - E N O S Y S ,R A X ( % r s p ) / * p t r a c e c a n c h a n g e t h i s f o r a b a d s y s c a l l * /
2005-04-17 02:20:36 +04:00
movq % r s p ,% r d i / * & p t _ r e g s - > a r g 1 * /
call s y s c a l l _ t r a c e _ e n t e r
2007-09-21 18:16:18 +04:00
LOAD_ A R G S 3 2 A R G O F F S E T / * r e l o a d a r g s f r o m s t a c k i n c a s e p t r a c e c h a n g e d i t * /
2005-04-17 02:20:36 +04:00
RESTORE_ R E S T
x86-64, compat: Test %rax for the syscall number, not %eax
On 64 bits, we always, by necessity, jump through the system call
table via %rax. For 32-bit system calls, in theory the system call
number is stored in %eax, and the code was testing %eax for a valid
system call number. At one point we loaded the stored value back from
the stack to enforce zero-extension, but that was removed in checkin
d4d67150165df8bf1cc05e532f6efca96f907cab. An actual 32-bit process
will not be able to introduce a non-zero-extended number, but it can
happen via ptrace.
Instead of re-introducing the zero-extension, test what we are
actually going to use, i.e. %rax. This only adds a handful of REX
prefixes to the code.
Reported-by: Ben Hawkes <hawkes@sota.gen.nz>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Cc: <stable@kernel.org>
Cc: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
2010-09-14 23:42:41 +04:00
cmpq $ ( I A 3 2 _ N R _ s y s c a l l s - 1 ) ,% r a x
2009-02-07 05:15:18 +03:00
ja i n t _ r e t _ f r o m _ s y s _ c a l l / * i a32 _ t r a c e s y s h a s s e t R A X ( % r s p ) * /
jmp i a32 _ d o _ c a l l
2006-06-26 15:56:55 +04:00
END( i a32 _ s y s c a l l )
2005-04-17 02:20:36 +04:00
ia32_badsys :
movq $ 0 ,O R I G _ R A X - A R G O F F S E T ( % r s p )
2009-09-30 14:22:11 +04:00
movq $ - E N O S Y S ,% r a x
jmp i a32 _ s y s r e t
2005-04-17 02:20:36 +04:00
quiet_ni_syscall :
movq $ - E N O S Y S ,% r a x
ret
CFI_ E N D P R O C
.macro PTREGSCALL label, f u n c , a r g
2011-11-29 15:24:10 +04:00
ALIGN
GLOBAL( \ l a b e l )
2005-04-17 02:20:36 +04:00
leaq \ f u n c ( % r i p ) ,% r a x
leaq - A R G O F F S E T + 8 ( % r s p ) ,\ a r g / * 8 f o r r e t u r n a d d r e s s * /
jmp i a32 _ p t r e g s _ c o m m o n
.endm
2006-01-12 00:41:59 +03:00
CFI_ S T A R T P R O C 3 2
2005-09-12 20:49:24 +04:00
2005-04-17 02:20:36 +04:00
PTREGSCALL s t u b32 _ r t _ s i g r e t u r n , s y s32 _ r t _ s i g r e t u r n , % r d i
PTREGSCALL s t u b32 _ s i g r e t u r n , s y s32 _ s i g r e t u r n , % r d i
PTREGSCALL s t u b32 _ s i g a l t s t a c k , s y s32 _ s i g a l t s t a c k , % r d x
PTREGSCALL s t u b32 _ e x e c v e , s y s32 _ e x e c v e , % r c x
PTREGSCALL s t u b32 _ f o r k , s y s _ f o r k , % r d i
PTREGSCALL s t u b32 _ c l o n e , s y s32 _ c l o n e , % r d x
PTREGSCALL s t u b32 _ v f o r k , s y s _ v f o r k , % r d i
PTREGSCALL s t u b32 _ i o p l , s y s _ i o p l , % r s i
2011-11-29 15:24:10 +04:00
ALIGN
ia32_ptregs_common :
2005-04-17 02:20:36 +04:00
popq % r11
2006-01-12 00:41:59 +03:00
CFI_ E N D P R O C
CFI_ S T A R T P R O C 3 2 s i m p l e
2006-09-26 12:52:41 +04:00
CFI_ S I G N A L _ F R A M E
2006-01-12 00:41:59 +03:00
CFI_ D E F _ C F A r s p ,S S + 8 - A R G O F F S E T
CFI_ R E L _ O F F S E T r a x ,R A X - A R G O F F S E T
CFI_ R E L _ O F F S E T r c x ,R C X - A R G O F F S E T
CFI_ R E L _ O F F S E T r d x ,R D X - A R G O F F S E T
CFI_ R E L _ O F F S E T r s i ,R S I - A R G O F F S E T
CFI_ R E L _ O F F S E T r d i ,R D I - A R G O F F S E T
CFI_ R E L _ O F F S E T r i p ,R I P - A R G O F F S E T
/* CFI_REL_OFFSET cs,CS-ARGOFFSET*/
/* CFI_REL_OFFSET rflags,EFLAGS-ARGOFFSET*/
CFI_ R E L _ O F F S E T r s p ,R S P - A R G O F F S E T
/* CFI_REL_OFFSET ss,SS-ARGOFFSET*/
2005-04-17 02:20:36 +04:00
SAVE_ R E S T
call * % r a x
RESTORE_ R E S T
jmp i a32 _ s y s r e t / * m i s b a l a n c e s t h e r e t u r n c a c h e * /
CFI_ E N D P R O C
2006-06-26 15:56:55 +04:00
END( i a32 _ p t r e g s _ c o m m o n )
2005-04-17 02:20:36 +04:00
2006-01-06 11:12:05 +03:00
.section .rodata , " a"
2005-04-17 02:20:36 +04:00
.align 8
ia32_sys_call_table :
.quad sys_restart_syscall
.quad sys_exit
.quad stub32_fork
.quad sys_read
.quad sys_write
2005-09-07 02:18:25 +04:00
.quad compat_sys_open /* 5 */
2005-04-17 02:20:36 +04:00
.quad sys_close
.quad sys32_waitpid
.quad sys_creat
.quad sys_link
.quad sys_unlink /* 10 */
.quad stub32_execve
.quad sys_chdir
.quad compat_sys_time
.quad sys_mknod
.quad sys_chmod /* 15 */
.quad sys_lchown16
.quad quiet_ni_syscall /* old break syscall holder */
.quad sys_stat
.quad sys32_lseek
.quad sys_getpid /* 20 */
.quad compat_sys_mount /* mount */
.quad sys_oldumount /* old_umount */
.quad sys_setuid16
.quad sys_getuid16
.quad compat_sys_stime /* stime */ /* 25 */
2008-04-22 23:21:25 +04:00
.quad compat_sys_ptrace /* ptrace */
2005-04-17 02:20:36 +04:00
.quad sys_alarm
.quad sys_fstat /* (old)fstat */
.quad sys_pause
.quad compat_sys_utime /* 30 */
.quad quiet_ni_syscall /* old stty syscall holder */
.quad quiet_ni_syscall /* old gtty syscall holder */
.quad sys_access
.quad sys_nice
.quad quiet_ni_syscall /* 35 */ /* old ftime syscall holder */
.quad sys_sync
.quad sys32_kill
.quad sys_rename
.quad sys_mkdir
.quad sys_rmdir /* 40 */
.quad sys_dup
2009-08-07 02:58:12 +04:00
.quad sys_pipe
2005-04-17 02:20:36 +04:00
.quad compat_sys_times
.quad quiet_ni_syscall /* old prof syscall holder */
.quad sys_brk /* 45 */
.quad sys_setgid16
.quad sys_getgid16
.quad sys_signal
.quad sys_geteuid16
.quad sys_getegid16 /* 50 */
.quad sys_acct
.quad sys_umount /* new_umount */
.quad quiet_ni_syscall /* old lock syscall holder */
.quad compat_sys_ioctl
.quad compat_sys_fcntl64 /* 55 */
.quad quiet_ni_syscall /* old mpx syscall holder */
.quad sys_setpgid
.quad quiet_ni_syscall /* old ulimit syscall holder */
2010-03-11 02:21:21 +03:00
.quad sys_olduname
2005-04-17 02:20:36 +04:00
.quad sys_umask /* 60 */
.quad sys_chroot
2008-11-28 12:09:09 +03:00
.quad compat_sys_ustat
2005-04-17 02:20:36 +04:00
.quad sys_dup2
.quad sys_getppid
.quad sys_getpgrp /* 65 */
.quad sys_setsid
.quad sys32_sigaction
.quad sys_sgetmask
.quad sys_ssetmask
.quad sys_setreuid16 /* 70 */
.quad sys_setregid16
2008-06-18 15:42:11 +04:00
.quad sys32_sigsuspend
2005-04-17 02:20:36 +04:00
.quad compat_sys_sigpending
.quad sys_sethostname
.quad compat_sys_setrlimit /* 75 */
.quad compat_sys_old_getrlimit /* old_getrlimit */
.quad compat_sys_getrusage
2008-10-16 09:02:06 +04:00
.quad compat_sys_gettimeofday
.quad compat_sys_settimeofday
2005-04-17 02:20:36 +04:00
.quad sys_getgroups16 /* 80 */
.quad sys_setgroups16
2010-03-11 02:21:13 +03:00
.quad compat_sys_old_select
2005-04-17 02:20:36 +04:00
.quad sys_symlink
.quad sys_lstat
.quad sys_readlink /* 85 */
.quad sys_uselib
.quad sys_swapon
.quad sys_reboot
.quad compat_sys_old_readdir
.quad sys32_mmap /* 90 */
.quad sys_munmap
.quad sys_truncate
.quad sys_ftruncate
.quad sys_fchmod
.quad sys_fchown16 /* 95 */
.quad sys_getpriority
.quad sys_setpriority
.quad quiet_ni_syscall /* old profil syscall holder */
.quad compat_sys_statfs
.quad compat_sys_fstatfs /* 100 */
.quad sys_ioperm
.quad compat_sys_socketcall
.quad sys_syslog
.quad compat_sys_setitimer
.quad compat_sys_getitimer /* 105 */
.quad compat_sys_newstat
.quad compat_sys_newlstat
.quad compat_sys_newfstat
2010-03-11 02:21:21 +03:00
.quad sys_uname
2005-04-17 02:20:36 +04:00
.quad stub32_iopl /* 110 */
.quad sys_vhangup
.quad quiet_ni_syscall /* old "idle" system call */
.quad sys32_vm86_warning /* vm86old */
.quad compat_sys_wait4
.quad sys_swapoff /* 115 */
2007-02-10 12:46:00 +03:00
.quad compat_sys_sysinfo
2005-04-17 02:20:36 +04:00
.quad sys32_ipc
.quad sys_fsync
.quad stub32_sigreturn
.quad stub32_clone /* 120 */
.quad sys_setdomainname
2010-04-20 07:31:02 +04:00
.quad sys_newuname
2005-04-17 02:20:36 +04:00
.quad sys_modify_ldt
2006-03-26 13:37:29 +04:00
.quad compat_sys_adjtimex
2005-04-17 02:20:36 +04:00
.quad sys32_mprotect /* 125 */
.quad compat_sys_sigprocmask
.quad quiet_ni_syscall /* create_module */
.quad sys_init_module
.quad sys_delete_module
.quad quiet_ni_syscall /* 130 get_kernel_syms */
2007-07-16 10:41:12 +04:00
.quad sys32_quotactl
2005-04-17 02:20:36 +04:00
.quad sys_getpgid
.quad sys_fchdir
.quad quiet_ni_syscall /* bdflush */
.quad sys_sysfs /* 135 */
.quad sys_personality
.quad quiet_ni_syscall /* for afs_syscall */
.quad sys_setfsuid16
.quad sys_setfsgid16
.quad sys_llseek /* 140 */
.quad compat_sys_getdents
.quad compat_sys_select
.quad sys_flock
.quad sys_msync
.quad compat_sys_readv /* 145 */
.quad compat_sys_writev
.quad sys_getsid
.quad sys_fdatasync
2009-04-03 11:59:52 +04:00
.quad compat_sys_sysctl /* sysctl */
2005-04-17 02:20:36 +04:00
.quad sys_mlock /* 150 */
.quad sys_munlock
.quad sys_mlockall
.quad sys_munlockall
.quad sys_sched_setparam
.quad sys_sched_getparam /* 155 */
.quad sys_sched_setscheduler
.quad sys_sched_getscheduler
.quad sys_sched_yield
.quad sys_sched_get_priority_max
.quad sys_sched_get_priority_min /* 160 */
2007-03-16 23:07:36 +03:00
.quad sys32_sched_rr_get_interval
2005-04-17 02:20:36 +04:00
.quad compat_sys_nanosleep
.quad sys_mremap
.quad sys_setresuid16
.quad sys_getresuid16 /* 165 */
.quad sys32_vm86_warning /* vm86 */
.quad quiet_ni_syscall /* query_module */
.quad sys_poll
2011-08-27 02:03:11 +04:00
.quad quiet_ni_syscall /* old nfsservctl */
2005-04-17 02:20:36 +04:00
.quad sys_setresgid16 /* 170 */
.quad sys_getresgid16
.quad sys_prctl
.quad stub32_rt_sigreturn
.quad sys32_rt_sigaction
.quad sys32_rt_sigprocmask /* 175 */
.quad sys32_rt_sigpending
.quad compat_sys_rt_sigtimedwait
.quad sys32_rt_sigqueueinfo
2008-06-18 15:42:11 +04:00
.quad sys_rt_sigsuspend
2005-04-17 02:20:36 +04:00
.quad sys32_pread /* 180 */
.quad sys32_pwrite
.quad sys_chown16
.quad sys_getcwd
.quad sys_capget
.quad sys_capset
.quad stub32_sigaltstack
.quad sys32_sendfile
.quad quiet_ni_syscall /* streams1 */
.quad quiet_ni_syscall /* streams2 */
.quad stub32_vfork /* 190 */
.quad compat_sys_getrlimit
2009-12-01 01:37:04 +03:00
.quad sys_mmap_pgoff
2005-04-17 02:20:36 +04:00
.quad sys32_truncate64
.quad sys32_ftruncate64
.quad sys32_stat64 /* 195 */
.quad sys32_lstat64
.quad sys32_fstat64
.quad sys_lchown
.quad sys_getuid
.quad sys_getgid /* 200 */
.quad sys_geteuid
.quad sys_getegid
.quad sys_setreuid
.quad sys_setregid
.quad sys_getgroups /* 205 */
.quad sys_setgroups
.quad sys_fchown
.quad sys_setresuid
.quad sys_getresuid
.quad sys_setresgid /* 210 */
.quad sys_getresgid
.quad sys_chown
.quad sys_setuid
.quad sys_setgid
.quad sys_setfsuid /* 215 */
.quad sys_setfsgid
.quad sys_pivot_root
.quad sys_mincore
.quad sys_madvise
.quad compat_sys_getdents64 /* 220 getdents64 */
.quad compat_sys_fcntl64
.quad quiet_ni_syscall /* tux */
.quad quiet_ni_syscall /* security */
.quad sys_gettid
2007-06-20 14:23:30 +04:00
.quad sys32_readahead /* 225 */
2005-04-17 02:20:36 +04:00
.quad sys_setxattr
.quad sys_lsetxattr
.quad sys_fsetxattr
.quad sys_getxattr
.quad sys_lgetxattr /* 230 */
.quad sys_fgetxattr
.quad sys_listxattr
.quad sys_llistxattr
.quad sys_flistxattr
.quad sys_removexattr /* 235 */
.quad sys_lremovexattr
.quad sys_fremovexattr
.quad sys_tkill
.quad sys_sendfile64
.quad compat_sys_futex /* 240 */
.quad compat_sys_sched_setaffinity
.quad compat_sys_sched_getaffinity
2008-01-30 15:30:46 +03:00
.quad sys_set_thread_area
.quad sys_get_thread_area
2005-04-17 02:20:36 +04:00
.quad compat_sys_io_setup /* 245 */
.quad sys_io_destroy
.quad compat_sys_io_getevents
.quad compat_sys_io_submit
.quad sys_io_cancel
2007-06-20 14:23:30 +04:00
.quad sys32_fadvise64 /* 250 */
2005-04-17 02:20:36 +04:00
.quad quiet_ni_syscall /* free_huge_pages */
.quad sys_exit_group
.quad sys32_lookup_dcookie
.quad sys_epoll_create
.quad sys_epoll_ctl /* 255 */
.quad sys_epoll_wait
.quad sys_remap_file_pages
.quad sys_set_tid_address
2006-01-10 07:52:08 +03:00
.quad compat_sys_timer_create
2005-04-17 02:20:36 +04:00
.quad compat_sys_timer_settime /* 260 */
.quad compat_sys_timer_gettime
.quad sys_timer_getoverrun
.quad sys_timer_delete
.quad compat_sys_clock_settime
.quad compat_sys_clock_gettime /* 265 */
.quad compat_sys_clock_getres
.quad compat_sys_clock_nanosleep
.quad compat_sys_statfs64
.quad compat_sys_fstatfs64
.quad sys_tgkill /* 270 */
.quad compat_sys_utimes
.quad sys32_fadvise64_64
.quad quiet_ni_syscall /* sys_vserver */
.quad sys_mbind
.quad compat_sys_get_mempolicy /* 275 */
.quad sys_set_mempolicy
.quad compat_sys_mq_open
.quad sys_mq_unlink
.quad compat_sys_mq_timedsend
.quad compat_sys_mq_timedreceive /* 280 */
.quad compat_sys_mq_notify
.quad compat_sys_mq_getsetattr
2005-06-26 01:58:02 +04:00
.quad compat_sys_kexec_load /* reserved for kexec */
2005-04-17 02:20:36 +04:00
.quad compat_sys_waitid
2005-07-25 23:19:29 +04:00
.quad quiet_ni_syscall /* 285: sys_altroot */
2005-04-17 02:20:36 +04:00
.quad sys_add_key
.quad sys_request_key
.quad sys_keyctl
2005-07-25 23:19:29 +04:00
.quad sys_ioprio_set
.quad sys_ioprio_get /* 290 */
.quad sys_inotify_init
.quad sys_inotify_add_watch
.quad sys_inotify_rm_watch
2006-01-08 12:00:51 +03:00
.quad sys_migrate_pages
2006-01-19 04:43:56 +03:00
.quad compat_sys_openat /* 295 */
.quad sys_mkdirat
.quad sys_mknodat
.quad sys_fchownat
2006-02-01 14:04:32 +03:00
.quad compat_sys_futimesat
2006-02-12 04:55:47 +03:00
.quad sys32_fstatat /* 300 */
2006-01-19 04:43:56 +03:00
.quad sys_unlinkat
.quad sys_renameat
.quad sys_linkat
.quad sys_symlinkat
.quad sys_readlinkat /* 305 */
.quad sys_fchmodat
.quad sys_faccessat
2006-09-26 12:52:27 +04:00
.quad compat_sys_pselect6
.quad compat_sys_ppoll
2006-02-09 02:35:50 +03:00
.quad sys_unshare /* 310 */
2006-03-27 13:16:26 +04:00
.quad compat_sys_set_robust_list
.quad compat_sys_get_robust_list
2006-04-07 21:50:34 +04:00
.quad sys_splice
2007-06-20 14:23:30 +04:00
.quad sys32_sync_file_range
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:33:25 +04:00
.quad sys_tee /* 315 */
2006-05-01 23:15:48 +04:00
.quad compat_sys_vmsplice
2006-06-23 13:03:56 +04:00
.quad compat_sys_move_pages
2006-09-26 12:52:28 +04:00
.quad sys_getcpu
2007-02-13 15:26:26 +03:00
.quad sys_epoll_pwait
utimensat implementation
Implement utimensat(2) which is an extension to futimesat(2) in that it
a) supports nano-second resolution for the timestamps
b) allows to selectively ignore the atime/mtime value
c) allows to selectively use the current time for either atime or mtime
d) supports changing the atime/mtime of a symlink itself along the lines
of the BSD lutimes(3) functions
For this change the internally used do_utimes() functions was changed to
accept a timespec time value and an additional flags parameter.
Additionally the sys_utime function was changed to match compat_sys_utime
which already use do_utimes instead of duplicating the work.
Also, the completely missing futimensat() functionality is added. We have
such a function in glibc but we have to resort to using /proc/self/fd/* which
not everybody likes (chroot etc).
Test application (the syscall number will need per-arch editing):
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/time.h>
#include <stddef.h>
#include <syscall.h>
#define __NR_utimensat 280
#define UTIME_NOW ((1l << 30) - 1l)
#define UTIME_OMIT ((1l << 30) - 2l)
int
main(void)
{
int status = 0;
int fd = open("ttt", O_RDWR|O_CREAT|O_EXCL, 0666);
if (fd == -1)
error (1, errno, "failed to create test file \"ttt\"");
struct stat64 st1;
if (fstat64 (fd, &st1) != 0)
error (1, errno, "fstat failed");
struct timespec t[2];
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
struct stat64 st2;
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0] = st1.st_atim;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_OMIT;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("atim not set");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim changed from zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_OMIT;
t[1] = st1.st_mtim;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != st1.st_atim.tv_sec
|| st2.st_atim.tv_nsec != st1.st_atim.tv_nsec)
{
puts ("mtim changed from original time");
status = 1;
}
if (st2.st_mtim.tv_sec != st1.st_mtim.tv_sec
|| st2.st_mtim.tv_nsec != st1.st_mtim.tv_nsec)
{
puts ("mtim not set");
status = 1;
}
if (status != 0)
goto out;
sleep (2);
t[0].tv_sec = 0;
t[0].tv_nsec = UTIME_NOW;
t[1].tv_sec = 0;
t[1].tv_nsec = UTIME_NOW;
if (syscall(__NR_utimensat, AT_FDCWD, "ttt", t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
struct timeval tv;
gettimeofday(&tv,NULL);
if (st2.st_atim.tv_sec <= st1.st_atim.tv_sec
|| st2.st_atim.tv_sec > tv.tv_sec)
{
puts ("atim not set to NOW");
status = 1;
}
if (st2.st_mtim.tv_sec <= st1.st_mtim.tv_sec
|| st2.st_mtim.tv_sec > tv.tv_sec)
{
puts ("mtim not set to NOW");
status = 1;
}
if (symlink ("ttt", "tttsym") != 0)
error (1, errno, "cannot create symlink");
t[0].tv_sec = 0;
t[0].tv_nsec = 0;
t[1].tv_sec = 0;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, AT_FDCWD, "tttsym", t, AT_SYMLINK_NOFOLLOW) != 0)
error (1, errno, "utimensat failed");
if (lstat64 ("tttsym", &st2) != 0)
error (1, errno, "lstat failed");
if (st2.st_atim.tv_sec != 0 || st2.st_atim.tv_nsec != 0)
{
puts ("symlink atim not reset to zero");
status = 1;
}
if (st2.st_mtim.tv_sec != 0 || st2.st_mtim.tv_nsec != 0)
{
puts ("symlink mtim not reset to zero");
status = 1;
}
if (status != 0)
goto out;
t[0].tv_sec = 1;
t[0].tv_nsec = 0;
t[1].tv_sec = 1;
t[1].tv_nsec = 0;
if (syscall(__NR_utimensat, fd, NULL, t, 0) != 0)
error (1, errno, "utimensat failed");
if (fstat64 (fd, &st2) != 0)
error (1, errno, "fstat failed");
if (st2.st_atim.tv_sec != 1 || st2.st_atim.tv_nsec != 0)
{
puts ("atim not reset to one");
status = 1;
}
if (st2.st_mtim.tv_sec != 1 || st2.st_mtim.tv_nsec != 0)
{
puts ("mtim not reset to one");
status = 1;
}
if (status == 0)
puts ("all OK");
out:
close (fd);
unlink ("ttt");
unlink ("tttsym");
return status;
}
[akpm@linux-foundation.org: add missing i386 syscall table entry]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Alexey Dobriyan <adobriyan@openvz.org>
Cc: Michael Kerrisk <mtk-manpages@gmx.net>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-05-08 11:33:25 +04:00
.quad compat_sys_utimensat /* 320 */
2007-05-12 19:27:41 +04:00
.quad compat_sys_signalfd
2008-02-05 09:27:28 +03:00
.quad sys_timerfd_create
2007-05-11 09:23:20 +04:00
.quad sys_eventfd
sys_fallocate() implementation on i386, x86_64 and powerpc
fallocate() is a new system call being proposed here which will allow
applications to preallocate space to any file(s) in a file system.
Each file system implementation that wants to use this feature will need
to support an inode operation called ->fallocate().
Applications can use this feature to avoid fragmentation to certain
level and thus get faster access speed. With preallocation, applications
also get a guarantee of space for particular file(s) - even if later the
the system becomes full.
Currently, glibc provides an interface called posix_fallocate() which
can be used for similar cause. Though this has the advantage of working
on all file systems, but it is quite slow (since it writes zeroes to
each block that has to be preallocated). Without a doubt, file systems
can do this more efficiently within the kernel, by implementing
the proposed fallocate() system call. It is expected that
posix_fallocate() will be modified to call this new system call first
and incase the kernel/filesystem does not implement it, it should fall
back to the current implementation of writing zeroes to the new blocks.
ToDos:
1. Implementation on other architectures (other than i386, x86_64,
and ppc). Patches for s390(x) and ia64 are already available from
previous posts, but it was decided that they should be added later
once fallocate is in the mainline. Hence not including those patches
in this take.
2. Changes to glibc,
a) to support fallocate() system call
b) to make posix_fallocate() and posix_fallocate64() call fallocate()
Signed-off-by: Amit Arora <aarora@in.ibm.com>
2007-07-18 05:42:44 +04:00
.quad sys32_fallocate
2008-02-05 09:27:28 +03:00
.quad compat_sys_timerfd_settime /* 325 */
.quad compat_sys_timerfd_gettime
flag parameters: signalfd
This patch adds the new signalfd4 syscall. It extends the old signalfd
syscall by one parameter which is meant to hold a flag value. In this
patch the only flag support is SFD_CLOEXEC which causes the close-on-exec
flag for the returned file descriptor to be set.
A new name SFD_CLOEXEC is introduced which in this implementation must
have the same value as O_CLOEXEC.
The following test must be adjusted for architectures other than x86 and
x86-64 and in case the syscall numbers changed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/syscall.h>
#ifndef __NR_signalfd4
# ifdef __x86_64__
# define __NR_signalfd4 289
# elif defined __i386__
# define __NR_signalfd4 327
# else
# error "need __NR_signalfd4"
# endif
#endif
#define SFD_CLOEXEC O_CLOEXEC
int
main (void)
{
sigset_t ss;
sigemptyset (&ss);
sigaddset (&ss, SIGUSR1);
int fd = syscall (__NR_signalfd4, -1, &ss, 8, 0);
if (fd == -1)
{
puts ("signalfd4(0) failed");
return 1;
}
int coe = fcntl (fd, F_GETFD);
if (coe == -1)
{
puts ("fcntl failed");
return 1;
}
if (coe & FD_CLOEXEC)
{
puts ("signalfd4(0) set close-on-exec flag");
return 1;
}
close (fd);
fd = syscall (__NR_signalfd4, -1, &ss, 8, SFD_CLOEXEC);
if (fd == -1)
{
puts ("signalfd4(SFD_CLOEXEC) failed");
return 1;
}
coe = fcntl (fd, F_GETFD);
if (coe == -1)
{
puts ("fcntl failed");
return 1;
}
if ((coe & FD_CLOEXEC) == 0)
{
puts ("signalfd4(SFD_CLOEXEC) does not set close-on-exec flag");
return 1;
}
close (fd);
puts ("OK");
return 0;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[akpm@linux-foundation.org: add sys_ni stub]
Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Acked-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2008-07-24 08:29:24 +04:00
.quad compat_sys_signalfd4
2008-07-24 08:29:25 +04:00
.quad sys_eventfd2
2008-07-24 08:29:43 +04:00
.quad sys_epoll_create1
2008-12-03 12:39:53 +03:00
.quad sys_dup3 /* 330 */
2008-07-24 08:29:30 +04:00
.quad sys_pipe2
2008-07-24 08:29:32 +04:00
.quad sys_inotify_init1
2009-04-03 03:59:23 +04:00
.quad compat_sys_preadv
.quad compat_sys_pwritev
2009-04-05 01:01:10 +04:00
.quad compat_sys_rt_tgsigqueueinfo /* 335 */
perf: Do the big rename: Performance Counters -> Performance Events
Bye-bye Performance Counters, welcome Performance Events!
In the past few months the perfcounters subsystem has grown out its
initial role of counting hardware events, and has become (and is
becoming) a much broader generic event enumeration, reporting, logging,
monitoring, analysis facility.
Naming its core object 'perf_counter' and naming the subsystem
'perfcounters' has become more and more of a misnomer. With pending
code like hw-breakpoints support the 'counter' name is less and
less appropriate.
All in one, we've decided to rename the subsystem to 'performance
events' and to propagate this rename through all fields, variables
and API names. (in an ABI compatible fashion)
The word 'event' is also a bit shorter than 'counter' - which makes
it slightly more convenient to write/handle as well.
Thanks goes to Stephane Eranian who first observed this misnomer and
suggested a rename.
User-space tooling and ABI compatibility is not affected - this patch
should be function-invariant. (Also, defconfigs were not touched to
keep the size down.)
This patch has been generated via the following script:
FILES=$(find * -type f | grep -vE 'oprofile|[^K]config')
sed -i \
-e 's/PERF_EVENT_/PERF_RECORD_/g' \
-e 's/PERF_COUNTER/PERF_EVENT/g' \
-e 's/perf_counter/perf_event/g' \
-e 's/nb_counters/nb_events/g' \
-e 's/swcounter/swevent/g' \
-e 's/tpcounter_event/tp_event/g' \
$FILES
for N in $(find . -name perf_counter.[ch]); do
M=$(echo $N | sed 's/perf_counter/perf_event/g')
mv $N $M
done
FILES=$(find . -name perf_event.*)
sed -i \
-e 's/COUNTER_MASK/REG_MASK/g' \
-e 's/COUNTER/EVENT/g' \
-e 's/\<event\>/event_id/g' \
-e 's/counter/event/g' \
-e 's/Counter/Event/g' \
$FILES
... to keep it as correct as possible. This script can also be
used by anyone who has pending perfcounters patches - it converts
a Linux kernel tree over to the new naming. We tried to time this
change to the point in time where the amount of pending patches
is the smallest: the end of the merge window.
Namespace clashes were fixed up in a preparatory patch - and some
stylistic fallout will be fixed up in a subsequent patch.
( NOTE: 'counters' are still the proper terminology when we deal
with hardware registers - and these sed scripts are a bit
over-eager in renaming them. I've undone some of that, but
in case there's something left where 'counter' would be
better than 'event' we can undo that on an individual basis
instead of touching an otherwise nicely automated patch. )
Suggested-by: Stephane Eranian <eranian@google.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Acked-by: Paul Mackerras <paulus@samba.org>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: <linux-arch@vger.kernel.org>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
2009-09-21 14:02:48 +04:00
.quad sys_perf_event_open
2009-10-13 10:40:10 +04:00
.quad compat_sys_recvmmsg
2009-12-18 05:24:25 +03:00
.quad sys_fanotify_init
2009-12-18 05:24:26 +03:00
.quad sys32_fanotify_mark
2010-08-11 02:35:10 +04:00
.quad sys_prlimit64 /* 340 */
2011-01-29 16:13:37 +03:00
.quad sys_name_to_handle_at
.quad compat_sys_open_by_handle_at
2011-02-01 16:52:30 +03:00
.quad compat_sys_clock_adjtime
2011-03-10 22:31:30 +03:00
.quad sys_syncfs
2011-05-03 00:21:35 +04:00
.quad compat_sys_sendmmsg /* 345 */
2011-05-28 06:28:27 +04:00
.quad sys_setns
2011-11-01 04:06:39 +04:00
.quad compat_sys_process_vm_readv
.quad compat_sys_process_vm_writev
2007-05-12 19:27:41 +04:00
ia32_syscall_end :