From patchwork Fri Aug 15 11:01:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35427 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f69.google.com (mail-qg0-f69.google.com [209.85.192.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 77AB3203C5 for ; Fri, 15 Aug 2014 11:03:08 +0000 (UTC) Received: by mail-qg0-f69.google.com with SMTP id a108sf6244338qge.8 for ; Fri, 15 Aug 2014 04:03:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=4LnkO6INqK8FDNPaTdSTg4I8dD5jDuC2tjIAJrDLQnM=; b=TCv7dJOTJ+umfXtF5ggdPSstIC92gH4ahzjT2SV0IPxRQH9vgfrIs8Y2FSS5rNRrf5 6lS9bpSMmNeclblqquo37zbq3N3ymG2yTs8hHPWASWvVZG8PdLMb8g7u9yVkhVKIGof9 ytufnkTy2sCdnqPZdlTYUzhwb97knoLPDSKqhdCx7y6QtsS/ccdmWSdRyCJGQ2BxPRBk Ke+C1zEkzotRbIdrBfxcWgFnp8Ys+7GdjW1gMPm3z1zw7Udx2xvfNeTEli++0C0c2kbB 24cZ69CMka0TmalfrCcd/EF2HVB1Lz4ee51MzBiSQ9J+0eq8bRr6qIo/LnR/jEInpRQE uW/Q== X-Gm-Message-State: ALoCoQlGjgq+Xbb8NjbFLIBb5fK2NtDgpIxXsytAQx/AIkyzg5HqD3PYHawJOrMxd8saufk0xfAG X-Received: by 10.236.112.234 with SMTP id y70mr5593291yhg.32.1408100588254; Fri, 15 Aug 2014 04:03:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.137 with SMTP id 9ls1369084qgp.68.gmail; Fri, 15 Aug 2014 04:03:08 -0700 (PDT) X-Received: by 10.224.71.198 with SMTP id i6mr26870997qaj.76.1408100588084; Fri, 15 Aug 2014 04:03:08 -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 b19si11345178qaw.25.2014.08.15.04.03.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:03:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id lf12so2758955vcb.15 for ; Fri, 15 Aug 2014 04:03:07 -0700 (PDT) X-Received: by 10.220.97.5 with SMTP id j5mr9732413vcn.16.1408100587865; Fri, 15 Aug 2014 04:03:07 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp103968vcb; Fri, 15 Aug 2014 04:03:07 -0700 (PDT) X-Received: by 10.224.47.130 with SMTP id n2mr26782442qaf.87.1408100587074; Fri, 15 Aug 2014 04:03:07 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b66si11334626qgf.68.2014.08.15.04.03.06 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 15 Aug 2014 04:03:07 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:58531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFHm-00062h-Jr for patch@linaro.org; Fri, 15 Aug 2014 07:03:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGa-0004wx-O4 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:02:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIFGT-00070w-V7 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:52 -0400 Received: from afflict.kos.to ([92.243.29.197]:57575) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIFGT-00070V-Ki for qemu-devel@nongnu.org; Fri, 15 Aug 2014 07:01:45 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 5906E26560; Fri, 15 Aug 2014 13:01:44 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 15 Aug 2014 14:01:20 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Mikhail Ilin , Peter Maydell , Riku Voipio Subject: [Qemu-devel] [PULL 02/24] linux-user: redirect openat calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio While Mikhail fixed /proc/self/maps, it was noticed openat calls are not redirected currently. Some archs don't have open at all, so openat needs to be redirected. Fix this by consolidating open/openat code to do_openat - open is implemented using openat(AT_FDCWD, ... ), which according to open(2) man page is identical. Since all targets now have openat, remove the ifdef around sys_openat and openat: case in do_syscall. Cc: Mikhail Ilin Signed-off-by: Riku Voipio --- linux-user/syscall.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c8c2b4c..dd77673 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -294,7 +294,6 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } -#ifdef TARGET_NR_openat static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) { /* @@ -306,7 +305,6 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) } return (openat(dirfd, pathname, flags)); } -#endif #ifdef TARGET_NR_utimensat #ifdef CONFIG_UTIMENSAT @@ -5274,7 +5272,7 @@ static int open_net_route(void *cpu_env, int fd) } #endif -static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) +static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode) { struct fake_open { const char *filename; @@ -5295,7 +5293,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) if (is_proc_myself(pathname, "exe")) { int execfd = qemu_getauxval(AT_EXECFD); - return execfd ? execfd : get_errno(open(exec_path, flags, mode)); + return execfd ? execfd : get_errno(sys_openat(dirfd, exec_path, flags, mode)); } for (fake_open = fakes; fake_open->filename; fake_open++) { @@ -5329,7 +5327,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) return fd; } - return get_errno(open(path(pathname), flags, mode)); + return get_errno(sys_openat(dirfd, path(pathname), flags, mode)); } /* do_syscall() should always have a single exit point at the end so @@ -5404,22 +5402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_open: if (!(p = lock_user_string(arg1))) goto efault; - ret = get_errno(do_open(cpu_env, p, - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); + ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); unlock_user(p, arg1, 0); break; -#if defined(TARGET_NR_openat) && defined(__NR_openat) case TARGET_NR_openat: if (!(p = lock_user_string(arg2))) goto efault; - ret = get_errno(sys_openat(arg1, - path(p), - target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); + ret = get_errno(do_openat(cpu_env, arg1, p, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); unlock_user(p, arg2, 0); break; -#endif case TARGET_NR_close: ret = get_errno(close(arg1)); break;