From 67a10f1a02de52e1fabeb02d014d895f8728770a Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 13 Mar 2012 13:44:37 +0100 Subject: [PATCH 4/5] Prevent partially initialized vcpu being visible RH-Author: Igor Mammedov Message-id: <1331646277-28469-5-git-send-email-imammedo@redhat.com> Patchwork-id: 38483 O-Subject: [RHEL6.3 qemu-kvm PATCH 4/4] Prevent partially initialized vcpu being visible Bugzilla: 562886 RH-Acked-by: Gleb Natapov RH-Acked-by: Alex Williamson RH-Acked-by: Andrew Jones Bugzilla: 562886 Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=4146795 Hunks 3,4 from: http://git.kiszka.org/?p=qemu-kvm.git;a=commitdiff;h=be8f21c6b54eac82f7add7ee9d4ecf9cb8ebb320 We need to synchronize VCPU initialization with the other QEMU threads (so that no semi-initialized VCPU is visible at any time) back-porting cpu_synchronize_post_init is not neccessary because of kvm_arch_put_registers is called for a new cpu which is roughly the same. ap_main_loop -> kvm_main_loop_cpu -> kvm_cpu_exec ->kvm_run -> pre_kvm_run -> kvm_arch_put_registers Signed-off-by: Igor Mammedov --- hw/pc.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) Signed-off-by: Michal Novotny --- hw/pc.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index b4cfa9a..683c10d 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -990,6 +990,10 @@ CPUState *pc_new_cpu(const char *cpu_model) { CPUState *env; + if (runstate_is_running()) { + pause_all_vcpus(); + } + env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to support requested x86 CPU definition\n"); @@ -1008,6 +1012,11 @@ CPUState *pc_new_cpu(const char *cpu_model) * it can access invalid state and crash. */ qemu_init_vcpu(env); + + if (runstate_is_running()) { + resume_all_vcpus(); + } + return env; } -- 1.7.7.6