summaryrefslogtreecommitdiffstats
path: root/cpus.c
Commit message (Collapse)AuthorAgeFilesLines
...
| * Stop current VCPU on synchronous reset requestsJan Kiszka2011-02-141-4/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
| * Prevent abortion on multiple VCPU kicksJan Kiszka2011-02-141-1/+5
| | | | | | | | | | | | | | | | | | | | | | 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>
* | io-thread: make sure to initialize qemu_work_cond and qemu_cpu_condAnthony Liguori2011-02-141-1/+3
|/ | | | Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* kvm: Do not use qemu_fair_mutexJan Kiszka2011-01-231-2/+0
| | | | | | | | | | 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. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
* cpus: flush all requests on each vm stopMichael S. Tsirkin2010-12-091-0/+2
| | | | | | | | | | Flush all requests once we have stopped all cpus and devices. Make sure disk is in consistent state. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Jason Wang <jasowang@redhat.com> Acked-by: Marcelo Tosatti <mtosatti@redhat.com>
* target-xxx: Use fprintf_function (format checking)Stefan Weil2010-10-301-2/+1
| | | | | | | | | | | | | 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 <blauwirbel@gmail.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* MCE: Relay UCR MCE to guestMarcelo Tosatti2010-10-201-8/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Port qemu-kvm's commit 4b62fff1101a7ad77553147717a8bd3bf79df7ef Author: Huang Ying <ying.huang@intel.com> 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, where some hardware error such as some memory error can be reported without PCC (processor context corrupted). To recover from such MCE, the corresponding memory will be unmapped, and all processes accessing the memory will be killed via SIGBUS. For KVM, if QEMU/KVM is killed, all guest processes will be killed too. So we relay SIGBUS from host OS to guest system via a UCR MCE injection. Then guest OS can isolate corresponding memory and kill necessary guest processes only. SIGBUS sent to main thread (not VCPU threads) will be broadcast to all VCPU threads as UCR MCE. aliguori: fix build Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* iothread: use signalfdMarcelo Tosatti2010-10-201-5/+69
| | | | | | | Block SIGALRM, SIGIO and consume them via signalfd. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* Rework debug exception processing for gdb useJan Kiszka2010-07-221-10/+16
| | | | | | | | | | | | | | | | | | 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 CPUDebugExcpHandler: cpu_debug_handler is registered as first handler, thus will be executed last after potential breakpoint emulation handlers. It sets informs the gdbstub about the debug event source, requests a debug exit of the main loop and stops the current VCPU. This mechanism works both for TCG and KVM, with and without IO-thread. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Rename tcg_cpu_exec and tcg_has_workJan Kiszka2010-07-221-5/+5
| | | | | | | | | | These functions are also used for kvm under !CONFIG_IOTHREAD, having 'tcg' in their name is just misleading. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Drop redundant global cur_cpu variableJan Kiszka2010-07-221-3/+2
| | | | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix qemu_wait_io_event processing in io-thread modeJan Kiszka2010-07-221-4/+9
| | | | | | | | | | | | | | 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. Rename qemu_wait_io_event to qemu_tcg_wait_io_event at this chance and purge its argument list as it has no use for it. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix cpu_exit for tcp_cpu_execJan Kiszka2010-07-221-1/+2
| | | | | | | | | | | | | 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. This preserves the VCPU scheduling order in SMP mode. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Init qemu_system_condJan Kiszka2010-07-221-0/+1
| | | | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Fix io-thread build breakage of a88790a14fJan Kiszka2010-07-061-0/+1
| | | | | Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* make qemu_thread_create block all signalsPaolo Bonzini2010-06-141-27/+11
| | | | | | | All signals will thus be routed through the IO thread. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* cpus: add one 'const'Blue Swirl2010-05-141-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* add cpu_is_stopped helperMarcelo Tosatti2010-05-111-0/+5
| | | | | Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* port qemu-kvm's on_vcpu codeMarcelo Tosatti2010-05-111-0/+53
| | | | | | | run_on_cpu allows to execute work on a given CPUState context. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* standardize on qemu_cpu_kick for signalling cpu thread(s)Marcelo Tosatti2010-05-111-5/+2
| | | | | Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* make SIG_IPI to tcg vcpu thread reliableMarcelo Tosatti2010-05-111-14/+9
| | | | | | | | | | 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 <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* Fix cpu list("-cpu ?") breakage, spotted by TeLeManBlue Swirl2010-05-041-0/+11
| | | | | | Fix breakage by 04c9a0cbc2bf496889cef6da2d61bf00ef190a4f. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* kvm_init_vcpu requires global lock heldMarcelo Tosatti2010-04-261-1/+1
| | | | | | Since it accesses data protected by the lock. Signed-off-by: Avi Kivity <avi@redhat.com>
* Fix build when configured with --enable-io-threadBlue Swirl2010-04-121-0/+16
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* fix 100% cpu utilization when cpu is stoppedPaolo Bonzini2010-04-071-4/+2
| | | | | | | | | | | | | | | | | | | | | | | > 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 > (i.e. the breakpoint is hit or C-c is pressed inside gdb to > interrupt the attached qemu instance) The bug is that env->stopped is not really as comprehensive as it seems to be (and cpu_has_work thinks); it is only valid with iothread basically, and even then it is cleared by reset and it is not set when starting qemu with -S. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Cc: malc <av1474@comtv.ru> Signed-off-by: malc <av1474@comtv.ru>
* Compile qemu-timer only onceBlue Swirl2010-03-291-0/+16
| | | | | | | | | 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 <blauwirbel@gmail.com>
* Refactor CPUState handling out of vl.cBlue Swirl2010-03-291-0/+773
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
OpenPOWER on IntegriCloud