[PATCH 2/38] KVM: Make /dev/registration happen when the arch specific module is loaded

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This avoids exposing the driver capabilities before they are loaded.

Signed-off-by: Avi Kivity <[email protected]>

Index: linux-2.6/drivers/kvm/kvm.h
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm.h
+++ linux-2.6/drivers/kvm/kvm.h
@@ -244,7 +244,7 @@ extern struct kvm_arch_ops *kvm_arch_ops
 #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
 #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)
 
-void kvm_init_arch(struct kvm_arch_ops *ops);
+int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module);
 void kvm_exit_arch(void);
 
 void kvm_mmu_destroy(struct kvm_vcpu *vcpu);
Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -3558,7 +3558,6 @@ static int kvm_dev_mmap(struct file *fil
 }
 
 static struct file_operations kvm_chardev_ops = {
-	.owner		= THIS_MODULE,
 	.open		= kvm_dev_open,
 	.release        = kvm_dev_release,
 	.unlocked_ioctl = kvm_dev_ioctl,
@@ -3612,13 +3611,26 @@ static void kvm_exit_debug(void)
 
 hpa_t bad_page_address;
 
-void kvm_init_arch(struct kvm_arch_ops *ops)
+int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module)
 {
+	int r;
+
 	kvm_arch_ops = ops;
+	kvm_chardev_ops.owner = module;
+
+	r = misc_register(&kvm_dev);
+	if (r) {
+		printk (KERN_ERR "kvm: misc device register failed\n");
+		goto out_free;
+	}
+
+out_free:
+	return r;
 }
 
 void kvm_exit_arch(void)
 {
+	misc_deregister(&kvm_dev);
 }
 
 static __init int kvm_init(void)
@@ -3644,13 +3656,6 @@ static __init int kvm_init(void)
 	on_each_cpu(kvm_enable, 0, 0, 1);
 	register_reboot_notifier(&kvm_reboot_notifier);
 
-	r = misc_register(&kvm_dev);
-	if (r) {
-		printk (KERN_ERR "kvm: misc device register failed\n");
-		goto out_free;
-	}
-
-
 	if ((bad_page = alloc_page(GFP_KERNEL)) == NULL) {
 		r = -ENOMEM;
 		goto out_free;
@@ -3671,7 +3676,6 @@ out:
 static __exit void kvm_exit(void)
 {
 	kvm_exit_debug();
-	misc_deregister(&kvm_dev);
 	unregister_reboot_notifier(&kvm_reboot_notifier);
 	on_each_cpu(kvm_disable, 0, 0, 1);
 	free_kvm_area();
Index: linux-2.6/drivers/kvm/vmx.c
===================================================================
--- linux-2.6.orig/drivers/kvm/vmx.c
+++ linux-2.6/drivers/kvm/vmx.c
@@ -26,7 +26,7 @@ static struct kvm_arch_ops vmx_arch_ops 
 
 static int __init vmx_init(void)
 {
-	kvm_init_arch(&vmx_arch_ops);
+	kvm_init_arch(&vmx_arch_ops, THIS_MODULE);
 	return 0;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux