diff options
author | Avi Kivity <avi@qumranet.com> | 2007-11-21 07:54:16 -0500 |
---|---|---|
committer | Avi Kivity <avi@qumranet.com> | 2008-01-30 10:53:11 -0500 |
commit | 3f3e7124f66df2d36751b0c97eabe38a13752fff (patch) | |
tree | 6ce4957583da71e60a8bf98b5b394544170c7f41 /drivers/kvm/mmu.c | |
parent | 1755fbcc6666906cada43c1c839ca1fc6616d4a6 (diff) |
KVM: MMU: Simplify nonpaging_map()
Instead of passing an hpa, pass a regular struct page.
Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm/mmu.c')
-rw-r--r-- | drivers/kvm/mmu.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 1dcffc49eff8..1965185bbe23 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c | |||
@@ -903,13 +903,11 @@ static void nonpaging_new_cr3(struct kvm_vcpu *vcpu) | |||
903 | { | 903 | { |
904 | } | 904 | } |
905 | 905 | ||
906 | static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p) | 906 | static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, struct page *page) |
907 | { | 907 | { |
908 | int level = PT32E_ROOT_LEVEL; | 908 | int level = PT32E_ROOT_LEVEL; |
909 | hpa_t table_addr = vcpu->mmu.root_hpa; | 909 | hpa_t table_addr = vcpu->mmu.root_hpa; |
910 | struct page *page; | ||
911 | 910 | ||
912 | page = pfn_to_page(p >> PAGE_SHIFT); | ||
913 | for (; ; level--) { | 911 | for (; ; level--) { |
914 | u32 index = PT64_INDEX(v, level); | 912 | u32 index = PT64_INDEX(v, level); |
915 | u64 *table; | 913 | u64 *table; |
@@ -930,8 +928,9 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, hpa_t p) | |||
930 | mark_page_dirty(vcpu->kvm, v >> PAGE_SHIFT); | 928 | mark_page_dirty(vcpu->kvm, v >> PAGE_SHIFT); |
931 | page_header_update_slot(vcpu->kvm, table, | 929 | page_header_update_slot(vcpu->kvm, table, |
932 | v >> PAGE_SHIFT); | 930 | v >> PAGE_SHIFT); |
933 | table[index] = p | PT_PRESENT_MASK | PT_WRITABLE_MASK | | 931 | table[index] = page_to_phys(page) |
934 | PT_USER_MASK; | 932 | | PT_PRESENT_MASK | PT_WRITABLE_MASK |
933 | | PT_USER_MASK; | ||
935 | if (!was_rmapped) | 934 | if (!was_rmapped) |
936 | rmap_add(vcpu, &table[index], v >> PAGE_SHIFT); | 935 | rmap_add(vcpu, &table[index], v >> PAGE_SHIFT); |
937 | else | 936 | else |
@@ -1050,10 +1049,9 @@ static gpa_t nonpaging_gva_to_gpa(struct kvm_vcpu *vcpu, gva_t vaddr) | |||
1050 | } | 1049 | } |
1051 | 1050 | ||
1052 | static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, | 1051 | static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, |
1053 | u32 error_code) | 1052 | u32 error_code) |
1054 | { | 1053 | { |
1055 | gpa_t addr = gva; | 1054 | struct page *page; |
1056 | hpa_t paddr; | ||
1057 | int r; | 1055 | int r; |
1058 | 1056 | ||
1059 | r = mmu_topup_memory_caches(vcpu); | 1057 | r = mmu_topup_memory_caches(vcpu); |
@@ -1063,16 +1061,14 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva, | |||
1063 | ASSERT(vcpu); | 1061 | ASSERT(vcpu); |
1064 | ASSERT(VALID_PAGE(vcpu->mmu.root_hpa)); | 1062 | ASSERT(VALID_PAGE(vcpu->mmu.root_hpa)); |
1065 | 1063 | ||
1064 | page = gfn_to_page(vcpu->kvm, gva >> PAGE_SHIFT); | ||
1066 | 1065 | ||
1067 | paddr = gpa_to_hpa(vcpu->kvm, addr & PT64_BASE_ADDR_MASK); | 1066 | if (is_error_page(page)) { |
1068 | 1067 | kvm_release_page_clean(page); | |
1069 | if (is_error_hpa(paddr)) { | ||
1070 | kvm_release_page_clean(pfn_to_page((paddr & PT64_BASE_ADDR_MASK) | ||
1071 | >> PAGE_SHIFT)); | ||
1072 | return 1; | 1068 | return 1; |
1073 | } | 1069 | } |
1074 | 1070 | ||
1075 | return nonpaging_map(vcpu, addr & PAGE_MASK, paddr); | 1071 | return nonpaging_map(vcpu, gva & PAGE_MASK, page); |
1076 | } | 1072 | } |
1077 | 1073 | ||
1078 | static void nonpaging_free(struct kvm_vcpu *vcpu) | 1074 | static void nonpaging_free(struct kvm_vcpu *vcpu) |