Files
Jamie LiuandgVisor bot 134f74b24b Add support for nvidia-imex.
- Add /proc/devices.

- Provide /proc/driver/nvidia/params when nvproxy is enabled. CUDA-using
  applications already try to open this file, but silently tolerate its
  non-existence. However, both the IMEX daemon and IMEX-using applications are
  believed to require this file for ImexChannelCount. (libnvidia-container
  additionally provides /proc/driver/nvidia/{registry,version}, but we have yet
  to see any application use these.)

- Add new capability nvconf.CapFabricIMEXManagement. When enabled, provide
  /proc/driver/nvidia/capabilities/fabric-imex-mgmt and the corresponding
  /dev/nvidia-caps/nvidia-cap#.

- Add support for /dev/nvidia-caps-imex-channels/ (irrespective of the new
  capability, since IMEX-using applications need this directory as well).

- Allow devutil.GoferClient.OpenAt() to take a relative path (i.e. containing
  more than one path component) rather than only a basename, since this is
  needed to open /dev/nvidia-caps/*.

- Add nvproxy support for all known-required controls, and all allocation
  classes to which those controls correspond.

This CL is specifically for nvidia-imex, the "NVIDIA IMEX Service for NVLink
Networks" (or "IMEX daemon"); applications using IMEX haven't been tested yet,
and may require additional allocation classes / control commands, or some
existing ones marked as requiring CapFabricIMEXManagement as being enabled more
broadly.

PiperOrigin-RevId: 859286209
2026-01-21 15:25:28 -08:00

62 lines
2.3 KiB
Go

// Copyright 2026 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package nvproxy
import (
"fmt"
"gvisor.dev/gvisor/pkg/sentry/vfs"
)
// ProcfsInfo contains information about procfs files maintained by nvproxy.
type ProcfsInfo struct {
// StaticFiles maps paths relative to /proc/driver/nvidia/ to the contents of
// files at those paths.
StaticFiles map[string]string
}
// ProcfsInfoFromVFS returns procfs information for nvproxy devices registered
// in vfsObj. If ProcfsInfoFromVFS returns nil, nvproxy.Register(vfsObj) has
// not been called.
func ProcfsInfoFromVFS(vfsObj *vfs.VirtualFilesystem) *ProcfsInfo {
nvp := nvproxyFromVFS(vfsObj)
if nvp == nil {
return nil
}
procfsInfo := &ProcfsInfo{
StaticFiles: map[string]string{
"params": nvp.procDriverNvidiaParams,
},
}
if nvp.devInfo.HaveFabricIMEXManagement {
procfsInfo.StaticFiles["capabilities/fabric-imex-mgmt"] = procfsCapability(nvp.devInfo.FabricIMEXManagementDevMinor, 0o400)
}
return procfsInfo
}
// procfsCapability returns the contents of a file in
// /proc/driver/nvidia/capabilities/ representing the capability with the given
// device minor number in /dev/nvidia-caps/. mode is the mode passed to
// kernel-open/nvidia/os-interface.c:os_nv_cap_create_file_entry() =>
// kernel-open/nvidia/nv-caps.c:nv_cap_create_file_entry() and stored in
// nv_cap_t::permissions, which does not include file type and is not updated
// by file mode changes in /dev/nvidia-caps/.
func procfsCapability(devMinor, mode uint32) string {
// Force DeviceFileModify to 0 regardless of the host value. This is
// consistent with our treatment of ModifyDeviceFiles in
// /proc/driver/nvidia/params.
return fmt.Sprintf("DeviceFileMinor: %d\nDeviceFileMode: %d\nDeviceFileModify: 0\n", devMinor, mode)
}