diff options
-rw-r--r-- | arch/x86/kvm/mmu.c | 27 | ||||
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 10 |
2 files changed, 19 insertions, 18 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 9832bc9e937e..74c120cd63fd 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c | |||
@@ -2564,13 +2564,13 @@ done: | |||
2564 | return ret; | 2564 | return ret; |
2565 | } | 2565 | } |
2566 | 2566 | ||
2567 | static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | 2567 | static bool mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, unsigned pte_access, |
2568 | unsigned pte_access, int write_fault, int *emulate, | 2568 | int write_fault, int level, gfn_t gfn, pfn_t pfn, |
2569 | int level, gfn_t gfn, pfn_t pfn, bool speculative, | 2569 | bool speculative, bool host_writable) |
2570 | bool host_writable) | ||
2571 | { | 2570 | { |
2572 | int was_rmapped = 0; | 2571 | int was_rmapped = 0; |
2573 | int rmap_count; | 2572 | int rmap_count; |
2573 | bool emulate = false; | ||
2574 | 2574 | ||
2575 | pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__, | 2575 | pgprintk("%s: spte %llx write_fault %d gfn %llx\n", __func__, |
2576 | *sptep, write_fault, gfn); | 2576 | *sptep, write_fault, gfn); |
@@ -2600,12 +2600,12 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | |||
2600 | if (set_spte(vcpu, sptep, pte_access, level, gfn, pfn, speculative, | 2600 | if (set_spte(vcpu, sptep, pte_access, level, gfn, pfn, speculative, |
2601 | true, host_writable)) { | 2601 | true, host_writable)) { |
2602 | if (write_fault) | 2602 | if (write_fault) |
2603 | *emulate = 1; | 2603 | emulate = true; |
2604 | kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); | 2604 | kvm_make_request(KVM_REQ_TLB_FLUSH, vcpu); |
2605 | } | 2605 | } |
2606 | 2606 | ||
2607 | if (unlikely(is_mmio_spte(*sptep) && emulate)) | 2607 | if (unlikely(is_mmio_spte(*sptep))) |
2608 | *emulate = 1; | 2608 | emulate = true; |
2609 | 2609 | ||
2610 | pgprintk("%s: setting spte %llx\n", __func__, *sptep); | 2610 | pgprintk("%s: setting spte %llx\n", __func__, *sptep); |
2611 | pgprintk("instantiating %s PTE (%s) at %llx (%llx) addr %p\n", | 2611 | pgprintk("instantiating %s PTE (%s) at %llx (%llx) addr %p\n", |
@@ -2624,6 +2624,8 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *sptep, | |||
2624 | } | 2624 | } |
2625 | 2625 | ||
2626 | kvm_release_pfn_clean(pfn); | 2626 | kvm_release_pfn_clean(pfn); |
2627 | |||
2628 | return emulate; | ||
2627 | } | 2629 | } |
2628 | 2630 | ||
2629 | static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, | 2631 | static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn, |
@@ -2658,9 +2660,8 @@ static int direct_pte_prefetch_many(struct kvm_vcpu *vcpu, | |||
2658 | return -1; | 2660 | return -1; |
2659 | 2661 | ||
2660 | for (i = 0; i < ret; i++, gfn++, start++) | 2662 | for (i = 0; i < ret; i++, gfn++, start++) |
2661 | mmu_set_spte(vcpu, start, access, 0, NULL, | 2663 | mmu_set_spte(vcpu, start, access, 0, sp->role.level, gfn, |
2662 | sp->role.level, gfn, page_to_pfn(pages[i]), | 2664 | page_to_pfn(pages[i]), true, true); |
2663 | true, true); | ||
2664 | 2665 | ||
2665 | return 0; | 2666 | return 0; |
2666 | } | 2667 | } |
@@ -2721,9 +2722,9 @@ static int __direct_map(struct kvm_vcpu *vcpu, int write, int map_writable, | |||
2721 | 2722 | ||
2722 | for_each_shadow_entry(vcpu, (u64)gfn << PAGE_SHIFT, iterator) { | 2723 | for_each_shadow_entry(vcpu, (u64)gfn << PAGE_SHIFT, iterator) { |
2723 | if (iterator.level == level) { | 2724 | if (iterator.level == level) { |
2724 | mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, | 2725 | emulate = mmu_set_spte(vcpu, iterator.sptep, ACC_ALL, |
2725 | write, &emulate, level, gfn, pfn, | 2726 | write, level, gfn, pfn, prefault, |
2726 | prefault, map_writable); | 2727 | map_writable); |
2727 | direct_pte_prefetch(vcpu, iterator.sptep); | 2728 | direct_pte_prefetch(vcpu, iterator.sptep); |
2728 | ++vcpu->stat.pf_fixed; | 2729 | ++vcpu->stat.pf_fixed; |
2729 | break; | 2730 | break; |
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index d8fdc5cd2e5f..11650eac1c6e 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h | |||
@@ -475,8 +475,8 @@ FNAME(prefetch_gpte)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, | |||
475 | * we call mmu_set_spte() with host_writable = true because | 475 | * we call mmu_set_spte() with host_writable = true because |
476 | * pte_prefetch_gfn_to_pfn always gets a writable pfn. | 476 | * pte_prefetch_gfn_to_pfn always gets a writable pfn. |
477 | */ | 477 | */ |
478 | mmu_set_spte(vcpu, spte, pte_access, 0, NULL, PT_PAGE_TABLE_LEVEL, | 478 | mmu_set_spte(vcpu, spte, pte_access, 0, PT_PAGE_TABLE_LEVEL, gfn, pfn, |
479 | gfn, pfn, true, true); | 479 | true, true); |
480 | 480 | ||
481 | return true; | 481 | return true; |
482 | } | 482 | } |
@@ -556,7 +556,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
556 | struct kvm_mmu_page *sp = NULL; | 556 | struct kvm_mmu_page *sp = NULL; |
557 | struct kvm_shadow_walk_iterator it; | 557 | struct kvm_shadow_walk_iterator it; |
558 | unsigned direct_access, access = gw->pt_access; | 558 | unsigned direct_access, access = gw->pt_access; |
559 | int top_level, emulate = 0; | 559 | int top_level, emulate; |
560 | 560 | ||
561 | direct_access = gw->pte_access; | 561 | direct_access = gw->pte_access; |
562 | 562 | ||
@@ -622,8 +622,8 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, | |||
622 | } | 622 | } |
623 | 623 | ||
624 | clear_sp_write_flooding_count(it.sptep); | 624 | clear_sp_write_flooding_count(it.sptep); |
625 | mmu_set_spte(vcpu, it.sptep, gw->pte_access, write_fault, &emulate, | 625 | emulate = mmu_set_spte(vcpu, it.sptep, gw->pte_access, write_fault, |
626 | it.level, gw->gfn, pfn, prefault, map_writable); | 626 | it.level, gw->gfn, pfn, prefault, map_writable); |
627 | FNAME(pte_prefetch)(vcpu, gw, it.sptep); | 627 | FNAME(pte_prefetch)(vcpu, gw, it.sptep); |
628 | 628 | ||
629 | return emulate; | 629 | return emulate; |