History

KVM: VMX: Enable bus lock VM exit

Virtual Machine can exploit bus locks to degrade the performance of system. Bus lock can be caused by split locked access to writeback(WB) memory or by using locks on uncacheable(UC) memory. The bus lock is typically >1000 cycles slower than an atomic operation within a cache line. It also disrupts performance on other cores (which must wait for the bus lock to be released before their memory operations can complete). To address the threat, bus lock VM exit is introduced to notify the VMM when a bus lock was acquired, allowing it to enforce throttling or other policy based mitigations. A VMM can enable VM exit due to bus locks by setting a new "Bus Lock Detection" VM-execution control(bit 30 of Secondary Processor-based VM execution controls). If delivery of this VM exit was preempted by a higher priority VM exit (e.g. EPT misconfiguration, EPT violation, APIC access VM exit, APIC write VM exit, exception bitmap exiting), bit 26 of exit reason in vmcs field is set to 1. In current implementation, the KVM exposes this capability through KVM_CAP_X86_BUS_LOCK_EXIT. The user can get the supported mode bitmap (i.e. off and exit) and enable it explicitly (disabled by default). If bus locks in guest are detected by KVM, exit to user space even when current exit reason is handled by KVM internally. Set a new field KVM_RUN_BUS_LOCK in vcpu->run->flags to inform the user space that there is a bus lock detected in guest. Document for Bus Lock VM exit is now available at the latest "Intel Architecture Instruction Set Extensions Programming Reference". Document Link: https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html

Chenyi Qiang committed 6 years ago

Commit fe6b6bc1 parent 15aad3b10 files · +83 −4Browse files

Showing the changes to include/uapi (1 of 10 files). Show all

Unified · Split

include/uapi/linux/kvm.h+5−0
@@ -252,6 +252,7 @@ struct kvm_hyperv_exit { · 251 unmodified lines
252#define KVM_EXIT_X86_WRMSR 30252#define KVM_EXIT_X86_WRMSR 30
253#define KVM_EXIT_DIRTY_RING_FULL 31253#define KVM_EXIT_DIRTY_RING_FULL 31
254#define KVM_EXIT_AP_RESET_HOLD 32254#define KVM_EXIT_AP_RESET_HOLD 32
255#define KVM_EXIT_X86_BUS_LOCK 33
255 256
256/* For KVM_EXIT_INTERNAL_ERROR */257/* For KVM_EXIT_INTERNAL_ERROR */
257/* Emulate instruction failed. */258/* Emulate instruction failed. */
@@ -1058,6 +1059,7 @@ struct kvm_ppc_resize_hpt { · 800 unmodified lines
1058#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 1901059#define KVM_CAP_ENFORCE_PV_FEATURE_CPUID 190
1059#define KVM_CAP_SYS_HYPERV_CPUID 1911060#define KVM_CAP_SYS_HYPERV_CPUID 191
1060#define KVM_CAP_DIRTY_LOG_RING 1921061#define KVM_CAP_DIRTY_LOG_RING 192
1062#define KVM_CAP_X86_BUS_LOCK_EXIT 193
1061 1063
1062#ifdef KVM_CAP_IRQ_ROUTING1064#ifdef KVM_CAP_IRQ_ROUTING
1063 1065
@@ -1774,4 +1776,7 @@ struct kvm_dirty_gfn { · 710 unmodified lines
1774 __u64 offset;1776 __u64 offset;
1775};1777};
1776 1778
1779#define KVM_BUS_LOCK_DETECTION_OFF (1 << 0)
1780#define KVM_BUS_LOCK_DETECTION_EXIT (1 << 1)
1781
1777#endif /* __LINUX_KVM_H */1782#endif /* __LINUX_KVM_H */