Re: [PATCH v3] PCI: vmd: Only assign OSC features in bare metal OS

Manivannan Sadhasivam <[email protected]>
Newsgroups org.kernel.vger.linux-pci
Message-ID <jm5tao5tdbfo4o6ivrhiwfl33xrislemr7ejnnbsmjsbq7pxaw@2xjdbaflro2c>
On Mon, Jul 13, 2026 at 10:08:44PM +0000, Nirmal Patel wrote:
> 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.
> 

I changed the subject and description as below while applying:

PCI: vmd: Only copy root bridge _OSC control flags in bare metal OS

Only in a bare metal OS environment, the _OSC control flags like Hotplug,
PME, AER, etc... reflect the physical root bridge capabilities. But in a VM
environment, these flags reflect the hypervisor policy and in most cases,
the hypervisor disables all of these control flags to the Guest.

So copying these flags would needlessly disable these features in the VMD
owned Root Ports. Hence, copy the flags only when VMD is running in a bare
metal OS environment.

> Signed-off-by: Nirmal Patel <[email protected]>
> Reviewed-by:  Andy Shevchenko <[email protected]>
> ---
> v3 : Removed period from commit and added a black line.
> v2 : Added descriptive boolean and removed period from commit message.
> ---
> ---
>  drivers/pci/controller/vmd.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/vmd.c b/drivers/pci/controller/vmd.c
> index d4ae250d4bc6..7c7d110290d6 100644
> --- a/drivers/pci/controller/vmd.c
> +++ b/drivers/pci/controller/vmd.c
> @@ -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,16 @@ 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 +913,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. */

Also reworded this comment:

         /*
         * Don't copy _OSC control flags from root bridge if running in a VM, as
         * they don't reflect the physical root bridge capabilities.
         */

- Mani

-- 
மணிவண்ணன் சதாசிவம்
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.