From patchwork Sat Jun 1 22:35:20 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 17414 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 96F7125E0F for ; Sat, 1 Jun 2013 22:35:29 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id p13sf3635299vbe.4 for ; Sat, 01 Jun 2013 15:35:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=ln479LpLIUXJyO31A9k8P7H3pmha/OYzkcp2l4iyVvM=; b=G0/8CTSRp1Dr4/lnN1k6pZraeyPNfJUSNokjN6icGvzU9UfqlZsXpxTHqds56x8abR R9bh9tNBveP0aym3rZ9I0qrN7ebS1taOBfbF6d3PO+kuVCxaNsd7jGSw0jNhllA3Bse5 PW4h8/ve3L6ZHMvvoZ/VCTtWMrHuDdiFHJs7G30h6bbMUxoZuRPs0aXmPgf8jEEgvXFl uTlSYuBZUTX7T4mxNVXabHa/OieqjiPINWLrEISDfRqdiZLeI+CVHfy8pEp4T6KPerj6 R7AXU8hAAZxaneOTPRA5i799eSHEEb+ygauPueox5G/1i6LKAUNQgzbJZnCCOizRnLEF Si8w== X-Received: by 10.224.42.141 with SMTP id s13mr10093575qae.3.1370126128845; Sat, 01 Jun 2013 15:35:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.41.7 with SMTP id b7ls1430667qel.12.gmail; Sat, 01 Jun 2013 15:35:28 -0700 (PDT) X-Received: by 10.220.77.4 with SMTP id e4mr11474008vck.5.1370126128619; Sat, 01 Jun 2013 15:35:28 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id ef7si32459852vdc.72.2013.06.01.15.35.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 01 Jun 2013 15:35:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hf12so429545vcb.1 for ; Sat, 01 Jun 2013 15:35:28 -0700 (PDT) X-Received: by 10.58.187.164 with SMTP id ft4mr14786896vec.5.1370126127930; Sat, 01 Jun 2013 15:35:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.229.199 with SMTP id jj7csp23612vcb; Sat, 1 Jun 2013 15:35:27 -0700 (PDT) X-Received: by 10.15.44.10 with SMTP id y10mr18183361eev.5.1370126126506; Sat, 01 Jun 2013 15:35:26 -0700 (PDT) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id b5si36257853eew.164.2013.06.01.15.35.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 01 Jun 2013 15:35:26 -0700 (PDT) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1UiuOP-0005z2-67; Sat, 01 Jun 2013 23:35:21 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio , Claudio Fontana Subject: [PATCH 1/2] linux-user: Drop direct use of openat etc syscalls Date: Sat, 1 Jun 2013 23:35:20 +0100 Message-Id: <1370126121-22975-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1370126121-22975-1-git-send-email-peter.maydell@linaro.org> References: <1370126121-22975-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQk7llPLTIJYdrfEY3X04bq9kIFUkNX3LPAxnOUHO60qP8hDCsTgEz9oyWBfLy1Wc3AloLq3 X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The linux-user syscall emulation layer currently supports the openat family of syscalls via two mechanisms: simply calling the corresponding libc functions, and making direct syscalls. Since glibc has supported these functions since at least glibc 2.5, there's no real need to retain the (essentially untested) direct syscall fallback code, so simply delete it. This allows us to remove some ifdeffery that was attempting to disable provision of some of the syscalls if the host didn't seem to support them, which in some cases was actually wrong (eg where there are several flavours of the syscall and we only need one of them, not necessarily the exact one the guest has, as with the fstatat* calls). Signed-off-by: Peter Maydell --- linux-user/syscall.c | 218 ++++++-------------------------------------------- 1 file changed, 24 insertions(+), 194 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 121218b..053fa14 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -181,29 +181,14 @@ static type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, \ #define __NR_sys_uname __NR_uname -#define __NR_sys_faccessat __NR_faccessat -#define __NR_sys_fchmodat __NR_fchmodat -#define __NR_sys_fchownat __NR_fchownat -#define __NR_sys_fstatat64 __NR_fstatat64 -#define __NR_sys_futimesat __NR_futimesat #define __NR_sys_getcwd1 __NR_getcwd #define __NR_sys_getdents __NR_getdents #define __NR_sys_getdents64 __NR_getdents64 #define __NR_sys_getpriority __NR_getpriority -#define __NR_sys_linkat __NR_linkat -#define __NR_sys_mkdirat __NR_mkdirat -#define __NR_sys_mknodat __NR_mknodat -#define __NR_sys_newfstatat __NR_newfstatat -#define __NR_sys_openat __NR_openat -#define __NR_sys_readlinkat __NR_readlinkat -#define __NR_sys_renameat __NR_renameat #define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo -#define __NR_sys_symlinkat __NR_symlinkat #define __NR_sys_syslog __NR_syslog #define __NR_sys_tgkill __NR_tgkill #define __NR_sys_tkill __NR_tkill -#define __NR_sys_unlinkat __NR_unlinkat -#define __NR_sys_utimensat __NR_utimensat #define __NR_sys_futex __NR_futex #define __NR_sys_inotify_init __NR_inotify_init #define __NR_sys_inotify_add_watch __NR_inotify_add_watch @@ -336,72 +321,6 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } -#ifdef CONFIG_ATFILE -/* - * Host system seems to have atfile syscall stubs available. We - * now enable them one by one as specified by target syscall_nr.h. - */ - -#ifdef TARGET_NR_faccessat -static int sys_faccessat(int dirfd, const char *pathname, int mode) -{ - return (faccessat(dirfd, pathname, mode, 0)); -} -#endif -#ifdef TARGET_NR_fchmodat -static int sys_fchmodat(int dirfd, const char *pathname, mode_t mode) -{ - return (fchmodat(dirfd, pathname, mode, 0)); -} -#endif -#if defined(TARGET_NR_fchownat) -static int sys_fchownat(int dirfd, const char *pathname, uid_t owner, - gid_t group, int flags) -{ - return (fchownat(dirfd, pathname, owner, group, flags)); -} -#endif -#ifdef __NR_fstatat64 -static int sys_fstatat64(int dirfd, const char *pathname, struct stat *buf, - int flags) -{ - return (fstatat(dirfd, pathname, buf, flags)); -} -#endif -#ifdef __NR_newfstatat -static int sys_newfstatat(int dirfd, const char *pathname, struct stat *buf, - int flags) -{ - return (fstatat(dirfd, pathname, buf, flags)); -} -#endif -#ifdef TARGET_NR_futimesat -static int sys_futimesat(int dirfd, const char *pathname, - const struct timeval times[2]) -{ - return (futimesat(dirfd, pathname, times)); -} -#endif -#ifdef TARGET_NR_linkat -static int sys_linkat(int olddirfd, const char *oldpath, - int newdirfd, const char *newpath, int flags) -{ - return (linkat(olddirfd, oldpath, newdirfd, newpath, flags)); -} -#endif -#ifdef TARGET_NR_mkdirat -static int sys_mkdirat(int dirfd, const char *pathname, mode_t mode) -{ - return (mkdirat(dirfd, pathname, mode)); -} -#endif -#ifdef TARGET_NR_mknodat -static int sys_mknodat(int dirfd, const char *pathname, mode_t mode, - dev_t dev) -{ - return (mknodat(dirfd, pathname, mode, dev)); -} -#endif #ifdef TARGET_NR_openat static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) { @@ -415,91 +334,6 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) return (openat(dirfd, pathname, flags)); } #endif -#ifdef TARGET_NR_readlinkat -static int sys_readlinkat(int dirfd, const char *pathname, char *buf, size_t bufsiz) -{ - return (readlinkat(dirfd, pathname, buf, bufsiz)); -} -#endif -#ifdef TARGET_NR_renameat -static int sys_renameat(int olddirfd, const char *oldpath, - int newdirfd, const char *newpath) -{ - return (renameat(olddirfd, oldpath, newdirfd, newpath)); -} -#endif -#ifdef TARGET_NR_symlinkat -static int sys_symlinkat(const char *oldpath, int newdirfd, const char *newpath) -{ - return (symlinkat(oldpath, newdirfd, newpath)); -} -#endif -#ifdef TARGET_NR_unlinkat -static int sys_unlinkat(int dirfd, const char *pathname, int flags) -{ - return (unlinkat(dirfd, pathname, flags)); -} -#endif -#else /* !CONFIG_ATFILE */ - -/* - * Try direct syscalls instead - */ -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) -_syscall3(int,sys_faccessat,int,dirfd,const char *,pathname,int,mode) -#endif -#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) -_syscall3(int,sys_fchmodat,int,dirfd,const char *,pathname, mode_t,mode) -#endif -#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) -_syscall5(int,sys_fchownat,int,dirfd,const char *,pathname, - uid_t,owner,gid_t,group,int,flags) -#endif -#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ - defined(__NR_fstatat64) -_syscall4(int,sys_fstatat64,int,dirfd,const char *,pathname, - struct stat *,buf,int,flags) -#endif -#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) -_syscall3(int,sys_futimesat,int,dirfd,const char *,pathname, - const struct timeval *,times) -#endif -#if (defined(TARGET_NR_newfstatat) || defined(TARGET_NR_fstatat64) ) && \ - defined(__NR_newfstatat) -_syscall4(int,sys_newfstatat,int,dirfd,const char *,pathname, - struct stat *,buf,int,flags) -#endif -#if defined(TARGET_NR_linkat) && defined(__NR_linkat) -_syscall5(int,sys_linkat,int,olddirfd,const char *,oldpath, - int,newdirfd,const char *,newpath,int,flags) -#endif -#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) -_syscall3(int,sys_mkdirat,int,dirfd,const char *,pathname,mode_t,mode) -#endif -#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) -_syscall4(int,sys_mknodat,int,dirfd,const char *,pathname, - mode_t,mode,dev_t,dev) -#endif -#if defined(TARGET_NR_openat) && defined(__NR_openat) -_syscall4(int,sys_openat,int,dirfd,const char *,pathname,int,flags,mode_t,mode) -#endif -#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) -_syscall4(int,sys_readlinkat,int,dirfd,const char *,pathname, - char *,buf,size_t,bufsize) -#endif -#if defined(TARGET_NR_renameat) && defined(__NR_renameat) -_syscall4(int,sys_renameat,int,olddirfd,const char *,oldpath, - int,newdirfd,const char *,newpath) -#endif -#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) -_syscall3(int,sys_symlinkat,const char *,oldpath, - int,newdirfd,const char *,newpath) -#endif -#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) -_syscall3(int,sys_unlinkat,int,dirfd,const char *,pathname,int,flags) -#endif - -#endif /* CONFIG_ATFILE */ #ifdef CONFIG_UTIMENSAT static int sys_utimensat(int dirfd, const char *pathname, @@ -5348,7 +5182,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } break; -#if defined(TARGET_NR_linkat) && defined(__NR_linkat) +#if defined(TARGET_NR_linkat) case TARGET_NR_linkat: { void * p2 = NULL; @@ -5359,7 +5193,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!p || !p2) ret = -TARGET_EFAULT; else - ret = get_errno(sys_linkat(arg1, p, arg3, p2, arg5)); + ret = get_errno(linkat(arg1, p, arg3, p2, arg5)); unlock_user(p, arg2, 0); unlock_user(p2, arg4, 0); } @@ -5371,11 +5205,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(unlink(p)); unlock_user(p, arg1, 0); break; -#if defined(TARGET_NR_unlinkat) && defined(__NR_unlinkat) +#if defined(TARGET_NR_unlinkat) case TARGET_NR_unlinkat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_unlinkat(arg1, p, arg3)); + ret = get_errno(unlinkat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif @@ -5493,11 +5327,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(mknod(p, arg2, arg3)); unlock_user(p, arg1, 0); break; -#if defined(TARGET_NR_mknodat) && defined(__NR_mknodat) +#if defined(TARGET_NR_mknodat) case TARGET_NR_mknodat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_mknodat(arg1, p, arg3, arg4)); + ret = get_errno(mknodat(arg1, p, arg3, arg4)); unlock_user(p, arg2, 0); break; #endif @@ -5628,7 +5462,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } break; -#if defined(TARGET_NR_futimesat) && defined(__NR_futimesat) +#if defined(TARGET_NR_futimesat) case TARGET_NR_futimesat: { struct timeval *tvp, tv[2]; @@ -5643,7 +5477,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_futimesat(arg1, path(p), tvp)); + ret = get_errno(futimesat(arg1, path(p), tvp)); unlock_user(p, arg2, 0); } break; @@ -5666,7 +5500,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_faccessat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_faccessat(arg1, p, arg3)); + ret = get_errno(faccessat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); break; #endif @@ -5699,7 +5533,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } break; -#if defined(TARGET_NR_renameat) && defined(__NR_renameat) +#if defined(TARGET_NR_renameat) case TARGET_NR_renameat: { void *p2; @@ -5708,7 +5542,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!p || !p2) ret = -TARGET_EFAULT; else - ret = get_errno(sys_renameat(arg1, p, arg3, p2)); + ret = get_errno(renameat(arg1, p, arg3, p2)); unlock_user(p2, arg4, 0); unlock_user(p, arg2, 0); } @@ -5720,11 +5554,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(mkdir(p, arg2)); unlock_user(p, arg1, 0); break; -#if defined(TARGET_NR_mkdirat) && defined(__NR_mkdirat) +#if defined(TARGET_NR_mkdirat) case TARGET_NR_mkdirat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_mkdirat(arg1, p, arg3)); + ret = get_errno(mkdirat(arg1, p, arg3)); unlock_user(p, arg2, 0); break; #endif @@ -6410,7 +6244,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } break; -#if defined(TARGET_NR_symlinkat) && defined(__NR_symlinkat) +#if defined(TARGET_NR_symlinkat) case TARGET_NR_symlinkat: { void *p2; @@ -6419,7 +6253,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!p || !p2) ret = -TARGET_EFAULT; else - ret = get_errno(sys_symlinkat(p, arg2, p2)); + ret = get_errno(symlinkat(p, arg2, p2)); unlock_user(p2, arg3, 0); unlock_user(p, arg1, 0); } @@ -6450,7 +6284,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, unlock_user(p, arg1, 0); } break; -#if defined(TARGET_NR_readlinkat) && defined(__NR_readlinkat) +#if defined(TARGET_NR_readlinkat) case TARGET_NR_readlinkat: { void *p2; @@ -6459,7 +6293,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, if (!p || !p2) ret = -TARGET_EFAULT; else - ret = get_errno(sys_readlinkat(arg1, path(p), p2, arg4)); + ret = get_errno(readlinkat(arg1, path(p), p2, arg4)); unlock_user(p2, arg3, ret); unlock_user(p, arg2, 0); } @@ -6594,11 +6428,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_fchmod: ret = get_errno(fchmod(arg1, arg2)); break; -#if defined(TARGET_NR_fchmodat) && defined(__NR_fchmodat) +#if defined(TARGET_NR_fchmodat) case TARGET_NR_fchmodat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_fchmodat(arg1, p, arg3)); + ret = get_errno(fchmodat(arg1, p, arg3, 0)); unlock_user(p, arg2, 0); break; #endif @@ -7686,8 +7520,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = host_to_target_stat64(cpu_env, arg2, &st); break; #endif -#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) && \ - (defined(__NR_fstatat64) || defined(__NR_newfstatat)) +#if (defined(TARGET_NR_fstatat64) || defined(TARGET_NR_newfstatat)) #ifdef TARGET_NR_fstatat64 case TARGET_NR_fstatat64: #endif @@ -7696,11 +7529,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #endif if (!(p = lock_user_string(arg2))) goto efault; -#ifdef __NR_fstatat64 - ret = get_errno(sys_fstatat64(arg1, path(p), &st, arg4)); -#else - ret = get_errno(sys_newfstatat(arg1, path(p), &st, arg4)); -#endif + ret = get_errno(fstatat(arg1, path(p), &st, arg4)); if (!is_error(ret)) ret = host_to_target_stat64(cpu_env, arg3, &st); break; @@ -7782,11 +7611,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_fchown: ret = get_errno(fchown(arg1, low2highuid(arg2), low2highgid(arg3))); break; -#if defined(TARGET_NR_fchownat) && defined(__NR_fchownat) +#if defined(TARGET_NR_fchownat) case TARGET_NR_fchownat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_fchownat(arg1, p, low2highuid(arg3), low2highgid(arg4), arg5)); + ret = get_errno(fchownat(arg1, p, low2highuid(arg3), + low2highgid(arg4), arg5)); unlock_user(p, arg2, 0); break; #endif