qemu-e2k/hw/i386
Chenyi Qiang 035d1ef265 i386: Add ratelimit for bus locks acquired in guest
A bus lock is acquired through either split locked access to writeback
(WB) memory or any locked access to non-WB memory. It is typically >1000
cycles slower than an atomic operation within a cache and can also
disrupts performance on other cores.

Virtual Machines can exploit bus locks to degrade the performance of
system. To address this kind of performance DOS attack coming from the
VMs, bus lock VM exit is introduced in KVM and it can report the bus
locks detected in guest. If enabled in KVM, it would exit to the
userspace to let the user enforce throttling policies once bus locks
acquired in VMs.

The availability of bus lock VM exit can be detected through the
KVM_CAP_X86_BUS_LOCK_EXIT. The returned bitmap contains the potential
policies supported by KVM. The field KVM_BUS_LOCK_DETECTION_EXIT in
bitmap is the only supported strategy at present. It indicates that KVM
will exit to userspace to handle the bus locks.

This patch adds a ratelimit on the bus locks acquired in guest as a
mitigation policy.

Introduce a new field "bus_lock_ratelimit" to record the limited speed
of bus locks in the target VM. The user can specify it through the
"bus-lock-ratelimit" as a machine property. In current implementation,
the default value of the speed is 0 per second, which means no
restrictions on the bus locks.

As for ratelimit on detected bus locks, simply set the ratelimit
interval to 1s and restrict the quota of bus lock occurence to the value
of "bus_lock_ratelimit". A potential alternative is to introduce the
time slice as a property which can help the user achieve more precise
control.

The detail of bus lock VM exit can be found in spec:
https://software.intel.com/content/www/us/en/develop/download/intel-architecture-instruction-set-extensions-programming-reference.html

Signed-off-by: Chenyi Qiang <chenyi.qiang@intel.com>
Message-Id: <20210521043820.29678-1-chenyi.qiang@intel.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2021-06-17 14:11:06 -04:00
..
kvm i386/kvm: The value passed to strerror should be positive 2021-06-05 21:01:17 +02:00
xen docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
acpi-build.c i386: Eliminate all TPM related code if CONFIG_TPM is not set 2021-06-15 10:54:46 -04:00
acpi-build.h
acpi-common.c acpi: Permit OEM ID and OEM table ID fields to be changed 2021-02-05 08:52:59 -05:00
acpi-common.h misc: Correct relative include path 2021-06-05 21:10:42 +02:00
acpi-microvm.c Do not include hw/boards.h if it's not really necessary 2021-05-02 17:24:51 +02:00
acpi-microvm.h
amd_iommu.c amd_iommu: fix wrong MMIO operations 2021-05-14 10:26:18 -04:00
amd_iommu.h
e820_memory_layout.c
e820_memory_layout.h
fw_cfg.c hw/smbios: support for type 41 (onboard devices extended information) 2021-05-14 10:26:18 -04:00
fw_cfg.h
generic_event_device_x86.c
intel_iommu_internal.h
intel_iommu.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
Kconfig hw/mem/nvdimm: Use Kconfig 'imply' instead of 'depends on' 2021-05-26 14:49:45 +02:00
kvmvapic.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
meson.build
microvm.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
multiboot.c
multiboot.h
pc_piix.c i386: split cpu accelerators from cpu.c, using AccelCPUClass 2021-05-10 15:41:49 -04:00
pc_q35.c Do not include exec/address-spaces.h if it's not really necessary 2021-05-02 17:24:51 +02:00
pc_sysfw.c Do not include sysemu/sysemu.h if it's not really necessary 2021-05-02 17:24:50 +02:00
pc.c i386: use better matching family/model/stepping for 'qemu64' CPU 2021-05-31 15:53:03 -04:00
port92.c
trace-events docs: fix references to docs/devel/tracing.rst 2021-06-02 06:51:09 +02:00
trace.h
vmmouse.c vmmouse: put it into the 'input' category 2021-02-20 12:36:19 +01:00
vmport.c Do not include cpu.h if it's not really necessary 2021-05-02 17:24:51 +02:00
x86-iommu-stub.c
x86-iommu.c Do not include hw/boards.h if it's not really necessary 2021-05-02 17:24:51 +02:00
x86.c i386: Add ratelimit for bus locks acquired in guest 2021-06-17 14:11:06 -04:00