Fix ARM7/9 and Cortex-A SYSCALLs: For threads in SVC mode, the SVC instructions clobbers R14. This must be taken account in the inline assembly

This commit is contained in:
Gregory Nutt 2014-08-29 10:07:11 -06:00
parent 63fd1e12dd
commit c499297899
2 changed files with 16 additions and 15 deletions

View File

@ -77,7 +77,7 @@ static inline uintptr_t sys_call0(unsigned int nbr)
"swi %1" "swi %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0) : "i"(SYS_syscall), "r"(reg0)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -95,7 +95,7 @@ static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1)
"swi %1" "swi %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1) : "i"(SYS_syscall), "r"(reg0), "r"(reg1)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -115,7 +115,7 @@ static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1,
"swi %1" "swi %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -136,7 +136,7 @@ static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1,
"swi %1" "swi %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -160,7 +160,7 @@ static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4) "r"(reg3), "r"(reg4)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -185,7 +185,7 @@ static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4), "r"(reg5) "r"(reg3), "r"(reg4), "r"(reg5)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -212,7 +212,7 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -228,7 +228,8 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
#ifdef __cplusplus #ifdef __cplusplus
#define EXTERN extern "C" #define EXTERN extern "C"
extern "C" { extern "C"
{
#else #else
#define EXTERN extern #define EXTERN extern
#endif #endif

View File

@ -77,7 +77,7 @@ static inline uintptr_t sys_call0(unsigned int nbr)
"svc %1" "svc %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0) : "i"(SYS_syscall), "r"(reg0)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -95,7 +95,7 @@ static inline uintptr_t sys_call1(unsigned int nbr, uintptr_t parm1)
"svc %1" "svc %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1) : "i"(SYS_syscall), "r"(reg0), "r"(reg1)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -115,7 +115,7 @@ static inline uintptr_t sys_call2(unsigned int nbr, uintptr_t parm1,
"svc %1" "svc %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2) : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -136,7 +136,7 @@ static inline uintptr_t sys_call3(unsigned int nbr, uintptr_t parm1,
"svc %1" "svc %1"
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3) : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), "r"(reg3)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -160,7 +160,7 @@ static inline uintptr_t sys_call4(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4) "r"(reg3), "r"(reg4)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -185,7 +185,7 @@ static inline uintptr_t sys_call5(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4), "r"(reg5) "r"(reg3), "r"(reg4), "r"(reg5)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;
@ -212,7 +212,7 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1,
: "=r"(reg0) : "=r"(reg0)
: "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2), : "i"(SYS_syscall), "r"(reg0), "r"(reg1), "r"(reg2),
"r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6) "r"(reg3), "r"(reg4), "r"(reg5), "r"(reg6)
: "memory" : "memory", "r14"
); );
return reg0; return reg0;