diff options
Diffstat (limited to 'drivers/kvm/mmu.c')
-rw-r--r-- | drivers/kvm/mmu.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 1dcbbd511660..da4d7ddb9bdc 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c | |||
@@ -292,12 +292,13 @@ static int is_empty_shadow_page(hpa_t page_hpa) | |||
292 | return 1; | 292 | return 1; |
293 | } | 293 | } |
294 | 294 | ||
295 | static hpa_t kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, u64 *parent_pte) | 295 | static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, |
296 | u64 *parent_pte) | ||
296 | { | 297 | { |
297 | struct kvm_mmu_page *page; | 298 | struct kvm_mmu_page *page; |
298 | 299 | ||
299 | if (list_empty(&vcpu->free_pages)) | 300 | if (list_empty(&vcpu->free_pages)) |
300 | return INVALID_PAGE; | 301 | return NULL; |
301 | 302 | ||
302 | page = list_entry(vcpu->free_pages.next, struct kvm_mmu_page, link); | 303 | page = list_entry(vcpu->free_pages.next, struct kvm_mmu_page, link); |
303 | list_del(&page->link); | 304 | list_del(&page->link); |
@@ -306,7 +307,7 @@ static hpa_t kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, u64 *parent_pte) | |||
306 | page->slot_bitmap = 0; | 307 | page->slot_bitmap = 0; |
307 | page->global = 1; | 308 | page->global = 1; |
308 | page->parent_pte = parent_pte; | 309 | page->parent_pte = parent_pte; |
309 | return page->page_hpa; | 310 | return page; |
310 | } | 311 | } |
311 | 312 | ||
312 | static void page_header_update_slot(struct kvm *kvm, void *pte, gpa_t gpa) | 313 | static void page_header_update_slot(struct kvm *kvm, void *pte, gpa_t gpa) |
@@ -402,19 +403,16 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p) | |||
402 | } | 403 | } |
403 | 404 | ||
404 | if (table[index] == 0) { | 405 | if (table[index] == 0) { |
405 | hpa_t new_table = kvm_mmu_alloc_page(vcpu, | 406 | struct kvm_mmu_page *new_table; |
406 | &table[index]); | ||
407 | 407 | ||
408 | if (!VALID_PAGE(new_table)) { | 408 | new_table = kvm_mmu_alloc_page(vcpu, &table[index]); |
409 | if (!new_table) { | ||
409 | pgprintk("nonpaging_map: ENOMEM\n"); | 410 | pgprintk("nonpaging_map: ENOMEM\n"); |
410 | return -ENOMEM; | 411 | return -ENOMEM; |
411 | } | 412 | } |
412 | 413 | ||
413 | if (level == PT32E_ROOT_LEVEL) | 414 | table[index] = new_table->page_hpa | PT_PRESENT_MASK |
414 | table[index] = new_table | PT_PRESENT_MASK; | 415 | | PT_WRITABLE_MASK | PT_USER_MASK; |
415 | else | ||
416 | table[index] = new_table | PT_PRESENT_MASK | | ||
417 | PT_WRITABLE_MASK | PT_USER_MASK; | ||
418 | } | 416 | } |
419 | table_addr = table[index] & PT64_BASE_ADDR_MASK; | 417 | table_addr = table[index] & PT64_BASE_ADDR_MASK; |
420 | } | 418 | } |
@@ -454,7 +452,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
454 | hpa_t root = vcpu->mmu.root_hpa; | 452 | hpa_t root = vcpu->mmu.root_hpa; |
455 | 453 | ||
456 | ASSERT(!VALID_PAGE(root)); | 454 | ASSERT(!VALID_PAGE(root)); |
457 | root = kvm_mmu_alloc_page(vcpu, NULL); | 455 | root = kvm_mmu_alloc_page(vcpu, NULL)->page_hpa; |
458 | vcpu->mmu.root_hpa = root; | 456 | vcpu->mmu.root_hpa = root; |
459 | return; | 457 | return; |
460 | } | 458 | } |
@@ -463,7 +461,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu) | |||
463 | hpa_t root = vcpu->mmu.pae_root[i]; | 461 | hpa_t root = vcpu->mmu.pae_root[i]; |
464 | 462 | ||
465 | ASSERT(!VALID_PAGE(root)); | 463 | ASSERT(!VALID_PAGE(root)); |
466 | root = kvm_mmu_alloc_page(vcpu, NULL); | 464 | root = kvm_mmu_alloc_page(vcpu, NULL)->page_hpa; |
467 | vcpu->mmu.pae_root[i] = root | PT_PRESENT_MASK; | 465 | vcpu->mmu.pae_root[i] = root | PT_PRESENT_MASK; |
468 | } | 466 | } |
469 | vcpu->mmu.root_hpa = __pa(vcpu->mmu.pae_root); | 467 | vcpu->mmu.root_hpa = __pa(vcpu->mmu.pae_root); |