Message ID | 20211119235759.1304274-10-dmatlack@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: x86/mmu: Eager Page Splitting for the TDP MMU | expand |
On Fri, Nov 19, 2021 at 3:58 PM David Matlack <dmatlack@google.com> wrote: > > restore_acc_track_spte is purely an SPTE manipulation, making it a good > fit for spte.c. It is also needed in spte.c in a follow-up commit so we > can construct child SPTEs during large page splitting. > > No functional change intended. > > Signed-off-by: David Matlack <dmatlack@google.com> Reviewed-by: Ben Gardon <bgardon@google.com> Love it. > --- > arch/x86/kvm/mmu/mmu.c | 18 ------------------ > arch/x86/kvm/mmu/spte.c | 18 ++++++++++++++++++ > arch/x86/kvm/mmu/spte.h | 1 + > 3 files changed, 19 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c > index 537952574211..54f0d2228135 100644 > --- a/arch/x86/kvm/mmu/mmu.c > +++ b/arch/x86/kvm/mmu/mmu.c > @@ -652,24 +652,6 @@ static u64 mmu_spte_get_lockless(u64 *sptep) > return __get_spte_lockless(sptep); > } > > -/* Restore an acc-track PTE back to a regular PTE */ > -static u64 restore_acc_track_spte(u64 spte) > -{ > - u64 new_spte = spte; > - u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT) > - & SHADOW_ACC_TRACK_SAVED_BITS_MASK; > - > - WARN_ON_ONCE(spte_ad_enabled(spte)); > - WARN_ON_ONCE(!is_access_track_spte(spte)); > - > - new_spte &= ~shadow_acc_track_mask; > - new_spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK << > - SHADOW_ACC_TRACK_SAVED_BITS_SHIFT); > - new_spte |= saved_bits; > - > - return new_spte; > -} > - > /* Returns the Accessed status of the PTE and resets it at the same time. */ > static bool mmu_spte_age(u64 *sptep) > { > diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c > index 0c76c45fdb68..df2cdb8bcf77 100644 > --- a/arch/x86/kvm/mmu/spte.c > +++ b/arch/x86/kvm/mmu/spte.c > @@ -268,6 +268,24 @@ u64 mark_spte_for_access_track(u64 spte) > return spte; > } > > +/* Restore an acc-track PTE back to a regular PTE */ > +u64 restore_acc_track_spte(u64 spte) > +{ > + u64 new_spte = spte; > + u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT) > + & SHADOW_ACC_TRACK_SAVED_BITS_MASK; > + > + WARN_ON_ONCE(spte_ad_enabled(spte)); > + WARN_ON_ONCE(!is_access_track_spte(spte)); > + > + new_spte &= ~shadow_acc_track_mask; > + new_spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK << > + SHADOW_ACC_TRACK_SAVED_BITS_SHIFT); > + new_spte |= saved_bits; > + > + return new_spte; > +} > + > void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 mmio_mask, u64 access_mask) > { > BUG_ON((u64)(unsigned)access_mask != access_mask); > diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h > index e73c41d31816..3e4943ee5a01 100644 > --- a/arch/x86/kvm/mmu/spte.h > +++ b/arch/x86/kvm/mmu/spte.h > @@ -342,6 +342,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, > u64 make_nonleaf_spte(u64 *child_pt, bool ad_disabled); > u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access); > u64 mark_spte_for_access_track(u64 spte); > +u64 restore_acc_track_spte(u64 spte); > u64 kvm_mmu_changed_pte_notifier_make_spte(u64 old_spte, kvm_pfn_t new_pfn); > > void kvm_mmu_reset_all_pte_masks(void); > -- > 2.34.0.rc2.393.gf8c9666880-goog >
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 537952574211..54f0d2228135 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -652,24 +652,6 @@ static u64 mmu_spte_get_lockless(u64 *sptep) return __get_spte_lockless(sptep); } -/* Restore an acc-track PTE back to a regular PTE */ -static u64 restore_acc_track_spte(u64 spte) -{ - u64 new_spte = spte; - u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT) - & SHADOW_ACC_TRACK_SAVED_BITS_MASK; - - WARN_ON_ONCE(spte_ad_enabled(spte)); - WARN_ON_ONCE(!is_access_track_spte(spte)); - - new_spte &= ~shadow_acc_track_mask; - new_spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK << - SHADOW_ACC_TRACK_SAVED_BITS_SHIFT); - new_spte |= saved_bits; - - return new_spte; -} - /* Returns the Accessed status of the PTE and resets it at the same time. */ static bool mmu_spte_age(u64 *sptep) { diff --git a/arch/x86/kvm/mmu/spte.c b/arch/x86/kvm/mmu/spte.c index 0c76c45fdb68..df2cdb8bcf77 100644 --- a/arch/x86/kvm/mmu/spte.c +++ b/arch/x86/kvm/mmu/spte.c @@ -268,6 +268,24 @@ u64 mark_spte_for_access_track(u64 spte) return spte; } +/* Restore an acc-track PTE back to a regular PTE */ +u64 restore_acc_track_spte(u64 spte) +{ + u64 new_spte = spte; + u64 saved_bits = (spte >> SHADOW_ACC_TRACK_SAVED_BITS_SHIFT) + & SHADOW_ACC_TRACK_SAVED_BITS_MASK; + + WARN_ON_ONCE(spte_ad_enabled(spte)); + WARN_ON_ONCE(!is_access_track_spte(spte)); + + new_spte &= ~shadow_acc_track_mask; + new_spte &= ~(SHADOW_ACC_TRACK_SAVED_BITS_MASK << + SHADOW_ACC_TRACK_SAVED_BITS_SHIFT); + new_spte |= saved_bits; + + return new_spte; +} + void kvm_mmu_set_mmio_spte_mask(u64 mmio_value, u64 mmio_mask, u64 access_mask) { BUG_ON((u64)(unsigned)access_mask != access_mask); diff --git a/arch/x86/kvm/mmu/spte.h b/arch/x86/kvm/mmu/spte.h index e73c41d31816..3e4943ee5a01 100644 --- a/arch/x86/kvm/mmu/spte.h +++ b/arch/x86/kvm/mmu/spte.h @@ -342,6 +342,7 @@ bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp, u64 make_nonleaf_spte(u64 *child_pt, bool ad_disabled); u64 make_mmio_spte(struct kvm_vcpu *vcpu, u64 gfn, unsigned int access); u64 mark_spte_for_access_track(u64 spte); +u64 restore_acc_track_spte(u64 spte); u64 kvm_mmu_changed_pte_notifier_make_spte(u64 old_spte, kvm_pfn_t new_pfn); void kvm_mmu_reset_all_pte_masks(void);
restore_acc_track_spte is purely an SPTE manipulation, making it a good fit for spte.c. It is also needed in spte.c in a follow-up commit so we can construct child SPTEs during large page splitting. No functional change intended. Signed-off-by: David Matlack <dmatlack@google.com> --- arch/x86/kvm/mmu/mmu.c | 18 ------------------ arch/x86/kvm/mmu/spte.c | 18 ++++++++++++++++++ arch/x86/kvm/mmu/spte.h | 1 + 3 files changed, 19 insertions(+), 18 deletions(-)