summaryrefslogtreecommitdiffstats
path: root/linux-user
Commit message (Collapse)AuthorAgeFilesLines
* translate-all: ensure host page mask is always extended with 1'sPaolo Bonzini2015-12-022-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | Anthony reported that >4GB guests on Xen with 32bit QEMU broke after commit 4ed023c ("Round up RAMBlock sizes to host page sizes", 2015-11-05). In that patch sizes are masked against qemu_host_page_size/mask which are uintptr_t, and thus 32bit on a 32bit QEMU, even though the ram space might be bigger than 4GB on Xen. Since ram_addr_t is not available on user-mode emulation targets, ensure that we get a sign extension when masking away the low bits of the address. Remove the ~10 year old scary comment that the type of these variables is probably wrong, with another equally scary comment. The new comment however does not have "???" in it, which is arguably an improvement. For completeness use the alignment macros in linux-user and bsd-user instead of manually doing an &. linux-user and bsd-user are not affected by the Xen issue, however. Reviewed-by: Juan Quintela <quintela@redhat.com> Reported-by: Anthony PERARD <anthony.perard@citrix.com> Fixes: 4ed023ce2a39ab5812d33cf4d819def168965a7f Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* linux-user/syscall: Replace g_malloc0 + memcpy with g_memdupThomas Huth2015-11-061-2/+1
| | | | | | | | | | | No need to use g_malloc0 to zero the memory if we memcpy to the whole buffer afterwards anyway. Actually, there is even a function which combines both steps, g_memdup, so let's use this function here instead. Signed-off-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* linux-user: Remove type casts to union typeStefan Weil2015-10-081-4/+4
| | | | | | | | | | | | | Casting to a union type is a gcc (and clang) extension. Other compilers might not support it. This is not a problem today, but the type casts can be removed easily. Smatch now no longer complains like before: linux-user/syscall.c:3190:18: warning: cast to non-scalar linux-user/syscall.c:7348:44: warning: cast to non-scalar Cc: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* linux-user: Use g_new() & friends where that makes obvious senseMarkus Armbruster2015-10-083-3/+3
| | | | | | | | | | | | | | | g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patch as in commit b45c03f. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* s/cpu_get_real_ticks/cpu_get_host_ticks/Christopher Covington2015-10-081-2/+2
| | | | | | | | | | | This should help clarify the purpose of the function that returns the host system's CPU cycle count. Signed-off-by: Christopher Covington <cov@codeaurora.org> Acked-by: Paolo Bonzini <pbonzini@redhat.com> ppc portion Acked-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* target-tilegx: Use TILEGX_EXCP_SIGNAL instead of TILEGX_EXCP_SEGVRichard Henderson2015-10-071-18/+23
| | | | | | Consolidate signal handling under a single exception. Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-tilegx: Decode ill pseudo-instructionsChen Gang2015-10-071-0/+14
| | | | | | | | | | | | Notice raise and bpt, decoding the constants embedded in the nop addil instruction in the x0 slot. [rth: Generalize TILEGX_EXCP_OPCODE_ILL to TILEGX_EXCP_SIGNAL. Drop validation of signal values.] Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Message-Id: <1443243635-4886-1-git-send-email-gang.chen.5i5j@gmail.com> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user/tilegx: Implement tilegx signal featuresChen Gang2015-10-072-1/+161
| | | | | | | | [rth: Remove the spreg[EX1] handling, as it's irrelevant to user-mode.] Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Message-Id: <1443312618-13641-1-git-send-email-gang.chen.5i5j@gmail.com> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user/syscall_defs.h: Sync the latest si_code from Linux kernelChen Gang2015-10-071-0/+11
| | | | | | | | They content several new macro members, also contents TARGET_N*. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Message-Id: <1443240605-2924-1-git-send-email-gang.chen.5i5j@gmail.com> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: assert that target_mprotect cannot failPaolo Bonzini2015-10-011-4/+1
| | | | | | | | | | | | | All error conditions that target_mprotect checks are also checked by target_mmap. EACCESS cannot happen because we are just removing PROT_WRITE. ENOMEM should not happen because we are modifying a whole VMA (and we have bigger problems anyway if it happens). Fixes a Coverity false positive, where Coverity complains about target_mprotect's return value being passed to tb_invalidate_phys_range. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user/signal.c: Use setup_rt_frame() instead of setup_frame() for ↵Chen Gang2015-10-011-7/+2
| | | | | | | | | | | | target openrisc qemu has already considered about some targets may have no traditional signals. And openrisc's setup_frame() is dummy, but it can be supported by setup_rt_frame(). Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user/syscall.c: Add EAGAIN to host_to_target_errno_table forChen Gang2015-09-281-0/+1
| | | | | | | | Under Alpha host, EAGAIN is redefined to 35, so it need be remapped too. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: add name_to_handle_at/open_by_handle_atLaurent Vivier2015-09-281-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch allows to run example given by open_by_handle_at(2): The following shell session demonstrates the use of these two programs: $ echo 'Can you please think about it?' > cecilia.txt $ ./t_name_to_handle_at cecilia.txt > fh $ ./t_open_by_handle_at < fh open_by_handle_at: Operation not permitted $ sudo ./t_open_by_handle_at < fh # Need CAP_SYS_ADMIN Read 31 bytes $ rm cecilia.txt Now we delete and (quickly) re-create the file so that it has the same content and (by chance) the same inode.[...] $ stat --printf="%i\n" cecilia.txt # Display inode number 4072121 $ rm cecilia.txt $ echo 'Can you please think about it?' > cecilia.txt $ stat --printf="%i\n" cecilia.txt # Check inode number 4072121 $ sudo ./t_open_by_handle_at < fh open_by_handle_at: Stale NFS file handle See the man page for source code. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Return target error number in do_fork()Timothy E Baldwin2015-09-281-2/+3
| | | | | | | | | Whilst calls to do_fork() are wrapped in get_errno() this does not translate return values. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: fix cmsg conversion in case of multiple headersJonathan Neuschäfer2015-09-282-10/+18
| | | | | | | | | | | | | | | | | | | Currently, __target_cmsg_nxthdr compares a pointer derived from target_cmsg against the msg_control field of target_msgh (through subtraction). This failed for me when emulating i386 code under x86_64, because pointers in the host address space and pointers in the guest address space were not the same. This patch passes the initial value of target_cmsg into __target_cmsg_nxthdr. I found and fixed two more related bugs: - __target_cmsg_nxthdr now returns the new cmsg pointer instead of the old one. - tgt_space (in host_to_target_cmsg) doesn't count "sizeof (struct target_cmsghdr)" twice anymore. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: remove MAX_ARG_PAGES limitStefan Brüns2015-09-285-76/+56
| | | | | | | | | | | | Instead of creating a temporary copy for the whole environment and the arguments, directly copy everything to the target stack. For this to work, we have to change the order of stack creation and copying the arguments. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: remove unused image_info membersStefan Brüns2015-09-282-5/+0
| | | | | | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Treat --foo options the same as -fooMeador Inge2015-09-281-0/+4
| | | | | | | | | The system mode binaries provide a similar alias and it makes common options like --version and --help work as expected. Signed-off-by: Meador Inge <meadori@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: use EXIT_SUCCESS and EXIT_FAILURERiku Voipio2015-09-281-36/+36
| | | | | | | | As suggested by Laurent, use EXIT_SUCCESS and EXIT_FAILURE from stdlib.h instead of numeric values. Cc: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Add proper error messages for bad optionsMeador Inge2015-09-281-3/+7
| | | | | | | | | | | | | This patch adds better support for diagnosing option parser errors. The previous implementation just printed the usage text and exited when a bad option or argument was found. This made it very difficult to determine why the usage was being displayed and it was doubly confusing for cases like '--help' (it wasn't clear that --help was actually an error). Signed-off-by: Meador Inge <meadori@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Add -helpMeador Inge2015-09-281-0/+2
| | | | | | | | | This option is already available on the system mode binaries. It would be better if long options were supported (i.e. --help), but this is okay for now. Signed-off-by: Meador Inge <meadori@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Exit 0 when -h is usedMeador Inge2015-09-281-10/+10
| | | | | Signed-off-by: Meador Inge <meadori@codesourcery.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* ppc: Rename ELF_MACHINE to be PPC specificPeter Crosthwaite2015-09-251-0/+1
| | | | | | | | | | | | | | | | Rename ELF_MACHINE to be PPC specific. This is used as-is by the various PPC bootloaders and is locally defined to ELF_MACHINE in linux user in PPC specific ifdeffery. This removes another architecture specific definition from the global namespace (as desired by multi-arch). Cc: Alexander Graf <agraf@suse.de> Cc: qemu-ppc@nongnu.org Reviewed-by: Richard Henderson <rth@twiddle.net> Acked-By: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* arm: Remove ELF_MACHINE from cpu.hPeter Crosthwaite2015-09-251-2/+2
| | | | | | | | | | | | | | | | | | | | The only generic code relying on this is linux-user. Linux user already has a lot of #ifdef TARGET_ customisation so instead, define ELF_ARCH as either EM_ARM or EM_AARCH64 appropriately. The armv7m bootloader can just pass EM_ARM directly, as that is architecture specific code. Note that arm_boot already has its own logic selecting an arm specific elf machine so this makes V7M more consistent with arm_boot. This removes another architecture specific definition from the global namespace. Cc: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Acked-By: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* linux-user: elfload: Provide default for elf_check_archPeter Crosthwaite2015-09-251-24/+4
| | | | | | | | | | | | | | | | | | | | | | | | For many arch's this macro is defined as the predicatable behaviour of checking the argument for eqaulity against ELF_ARCH. Provide a default define as such, so only archs with special handling (usually allowing multiple EM values) need to provide a def. Arches that do any of: 1: provide this def exactly the same way as the new default (alpha, x86_64) 2: check against ELF_MACHINE while defining ELF_ARCH == ELF_MACHINE (arm, aarch64) 3: check against EM_FOO directly while defining ELF_ARCH == EM_FOO (unicore32, sparc32, ppc32, mips, openrisc, sh4, cris, m86k) have their elf_check_arch removed as the default will provide the correct behaviour. Reviewed-by: Richard Henderson <rth@twiddle.net> Acked-By: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* linux_user: elfload: Default ELF_MACHINE to ELF_ARCHPeter Crosthwaite2015-09-251-0/+4
| | | | | | | | | | | In most (but not all) cases, ELF_MACHINE and ELF_ARCH are safely the same. Default ELF_MACHINE to ELF_ARCH. This makes defining ELF_MACHINE optional for target-*/cpu.h when they are known to match. Reviewed-by: Richard Henderson <rth@twiddle.net> Acked-By: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* target-ppc: Fix SRR0 when taking unaligned exceptionsAnton Blanchard2015-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We are setting SRR0 to the instruction before the one causing the unaligned exception. A quick testcase: . = 0x100 .globl _start _start: /* Cause a 0x600 */ li 3,0x1 stwcx. 3,0,3 1: b 1b . = 0x600 1: b 1b Built into something we can load as a BIOS image: gcc -mbig -c test.S ld -EB -Ttext 0x0 -o test test.o objcopy -O binary test test.bin Run with: qemu-system-ppc64 -nographic -bios test.bin Shows an incorrect SRR0 (points at the li): SRR0 0000000000000100 With the patch we get the correct SRR0: SRR0 0000000000000104 Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Alexander Graf <agraf@suse.de>
* target-tilegx: Handle atomic instructionsRichard Henderson2015-09-151-0/+166
| | | | | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
* target-tilegx: Generate SEGV properlyRichard Henderson2015-09-151-0/+3
| | | | | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Conditionalize syscalls which are not defined in tilegxChen Gang2015-09-151-1/+49
| | | | | | | | | | Some of architectures (e.g. tilegx), several syscall macros are not supported, so switch them. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <BLU436-SMTP457D6FC9B2B9BA87AEB22CB9660@phx.gbl> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Support tilegx architecture in linux-userChen Gang2015-09-153-5/+101
| | | | | | | | | | | | | Add main working flow feature, system call processing feature, and elf64 tilegx binary loading feature, based on Linux kernel tilegx 64-bit implementation. [rth: Moved all of the implementation of atomic instructions to a later patch.] Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <BLU436-SMTP938552D42808AA60634582B9660@phx.gbl> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: tilegx: Add architecture related featuresChen Gang2015-09-156-0/+747
| | | | | | | | | | | They are based on Linux kernel tilegx architecture for 64 bit binary, and also based on tilegx ABI reference document, and also reference from other targets implementations. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Message-Id: <BLU436-SMTP2508945F92945BB525605A3B9660@phx.gbl> Signed-off-by: Richard Henderson <rth@twiddle.net>
* Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell2015-09-143-5/+5
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Support for jemalloc * qemu_mutex_lock_iothread "No such process" fix * cutils: qemu_strto* wrappers * iohandler.c simplification * Many other fixes and misc patches. And some MTTCG work (with Emilio's fixes squashed): * Signal-free TCG kick * Removing spinlock in favor of QemuMutex * User-mode emulation multi-threading fixes/docs # gpg: Signature made Thu 10 Sep 2015 09:03:07 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: (44 commits) cutils: work around platform differences in strto{l,ul,ll,ull} cpu-exec: fix lock hierarchy for user-mode emulation exec: make mmap_lock/mmap_unlock globally available tcg: comment on which functions have to be called with mmap_lock held tcg: add memory barriers in page_find_alloc accesses remove unused spinlock. replace spinlock by QemuMutex. cpus: remove tcg_halt_cond and tcg_cpu_thread globals cpus: protect work list with work_mutex scripts/dump-guest-memory.py: fix after RAMBlock change configure: Add support for jemalloc add macro file for coccinelle configure: factor out adding disas configure vhost-scsi: fix wrong vhost-scsi firmware path checkpatch: remove tests that are not relevant outside the kernel checkpatch: adapt some tests to QEMU CODING_STYLE: update mixed declaration rules qmp: Add example usage of strto*l() qemu wrapper cutils: Add qemu_strtoull() wrapper cutils: Add qemu_strtoll() wrapper ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * exec: make mmap_lock/mmap_unlock globally availablePaolo Bonzini2015-09-091-2/+0
| | | | | | | | | | | | | | | | | | There is some iffy lock hierarchy going on in translate-all.c. To fix it, we need to take the mmap_lock in cpu-exec.c. Make the functions globally available. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * replace spinlock by QemuMutex.KONRAD Frederic2015-09-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | spinlock is only used in two cases: * cpu-exec.c: to protect TranslationBlock * mem_helper.c: for lock helper in target-i386 (which seems broken). It's a pthread_mutex_t in user-mode, so we can use QemuMutex directly, with an #ifdef. The #ifdef will be removed when multithreaded TCG will need the mutex as well. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-Id: <1439220437-23957-5-git-send-email-fred.konrad@greensocs.com> Signed-off-by: Emilio G. Cota <cota@braap.org> [Merge Emilio G. Cota's patch to remove volatile. - Paolo] Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * linux-user: call rcu_(un)register_thread on pthread_(exit|create)Emilio G. Cota2015-09-091-0/+2
| | | | | | | | | | | | Signed-off-by: Emilio G. Cota <cota@braap.org> Message-Id: <1440375847-17603-13-git-send-email-cota@braap.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | typofixes - v4Veres Lajos2015-09-112-3/+2
| | | | | | | | | | Signed-off-by: Veres Lajos <vlajos@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | linux-user: Fix warnings caused by missing 'static' attributeStefan Weil2015-09-111-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warnings from the Sparse static analysis tool: linux-user/main.c:40:12: warning: symbol 'filename' was not declared. Should it be static? linux-user/main.c:41:12: warning: symbol 'argv0' was not declared. Should it be static? linux-user/main.c:42:5: warning: symbol 'gdbstub_port' was not declared. Should it be static? linux-user/main.c:43:11: warning: symbol 'envlist' was not declared. Should it be static? Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | maint: remove unused include for assert.hDaniel P. Berrange2015-09-111-1/+0
| | | | | | | | | | | | | | | | | | A number of files were including assert.h but not using any of the functions it provides Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | maint: remove / fix many doubled wordsDaniel P. Berrange2015-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Many source files have doubled words (eg "the the", "to to", and so on). Most of these can simply be removed, but a couple were actual mis-spellings (eg "to to" instead of "to do"). There was even one triple word score "to to to" :-) Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* | target-arm: Wire up HLT 0xf000 as the A64 semihosting instructionPeter Maydell2015-09-071-0/+3
|/ | | | | | | | | | | For the A64 instruction set, the semihosting call instruction is 'HLT 0xf000'. Wire this up to call do_arm_semihosting() if semihosting is enabled. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Christopher Covington <christopher.covington@linaro.org> Tested-by: Christopher Covington <cov@codeaurora.org> Message-id: 1439483745-28752-10-git-send-email-peter.maydell@linaro.org
* linux-user: remove useless macros GUEST_BASE and RESERVED_VALaurent Vivier2015-08-241-10/+10
| | | | | | | | | | | As we have removed CONFIG_USE_GUEST_BASE, we always use a guest base and the macros GUEST_BASE and RESERVED_VA become useless: replace them by their values. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1440420834-8388-1-git-send-email-laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: remove --enable-guest-base/--disable-guest-baseLaurent Vivier2015-08-243-18/+0
| | | | | | | | | | | | | | | | | | All tcg host architectures now support the guest base and as there is no real performance lost, it can be always enabled. Anyway, guest base use can be disabled lively by setting guest base to 0. CONFIG_USE_GUEST_BASE is defined as (USE_GUEST_BASE && USER_ONLY), it should have to be replaced by CONFIG_USER_ONLY in non CONFIG_USER_ONLY parts, but as some other parts are using !CONFIG_SOFTMMU I have chosen to use !CONFIG_SOFTMMU instead. Reviewed-by: Alexander Graf <agraf@suse.de> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1440373328-9788-2-git-send-email-laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Fix MIPS N64 trap and break instruction bugAndrew Bennett2015-07-151-2/+2
| | | | | | | | | | | | | | | For the MIPS N64 ABI when QEMU reads the break/trap instruction so that it can inspect the break/trap code it reads 8 rather than 4 bytes which means it finds the code field from the instruction after the break/trap instruction. This then causes the break/trap handling code to fail because it does not understand the code number. The fix forces QEMU to always read 4 bytes of instruction data rather than deciding how much to read based on the ABI. Signed-off-by: Andrew Bennett <andrew.bennett@imgtec.com> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
* cpu-exec: Purge all uses of ENV_GET_CPU()Peter Crosthwaite2015-07-091-14/+14
| | | | | | | | | | | | | | | | Remove un-needed usages of ENV_GET_CPU() by converting the APIs to use CPUState pointers and retrieving the env_ptr as minimally needed. Scripted conversion for target-* change: for I in target-*/cpu.h; do sed -i \ 's/\(^int cpu_[^_]*_exec(\)[^ ][^ ]* \*s);$/\1CPUState *cpu);/' \ $I; done Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* gdbstub: Change gdbserver_fork() to accept cpu instead of envPeter Crosthwaite2015-07-091-1/+1
| | | | | | | | | | | | | All callsites to this function navigate the cpu->env_ptr only for the function to take the env ptr back to the original cpu ptr. Change the function to just pass in the CPU pointer instead. Removes a core code usage of ENV_GET_CPU() (in gdbstub.c). Cc: Riku Voipio <riku.voipio@iki.fi> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* translate-all: Change tb_flush() env argument to cpuPeter Crosthwaite2015-07-091-1/+1
| | | | | | | | | | | | | | | All of the core-code usages of this API have the cpu pointer handy so pass it in. There are only 3 architecture specific usages (2 of which are commented out) which can just use ENV_GET_CPU() locally to get the cpu pointer. The reduces core code usage of the CPU env, which brings us closer to common-obj'ing these core files. Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Acked-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Andreas Färber <afaerber@suse.de>
* linux-user, ppc: mftbl can be used by user applicationLaurent Vivier2015-07-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In qemu-linux-user, when calling gethostbyname2(), it was hanging in .__res_nmkquery. (gdb) bt 0 in .__res_nmkquery () from /lib64/libresolv.so.2 1 in .__libc_res_nquery () from /lib64/libresolv.so.2 2 in .__libc_res_nsearch () from /lib64/libresolv.so.2 3 in ._nss_dns_gethostbyname3_r () from /lib64/libnss_dns.so.2 4 in ._nss_dns_gethostbyname2_r () from /lib64/libnss_dns.so.2 5 in .gethostbyname2_r () from /lib64/libc.so.6 6 in .gethostbyname2 () from /lib64/libc.so.6 .__res_nmkquery() is: ... do { RANDOM_BITS (randombits); } while ((randombits & 0xffff) == 0); ... <.__res_nmkquery+112>: mftbl r11 <.__res_nmkquery+116>: clrlwi r10,r11,16 <.__res_nmkquery+120>: cmpwi cr7,r10,0 <.__res_nmkquery+124>: beq cr7,<.__res_nmkquery+112> but as mftbl (Move From Time Base Lower) is not implemented, r11 is always 0, so we have an infinite loop. This patch fills the Time Base register with cpu_get_real_ticks(). Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Alexander Graf <agraf@suse.de>
* linux-user: ioctl() command type is intLaurent Vivier2015-06-161-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: fix the breakpoint inheritance in spawned threadsThierry Bultel2015-06-161-2/+2
| | | | | | | | | | When a thread is spawned, cpu_copy re-initializes the bp & wp lists of current thread, instead of the ones of the new thread. The effect is that breakpoints are no longer hit. Signed-off-by: Thierry Bultel <thierry.bultel@basystemes.fr> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
OpenPOWER on IntegriCloud