From patchwork Tue Jun 16 07:06:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 49948 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B8407205DE for ; Tue, 16 Jun 2015 07:09:55 +0000 (UTC) Received: by labsp1 with SMTP id sp1sf2107977lab.3 for ; Tue, 16 Jun 2015 00:09:54 -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=PZoFv+bIM0wDBf86zbfsEtg7LwWFNfvFR9a95ZtU12I=; b=WvRfjAhqdoZPCZ/1G1ZNwoEEkSGovrO4m2DKYxtXzBtlwOSonRMPpBubDc55Ppe6fO dK00Biz1vvu7SNUYii5ufUE1uYS4Lx/NI8bPBRrs4EdjI54mV/nTp3iss1RHG8rPi4/0 Rkz4YTNicguV/jrw5e6u9VA+xq5kExDCxRJb+SPWknfq3FoOAr/67gyJm9b/5dsLscXC 8cLQBTvsq1X2vqH8+9+8satvjCc01fQB76L44l5QPv5bOcZnNCExxK2U3ZuL0a1bbfBq qE+kGelNzNPX1FbVqsfNYyOovBt4TUIsEx4kdBSMQ/U4LS24bkE74/B23SuAc7YyZPz6 zjnA== X-Gm-Message-State: ALoCoQmtS4bFgxC3GH4tES9TdtzbpNh/ztjzjspFxmnolYTJJ1I/aI/09LrnZBhRj74XCBNGB8ll X-Received: by 10.180.105.226 with SMTP id gp2mr23493690wib.1.1434438594677; Tue, 16 Jun 2015 00:09:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.72 with SMTP id h8ls39507laa.71.gmail; Tue, 16 Jun 2015 00:09:54 -0700 (PDT) X-Received: by 10.112.213.108 with SMTP id nr12mr4613533lbc.42.1434438594494; Tue, 16 Jun 2015 00:09:54 -0700 (PDT) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id n7si95811lbs.61.2015.06.16.00.09.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jun 2015 00:09:54 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by lblr1 with SMTP id r1so4780177lbl.0 for ; Tue, 16 Jun 2015 00:09:54 -0700 (PDT) X-Received: by 10.152.29.34 with SMTP id g2mr31374269lah.73.1434438594359; Tue, 16 Jun 2015 00:09:54 -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 hn6csp1914159lbb; Tue, 16 Jun 2015 00:09:52 -0700 (PDT) X-Received: by 10.140.196.129 with SMTP id r123mr43093072qha.93.1434438591532; Tue, 16 Jun 2015 00:09:51 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id jm7si104142qcb.11.2015.06.16.00.09.50 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 16 Jun 2015 00:09:51 -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]:38178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4l0I-0000YO-J2 for patch@linaro.org; Tue, 16 Jun 2015 03:09:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60949) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4kxH-0004Fy-RF for qemu-devel@nongnu.org; Tue, 16 Jun 2015 03:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4kxE-0006p1-JY for qemu-devel@nongnu.org; Tue, 16 Jun 2015 03:06:43 -0400 Received: from mail-lb0-f171.google.com ([209.85.217.171]:34080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4kxE-0006on-8a for qemu-devel@nongnu.org; Tue, 16 Jun 2015 03:06:40 -0400 Received: by lbbti3 with SMTP id ti3so4706761lbb.1 for ; Tue, 16 Jun 2015 00:06:39 -0700 (PDT) X-Received: by 10.152.26.230 with SMTP id o6mr32270892lag.7.1434438399677; Tue, 16 Jun 2015 00:06:39 -0700 (PDT) Received: from localhost.localdomain (91-157-196-38.elisa-laajakaista.fi. [91.157.196.38]) by mx.google.com with ESMTPSA id wc8sm27104lbb.37.2015.06.16.00.06.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Jun 2015 00:06:39 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 16 Jun 2015 10:06:32 +0300 Message-Id: <45c874ebbae661238bfa3c0534480ebe2940b112.1434438233.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.171 Cc: peter.maydell@linaro.org, Laurent Vivier Subject: [Qemu-devel] [PULL v2 6/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.182 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. Signed-off-by: Laurent Vivier Signed-off-by: Riku Voipio --- linux-user/syscall.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5cf265c..f62c698 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3346,7 +3346,7 @@ 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; @@ -3372,7 +3372,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 @@ -3453,7 +3453,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; @@ -3547,7 +3547,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; @@ -3772,7 +3772,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; @@ -3825,7 +3825,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; @@ -3888,7 +3888,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)); @@ -3905,7 +3905,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;