Skip to contentSkip to conversation

KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr

PATCH Applied Tao Su 4 participants 5 messages May 28, 2024 – Jun 5, 2024

Subsystems (3)
lore
Share & tools
lore

Tao Su

author
#0 lore raw

PATCH 1/1 KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr

Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn(). Before checking the mismatch of private vs. shared, mmu_invalidate_seq is saved to fault->mmu_seq, which can be used to detect an invalidation related to the gfn occurred, i.e. KVM will not install a mapping in page table if fault->mmu_seq != mmu_invalidate_seq.

Currently there is a second snapshot of mmu_invalidate_seq, which may not be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute may be changed between the two snapshots, but the gfn may be mapped in page table without hindrance. Therefore, drop the second snapshot as it has no obvious benefits.

Fixes f6adeae81f35 ("KVM: x86/mmu: Handle no-slot faults at the beginning of kvm_faultin_pfn()")
---
 arch/x86/kvm/mmu/mmu.c | 3 ---
 1 file changed, 3 deletions(-)
arch/x86/kvm/mmu/mmu.c +0 -3
index 662f62dfb2aa..4372df109aff 100644
@@ -4400,9 +4400,6 @@ static int kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault,
 			return RET_PF_EMULATE;
 	}
 
-	fault->mmu_seq = vcpu->kvm->mmu_invalidate_seq;
-	smp_rmb();
-
 	/*
 	 * Check for a relevant mmu_notifier invalidation event before getting
 	 * the pfn from the primary MMU, and before acquiring mmu_lock.

base-commit: 2bfcfd584ff5ccc8bb7acde19b42570414bf880b

Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Tao Su

Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn(). Before checking the mismatch of private vs. shared, mmu_invalidate_seq is saved to fault->mmu_seq, which can be used to detect an invalidation related to the gfn occurred, i.e. KVM will not install a mapping in page table if fault->mmu_seq != mmu_invalidate_seq.

Quoted 8 lines

Currently there is a second snapshot of mmu_invalidate_seq, which may not be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute may be changed between the two snapshots, but the gfn may be mapped in page table without hindrance. Therefore, drop the second snapshot as it has no obvious benefits.

Fixes f6adeae81f35 ("KVM: x86/mmu: Handle no-slot faults at the beginning of kvm_faultin_pfn()")
maintainer Applied
#2 lore raw
In reply to Tao Su
Quoted 6 lines · Tao Su

Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn(). Before checking the mismatch of private vs. shared, mmu_invalidate_seq is saved to fault->mmu_seq, which can be used to detect an invalidation related to the gfn occurred, i.e. KVM will not install a mapping in page table if fault->mmu_seq != mmu_invalidate_seq.

Quoted 7 lines

Currently there is a second snapshot of mmu_invalidate_seq, which may not be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute may be changed between the two snapshots, but the gfn may be mapped in page table without hindrance. Therefore, drop the second snapshot as it has no obvious benefits.

[...]

Applied to kvm-x86 fixes, thanks!

[1/1] KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr

      https://github.com/kvm-x86/linux/commit/f66e50ed09b3

--
https://github.com/kvm-x86/linux/tree/next

maintainer
#3 lore raw
Quoted 13 lines · Sean Christopherson
Quoted 12 lines · Tao Su

Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn(). Before checking the mismatch of private vs. shared, mmu_invalidate_seq is saved to fault->mmu_seq, which can be used to detect an invalidation related to the gfn occurred, i.e. KVM will not install a mapping in page table if fault->mmu_seq != mmu_invalidate_seq.

Currently there is a second snapshot of mmu_invalidate_seq, which may not be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute may be changed between the two snapshots, but the gfn may be mapped in page table without hindrance. Therefore, drop the second snapshot as it has no obvious benefits.

Quoted 6 lines
Quoted 1 line

[...]

Applied to kvm-x86 fixes, thanks!

[1/1] KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr

       https://github.com/kvm-x86/linux/commit/f66e50ed09b3

Since I'm already sending a much larger pull request for -rc3, I guess you don't mind if I also queue this one. :)

Paolo

#4 lore raw
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Sean Christopherson
Quoted 13 lines · Tao Su

Drop the second snapshot of mmu_invalidate_seq in kvm_faultin_pfn(). Before checking the mismatch of private vs. shared, mmu_invalidate_seq is saved to fault->mmu_seq, which can be used to detect an invalidation related to the gfn occurred, i.e. KVM will not install a mapping in page table if fault->mmu_seq != mmu_invalidate_seq.

Currently there is a second snapshot of mmu_invalidate_seq, which may not be same as the first snapshot in kvm_faultin_pfn(), i.e. the gfn attribute may be changed between the two snapshots, but the gfn may be mapped in page table without hindrance. Therefore, drop the second snapshot as it has no obvious benefits.

[...]

Quoted 7 lines
Quoted 4 lines

Applied to kvm-x86 fixes, thanks!

[1/1] KVM: x86/mmu: Don't save mmu_invalidate_seq after checking private attr

       https://github.com/kvm-x86/linux/commit/f66e50ed09b3

Since I'm already sending a much larger pull request for -rc3, I guess you don't mind if I also queue this one. :)

Not at all, dropped from kvm-x86.