From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 1/2] KVM: page track: add a new notifier type: track_flush_slot Date: Tue, 11 Oct 2016 17:21:07 +0800 Message-ID: References: <1475998904-13456-1-git-send-email-xiaoguang.chen@intel.com> <1475998904-13456-2-git-send-email-xiaoguang.chen@intel.com> <20161009083134.GA19090@nvidia.com> <20161010180140.GA27757@nvidia.com> <1259cdba-c137-c3da-abe2-ecf51aec6738@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, guangrong.xiao@intel.com, jike.song@intel.com, Kirti Wankhede To: Paolo Bonzini , Neo Jia , Xiaoguang Chen Return-path: Received: from mga02.intel.com ([134.134.136.20]:30619 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbcJKJ1p (ORCPT ); Tue, 11 Oct 2016 05:27:45 -0400 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 10/11/2016 04:54 PM, Paolo Bonzini wrote: > > > On 11/10/2016 04:39, Xiao Guangrong wrote: >> >> >> On 10/11/2016 02:32 AM, Paolo Bonzini wrote: >>> >>> >>> On 10/10/2016 20:01, Neo Jia wrote: >>>>> Hi Neo, >>>>> >>>>> AFAIK this is needed because KVMGT doesn't paravirtualize the PPGTT, >>>>> while nVidia does. >>>> >>>> Hi Paolo and Xiaoguang, >>>> >>>> I am just wondering how device driver can register a notifier so he >>>> can be >>>> notified for write-protected pages when writes are happening. >>> >>> It can't yet, but the API is ready for that. kvm_vfio_set_group is >>> currently where a struct kvm_device* and struct vfio_group* touch. Given >>> a struct kvm_device*, dev->kvm provides the struct kvm to be passed to >>> kvm_page_track_register_notifier. So I guess you could add a callback >>> that passes the struct kvm_device* to the mdev device. >>> >>> Xiaoguang and Guangrong, what were your plans? We discussed it briefly >>> at KVM Forum but I don't remember the details. >>> >> >> Your suggestion was that pass kvm fd to KVMGT via VFIO, so that we can >> figure out the kvm instance based on the fd. >> >> We got a new idea, how about search the kvm instance by mm_struct, it >> can work as KVMGT is running in the vcpu context and it is much more >> straightforward. > > Perhaps I didn't understand your suggestion, but the same mm_struct can > have more than 1 struct kvm so I'm not sure that it can work. vcpu->pid is valid during vcpu running so that it can be used to figure out which kvm instance owns the vcpu whose pid is the one as current thread, i think it can work. :)