From: Yacine Subject: Difference between =?utf-8?b?dmNwdV9sb2Fk?= and =?utf-8?b?a3ZtX3NjaGVkX2lu?= ? Date: Tue, 20 Oct 2015 09:57:51 +0000 (UTC) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org Return-path: Received: from plane.gmane.org ([80.91.229.3]:39859 "EHLO plane.gmane.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752913AbbJTKAV (ORCPT ); Tue, 20 Oct 2015 06:00:21 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZoTi8-0005EI-7i for kvm@vger.kernel.org; Tue, 20 Oct 2015 12:00:04 +0200 Received: from machine107.orange-labs.com ([161.106.0.5]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Oct 2015 12:00:04 +0200 Received: from y_hebbal by machine107.orange-labs.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 20 Oct 2015 12:00:04 +0200 Sender: kvm-owner@vger.kernel.org List-ID: Hi, I'm a student working on virtual machine introspection. I'm trying to implement an application on top of KVM in which I need to trap writes to CR3 (host with 8 cores and guest with one vcpu). When I do this when handling a VM EXIT using: vmcs_set_bits(CPU_BASED_VM_EXEC_CONTROL, CPU_BASED_CR3_LOAD_EXITING), it works correctly and I can see the traps in my log file. Now when I do the same thing after receiving a command from Qemu (command is handled in kvm_vm_ioctl by calling a function I added to kvm_x86_ops vmx_x86_ops) I get a vmwrite error. I found out that the problem is because the logical processor on the host that is handling the ioctl command is not the same that is running the VM and holding its state; so I must do the vmwrite on the one executing the VM To change the logical cpu executing the VM, I tried this: vcpu_load; start cr3 trapping; vcpu_put it worked correctly (in my logs I see that vcpu.cpu become equal to "cpu = raw_smp_processor_id();") but the VM blocks for a lot of time due to mutex in vcpu_load (up to serveral seconds and sometimes minutes !) I replaced vcpu_load with kvm_sched_in, now everything works perfectly and the VM doesn't block at all (logs here: http://pastebin.com/h5XNNMcb). So, what I want to know is: what is the difference between vcpu_load and kvm_sched_in ? both of this functions call kvm_arch_vcpu_loadbut the latter one does it without doing a mutex Is there a problem in using kvm_sched_in instead of vcpu_load for my use case ?