<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/virt/kvm/vfio.h, branch v4.4.58</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>kvm: vfio: fix unregister kvm_device_ops of vfio</title>
<updated>2014-10-24T11:30:47+00:00</updated>
<author>
<name>Wanpeng Li</name>
<email>wanpeng.li@linux.intel.com</email>
</author>
<published>2014-10-09T10:30:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=571ee1b6859869a09ed718d390aac2b9414646a2'/>
<id>571ee1b6859869a09ed718d390aac2b9414646a2</id>
<content type='text'>
After commit 80ce163 (KVM: VFIO: register kvm_device_ops dynamically),
kvm_device_ops of vfio can be registered dynamically. Commit 3c3c29fd
(kvm-vfio: do not use module_init) move the dynamic register invoked by
kvm_init in order to fix broke unloading of the kvm module. However,
kvm_device_ops of vfio is unregistered after rmmod kvm-intel module
which lead to device type collision detection warning after kvm-intel
module reinsmod.

    WARNING: CPU: 1 PID: 10358 at /root/cathy/kvm/arch/x86/kvm/../../../virt/kvm/kvm_main.c:3289 kvm_init+0x234/0x282 [kvm]()
    Modules linked in: kvm_intel(O+) kvm(O) nfsv3 nfs_acl auth_rpcgss oid_registry nfsv4 dns_resolver nfs fscache lockd sunrpc pci_stub bridge stp llc autofs4 8021q cpufreq_ondemand ipv6 joydev microcode pcspkr igb i2c_algo_bit ehci_pci ehci_hcd e1000e i2c_i801 ixgbe ptp pps_core hwmon mdio tpm_tis tpm ipmi_si ipmi_msghandler acpi_cpufreq isci libsas scsi_transport_sas button dm_mirror dm_region_hash dm_log dm_mod [last unloaded: kvm_intel]
    CPU: 1 PID: 10358 Comm: insmod Tainted: G        W  O   3.17.0-rc1 #2
    Hardware name: Intel Corporation S2600CP/S2600CP, BIOS RMLSDP.86I.00.29.D696.1311111329 11/11/2013
     0000000000000cd9 ffff880ff08cfd18 ffffffff814a61d9 0000000000000cd9
     0000000000000000 ffff880ff08cfd58 ffffffff810417b7 ffff880ff08cfd48
     ffffffffa045bcac ffffffffa049c420 0000000000000040 00000000000000ff
    Call Trace:
     [&lt;ffffffff814a61d9&gt;] dump_stack+0x49/0x60
     [&lt;ffffffff810417b7&gt;] warn_slowpath_common+0x7c/0x96
     [&lt;ffffffffa045bcac&gt;] ? kvm_init+0x234/0x282 [kvm]
     [&lt;ffffffff810417e6&gt;] warn_slowpath_null+0x15/0x17
     [&lt;ffffffffa045bcac&gt;] kvm_init+0x234/0x282 [kvm]
     [&lt;ffffffffa016e995&gt;] vmx_init+0x1bf/0x42a [kvm_intel]
     [&lt;ffffffffa016e7d6&gt;] ? vmx_check_processor_compat+0x64/0x64 [kvm_intel]
     [&lt;ffffffff810002ab&gt;] do_one_initcall+0xe3/0x170
     [&lt;ffffffff811168a9&gt;] ? __vunmap+0xad/0xb8
     [&lt;ffffffff8109c58f&gt;] do_init_module+0x2b/0x174
     [&lt;ffffffff8109d414&gt;] load_module+0x43e/0x569
     [&lt;ffffffff8109c6d8&gt;] ? do_init_module+0x174/0x174
     [&lt;ffffffff8109c75a&gt;] ? copy_module_from_user+0x39/0x82
     [&lt;ffffffff8109b7dd&gt;] ? module_sect_show+0x20/0x20
     [&lt;ffffffff8109d65f&gt;] SyS_init_module+0x54/0x81
     [&lt;ffffffff814a9a12&gt;] system_call_fastpath+0x16/0x1b
    ---[ end trace 0626f4a3ddea56f3 ]---

The bug can be reproduced by:

    rmmod kvm_intel.ko
    insmod kvm_intel.ko

without rmmod/insmod kvm.ko
This patch fixes the bug by unregistering kvm_device_ops of vfio when the
kvm-intel module is removed.

Reported-by: Liu Rongrong &lt;rongrongx.liu@intel.com&gt;
Fixes: 3c3c29fd0d7cddc32862c350d0700ce69953e3bd
Signed-off-by: Wanpeng Li &lt;wanpeng.li@linux.intel.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After commit 80ce163 (KVM: VFIO: register kvm_device_ops dynamically),
kvm_device_ops of vfio can be registered dynamically. Commit 3c3c29fd
(kvm-vfio: do not use module_init) move the dynamic register invoked by
kvm_init in order to fix broke unloading of the kvm module. However,
kvm_device_ops of vfio is unregistered after rmmod kvm-intel module
which lead to device type collision detection warning after kvm-intel
module reinsmod.

    WARNING: CPU: 1 PID: 10358 at /root/cathy/kvm/arch/x86/kvm/../../../virt/kvm/kvm_main.c:3289 kvm_init+0x234/0x282 [kvm]()
    Modules linked in: kvm_intel(O+) kvm(O) nfsv3 nfs_acl auth_rpcgss oid_registry nfsv4 dns_resolver nfs fscache lockd sunrpc pci_stub bridge stp llc autofs4 8021q cpufreq_ondemand ipv6 joydev microcode pcspkr igb i2c_algo_bit ehci_pci ehci_hcd e1000e i2c_i801 ixgbe ptp pps_core hwmon mdio tpm_tis tpm ipmi_si ipmi_msghandler acpi_cpufreq isci libsas scsi_transport_sas button dm_mirror dm_region_hash dm_log dm_mod [last unloaded: kvm_intel]
    CPU: 1 PID: 10358 Comm: insmod Tainted: G        W  O   3.17.0-rc1 #2
    Hardware name: Intel Corporation S2600CP/S2600CP, BIOS RMLSDP.86I.00.29.D696.1311111329 11/11/2013
     0000000000000cd9 ffff880ff08cfd18 ffffffff814a61d9 0000000000000cd9
     0000000000000000 ffff880ff08cfd58 ffffffff810417b7 ffff880ff08cfd48
     ffffffffa045bcac ffffffffa049c420 0000000000000040 00000000000000ff
    Call Trace:
     [&lt;ffffffff814a61d9&gt;] dump_stack+0x49/0x60
     [&lt;ffffffff810417b7&gt;] warn_slowpath_common+0x7c/0x96
     [&lt;ffffffffa045bcac&gt;] ? kvm_init+0x234/0x282 [kvm]
     [&lt;ffffffff810417e6&gt;] warn_slowpath_null+0x15/0x17
     [&lt;ffffffffa045bcac&gt;] kvm_init+0x234/0x282 [kvm]
     [&lt;ffffffffa016e995&gt;] vmx_init+0x1bf/0x42a [kvm_intel]
     [&lt;ffffffffa016e7d6&gt;] ? vmx_check_processor_compat+0x64/0x64 [kvm_intel]
     [&lt;ffffffff810002ab&gt;] do_one_initcall+0xe3/0x170
     [&lt;ffffffff811168a9&gt;] ? __vunmap+0xad/0xb8
     [&lt;ffffffff8109c58f&gt;] do_init_module+0x2b/0x174
     [&lt;ffffffff8109d414&gt;] load_module+0x43e/0x569
     [&lt;ffffffff8109c6d8&gt;] ? do_init_module+0x174/0x174
     [&lt;ffffffff8109c75a&gt;] ? copy_module_from_user+0x39/0x82
     [&lt;ffffffff8109b7dd&gt;] ? module_sect_show+0x20/0x20
     [&lt;ffffffff8109d65f&gt;] SyS_init_module+0x54/0x81
     [&lt;ffffffff814a9a12&gt;] system_call_fastpath+0x16/0x1b
    ---[ end trace 0626f4a3ddea56f3 ]---

The bug can be reproduced by:

    rmmod kvm_intel.ko
    insmod kvm_intel.ko

without rmmod/insmod kvm.ko
This patch fixes the bug by unregistering kvm_device_ops of vfio when the
kvm-intel module is removed.

Reported-by: Liu Rongrong &lt;rongrongx.liu@intel.com&gt;
Fixes: 3c3c29fd0d7cddc32862c350d0700ce69953e3bd
Signed-off-by: Wanpeng Li &lt;wanpeng.li@linux.intel.com&gt;
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>kvm-vfio: do not use module_init</title>
<updated>2014-09-24T12:06:36+00:00</updated>
<author>
<name>Paolo Bonzini</name>
<email>pbonzini@redhat.com</email>
</author>
<published>2014-09-24T11:02:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=3c3c29fd0d7cddc32862c350d0700ce69953e3bd'/>
<id>3c3c29fd0d7cddc32862c350d0700ce69953e3bd</id>
<content type='text'>
/me got confused between the kernel and QEMU.  In the kernel, you can
only have one module_init function, and it will prevent unloading the
module unless you also have the corresponding module_exit function.

So, commit 80ce1639727e (KVM: VFIO: register kvm_device_ops dynamically,
2014-09-02) broke unloading of the kvm module, by adding a module_init
function and no module_exit.

Repair it by making kvm_vfio_ops_init weak, and checking it in
kvm_init.

Cc: Will Deacon &lt;will.deacon@arm.com&gt;
Cc: Gleb Natapov &lt;gleb@kernel.org&gt;
Cc: Alex Williamson &lt;Alex.Williamson@redhat.com&gt;
Fixes: 80ce1639727e9d38729c34f162378508c307ca25
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
/me got confused between the kernel and QEMU.  In the kernel, you can
only have one module_init function, and it will prevent unloading the
module unless you also have the corresponding module_exit function.

So, commit 80ce1639727e (KVM: VFIO: register kvm_device_ops dynamically,
2014-09-02) broke unloading of the kvm module, by adding a module_init
function and no module_exit.

Repair it by making kvm_vfio_ops_init weak, and checking it in
kvm_init.

Cc: Will Deacon &lt;will.deacon@arm.com&gt;
Cc: Gleb Natapov &lt;gleb@kernel.org&gt;
Cc: Alex Williamson &lt;Alex.Williamson@redhat.com&gt;
Fixes: 80ce1639727e9d38729c34f162378508c307ca25
Signed-off-by: Paolo Bonzini &lt;pbonzini@redhat.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
