summary refs log tree commit diff
diff options
context:
space:
mode:
authorZide Chen <zide.chen@intel.com>2019-08-16 16:40:51 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-23 19:49:54 +0000
commit4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076 (patch)
tree41715796c37d816f51a10a686c759d7036919b34
parent6f9215cecd81947cb5c42e5ad43e1470f7e4e802 (diff)
downloadcrosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar.gz
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar.bz2
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar.lz
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar.xz
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.tar.zst
crosvm-4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076.zip
devices: virtio: set zero length mmio eventfd for VQ notification address
By registering the notify address with Datamatch::AnyLength, KVM is able
to take advantage of KVM_FAST_MMIO_BUS to accelerate eventfd handling.

Seems this doesn't violate the virtio spec because "writing the 16-bit
virtqueue index" refers to the implementation of front-end driver, for
example, Linux's vp_notify() function. While how to handle the VQ index
write in VMM is not covererd by virtio spec. Here Crosvm ensures that
every VQ has dedicated notify address and KVM implements the notification
by eventfd, which should be fine with the spec.

On eve Pixelbook (R77 host kernel 4.4.185), in 5000 samples, on average
the MMIO write vmexit takes 0.96us with fast_mmio enabled, while it takes
3.36us without fast_mmio.

without fast_mmio:
    232812.822491: kvm_exit: reason EPT_MISCONFIG rip 0xffffffff986f18ef info 0 0
    232812.822492: kvm_emulate_insn: 0:ffffffff986f18ef:66 89 3e (prot64)
    232812.822493: vcpu_match_mmio: gva 0xffffb0f4803a1004 gpa 0xe000f004 Write GPA
    232812.822493: kvm_mmio: mmio write len 2 gpa 0xe000f004 val 0x1
    232812.822495: kvm_entry: vcpu 1

with fast_mmio:
    230585.034396: kvm_exit: reason EPT_MISCONFIG rip 0xffffffff9a6f18ef info 0 0
    230585.034397: kvm_fast_mmio: fast mmio at gpa 0xe000f004
    230585.034397: kvm_entry: vcpu 1

BUG=chromium:993488
TEST=Boot Crostini on eve and run iperf benchmark
TEST=Analysis kernel trace for vmexit handling time

Change-Id: Id1dac22b37490f7026b6c119c85ca9d104a8a3f4
Signed-off-by: Zide Chen <zide.chen@intel.corp-partner.google.com>
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1762282
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
-rw-r--r--devices/src/virtio/virtio_pci_device.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs
index 2e437b6..7da2e45 100644
--- a/devices/src/virtio/virtio_pci_device.rs
+++ b/devices/src/virtio/virtio_pci_device.rs
@@ -422,7 +422,7 @@ impl PciDevice for VirtioPciDevice {
                 (
                     event,
                     notify_base + i as u64 * NOTIFY_OFF_MULTIPLIER as u64,
-                    Datamatch::U16(Some(i as u16)),
+                    Datamatch::AnyLength,
                 )
             })
             .collect()