vfio/pci: make nointxmask and disable_idle_d3 module params read-only
Subsystems (2)
PATCH 1/1 vfio/pci: make nointxmask and disable_idle_d3 module params read-only
The nointxmask and disable_idle_d3 module parameters are registered with S_IWUSR, exposing a writable node under /sys/module/vfio_pci/parameters/. However, writing to them at runtime has no effect on driver behaviour:
- Both values are copied into vfio-pci-core's own static variables via vfio_pci_core_set_params(), which is only called once at module init time. A later write to the vfio_pci front-end variable is never propagated to the core.
- disable_idle_d3 additionally gates paired runtime PM get/put calls across the probe/remove (register/unregister) and open/close (enable/disable) life cycles. Changing it at runtime would tear these pairs apart and leak or underflow the runtime PM usage counter.
- nointxmask is latched into per-device state (vdev->nointx / vdev->pci_2_3) at device open time, so a later change can only affect newly opened devices and yields inconsistent behaviour.
These parameters are effectively load-time constants. Drop the write permission so they match disable_vga, which is already read-only, and to stop misleading users into thinking they are runtime tunable.
--- drivers/vfio/pci/vfio_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/vfio/pci/vfio_pci.c +2 -2
@@ -35,7 +35,7 @@ module_param_string(ids, ids, sizeof(ids), 0);MODULE_PARM_DESC (ids,"Initial PCI IDs to add to the vfio driver, format is \"vendor:device[:subvendor[:subdevice[:class[:class_mask]]]]\" and multiple comma separated entries can be specified" );static bool nointxmask; -module_param_named (nointxmask, nointxmask, bool,S_IRUGO |S_IWUSR ); +module_param_named (nointxmask, nointxmask, bool,0444 );MODULE_PARM_DESC (nointxmask,"Disable support for PCI 2.3 style INTx masking. If this resolves problems for specific devices, report lspci -vvvxxx to [email protected] so the device can be fixed automatically via the broken_intx_masking flag." );
@@ -46,7 +46,7 @@ MODULE_PARM_DESC(disable_vga, "Disable VGA resource access through vfio-pci");#endif static bool disable_idle_d3; -module_param (disable_idle_d3, bool,S_IRUGO |S_IWUSR ); +module_param (disable_idle_d3, bool,0444 );MODULE_PARM_DESC (disable_idle_d3,"Disable using the PCI D3 low power state for idle, unused devices" );
Signature · 1 line
2.43.7
Alex Williamson
maintainerQuoted 18 lines · On Wed, 10 Jun 2026 13:47:34 +0800 Guixin Liu <[email protected]> wrote:
The nointxmask and
disable_idle_d3module parameters are registered withS_IWUSR, exposing a writable node under/sys/module/vfio_pci/parameters/. However, writing to them at runtime has no effect on driver behaviour:- Both values are copied into vfio-pci-core's own static variables via
vfio_pci_core_set_params(), which is only called once at module init time. A later write to thevfio_pcifront-end variable is never propagated to the core.-
disable_idle_d3additionally gates paired runtime PM get/put calls across the probe/remove (register/unregister) and open/close (enable/disable) life cycles. Changing it at runtime would tear these pairs apart and leak or underflow the runtime PM usage counter.- nointxmask is latched into per-device state (
vdev->nointx/vdev->pci_2_3) at device open time, so a later change can only affect newly opened devices and yields inconsistent behaviour.
Quoted 8 lines
These parameters are effectively load-time constants. Drop the write permission so they match
disable_vga, which is already read-only, and to stop misleading users into thinking they are runtime tunable.Signed-off-by Guixin Liu <[email protected]>--- drivers/vfio/pci/vfio_pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks for the patch, I think this actually highlights a broader problem. Making disable_idle_d3 a read-only module parameter in vfio-pci doesn't change that vfio-pci can be unload and reloaded with different parameter values, therefore the gap is not closed. We need to use per device setting, latched at device probe, which actually also returns some value to these parameters being runtime modified. This feature was inadvertently lost in the vfio-pci-core split.
I've copied you on the broader fix:
https://lore.kernel.org/kvm/[email protected]/T/#t
Thanks,
Alex