Commit Graph

785 Commits

Author SHA1 Message Date
Richard Henderson 7bc7b099df linux-user: Use h2g_valid in qemu_vmalloc.
Signed-off-by: Richard Henderson <rth@twiddle.net>
2010-03-12 16:29:07 +00:00
Blue Swirl 70539e1850 Update to a hopefully more future proof FSF address
See also 8167ee8839,
530e7615ce and
fad6cb1a56.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-03-07 15:48:43 +00:00
takasi-y@ops.dti.ne.jp d871443692 linux-user: Save/restore fpu registers to signal context on sh4
As "todo" comment in source code.
And modify restore_sigcontext() to have three args as kernel's does.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-03-06 19:37:05 +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
Paul Brook 9f9f030928 Disassembler symbol lookup fix
Fix function signature for userspace disassembler symbol lookup.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-03-01 04:39:50 +00: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
Richard Henderson dad081ee69 target-alpha: Reduce internal processor registers for user-mode.
The existing set of IPRs is totally irrelevant to user-mode emulation.
Indeed, they most are irrelevant to implementing kernel-mode emulation,
and would only be relevant to PAL-mode emulation, which I suspect that
no one will ever attempt.

Reducing the set of processor registers reduces the size of the CPU state.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2010-02-23 23:36:22 +01:00
john cooper b5ec5ce0e3 Add cpu model configuration support..
This is a reimplementation of prior versions which adds
the ability to define cpu models for contemporary processors.
The added models are likewise selected via -cpu <name>,
and are intended to displace the existing convention
of "-cpu qemu64" augmented with a series of feature flags.

A primary motivation was determination of a least common
denominator within a given processor class to simplify guest
migration.  It is still possible to modify an arbitrary model
via additional feature flags however the goal here was to
make doing so unnecessary in typical usage.  The other
consideration was providing models names reflective of
current processors.  Both AMD and Intel have reviewed the
models in terms of balancing generality of migration vs.
excessive feature downgrade relative to released silicon.

This version of the patch replaces the prior hard wired
definitions with a configuration file approach for new
models.  Existing models are thus far left as-is but may
easily be transitioned to (or may be overridden by) the
configuration file representation.

Proposed new model definitions are provided here for current
AMD and Intel processors.  Each model consists of a name
used to select it on the command line (-cpu <name>), and a
model_id which corresponds to a least common denominator
commercial instance of the processor class.

A table of names/model_ids may be queried via "-cpu ?model":

        :
    x86       Opteron_G3  AMD Opteron 23xx (Gen 3 Class Opteron)
    x86       Opteron_G2  AMD Opteron 22xx (Gen 2 Class Opteron)
    x86       Opteron_G1  AMD Opteron 240 (Gen 1 Class Opteron)
    x86          Nehalem  Intel Core i7 9xx (Nehalem Class Core i7)
    x86           Penryn  Intel Core 2 Duo P9xxx (Penryn Class Core 2)
    x86           Conroe  Intel Celeron_4x0 (Conroe/Merom Class Core 2)
        :

Also added is "-cpu ?dump" which exhaustively outputs all config
data for all defined models, and "-cpu ?cpuid" which enumerates
all qemu recognized CPUID feature flags.

The pseudo cpuid flag 'check' when added to the feature flag list
will warn when feature flags (either implicit in a cpu model or
explicit on the command line) would have otherwise been quietly
unavailable to a guest:

    # qemu-system-x86_64 ... -cpu Nehalem,check
    warning: host cpuid 0000_0001 lacks requested flag 'sse4.2|sse4_2' [0x00100000]
    warning: host cpuid 0000_0001 lacks requested flag 'popcnt' [0x00800000]

A similar 'enforce' pseudo flag exists which in addition
to the above causes qemu to error exit if requested flags are
unavailable.

Configuration data for a cpu model resides in the target config
file which by default will be installed as:

    /usr/local/etc/qemu/target-<arch>.conf

The format of this file should be self explanatory given the
definitions for the above six models and essentially mimics
the structure of the static x86_def_t x86_defs.

Encoding of cpuid flags names now allows aliases for both the
configuration file and the command line which reconciles some
Intel/AMD/Linux/Qemu naming differences.

This patch was tested relative to qemu.git.

Signed-off-by: john cooper <john.cooper@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-22 16:16:17 -06:00
Paul Brook 5f2243f301 Fix strace or FUTEX_PRIVATE_FLAG
FUTEX_PRIVATE_FLAG is a bit orred with an existing futex op,
not a distinct value.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2010-02-19 16:04:51 +00: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
Juan Quintela ee636500d6 mmap_frag() users only check for -1 error
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:59:20 -06:00
Kirill A. Shutemov fb7e378cf9 linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
CC    i386-linux-user/mmap.o
cc1: warnings being treated as errors
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return value of 'pread', declared with attribute warn_unused_result
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'target_mmap':
/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:477: error: ignoring return value of 'pread', declared with attribute warn_unused_result
make[1]: *** [mmap.o] Error 1

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 14:59:20 -06:00
Mike Frysinger 0ddbc96ec1 fix linux-user microblaze ELF_ARCH definition
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2010-01-17 09:51:03 +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
Aurelien Jarno f7001a3b9e linux-user: fix build with gcc-4.1
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-24 00:17:12 +01:00
Alexander Graf 73b01960b4 PPC: Make DCR uint32_t
For what I know DCR is always 32 bits wide, so we should also use uint32_t to
pass it along the stacks.

This fixes a warning when compiling qemu-system-ppc64 with KVM enabled, making
it compile without --disable-werror

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-21 16:03:03 +01:00
Aurelien Jarno b711de9565 PPC64: Fix alternate timebase
Fix the alternate time base the same way as the default timebase. SPR_ATBL
should return a 64-bit value on 64 bit implementations.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-21 13:52:08 +01:00
Alexander Graf e3ea652962 PPC64: Fix timebase
On PPC we have a 64-bit time base. Usually (PPC32) this is accessed using
two separate 32 bit SPR accesses to SPR_TBU and SPR_TBL.

On PPC64 the SPR_TBL register acts as 64 bit though, so we get the full
64 bits as return value. If we only take the lower ones, fine. But Linux
wants to see all 64 bits or it breaks.

This patch makes PPC64 Linux work even after TB crossed the 32-bit boundary,
which usually happened a few seconds after bootup.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-21 13:42:37 +01:00
Richard Henderson a3b3912ad0 linux-user: Add aliases for some Alpha syscalls
Alpha always used 32-bit uids, but never renamed the syscalls
to match i386 when 32-bit uids were added there.  This enables
the proper bits in syscall.c.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-21 11:29:27 +01:00
Nathan Froyd 7631c97ec9 linux-user: add core dump support for SH
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd 7a93cc55e9 linux-user: add core dump support for M68K
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd 51e526063d linux-user: add core dump support for MIPS
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd e2f3e741b4 linux-user: add core dump support for PPC
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd d049e626ad linux-user: fix ARM core dumps on opposite-endian hosts
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd 21e807fadb linux-user: commonify definitions of target typedefs
There's no sense in separately declaring target_{elf_greg,uid,gid,pid}_t
for every architecture.  Just declare them once with appropriate
USE_UID16 handling.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Nathan Froyd dd0a365144 linux-user: fix ELF_USE_CORE_DUMP/USE_ELF_CORE_DUMP confusion
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Aurelien Jarno 49995e1748 linux-user: use TARGET_ABI_FMT_lx to print abi_ulong types
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 20:29:18 +01:00
Riku Voipio 66393fb9dd linux-user: cleanup force_sig() calls
Force_sig should be always called with TARGET_ signals.
Not that it really matters with SEGV, so this patch is
just for cleanup and improving consistency.

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 19:45:27 +01:00
Riku Voipio d032d1b4b4 linux-user: Fix mmap_lock ordering
mmap_lock() can be called while tb_lock() is being held. To
avoid deadlock when one thread is holding mmap_lock and another
tb_lock, _always_ lock first tb_lock().

Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-19 19:45:27 +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
Richard Henderson 8a57a6c740 target-alpha: Drop bogus UNIQ initial value on Linux.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-12-13 20:32:36 +01:00
Paul Brook 725b8a6983 Fix ARM userspace strex implementation.
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-12-11 15:38:50 +00:00
Arnaud Patard 3ca055883b linux-user: remove hardcoded value of _NSIG in signal.c
In a bunch of places, 64 is used as value of _NSIG but it's wrong
at least on MIPS were _NSIG is 128.

Based on a patch from Arnaud Patard <arnaud.patard@rtp-net.org>

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-24 19:51:12 +01:00
Paul Brook e92734555f Add missing break.
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-11-24 13:10:08 +00:00
Paul Brook 426f5abcaa ARM atomic ops rewrite
Implement ARMv6 atomic ops (ldrex/strex) using the same trick as PPC.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-11-22 21:35:13 +00:00
Aurelien Jarno 5499b6ffac target-mips: rename CP0_LLAddr into lladdr
The variable CP0_LLAddr represent the full lladdr, not the actual
register value, which is only part of this value and depends on the
CPU.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-11-22 14:12:13 +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
Blue Swirl b55a37c981 user: move CPU reset call to main.c for x86/PPC/Sparc
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-07 10:37:06 +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
Riku Voipio cf6de34aec linux-user: Update ARM hwcaps
Update ARM hwcaps to match Linux kernel 2.6.31 state

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-16 14:37:33 +03:00
Paul Bolle e2cc3f6ebe linux-user: don't zero a buffer twice
prepare_binprm() zeroes bprm->buf. That buffer is already zeroed in
main() and hasn't been touched since so that is not necessary.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-16 14:36:36 +03:00
Max Filippov 61322e91a1 linux-user: fix ppc target_stat64 st_blocks layout
Swap __pad1 and st_blocks fields location to maintain proper alignment.
This fixes incorrect 'du' and 'stat' report on ppc guest.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-10-15 23:55:56 +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
Paul Bolle 3bc0bdcaad linux-user: fix "#if 0"'d printf()
Make an "#if 0"'d printf() in load_elf_binary(), probably left to aid in
debugging, reflect what the actual code does. The current printf() will
only confuse those who "#if 1" it (it certainly confused me enough to
write this trivial patch).

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2009-10-04 13:24:45 +02:00
Michael S. Tsirkin 22e4104079 linux-user: fix up oversealous nitpicking
Looks like linux-user code was correct, just unreadable: what it wanted
to do with "-=" was really assign a negative number, not decrement.  Fix
up accordingly.

Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-10-02 17:59:12 +00: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
Michael S. Tsirkin 5d024825be linux-user: fix old style decrement usage
Modern compilers do not parse "=-" as decrement:
you must use "-=" for that.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-30 18:45:50 +00:00
Michael S. Tsirkin 6ece4df63b elfload: fix coding style nit
Put space between = and * when dereferencing 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:45:50 +00:00
Juan Quintela dfd3f85c45 __thread should be before real type
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-25 19:53:17 +00:00
Juan Quintela 86178a576b static and inline should came before the type of the functions
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-25 19:51:45 +00:00
Blue Swirl d4fa8d909c Export tables properly to avoid a Sparse warning
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-21 18:40:57 +00:00
Blue Swirl b9d38e9510 Fix Sparse warnings about using plain integer as NULL pointer
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-21 18:11:34 +00:00
Blue Swirl ca20cf32ab Compile loader only once
Callers must pass ELF machine, byte swapping and symbol LSB clearing
information to ELF loader. A.out loader needs page size information, pass
that too as a parameter.

Extract prototypes to a separate file. Move loader.[ch] and elf_ops.h under hw.

Adjust callers. Also use target_phys_addr_t instead of target_ulong for
addresses: loader addresses aren't virtual.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-20 14:58:02 +00:00
Blue Swirl 50108930b8 Revert "Fix Sparc/Linux host breakage by df70204db53e3611af986f434e74a882bce190ca"
This reverts commit 91b40c5be8.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-13 19:38:48 +00:00
Blue Swirl 91b40c5be8 Fix Sparc/Linux host breakage by df70204db5
While i386, x86_64 and Sparc64/OpenBSD still worked after
df70204db5, Sparc32 and Sparc64 Linux hosts
broke.

Partially revert the commit: make the restored code conditional to
!CONFIG_USER_PIE.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-13 13:33:05 +00:00
Kirill A. Shutemov df70204db5 Fix text relocations in linux-user targets
There is a link hack in linux-user which produces an executable that
looks like PIE, but always has text relocations since all object files
isn't position-independent (compiled without -fpic/-fpie). Dynamic loader
has to do more work to load a binary with text relocations.

The best way to keep this functionality is to build a true PIE without
text relocations.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-12 13:15:26 +00:00
Blue Swirl 72cf2d4f0e Fix sys-queue.h conflict for good
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 15cc923584,
f40d753718,
96555a96d7 and
3990d09adf 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-09-12 07:36:22 +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
Blue Swirl 1e6eec8b33 Fix Sparse warnings: add "static"
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-09-05 10:14:07 +00:00
Kirill A. Shutemov fe3b415231 linux-user: Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets
qemu's page table can be incomple if /proc/self/maps is unavailable or
host allocating a memory with mmap(), so we can't use it to find free
memory area.

New version mmap_find_vma() uses mmap() without MAP_FIXED to find free
memory.

Tested-by: Martin Mohring <martin.mohring@opensuse.org> :

quite some time ago this patch had been sent by Kirill to the QEMU ml.
At that time, the patch was rejected. Now we found out why the current
user mode memory allocator sometimes fails:

- Kernel Bug  linux/fs/proc/task_mmu.c (fixed after 2.6.27)
http://bugzilla.kernel.org/attachment.cgi?id=17219
- use of proc file system to find memory mappings => bad idea

So I please apply the attached patch from Kirill to qemu to fix this
longstanding bug, because it causes all older linux distros (using
kernel 2.6.26 or older) to fail the QEMU memory allocator in user mode.

Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:35 +03: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
Laurent Vivier 7181155db9 m68k, linux-user: add setup_rt_frame
This patch implements setup_rt_frame().

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
Laurent Vivier 492a87445b m68k,linux-user: add setup_frame
This patch adds signals management for linux-user.

It implements setup_frame() which allows to call the user signal
handler.

setup_rt_frame() is always unimplemented.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
2009-08-25 17:15:33 +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
Blue Swirl 90e189ece1 Replace local ADDRX/PADDRX macros with TARGET_FMT_lx/plx
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-16 11:13:18 +00:00
Blue Swirl 6af5a25246 linux-user: compile envlist.c only once
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-15 08:47:42 +00:00
Blue Swirl 370220865b user: compile path.c only once
Also merge bsd-user/path.c and linux-user/path.c.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-15 07:51:59 +00:00
Laurent Desnogues ec822001a2 Fix symfind.
this patch fixes an issue in symfind.

Assume you have the following symbols:

Address  Size
0045bca0 00000080 T s0
0045bd20 00000112 T s1

You'll notice that s1 is s0 + size.

So the current symfind will find that address 0045bd20 belongs to s0
instead of s1.

Laurent

Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Message-Id:
2009-08-10 13:05:25 -05:00
Igor Kovalenko 8194f35a0c Sparc64: replace tsptr with helper routine
tl and tsptr of members sparc64 cpu state must be changed
simultaneously to keep trap state window in sync with current
trap level. Currently translation of store to tl does not change
tsptr, which leads to corrupt trap state on corresponding
trap level.

This patch removes tsptr from sparc64 cpu state and replaces
all uses with call to helper routine.

Changes v0->v1:
- reimplemented helper routine with tcg generator
- on cpu reset trap type and pstate are populated with power-on reset
values, including tl=maxtl

Signed-off-by: igor.v.kovalenko@gmail.com
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-04 20:22:10 +00: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
Nathan Froyd 56f066bb17 linux-user: handle POWERPC_EXCP_STCX
We handle conditional stores as an exception so we can ensure that no
other thread is changing memory out from underneath us.

Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>
Signed-off-by: malc <av1474@comtv.ru>
2009-08-03 20:33:41 +04:00
Blue Swirl 7cba04f6de More NULL pointer fixes
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-08-01 10:13:20 +00: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 e2542fe2bc rename WORDS_BIGENDIAN to HOST_WORDS_BIGENDIAN
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
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
malc 9fdca5aa5d Use correct byteswap routine for elf_note
All elf64_note structure members are Elf64_Word (which is 32bit value)
hence using bswaptls to byteswap it on 64bit platforms is incorrect.

Signed-off-by: malc <av1474@comtv.ru>
2009-07-18 13:17:01 +04:00
malc 3efa9a672e Avoid name clashes with symbols that leak from system headers
Signed-off-by: malc <av1474@comtv.ru>
2009-07-18 13:16:51 +04:00
Laurent Desnogues a2547a1378 ELF codedump build failures
Rename ELF coredump types to avoid conflict with the corresponding host types.

Signed-off-by: Laurent Desnogues <laurent.desnogues@gmail.com>
2009-07-17 13:33:41 +01:00
Paul Brook 379f6698d7 Userspace guest address offsetting
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-17 13:12:41 +01: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
malc 430c7ec700 Avoid SIGSEGV when dumping cpu state without enabled logging
Signed-off-by: malc <av1474@comtv.ru>
2009-07-15 21:03:34 +04:00
Isaku Yamahata 5f65049560 consolidate user cpu_{in, out}[bwl] into ioport-user.c
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-09 16:06:40 -05:00
Anthony Liguori 2152390dca Merge commit 'linux-user/linux-user-for-upstream' into tmp-staging 2009-07-09 15:09:27 -05:00
Paul Brook 94c5495dd1 MIPS signal handling fix
Add explicit padding to MIPS signal frame structures.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-07-09 18:40:15 +01:00
Paul Brook 590bc601d8 MIPS atomic instructions
Implement MIPS ll/sc instructions using atomic compare+exchange.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-07-09 17:45:17 +01:00
Paul Brook 18113962e4 Fix MIPS sys_clone
The clone syscall takes 6 args.

Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-07-09 13:11:52 +01: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