summaryrefslogtreecommitdiff
path: root/linux-user/qemu.h
AgeCommit message (Collapse)AuthorFilesLines
2011-01-07Remove dead code for ARM semihosting commandline handlingWolfgang Schildbach1-1/+0
There are some bits in the code which were used to store the commandline for the semihosting call. These bits are now write-only and can be removed. Signed-off-by: Wolfgang Schildbach <wschi@dolby.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2010-12-03linux-user: remove unnecessary local from __get_user(), __put_user()Peter Maydell1-4/+2
Remove an unnecessary local variable from the __get_user() and __put_user() macros. This avoids confusing compilation failures if the name of the local variable ('size') happens to be the same as the variable the macro user is trying to read/write. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2010-12-03linux-user: fix memory leaks with NPTL emulationNathan Froyd1-2/+0
Running programs that create large numbers of threads, such as this snippet from libstdc++'s pthread7-rope.cc: const int max_thread_count = 4; const int max_loop_count = 10000; ... for (int j = 0; j < max_loop_count; j++) { ... for (int i = 0; i < max_thread_count; i++) pthread_create (&tid[i], NULL, thread_main, 0); for (int i = 0; i < max_thread_count; i++) pthread_join (tid[i], NULL); } in user-mode emulation will quickly run out of memory. This is caused by a failure to free memory in do_syscall prior to thread exit: /* TODO: Free CPU state. */ pthread_exit(NULL); The first step in fixing this is to make all TaskStates used by QEMU dynamically allocated. The TaskState used by the initial thread was not, as it was allocated on main's stack. So fix that, free the cpu_env, free the TaskState, and we're home free, right? Not exactly. When we create a thread, we do: ts = qemu_mallocz(sizeof(TaskState) + NEW_STACK_SIZE); ... new_stack = ts->stack; ... ret = pthread_attr_setstack(&attr, new_stack, NEW_STACK_SIZE); If we blindly free the TaskState, then, we yank the current (host) thread's stack out from underneath it while it still has things to do, like calling pthread_exit. That causes problems, as you might expect. The solution adopted here is to let the C library allocate the thread's stack (so the C library can properly clean it up at pthread_exit) and provide a hint that we want NEW_STACK_SIZE bytes of stack. With those two changes, we're done, right? Well, almost. You see, we're creating all these host threads and their parent threads never bother to check that their children are finished. There's no good place for the parent threads to do so. Therefore, we need to create the threads in a detached state so the parent thread doesn't have to call pthread_join on the child to release the child's resources; the child does so automatically. With those three major changes, we can comfortably run programs like the above without exhausting memory. We do need to delete 'stack' from the TaskState structure. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2010-10-03Replace most gcc format attributes by macro GCC_FMT_ATTR (format checking)Stefan Weil1-1/+1
Since version 4.4.x, gcc supports additional format attributes. __attribute__ ((format (gnu_printf, 1, 2))) should be used instead of __attribute__ ((format (printf, 1, 2)) because QEMU always uses standard format strings (even with mingw32). The patch replaces format attribute printf / __printf__ by macro GCC_FMT_ATTR which uses gnu_printf if supported. It also removes an #ifdef __GNUC__ (not needed any longer). Cc: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-07-29linux-user: Reduce lseek+reads while loading elf files.Richard Henderson1-1/+6
Define BPRM_BUF_SIZE to 1k and read that amount initially. If the data we want from the binary is in this buffer, use it instead of reading from the file again. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2010-06-16Usermode exec-stack fixPaul Brook1-0/+1
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-04-25linux-user: Remove ELFLOAD32.Richard Henderson1-5/+0
The ABI-specific types used by linux_binprm and image_info are different after forcing TARGET_ABI32 on. Which means that the parameters that load_elf_binary_multi sees are not those that loader_exec passed. This is inherently broken and is more trouble than it's worth fixing. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-27linux-user: Use RLIMIT_STACK for default stack size.Richard Henderson1-1/+1
The current default stack limit of 512kB is far too small; a fair number of gcc testsuite failures (for all guests) are directly attributable to this. Using the -s option in every invocation of the emulator is annoying to say the least. A reasonable compromise seems to be to honor the system rlimit. At least on two Linux distributions, this is set to 8MB and 10MB respectively. If the system does not limit the stack, then we're no worse off than before. At the same time, rename the variable from x86_stack_size and change the ultimate fallback size from 512kB to 8MB. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-12linux-user: Fix mmap_find_vma returning invalid addresses.Richard Henderson1-2/+0
Don't return addresses that aren't properly aligned for the guest, e.g. when the guest has a larger page size than the host. Don't return addresses that are outside the virtual address space for the target, by paying proper attention to the h2g/g2h macros. At the same time, place the default mapping base for 64-bit guests (on 64-bit hosts) outside the low 4G. Consistently interpret mmap_next_start in the guest address space. Signed-off-by: Richard Henderson <rth@twiddle.net>
2009-10-01Revert "Get rid of _t suffix"Anthony Liguori1-4/+4
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 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01Get rid of _t suffixmalc1-4/+4
Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
2009-09-12Fix sys-queue.h conflict for goodBlue Swirl1-1/+1
Problem: Our file sys-queue.h is a copy of the BSD file, but there are some additions and it's not entirely compatible. Because of that, there have been conflicts with system headers on BSD systems. Some hacks have been introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896, f40d753718c72693c5f520f0d9899f6e50395e94, 96555a96d724016e13190b28cffa3bc929ac60dc and 3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile. Solution: Avoid the conflict entirely by renaming the functions and the file. Revert the previous hacks. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-15user: compile path.c only onceBlue Swirl1-2/+0
Also merge bsd-user/path.c and linux-user/path.c. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-27rename USE_NPTL to CONFIG_USE_NPTLJuan Quintela1-4/+4
Signed-off-by: Juan Quintela <quintela@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-17Userspace guest address offsettingPaul Brook1-0/+3
Re-implement GUEST_BASE support. Offset guest ddress space by default if the guest binary contains regions below the host mmap_min_addr. Implement support for i386, x86-64 and arm hosts. Signed-off-by: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-07-08linux-user: increment MAX_ARG_PAGESArnaud Patard1-1/+1
There's a error When doing something like that : find / -type f -print0 | xargs -0 echo [ done in a arm chroot with qemu-arm and linux binfmt stuff or with find / -type f -print0 | qemu-arm -L <path> <path>/usr/bin/xargs -0 echo ] Doing this outsite qemu is fine. The problem was the huge number of parameters. Increasing MAX_ARG_PAGES is fixing that. While I was at it, I've modified linux-user/main.c to report error code of loader_exec. It helps to debug/know what's wrong. Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-06-16linux-user: implemented ELF coredump support for ARM targetMika Westerberg1-2/+11
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-16export mmap_find_vma for shmatRiku Voipio1-0/+1
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-05-19Avoid implicit truncation compiler warningsPaul Brook1-2/+2
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-04-16Translate signal values in exit status.pbrook1-0/+1
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-03-07The _exit syscall is used for both thread termination in NPTL applications,pbrook1-0/+5
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-01-30linux-user: identify running binary in /proc/self/exeaurel321-0/+1
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
2008-12-08linux-user: Move abi_* typedefs into qemu-types.haurel321-19/+1
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5954 c046a42c-6fe2-441c-8c8c-71466251a162
2008-10-05Export x86_stack_size in qemu.hblueswir11-0/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5427 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-30Fix some warnings that would be generated by gcc -Wredundant-declsblueswir11-2/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5115 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-07Multithreaded locking fixes.pbrook1-1/+13
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4692 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-03Spelling fixes, by Stefan Weil.ths1-1/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4655 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-02Multithreaded locking for mmap().pbrook1-0/+6
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4654 c046a42c-6fe2-441c-8c8c-71466251a162
2008-05-31Mark host brk() area as reserved.pbrook1-0/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4637 c046a42c-6fe2-441c-8c8c-71466251a162
2008-05-31Make signal queues per thread.pbrook1-3/+23
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4635 c046a42c-6fe2-441c-8c8c-71466251a162
2008-05-30Perform target->host signal mapping for *kill syscalls.pbrook1-0/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4625 c046a42c-6fe2-441c-8c8c-71466251a162
2008-05-06Update ARM rt_frame layout.pbrook1-0/+1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4365 c046a42c-6fe2-441c-8c8c-71466251a162
2007-12-24Fix a compiler error with DEBUG_REMAP enabled (Thayne Harbaugh).balrog1-1/+6
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3845 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-16suppressed tgetx and tputx (initial patch by Thayne Harbaugh)bellard1-18/+29
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3653 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-14always define TARGET_ABI32 if 32 bit userbellard1-0/+4
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3643 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-14suppressed page_unprotect_range() - fixed access_ok()bellard1-2/+5
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3641 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-11use correct typesbellard1-3/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3596 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-11Linux user memory access API change (initial patch by Thayne Harbaugh)bellard1-47/+74
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3583 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-03Fix some compiler warnings.ths1-0/+6
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3520 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-02EFAULT - update __get_user() __put_user(), by Thayne Harbaugh.ths1-13/+13
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3508 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-02EFAULT - verify pages are in cache and are read/write, by Thayne Harbaugh.ths1-1/+2
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3506 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-01Strace for userland emulation, by Stuart Anderson and Thayne Harbaugh.ths1-0/+8
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3502 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-14 Support for 32 bit ABI on 64 bit targets (only enabled Sparc64)blueswir11-43/+53
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3396 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-09 Support for executing 32 bit SPARC32PLUS files for Sparc64 user emulatorblueswir11-0/+5
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3378 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-07Fix host and target longs confusions (continued).j_mayer1-13/+13
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3345 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-05 Implement sparc64_[gs]et_contextblueswir11-0/+3
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3334 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-30Fix mmap to handle differing host/target page sizes, by Edgar E. Iglesias.ths1-2/+2
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3291 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27linux-user sigaltstack() syscall, by Thayne Harbaugh.ths1-0/+4
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3252 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-27New ppc64-linux-user target.j_mayer1-0/+1
Allow use of PowerPC 970 for debugging (softmmu would not run, for now). git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3246 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-26Convert syscall arguments and return value from long to int or target_long.j_mayer1-3/+4
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3241 c046a42c-6fe2-441c-8c8c-71466251a162