Commit 2f6305dd authored by Paolo Bonzini's avatar Paolo Bonzini

KVM: MMU: change kvm_tdp_mmu_map() arguments to kvm_page_fault

Pass struct kvm_page_fault to kvm_tdp_mmu_map() instead of
extracting the arguments from the struct.
Suggested-by: default avatarIsaku Yamahata <isaku.yamahata@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 9c03b182
...@@ -3988,8 +3988,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault ...@@ -3988,8 +3988,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
goto out_unlock; goto out_unlock;
if (is_tdp_mmu_fault) if (is_tdp_mmu_fault)
r = kvm_tdp_mmu_map(vcpu, gpa, error_code, fault->map_writable, fault->max_level, r = kvm_tdp_mmu_map(vcpu, fault);
fault->pfn, fault->prefault);
else else
r = __direct_map(vcpu, fault); r = __direct_map(vcpu, fault);
......
...@@ -985,35 +985,30 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, int write, ...@@ -985,35 +985,30 @@ static int tdp_mmu_map_handle_target_level(struct kvm_vcpu *vcpu, int write,
* Handle a TDP page fault (NPT/EPT violation/misconfiguration) by installing * Handle a TDP page fault (NPT/EPT violation/misconfiguration) by installing
* page tables and SPTEs to translate the faulting guest physical address. * page tables and SPTEs to translate the faulting guest physical address.
*/ */
int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
int map_writable, int max_level, kvm_pfn_t pfn,
bool prefault)
{ {
bool nx_huge_page_workaround_enabled = is_nx_huge_page_enabled(); bool nx_huge_page_workaround_enabled = is_nx_huge_page_enabled();
bool write = error_code & PFERR_WRITE_MASK; bool huge_page_disallowed = fault->exec && nx_huge_page_workaround_enabled;
bool exec = error_code & PFERR_FETCH_MASK;
bool huge_page_disallowed = exec && nx_huge_page_workaround_enabled;
struct kvm_mmu *mmu = vcpu->arch.mmu; struct kvm_mmu *mmu = vcpu->arch.mmu;
struct tdp_iter iter; struct tdp_iter iter;
struct kvm_mmu_page *sp; struct kvm_mmu_page *sp;
u64 *child_pt; u64 *child_pt;
u64 new_spte; u64 new_spte;
int ret; int ret;
gfn_t gfn = gpa >> PAGE_SHIFT;
int level; int level;
int req_level; int req_level;
level = kvm_mmu_hugepage_adjust(vcpu, gfn, max_level, &pfn, level = kvm_mmu_hugepage_adjust(vcpu, fault->gfn, fault->max_level, &fault->pfn,
huge_page_disallowed, &req_level); huge_page_disallowed, &req_level);
trace_kvm_mmu_spte_requested(gpa, level, pfn); trace_kvm_mmu_spte_requested(fault->addr, level, fault->pfn);
rcu_read_lock(); rcu_read_lock();
tdp_mmu_for_each_pte(iter, mmu, gfn, gfn + 1) { tdp_mmu_for_each_pte(iter, mmu, fault->gfn, fault->gfn + 1) {
if (nx_huge_page_workaround_enabled) if (nx_huge_page_workaround_enabled)
disallowed_hugepage_adjust(iter.old_spte, gfn, disallowed_hugepage_adjust(iter.old_spte, fault->gfn,
iter.level, &pfn, &level); iter.level, &fault->pfn, &level);
if (iter.level == level) if (iter.level == level)
break; break;
...@@ -1069,8 +1064,8 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, ...@@ -1069,8 +1064,8 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code,
return RET_PF_RETRY; return RET_PF_RETRY;
} }
ret = tdp_mmu_map_handle_target_level(vcpu, write, map_writable, &iter, ret = tdp_mmu_map_handle_target_level(vcpu, fault->write, fault->map_writable, &iter,
pfn, prefault); fault->pfn, fault->prefault);
rcu_read_unlock(); rcu_read_unlock();
return ret; return ret;
......
...@@ -48,9 +48,7 @@ void kvm_tdp_mmu_zap_all(struct kvm *kvm); ...@@ -48,9 +48,7 @@ void kvm_tdp_mmu_zap_all(struct kvm *kvm);
void kvm_tdp_mmu_invalidate_all_roots(struct kvm *kvm); void kvm_tdp_mmu_invalidate_all_roots(struct kvm *kvm);
void kvm_tdp_mmu_zap_invalidated_roots(struct kvm *kvm); void kvm_tdp_mmu_zap_invalidated_roots(struct kvm *kvm);
int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, gpa_t gpa, u32 error_code, int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault);
int map_writable, int max_level, kvm_pfn_t pfn,
bool prefault);
bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range, bool kvm_tdp_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range,
bool flush); bool flush);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment