Skip to contentSkip to conversation

pci-hyperv: Add check for hyperv_initialized in init_hv_pci_drv()

PATCH In review Haiyang Zhang 3 participants 7 messages May 25, 2021 – Jun 18, 2021

Subsystems (4)
lore
Share & tools
lore

Haiyang Zhang

author maintainer
#0 lore raw

PATCH 1/1 pci-hyperv: Add check for hyperv_initialized in init_hv_pci_drv()

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

---
 drivers/pci/controller/pci-hyperv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
index 6511648271b2..bebe3eeebc4e 100644
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)
 
 static int __init init_hv_pci_drv(void)
 {
+	if (!hv_is_hyperv_initialized())
+		return -ENODEV;
+
 	/* Set the invalid domain number's bit, so it will not be used */
 	set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Quoted 21 lines
---
 drivers/pci/controller/pci-hyperv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
index 6511648271b2..bebe3eeebc4e 100644
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)
 
 static int __init init_hv_pci_drv(void)
 {
+	if (!hv_is_hyperv_initialized())
+		return -ENODEV;
+
 	/* Set the invalid domain number's bit, so it will not be used */
 	set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw
In reply to Haiyang Zhang
Quoted 7 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Hello PCI subsystem maintainers, are you going to take this patch or shall I?

Wei.

Quoted 21 lines
---
 drivers/pci/controller/pci-hyperv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
index 6511648271b2..bebe3eeebc4e 100644
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)
 
 static int __init init_hv_pci_drv(void)
 {
+	if (!hv_is_hyperv_initialized())
+		return -ENODEV;
+
 	/* Set the invalid domain number's bit, so it will not be used */
 	set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
 
Signature · 1 line
2.25.1
#3 lore raw
Quoted 11 lines · Wei Liu
Quoted 7 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Hello PCI subsystem maintainers, are you going to take this patch or shall I?

This was mistakenly assigned to me, so I reassigned it back to Lorenzo.

If you *do* take this, please at least update it to follow the PCI commit log conventions, e.g.,

PCI: hv: Add check ...

and wrap the text so it fits in 75 columns.

Quoted 21 lines
Quoted 21 lines
---
 drivers/pci/controller/pci-hyperv.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/pci/controller/pci-hyperv.c +3 -0
index 6511648271b2..bebe3eeebc4e 100644
@@ -3476,6 +3476,9 @@ static void __exit exit_hv_pci_drv(void)
 
 static int __init init_hv_pci_drv(void)
 {
+	if (!hv_is_hyperv_initialized())
+		return -ENODEV;
+
 	/* Set the invalid domain number's bit, so it will not be used */
 	set_bit(HVPCI_DOM_INVALID, hvpci_dom_map);
 
Signature · 1 line
2.25.1
maintainer
#4 lore raw
Quoted 16 lines · Bjorn Helgaas
Quoted 11 lines · Wei Liu
Quoted 7 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Hello PCI subsystem maintainers, are you going to take this patch or shall I?

This was mistakenly assigned to me, so I reassigned it back to Lorenzo.

Quoted 6 lines

If you *do* take this, please at least update it to follow the PCI commit log conventions, e.g.,

PCI: hv: Add check ...

and wrap the text so it fits in 75 columns.

Lorenzo already picked up two Hyper-V PCI patches from Long Li. I think leaving this to him is better.

Wei.

maintainer
#5 lore raw
Quoted 20 lines · Wei Liu
Quoted 19 lines · Bjorn Helgaas
Quoted 11 lines · Wei Liu
Quoted 7 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Hello PCI subsystem maintainers, are you going to take this patch or shall I?

This was mistakenly assigned to me, so I reassigned it back to Lorenzo.

If you *do* take this, please at least update it to follow the PCI commit log conventions, e.g.,

Quoted 7 lines
Quoted 3 lines

PCI: hv: Add check ...

and wrap the text so it fits in 75 columns.

Lorenzo already picked up two Hyper-V PCI patches from Long Li. I think leaving this to him is better.

This patch is still missing from pci/hv, so I've picked it up via hyperv-next (with the adjustments required by Bjorn).

Wei.

author maintainer
#6 lore raw
Quoted 39 lines

-----Original Message-----
From: Wei Liu <[email protected]>
Sent: Friday, June 18, 2021 9:23 AM
To: Bjorn Helgaas <[email protected]>
Cc: Wei Liu <[email protected]>; Haiyang Zhang <[email protected]>; [email protected]; [email protected]; linux- [email protected]; [email protected]; KY Srinivasan <[email protected]>; [email protected]; vkuznets <[email protected]>; [email protected]
Subject: Re: [PATCH] pci-hyperv: Add check for hyperv_initialized in init_hv_pci_drv()

Quoted 24 lines · Wei Liu
Quoted 23 lines · Bjorn Helgaas
Quoted 7 lines · Wei Liu
Quoted 6 lines · Haiyang Zhang

Add check for hv_is_hyperv_initialized() at the top of init_hv_pci_drv(), so if the pci-hyperv driver is force-loaded on non Hyper-V platforms, the
init_hv_pci_drv() will exit immediately, without any side effects, like assignments to hvpci_block_ops, etc.

Quoted 6 lines
Quoted 3 lines
Reported-and-tested-by Mohammad Alqayeem

<[email protected]>

Hello PCI subsystem maintainers, are you going to take this patch or shall I?

This was mistakenly assigned to me, so I reassigned it back to Lorenzo.

If you *do* take this, please at least update it to follow the PCI commit log conventions, e.g.,

PCI: hv: Add check ...

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

and wrap the text so it fits in 75 columns.

Lorenzo already picked up two Hyper-V PCI patches from Long Li. I think leaving this to him is better.

This patch is still missing from pci/hv, so I've picked it up via hyperv-next (with the adjustments required by Bjorn).

Thank you!

- Haiyang