On Sat, Dec 21, 2019 at 02:51:52PM +0100, Paolo Bonzini wrote: > On 21/12/19 02:49, Peter Xu wrote: > > Originally, we have three code paths that can dirty a page without > > vcpu context for X86: > > > > - init_rmode_identity_map > > - init_rmode_tss > > - kvmgt_rw_gpa > > > > init_rmode_identity_map and init_rmode_tss will be setup on > > destination VM no matter what (and the guest cannot even see them), so > > it does not make sense to track them at all. > > > > To do this, a new parameter is added to kvm_[write|clear]_guest_page() > > to show whether we would like to track dirty bits for the operations. > > With that, pass in "false" to this new parameter for any guest memory > > write of the ioctls (KVM_SET_TSS_ADDR, KVM_SET_IDENTITY_MAP_ADDR). > > We can also return the hva from x86_set_memory_region and > __x86_set_memory_region. Yes. Though it is a bit tricky in that then we'll also need to make sure to take slots_lock or srcu to protect that hva (say, we must drop that hva reference before we release the locks, otherwise the hva could gone under us, iiuc). So if we want to do that we'd better comment on that hva value very explicitly, just in case some future callers of __x86_set_memory_region could cache it somewhere. (Side topic: I feel like the srcu_read_lock() pair in init_rmode_identity_map() is redundant..) -- Peter Xu