lkml.org 
[lkml]   [2010]   [Jul]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 3/6] KVM: MMU: fix page dirty tracking lost while sync page
On 07/16/2010 06:25 AM, Xiao Guangrong wrote:
> In sync-page path, if spte.writable is changed, it will lose page dirty
> tracking, for example:
>
> assume spte.writable = 0 in a unsync-page, when it's synced, it map spte
> to writable(that is spte.writable = 1), later guest write spte.gfn, it means
> spte.gfn is dirty, then guest changed this mapping to read-only, after it's
> synced, spte.writable = 0
>
> So, when host release the spte, it detect spte.writable = 0 and not mark page
> dirty
>
>

Subtle, good catch.

> set_pte:
> + if (is_writable_pte(*sptep)&& !is_writable_pte(spte))
> + kvm_set_pfn_dirty(pfn);
> update_spte(sptep, spte);
>

I think this has to be done after the tlb flush, otherwise we have

set_pfn_dirty
(some other cpu) write out page, mark as clean
(some other vcpu writes through stale tlb entry)
update_spte
tlb flush

but perhaps mmu notifiers protect us here, if the cleaner wants to write
out the page it has to clear the dirty bit in sptes as well, and that
will block on mmu_lock.

Later on we can use the dirty bit instead of writeable bit, except on
EPT. But let's start with your fix.

--
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.



\
 
 \ /
  Last update: 2010-07-21 20:37    [W:0.068 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site