linux-user: ioctl() command type is int
commit45c874ebbae661238bfa3c0534480ebe2940b112
authorLaurent Vivier <laurent@vivier.eu>
Mon, 15 Jun 2015 22:35:28 +0000 (16 00:35 +0200)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 16 Jun 2015 06:37:17 +0000 (16 09:37 +0300)
tree83b72699bfd3d871c92606a1f1adbc05499a9c5e
parent1d085f6cae51b1a0fb92ad03ce8bf038e29c9750
linux-user: ioctl() command type is int

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 <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c