Kernel KVM virtualization development
 help / color / mirror / Atom feed
* tlb flushing after spin_unlock of mmu lock
@ 2009-04-11  4:45 Peter Teoh
  2009-04-16 19:19 ` Marcelo Tosatti
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Teoh @ 2009-04-11  4:45 UTC (permalink / raw)
  To: kvm

In this function, the TLB flushing comes before spin unlock,

void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
{
       struct kvm_mmu_page *sp;

       spin_lock(&kvm->mmu_lock);

       kvm_flush_remote_tlbs(kvm);
       spin_unlock(&kvm->mmu_lock);
}


but in kvm_vm_ioctl_set_memory_alias():

       spin_unlock(&kvm->mmu_lock);
       kvm_mmu_zap_all(kvm);

it comes after inside kvm_mmu_zap_all().   Does it sound logical?


-- 
Regards,
Peter Teoh

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: tlb flushing after spin_unlock of mmu lock
  2009-04-11  4:45 tlb flushing after spin_unlock of mmu lock Peter Teoh
@ 2009-04-16 19:19 ` Marcelo Tosatti
  0 siblings, 0 replies; 2+ messages in thread
From: Marcelo Tosatti @ 2009-04-16 19:19 UTC (permalink / raw)
  To: Peter Teoh; +Cc: kvm

Peter,

On Sat, Apr 11, 2009 at 12:45:21AM -0400, Peter Teoh wrote:
> In this function, the TLB flushing comes before spin unlock,
> 
> void kvm_mmu_slot_remove_write_access(struct kvm *kvm, int slot)
> {
>        struct kvm_mmu_page *sp;
> 
>        spin_lock(&kvm->mmu_lock);
> 
>        kvm_flush_remote_tlbs(kvm);
>        spin_unlock(&kvm->mmu_lock);
> }

kvm_vm_ioctl_get_dirty_log does:


	down_write(slots_lock)

	- collect data from dirty bitmap (kvm_get_dirty_log)
	if (something was dirty)
		- remove write access for all translations
		- flush remote tlb's
		- clear the dirty bitmap

	up_write(slots_lock)

The vmexit path (take a look at vcpu_run), takes slots_lock in
read-mode. This means that no other vcpu will be able to dirty a
shadow translation (spte) in the meantime.

So its safe.
		
> but in kvm_vm_ioctl_set_memory_alias():
> 
>        spin_unlock(&kvm->mmu_lock);
>        kvm_mmu_zap_all(kvm);
> 
> it comes after inside kvm_mmu_zap_all().   Does it sound logical?

Note that here it also takes slots_lock in write-mode, which blocks all
other vcpus.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-04-16 19:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-11  4:45 tlb flushing after spin_unlock of mmu lock Peter Teoh
2009-04-16 19:19 ` Marcelo Tosatti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox