All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] vDPA/ifcvf: got a warning when removing the module
@ 2022-05-21 14:27 Zheyu Ma
  2022-05-23  4:15   ` Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: Zheyu Ma @ 2022-05-21 14:27 UTC (permalink / raw)
  To: mst, jasowang, lingshan.zhu, xieyongji, elic, parav
  Cc: virtualization, Linux Kernel Mailing List

Hello,

I found a bug in the ifcvf driver.
When removing the module, I got the following warning:

[   14.478123] general protection fault, probably for non-canonical
address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
[   14.478701] KASAN: null-ptr-deref in range
[0x0000000000000028-0x000000000000002f]
[   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
[   14.484063] Call Trace:
[   14.484186]  <TASK>
[   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
[   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
[   14.484743]  pci_device_remove+0x92/0x240

The reason is that the 'ifcvf_mgmt_dev' is zero which means that
ifcvf_vdpa_dev_add() was not executed.
Since I am not familiar with the driver, I cannot find a proper solution for it.

Zheyu Ma

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [BUG] vDPA/ifcvf: got a warning when removing the module
  2022-05-21 14:27 [BUG] vDPA/ifcvf: got a warning when removing the module Zheyu Ma
@ 2022-05-23  4:15   ` Jason Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-05-23  4:15 UTC (permalink / raw)
  To: Zheyu Ma
  Cc: mst, Linux Kernel Mailing List, virtualization, Yongji Xie,
	Zhu Lingshan, Eli Cohen

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

On Sat, May 21, 2022 at 10:27 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> Hello,
>
> I found a bug in the ifcvf driver.
> When removing the module, I got the following warning:
>
> [   14.478123] general protection fault, probably for non-canonical
> address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
> [   14.478701] KASAN: null-ptr-deref in range
> [0x0000000000000028-0x000000000000002f]
> [   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
> [   14.484063] Call Trace:
> [   14.484186]  <TASK>
> [   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
> [   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
> [   14.484743]  pci_device_remove+0x92/0x240
>
> The reason is that the 'ifcvf_mgmt_dev' is zero which means that
> ifcvf_vdpa_dev_add() was not executed.
> Since I am not familiar with the driver, I cannot find a proper solution for it.
>

Looks like the drv data needs to be set in probe(). Could you pleas
try to the attached patch? (compile test only).

Thanks

> Zheyu Ma
>

[-- Attachment #2: 0001-vdpa-ifcvf-set-pci-driver-data-in-probe.patch --]
[-- Type: application/octet-stream, Size: 1265 bytes --]

From c7c031d1a5c64e0f58e01579ff78224a58d6a4fa Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 23 May 2022 12:12:00 +0800
Subject: [PATCH] vdpa: ifcvf: set pci driver data in probe
Content-type: text/plain

We should set the pci driver data in probe instead of the vdpa device
adding callback. Otherwise if no vDPA device is created we will lose
the pointer to the management device.

Fixes: 6b5df347c6482 ("vDPA/ifcvf: implement management netlink framework for ifcvf")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 4366320fb68d..197d52e7b801 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -765,7 +765,6 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 	}
 
 	ifcvf_mgmt_dev->adapter = adapter;
-	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
 
 	vf = &adapter->vf;
 	vf->dev_type = get_dev_type(pdev);
@@ -880,6 +879,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err;
 	}
 
+	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
+
 	return 0;
 
 err:
-- 
2.25.1


[-- Attachment #3: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [BUG] vDPA/ifcvf: got a warning when removing the module
@ 2022-05-23  4:15   ` Jason Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2022-05-23  4:15 UTC (permalink / raw)
  To: Zheyu Ma
  Cc: mst, Zhu Lingshan, Yongji Xie, Eli Cohen, Parav Pandit,
	virtualization, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 1006 bytes --]

On Sat, May 21, 2022 at 10:27 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
>
> Hello,
>
> I found a bug in the ifcvf driver.
> When removing the module, I got the following warning:
>
> [   14.478123] general protection fault, probably for non-canonical
> address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
> [   14.478701] KASAN: null-ptr-deref in range
> [0x0000000000000028-0x000000000000002f]
> [   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
> [   14.484063] Call Trace:
> [   14.484186]  <TASK>
> [   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
> [   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
> [   14.484743]  pci_device_remove+0x92/0x240
>
> The reason is that the 'ifcvf_mgmt_dev' is zero which means that
> ifcvf_vdpa_dev_add() was not executed.
> Since I am not familiar with the driver, I cannot find a proper solution for it.
>

Looks like the drv data needs to be set in probe(). Could you pleas
try to the attached patch? (compile test only).

Thanks

> Zheyu Ma
>

[-- Attachment #2: 0001-vdpa-ifcvf-set-pci-driver-data-in-probe.patch --]
[-- Type: application/octet-stream, Size: 1265 bytes --]

From c7c031d1a5c64e0f58e01579ff78224a58d6a4fa Mon Sep 17 00:00:00 2001
From: Jason Wang <jasowang@redhat.com>
Date: Mon, 23 May 2022 12:12:00 +0800
Subject: [PATCH] vdpa: ifcvf: set pci driver data in probe
Content-type: text/plain

We should set the pci driver data in probe instead of the vdpa device
adding callback. Otherwise if no vDPA device is created we will lose
the pointer to the management device.

Fixes: 6b5df347c6482 ("vDPA/ifcvf: implement management netlink framework for ifcvf")
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index 4366320fb68d..197d52e7b801 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -765,7 +765,6 @@ static int ifcvf_vdpa_dev_add(struct vdpa_mgmt_dev *mdev, const char *name,
 	}
 
 	ifcvf_mgmt_dev->adapter = adapter;
-	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
 
 	vf = &adapter->vf;
 	vf->dev_type = get_dev_type(pdev);
@@ -880,6 +879,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err;
 	}
 
+	pci_set_drvdata(pdev, ifcvf_mgmt_dev);
+
 	return 0;
 
 err:
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [BUG] vDPA/ifcvf: got a warning when removing the module
  2022-05-23  4:15   ` Jason Wang
  (?)
@ 2022-05-23  4:47   ` Zheyu Ma
  -1 siblings, 0 replies; 4+ messages in thread
From: Zheyu Ma @ 2022-05-23  4:47 UTC (permalink / raw)
  To: Jason Wang
  Cc: mst, Zhu Lingshan, Yongji Xie, Eli Cohen, Parav Pandit,
	virtualization, Linux Kernel Mailing List

On Mon, May 23, 2022 at 12:15 PM Jason Wang <jasowang@redhat.com> wrote:
>
> On Sat, May 21, 2022 at 10:27 PM Zheyu Ma <zheyuma97@gmail.com> wrote:
> >
> > Hello,
> >
> > I found a bug in the ifcvf driver.
> > When removing the module, I got the following warning:
> >
> > [   14.478123] general protection fault, probably for non-canonical
> > address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN PTI
> > [   14.478701] KASAN: null-ptr-deref in range
> > [0x0000000000000028-0x000000000000002f]
> > [   14.479922] RIP: 0010:vdpa_mgmtdev_unregister+0x39/0x150
> > [   14.484063] Call Trace:
> > [   14.484186]  <TASK>
> > [   14.484292]  ? _raw_spin_unlock_irqrestore+0x3d/0x60
> > [   14.484536]  ifcvf_remove+0x3a/0x50 [ifcvf]
> > [   14.484743]  pci_device_remove+0x92/0x240
> >
> > The reason is that the 'ifcvf_mgmt_dev' is zero which means that
> > ifcvf_vdpa_dev_add() was not executed.
> > Since I am not familiar with the driver, I cannot find a proper solution for it.
> >
>
> Looks like the drv data needs to be set in probe(). Could you pleas
> try to the attached patch? (compile test only).

This patch works for me, thanks!

Tested-by: Zheyu Ma <zheyuma97@gmail.com>

Regards,
Zheyu Ma

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-23  4:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-21 14:27 [BUG] vDPA/ifcvf: got a warning when removing the module Zheyu Ma
2022-05-23  4:15 ` Jason Wang
2022-05-23  4:15   ` Jason Wang
2022-05-23  4:47   ` Zheyu Ma

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.