Commit graph

13858 commits

Author SHA1 Message Date
Aurelien Jarno 71deff2749 target-i386: set target_phys_bits to 64
qemu i386 used to support more than 4GB of RAM through PAE, but it has
been disabled for an unknown reason. Reenable it.

Note that simply running qemu x86_64 and emulating a 32-bit CPU is not
a solution to this problem as it is about 15% slower (it needs to
emulate 64 bit registers even if half of them are not used). On the
other hand, I haven't seen any measurable impact by switching
target_phys_bits to 64.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2011-02-20 15:13:57 +01:00
Aurelien Jarno 0899965f68 Merge branch 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu
* 'linux-user-for-upstream' of git://gitorious.org/qemu-maemo/qemu:
  linux-user: correct core dump format
  linux-user: Define target alignment size
  linux-user: Support the epoll syscalls
  linux-user: in linux-user/strace.c, tswap() is useless
  linux-user: add rmdir() strace
2011-02-20 14:47:48 +01:00
Blue Swirl 64d7e9a421 i8254: convert to qdev
Convert to qdev. Don't expose PITState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:35:06 +00:00
Blue Swirl c74b88dffc vga-isa: make optional
Ignore failure with vga-isa device creation, but print a warning
message.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:34:44 +00:00
Blue Swirl 7435b791ca vga-isa: convert to qdev
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:34:31 +00:00
Blue Swirl 1c9c5fcdfe applesmc: make optional
Based on patch by David Ahern.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:34:16 +00:00
Blue Swirl 17801c78fe fdc: make optional
Ignore failure with fdc device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:34:06 +00:00
Blue Swirl 63ffb564dc fdc: refactor device creation
Turn fdc_init_isa into an inline function.

Get floppy geometry directly from the drives.

Don't expose FDCtrl.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:33:46 +00:00
Blue Swirl d288c7ba7b fdc: use FDriveType for floppy drive type
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:33:26 +00:00
Blue Swirl 5bbdbb4676 fdc: move floppy geometry guessing to block.c
Other geometry guessing functions already reside in block.c.

Remove some unused or debugging only fields.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:33:17 +00:00
Blue Swirl 9b13ef9f4c serial: make optional
Ignore failure with serial device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:33:03 +00:00
Blue Swirl e22cf21efd serial: refactor device creation
Turn serial_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:32:50 +00:00
Blue Swirl cd1b8a8b0d ne2000_isa: make optional
Ignore failure with ne2000_isa device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:32:35 +00:00
Blue Swirl 60a14ad31e ne2000_isa: refactor device creation
Turn isa_ne2000_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:32:26 +00:00
Blue Swirl 7353153891 parallel: make optional
Ignore failure with parallel device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:31:57 +00:00
Blue Swirl defdb20e1a parallel: refactor device creation
Turn parallel_init into an inline function.

Don't expose ParallelState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-20 09:31:21 +00:00
Marcelo Tosatti e14da0af64 Fix vmport segfault (v2)
Fix regression caused by qdev conversion.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2011-02-17 19:34:52 +00:00
Laurent Vivier 80f5ce758a linux-user: correct core dump format
This patch allows to really use the core dumped by qemu with guest
architecture tools.

- it adds a missing bswap_phdr() for the program headers
  of memory regions.

  "objdump -x" sample:

BEFORE:

0x1000000 off    0x00200000 vaddr 0x00000400 paddr 0x00000000 align 2**21
         filesz 0x00000000 memsz 0x00100000 flags ---
0x1000000 off    0x00200000 vaddr 0x00100400 paddr 0x00000000 align 2**21
         filesz 0x00000000 memsz 0x00080000 flags --- 6000000

AFTER:

    LOAD off    0x00002000 vaddr 0x00040000 paddr 0x00000000 align 2**13
         filesz 0x00000000 memsz 0x00001000 flags ---
    LOAD off    0x00002000 vaddr 0x00041000 paddr 0x00000000 align 2**13
         filesz 0x00000000 memsz 0x00000800 flags rw-

- it doesn't pad the note size to sizeof(int32_t).
  On m68k the NT_PRSTATUS note size is 154 and
  must not be rounded up to 156, because this value is checked by
  objdump and gdb.

  "gdb" symptoms:

      "warning: Couldn't find general-purpose registers in core file."

  "objdump -x" sample:

BEFORE:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 note0         000001c4  00000000  00000000  000003b4  2**0
                  CONTENTS, READONLY
  1 .auxv         00000070  00000000  00000000  00000508  2**2
                  CONTENTS
  2 proc1         00100000  00000400  00000000  00200000  2**10
                  READONLY

AFTER:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 note0         000001c4  00000000  00000000  000003b4  2**0
                  CONTENTS, READONLY
  1 .reg/19022    00000050  00000000  00000000  0000040e  2**2
                  CONTENTS
  2 .reg          00000050  00000000  00000000  0000040e  2**2
                  CONTENTS
  3 .auxv         00000070  00000000  00000000  00000508  2**2
                  CONTENTS
  4 load1         00000000  00040000  00000000  00002000  2**13
                  ALLOC, READONLY

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-17 11:46:34 +02:00
Laurent Vivier c2e3dee6e0 linux-user: Define target alignment size
Datatype alignment can be found using following application:

int main(void)
{
	printf("alignof(short) %ld\n", __alignof__(short));
	printf("alignof(int) %ld\n", __alignof__(int));
	printf("alignof(long) %ld\n", __alignof__(long));
	printf("alignof(long long) %ld\n", __alignof__(long long));
}

This patch includes following alignments:

i386

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

 x86_64

   alignof(short) 2
   alignof(int) 4
   alignof(long) 8
   alignof(long long) 8

 arm

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 4

 m68k (680x0)

   alignof(short) 2
   alignof(int) 2
   alignof(long) 2
   alignof(long long) 2

 mips

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

 ppc

   alignof(short) 2
   alignof(int) 4
   alignof(long) 4
   alignof(long long) 8

for other targets, use by default (2,4,4,8).

Please, update for your favorite target...

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-17 11:46:34 +02:00
Peter Maydell 3b6edd1611 linux-user: Support the epoll syscalls
Support the epoll family of syscalls: epoll_create(), epoll_create1(),
epoll_ctl(), epoll_wait() and epoll_pwait(). Note that epoll_create1()
and epoll_pwait() are later additions, so we have to test separately
in configure for their presence.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-17 11:46:34 +02:00
Laurent Vivier d2ee72a5b1 linux-user: in linux-user/strace.c, tswap() is useless
Syscall parameters are already swapped by the caller.

This patch removes useless tswap() from strace.c

$ QEMU_STRACE=1 chroot /m68k mknod myramdisk b 1 1
with tswap()
...
29944 mknod("myramdisk",026630200000) = 0
...

without tswap()

...
30042 mknod("myramdisk",S_IFBLK|0666,makedev(1,1)) = 0
...

natively:

$ strace touch mytouch
...
open("mytouch", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
...

$ QEMU_STRACE=1 chroot /m68k touch mytouch
with tswap()
...
30368 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30368 fstat64(50331648,0x4080032c) = 0
...
30368 open("mytouch",O_RDONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK|0x1) = 0
...
without tswap()
...
30572 open("/usr/share/locale/locale.alias",O_RDONLY) = 3
30572 fstat64(3,0x4080032c) = 0
...
30572 open("mytouch",O_WRONLY|O_CREAT|O_LARGEFILE|O_NOCTTY|O_NONBLOCK,0666) = 0

Signed-off-by: Laurent Vivier <laurent@vivier.eu>

Fixes by Riku Voipio: add casts
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-17 11:46:34 +02:00
Laurent Vivier 4de596cb50 linux-user: add rmdir() strace
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
2011-02-17 11:46:34 +02:00
Anthony Liguori 79f2b6fcdb Merge remote branch 'kwolf/for-anthony' into staging 2011-02-16 08:47:13 -06:00
Anthony Liguori c5d69e6bbf Merge remote branch 'qemu-kvm/uq/master' into staging 2011-02-16 08:47:07 -06:00
Tristan Gingold 630ecca0da Handle icount for powerpc tbl/tbu/decr load and store.
Handle option '-icount X' on powerpc targets.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
2011-02-16 15:35:32 +01:00
Dmitry Eremin-Solenikov 459505a264 Merge mainstone.h header into mainstone.c
Now the only user of mainstone.h is mainstone.c file. Merge header
into board file.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
2011-02-16 02:04:51 +01:00
Dmitry Eremin-Solenikov cb380f615c mainstone: convert FPGA emulation code to use QDev/SysBus
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
2011-02-16 02:04:03 +01:00
Dmitry Eremin-Solenikov 43d91709c1 mainstone: correct and simplify irq handling
Simplify IRQ handling to stop setting an input irq pin. As a win, also get
correct IRQ status after save/load cycle.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
2011-02-16 02:00:27 +01:00
Anthony Liguori 8fe3046f17 Fix build from previous commit
I unfortunately got on an unnamed branch and pushed the wrong bits

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-14 14:24:24 -06:00
Bruce Rogers 53fae6d27f PATCH] slirp: fix buffer overrun
Since the addition of the slirp member to struct mbuf, the value of
SLIRP_MSIZE and the initialization of m_size have not been correct,
resulting in overrunning the end of the malloc'd buffer in some cases.

Signed-off-by: Bruce Rogers <brogers@novell.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-14 13:23:00 -06:00
Gleb Natapov 0fbfbb59a9 correctly check ppr priority during interrupt injection]
TPR blocks all interrupts in a priority class, so simple "less or
equal" check is not enough.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-14 08:43:30 -06:00
Anthony Liguori ed94592be2 io-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-14 08:43:30 -06:00
Jan Kiszka 0ec329dab9 kvm: x86: Introduce kvmclock device to save/restore its state
If kvmclock is used, which implies the kernel supports it, register a
kvmclock device with the sysbus. Its main purpose is to save and restore
the kernel state on migration, but this will also allow to visualize it
one day.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Glauber Costa <glommer@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:43:09 -02:00
Jan Kiszka 6a7af8cb04 kvm: Make kvm_state globally available
KVM-assisted devices need access to it but we have no clean channel to
distribute a reference. As a workaround until there is a better
solution, export kvm_state for global use, though use should remain
restricted to the mentioned scenario.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:47 -02:00
Jan Kiszka 638a84af9f cirrus: Remove obsolete kvm.h include
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:47 -02:00
Anthony PERARD e5896b12e2 Introduce log_start/log_stop in CPUPhysMemoryClient
In order to use log_start/log_stop with Xen as well in the vga code,
this two operations have been put in CPUPhysMemoryClient.

The two new functions cpu_physical_log_start,cpu_physical_log_stop are
used in hw/vga.c and replace the kvm_log_start/stop. With this, vga does
no longer depends on kvm header.

[ Jan: rebasing and style fixlets ]

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:47 -02:00
Jan Kiszka 8e045ac407 kvm: Remove unneeded memory slot reservation
The number of slots and the location of private ones changed several
times in KVM's early days. However, it's stable since 2.6.29 (our
required baseline), and slots 8..11 are no longer reserved since then.
So remove this unneeded restriction.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka ce377af399 kvm: x86: Catch and report failing IRQ and NMI injections
We do not need to abort, but the user should be notified that weird
things go on.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 7a39fe5882 kvm: Drop return values from kvm_arch_pre/post_run
We do not check them, and the only arch with non-empty implementations
always returns 0 (this is also true for qemu-kvm).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Alexander Graf <agraf@suse.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka db1669bcca kvm: x86: Prepare VCPU loop for in-kernel irqchip
Effectively no functional change yet as kvm_irqchip_in_kernel still only
returns 0, but this patch will allow qemu-kvm to adopt the VCPU loop of
upsteam KVM.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 6792a57bf1 kvm: Separate TCG from KVM cpu execution
Mixing up TCG bits with KVM already led to problems around eflags
emulation on x86. Moreover, quite some code that TCG requires on cpu
enty/exit is useless for KVM. So dispatch between tcg_cpu_exec and
kvm_cpu_exec as early as possible.

The core logic of cpu_halted from cpu_exec is added to
kvm_arch_process_irqchip_events. Moving away from cpu_exec makes
exception_index meaningless for KVM, we can simply pass the exit reason
directly (only "EXCP_DEBUG vs. rest" is relevant).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 83f338f73e Move debug exception handling out of cpu_exec
To prepare splitting up KVM and TCG CPU entry/exit, move the debug
exception into cpus.c and invoke cpu_handle_debug_exception on return
from qemu_cpu_exec.

This also allows to clean up the debug request signaling: We can assign
the job of informing main-loop to qemu_system_debug_request and stop the
calling cpu directly in cpu_handle_debug_exception. That means a debug
stop will now only be signaled via debug_requested and not additionally
via vmstop_requested.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 8cf71710f0 Refactor debug and vmstop request interface
Instead of fiddling with debug_requested and vmstop_requested directly,
introduce qemu_system_debug_request and turn qemu_system_vmstop_request
into a public interface. This aligns those services with exiting ones in
vl.c.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka e07bbac542 Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actually
have nothing to do with the EXCP_* defines used so far. At this chance,
specify more detailed reasons so that VM state change handlers can
evaluate them.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 0ab07c623c Fix a few coding style violations in cpus.c
No functional changes.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 1640032283 Refactor cpu_has_work/any_cpu_has_work in cpus.c
Avoid duplicate use of the function name cpu_has_work, it's confusing,
also their scope. Refactor cpu_has_work to cpu_thread_is_idle and do the
same with any_cpu_has_work.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka 7e97cd8814 Refactor kvm&tcg function names in cpus.c
Pure interface cosmetics: Ensure that only kvm core services (as
declared in kvm.h) start with "kvm_". Prepend "qemu_" to those that
violate this rule in cpus.c. Also rename the corresponding tcg functions
for the sake of consistency.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Glauber Costa b8cc45d6a6 kvm: make tsc stable over migration and machine start
If the machine is stopped, we should not record two different tsc values
upon a save operation. The same problem happens with kvmclock.

But kvmclock is taking a different diretion, being now seen as a separate
device. Since this is unlikely to happen with the tsc, I am taking the
approach here of simply registering a handler for state change, and
using a per-CPUState variable that prevents double updates for the TSC.

Signed-off-by: Glauber Costa <glommer@redhat.com>
CC: Jan Kiszka <jan.kiszka@web.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:46 -02:00
Jan Kiszka cdea50ede1 kvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN
The reset we issue on KVM_EXIT_SHUTDOWN implies that we should also
leave the VCPU loop. As we now check for exit_request which is set by
qemu_system_reset_request, this bug is no longer critical. Still it's an
unneeded extra turn.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:45 -02:00
Jan Kiszka b30e93e9ec kvm: Remove static return code of kvm_handle_io
Improve the readability of the exit dispatcher by moving the static
return value of kvm_handle_io to its caller.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
2011-02-14 12:39:45 -02:00