Rename the memory helpers that will soon be moved to common code and be made globaly available via linux/kvm_host.h. "mmu" alone is not a sufficient namespace for globally available KVM symbols. Opportunistically add "nr_" in mmu_memory_cache_free_objects() to make it clear the function returns the number of free objects, as opposed to freeing existing objects.
Unified · Split
| @@ -1072,7 +1072,7 @@ static inline void *mmu_memory_cache_alloc_obj(struct kvm_mmu_memory_cache *mc, · 1071 unmodified lines | ||
| 1072 | 1072 | return (void *)__get_free_page(gfp_flags); |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | −static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min) | |
| 1075 | +static int kvm_mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min) | |
| 1076 | 1076 | { |
| 1077 | 1077 | void *obj; |
| 1078 | 1078 | |
| @@ -1087,12 +1087,12 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *mc, int min) · 8 unmodified lines | ||
| 1087 | 1087 | return 0; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | −static int mmu_memory_cache_free_objects(struct kvm_mmu_memory_cache *mc) | |
| 1090 | +static int kvm_mmu_memory_cache_nr_free_objects(struct kvm_mmu_memory_cache *mc) | |
| 1091 | 1091 | { |
| 1092 | 1092 | return mc->nobjs; |
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | −static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc) | |
| 1095 | +static void kvm_mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc) | |
| 1096 | 1096 | { |
| 1097 | 1097 | while (mc->nobjs) { |
| 1098 | 1098 | if (mc->kmem_cache) |
| @@ -1107,33 +1107,33 @@ static int mmu_topup_memory_caches(struct kvm_vcpu *vcpu, bool maybe_indirect) · 8 unmodified lines | ||
| 1107 | 1107 | int r; |
| 1108 | 1108 | |
| 1109 | 1109 | /* 1 rmap, 1 parent PTE per level, and the prefetched rmaps. */ |
| 1110 | − r = mmu_topup_memory_cache(&vcpu->arch.mmu_pte_list_desc_cache, | |
| 1111 | − 1 + PT64_ROOT_MAX_LEVEL + PTE_PREFETCH_NUM); | |
| 1110 | + r = kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_pte_list_desc_cache, | |
| 1111 | + 1 + PT64_ROOT_MAX_LEVEL + PTE_PREFETCH_NUM); | |
| 1112 | 1112 | if (r) |
| 1113 | 1113 | return r; |
| 1114 | − r = mmu_topup_memory_cache(&vcpu->arch.mmu_shadow_page_cache, | |
| 1115 | − PT64_ROOT_MAX_LEVEL); | |
| 1114 | + r = kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_shadow_page_cache, | |
| 1115 | + PT64_ROOT_MAX_LEVEL); | |
| 1116 | 1116 | if (r) |
| 1117 | 1117 | return r; |
| 1118 | 1118 | if (maybe_indirect) { |
| 1119 | − r = mmu_topup_memory_cache(&vcpu->arch.mmu_gfn_array_cache, | |
| 1120 | − PT64_ROOT_MAX_LEVEL); | |
| 1119 | + r = kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_gfn_array_cache, | |
| 1120 | + PT64_ROOT_MAX_LEVEL); | |
| 1121 | 1121 | if (r) |
| 1122 | 1122 | return r; |
| 1123 | 1123 | } |
| 1124 | − return mmu_topup_memory_cache(&vcpu->arch.mmu_page_header_cache, | |
| 1125 | − PT64_ROOT_MAX_LEVEL); | |
| 1124 | + return kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_page_header_cache, | |
| 1125 | + PT64_ROOT_MAX_LEVEL); | |
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | 1128 | static void mmu_free_memory_caches(struct kvm_vcpu *vcpu) |
| 1129 | 1129 | { |
| 1130 | − mmu_free_memory_cache(&vcpu->arch.mmu_pte_list_desc_cache); | |
| 1131 | − mmu_free_memory_cache(&vcpu->arch.mmu_shadow_page_cache); | |
| 1132 | − mmu_free_memory_cache(&vcpu->arch.mmu_gfn_array_cache); | |
| 1133 | − mmu_free_memory_cache(&vcpu->arch.mmu_page_header_cache); | |
| 1130 | + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_pte_list_desc_cache); | |
| 1131 | + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_shadow_page_cache); | |
| 1132 | + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_gfn_array_cache); | |
| 1133 | + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_header_cache); | |
| 1134 | 1134 | } |
| 1135 | 1135 | |
| 1136 | −static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc) | |
| 1136 | +static void *kvm_mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc) | |
| 1137 | 1137 | { |
| 1138 | 1138 | void *p; |
| 1139 | 1139 | |
| @@ -1147,7 +1147,7 @@ static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc) · 7 unmodified lines | ||
| 1147 | 1147 | |
| 1148 | 1148 | static struct pte_list_desc *mmu_alloc_pte_list_desc(struct kvm_vcpu *vcpu) |
| 1149 | 1149 | { |
| 1150 | − return mmu_memory_cache_alloc(&vcpu->arch.mmu_pte_list_desc_cache); | |
| 1150 | + return kvm_mmu_memory_cache_alloc(&vcpu->arch.mmu_pte_list_desc_cache); | |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | static void mmu_free_pte_list_desc(struct pte_list_desc *pte_list_desc) |
| @@ -1418,7 +1418,7 @@ static bool rmap_can_add(struct kvm_vcpu *vcpu) · 264 unmodified lines | ||
| 1418 | 1418 | struct kvm_mmu_memory_cache *mc; |
| 1419 | 1419 | |
| 1420 | 1420 | mc = &vcpu->arch.mmu_pte_list_desc_cache; |
| 1421 | − return mmu_memory_cache_free_objects(mc); | |
| 1421 | + return kvm_mmu_memory_cache_nr_free_objects(mc); | |
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn) |
| @@ -2090,10 +2090,10 @@ static struct kvm_mmu_page *kvm_mmu_alloc_page(struct kvm_vcpu *vcpu, int direct · 665 unmodified lines | ||
| 2090 | 2090 | { |
| 2091 | 2091 | struct kvm_mmu_page *sp; |
| 2092 | 2092 | |
| 2093 | − sp = mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache); | |
| 2094 | − sp->spt = mmu_memory_cache_alloc(&vcpu->arch.mmu_shadow_page_cache); | |
| 2093 | + sp = kvm_mmu_memory_cache_alloc(&vcpu->arch.mmu_page_header_cache); | |
| 2094 | + sp->spt = kvm_mmu_memory_cache_alloc(&vcpu->arch.mmu_shadow_page_cache); | |
| 2095 | 2095 | if (!direct) |
| 2096 | − sp->gfns = mmu_memory_cache_alloc(&vcpu->arch.mmu_gfn_array_cache); | |
| 2096 | + sp->gfns = kvm_mmu_memory_cache_alloc(&vcpu->arch.mmu_gfn_array_cache); | |
| 2097 | 2097 | set_page_private(virt_to_page(sp->spt), (unsigned long)sp); |
| 2098 | 2098 | |
| 2099 | 2099 | /* |