From 0e4248a114bb1735078c2ef2e954e847aa67cdb9 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Fri, 10 Nov 2017 13:40:27 +0000 Subject: [PATCH] Prevent mlx5 core from accessing host memory after shutdown by disabling PCI busmaster. Sponsored by: Mellanox Technologies MFC after: 1 week --- sys/dev/mlx5/mlx5_core/mlx5_main.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_main.c b/sys/dev/mlx5/mlx5_core/mlx5_main.c index 5c102f40ea2..07a04b232d0 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_main.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_main.c @@ -1134,6 +1134,12 @@ static void remove_one(struct pci_dev *pdev) kfree(dev); } +static void shutdown_one(struct pci_dev *pdev) +{ + /* prevent device from accessing host memory after shutdown */ + pci_clear_master(pdev); +} + static const struct pci_device_id mlx5_core_pci_table[] = { { PCI_VDEVICE(MELLANOX, 4113) }, /* Connect-IB */ { PCI_VDEVICE(MELLANOX, 4114) }, /* Connect-IB VF */ @@ -1175,6 +1181,7 @@ MODULE_DEVICE_TABLE(pci, mlx5_core_pci_table); static struct pci_driver mlx5_core_driver = { .name = DRIVER_NAME, .id_table = mlx5_core_pci_table, + .shutdown = shutdown_one, .probe = init_one, .remove = remove_one };