From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH] revert part of 3db8b916e merge Date: Wed, 03 Jun 2009 15:16:46 +0300 Message-ID: <4A2669AE.3010602@redhat.com> References: <20090603120756.GC11384@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx2.redhat.com ([66.187.237.31]:58574 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753332AbZFCMQr (ORCPT ); Wed, 3 Jun 2009 08:16:47 -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 n53CGn3B004597 for ; Wed, 3 Jun 2009 08:16:49 -0400 In-Reply-To: <20090603120756.GC11384@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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? > 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.