vhost: Don't call log_access_ok() when using IOTLB
authorGreg Kurz <groug@kaod.org>
Sat, 3 Oct 2020 10:02:13 +0000 (12:02 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 4 Oct 2020 07:45:20 +0000 (03:45 -0400)
commitab5122510b0a453c0ac898ec9952d38e80243ee7
treed645c482c4a211c0b1031c75d2590147462bd540
parent71878fa46c7e3b40fa7b3f1b6e4ba3f92f1ac359
vhost: Don't call log_access_ok() when using IOTLB

When the IOTLB device is enabled, the log_guest_addr that is passed by
userspace to the VHOST_SET_VRING_ADDR ioctl, and which is then written
to vq->log_addr, is a GIOVA. All writes to this address are translated
by log_user() to writes to an HVA, and then ultimately logged through
the corresponding GPAs in log_write_hva(). No logging will ever occur
with vq->log_addr in this case. It is thus wrong to pass vq->log_addr
and log_guest_addr to log_access_vq() which assumes they are actual
GPAs.

Introduce a new vq_log_used_access_ok() helper that only checks accesses
to the log for the used structure when there isn't an IOTLB device around.

Signed-off-by: Greg Kurz <groug@kaod.org>
Link: https://lore.kernel.org/r/160171933385.284610.10189082586063280867.stgit@bahia.lan
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/vhost.c