From d7a3ec8305f0cc5ba6b008a731e70b6edc34062c Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Thu, 7 Dec 2023 11:25:24 -0800 Subject: [PATCH] Allow vfio releted subdirectories to be mirrored by gVisor. It expects to mirror sysfs device subdirectories like `vfio-dev` and `vfio#` PiperOrigin-RevId: 588855389 --- pkg/sentry/fsimpl/sys/pci.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/sentry/fsimpl/sys/pci.go b/pkg/sentry/fsimpl/sys/pci.go index a8739a778..3caaf9b49 100644 --- a/pkg/sentry/fsimpl/sys/pci.go +++ b/pkg/sentry/fsimpl/sys/pci.go @@ -37,9 +37,9 @@ const ( var ( // Matches PCI device addresses in the main domain. pciDeviceRegex = regex.MustCompile(`0000:([a-fA-F0-9]{2}|[a-fA-F0-9]{4}):[a-fA-F0-9]{2}\.[a-fA-F0-9]{1,2}`) - // Matches the directories for the main bus (i.e. pci000:00), accel, and - // individual devices (e.g. 00:00:04.0) - sysDevicesDirRegex = regex.MustCompile(`pci0000:00|accel|(0000:([a-fA-F0-9]{2}|[a-fA-F0-9]{4}):[a-fA-F0-9]{2}\.[a-fA-F0-9]{1,2})`) + // Matches the directories for the main bus (i.e. pci000:00), + // individual devices (e.g. 00:00:04.0), accel (TPU v4), and vfio (TPU v5) + sysDevicesDirRegex = regex.MustCompile(`pci0000:00|accel|vfio|(0000:([a-fA-F0-9]{2}|[a-fA-F0-9]{4}):[a-fA-F0-9]{2}\.[a-fA-F0-9]{1,2})`) // Files allowlisted for host passthrough. These files are read-only. sysDevicesFiles = map[string]any{ "vendor": nil, "device": nil, "subsystem_vendor": nil, "subsystem_device": nil,