* [PATCH] KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change
@ 2024-11-27 23:53 Sean Christopherson
2024-12-19 2:40 ` Sean Christopherson
0 siblings, 1 reply; 2+ messages in thread
From: Sean Christopherson @ 2024-11-27 23:53 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
Drop SVM's direct TLB flush when CR4.PGE is toggled and NPT is enabled, as
KVM already guarantees TLBs are flushed appropriately.
For the call from cr_trap(), kvm_post_set_cr4() requests TLB_FLUSH_GUEST
(which is a superset of TLB_FLUSH_CURRENT) when CR4.PGE is toggled,
regardless of whether or not KVM is using TDP.
The calls from nested_vmcb02_prepare_save() and nested_svm_vmexit() are
checking guest (L2) vs. host (L1) CR4, and so a flush is unnecessary as L2
is defined to use a different ASID (from L1's perspective).
Lastly, the call from svm_set_cr0() passes in the current CR4 value, i.e.
can't toggle PGE.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/svm.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index dd15cc635655..f39724bf26be 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -284,8 +284,6 @@ u32 svm_msrpm_offset(u32 msr)
return MSR_INVALID;
}
-static void svm_flush_tlb_current(struct kvm_vcpu *vcpu);
-
static int get_npt_level(void)
{
#ifdef CONFIG_X86_64
@@ -1921,9 +1919,6 @@ void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
unsigned long host_cr4_mce = cr4_read_shadow() & X86_CR4_MCE;
unsigned long old_cr4 = vcpu->arch.cr4;
- if (npt_enabled && ((old_cr4 ^ cr4) & X86_CR4_PGE))
- svm_flush_tlb_current(vcpu);
-
vcpu->arch.cr4 = cr4;
if (!npt_enabled) {
cr4 |= X86_CR4_PAE;
base-commit: 4d911c7abee56771b0219a9fbf0120d06bdc9c14
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change
2024-11-27 23:53 [PATCH] KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change Sean Christopherson
@ 2024-12-19 2:40 ` Sean Christopherson
0 siblings, 0 replies; 2+ messages in thread
From: Sean Christopherson @ 2024-12-19 2:40 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
On Wed, 27 Nov 2024 15:53:12 -0800, Sean Christopherson wrote:
> Drop SVM's direct TLB flush when CR4.PGE is toggled and NPT is enabled, as
> KVM already guarantees TLBs are flushed appropriately.
>
> For the call from cr_trap(), kvm_post_set_cr4() requests TLB_FLUSH_GUEST
> (which is a superset of TLB_FLUSH_CURRENT) when CR4.PGE is toggled,
> regardless of whether or not KVM is using TDP.
>
> [...]
Applied to kvm-x86 svm, thanks!
[1/1] KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change
https://github.com/kvm-x86/linux/commit/036e78a942b4
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-19 2:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-27 23:53 [PATCH] KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change Sean Christopherson
2024-12-19 2:40 ` Sean Christopherson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®