From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: tlb flush after each vm_exit, also virtual interrupts injection Date: Fri, 5 Aug 2016 07:59:46 -0400 (EDT) Message-ID: <1622465933.13766546.1470398386460.JavaMail.zimbra@redhat.com> References: <346384966.13112634.1470159219285.JavaMail.zimbra@redhat.com> <0f6d9ae0-d373-f651-4167-d4ad9facfb91@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: "Charls D. Chap" Return-path: Received: from mx4-phx2.redhat.com ([209.132.183.25]:40982 "EHLO mx4-phx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934333AbcHEL7s (ORCPT ); Fri, 5 Aug 2016 07:59:48 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: > >> So in the case of write I/O using virtio-blk dataplane=off > >> [...] What is going to happen after the host there is > >> the real I/O completion, the host complete bh is executed? We go > >> through iothread to guest, in order to executte the > >> virtio-blk-complete request? > > > > How did the control transfer to QEMU user space (and which thread is > running vcpu or worker) > ->virtio_blk_device_realize > -> virtio_blk_req_complete > Was it the "real" interrupt for I/O completion from the device? > > Which qemu thread executes the code you mentioned?, vcpu or a > worker(iothread or main_loop) When did iothread finish its work? There are two ways: 1) the VCPU thread starts the I/O (control is transferred to QEMU user space by leaving KVM_RUN). The I/O system call happens in a worker thread. When the systemc call is finished the worker thread wakes up the I/O thread and the I/O thread executes virtio_blk_req_complete. 2) the VCPU thread (which is running KVM_RUN) writes to an eventfd, which wakes up the I/O thread. The I/O thread runs the I/O system call in a worker thread, same as case 1. Also like case 1, when the I/O is finished the worker thread wakes up the I/O thread and the I/O thread executes virtio_blk_req_complete. > I know that there are many exit reasons, but it's not clear to me > HOW exactly, transfer the control from the execution of one of these > instructions > to VMEXIT point which is "vmx_return: " _ASM_PTR " 2b \n\t" > Where does this extraction happened and we jumped to this label? > Is it inside of the corresponding ioctl implementation? > > I guess the answer is: "read the manual", which is fine to me, because > you already helped me a lot :) This is a more specific question, and thus easier to answer: after a vmexit the instruction pointer is reset to the VMCS's HOST_RIP field, and KVM writes the address of vmx_return to that field. :) Paolo