Skip to contentSkip to conversation

PCI: vmd: Only assign OSC features in bare metal OS.

PATCH Superseded Nirmal Patel 4 participants 5 messages Jul 10 – Jul 13

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 PCI: vmd: Only assign OSC features in bare metal OS.

Copy valid OSC flags from root bridge only when OS can provide correct values. In virtual machine, all of the control features are disabled as hypervisor will not passthrough root bridge information to VM.

---
v2 : Added descriptive boolean and removed period from commit message.

---
 drivers/pci/controller/vmd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/pci/controller/vmd.c +8 -4
index d4ae250d4bc6..760dfb4d9480 100644
@@ -782,6 +782,7 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 	resource_size_t membar2_offset = 0x2000;
 	struct pci_bus *child;
 	struct pci_dev *dev;
+	bool vmd_in_guest;
 	int ret;
 
 	/*
@@ -862,14 +863,15 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 		.parent = res,
 	};
 
+	/* Non-zero offset means guest/direct assign view. */
+	vmd_in_guest = offset[0] || offset[1];
 	/*
 	 * Currently MSI remapping must be enabled in guest passthrough mode
 	 * due to some missing interrupt remapping plumbing. This is probably
 	 * acceptable because the guest is usually CPU-limited and MSI
 	 * remapping doesn't become a performance bottleneck.
 	 */
-	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||
-	    offset[0] || offset[1]) {
+	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) || vmd_in_guest) {
 		ret = vmd_alloc_irqs(vmd);
 		if (ret)
 			return ret;
@@ -910,8 +912,10 @@ static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
 		return -ENODEV;
 	}
 
-	vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus),
-				   to_pci_host_bridge(vmd->bus->bridge));
+	/* Don't copy OSC control flags in VM, it disables features.*/
+	if (!vmd_in_guest)
+		vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus),
+					 to_pci_host_bridge(vmd->bus->bridge));
 
 	vmd_attach_resources(vmd);
 	if (vmd->irq_domain)

--
2.43.0

#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 5 lines

Copy valid OSC flags from root bridge only when OS can provide correct values. In virtual machine, all of the control features are disabled as hypervisor will not passthrough root bridge information to VM.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Nirmal Patel
Quoted 3 lines · Nirmal Patel

Copy valid OSC flags from root bridge only when OS can provide correct values. In virtual machine, all of the control features are disabled as hypervisor will not passthrough root bridge information to VM.

...

Quoted 1 line

v2 : Added descriptive boolean and removed period from commit message.

It's still in the $Subject. You probably misinterpreted the comment(s).

...

drivers/pci/controller/vmd.c static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) · line 867

Quoted 2 lines
drivers/pci/controller/vmd.c +2 -0
+	/* Non-zero offset means guest/direct assign view. */
+	vmd_in_guest = offset[0] || offset[1];

+ Blank line?

Quoted 12 lines
drivers/pci/controller/vmd.c +1 -2
 	/*
 	 * Currently MSI remapping must be enabled in guest passthrough mode
 	 * due to some missing interrupt remapping plumbing. This is probably
 	 * acceptable because the guest is usually CPU-limited and MSI
 	 * remapping doesn't become a performance bottleneck.
 	 */
-	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||
-	    offset[0] || offset[1]) {
+	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) || vmd_in_guest) {
 		ret = vmd_alloc_irqs(vmd);
 		if (ret)
 			return ret;

...

drivers/pci/controller/vmd.c static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) · line 915

Quoted 3 lines
drivers/pci/controller/vmd.c +1 -2
-	vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus),
-				   to_pci_host_bridge(vmd->bus->bridge));
+	/* Don't copy OSC control flags in VM, it disables features.*/

Missing space before */.

Quoted 3 lines
drivers/pci/controller/vmd.c +3 -0
+	if (!vmd_in_guest)
+		vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus),
+					 to_pci_host_bridge(vmd->bus->bridge));
Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#3 lore raw
Quoted 6 lines · On Sun, 12 Jul 2026 15:30:01 +0300 Andy Shevchenko…
Quoted 4 lines · Nirmal Patel

Copy valid OSC flags from root bridge only when OS can provide correct values. In virtual machine, all of the control features are disabled as hypervisor will not passthrough root bridge information to VM.

Quoted 7 lines

...

Quoted 2 lines

v2 : Added descriptive boolean and removed period from commit message.

It's still in the $Subject. You probably misinterpreted the comment(s).

My bad, i removed (_). Let me correct. Is (_OSC) in subject okay?

Quoted 7 lines

...

drivers/pci/controller/vmd.c static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) · line 867

Quoted 2 lines
drivers/pci/controller/vmd.c +2 -0
+	/* Non-zero offset means guest/direct assign view. */
+	vmd_in_guest = offset[0] || offset[1];  

+ Blank line?

Ack.

Quoted 19 lines
Quoted 16 lines
(quoted diff) +0 -0
 	/*
 	 * Currently MSI remapping must be enabled in guest

passthrough mode
* due to some missing interrupt remapping plumbing. This
is probably
* acceptable because the guest is usually CPU-limited and
MSI

drivers/pci/controller/vmd.c +1 -2
 	 * remapping doesn't become a performance bottleneck.
 	 */
-	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||
-	    offset[0] || offset[1]) {
+	if (!(features & VMD_FEAT_CAN_BYPASS_MSI_REMAP) ||

vmd_in_guest) { ret = vmd_alloc_irqs(vmd);

drivers/pci/controller/vmd.c +0 -0
 		if (ret)
 			return ret;  

...

Quoted 8 lines
Quoted 6 lines

- vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus), -
to_pci_host_bridge(vmd->bus->bridge));

(quoted diff) +1 -0
+	/* Don't copy OSC control flags in VM, it disables

features.*/

Missing space before */.

Ack.

Quoted 7 lines
Quoted 6 lines
(quoted diff) +2 -0
+	if (!vmd_in_guest)
+

vmd_copy_host_bridge_flags(pci_find_host_bridge(vmd->dev->bus), +
to_pci_host_bridge(vmd->bus->bridge));

#4 lore raw
Quoted 3 lines · Nirmal Patel
Quoted 1 line · On Sun, 12 Jul 2026 15:30:01 +0300 Andy Shevchenko…

On Fri, Jul 10, 2026 at 08:05:58PM +0000, Nirmal Patel wrote:

...

Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

v2 : Added descriptive boolean and removed period from commit message.

It's still in the $Subject. You probably misinterpreted the comment(s).

My bad, i removed (_). Let me correct. Is (_OSC) in subject okay?

I believe so.

Signature · 2 lines
With Best Regards,
Andy Shevchenko