Commit 5df34a86 authored by Avi Kivity's avatar Avi Kivity

KVM: MMU: Move dirty bit updates to a separate function

Signed-off-by: default avatarAvi Kivity <avi@qumranet.com>
parent 6bfccdc9
...@@ -69,6 +69,17 @@ struct guest_walker { ...@@ -69,6 +69,17 @@ struct guest_walker {
u32 error_code; u32 error_code;
}; };
static void FNAME(update_dirty_bit)(struct kvm_vcpu *vcpu,
int write_fault,
pt_element_t *ptep,
gfn_t table_gfn)
{
if (write_fault && !is_dirty_pte(*ptep)) {
mark_page_dirty(vcpu->kvm, table_gfn);
*ptep |= PT_DIRTY_MASK;
}
}
/* /*
* Fetch a guest pte for a guest virtual address * Fetch a guest pte for a guest virtual address
*/ */
...@@ -144,10 +155,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker, ...@@ -144,10 +155,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
if (walker->level == PT_PAGE_TABLE_LEVEL) { if (walker->level == PT_PAGE_TABLE_LEVEL) {
walker->gfn = (*ptep & PT_BASE_ADDR_MASK) walker->gfn = (*ptep & PT_BASE_ADDR_MASK)
>> PAGE_SHIFT; >> PAGE_SHIFT;
if (write_fault && !is_dirty_pte(*ptep)) { FNAME(update_dirty_bit)(vcpu, write_fault, ptep,
mark_page_dirty(vcpu->kvm, table_gfn); table_gfn);
*ptep |= PT_DIRTY_MASK;
}
break; break;
} }
...@@ -157,10 +166,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker, ...@@ -157,10 +166,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker,
walker->gfn = (*ptep & PT_DIR_BASE_ADDR_MASK) walker->gfn = (*ptep & PT_DIR_BASE_ADDR_MASK)
>> PAGE_SHIFT; >> PAGE_SHIFT;
walker->gfn += PT_INDEX(addr, PT_PAGE_TABLE_LEVEL); walker->gfn += PT_INDEX(addr, PT_PAGE_TABLE_LEVEL);
if (write_fault && !is_dirty_pte(*ptep)) { FNAME(update_dirty_bit)(vcpu, write_fault, ptep,
mark_page_dirty(vcpu->kvm, table_gfn); table_gfn);
*ptep |= PT_DIRTY_MASK;
}
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment