[PATCH] Remove the use of _syscallX macros in UML
User mode linux uses _syscallX() to call into the host kernel. The recommended way to do this is to use the syscall() function from libc. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Cc: Andi Kleen <ak@muc.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Russell King <rmk@arm.linux.org.uk> Cc: Ian Molton <spyro@f2s.com> Cc: Mikael Starvik <starvik@axis.com> Cc: David Howells <dhowells@redhat.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Hirokazu Takata <takata.hirokazu@renesas.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Kyle McMartin <kyle@mcmartin.ca> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp> Cc: Richard Curnow <rc@rc0.org.uk> Cc: William Lee Irwin III <wli@holomorphy.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Cc: Miles Bader <uclinux-v850@lsi.nec.co.jp> Cc: Chris Zankel <chris@zankel.net> Cc: "Luck, Tony" <tony.luck@intel.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
fe74290d51
commit
5f4c6bc1f3
5 changed files with 15 additions and 25 deletions
|
@ -11,6 +11,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include "ptrace_user.h"
|
#include "ptrace_user.h"
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "user.h"
|
#include "user.h"
|
||||||
|
@ -140,11 +141,9 @@ void os_usr1_process(int pid)
|
||||||
* syscalls, and also breaks with clone(), which does not unshare the TLS.
|
* syscalls, and also breaks with clone(), which does not unshare the TLS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
inline _syscall0(pid_t, getpid)
|
|
||||||
|
|
||||||
int os_getpid(void)
|
int os_getpid(void)
|
||||||
{
|
{
|
||||||
return(getpid());
|
return(syscall(__NR_getpid));
|
||||||
}
|
}
|
||||||
|
|
||||||
int os_getpgrp(void)
|
int os_getpgrp(void)
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/unistd.h>
|
#include <linux/unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include "sysdep/tls.h"
|
#include "sysdep/tls.h"
|
||||||
#include "user_util.h"
|
#include "user_util.h"
|
||||||
|
|
||||||
static _syscall1(int, get_thread_area, user_desc_t *, u_info);
|
|
||||||
|
|
||||||
/* Checks whether host supports TLS, and sets *tls_min according to the value
|
/* Checks whether host supports TLS, and sets *tls_min according to the value
|
||||||
* valid on the host.
|
* valid on the host.
|
||||||
* i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
|
* i386 host have it == 6; x86_64 host have it == 12, for i386 emulation. */
|
||||||
|
@ -17,7 +16,7 @@ void check_host_supports_tls(int *supports_tls, int *tls_min) {
|
||||||
user_desc_t info;
|
user_desc_t info;
|
||||||
info.entry_number = val[i];
|
info.entry_number = val[i];
|
||||||
|
|
||||||
if (get_thread_area(&info) == 0) {
|
if (syscall(__NR_get_thread_area, &info) == 0) {
|
||||||
*tls_min = val[i];
|
*tls_min = val[i];
|
||||||
*supports_tls = 1;
|
*supports_tls = 1;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
#include <asm/ldt.h>
|
#include <asm/ldt.h>
|
||||||
#include "sysdep/tls.h"
|
#include "sysdep/tls.h"
|
||||||
#include "uml-config.h"
|
#include "uml-config.h"
|
||||||
|
@ -48,14 +49,11 @@ int os_get_thread_area(user_desc_t *info, int pid)
|
||||||
#ifdef UML_CONFIG_MODE_TT
|
#ifdef UML_CONFIG_MODE_TT
|
||||||
#include "linux/unistd.h"
|
#include "linux/unistd.h"
|
||||||
|
|
||||||
static _syscall1(int, get_thread_area, user_desc_t *, u_info);
|
|
||||||
static _syscall1(int, set_thread_area, user_desc_t *, u_info);
|
|
||||||
|
|
||||||
int do_set_thread_area_tt(user_desc_t *info)
|
int do_set_thread_area_tt(user_desc_t *info)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = set_thread_area(info);
|
ret = syscall(__NR_set_thread_area,info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +64,7 @@ int do_get_thread_area_tt(user_desc_t *info)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = get_thread_area(info);
|
ret = syscall(__NR_get_thread_area,info);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,20 +5,17 @@
|
||||||
|
|
||||||
#include <linux/mman.h>
|
#include <linux/mman.h>
|
||||||
#include <asm/unistd.h>
|
#include <asm/unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
static int errno;
|
|
||||||
|
|
||||||
static inline _syscall2(int,munmap,void *,start,size_t,len)
|
|
||||||
static inline _syscall6(void *,mmap2,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
|
|
||||||
int switcheroo(int fd, int prot, void *from, void *to, int size)
|
int switcheroo(int fd, int prot, void *from, void *to, int size)
|
||||||
{
|
{
|
||||||
if(munmap(to, size) < 0){
|
if (syscall(__NR_munmap, to, size) < 0){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if(mmap2(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
|
if (syscall(__NR_mmap2, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1 ){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if(munmap(from, size) < 0){
|
if (syscall(__NR_munmap, from, size) < 0){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
|
|
@ -5,20 +5,17 @@
|
||||||
|
|
||||||
#include <linux/mman.h>
|
#include <linux/mman.h>
|
||||||
#include <asm/unistd.h>
|
#include <asm/unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
|
||||||
static int errno;
|
|
||||||
|
|
||||||
static inline _syscall2(int,munmap,void *,start,size_t,len)
|
|
||||||
static inline _syscall6(void *,mmap,void *,addr,size_t,len,int,prot,int,flags,int,fd,off_t,offset)
|
|
||||||
int switcheroo(int fd, int prot, void *from, void *to, int size)
|
int switcheroo(int fd, int prot, void *from, void *to, int size)
|
||||||
{
|
{
|
||||||
if(munmap(to, size) < 0){
|
if (syscall(__NR_munmap, to, size) < 0){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if(mmap(to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
|
if (syscall(__NR_mmap, to, size, prot, MAP_SHARED | MAP_FIXED, fd, 0) == (void*) -1){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if(munmap(from, size) < 0){
|
if (syscall(__NR_munmap, from, size) < 0){
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
|
Loading…
Reference in a new issue