未验证 提交 7eddfefc 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!1700 vfio-pci: Match specific devices with vendor id and device id

Merge Pull Request from: @did-you-collect-the-wool-today 
 
virt inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7QPGW
CVE: NA

------------------------------------------------------------------

In probe_vendor_drivers, all registered vendor drivers are traversed.
This is not a good idea. If a vendor driver is not implemented well
enough, it may cause the system to panic. Use the vendor id and
device id to select a proper driver.

In the pervious device registration logic, since the live migration
operation ops of the three accelerator devices is the same.
Therefore, only one driver entity will be registered. As a result,
only the first sec will be loaded successfully, while hpre and zip
cannot be loaded.

The acc live migration driver needs to be adapted.

Tips: The problem code is not completely fixed. To keep consistent with
olk-5.10, roll back the previous bugfix and resubmit a new one. This new
bugfix is consistent with the one for the olk-5.10 branch.
Signed-off-by: NLongfang Liu <liulongfang@huawei.com>
Signed-off-by: Kunkun Jiang <jiangkunkun@huawei.com> 
 
Link:https://gitee.com/openeuler/kernel/pulls/1700 

Reviewed-by: Zenghui Yu <yuzenghui@huawei.com> 
Signed-off-by: Jialin Zhang <zhangjialin11@huawei.com> 
......@@ -1779,7 +1779,9 @@ static int __init acc_vf_module_init(void)
static void __exit acc_vf_module_exit(void)
{
vfio_pci_unregister_vendor_driver(&acc_vf_device_ops_node);
vfio_pci_unregister_vendor_driver(&sec_vf_mig_ops);
vfio_pci_unregister_vendor_driver(&hpre_vf_mig_ops);
vfio_pci_unregister_vendor_driver(&zip_vf_mig_ops);
};
module_init(acc_vf_module_init);
module_exit(acc_vf_module_exit);
......
......@@ -2608,7 +2608,8 @@ int __vfio_pci_register_vendor_driver(struct vfio_pci_vendor_driver_ops *ops)
/* Check for duplicates */
list_for_each_entry(tmp, &vfio_pci.vendor_drivers_list, next) {
if (tmp->ops->device_ops == ops->device_ops) {
if (tmp->ops->vendor == ops->vendor &&
tmp->ops->vendor == ops->device) {
mutex_unlock(&vfio_pci.vendor_drivers_lock);
kfree(driver);
return -EINVAL;
......@@ -2626,14 +2627,15 @@ int __vfio_pci_register_vendor_driver(struct vfio_pci_vendor_driver_ops *ops)
}
EXPORT_SYMBOL_GPL(__vfio_pci_register_vendor_driver);
void vfio_pci_unregister_vendor_driver(struct vfio_device_ops *device_ops)
void vfio_pci_unregister_vendor_driver(struct vfio_pci_vendor_driver_ops *ops)
{
struct vfio_pci_vendor_driver *driver, *tmp;
mutex_lock(&vfio_pci.vendor_drivers_lock);
list_for_each_entry_safe(driver, tmp,
&vfio_pci.vendor_drivers_list, next) {
if (driver->ops->device_ops == device_ops) {
if (driver->ops->vendor == ops->vendor &&
driver->ops->device == ops->device) {
list_del(&driver->next);
mutex_unlock(&vfio_pci.vendor_drivers_lock);
kfree(driver);
......
......@@ -261,7 +261,7 @@ struct vfio_pci_vendor_driver_ops {
struct vfio_device_ops *device_ops;
};
int __vfio_pci_register_vendor_driver(struct vfio_pci_vendor_driver_ops *ops);
void vfio_pci_unregister_vendor_driver(struct vfio_device_ops *device_ops);
void vfio_pci_unregister_vendor_driver(struct vfio_pci_vendor_driver_ops *ops);
#define vfio_pci_register_vendor_driver(__name, __probe, __remove, \
__device_ops) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册