Merge tag 'kvm-x86-generic-6.12' of https://github.com/kvm-x86/linux into HEAD

KVK generic changes for 6.12:

 - Fix a bug that results in KVM prematurely exiting to userspace for coalesced
   MMIO/PIO in many cases, clean up the related code, and add a testcase.

 - Fix a bug in kvm_clear_guest() where it would trigger a buffer overflow _if_
   the gpa+len crosses a page boundary, which thankfully is guaranteed to not
   happen in the current code base.  Add WARNs in more helpers that read/write
   guest memory to detect similar bugs.
This commit is contained in:
Paolo Bonzini
2024-09-14 09:34:30 -04:00
5 changed files with 283 additions and 24 deletions

View File

@@ -460,6 +460,32 @@ static inline uint32_t kvm_vm_reset_dirty_ring(struct kvm_vm *vm)
return __vm_ioctl(vm, KVM_RESET_DIRTY_RINGS, NULL);
}
static inline void kvm_vm_register_coalesced_io(struct kvm_vm *vm,
uint64_t address,
uint64_t size, bool pio)
{
struct kvm_coalesced_mmio_zone zone = {
.addr = address,
.size = size,
.pio = pio,
};
vm_ioctl(vm, KVM_REGISTER_COALESCED_MMIO, &zone);
}
static inline void kvm_vm_unregister_coalesced_io(struct kvm_vm *vm,
uint64_t address,
uint64_t size, bool pio)
{
struct kvm_coalesced_mmio_zone zone = {
.addr = address,
.size = size,
.pio = pio,
};
vm_ioctl(vm, KVM_UNREGISTER_COALESCED_MMIO, &zone);
}
static inline int vm_get_stats_fd(struct kvm_vm *vm)
{
int fd = __vm_ioctl(vm, KVM_GET_STATS_FD, NULL);