From patchwork Mon Jun 15 12:20:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 49862 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 83BA8211FD for ; Mon, 15 Jun 2015 12:28:00 +0000 (UTC) Received: by labsp1 with SMTP id sp1sf27127561lab.3 for ; Mon, 15 Jun 2015 05:27:59 -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=D+6pnVTZEKSLepBTuf2nZMe6bS0/MELM1eEXBhL2Gr0=; b=ejVrhkbh9aKMv0++b+lII34SRG7MNzeobu7OcI2QsgOA1M77rBBcGIDE+ITZbtckFS SBQG0iu9hqp9vGUJOqwpWjgYBTFrKDGMdc6Qcpmp+9KC0bNDAnebPELIbGgmWX1mK5l0 blpbR03k+EBfzOrQhd7DrRMUl264X9KJjz7+b6aGuMvLCGw8bW0dmN3jXYFgh8KOdHaD D3+xnpOfSZgi2UrNAb/hRlzMQ5BLdYqIeolKiidRJ7bOWdIHxwNlmALBxPF5DRMgESSk A7p6MdUSVA0p4bSJ9k85AWpyxydmO/zpecqCbrRQ1EfySDLoHmqfP478jb+ZhcqAxyp6 oduw== X-Gm-Message-State: ALoCoQmpxfjLkqFqLzXqkwYMuYbVSxLTvW91XeFPZ8luJVtHMBIrtp+TO5C3eW1VSxLyASzTfJUd X-Received: by 10.180.11.101 with SMTP id p5mr19395924wib.3.1434371276155; Mon, 15 Jun 2015 05:27:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.71 with SMTP id t7ls896513lae.31.gmail; Mon, 15 Jun 2015 05:27:55 -0700 (PDT) X-Received: by 10.152.164.193 with SMTP id ys1mr26988397lab.65.1434371275959; Mon, 15 Jun 2015 05:27:55 -0700 (PDT) Received: from mail-lb0-f180.google.com (mail-lb0-f180.google.com. [209.85.217.180]) by mx.google.com with ESMTPS id xr5si10381319lbb.76.2015.06.15.05.27.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jun 2015 05:27:55 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.180 as permitted sender) client-ip=209.85.217.180; Received: by lbbwc1 with SMTP id wc1so481189lbb.2 for ; Mon, 15 Jun 2015 05:27:55 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr26853647lbc.73.1434371275774; Mon, 15 Jun 2015 05:27:55 -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.112.108.230 with SMTP id hn6csp1381219lbb; Mon, 15 Jun 2015 05:27:54 -0700 (PDT) X-Received: by 10.55.21.219 with SMTP id 88mr36535519qkv.96.1434371274197; Mon, 15 Jun 2015 05:27:54 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id 11si12530795qhq.44.2015.06.15.05.27.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 15 Jun 2015 05:27:54 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:33921 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUX-0005zr-F8 for patch@linaro.org; Mon, 15 Jun 2015 08:27:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TTz-0005Sl-Fy for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:27:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4TTv-0005gN-F9 for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:27:19 -0400 Received: from mail-lb0-f170.google.com ([209.85.217.170]:33371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TTv-0005gC-3v for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:27:15 -0400 Received: by lblr1 with SMTP id r1so25895209lbl.0 for ; Mon, 15 Jun 2015 05:27:14 -0700 (PDT) X-Received: by 10.152.26.230 with SMTP id o6mr27603593lag.7.1434370855678; Mon, 15 Jun 2015 05:20:55 -0700 (PDT) Received: from localhost.localdomain (91-157-196-38.elisa-laajakaista.fi. [91.157.196.38]) by mx.google.com with ESMTPSA id bm5sm2683890lbc.45.2015.06.15.05.20.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Jun 2015 05:20:55 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 15 Jun 2015 15:20:47 +0300 Message-Id: <14c4e6f433adbb1c107412292935d48d0106e670.1434369586.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.217.170 Cc: peter.maydell@linaro.org, Laurent Vivier Subject: [Qemu-devel] [PULL 3/6] linux-user: ioctl() command type is int 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.217.180 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: Laurent Vivier When executing a 64bit target chroot on 64bit host, the ioctl() command can mismatch. It seems the previous commit doesn't solve the problem in my case: 9c6bf9c7 linux-user: Fix ioctl cmd type mismatch on 64-bit targets For example, a ppc64 chroot on an x86_64 host: bash-4.3# ls Unsupported ioctl: cmd=0x80087467 Unsupported ioctl: cmd=0x802c7415 The origin of the problem is in syscall.c:do_ioctl(). static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) In this case (ppc64) abi_long is long (on the x86_64), and cmd = 0x0000000080087467 then if (ie->target_cmd == cmd) target_cmd is int, so target_cmd = 0x80087467 and to compare an int with a long, the sign is extended to 64bit, so the comparison is: if (0xffffffff80087467 == 0x0000000080087467) which doesn't match whereas it should. This patch uses int in the case of the target command type instead of abi_long (and for consistency, update IOCTLEntry). Signed-off-by: Laurent Vivier Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f56f3e0..ed8c423 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3291,11 +3291,11 @@ STRUCT_MAX typedef struct IOCTLEntry IOCTLEntry; typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, abi_long cmd, abi_long arg); + int fd, int cmd, abi_long arg); struct IOCTLEntry { int target_cmd; - unsigned int host_cmd; + int host_cmd; const char *name; int access; do_ioctl_fn *do_ioctl; @@ -3317,7 +3317,7 @@ struct IOCTLEntry { / sizeof(struct fiemap_extent)) static abi_long do_ioctl_fs_ioc_fiemap(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, abi_long cmd, abi_long arg) + int fd, int cmd, abi_long arg) { /* The parameter for this ioctl is a struct fiemap followed * by an array of struct fiemap_extent whose size is set @@ -3398,7 +3398,7 @@ static abi_long do_ioctl_fs_ioc_fiemap(const IOCTLEntry *ie, uint8_t *buf_temp, #endif static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, abi_long cmd, abi_long arg) + int fd, int cmd, abi_long arg) { const argtype *arg_type = ie->arg_type; int target_size; @@ -3492,7 +3492,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp, } static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, - abi_long cmd, abi_long arg) + int cmd, abi_long arg) { void *argptr; struct dm_ioctl *host_dm; @@ -3717,7 +3717,7 @@ out: } static abi_long do_ioctl_blkpg(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, - abi_long cmd, abi_long arg) + int cmd, abi_long arg) { void *argptr; int target_size; @@ -3770,7 +3770,7 @@ out: } static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, abi_long cmd, abi_long arg) + int fd, int cmd, abi_long arg) { const argtype *arg_type = ie->arg_type; const StructEntry *se; @@ -3833,7 +3833,7 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp, } static abi_long do_ioctl_kdsigaccept(const IOCTLEntry *ie, uint8_t *buf_temp, - int fd, abi_long cmd, abi_long arg) + int fd, int cmd, abi_long arg) { int sig = target_to_host_signal(arg); return get_errno(ioctl(fd, ie->host_cmd, sig)); @@ -3850,7 +3850,7 @@ static IOCTLEntry ioctl_entries[] = { /* ??? Implement proper locking for ioctls. */ /* do_ioctl() Must return target values and target errnos. */ -static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) +static abi_long do_ioctl(int fd, int cmd, abi_long arg) { const IOCTLEntry *ie; const argtype *arg_type;