Skip to content

Commit 036e78a

Browse files
committed
KVM: SVM: Remove redundant TLB flush on guest CR4.PGE change
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. Link: https://lore.kernel.org/r/20241127235312.4048445-1-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent 45d522d commit 036e78a

File tree

1 file changed

+0
-5
lines changed

1 file changed

+0
-5
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,6 @@ u32 svm_msrpm_offset(u32 msr)
284284
return MSR_INVALID;
285285
}
286286

287-
static void svm_flush_tlb_current(struct kvm_vcpu *vcpu);
288-
289287
static int get_npt_level(void)
290288
{
291289
#ifdef CONFIG_X86_64
@@ -1921,9 +1919,6 @@ void svm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
19211919
unsigned long host_cr4_mce = cr4_read_shadow() & X86_CR4_MCE;
19221920
unsigned long old_cr4 = vcpu->arch.cr4;
19231921

1924-
if (npt_enabled && ((old_cr4 ^ cr4) & X86_CR4_PGE))
1925-
svm_flush_tlb_current(vcpu);
1926-
19271922
vcpu->arch.cr4 = cr4;
19281923
if (!npt_enabled) {
19291924
cr4 |= X86_CR4_PAE;

0 commit comments

Comments
 (0)