diff options
Diffstat (limited to 'drivers/kvm')
-rw-r--r-- | drivers/kvm/paging_tmpl.h | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index 4538b1533d5b..a0f84a5379a4 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -69,6 +69,17 @@ struct guest_walker { | |||
69 | u32 error_code; | 69 | u32 error_code; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static void FNAME(update_dirty_bit)(struct kvm_vcpu *vcpu, | ||
73 | int write_fault, | ||
74 | pt_element_t *ptep, | ||
75 | gfn_t table_gfn) | ||
76 | { | ||
77 | if (write_fault && !is_dirty_pte(*ptep)) { | ||
78 | mark_page_dirty(vcpu->kvm, table_gfn); | ||
79 | *ptep |= PT_DIRTY_MASK; | ||
80 | } | ||
81 | } | ||
82 | |||
72 | /* | 83 | /* |
73 | * Fetch a guest pte for a guest virtual address | 84 | * Fetch a guest pte for a guest virtual address |
74 | */ | 85 | */ |
@@ -144,10 +155,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker, | |||
144 | if (walker->level == PT_PAGE_TABLE_LEVEL) { | 155 | if (walker->level == PT_PAGE_TABLE_LEVEL) { |
145 | walker->gfn = (*ptep & PT_BASE_ADDR_MASK) | 156 | walker->gfn = (*ptep & PT_BASE_ADDR_MASK) |
146 | >> PAGE_SHIFT; | 157 | >> PAGE_SHIFT; |
147 | if (write_fault && !is_dirty_pte(*ptep)) { | 158 | FNAME(update_dirty_bit)(vcpu, write_fault, ptep, |
148 | mark_page_dirty(vcpu->kvm, table_gfn); | 159 | table_gfn); |
149 | *ptep |= PT_DIRTY_MASK; | ||
150 | } | ||
151 | break; | 160 | break; |
152 | } | 161 | } |
153 | 162 | ||
@@ -157,10 +166,8 @@ static int FNAME(walk_addr)(struct guest_walker *walker, | |||
157 | walker->gfn = (*ptep & PT_DIR_BASE_ADDR_MASK) | 166 | walker->gfn = (*ptep & PT_DIR_BASE_ADDR_MASK) |
158 | >> PAGE_SHIFT; | 167 | >> PAGE_SHIFT; |
159 | walker->gfn += PT_INDEX(addr, PT_PAGE_TABLE_LEVEL); | 168 | walker->gfn += PT_INDEX(addr, PT_PAGE_TABLE_LEVEL); |
160 | if (write_fault && !is_dirty_pte(*ptep)) { | 169 | FNAME(update_dirty_bit)(vcpu, write_fault, ptep, |
161 | mark_page_dirty(vcpu->kvm, table_gfn); | 170 | table_gfn); |
162 | *ptep |= PT_DIRTY_MASK; | ||
163 | } | ||
164 | break; | 171 | break; |
165 | } | 172 | } |
166 | 173 | ||