Skip to content

Commit 3dacbea

Browse files
committed
KVM: x86/mmu: Add parameter "kvm" to kvm_mmu_page_ad_need_write_protect()
JIRA: https://issues.redhat.com/browse/RHEL-15711 Upstream status: https://git.kernel.org/pub/scm/virt/kvm/kvm.git Add a parameter "kvm" to kvm_mmu_page_ad_need_write_protect() and its caller tdp_mmu_need_write_protect(). This is a preparation to make cpu_dirty_log_size a per-VM value rather than a system-wide value. No function changes expected. Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit fd32525) Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> RHEL: kvm_ad_enabled() is a function rather than a variable
1 parent cadaf8b commit 3dacbea

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

arch/x86/kvm/mmu/mmu_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ static inline gfn_t kvm_gfn_root_bits(const struct kvm *kvm, const struct kvm_mm
187187
return kvm_gfn_direct_bits(kvm);
188188
}
189189

190-
static inline bool kvm_mmu_page_ad_need_write_protect(struct kvm_mmu_page *sp)
190+
static inline bool kvm_mmu_page_ad_need_write_protect(struct kvm *kvm,
191+
struct kvm_mmu_page *sp)
191192
{
192193
/*
193194
* When using the EPT page-modification log, the GPAs in the CPU dirty

arch/x86/kvm/mmu/spte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
152152

153153
if (sp->role.ad_disabled)
154154
spte |= SPTE_TDP_AD_DISABLED;
155-
else if (kvm_mmu_page_ad_need_write_protect(sp))
155+
else if (kvm_mmu_page_ad_need_write_protect(vcpu->kvm, sp))
156156
spte |= SPTE_TDP_AD_WRPROT_ONLY;
157157

158158
spte |= shadow_present_mask;

arch/x86/kvm/mmu/tdp_mmu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,21 +1672,21 @@ void kvm_tdp_mmu_try_split_huge_pages(struct kvm *kvm,
16721672
}
16731673
}
16741674

1675-
static bool tdp_mmu_need_write_protect(struct kvm_mmu_page *sp)
1675+
static bool tdp_mmu_need_write_protect(struct kvm *kvm, struct kvm_mmu_page *sp)
16761676
{
16771677
/*
16781678
* All TDP MMU shadow pages share the same role as their root, aside
16791679
* from level, so it is valid to key off any shadow page to determine if
16801680
* write protection is needed for an entire tree.
16811681
*/
1682-
return kvm_mmu_page_ad_need_write_protect(sp) || !kvm_ad_enabled();
1682+
return kvm_mmu_page_ad_need_write_protect(kvm, sp) || !kvm_ad_enabled();
16831683
}
16841684

16851685
static bool clear_dirty_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
16861686
gfn_t start, gfn_t end)
16871687
{
1688-
const u64 dbit = tdp_mmu_need_write_protect(root) ? PT_WRITABLE_MASK :
1689-
shadow_dirty_mask;
1688+
const u64 dbit = tdp_mmu_need_write_protect(kvm, root) ?
1689+
PT_WRITABLE_MASK : shadow_dirty_mask;
16901690
struct tdp_iter iter;
16911691
bool spte_set = false;
16921692

@@ -1739,8 +1739,8 @@ bool kvm_tdp_mmu_clear_dirty_slot(struct kvm *kvm,
17391739
static void clear_dirty_pt_masked(struct kvm *kvm, struct kvm_mmu_page *root,
17401740
gfn_t gfn, unsigned long mask, bool wrprot)
17411741
{
1742-
const u64 dbit = (wrprot || tdp_mmu_need_write_protect(root)) ? PT_WRITABLE_MASK :
1743-
shadow_dirty_mask;
1742+
const u64 dbit = (wrprot || tdp_mmu_need_write_protect(kvm, root)) ?
1743+
PT_WRITABLE_MASK : shadow_dirty_mask;
17441744
struct tdp_iter iter;
17451745

17461746
lockdep_assert_held_write(&kvm->mmu_lock);

0 commit comments

Comments
 (0)