mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
qat: detect noiommu mode with VFIO
If the kernel has CONFIG_VFIO_NOIOMMU enabled and the node admin has explicitly set enable_unsafe_noiommu_mode VFIO parameter, VFIO taints the kernel and writes "vfio-noiommu" to the IOMMU group name. If these conditions are true, the /dev/vfio/ devices are prefixed with "noiommu-". This use-case is documented for DPDK so we don't want to break it (as it was before because we added DeviceMounts to /dev/vfio/<iommugroup> files that did not exist). See DPDK documentation for further information and warnings. Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
This commit is contained in:
parent
08d0bcf503
commit
c306f5ef68
@ -169,6 +169,15 @@ func (dp *DevicePlugin) getDpdkDevice(vfBdf string) (string, error) {
|
|||||||
|
|
||||||
s := filepath.Base(group)
|
s := filepath.Base(group)
|
||||||
|
|
||||||
|
// If the kernel has CONFIG_VFIO_NOIOMMU enabled and the node admin
|
||||||
|
// has explicitly set enable_unsafe_noiommu_mode VFIO parameter,
|
||||||
|
// VFIO taints the kernel and writes "vfio-noiommu" to the IOMMU
|
||||||
|
// group name. If these conditions are true, the /dev/vfio/ devices
|
||||||
|
// are prefixed with "noiommu-".
|
||||||
|
if isVfioNoIOMMU(vfioDirPath) {
|
||||||
|
s = fmt.Sprintf("noiommu-%s", s)
|
||||||
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -176,6 +185,16 @@ func (dp *DevicePlugin) getDpdkDevice(vfBdf string) (string, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isVfioNoIOMMU(iommuGroupPath string) bool {
|
||||||
|
if fileData, err := os.ReadFile(filepath.Join(iommuGroupPath, "name")); err == nil {
|
||||||
|
if strings.TrimSpace(string(fileData)) == "vfio-noiommu" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (dp *DevicePlugin) getDpdkDeviceSpecs(dpdkDeviceName string) []pluginapi.DeviceSpec {
|
func (dp *DevicePlugin) getDpdkDeviceSpecs(dpdkDeviceName string) []pluginapi.DeviceSpec {
|
||||||
switch dp.dpdkDriver {
|
switch dp.dpdkDriver {
|
||||||
case igbUio:
|
case igbUio:
|
||||||
|
@ -348,7 +348,7 @@ func TestScan(t *testing.T) {
|
|||||||
expectedErr: true,
|
expectedErr: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "vfio-pci DPDKdriver with one kernel bound device (QAT device) where vfdevID is equal to qatDevId (37c9), running in a VM",
|
name: "vfio-pci DPDKdriver with one kernel bound device (QAT device) where vfdevID is equal to qatDevId (37c9), running in a VM with vIOMMU",
|
||||||
dpdkDriver: "vfio-pci",
|
dpdkDriver: "vfio-pci",
|
||||||
kernelVfDrivers: []string{"c6xxvf"},
|
kernelVfDrivers: []string{"c6xxvf"},
|
||||||
dirs: []string{
|
dirs: []string{
|
||||||
@ -366,6 +366,27 @@ func TestScan(t *testing.T) {
|
|||||||
maxDevNum: 1,
|
maxDevNum: 1,
|
||||||
expectedDevNum: 1,
|
expectedDevNum: 1,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "vfio-pci DPDKdriver in unsafe NOIOMMU mode with one kernel bound device (QAT device) where vfdevID is equal to qatDevId (37c9), running in a VM without IOMMU",
|
||||||
|
dpdkDriver: "vfio-pci",
|
||||||
|
kernelVfDrivers: []string{"c6xxvf"},
|
||||||
|
dirs: []string{
|
||||||
|
"sys/bus/pci/drivers/c6xxvf",
|
||||||
|
"sys/bus/pci/drivers/vfio-pci",
|
||||||
|
"sys/bus/pci/devices/0000:02:01.0",
|
||||||
|
"sys/kernel/iommu_groups/vfiotestfile",
|
||||||
|
},
|
||||||
|
files: map[string][]byte{
|
||||||
|
"sys/bus/pci/devices/0000:02:01.0/device": []byte("0x37c9"),
|
||||||
|
"sys/kernel/iommu_groups/vfiotestfile/name": []byte("vfio-noiommu"),
|
||||||
|
},
|
||||||
|
symlinks: map[string]string{
|
||||||
|
"sys/bus/pci/devices/0000:02:01.0/iommu_group": "sys/kernel/iommu_groups/vfiotestfile",
|
||||||
|
"sys/bus/pci/devices/0000:02:01.0/driver": "sys/bus/pci/drivers/c6xxvf",
|
||||||
|
},
|
||||||
|
maxDevNum: 1,
|
||||||
|
expectedDevNum: 1,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tcases {
|
for _, tt := range tcases {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user