KVM: x86: drop PIO from unregistered devices
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 15 Jun 2022 15:05:06 +0000 (11:05 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 24 Jun 2022 16:53:37 +0000 (12:53 -0400)
commit35ab3b77a0ae76246dd2666d4f8190c824392fb4
tree6f17260e675b1f6c80ee64fa7358293c6c071e6c
parent0f87ac234d98c68e4b2bfde6a8bcdeef3d3f54b7
KVM: x86: drop PIO from unregistered devices

KVM protects the device list with SRCU, and therefore different calls
to kvm_io_bus_read()/kvm_io_bus_write() can very well see different
incarnations of kvm->buses.  If userspace unregisters a device while
vCPUs are running there is no well-defined result.  This patch applies
a safe fallback by returning early from emulator_pio_in_out().  This
corresponds to returning zeroes from IN, and dropping the writes on
the floor for OUT.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c