* [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path
@ 2024-06-08 0:10 Sean Christopherson
2024-06-20 18:19 ` Paolo Bonzini
2024-06-28 22:55 ` Sean Christopherson
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2024-06-08 0:10 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
Remove the completely pointess global INVEPT, i.e. EPT TLB flush, from
KVM's VMX enablement path. KVM always does a targeted TLB flush when
using a "new" EPT root, in quotes because "new" simply means a root that
isn't currently being used by the vCPU.
KVM also _deliberately_ runs with stale TLB entries for defunct roots,
i.e. doesn't do a TLB flush when vCPUs stop using roots, precisely because
KVM does the flush on first use. As called out by the comment in
kvm_mmu_load(), the reason KVM flushes on first use is because KVM can't
guarantee the correctness of past hypervisors.
Jumping back to the global INVEPT, when the painfully terse commit
1439442c7b25 ("KVM: VMX: Enable EPT feature for KVM") was added, the
effective TLB flush being performed was:
static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
{
vpid_sync_vcpu_all(to_vmx(vcpu));
}
I.e. KVM was not flushing EPT TLB entries when allocating a "new" root,
which very strongly suggests that the global INVEPT during hardware
enabling was a misguided hack that addressed the most obvious symptom,
but failed to fix the underlying bug.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/vmx/vmx.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 0e3aaf520db2..21dbe20f50ba 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2832,9 +2832,6 @@ int vmx_hardware_enable(void)
return r;
}
- if (enable_ept)
- ept_sync_global();
-
return 0;
}
base-commit: af0903ab52ee6d6f0f63af67fa73d5eb00f79b9a
--
2.45.2.505.gda0bf45e8d-goog
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path
2024-06-08 0:10 [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path Sean Christopherson
@ 2024-06-20 18:19 ` Paolo Bonzini
2024-06-28 22:55 ` Sean Christopherson
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2024-06-20 18:19 UTC (permalink / raw)
To: Sean Christopherson; +Cc: kvm, linux-kernel
On Sat, Jun 8, 2024 at 2:10 AM Sean Christopherson <seanjc@google.com> wrote:
>
> Remove the completely pointess global INVEPT, i.e. EPT TLB flush, from
> KVM's VMX enablement path. KVM always does a targeted TLB flush when
> using a "new" EPT root, in quotes because "new" simply means a root that
> isn't currently being used by the vCPU.
>
> KVM also _deliberately_ runs with stale TLB entries for defunct roots,
> i.e. doesn't do a TLB flush when vCPUs stop using roots, precisely because
> KVM does the flush on first use. As called out by the comment in
> kvm_mmu_load(), the reason KVM flushes on first use is because KVM can't
> guarantee the correctness of past hypervisors.
>
> Jumping back to the global INVEPT, when the painfully terse commit
> 1439442c7b25 ("KVM: VMX: Enable EPT feature for KVM") was added, the
> effective TLB flush being performed was:
>
> static void vmx_flush_tlb(struct kvm_vcpu *vcpu)
> {
> vpid_sync_vcpu_all(to_vmx(vcpu));
> }
>
> I.e. KVM was not flushing EPT TLB entries when allocating a "new" root,
> which very strongly suggests that the global INVEPT during hardware
> enabling was a misguided hack that addressed the most obvious symptom,
> but failed to fix the underlying bug.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> arch/x86/kvm/vmx/vmx.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
> index 0e3aaf520db2..21dbe20f50ba 100644
> --- a/arch/x86/kvm/vmx/vmx.c
> +++ b/arch/x86/kvm/vmx/vmx.c
> @@ -2832,9 +2832,6 @@ int vmx_hardware_enable(void)
> return r;
> }
>
> - if (enable_ept)
> - ept_sync_global();
> -
> return 0;
> }
>
>
> base-commit: af0903ab52ee6d6f0f63af67fa73d5eb00f79b9a
> --
> 2.45.2.505.gda0bf45e8d-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path
2024-06-08 0:10 [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path Sean Christopherson
2024-06-20 18:19 ` Paolo Bonzini
@ 2024-06-28 22:55 ` Sean Christopherson
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2024-06-28 22:55 UTC (permalink / raw)
To: Sean Christopherson, Paolo Bonzini; +Cc: kvm, linux-kernel
On Fri, 07 Jun 2024 17:10:03 -0700, Sean Christopherson wrote:
> Remove the completely pointess global INVEPT, i.e. EPT TLB flush, from
> KVM's VMX enablement path. KVM always does a targeted TLB flush when
> using a "new" EPT root, in quotes because "new" simply means a root that
> isn't currently being used by the vCPU.
>
> KVM also _deliberately_ runs with stale TLB entries for defunct roots,
> i.e. doesn't do a TLB flush when vCPUs stop using roots, precisely because
> KVM does the flush on first use. As called out by the comment in
> kvm_mmu_load(), the reason KVM flushes on first use is because KVM can't
> guarantee the correctness of past hypervisors.
>
> [...]
Applied to kvm-x86 vmx, thanks!
[1/1] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path
https://github.com/kvm-x86/linux/commit/23b2c5088d01
--
https://github.com/kvm-x86/linux/tree/next
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-28 22:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-08 0:10 [PATCH] KVM: VMX: Remove unnecessary INVEPT[GLOBAL] from hardware enable path Sean Christopherson
2024-06-20 18:19 ` Paolo Bonzini
2024-06-28 22:55 ` 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®