diff options
author | Avi Kivity <avi@qumranet.com> | 2007-11-21 07:08:40 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:11 -0500 |
commit | 4e542370c7570bdb582ab8c751ab899ff9e4214a (patch) | |
tree | 7fdb7ad0076d21a3833f67ef4cc37bce98e40153 /drivers/kvm/paging_tmpl.h | |
parent | da928521b7a095e85f6ac92a6c106bca7e17625f (diff) |
KVM: MMU: Remove extra gaddr parameter from set_pte_common()
Similar information is available in the gfn parameter, so use that.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/paging_tmpl.h')
-rw-r--r-- | drivers/kvm/paging_tmpl.h | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/drivers/kvm/paging_tmpl.h b/drivers/kvm/paging_tmpl.h index dceb4b9137a4..cc373ed1f049 100644 --- a/drivers/kvm/paging_tmpl.h +++ b/drivers/kvm/paging_tmpl.h | |||
@@ -188,7 +188,6 @@ err: | |||
188 | 188 | ||
189 | static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | 189 | static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, |
190 | u64 *shadow_pte, | 190 | u64 *shadow_pte, |
191 | gpa_t gaddr, | ||
192 | pt_element_t gpte, | 191 | pt_element_t gpte, |
193 | u64 access_bits, | 192 | u64 access_bits, |
194 | int user_fault, | 193 | int user_fault, |
@@ -197,7 +196,6 @@ static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | |||
197 | struct guest_walker *walker, | 196 | struct guest_walker *walker, |
198 | gfn_t gfn) | 197 | gfn_t gfn) |
199 | { | 198 | { |
200 | hpa_t paddr; | ||
201 | int dirty = gpte & PT_DIRTY_MASK; | 199 | int dirty = gpte & PT_DIRTY_MASK; |
202 | u64 spte; | 200 | u64 spte; |
203 | int was_rmapped = is_rmap_pte(*shadow_pte); | 201 | int was_rmapped = is_rmap_pte(*shadow_pte); |
@@ -218,26 +216,20 @@ static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | |||
218 | if (!dirty) | 216 | if (!dirty) |
219 | access_bits &= ~PT_WRITABLE_MASK; | 217 | access_bits &= ~PT_WRITABLE_MASK; |
220 | 218 | ||
221 | paddr = gpa_to_hpa(vcpu->kvm, gaddr & PT64_BASE_ADDR_MASK); | 219 | page = gfn_to_page(vcpu->kvm, gfn); |
222 | |||
223 | /* | ||
224 | * the reason paddr get mask even that it isnt pte is beacuse the | ||
225 | * HPA_ERR_MASK bit might be used to signal error | ||
226 | */ | ||
227 | page = pfn_to_page((paddr & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT); | ||
228 | 220 | ||
229 | spte |= PT_PRESENT_MASK; | 221 | spte |= PT_PRESENT_MASK; |
230 | if (access_bits & PT_USER_MASK) | 222 | if (access_bits & PT_USER_MASK) |
231 | spte |= PT_USER_MASK; | 223 | spte |= PT_USER_MASK; |
232 | 224 | ||
233 | if (is_error_hpa(paddr)) { | 225 | if (is_error_page(page)) { |
234 | set_shadow_pte(shadow_pte, | 226 | set_shadow_pte(shadow_pte, |
235 | shadow_trap_nonpresent_pte | PT_SHADOW_IO_MARK); | 227 | shadow_trap_nonpresent_pte | PT_SHADOW_IO_MARK); |
236 | kvm_release_page_clean(page); | 228 | kvm_release_page_clean(page); |
237 | return; | 229 | return; |
238 | } | 230 | } |
239 | 231 | ||
240 | spte |= paddr; | 232 | spte |= page_to_phys(page); |
241 | 233 | ||
242 | if ((access_bits & PT_WRITABLE_MASK) | 234 | if ((access_bits & PT_WRITABLE_MASK) |
243 | || (write_fault && !is_write_protection(vcpu) && !user_fault)) { | 235 | || (write_fault && !is_write_protection(vcpu) && !user_fault)) { |
@@ -266,14 +258,14 @@ static void FNAME(set_pte_common)(struct kvm_vcpu *vcpu, | |||
266 | unshadowed: | 258 | unshadowed: |
267 | 259 | ||
268 | if (access_bits & PT_WRITABLE_MASK) | 260 | if (access_bits & PT_WRITABLE_MASK) |
269 | mark_page_dirty(vcpu->kvm, gaddr >> PAGE_SHIFT); | 261 | mark_page_dirty(vcpu->kvm, gfn); |
270 | 262 | ||
271 | pgprintk("%s: setting spte %llx\n", __FUNCTION__, spte); | 263 | pgprintk("%s: setting spte %llx\n", __FUNCTION__, spte); |
272 | set_shadow_pte(shadow_pte, spte); | 264 | set_shadow_pte(shadow_pte, spte); |
273 | page_header_update_slot(vcpu->kvm, shadow_pte, gaddr); | 265 | page_header_update_slot(vcpu->kvm, shadow_pte, |
266 | (gpa_t)gfn << PAGE_SHIFT); | ||
274 | if (!was_rmapped) { | 267 | if (!was_rmapped) { |
275 | rmap_add(vcpu, shadow_pte, (gaddr & PT64_BASE_ADDR_MASK) | 268 | rmap_add(vcpu, shadow_pte, gfn); |
276 | >> PAGE_SHIFT); | ||
277 | if (!is_rmap_pte(*shadow_pte)) | 269 | if (!is_rmap_pte(*shadow_pte)) |
278 | kvm_release_page_clean(page); | 270 | kvm_release_page_clean(page); |
279 | } | 271 | } |
@@ -289,7 +281,7 @@ static void FNAME(set_pte)(struct kvm_vcpu *vcpu, pt_element_t gpte, | |||
289 | struct guest_walker *walker, gfn_t gfn) | 281 | struct guest_walker *walker, gfn_t gfn) |
290 | { | 282 | { |
291 | access_bits &= gpte; | 283 | access_bits &= gpte; |
292 | FNAME(set_pte_common)(vcpu, shadow_pte, gpte & PT_BASE_ADDR_MASK, | 284 | FNAME(set_pte_common)(vcpu, shadow_pte, |
293 | gpte, access_bits, user_fault, write_fault, | 285 | gpte, access_bits, user_fault, write_fault, |
294 | ptwrite, walker, gfn); | 286 | ptwrite, walker, gfn); |
295 | } | 287 | } |
@@ -318,11 +310,8 @@ static void FNAME(set_pde)(struct kvm_vcpu *vcpu, pt_element_t gpde, | |||
318 | int user_fault, int write_fault, int *ptwrite, | 310 | int user_fault, int write_fault, int *ptwrite, |
319 | struct guest_walker *walker, gfn_t gfn) | 311 | struct guest_walker *walker, gfn_t gfn) |
320 | { | 312 | { |
321 | gpa_t gaddr; | ||
322 | |||
323 | access_bits &= gpde; | 313 | access_bits &= gpde; |
324 | gaddr = (gpa_t)gfn << PAGE_SHIFT; | 314 | FNAME(set_pte_common)(vcpu, shadow_pte, |
325 | FNAME(set_pte_common)(vcpu, shadow_pte, gaddr, | ||
326 | gpde, access_bits, user_fault, write_fault, | 315 | gpde, access_bits, user_fault, write_fault, |
327 | ptwrite, walker, gfn); | 316 | ptwrite, walker, gfn); |
328 | } | 317 | } |