sdk/emulator/qemu.git
13 years agofdc: make optional
Blue Swirl [Sat, 12 Feb 2011 22:25:26 +0000 (22:25 +0000)]
fdc: make optional

Ignore failure with fdc device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 16:32:23 +0000 (16:32 +0000)]
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>
13 years agofdc: use FDriveType for floppy drive type
Blue Swirl [Sat, 12 Feb 2011 21:23:12 +0000 (21:23 +0000)]
fdc: use FDriveType for floppy drive type

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agofdc: move floppy geometry guessing to block.c
Blue Swirl [Sat, 12 Feb 2011 20:43:32 +0000 (20:43 +0000)]
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>
13 years agoserial: make optional
Blue Swirl [Sat, 5 Feb 2011 21:30:42 +0000 (21:30 +0000)]
serial: make optional

Ignore failure with serial device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoserial: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 19:37:40 +0000 (19:37 +0000)]
serial: refactor device creation

Turn serial_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agone2000_isa: make optional
Blue Swirl [Sat, 5 Feb 2011 15:44:45 +0000 (15:44 +0000)]
ne2000_isa: make optional

Ignore failure with ne2000_isa device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agone2000_isa: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 15:39:57 +0000 (15:39 +0000)]
ne2000_isa: refactor device creation

Turn isa_ne2000_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoparallel: make optional
Blue Swirl [Sat, 5 Feb 2011 14:56:53 +0000 (14:56 +0000)]
parallel: make optional

Ignore failure with parallel device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoparallel: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 14:51:57 +0000 (14:51 +0000)]
parallel: refactor device creation

Turn parallel_init into an inline function.

Don't expose ParallelState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoFix vmport segfault (v2)
Marcelo Tosatti [Thu, 17 Feb 2011 03:27:19 +0000 (01:27 -0200)]
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>
13 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Wed, 16 Feb 2011 14:47:13 +0000 (08:47 -0600)]
Merge remote branch 'kwolf/for-anthony' into staging

13 years agoMerge remote branch 'qemu-kvm/uq/master' into staging
Anthony Liguori [Wed, 16 Feb 2011 14:47:07 +0000 (08:47 -0600)]
Merge remote branch 'qemu-kvm/uq/master' into staging

13 years agoHandle icount for powerpc tbl/tbu/decr load and store.
Tristan Gingold [Tue, 15 Feb 2011 08:39:54 +0000 (09:39 +0100)]
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>
13 years agoMerge mainstone.h header into mainstone.c
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:25 +0000 (03:15 +0300)]
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>
13 years agomainstone: convert FPGA emulation code to use QDev/SysBus
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:24 +0000 (03:15 +0300)]
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>
13 years agomainstone: correct and simplify irq handling
Dmitry Eremin-Solenikov [Sat, 12 Feb 2011 00:15:23 +0000 (03:15 +0300)]
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>
13 years agoFix build from previous commit
Anthony Liguori [Mon, 14 Feb 2011 20:24:24 +0000 (14:24 -0600)]
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>
13 years agoPATCH] slirp: fix buffer overrun
Bruce Rogers [Sat, 5 Feb 2011 21:47:56 +0000 (14:47 -0700)]
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>
13 years agocorrectly check ppr priority during interrupt injection]
Gleb Natapov [Mon, 7 Feb 2011 14:14:44 +0000 (16:14 +0200)]
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>
13 years agoio-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond
Anthony Liguori [Tue, 8 Feb 2011 17:18:18 +0000 (18:18 +0100)]
io-thread: make sure to initialize qemu_work_cond and qemu_cpu_cond

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agokvm: x86: Introduce kvmclock device to save/restore its state
Jan Kiszka [Mon, 7 Feb 2011 11:19:26 +0000 (12:19 +0100)]
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>
13 years agokvm: Make kvm_state globally available
Jan Kiszka [Mon, 7 Feb 2011 11:19:25 +0000 (12:19 +0100)]
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>
13 years agocirrus: Remove obsolete kvm.h include
Jan Kiszka [Mon, 7 Feb 2011 11:19:24 +0000 (12:19 +0100)]
cirrus: Remove obsolete kvm.h include

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoIntroduce log_start/log_stop in CPUPhysMemoryClient
Anthony PERARD [Mon, 7 Feb 2011 11:19:23 +0000 (12:19 +0100)]
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>
13 years agokvm: Remove unneeded memory slot reservation
Jan Kiszka [Mon, 7 Feb 2011 11:19:22 +0000 (12:19 +0100)]
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>
13 years agokvm: x86: Catch and report failing IRQ and NMI injections
Jan Kiszka [Mon, 7 Feb 2011 11:19:21 +0000 (12:19 +0100)]
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>
13 years agokvm: Drop return values from kvm_arch_pre/post_run
Jan Kiszka [Mon, 7 Feb 2011 11:19:20 +0000 (12:19 +0100)]
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>
13 years agokvm: x86: Prepare VCPU loop for in-kernel irqchip
Jan Kiszka [Mon, 7 Feb 2011 11:19:19 +0000 (12:19 +0100)]
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>
13 years agokvm: Separate TCG from KVM cpu execution
Jan Kiszka [Mon, 7 Feb 2011 11:19:18 +0000 (12:19 +0100)]
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>
13 years agoMove debug exception handling out of cpu_exec
Jan Kiszka [Mon, 7 Feb 2011 11:19:17 +0000 (12:19 +0100)]
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>
13 years agoRefactor debug and vmstop request interface
Jan Kiszka [Mon, 7 Feb 2011 11:19:16 +0000 (12:19 +0100)]
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>
13 years agoImprove vm_stop reason declarations
Jan Kiszka [Wed, 9 Feb 2011 15:29:40 +0000 (16:29 +0100)]
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>
13 years agoFix a few coding style violations in cpus.c
Jan Kiszka [Mon, 7 Feb 2011 11:19:14 +0000 (12:19 +0100)]
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>
13 years agoRefactor cpu_has_work/any_cpu_has_work in cpus.c
Jan Kiszka [Wed, 9 Feb 2011 15:29:37 +0000 (16:29 +0100)]
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>
13 years agoRefactor kvm&tcg function names in cpus.c
Jan Kiszka [Mon, 7 Feb 2011 11:19:12 +0000 (12:19 +0100)]
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>
13 years agokvm: make tsc stable over migration and machine start
Glauber Costa [Thu, 3 Feb 2011 19:19:53 +0000 (14:19 -0500)]
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>
13 years agokvm: Leave kvm_cpu_exec directly after KVM_EXIT_SHUTDOWN
Jan Kiszka [Tue, 1 Feb 2011 21:16:02 +0000 (22:16 +0100)]
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>
13 years agokvm: Remove static return code of kvm_handle_io
Jan Kiszka [Tue, 1 Feb 2011 21:16:01 +0000 (22:16 +0100)]
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>
13 years agokvm: Unconditionally reenter kernel after IO exits
Jan Kiszka [Tue, 1 Feb 2011 21:16:00 +0000 (22:16 +0100)]
kvm: Unconditionally reenter kernel after IO exits

KVM requires to reenter the kernel after IO exits in order to complete
instruction emulation. Failing to do so will leave the kernel state
inconsistently behind. To ensure that we will get back ASAP, we issue a
self-signal that will cause KVM_RUN to return once the pending
operations are completed.

We can move kvm_arch_process_irqchip_events out of the inner VCPU loop.
The only state that mattered at its old place was a pending INIT
request. Catch it in kvm_arch_pre_run and also trigger a self-signal to
process the request on next kvm_cpu_exec.

This patch also fixes the missing exit_request check in kvm_cpu_exec in
the CONFIG_IOTHREAD case.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoIntroduce VCPU self-signaling service
Jan Kiszka [Tue, 1 Feb 2011 21:15:59 +0000 (22:15 +0100)]
Introduce VCPU self-signaling service

Introduce qemu_cpu_kick_self to send SIG_IPI to the calling VCPU
context. First user will be kvm.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Add MCE signal support for !CONFIG_IOTHREAD
Jan Kiszka [Tue, 1 Feb 2011 21:15:58 +0000 (22:15 +0100)]
kvm: Add MCE signal support for !CONFIG_IOTHREAD

Currently, we only configure and process MCE-related SIGBUS events if
CONFIG_IOTHREAD is enabled. The groundwork is laid, we just need to
factor out the required handler registration and system configuration.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Huang Ying <ying.huang@intel.com>
CC: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
CC: Jin Dongming <jin.dongming@np.css.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Fix race between timer signals and vcpu entry under !IOTHREAD
Jan Kiszka [Tue, 1 Feb 2011 21:15:57 +0000 (22:15 +0100)]
kvm: Fix race between timer signals and vcpu entry under !IOTHREAD

Found by Stefan Hajnoczi: There is a race in kvm_cpu_exec between
checking for exit_request on vcpu entry and timer signals arriving
before KVM starts to catch them. Plug it by blocking both timer related
signals also on !CONFIG_IOTHREAD and process those via signalfd.

As this fix depends on real signalfd support (otherwise the timer
signals only kick the compat helper thread, and the main thread hangs),
we need to detect the invalid constellation and abort configure.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
CC: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoSet up signalfd under !CONFIG_IOTHREAD
Jan Kiszka [Tue, 1 Feb 2011 21:15:56 +0000 (22:15 +0100)]
Set up signalfd under !CONFIG_IOTHREAD

Will be required for SIGBUS handling. For obvious reasons, this will
remain a nop on Windows hosts.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Call qemu_kvm_eat_signals also under !CONFIG_IOTHREAD
Jan Kiszka [Tue, 1 Feb 2011 21:15:55 +0000 (22:15 +0100)]
kvm: Call qemu_kvm_eat_signals also under !CONFIG_IOTHREAD

Move qemu_kvm_eat_signals around and call it also when the IO-thread is
not used. Do not yet process SIGBUS, will be armed in a separate step.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Refactor qemu_kvm_eat_signals
Jan Kiszka [Tue, 1 Feb 2011 21:15:54 +0000 (22:15 +0100)]
kvm: Refactor qemu_kvm_eat_signals

We do not use the timeout, so drop its logic. As we always poll our
signals, we do not need to drop the global lock. Removing those calls
allows some further simplifications. Also fix the error processing of
sigpending at this chance.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Set up signal mask also for !CONFIG_IOTHREAD
Jan Kiszka [Tue, 1 Feb 2011 21:15:53 +0000 (22:15 +0100)]
kvm: Set up signal mask also for !CONFIG_IOTHREAD

Block SIG_IPI, unblock it during KVM_RUN, just like in io-thread mode.
It's unused so far, but this infrastructure will be required for
self-IPIs and to process SIGBUS plus, in KVM mode, SIGIO and SIGALRM. As
Windows doesn't support signal services, we need to provide a stub for
the init function.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoRefactor signal setup functions in cpus.c
Jan Kiszka [Tue, 1 Feb 2011 21:15:52 +0000 (22:15 +0100)]
Refactor signal setup functions in cpus.c

Move {tcg,kvm}_init_ipi and block_io_signals to avoid prototypes, rename
the former two to clarify that they deal with more than SIG_IPI. No
functional changes - except for the tiny fixup of strerror usage.

The forward declaration of sigbus_handler is just temporarily, it will
be moved in a succeeding patch. dummy_signal is moved into the !_WIN32
block as we will soon need it also for !CONFIG_IOTHREAD.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Provide sigbus services arch-independently
Jan Kiszka [Tue, 1 Feb 2011 21:15:51 +0000 (22:15 +0100)]
kvm: Provide sigbus services arch-independently

Provide arch-independent kvm_on_sigbus* stubs to remove the #ifdef'ery
from cpus.c. This patch also fixes --disable-kvm build by providing the
missing kvm_on_sigbus_vcpu kvm-stub.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Handle kvm_init_vcpu errors
Jan Kiszka [Tue, 1 Feb 2011 21:15:50 +0000 (22:15 +0100)]
kvm: Handle kvm_init_vcpu errors

Do not ignore errors of kvm_init_vcpu, they are fatal.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Drop redundant kvm_enabled from kvm_cpu_thread_fn
Jan Kiszka [Tue, 1 Feb 2011 21:15:49 +0000 (22:15 +0100)]
kvm: Drop redundant kvm_enabled from kvm_cpu_thread_fn

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agokvm: Report proper error on GET_VCPU_MMAP_SIZE failures
Jan Kiszka [Tue, 1 Feb 2011 21:15:48 +0000 (22:15 +0100)]
kvm: Report proper error on GET_VCPU_MMAP_SIZE failures

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoFlatten the main loop
Jan Kiszka [Tue, 1 Feb 2011 21:15:47 +0000 (22:15 +0100)]
Flatten the main loop

First of all, vm_can_run is a misnomer, it actually means "no request
pending". Moreover, there is no need to check all pending requests
twice, the first time via the inner loop check and then again when
actually processing the requests. We can simply remove the inner loop
and do the checks directly.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoLeave inner main_loop faster on pending requests
Jan Kiszka [Tue, 1 Feb 2011 21:15:46 +0000 (22:15 +0100)]
Leave inner main_loop faster on pending requests

If there is any pending request that requires us to leave the inner loop
if main_loop, makes sure we do this as soon as possible by enforcing
non-blocking IO processing.

At this change, move variable definitions out of the inner loop to
improve readability.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoTrigger exit from cpu_exec_all on pending IO events
Jan Kiszka [Tue, 1 Feb 2011 21:15:45 +0000 (22:15 +0100)]
Trigger exit from cpu_exec_all on pending IO events

Except for timer events, we currently do not leave the loop over all
VCPUs if an IO event was filed. That may cause unexpected IO latencies
under !CONFIG_IOTHREAD in SMP scenarios. Fix it by setting the global
exit_request which breaks the loop.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoProcess vmstop requests in IO thread
Jan Kiszka [Tue, 1 Feb 2011 21:15:44 +0000 (22:15 +0100)]
Process vmstop requests in IO thread

A pending vmstop request is also a reason to leave the inner main loop.
So far we ignored it, and pending stop requests issued over VCPU threads
were simply ignored.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoStop current VCPU on synchronous reset requests
Jan Kiszka [Tue, 1 Feb 2011 21:15:43 +0000 (22:15 +0100)]
Stop current VCPU on synchronous reset requests

If some I/O operation ends up calling qemu_system_reset_request in VCPU
context, we record this and inform the io-thread, but we do not
terminate the VCPU loop. This can lead to fairly unexpected behavior if
the triggering reset operation is supposed to work synchronously.

Fix this for TCG (when run in deterministic I/O mode) by setting the
VCPU on stop and issuing a cpu_exit. KVM requires some more work on its
VCPU loop.

[ ported from qemu-kvm ]

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agoPrevent abortion on multiple VCPU kicks
Jan Kiszka [Tue, 1 Feb 2011 21:15:42 +0000 (22:15 +0100)]
Prevent abortion on multiple VCPU kicks

If we call qemu_cpu_kick more than once before the target was able to
process the signal, pthread_kill will fail, and qemu will abort. Prevent
this by avoiding the redundant signal.

This logic can be found in qemu-kvm as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
13 years agovmmouse: fix queue_size field initialization
Blue Swirl [Sat, 12 Feb 2011 17:44:11 +0000 (17:44 +0000)]
vmmouse: fix queue_size field initialization

Initialize the field queue_size, dropped by
91c9e09147ba1f3604a3d5d29b4de7702082a33f.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agohpet: make optional
Blue Swirl [Sat, 5 Feb 2011 14:35:00 +0000 (14:35 +0000)]
hpet: make optional

Ignore failure with hpet device creation.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agosysbus: add creation function that may fail
Blue Swirl [Sat, 5 Feb 2011 14:34:56 +0000 (14:34 +0000)]
sysbus: add creation function that may fail

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agox86: make vmmouse optional
Blue Swirl [Sat, 5 Feb 2011 14:34:52 +0000 (14:34 +0000)]
x86: make vmmouse optional

Compile vmmouse in hwlib. Ignore failure if vmmouse device can't be
created.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoisa: add creation function that may fail
Blue Swirl [Sat, 5 Feb 2011 14:34:48 +0000 (14:34 +0000)]
isa: add creation function that may fail

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agovmmouse: convert to qdev
Blue Swirl [Sat, 5 Feb 2011 14:34:45 +0000 (14:34 +0000)]
vmmouse: convert to qdev

Convert to qdev, also add a proper reset function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agovmport: convert to qdev
Blue Swirl [Sat, 5 Feb 2011 14:34:41 +0000 (14:34 +0000)]
vmport: convert to qdev

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agox86,MIPS: make vmware_vga optional
Blue Swirl [Sat, 5 Feb 2011 14:34:37 +0000 (14:34 +0000)]
x86,MIPS: make vmware_vga optional

Allow failure with vmware_vga device creation and use standard
VGA instead.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agopci: add creation functions that may fail
Blue Swirl [Sat, 5 Feb 2011 14:34:32 +0000 (14:34 +0000)]
pci: add creation functions that may fail

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agoqdev: add creation function that may fail
Blue Swirl [Sat, 5 Feb 2011 14:34:25 +0000 (14:34 +0000)]
qdev: add creation function that may fail

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agovmware_vga: refactor device creation
Blue Swirl [Sat, 5 Feb 2011 14:34:19 +0000 (14:34 +0000)]
vmware_vga: refactor device creation

Turn vmsvga_init into an inline function.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
13 years agomst_fpga: Drop one more pxa.h inclusion.
Andrzej Zaborowski [Fri, 11 Feb 2011 22:35:20 +0000 (23:35 +0100)]
mst_fpga: Drop one more pxa.h inclusion.

Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agopxa2xx: convert i2c master to use qdev/vmsd
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:39 +0000 (23:57 +0300)]
pxa2xx: convert i2c master to use qdev/vmsd

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agomax7310: finish qdev'ication
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:38 +0000 (23:57 +0300)]
max7310: finish qdev'ication

1) Move GPIO-related functionality to qdev. Now one can use directly
qdev_get_gpio_in()/qdev_connect_gpio_out() on max7310 devices.

2) Make reset to be called through qdev.reset callback.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agotosa: we aren't connected to VBus, pass this info to Linux kernel
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:37 +0000 (23:57 +0300)]
tosa: we aren't connected to VBus, pass this info to Linux kernel

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agomainstone: pass one irq to the mst_fpga instead of the whole PIC
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:35 +0000 (23:57 +0300)]
mainstone: pass one irq to the mst_fpga instead of the whole PIC

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoDrop unnecessary inclusions of pxa.h header
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:34 +0000 (23:57 +0300)]
Drop unnecessary inclusions of pxa.h header

Seceral files contained onnecessary dependencies on hw/pxa.h header.
Drop unused references.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoAdd scoop post_load callback that sets IRQs to loaded levels
Dmitry Eremin-Solenikov [Fri, 11 Feb 2011 20:57:33 +0000 (23:57 +0300)]
Add scoop post_load callback that sets IRQs to loaded levels

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agotc6393xb: correct NAND isr assertion
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:46 +0000 (18:20 +0300)]
tc6393xb: correct NAND isr assertion

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agosysbus: print number of irqs in dev_print
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:41 +0000 (18:20 +0300)]
sysbus: print number of irqs in dev_print

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years ago.gitignore: ignore vi swap files and ctags files
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:40 +0000 (18:20 +0300)]
.gitignore: ignore vi swap files and ctags files

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agoarm: drop unused irq-related part of CPUARMState
Dmitry Eremin-Solenikov [Mon, 31 Jan 2011 15:20:42 +0000 (18:20 +0300)]
arm: drop unused irq-related part of CPUARMState

These two fields were added as a part of ARMv7 support patch (back in
2007), were never used by any code, so can be dropped.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
13 years agotarget-arm: Remove stray #include from middle of neon_helper.c
Peter Maydell [Thu, 10 Feb 2011 15:47:14 +0000 (15:47 +0000)]
target-arm: Remove stray #include from middle of neon_helper.c

Remove a stray #include <stdio.h> from the middle of neon_helper.c:
it was harmless but pointless since we include stdio.h at the top
of the file anyway.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agolinux-user/arm: fix compilation failures using softfloat's struct types
Peter Maydell [Thu, 10 Feb 2011 13:59:35 +0000 (13:59 +0000)]
linux-user/arm: fix compilation failures using softfloat's struct types

Add uses of the float32/float64 boxing and unboxing macros so that
the ARM linux-user targets will compile with USE_SOFTFLOAT_STRUCT_TYPES
enabled.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES
Peter Maydell [Thu, 10 Feb 2011 13:59:34 +0000 (13:59 +0000)]
softfloat: Fix compilation failures with USE_SOFTFLOAT_STRUCT_TYPES

Make softfloat compile with USE_SOFTFLOAT_STRUCT_TYPES defined, by
adding and using new macros const_float16(), const_float32() and
const_float64() so you can use array initializers in an array of
float16/float32/float64 whether the types are bare or wrapped in the
structs.

[aurelien@aurel32.net: do the same for float16]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Use standard FPSCR for Neon half-precision operations
Peter Maydell [Thu, 10 Feb 2011 11:29:01 +0000 (11:29 +0000)]
target-arm: Use standard FPSCR for Neon half-precision operations

The Neon half-precision conversion operations (VCVT.F16.F32 and
VCVT.F32.F16) use ARM standard floating-point arithmetic, unlike
the VFP versions (VCVTB and VCVTT).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agotarget-arm: Silence NaNs resulting from half-precision conversions
Peter Maydell [Thu, 10 Feb 2011 11:29:00 +0000 (11:29 +0000)]
target-arm: Silence NaNs resulting from half-precision conversions

Silence the NaNs that may result from half-precision conversion,
as we do for the other conversions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Correctly handle NaNs in float16_to_float32()
Peter Maydell [Thu, 10 Feb 2011 11:28:59 +0000 (11:28 +0000)]
softfloat: Correctly handle NaNs in float16_to_float32()

Correctly handle NaNs in float16_to_float32(), by defining and
using a float16ToCommonNaN() function, as we do with the other formats.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Fix single-to-half precision float conversions
Peter Maydell [Thu, 10 Feb 2011 11:28:58 +0000 (11:28 +0000)]
softfloat: Fix single-to-half precision float conversions

Fix various bugs in the single-to-half-precision conversion code:
 * input NaNs not correctly converted in IEEE mode
   (fixed by defining and using a commonNaNToFloat16())
 * wrong values returned when converting NaN/Inf into non-IEEE
   half precision value
 * wrong values returned for conversion of values which are
   on the boundary between denormal and zero for the half
   precision format
 * zeroes not correctly identified
 * excessively large results in non-IEEE mode should
   generate InvalidOp, not Overflow

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Honour default_nan_mode for float-to-float conversions
Christophe Lyon [Thu, 10 Feb 2011 11:28:57 +0000 (11:28 +0000)]
softfloat: Honour default_nan_mode for float-to-float conversions

Honour the default_nan_mode flag when doing conversions between
different floating point formats, as well as when returning a NaN from
a two-operand floating point function. This corrects the behaviour
of float<->double conversions on both ARM and SH4.

Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agosoftfloat: Add float16 type and float16 NaN handling functions
Peter Maydell [Thu, 10 Feb 2011 11:28:56 +0000 (11:28 +0000)]
softfloat: Add float16 type and float16 NaN handling functions

Add a float16 type to softfloat, rather than using bits16 directly.
Also add the missing functions float16_is_quiet_nan(),
float16_is_signaling_nan() and float16_maybe_silence_nan(),
which are needed for the float16 conversion routines.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoMake tb_alloc static
Tristan Gingold [Thu, 10 Feb 2011 09:04:57 +0000 (10:04 +0100)]
Make tb_alloc static

This function is only used within exec.c, so no need to make it public.

Signed-off-by: Tristan Gingold <gingold@adacore.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
13 years agoqcow2: Fix order in L2 table COW
Kevin Wolf [Wed, 9 Feb 2011 16:36:19 +0000 (17:36 +0100)]
qcow2: Fix order in L2 table COW

When copying L2 tables (this happens only with internal snapshots), the order
wasn't completely safe, so that after a crash you could end up with a L2 table
that has too low refcount, possibly leading to corruption in the long run.

This patch puts the operations in the right order: First allocate the new
L2 table and replace the reference, and only then decrease the refcount of the
old table.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Plug memory leak in drive_init() error paths
Markus Armbruster [Tue, 8 Feb 2011 14:12:39 +0000 (15:12 +0100)]
blockdev: Plug memory leak in drive_init() error paths

Should have spotted this when doing commit 319ae529.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoblockdev: Plug memory leak in drive_uninit()
Markus Armbruster [Tue, 8 Feb 2011 14:12:38 +0000 (15:12 +0100)]
blockdev: Plug memory leak in drive_uninit()

Started leaking in commit 1dae12e6.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoqemu-img: Improve error messages for failed bdrv_open
Kevin Wolf [Wed, 9 Feb 2011 10:25:53 +0000 (11:25 +0100)]
qemu-img: Improve error messages for failed bdrv_open

Output the error message string of the bdrv_open return code. Also set a
non-empty device name for the images because the unknown feature error message
includes it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqed: Report error for unsupported features
Kevin Wolf [Wed, 9 Feb 2011 10:13:26 +0000 (11:13 +0100)]
qed: Report error for unsupported features

Instead of just returning -ENOTSUP, generate a more detailed error.

Unfortunately we don't have a helpful text for features that we don't know yet,
so just print the feature mask. It might be useful at least if someone asks for
help.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Acked-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
13 years agoqcow2: Report error for version > 2
Kevin Wolf [Wed, 9 Feb 2011 10:11:07 +0000 (11:11 +0100)]
qcow2: Report error for version > 2

The qcow2 driver is now declared responsible for any QCOW image that has
version 2 or greater (before this, version 3 would be detected as raw).

For everything newer than version 2, an error is reported.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE
Kevin Wolf [Wed, 9 Feb 2011 10:09:38 +0000 (11:09 +0100)]
qerror: Add QERR_UNKNOWN_BLOCK_FORMAT_FEATURE

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
13 years agoqcow2: Fix error handling for reading compressed clusters
Kevin Wolf [Wed, 9 Feb 2011 09:26:06 +0000 (10:26 +0100)]
qcow2: Fix error handling for reading compressed clusters

When reading a compressed cluster failed, qcow2 falsely returned success.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
13 years agoqcow2: Fix error handling for immediate backing file read failure
Kevin Wolf [Tue, 8 Feb 2011 17:12:35 +0000 (18:12 +0100)]
qcow2: Fix error handling for immediate backing file read failure

Requests could return success even though they failed when bdrv_aio_readv
returned NULL for a backing file read.

Reported-by: Chunqiang Tang <ctang@us.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
13 years agoQCOW2: bug fix - read base image beyond its size
Chunqiang Tang [Thu, 3 Feb 2011 15:12:49 +0000 (10:12 -0500)]
QCOW2: bug fix - read base image beyond its size

This patch fixes the following bug in QCOW2. For a QCOW2 image that is larger
than its base image, when handling a read request straddling over the end of the
base image, the QCOW2 driver attempts to read beyond the end of the base image
and the request would fail.

This bug was found by Fast Virtual Disk (FVD)'s fully automated testing tool.
The following test triggered the bug.

dd if=/dev/zero of=/var/ramdisk/truth.raw count=0 bs=1 seek=1098561536
dd if=/dev/zero of=/var/ramdisk/zero-500M.raw count=0 bs=1 seek=593099264
./qemu-img create -f qcow2 -ocluster_size=65536,backing_fmt=blksim -b /var/ramdisk/zero-500M.raw /var/ramdisk/test.qcow2 1098561536
./qemu-io --auto --seed=30477694 --truth=/var/ramdisk/truth.raw --format=qcow2 --test=blksim:/var/ramdisk/test.qcow2 --verify_write=true --compare_before=false --compare_after=true --round=100000 --parallel=100 --io_size=10485760 --fail_prob=0 --cancel_prob=0 --instant_qemubh=true

Signed-off-by: Chunqiang Tang <ctang@us.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>