Statistics
| Branch: | Revision:

root / cpus.c @ 7a39fe58

History | View | Annotate | Download (25.3 kB)

# Date Author Comment
7e97cd88 02/14/2011 04:39 pm Jan Kiszka

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....

16400322 02/14/2011 04:39 pm Jan Kiszka

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 <>...

0ab07c62 02/14/2011 04:39 pm Jan Kiszka

Fix a few coding style violations in cpus.c

No functional changes.

Signed-off-by: Jan Kiszka <>
Signed-off-by: Marcelo Tosatti <>

e07bbac5 02/14/2011 04:39 pm Jan Kiszka

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....

8cf71710 02/14/2011 04:39 pm Jan Kiszka

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...

83f338f7 02/14/2011 04:39 pm Jan Kiszka

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...

6792a57b 02/14/2011 04:39 pm Jan Kiszka

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....

d31ae052 02/14/2011 04:39 pm Jan Kiszka

kvm: Drop redundant kvm_enabled from kvm_cpu_thread_fn

Signed-off-by: Jan Kiszka <>
Signed-off-by: Marcelo Tosatti <>

84b4915d 02/14/2011 04:39 pm Jan Kiszka

kvm: Handle kvm_init_vcpu errors

Do not ignore errors of kvm_init_vcpu, they are fatal.

Signed-off-by: Jan Kiszka <>
Signed-off-by: Marcelo Tosatti <>

a1b87fe0 02/14/2011 04:39 pm Jan Kiszka

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 <>...

55f8d6ac 02/14/2011 04:39 pm Jan Kiszka

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...

ff48eb5f 02/14/2011 04:39 pm Jan Kiszka

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...

5db5bdac 02/14/2011 04:39 pm Jan Kiszka

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....

9a36085b 02/14/2011 04:39 pm Jan Kiszka

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 <>
Signed-off-by: Marcelo Tosatti <>

d0f294ce 02/14/2011 04:39 pm Jan Kiszka

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 <>
Reviewed-by: Paolo Bonzini <>
Signed-off-by: Marcelo Tosatti <>

de758970 02/14/2011 04:39 pm Jan Kiszka

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...

6d9cb73c 02/14/2011 04:39 pm Jan Kiszka

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....

46d62fac 02/14/2011 04:39 pm Jan Kiszka

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 <>
Signed-off-by: Marcelo Tosatti <>

aa2c364b 02/14/2011 04:39 pm Jan Kiszka

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....

b4a3d965 02/14/2011 04:39 pm Jan Kiszka

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...

38145df2 02/14/2011 04:39 pm Jan Kiszka

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...

b66042c7 01/23/2011 06:27 am Jan Kiszka

kvm: Do not use qemu_fair_mutex

The imbalance in the hold time of qemu_global_mutex only exists in TCG
mode. In contrast to TCG VCPUs, KVM drops the global lock during guest
execution. We already avoid touching the fairness lock from the
IO-thread in KVM mode, so also stop using it from the VCPU threads....

55df6f33 12/09/2010 12:47 pm Michael S. Tsirkin

cpus: flush all requests on each vm stop

Flush all requests once we have stopped all
cpus and devices.
Make sure disk is in consistent state.

Signed-off-by: Michael S. Tsirkin <>
Tested-by: Jason Wang <>
Acked-by: Marcelo Tosatti <>

9a78eead 10/30/2010 11:01 am Stefan Weil

target-xxx: Use fprintf_function (format checking)

fprintf_function uses format checking with GCC_FMT_ATTR.

Format errors were fixed in
  • target-i386/helper.c
  • target-mips/translate.c
  • target-ppc/translate.c

Cc: Blue Swirl <>
Signed-off-by: Stefan Weil <>...

a8486bc9 10/21/2010 12:15 am Marcelo Tosatti

iothread: use signalfd

Block SIGALRM, SIGIO and consume them via signalfd.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Avi Kivity <>

c0532a76 10/21/2010 12:15 am Marcelo Tosatti

MCE: Relay UCR MCE to guest

Port qemu-kvm's

commit 4b62fff1101a7ad77553147717a8bd3bf79df7ef
Author: Huang Ying <>
Date: Mon Sep 21 10:43:25 2009 +0800

MCE: Relay UCR MCE to guest
UCR (uncorrected recovery) MCE is supported in recent Intel CPUs,...
f8ca7b43 07/22/2010 06:52 am Jan Kiszka

Init qemu_system_cond

Signed-off-by: Jan Kiszka <>
Acked-by: Paolo Bonzini <>
Reviewed-by: Marcelo Tosatti <>
Signed-off-by: Aurelien Jarno <>

c629a4bc 07/22/2010 06:52 am Jan Kiszka

Fix cpu_exit for tcp_cpu_exec

If a cpu_exit request is pending, ensure that we leave the CPU loop
quickly. For this purpose, keep the global exit_request pending until
we are about to leave tcg_cpu_exec. Also, immediately break out of the
SMP loop if the request is set, do not run till the end of the chain....

6cabe1f3 07/22/2010 06:52 am Jan Kiszka

Fix qemu_wait_io_event processing in io-thread mode

When checking for I/O events in the tcg CPU loop, make sure that we
call qemu_wait_io_event_common for all CPUs, not only the current one.
Otherwise pause_all_vcpus may lock up or run_on_cpu requests may starve....

345f4426 07/22/2010 06:52 am Jan Kiszka

Drop redundant global cur_cpu variable

Signed-off-by: Jan Kiszka <>
Acked-by: Paolo Bonzini <>
Reviewed-by: Marcelo Tosatti <>
Signed-off-by: Aurelien Jarno <>

472fb0c4 07/22/2010 06:52 am Jan Kiszka

Rename tcg_cpu_exec and tcg_has_work

These functions are also used for kvm under !CONFIG_IOTHREAD, having
'tcg' in their name is just misleading.

Signed-off-by: Jan Kiszka <>
Acked-by: Paolo Bonzini <>
Reviewed-by: Marcelo Tosatti <>...

3c638d06 07/22/2010 06:52 am Jan Kiszka

Rework debug exception processing for gdb use

Guest debugging is currently broken under CONFIG_IOTHREAD. The reason is
inconsistent or even lacking signaling the debug events from the source
VCPU to the main loop and the gdbstub.

This patch addresses the issue by pushing this signaling into a...

262ea18e 07/06/2010 06:36 pm Jan Kiszka

Fix io-thread build breakage of a88790a14f

Signed-off-by: Jan Kiszka <>
Signed-off-by: Anthony Liguori <>

55541c8a 06/14/2010 11:46 pm Paolo Bonzini

make qemu_thread_create block all signals

All signals will thus be routed through the IO thread.

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Anthony Liguori <>

26a82330 05/14/2010 10:32 pm Blue Swirl

cpus: add one 'const'

Signed-off-by: Blue Swirl <>

1a28cac3 05/11/2010 08:02 pm Marcelo Tosatti

make SIG_IPI to tcg vcpu thread reliable

Store tcg loop exit request on a global variable, and transfer it to
per-CPUState exit_request after assignment of cpu_single_env.

This makes exit request signal from robust. Drop the timedlock hack.

Signed-off-by: Marcelo Tosatti <>...

1fbb22e5 05/11/2010 08:02 pm Marcelo Tosatti

standardize on qemu_cpu_kick for signalling cpu thread(s)

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Avi Kivity <>

e82bcec2 05/11/2010 08:02 pm Marcelo Tosatti

port qemu-kvm's on_vcpu code

run_on_cpu allows to execute work on a given CPUState context.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Avi Kivity <>

3ae9501c 05/11/2010 08:02 pm Marcelo Tosatti

add cpu_is_stopped helper

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Avi Kivity <>

262353cb 05/04/2010 10:55 pm Blue Swirl

Fix cpu list("-cpu ?") breakage, spotted by TeLeMan

Fix breakage by 04c9a0cbc2bf496889cef6da2d61bf00ef190a4f.

Signed-off-by: Blue Swirl <>

6164e6d6 04/26/2010 05:28 pm Marcelo Tosatti

kvm_init_vcpu requires global lock held

Since it accesses data protected by the lock.

Signed-off-by: Avi Kivity <>

7277e027 04/12/2010 08:19 pm Blue Swirl

Fix build when configured with --enable-io-thread

Signed-off-by: Blue Swirl <>

55274a30 04/07/2010 01:24 am Paolo Bonzini

fix 100% cpu utilization when cpu is stopped

Hello,

d6f4ade (disentangle tcg and deadline calculation, 2010-03-10)
introduces following regression(s):

100% cpu utilization when QEMU is invoked like:
qemu -S -s ...

ditto when gdb takes control over the session via gdb-stub...

29e922b6 03/29/2010 10:24 pm Blue Swirl

Compile qemu-timer only once

Arrange various declarations so that also non-CPU code can access
them, adjust users.

Move CPU specific code to cpus.c.

Signed-off-by: Blue Swirl <>

296af7c9 03/29/2010 10:23 pm Blue Swirl

Refactor CPUState handling out of vl.c

Signed-off-by: Blue Swirl <>