From 4d7fd7f93dcc45cd55ff519c6b6ba5b103c38076 Mon Sep 17 00:00:00 2001 From: Zide Chen Date: Fri, 16 Aug 2019 16:40:51 -0700 Subject: 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 Signed-off-by: Sainath Grandhi Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1762282 Reviewed-by: Daniel Verkamp Tested-by: kokoro Commit-Queue: Daniel Verkamp --- devices/src/virtio/virtio_pci_device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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() -- cgit 1.4.1