Skip to content

Commit fd32525

Browse files
yanzhao56bonzini
authored andcommitted
KVM: x86/mmu: Add parameter "kvm" to kvm_mmu_page_ad_need_write_protect()
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>
1 parent c4a92f1 commit fd32525

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
@@ -168,7 +168,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
168168

169169
if (sp->role.ad_disabled)
170170
spte |= SPTE_TDP_AD_DISABLED;
171-
else if (kvm_mmu_page_ad_need_write_protect(sp))
171+
else if (kvm_mmu_page_ad_need_write_protect(vcpu->kvm, sp))
172172
spte |= SPTE_TDP_AD_WRPROT_ONLY;
173173

174174
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
@@ -1613,21 +1613,21 @@ void kvm_tdp_mmu_try_split_huge_pages(struct kvm *kvm,
16131613
}
16141614
}
16151615

1616-
static bool tdp_mmu_need_write_protect(struct kvm_mmu_page *sp)
1616+
static bool tdp_mmu_need_write_protect(struct kvm *kvm, struct kvm_mmu_page *sp)
16171617
{
16181618
/*
16191619
* All TDP MMU shadow pages share the same role as their root, aside
16201620
* from level, so it is valid to key off any shadow page to determine if
16211621
* write protection is needed for an entire tree.
16221622
*/
1623-
return kvm_mmu_page_ad_need_write_protect(sp) || !kvm_ad_enabled;
1623+
return kvm_mmu_page_ad_need_write_protect(kvm, sp) || !kvm_ad_enabled;
16241624
}
16251625

16261626
static void clear_dirty_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
16271627
gfn_t start, gfn_t end)
16281628
{
1629-
const u64 dbit = tdp_mmu_need_write_protect(root) ? PT_WRITABLE_MASK :
1630-
shadow_dirty_mask;
1629+
const u64 dbit = tdp_mmu_need_write_protect(kvm, root) ?
1630+
PT_WRITABLE_MASK : shadow_dirty_mask;
16311631
struct tdp_iter iter;
16321632

16331633
rcu_read_lock();
@@ -1672,8 +1672,8 @@ void kvm_tdp_mmu_clear_dirty_slot(struct kvm *kvm,
16721672
static void clear_dirty_pt_masked(struct kvm *kvm, struct kvm_mmu_page *root,
16731673
gfn_t gfn, unsigned long mask, bool wrprot)
16741674
{
1675-
const u64 dbit = (wrprot || tdp_mmu_need_write_protect(root)) ? PT_WRITABLE_MASK :
1676-
shadow_dirty_mask;
1675+
const u64 dbit = (wrprot || tdp_mmu_need_write_protect(kvm, root)) ?
1676+
PT_WRITABLE_MASK : shadow_dirty_mask;
16771677
struct tdp_iter iter;
16781678

16791679
lockdep_assert_held_write(&kvm->mmu_lock);

0 commit comments

Comments
 (0)