From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH] revert part of 3db8b916e merge Date: Wed, 3 Jun 2009 15:20:40 +0300 Message-ID: <20090603122040.GD11384@redhat.com> References: <20090603120756.GC11384@redhat.com> <4A2669AE.3010602@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx2.redhat.com ([66.187.237.31]:57973 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753061AbZFCMUk (ORCPT ); Wed, 3 Jun 2009 08:20:40 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n53CKgGR006405 for ; Wed, 3 Jun 2009 08:20:42 -0400 Content-Disposition: inline In-Reply-To: <4A2669AE.3010602@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Jun 03, 2009 at 03:16:46PM +0300, Avi Kivity wrote: > Gleb Natapov wrote: >> kvm_*_mpstate() cannot be called from kvm_arch_*_registers() >> since kvm_arch_*_registers() sometimes called from io thread, but >> kvm_*_mpstate() can be called only by cpu thread. >> >> > > I really dislike vcpu functions to be called from outside the vcpu > thread. Who are the callers? > monitor.c. May be others (git grep cpu_synchronize_state). But kvm_save_registers() does the right thing and calls another function on vcpu thread. >> Signed-off-by: Gleb Natapov >> diff --git a/qemu-kvm.c b/qemu-kvm.c >> index 68d3b92..7ed1e06 100644 >> --- a/qemu-kvm.c >> +++ b/qemu-kvm.c >> @@ -1431,26 +1431,3 @@ void qemu_kvm_cpu_stop(CPUState *env) >> if (kvm_enabled()) >> env->kvm_cpu_state.stopped = 1; >> } >> - >> -void kvm_arch_get_registers(CPUState *env) >> -{ >> - kvm_save_registers(env); >> - kvm_save_mpstate(env); >> -} >> - >> -void kvm_arch_put_registers(CPUState *env) >> -{ >> - kvm_load_registers(env); >> - kvm_load_mpstate(env); >> -} >> - >> - >> -void cpu_synchronize_state(CPUState *env, int modified) >> -{ >> - if (kvm_enabled()) { >> - if (modified) >> - kvm_arch_put_registers(env); >> - else >> - kvm_arch_get_registers(env); >> - } >> -} >> diff --git a/qemu-kvm.h b/qemu-kvm.h >> index 725589b..5d47e88 100644 >> --- a/qemu-kvm.h >> +++ b/qemu-kvm.h >> @@ -216,10 +216,25 @@ int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len); >> static inline int kvm_sync_vcpus(void) { return 0; } >> -void kvm_arch_get_registers(CPUState *env); >> -void kvm_arch_put_registers(CPUState *env); >> +static inline void kvm_arch_get_registers(CPUState *env) >> +{ >> + kvm_save_registers(env); >> +} >> -void cpu_synchronize_state(CPUState *env, int modified); >> +static inline void kvm_arch_put_registers(CPUState *env) >> +{ >> + kvm_load_registers(env); >> +} >> + >> +static inline void cpu_synchronize_state(CPUState *env, int modified) >> +{ >> + if (kvm_enabled()) { >> + if (modified) >> + kvm_arch_put_registers(env); >> + else >> + kvm_arch_get_registers(env); >> + } >> +} >> uint32_t kvm_arch_get_supported_cpuid(CPUState *env, uint32_t >> function, >> int reg); >> diff --git a/target-i386/machine.c b/target-i386/machine.c >> index f280d3d..07df1e1 100644 >> --- a/target-i386/machine.c >> +++ b/target-i386/machine.c >> @@ -32,7 +32,10 @@ void cpu_save(QEMUFile *f, void *opaque) >> int32_t pending_irq; >> int i, bit; >> - cpu_synchronize_state(env, 0); >> + if (kvm_enabled()) { >> + kvm_save_registers(env); >> + kvm_save_mpstate(env); >> + } >> for(i = 0; i < CPU_NB_REGS; i++) >> qemu_put_betls(f, &env->regs[i]); >> -- >> Gleb. >> > > > -- > Do not meddle in the internals of kernels, for they are subtle and quick to panic. -- Gleb.