Commit Graph

362 Commits

Author SHA1 Message Date
Paul Brook 97374d3858 Usermode exec-stack fix
When loading a shared library that requires an executable stack,
glibc uses the mprotext PROT_GROWSDOWN flag to achieve this.
We don't support PROT_GROWSDOWN.
Add a special case to handle changing the stack permissions in this way.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-06-16 13:03:51 +01:00
Richard Henderson d35b261c7a s390x: Avoid _llseek.
There's no _llseek on s390x either.  Replace the existing
test for __x86_64__ with a functional test for __NR_llseek.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-06-11 18:15:35 +02:00
Riku Voipio 9e42382fc1 linux-user: do not warn for missing pselect6
Libc will fallback gracefully if pselect6 is not available. Thus put
pselect6 to nowarn until the atomicity issues of the original pselect6
patch are dealt with.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Cc: Michael Casadevall <mcasadevall@ubuntu.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 18:42:37 +02:00
Richard Henderson a5b3b13bed alpha-linux-user: Fix sigprocmask.
Alpha passes oldset by value in a register, and returns the newset
as the return value; as compared to the standard implementation in
which both are passed by reference.  This requires being able to
distinguish negative return values that are not errors.  Do this in
the same way as the Alpha Linux kernel, by storing a zero in V0 in
the implementation of the syscall.

At the same time, fix a think-o in the regular sigprocmask path in
which we passed the target, rather than the host, HOW value.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 16:22:21 +00:00
Richard Henderson f43ce12b47 alpha-linux-user: Fix sigsuspend parameters.
Alpha passes the signal set in a register, not by reference.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 16:22:21 +00:00
Richard Henderson 9231733a82 alpha-linux-user: Fix getxpid.
Put ppid in the second return register.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 16:22:21 +00:00
Richard Henderson fb41a66edd alpha-linux-user: Fix pipe return mechanism.
At the same time, tidy the code wrt MIPS and SH4 which have the
same two register return mechanism.  Fix confusion between pipe
and pipe2 with an explicit flags=0, when the guest will not be
using the two register return mechanism.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 16:22:20 +00:00
Richard Henderson 7dd46c02e4 alpha-linux-user: Fix brk error return.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-21 16:22:20 +00:00
takasi-y@ops.dti.ne.jp 81bbe906c8 linux-user: rlimit conversion between host and target.
rlim_t conversion between host and target added.
Otherwise there are some incorrect case like
- RLIM_INFINITY on 32bit target -> 64bit host.
- RLIM_INFINITY on 64bit host -> mips and sparc target ?
- Big value(for 32bit target) on 64bit host -> 32bit target.

One is added into getrlimit, setrlimit, and ugetrlimit. It converts both
RLIM_INFINITY and value bigger than target can hold(>31bit) to RLIM_INFINITY.

Another one is added to guest_stack_size calculation introduced by
703e0e89. The rule is mostly same except the result on the case is keeping
the value of guest_stack_size.

Slightly tested for SH4, and x86_64 -linux-user on x86_64-pc-linux host.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-05-18 19:30:10 +02:00
Richard Henderson a4b388ff51 target-alpha: Enable NPTL.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-27 05:50:41 +02:00
Richard Henderson ed18c5ce1d linux-user: Fix sparc32plus stat64 syscalls.
Check TARGET_ABI_BITS, not TARGET_LONG_BITS, when deciding
whether or not the guest needs special 64-bit stat translation.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-04-26 17:30:17 +00:00
takasi-y@ops.dti.ne.jp e00ac24953 linux-user: do_shmdt(): Fix page_set_flags's 2nd arg.
2nd arg of page_set_flags() should be start+size, but size.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-14 00:19:56 +02:00
Stefan Weil a1606b0baa Fix compilation with missing inotify_init1
Commit c05c7a7306
breaks cross compilation for mips (and other
compilations without CONFIG_INOTIFY1):

make[1]: Entering directory `/qemu/bin/mips'
  CC    i386-linux-user/syscall.o
cc1: warnings being treated as errors
/qemu/linux-user/syscall.c: In function ‘do_syscall’:
/qemu/linux-user/syscall.c:7067: error: implicit declaration of function ‘sys_inotify_init1’

Cc: Riku Voipio <riku.voipio@nokia.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-04-01 21:51:59 +02:00
Aurelien Jarno 60e99246d6 linux-user/ia64: workaround ia64 strangenesses
ia64 has some strangenesses that need to be workaround:
- it has a __clone2() syscall instead of the using clone() one, with
  different arguments, and which is not declared in the usual headers.
- ucontext.uc_sigmask is declared with type long int, while it is
  actually of type sigset_t.
- uc_mcontext, uc_sigmask, uc_stack, uc_link are declared using #define,
  which clashes with the target_ucontext fields. Change their names to
  tuc_*, as already done for some target architectures.
2010-04-01 21:51:58 +02:00
Riku Voipio c05c7a7306 linux-user: add inotify_init1 syscall support
New syscall which gets actively used when you have a
fresh kernel.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-26 17:15:10 +01:00
takasi-y@ops.dti.ne.jp 597c0212a7 linux-user: Fix syscall pipe2() retval on sh4
On linux/sh4
 pipe() return values by r0:r1 as SH C calling convention.
 pipe2() return values on memory as traditional unix way.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-06 19:35:18 +01:00
Richard Henderson 6049f4f831 alpha-linux-user: Implement signals.
Move userland PALcode handling into linux-user main loop so that
we can send signals from there.  This also makes alpha_palcode.c
system-level only, so don't build it for userland.  Add defines
for GENTRAP PALcall mapping to signals.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-28 17:54:52 +01:00
Loïc Minier da79030f47 linux-user: adapt uname machine to emulated CPU
This patch for linux-user adapts the output of the emulated uname()
syscall to match the configured CPU.  Tested with x86, x86-64 and arm
emulation.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Loïc Minier <lool@dooz.org>
2010-02-06 17:19:43 +01:00
Vince Weaver 8b0ee8c576 alpha: fix stat64 issue
The stat64/fstat64 syscalls are broken for alpha linux-user.

This is because Alpha, even though it is native 64-bits, has a stat64
syscall that is different than regular stat.  This means that the
"TARGET_LONG_BITS==64" check in syscall.c isn't enough.  Below is
a patch that fixes things for me, although it might not be the cleanest
fix.

This issue keeps sixtrack and fma3d spec2k benchmarks from running.

Signed-off-by: Vince Weaver <vince@csl.cornell.edu>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-01-14 15:59:59 +01:00
Richard Henderson ba0e276db4 target-alpha: Fixes for alpha-linux syscalls.
1. Add correct definitions of error numbers.
2. Implement SYS_osf_sigprocmask
3. Implement SYS_osf_get/setsysinfo for IEEE_FP_CONTROL.

This last requires exposing the FPCR value to do_syscall.
Since this value is actually split up into the float_status,
expose routines from helper.c to access it.

Finally, also add a float_exception_mask field to float_status.
We don't actually use it to control delivery of exceptions to
the emulator yet, but simply hold the value that we placed there
when loading/storing the FPCR.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-13 20:32:36 +01:00
Blue Swirl b4558d7481 (x86/Sparc/PPC)-user: fix cpu_copy
b55a37c981 moved the call to cpu_reset
to user emulators. But cpu_copy also initializes a CPU structure, so add the
call also there.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 16:34:12 +00:00
Jan-Simon Möller dab46405d9 Re: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer
This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 . failing call:
mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address)

correct call:
mount("rootfs", "/", 0x37ab0, MS_MGC_VAL|MS_REMOUNT, NULL) = 0

Signed-off-by:  Jan-Simon Möller  <dl9pf@gmx.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-17 21:52:43 +03:00
Ulrich Hecht f7680a5593 linux-user: KD/VT/FB ioctls
everything needed to run SDL on a framebuffer device in the userspace emulator

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-17 11:38:00 +03:00
Ulrich Hecht 691372066c linux-user: getpriority errno fix
getpriority returned wrong errno; fixes LTP test getpriority02.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-15 23:55:55 +03:00
Ulrich Hecht d092793872 implementations of dup3 and fallocate that are good enough to fool LTP
updated fallocate check to new configure, added dup3 check as suggested
by Jan-Simon Möller.

Riku: updated to apply to current git.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-15 23:55:55 +03:00
Anthony Liguori c227f0995e Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.

The naming convention is goofy and it causes a massive merge problem.  Something
like this _must_ be presented on the list first so people can provide input
and cope with it.

This reverts commit 99a0949b72.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01 16:12:16 -05:00
malc 99a0949b72 Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the time
being.

Signed-off-by: malc <av1474@comtv.ru>
2009-10-01 22:45:02 +04:00
Michael S. Tsirkin e8bbe36c03 linux-user: fix coding style nit
Put space between = and & when taking a pointer,
to avoid confusion with old-style "&=".

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-30 18:56:44 +00:00
malc fbd5de9b69 F_DUPFD_CLOEXEC is not universally available
The same issue (and the same patch to the byte) was experienced/proposed
by Vince Weaver.

Signed-off-by: malc <av1474@comtv.ru>
2009-09-10 20:27:36 +04:00
Ulrich Hecht 12727917db linux-user: zero fstat buffer to initialize nsec fields
The fstat implementation does not initialize the nanosecond fields in the
stat buffer; this caused funny values to turn up there, preventing, for
instance, cp -p from preserving timestamps because utimensat rejected
the out-of-bounds nanosecond values. Resetting the entire structure
to zero fixes that.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:35 +03:00
Ulrich Hecht e72d2cc781 linux-user: fadvise64 implementation
good enough to pass all LTP fadvise64 tests

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:35 +03:00
Ulrich Hecht d83c8733b7 linux-user: enable getdents for > 32-bit systems
works perfectly fine with the example from getdents(2) and passes the LTP
tests (tested with s390x on x86_64 emulation)

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:34 +03:00
Ulrich Hecht 7e22e54602 linux-user: fcntl fixes for LTP
Fixes swaps on l_pid which were pretty much of random size. Implements
F_SETLEASE, F_GETLEASE. Now passes all LTP fcntl tests.

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:34 +03:00
Nathan Froyd 8ec9cf8971 linux-user: fix mq_* compilation problems
mqueue.h is only available if __NR_mq_open is defined.  So don't include
it unconditionally.  Similarly, the mq_* family of syscalls depend on
__NR_mq_open.  Finally, the copy_{from,to}_user_mq_attr functions should
not be defined unconditionally, but only if we're going to use the mq_*
syscalls.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:34 +03:00
Laurent Vivier c761c15403 m68k, linux-user: enable sigaltstack()
As setup_frame() and setup_rt_frame() are now implemented we can now
enable sigaltstack().

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:34 +03:00
Riku Voipio c2882b9654 linux-user: add eventfd support
Straightforward implementation. This syscall is rare enough that we
don't need to support the odder cases, just disable it if host glibc
is too old.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:26 +03:00
Nathan Froyd a16aae0ca4 linux-user: make FUTEX_* calls honor timeout parameter
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: malc <av1474@comtv.ru>
2009-08-03 20:33:42 +04:00
Juan Quintela 2f7bb8780a rename USE_NPTL to CONFIG_USE_NPTL
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 14:10:55 -05:00
Juan Quintela 9788c9cadf rename HAVE_GPROF to TARGET_GPROF
Use was not consistent, in Makefile was TARGET_GPROF and in *h HAVE_GPROF

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-27 14:09:21 -05:00
Blue Swirl 0bf9e31af1 Fix most warnings (errors with -Werror) when debugging is enabled
I used the following command to enable debugging:
perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * */* */*/*

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-20 17:19:25 +00:00
Blue Swirl 8167ee8839 Update to a hopefully more future proof FSF address
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-16 20:47:01 +00:00
Ulrich Hecht 666bcd913b getrlimit conversion mix-up
Fixes getrlimit implementation that overwrote the result of the syscall
instead of converting it

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:02:28 +03:00
Ulrich Hecht 719f908e3a wrap path for access syscall
Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:02:28 +03:00
Ulrich Hecht 98818189ea 64-bit clean socketcall syscall
makes socketcall 64-bit clean so it works on 64-bit big-endian systems

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:02:27 +03:00
Ulrich Hecht 784ccfdb36 pipe argument should not be signed
pipedes is an address, it should not be signed (breaks for addresses
> 0x80000000)

Signed-off-by: Ulrich Hecht <uli@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:02:27 +03:00
vibi sreenivasan 7b8118e823 linux-user/syscall.c: remove warning: ‘array’ may be used uninitialized in this function
Removes the following warning

CC    i386-linux-user/syscall.o
cc1: warnings being treated as errors
/media/nfs/qemu/linux-user/syscall.c: In function ‘do_syscall’:
/media/nfs/qemu/linux-user/syscall.c:2219: warning: ‘array’ may be used uninitialized in this function

Signed-off-by: Vibi Sreenivasan <vibi_sreenivasan@cms.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:01:08 +03:00
Arnaud Patard 917507b01e linux-user: check some parameters for some socket syscalls.
This patch is fixing following issues :

- commit 8fea36025b was applied to
  do_getsockname instead of do_accept.
- Some syscalls were not checking properly the memory addresses passed
  as argument
- Add check before syscalls made for cases like do_getpeername() where
  we're using the address parameter after doing the syscall
- Fix do_accept to return EINVAL instead of EFAULT when parameters
  invalid to match with linux behaviour

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-07-08 17:01:08 +03:00
Riku Voipio 03dfe9f871 linux-user: strace now handles guest stringscorrectly [v2]
On Tue, Jun 16, 2009 at 08:19:23PM -0500, Anthony Liguori wrote:
> malc wrote:
>>
>> On my system the above line causes gcc to emit:
>>
>> In file included from /home/malc/x/rcs/git/qemu/linux-user/strace.c:12:
>> /usr/include/linux/futex.h:48: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:48: error: syntax error before '*' token
>> /usr/include/linux/futex.h:63: error: field `list' has incomplete type
>> /usr/include/linux/futex.h:83: error: field `__user' has incomplete type
>> /usr/include/linux/futex.h:83: error: syntax error before '*' token
>> make[1]: *** [strace.o] Error 1

> We had the same problem with usb-linux.c.  It's broken system headers,
> the __user stuff is supposed to get removed as part of the headers
> installation.

> It builds fine on my system (Fedora 10).

Howabout something like this:

commit eb8387cb0eda32a18880664eb5f0ca5c8bf05b45
Author: Riku Voipio <riku.voipio@iki.fi>
Date:   Thu Jun 18 22:44:31 2009 +0300
Subject: linux-user: include futex defines directly

Since some common distributions have broken linux/futex.h, stop
including it. Instead add the defines directly.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-19 02:51:47 +04:00
Laurent Vivier 3f9ac9b39b linux-user: remove duplicate tswap32() from do_getsockopt()
This issue has been detected with tests/linux-tests.c:

linux-test.c:330: getsockopt

327     len = sizeof(val);
328     chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
329     if (val != SOCK_STREAM)
330         error("getsockopt");

In linux-user/syscall.c:do_getsockopt(), we have:
...
        val = tswap32(val);
...
            if (put_user_u32(val, optval_addr))
...

whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".

So the "val = tswap32(val);" is useless and wrong.

This patch removes it.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:58:45 +03:00
Eduardo Habkost d5b3a9b6a9 linux-user/syscall.c: define _ATFILE_SOURCE
Needed to make sure the xxxat() functions are available.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:58:45 +03:00
Arnaud Patard (Rtp) 5f10681186 RFC: fix fcntl support in linux-user - new try
Hi,

This is a new try to fix the fcntl support in linux-user. I tried to
adress all comments but as the previous version is several weeks old,
it's possible that I've missed some.

This patch doesn't handle linux specific fcntl flags. My plan is to get
this version of the patch reviewed/fixed and then, add them if wanted.

Thanks,
Arnaud

Signed-off-by: Arnaud Patard (Rtp) <arnaud.patard@rtp-net.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:58:45 +03:00
vibisreenivasan 3ce34dfb42 linux-user: add tee, splice and vmsplice
Add support for tee, splice and vmsplice.

Originally from: vibi sreenivasan <vibi_sreenivasan@cms.com>

Riku: squashed patches together, added a test to configure
and removed compliler warning by picking up correct type for
splice param

Signed-off-by: vibisreenivasan <vibi_sreenivasan@cms.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:58:07 +03:00
Riku Voipio 099d6b0fe9 linux-user: implement pipe2 [v3]
implement pipe2 syscall.

[v2] fix do_pipe on mips and sh4
[v3] use pipe2 to ensure atomicity, but only when it is available.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Riku Voipio c4d2302e7a add futex wake op
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Martin Mohring a29ccd6382 linux-user: support private futexes
Implemented the same way as in the kernel.

From: Martin Mohring <martin.mohring@opensuse.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Martin Mohring 350d1779f8 linux-user: include linux/fs.h
defines FIGETBSZ FIBMAP, allowing the respective ioctl's to
be implemented.

From: Martin Mohring <martin.mohring@opensuse.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Lionel Landwerlin 6e3cb58fa2 linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt
linux-user: Added IP_(UN)BLOCK_SOURCE/IP_(ADD|DROP)_SOURCE_MEMBERSHIP flags to setsockopt

Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Lionel Landwerlin b975b83bec linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt
linux-user: Added IP_ADD_MEMBERSHIP/IP_DROP_MEMBERSHIP flags to setsockopt

Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:29 +03:00
Arnaud Patard 6f932f9172 Return EOPNOTSUPP instead of ENOSYS for *xattr* syscalls
In current code, we're sending ENOSYS to target when a syscall for the
xattrs is done. This makes applications like ls complain loudly about
that and breaks scripts parsing the output. Moreover, iirc, implemented
features of filesystems are are sending EOPNOTSUPP (I've not checked so
I may be a little bit wrong on that...).
So, I'm proposing to return -EOPNOTSUPP and make ls happy

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Arnaud Patard 44607123c4 Fix struct termios host - target translation
When converting the termios structure between host and target in
target_to_host_termios and host_to_target_termios, the c_cc[] array is
never initialised.
Calling memset() before using it allows to run successfully "stty echo /
stty -echo" on arm-linux-user target (host being x86 and mips).

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Riku Voipio ebc996f3b1 linux-user: fix utimensat
The glibc function for utimensat glibc returns -EINVAL when the path is null
which is a different behaviour with the syscall.

path can be null because internally the glibc is using utimensat with
path null when implmenting futimens. If path is null, call futimes
instead.

don't try to copy timespec from user if is NULL.

Add configure check for older systems

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Mika Westerberg 74d753ac86 linux-user: strace now handles guest strings correctly [v2]
- to not to break strace with GUEST_BASE is set:
- Strace now can load and print guest strings correctly.
- Added printing support for commonly used flags in some syscalls
  (e.g open, creat, mmap etc.)

v2:
- fix strace.c build on etch
- add futex print to strace

Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Mika Westerberg edf8e2af14 linux-user: implemented ELF coredump support for ARM target
When target process is killed with signal (such signal that
should dump core) a coredump file is created.  This file is
similar than coredump generated by Linux (there are few exceptions
though).

Riku Voipio: added support for rlimit

Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Riku Voipio 88a8c98455 Implement shm* syscalls and fix 64/32bit errors
No regressions were observed on either 64bit or 32bit
IA hosts.

Patch based on original patches by:
  Kirill A. Shutemov <kirill@shutemov.name>
  - Implement shm* syscalls
  - Fix and cleanup IPCOP_shm* ipc calls handling

Depends on "export mmap_find_vma for shmat" patch.

Various whitespace uglifications applied to minimize
patch size.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16 16:56:28 +03:00
Nathan Froyd 1e9fa73016 fix gdbstub support for multiple threads in usermode, v3
When debugging multi-threaded programs, QEMU's gdb stub would report the
correct number of threads (the qfThreadInfo and qsThreadInfo packets).
However, the stub was unable to actually switch between threads (the T
packet), since it would report every thread except the first as being
dead.  Furthermore, the stub relied upon cpu_index as a reliable means
of assigning IDs to the threads.  This was a bad idea; if you have this
sequence of events:

initial thread created
new thread #1
new thread #2
thread #1 exits
new thread #3

thread #3 will have the same cpu_index as thread #1, which would confuse
GDB.  (This problem is partly due to the remote protocol not having a
good way to send thread creation/destruction events.)

We fix this by using the host thread ID for the identifier passed to GDB
when debugging a multi-threaded userspace program.  The thread ID might
wrap, but the same sort of problems with wrapping thread IDs would come
up with debugging programs natively, so this doesn't represent a
problem.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
2009-06-04 10:04:49 +01:00
Edgar E. Iglesias b779e29ed8 microblaze: linux-user support.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2009-05-26 21:10:28 +02:00
Paul Brook 909b69cf52 Only define __llseek if it is going to be used
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-19 15:58:52 +01:00
Blue Swirl 001faf3269 Replace gcc variadic macro extension with C99 version
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-05-13 17:53:17 +00:00
aurel32 465c9f0630 linux-user: Linux kernel's fchmodat and faccessat have three args (no 4th arg)
In Linux kernel, fchmodat() and faccessat() take tree args.
4th value <int flags> is only processed by libc.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7187 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-19 08:52:17 +00:00
aurel32 e5289087ed linux-user: fix IPCOP_sem* and implement sem*
Fix and cleanup IPCOP_sem* ipc calls handling and
implement sem* syscalls.

Riku:

1) Uglify whitespace so that diff gets smaller and easier
to review

2) use __get_user in target_to_host_sembuf

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7184 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-18 16:16:12 +00:00
aurel32 8690e42010 linux-user: fix inotify syscalls
Configure test was broken, so the breakage of the #ifdef'd
code was not noticed.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7134 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-17 13:50:32 +00:00
pbrook 1d9d8b551d Translate signal values in exit status.
Signed-off-by: Paul Brook <paul@codesourcery.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7131 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-16 15:17:02 +00:00
aurel32 aaf4ad3913 linux-user: fix getcwd syscall
The patch called "prefer glibc over direct syscalls" (commit 7118) has
replaced the getcwd syscall with a call to the glibc. With this change,
the syscall is returning -1 in error case and 0 otherwise.
This is problematic as the sys_getcwd syscall should return the number
of bytes written to the buffer including the '\0'.

Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
Acked-By: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7130 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-16 14:17:14 +00:00
aurel32 fda3374454 linux-user: fix warnings introduced by r7118
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7120 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 17:12:01 +00:00
aurel32 3b3f24add0 linux-user: prefer glibc over direct syscalls
The openat/*at syscalls are incredibly common with modern coreutils,
calling them directly via syscalls breaks for example fakeroot. Use
glibc stubs whenever directly available and provide old syscall
calling for people still using older libc.

Patch originally from Mika Westerberg, Adapted to
apply to current trunk and cleaned up by Riku Voipio.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7118 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 16:12:13 +00:00
aurel32 be09ac4194 linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls
- This check is not needed because kernel will check whether given
  buffer is too small and there is no upper limit for size of the buffer.

From: Mika Westerberg <mika.westerberg@iki.fi>

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7117 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 16:12:06 +00:00
aurel32 607175e0fb linux-user: unix sockets - fix running dbus
dbus sends too short (according to man 7 unix) addrlen for it's
unix socket. I've been told that happens with other applications
as well. Linux kernel doesn't appear to mind, so I guess
we whould be tolerant as well. Expand sockaddr with +1 to fit
the \0 of the pathname passed.

(scratchbox1 qemu had a very different workaround for the same issue).

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7116 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 16:11:59 +00:00
aurel32 24e1003a52 linux-user: Added posix message queue syscalls except mq_notify
Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7114 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 16:11:43 +00:00
aurel32 9d33b76b20 linux-user: fix fstatat64()/newfstatat() syscall implementation
There are two different syscall names for the same goal.

On systems with sizeof(long) == 64 it calls newfstatat.
On systems with sizeof(long) == 32 it calls fstatat64.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7050 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-08 23:07:05 +00:00
aurel32 dbfe4c3611 linux-user: fix problems with inotify syscalls
The sys_inotify* calls are defined if the target supports them and the
host supports the necessary syscalls.  But the syscalls are handled if
the target supports them.  This situation leads to compilation failures
when the host doesn't support the necessary syscalls, as the linker will
complain about undefined functions.

Fix this state of affairs by making the handling conditions the same as
the call definition conditions.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Acked-By: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7038 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-08 21:29:30 +00:00
pbrook c276471991 The _exit syscall is used for both thread termination in NPTL applications,
and process termination in legacy applications.  Try to guess which we want
based on the presence of multiple threads.

Also implement locking when modifying the CPU list.


Signed-off-by: Paul Brook <paul@codesourcery.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6735 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-07 15:24:59 +00:00
aurel32 bedf26e6b4 linux-user: Remove incorrect break;
Reported-By: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6503 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-03 19:55:26 +00:00
aurel32 d088d664f2 linux-user: identify running binary in /proc/self/exe
Some applications like to test /proc/self/exe to find
out who they are. Fake the result of readlink() for
them. Use realpath() to return full path to binary
(which the links /proc/self/exe are)

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6485 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-30 20:09:01 +00:00
aurel32 38d840e679 linuw-user fix: read() and acct() on NULL arguments
Returning efault in these cases is not correct. Originally
proposed by Thayne Harbaugh in 2007:
http://www.mail-archive.com/qemu-devel@nongnu.org/msg14658.html

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6481 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-30 19:48:17 +00:00
aurel32 8f7aeaf6b3 linux-user: return EINVAL on incorrect sockaddr
From: Lauro Ramos Venancio <lauro.venancio@gmail.com>

Fixes ltp test accept01

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6479 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-30 19:47:57 +00:00
aurel32 8fea36025b linux-user: fix accept(2) with NULL peer
Based on scratchbox2 patch by Mika Westerberg

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6478 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-30 19:47:47 +00:00
edgar_igl b15ad61c2e CRIS: Clone flags are reversed on CRIS.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6222 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 19:43:47 +00:00
edgar_igl ef96779bc3 CRIS: Implement set_thread_area for CRIS.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6210 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 14:19:38 +00:00
blueswir1 530e7615ce Fix more FSF addresses
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6192 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-05 18:11:53 +00:00
aurel32 2b1319c85c User-mode GDB stub improvements - handle fork
Close gdbserver in child processes, so that only one stub tries to talk
to GDB at a time.  Updated from an earlier patch by Paul Brook.

Signed-off-by: Daniel Jacobowitz <dan@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6095 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-18 22:44:04 +00:00
blueswir1 3f911a51b2 Fix warning about unused shm_regions
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6001 c046a42c-6fe2-441c-8c8c-71466251a162
2008-12-13 11:37:02 +00:00
aurel32 64b4d28c38 target-alpha: implement getxuid and getxgid syscalls
This patch implemented the setxuid and setxgid syscalls for Alpha.
These syscalls return two values, both uid/euid and gid/egid.
In addition to returning the first value in $v0, the additional
value is returned in the $a4 register.

The syscalls are used instead of the separate syscalls for those values
used on other architectures (this is probably because Alpha Linux started
out syscall compatible with DEC/OSF/Tru64).

With this patch, the perlbmk benchmarks from Spec2000 run properly.

(Vince Weaver)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5722 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-14 17:20:15 +00:00
balrog e441570f8a use target_mmap() to allocate idt, gdt and ldt (Kirill A. Shutemov).
env->*dt.base should fit target address space, so we should use
target_mmap to allocate them.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5666 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-10 02:55:33 +00:00
aurel32 6d946cdae0 User qemu profiling
- Makefile.target:  re-enable profiling for user qemu.  It seems
  profiling was (accidently?) removed by commit 3937

- syscall.c:
    * add an include to get _mcleanup prototype
    * add a call to _mcleanup for exit_group in a way
      similar to what is done for exit

(Laurent Desnogues)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5642 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-06 16:15:18 +00:00
balrog 6de645c7d1 Recvmsg must return the number of bytes received (Lauro Ramos Venancio).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5564 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-28 10:26:29 +00:00
balrog d732dcb442 Fix iovec for the case with invalid elements (Lauro Ramos Venancio).
We must call the writev even if an iovec element is invalid. For
example, if the second element is invalid, the linux process the first
one.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5562 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-28 10:21:03 +00:00
balrog a2f86d8e08 Use the host exit syscall for exiting (Lauro Ramos Venancio).
We can't call the libc _exit function because it calls the exit_group
host syscall. We must call directly the exit host syscall.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5561 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-28 10:18:28 +00:00
blueswir1 b1d8e52e63 Fix undeclared symbol warnings from sparse
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5539 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-26 13:43:07 +00:00
blueswir1 be15b141e0 Replace uses of strncpy (a GNU extension) with Qemu pstrcpy
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5531 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-25 11:21:28 +00:00
aurel32 00b229ac6a Add missing return statement (fixes compiler warning).
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5523 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-24 13:12:52 +00:00