KVM: MMU: Unify direct map 4K and large page paths
authorAvi Kivity <avi@qumranet.com>
Fri, 22 Aug 2008 16:14:17 +0000 (19:14 +0300)
committerAvi Kivity <avi@qumranet.com>
Wed, 15 Oct 2008 08:15:22 +0000 (10:15 +0200)
The two paths are equivalent except for one argument, which is already
available.  Merge the two codepaths.

Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/mmu.c

index 51d4cd7ae4f9a792ff3cdf9a43e1740446c1ccc8..3ee856f6812d554259ce0f447a690c5a3ede7fe4 100644 (file)
@@ -1240,15 +1240,10 @@ static int __direct_map(struct kvm_vcpu *vcpu, gpa_t v, int write,
                ASSERT(VALID_PAGE(table_addr));
                table = __va(table_addr);
 
-               if (level == 1) {
+               if (level == 1 || (largepage && level == 2)) {
                        mmu_set_spte(vcpu, &table[index], ACC_ALL, ACC_ALL,
-                                    0, write, 1, &pt_write, 0, gfn, pfn, false);
-                       return pt_write;
-               }
-
-               if (largepage && level == 2) {
-                       mmu_set_spte(vcpu, &table[index], ACC_ALL, ACC_ALL,
-                                    0, write, 1, &pt_write, 1, gfn, pfn, false);
+                                    0, write, 1, &pt_write, largepage,
+                                    gfn, pfn, false);
                        return pt_write;
                }