android_kernel_xiaomi_sm8350/arch/x86/kvm/vmx
Paolo Bonzini 1eb3e32de7 KVM: x86: do not report a vCPU as preempted outside instruction boundaries
commit 6cd88243c7e03845a450795e134b488fc2afb736 upstream.

If a vCPU is outside guest mode and is scheduled out, it might be in the
process of making a memory access.  A problem occurs if another vCPU uses
the PV TLB flush feature during the period when the vCPU is scheduled
out, and a virtual address has already been translated but has not yet
been accessed, because this is equivalent to using a stale TLB entry.

To avoid this, only report a vCPU as preempted if sure that the guest
is at an instruction boundary.  A rescheduling request will be delivered
to the host physical CPU as an external interrupt, so for simplicity
consider any vmexit *not* instruction boundary except for external
interrupts.

It would in principle be okay to report the vCPU as preempted also
if it is sleeping in kvm_vcpu_block(): a TLB flush IPI will incur the
vmentry/vmexit overhead unnecessarily, and optimistic spinning is
also unlikely to succeed.  However, leave it for later because right
now kvm_vcpu_check_block() is doing memory accesses.  Even
though the TLB flush issue only applies to virtual memory address,
it's very much preferrable to be conservative.

Reported-by: Jann Horn <jannh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[OP: use VCPU_STAT() for debugfs entries]
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-30 12:44:07 +01:00
..
capabilities.h
evmcs.c
evmcs.h KVM: nVMX: eVMCS: Filter out VM_EXIT_SAVE_VMX_PREEMPTION_TIMER 2022-02-16 12:52:49 +01:00
nested.c KVM: nVMX: add missing consistency checks for CR0 and CR4 2023-03-22 13:28:09 +01:00
nested.h
ops.h
pmu_intel.c KVM: x86/pmu: Refactoring find_arch_event() to pmc_perf_hw_id() 2022-05-15 19:54:47 +02:00
run_flags.h KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS 2022-10-07 09:16:56 +02:00
vmcs12.c
vmcs12.h
vmcs_shadow_fields.h
vmcs.h
vmenter.S x86/speculation: Add RSB VM Exit protections 2022-10-07 09:16:56 +02:00
vmx.c KVM: x86: do not report a vCPU as preempted outside instruction boundaries 2023-05-30 12:44:07 +01:00
vmx.h KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS 2022-10-07 09:16:56 +02:00