<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/vfio, branch v4.19.112</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v4.19.112'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2020-01-27T13:50:46+00:00</updated>
<entry>
<title>vfio/mdev: Fix aborting mdev child device removal if one fails</title>
<updated>2020-01-27T13:50:46+00:00</updated>
<author>
<name>Parav Pandit</name>
<email>parav@mellanox.com</email>
</author>
<published>2019-04-30T22:49:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5babded4449053ec490a1dd687ebd03c04548bd7'/>
<id>urn:sha1:5babded4449053ec490a1dd687ebd03c04548bd7</id>
<content type='text'>
[ Upstream commit 6093e348a5e2475c5bb2e571346460f939998670 ]

device_for_each_child() stops executing callback function for remaining
child devices, if callback hits an error.
Each child mdev device is independent of each other.
While unregistering parent device, mdev core must remove all child mdev
devices.
Therefore, mdev_device_remove_cb() always returns success so that
device_for_each_child doesn't abort if one child removal hits error.

While at it, improve remove and unregister functions for below simplicity.

There isn't need to pass forced flag pointer during mdev parent
removal which invokes mdev_device_remove(). So simplify the flow.

mdev_device_remove() is called from two paths.
1. mdev_unregister_driver()
     mdev_device_remove_cb()
       mdev_device_remove()
2. remove_store()
     mdev_device_remove()

Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
Reviewed-by: Maxim Levitsky &lt;mlevitsk@redhat.com&gt;
Signed-off-by: Parav Pandit &lt;parav@mellanox.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio/mdev: Follow correct remove sequence</title>
<updated>2020-01-27T13:50:45+00:00</updated>
<author>
<name>Parav Pandit</name>
<email>parav@mellanox.com</email>
</author>
<published>2019-04-30T22:49:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=09dbc7e408dc9ade20255148ba0c0cd395acb31e'/>
<id>urn:sha1:09dbc7e408dc9ade20255148ba0c0cd395acb31e</id>
<content type='text'>
[ Upstream commit a6d6f4f160f76d840e59affe664b8d3159e23056 ]

mdev_remove_sysfs_files() should follow exact mirror sequence of a
create, similar to what is followed in error unwinding path of
mdev_create_sysfs_files().

Fixes: 6a62c1dfb5c7 ("vfio/mdev: Re-order sysfs attribute creation")
Reviewed-by: Cornelia Huck &lt;cohuck@redhat.com&gt;
Reviewed-by: Maxim Levitsky &lt;mlevitsk@redhat.com&gt;
Signed-off-by: Parav Pandit &lt;parav@mellanox.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio/mdev: Avoid release parent reference during error path</title>
<updated>2020-01-27T13:50:45+00:00</updated>
<author>
<name>Parav Pandit</name>
<email>parav@mellanox.com</email>
</author>
<published>2019-04-30T22:49:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=5c5492ee3e8c2b1656da012112496b65da21c55f'/>
<id>urn:sha1:5c5492ee3e8c2b1656da012112496b65da21c55f</id>
<content type='text'>
[ Upstream commit 60e7f2c3fe9919cee9534b422865eed49f4efb15 ]

During mdev parent registration in mdev_register_device(),
if parent device is duplicate, it releases the reference of existing
parent device.
This is incorrect. Existing parent device should not be touched.

Fixes: 7b96953bc640 ("vfio: Mediated device Core driver")
Reviewed-by: Cornelia Huck &lt;cohuck@redhat.com&gt;
Reviewed-by: Kirti Wankhede &lt;kwankhede@nvidia.com&gt;
Reviewed-by: Maxim Levitsky &lt;mlevitsk@redhat.com&gt;
Signed-off-by: Parav Pandit &lt;parav@mellanox.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio_pci: Enable memory accesses before calling pci_map_rom</title>
<updated>2020-01-27T13:50:24+00:00</updated>
<author>
<name>Eric Auger</name>
<email>eric.auger@redhat.com</email>
</author>
<published>2019-02-15T16:16:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c8fa33f8315353035dece3e3ff24e4b21b05b5b0'/>
<id>urn:sha1:c8fa33f8315353035dece3e3ff24e4b21b05b5b0</id>
<content type='text'>
[ Upstream commit 0cfd027be1d6def4a462cdc180c055143af24069 ]

pci_map_rom/pci_get_rom_size() performs memory access in the ROM.
In case the Memory Space accesses were disabled, readw() is likely
to trigger a synchronous external abort on some platforms.

In case memory accesses were disabled, re-enable them before the
call and disable them back again just after.

Fixes: 89e1f7d4c66d ("vfio: Add PCI device driver")
Signed-off-by: Eric Auger &lt;eric.auger@redhat.com&gt;
Suggested-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio/pci: call irq_bypass_unregister_producer() before freeing irq</title>
<updated>2019-12-21T09:57:37+00:00</updated>
<author>
<name>Jiang Yi</name>
<email>giangyi@amazon.com</email>
</author>
<published>2019-11-27T16:49:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=73155507af8fe30db7d8ca2e6e3b6c2aa13491a0'/>
<id>urn:sha1:73155507af8fe30db7d8ca2e6e3b6c2aa13491a0</id>
<content type='text'>
commit d567fb8819162099035e546b11a736e29c2af0ea upstream.

Since irq_bypass_register_producer() is called after request_irq(), we
should do tear-down in reverse order: irq_bypass_unregister_producer()
then free_irq().

Specifically free_irq() may release resources required by the
irqbypass del_producer() callback.  Notably an example provided by
Marc Zyngier on arm64 with GICv4 that he indicates has the potential
to wedge the hardware:

 free_irq(irq)
   __free_irq(irq)
     irq_domain_deactivate_irq(irq)
       its_irq_domain_deactivate()
         [unmap the VLPI from the ITS]

 kvm_arch_irq_bypass_del_producer(cons, prod)
   kvm_vgic_v4_unset_forwarding(kvm, irq, ...)
     its_unmap_vlpi(irq)
       [Unmap the VLPI from the ITS (again), remap the original LPI]

Signed-off-by: Jiang Yi &lt;giangyi@amazon.com&gt;
Cc: stable@vger.kernel.org # v4.4+
Fixes: 6d7425f109d26 ("vfio: Register/unregister irq_bypass_producer")
Link: https://lore.kernel.org/kvm/20191127164910.15888-1-giangyi@amazon.com
Reviewed-by: Marc Zyngier &lt;maz@kernel.org&gt;
Reviewed-by: Eric Auger &lt;eric.auger@redhat.com&gt;
[aw: commit log]
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>vfio/spapr_tce: Get rid of possible infinite loop</title>
<updated>2019-12-05T08:20:43+00:00</updated>
<author>
<name>Alexey Kardashevskiy</name>
<email>aik@ozlabs.ru</email>
</author>
<published>2018-10-02T03:22:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=42cdd8e9616d5a228ba1dd17ed8a2a8d2719b1a1'/>
<id>urn:sha1:42cdd8e9616d5a228ba1dd17ed8a2a8d2719b1a1</id>
<content type='text'>
[ Upstream commit 517ad4ae8aa93dccdb9a88c27257ecb421c9e848 ]

As a part of cleanup, the SPAPR TCE IOMMU subdriver releases preregistered
memory. If there is a bug in memory release, the loop in
tce_iommu_release() becomes infinite; this actually happened to me.

This makes the loop finite and prints a warning on every failure to make
the code more bug prone.

Signed-off-by: Alexey Kardashevskiy &lt;aik@ozlabs.ru&gt;
Reviewed-by: David Gibson &lt;david@gibson.dropbear.id.au&gt;
Acked-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio/pci: Mask buggy SR-IOV VF INTx support</title>
<updated>2019-11-20T17:47:32+00:00</updated>
<author>
<name>Alex Williamson</name>
<email>alex.williamson@redhat.com</email>
</author>
<published>2018-09-25T19:01:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1ae5bfee6cff11dfe958dc86f38e168d7fe7865e'/>
<id>urn:sha1:1ae5bfee6cff11dfe958dc86f38e168d7fe7865e</id>
<content type='text'>
[ Upstream commit db04264fe9bc0f2b62e036629f9afb530324b693 ]

The SR-IOV spec requires that VFs must report zero for the INTx pin
register as VFs are precluded from INTx support.  It's much easier for
the host kernel to understand whether a device is a VF and therefore
whether a non-zero pin register value is bogus than it is to do the
same in userspace.  Override the INTx count for such devices and
virtualize the pin register to provide a consistent view of the device
to the user.

As this is clearly a spec violation, warn about it to support hardware
validation, but also provide a known whitelist as it doesn't do much
good to continue complaining if the hardware vendor doesn't plan to
fix it.

Known devices with this issue: 8086:270c

Tested-by: Gage Eads &lt;gage.eads@intel.com&gt;
Reviewed-by: Ashok Raj &lt;ashok.raj@intel.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio/pci: Fix potential memory leak in vfio_msi_cap_len</title>
<updated>2019-11-20T17:47:32+00:00</updated>
<author>
<name>Li Qiang</name>
<email>liq3ea@gmail.com</email>
</author>
<published>2018-09-25T19:01:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=dde3433de9a067a33d67d65b9093cad3e043e49e'/>
<id>urn:sha1:dde3433de9a067a33d67d65b9093cad3e043e49e</id>
<content type='text'>
[ Upstream commit 30ea32ab1951c80c6113f300fce2c70cd12659e4 ]

Free allocated vdev-&gt;msi_perm in error path.

Signed-off-by: Li Qiang &lt;liq3ea@gmail.com&gt;
Reviewed-by: Eric Auger &lt;eric.auger@redhat.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio_pci: Restore original state on release</title>
<updated>2019-10-07T16:56:53+00:00</updated>
<author>
<name>hexin</name>
<email>hexin.op@gmail.com</email>
</author>
<published>2019-08-22T03:35:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9b2d2f2ad0039fb8bb77993751cbf9eaaff223f0'/>
<id>urn:sha1:9b2d2f2ad0039fb8bb77993751cbf9eaaff223f0</id>
<content type='text'>
[ Upstream commit 92c8026854c25093946e0d7fe536fd9eac440f06 ]

vfio_pci_enable() saves the device's initial configuration information
with the intent that it is restored in vfio_pci_disable().  However,
the commit referenced in Fixes: below replaced the call to
__pci_reset_function_locked(), which is not wrapped in a state save
and restore, with pci_try_reset_function(), which overwrites the
restored device state with the current state before applying it to the
device.  Reinstate use of __pci_reset_function_locked() to return to
the desired behavior.

Fixes: 890ed578df82 ("vfio-pci: Use pci "try" reset interface")
Signed-off-by: hexin &lt;hexin15@baidu.com&gt;
Signed-off-by: Liu Qi &lt;liuqi16@baidu.com&gt;
Signed-off-by: Zhang Yu &lt;zhangyu31@baidu.com&gt;
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>vfio: Fix WARNING "do not call blocking ops when !TASK_RUNNING"</title>
<updated>2019-06-15T09:54:07+00:00</updated>
<author>
<name>Farhan Ali</name>
<email>alifm@linux.ibm.com</email>
</author>
<published>2019-04-03T18:22:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=f7883f9b5a6777f1b1a19c82aa42978181300f3b'/>
<id>urn:sha1:f7883f9b5a6777f1b1a19c82aa42978181300f3b</id>
<content type='text'>
[ Upstream commit 41be3e2618174fdf3361e49e64f2bf530f40c6b0 ]

vfio_dev_present() which is the condition to
wait_event_interruptible_timeout(), will call vfio_group_get_device
and try to acquire the mutex group-&gt;device_lock.

wait_event_interruptible_timeout() will set the state of the current
task to TASK_INTERRUPTIBLE, before doing the condition check. This
means that we will try to acquire the mutex while already in a
sleeping state. The scheduler warns us by giving the following
warning:

[ 4050.264464] ------------[ cut here ]------------
[ 4050.264508] do not call blocking ops when !TASK_RUNNING; state=1 set at [&lt;00000000b33c00e2&gt;] prepare_to_wait_event+0x14a/0x188
[ 4050.264529] WARNING: CPU: 12 PID: 35924 at kernel/sched/core.c:6112 __might_sleep+0x76/0x90
....

 4050.264756] Call Trace:
[ 4050.264765] ([&lt;000000000017bbaa&gt;] __might_sleep+0x72/0x90)
[ 4050.264774]  [&lt;0000000000b97edc&gt;] __mutex_lock+0x44/0x8c0
[ 4050.264782]  [&lt;0000000000b9878a&gt;] mutex_lock_nested+0x32/0x40
[ 4050.264793]  [&lt;000003ff800d7abe&gt;] vfio_group_get_device+0x36/0xa8 [vfio]
[ 4050.264803]  [&lt;000003ff800d87c0&gt;] vfio_del_group_dev+0x238/0x378 [vfio]
[ 4050.264813]  [&lt;000003ff8015f67c&gt;] mdev_remove+0x3c/0x68 [mdev]
[ 4050.264825]  [&lt;00000000008e01b0&gt;] device_release_driver_internal+0x168/0x268
[ 4050.264834]  [&lt;00000000008de692&gt;] bus_remove_device+0x162/0x190
[ 4050.264843]  [&lt;00000000008daf42&gt;] device_del+0x1e2/0x368
[ 4050.264851]  [&lt;00000000008db12c&gt;] device_unregister+0x64/0x88
[ 4050.264862]  [&lt;000003ff8015ed84&gt;] mdev_device_remove+0xec/0x130 [mdev]
[ 4050.264872]  [&lt;000003ff8015f074&gt;] remove_store+0x6c/0xa8 [mdev]
[ 4050.264881]  [&lt;000000000046f494&gt;] kernfs_fop_write+0x14c/0x1f8
[ 4050.264890]  [&lt;00000000003c1530&gt;] __vfs_write+0x38/0x1a8
[ 4050.264899]  [&lt;00000000003c187c&gt;] vfs_write+0xb4/0x198
[ 4050.264908]  [&lt;00000000003c1af2&gt;] ksys_write+0x5a/0xb0
[ 4050.264916]  [&lt;0000000000b9e270&gt;] system_call+0xdc/0x2d8
[ 4050.264925] 4 locks held by sh/35924:
[ 4050.264933]  #0: 000000001ef90325 (sb_writers#4){.+.+}, at: vfs_write+0x9e/0x198
[ 4050.264948]  #1: 000000005c1ab0b3 (&amp;of-&gt;mutex){+.+.}, at: kernfs_fop_write+0x1cc/0x1f8
[ 4050.264963]  #2: 0000000034831ab8 (kn-&gt;count#297){++++}, at: kernfs_remove_self+0x12e/0x150
[ 4050.264979]  #3: 00000000e152484f (&amp;dev-&gt;mutex){....}, at: device_release_driver_internal+0x5c/0x268
[ 4050.264993] Last Breaking-Event-Address:
[ 4050.265002]  [&lt;000000000017bbaa&gt;] __might_sleep+0x72/0x90
[ 4050.265010] irq event stamp: 7039
[ 4050.265020] hardirqs last  enabled at (7047): [&lt;00000000001cee7a&gt;] console_unlock+0x6d2/0x740
[ 4050.265029] hardirqs last disabled at (7054): [&lt;00000000001ce87e&gt;] console_unlock+0xd6/0x740
[ 4050.265040] softirqs last  enabled at (6416): [&lt;0000000000b8fe26&gt;] __udelay+0xb6/0x100
[ 4050.265049] softirqs last disabled at (6415): [&lt;0000000000b8fe06&gt;] __udelay+0x96/0x100
[ 4050.265057] ---[ end trace d04a07d39d99a9f9 ]---

Let's fix this as described in the article
https://lwn.net/Articles/628628/.

Signed-off-by: Farhan Ali &lt;alifm@linux.ibm.com&gt;
[remove now redundant vfio_dev_present()]
Signed-off-by: Alex Williamson &lt;alex.williamson@redhat.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
