Skip to content

Commit 00d98dd

Browse files
yamahatabonzini
authored andcommitted
KVM: x86/tdp_mmu: Take root in tdp_mmu_for_each_pte()
Take the root as an argument of tdp_mmu_for_each_pte() instead of looking it up in the mmu. With no other purpose of passing the mmu, drop it. Future changes will want to change which root is used based on the context of the MMU operation. So change the callers to pass in the root currently used, mmu->root.hpa in a preparatory patch to make the later one smaller and easier to review. Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com> Message-ID: <20240718211230.1492011-12-rick.p.edgecombe@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent de86ef7 commit 00d98dd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ static inline void tdp_mmu_iter_set_spte(struct kvm *kvm, struct tdp_iter *iter,
647647
continue; \
648648
else
649649

650-
#define tdp_mmu_for_each_pte(_iter, _kvm, _mmu, _start, _end) \
651-
for_each_tdp_pte(_iter, _kvm, root_to_sp(_mmu->root.hpa), _start, _end)
650+
#define tdp_mmu_for_each_pte(_iter, _kvm, _root, _start, _end) \
651+
for_each_tdp_pte(_iter, _kvm, _root, _start, _end)
652652

653653
static inline bool __must_check tdp_mmu_iter_need_resched(struct kvm *kvm,
654654
struct tdp_iter *iter)
@@ -1083,8 +1083,8 @@ static int tdp_mmu_split_huge_page(struct kvm *kvm, struct tdp_iter *iter,
10831083
*/
10841084
int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
10851085
{
1086-
struct kvm_mmu *mmu = vcpu->arch.mmu;
10871086
struct kvm *kvm = vcpu->kvm;
1087+
struct kvm_mmu_page *root = root_to_sp(vcpu->arch.mmu->root.hpa);
10881088
struct tdp_iter iter;
10891089
struct kvm_mmu_page *sp;
10901090
int ret = RET_PF_RETRY;
@@ -1095,7 +1095,7 @@ int kvm_tdp_mmu_map(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault)
10951095

10961096
rcu_read_lock();
10971097

1098-
tdp_mmu_for_each_pte(iter, kvm, mmu, fault->gfn, fault->gfn + 1) {
1098+
tdp_mmu_for_each_pte(iter, kvm, root, fault->gfn, fault->gfn + 1) {
10991099
int r;
11001100

11011101
if (fault->nx_huge_page_workaround_enabled)
@@ -1744,14 +1744,14 @@ bool kvm_tdp_mmu_write_protect_gfn(struct kvm *kvm,
17441744
int kvm_tdp_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes,
17451745
int *root_level)
17461746
{
1747+
struct kvm_mmu_page *root = root_to_sp(vcpu->arch.mmu->root.hpa);
17471748
struct tdp_iter iter;
1748-
struct kvm_mmu *mmu = vcpu->arch.mmu;
17491749
gfn_t gfn = addr >> PAGE_SHIFT;
17501750
int leaf = -1;
17511751

17521752
*root_level = vcpu->arch.mmu->root_role.level;
17531753

1754-
tdp_mmu_for_each_pte(iter, vcpu->kvm, mmu, gfn, gfn + 1) {
1754+
tdp_mmu_for_each_pte(iter, vcpu->kvm, root, gfn, gfn + 1) {
17551755
leaf = iter.level;
17561756
sptes[leaf] = iter.old_spte;
17571757
}
@@ -1773,11 +1773,11 @@ int kvm_tdp_mmu_get_walk(struct kvm_vcpu *vcpu, u64 addr, u64 *sptes,
17731773
u64 *kvm_tdp_mmu_fast_pf_get_last_sptep(struct kvm_vcpu *vcpu, gfn_t gfn,
17741774
u64 *spte)
17751775
{
1776+
struct kvm_mmu_page *root = root_to_sp(vcpu->arch.mmu->root.hpa);
17761777
struct tdp_iter iter;
1777-
struct kvm_mmu *mmu = vcpu->arch.mmu;
17781778
tdp_ptep_t sptep = NULL;
17791779

1780-
tdp_mmu_for_each_pte(iter, vcpu->kvm, mmu, gfn, gfn + 1) {
1780+
tdp_mmu_for_each_pte(iter, vcpu->kvm, root, gfn, gfn + 1) {
17811781
*spte = iter.old_spte;
17821782
sptep = iter.sptep;
17831783
}

0 commit comments

Comments
 (0)