Skip to contentSkip to conversation

KVM: x86/mmu: Remove stale comment mentioning skip_4k

PATCH In review David Matlack 2 participants 3 messages May 25, 2021 – May 26, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: x86/mmu: Remove stale comment mentioning skip_4k

This comment was left over from a previous version of the patch that introduced wrprot_gfn_range, when skip_4k was passed in instead of min_level.

Remove the comment (instead of fixing it) since wrprot_gfn_range has only one caller and min_level is documented there.

---
 arch/x86/kvm/mmu/tdp_mmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +1 -2
index 95eeb5ac6a8a..97f273912764 100644
@@ -1192,8 +1192,7 @@ bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
 }
 
 /*
- * Remove write access from all the SPTEs mapping GFNs [start, end). If
- * skip_4k is set, SPTEs that map 4k pages, will not be write-protected.
+ * Remove write access from all the SPTEs mapping GFNs [start, end).
  * Returns true if an SPTE has been changed and the TLBs need to be flushed.
  */
 static bool wrprot_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
Signature · 1 line
2.32.0.rc0.204.g9fa02ecfa5-goog
#1 lore raw
Quoted 6 lines · David Matlack

This comment was left over from a previous version of the patch that introduced wrprot_gfn_range, when skip_4k was passed in instead of min_level.

Remove the comment (instead of fixing it) since wrprot_gfn_range has only one caller and min_level is documented there.

That would be ok-ish if there were no comment whatsoever, but the function comment is now flat out wrong, which is bad.

Quoted 10 lines
---
 arch/x86/kvm/mmu/tdp_mmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +0 -0
index 95eeb5ac6a8a..97f273912764 100644

arch/x86/kvm/mmu/tdp_mmu.c bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) · line 1195

Quoted 6 lines
arch/x86/kvm/mmu/tdp_mmu.c +1 -2
@@ -1192,8 +1192,7 @@ bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
 }
 
 /*
- * Remove write access from all the SPTEs mapping GFNs [start, end). If
- * skip_4k is set, SPTEs that map 4k pages, will not be write-protected.
+ * Remove write access from all the SPTEs mapping GFNs [start, end).

If the goal is to avoid churn on the last sentence, what about:

* Write protect SPTEs mapping GFNs [start, end) at or above min_level.

Quoted 6 lines
arch/x86/kvm/mmu/tdp_mmu.c +0 -0
  * Returns true if an SPTE has been changed and the TLBs need to be flushed.
  */
 static bool wrprot_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
Signature · 1 line
2.32.0.rc0.204.g9fa02ecfa5-goog
#2 lore raw
Quoted 11 lines · Sean Christopherson
Quoted 6 lines · David Matlack

This comment was left over from a previous version of the patch that introduced wrprot_gfn_range, when skip_4k was passed in instead of min_level.

Remove the comment (instead of fixing it) since wrprot_gfn_range has only one caller and min_level is documented there.

That would be ok-ish if there were no comment whatsoever, but the function comment is now flat out wrong, which is bad.

You're right!

Quoted 13 lines
Quoted 13 lines
---
 arch/x86/kvm/mmu/tdp_mmu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/x86/kvm/mmu/tdp_mmu.c +0 -0
index 95eeb5ac6a8a..97f273912764 100644
@@ -1192,8 +1192,7 @@ bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range)
 }
 
Quoted 8 lines

arch/x86/kvm/mmu/tdp_mmu.c bool kvm_tdp_mmu_set_spte_gfn(struct kvm *kvm, struct kvm_gfn_range *range) · line 1195

Quoted 4 lines
arch/x86/kvm/mmu/tdp_mmu.c +1 -2
 /*
- * Remove write access from all the SPTEs mapping GFNs [start, end). If
- * skip_4k is set, SPTEs that map 4k pages, will not be write-protected.
+ * Remove write access from all the SPTEs mapping GFNs [start, end).

If the goal is to avoid churn on the last sentence, what about:

* Write protect SPTEs mapping GFNs [start, end) at or above min_level.

Thanks. Will send another patch fixing the comment.

Quoted 7 lines
Quoted 7 lines
arch/x86/kvm/mmu/tdp_mmu.c +0 -1
  * Returns true if an SPTE has been changed and the TLBs need to be flushed.
  */
 static bool wrprot_gfn_range(struct kvm *kvm, struct kvm_mmu_page *root,
--

2.32.0.rc0.204.g9fa02ecfa5-goog