From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: Reset problem vs. MMIO emulation, hypercalls, etc... Date: Sun, 05 Aug 2012 11:55:56 +0300 Message-ID: <501E351C.8080603@redhat.com> References: <1343791031.16975.41.camel@pasglop> <501A740F.2000000@redhat.com> <501A7B31.9060506@redhat.com> <1343939348.6911.15.camel@pasglop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Alexander Graf , kvm@vger.kernel.org, Paul Mackerras , kvm-ppc@vger.kernel.org To: Benjamin Herrenschmidt Return-path: In-Reply-To: <1343939348.6911.15.camel@pasglop> Sender: kvm-ppc-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 08/02/2012 11:29 PM, Benjamin Herrenschmidt wrote: > On Thu, 2012-08-02 at 16:05 +0300, Avi Kivity wrote: >> > Yeah, we stumbled over this chunk as well. So you're saying we >> should delay the reset by invoking a self-signal if we're in such an >> operation? >> >> Yes. Qemu of course already supports this for migration, so it should >> be easy to add. > > Adding a self signal for the CPU initiating the reset is not enough, > other VCPUs might also be in an hcall or MMIO emulation when that > happens. That happens naturally if you update (or read) registers through a run_on_cpu() call. run_on_cpu() should never happen within an mmio sequence. > > It must be done for all VCPUs, so best is to look at the migration > situation. > > For reset, there are two code path at play: > > - The VCPU initiating the request: It calls qemu_system_reset_request() > which calls cpu_stop_current() directly after signaling the main loop > > - The other VCPUs are then marked with the "stop" flag by the maintloop > which will then wait for them to set "stopped" to 1, which is done by > qemu_wait_io_event_common() when it sees "stop". > > Now, it seems like suspend also uses that same technique. I don't > totally grasp where migration fits in that picture and where it does the > KVM_RUN with a signal pending trick to complete pending operations, any > chance you can enlighten me ? I'm afraid I no longer know the details so closely, the code has changed quite a lot. But the self-signal happens in kvm_cpu_exec(), see also env->exit_request. -- error compiling committee.c: too many arguments to function