--- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1664,7 +1664,8 @@ int __kvm_set_memory_region(struct kvm * id = (u16)mem->slot; /* General sanity checks */ - if (mem->memory_size & (PAGE_SIZE - 1)) + if ((mem->memory_size & (PAGE_SIZE - 1)) || + (mem->memory_size != (unsigned long)mem->memory_size)) return -EINVAL; if (mem->guest_phys_addr & (PAGE_SIZE - 1)) return -EINVAL;