Merge tag 'kvm-x86-generic-6.9' of https://github.com/kvm-x86/linux into HEAD
[linux-2.6-microblaze.git] / virt / kvm / kvm_main.c
index 4c48f61..741d86c 100644 (file)
@@ -1152,10 +1152,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, const char *fdname)
                                    &stat_fops_per_vm);
        }
 
-       ret = kvm_arch_create_vm_debugfs(kvm);
-       if (ret)
-               goto out_err;
-
+       kvm_arch_create_vm_debugfs(kvm);
        return 0;
 out_err:
        kvm_destroy_vm_debugfs(kvm);
@@ -1185,9 +1182,8 @@ void __weak kvm_arch_pre_destroy_vm(struct kvm *kvm)
  * Cleanup should be automatic done in kvm_destroy_vm_debugfs() recursively, so
  * a per-arch destroy interface is not needed.
  */
-int __weak kvm_arch_create_vm_debugfs(struct kvm *kvm)
+void __weak kvm_arch_create_vm_debugfs(struct kvm *kvm)
 {
-       return 0;
 }
 
 static struct kvm *kvm_create_vm(unsigned long type, const char *fdname)
@@ -1616,8 +1612,14 @@ static int check_memory_region_flags(struct kvm *kvm,
        if (mem->flags & KVM_MEM_GUEST_MEMFD)
                valid_flags &= ~KVM_MEM_LOG_DIRTY_PAGES;
 
-#ifdef __KVM_HAVE_READONLY_MEM
-       valid_flags |= KVM_MEM_READONLY;
+#ifdef CONFIG_HAVE_KVM_READONLY_MEM
+       /*
+        * GUEST_MEMFD is incompatible with read-only memslots, as writes to
+        * read-only memslots have emulated MMIO, not page fault, semantics,
+        * and KVM doesn't allow emulated MMIO for private memory.
+        */
+       if (!(mem->flags & KVM_MEM_GUEST_MEMFD))
+               valid_flags |= KVM_MEM_READONLY;
 #endif
 
        if (mem->flags & ~valid_flags)