137 Commits
Author SHA1 Message Date
Ayush RanjanandgVisor bot 738e1d995f nvproxy: Add HasStatus.SetStatus and provide failWithStatus() util functions.
This creates a more centralized way for nvproxy to return errors to the the
user mode driver via the NvStatus field in ioctl structs. As opposed to failing
the ioctl with mysterious EINVALs.

Also updated the following structs to NOT implement HasStatus interface:
- IoctlRegisterFD
- RMAPIVersion
- IoctlSysParams

These don't have a Status field so it is misleading for them to implement
HasStatus. Created frontendIoctlSimpleNoStatus() and
frontendIoctlInvokeNoStatus() for such structs to use.

PiperOrigin-RevId: 738959856
2025-03-20 15:29:44 -07:00
Ayush RanjanandgVisor bot 97820ce5c9 nvproxy: Add support for 570.124.06.
The following command does not report any changes in the structs we proxy:
```
make run TARGETS=//tools/nvidia_driver_differ:run_differ \
  ARGS="--base 570.86.15 --next 570.124.06"
```

PiperOrigin-RevId: 738093448
2025-03-18 12:06:36 -07:00
Jamie LiuandgVisor bot b01944883b Add memmap.File.MemoryType()
This has no effect (outside of debug logging) until cl/723723715.

Updates #11436

PiperOrigin-RevId: 736686635
2025-03-13 17:08:52 -07:00
Ayush RanjanandgVisor bot 906fb319cc nvproxy: Add option to use the device gofer optionally.
We always use the device gofer in runsc, because the sandbox's filesystem
does not have the GPU devices mounted in it.

PiperOrigin-RevId: 736316547
2025-03-12 17:08:54 -07:00
Jamie LiuandgVisor bot 8153170320 nvproxy: reduce kernel mmap_lock contention from rmAllocOSDescriptor()
PiperOrigin-RevId: 734667529
2025-03-07 13:23:48 -08:00
Ayush RanjanandgVisor bot 138e98fb7d nvproxy: Refactor DriverVersion out to nvconf package.
This allows for runsc to be able to use DriverVersion without having to depend
on the entirety of nvproxy.

PiperOrigin-RevId: 733912696
2025-03-05 16:43:03 -08:00
Ayush RanjanandgVisor bot 6b4f0082c2 nvproxy: Add support for AMPERE_A, ADA_A, HOPPER_A.
TURING_A was added in e6e1ecbdcc ("Add support for graphics in nvproxy.").
{GPU_ARCH}_A class is used for graphics workloads. Add the missing classes for
other GPU architectures we support.

PiperOrigin-RevId: 726620575
2025-02-13 13:45:12 -08:00
Ayush RanjanandgVisor bot 5457cf6def Consistently use "handler is undefined" for missing handlers.
nvproxy additionally branches at the following points which are not covered by
the ABI struct:
1. Frontend ioctl NV_ESC_RM_ALLOC_MEMORY on
   nv_ioctl_nvos02_parameters_with_fd::params::hClass.
2. Frontend ioctl NV_ESC_RM_VID_HEAP_CONTROL on NVOS32_PARAMETERS::function.

In case nvproxy doesn't implement one of the values, it should print a warning
with the same prefix of "handler is undefined" which is used for other branch
points. This will make it easier to grep for missing nvproxy functionality.

Also update documentation for nvproxy debugging. Earlier, nvproxy logged
"nvproxy: unknown ..." for such situations. That changed with 6953ca0ca3
("Add NVIDIA driver capability segmentation support to nvproxy."), which moved
to using "nvproxy: handler is undefined ...".

PiperOrigin-RevId: 726565029
2025-02-13 11:22:19 -08:00
1a9abee80b nvproxy: Add support for 570.86.15 driver.
Co-authored-by: Zach Koopmans <zkoopmans@google.com>
PiperOrigin-RevId: 721910920
2025-01-31 14:53:49 -08:00
Ayush RanjanandgVisor bot 544cbea1b4 nvproxy: Fix checksum of 535.230.02.
Also run the validate_checksum command on presubmit to avoid such issues.

Fixes 888f66d0a1 ("nvproxy: Add support for 535.230.02 driver.")

PiperOrigin-RevId: 720687756
2025-01-28 13:27:50 -08:00
Ayush RanjanandgVisor bot 888f66d0a1 nvproxy: Add support for 535.230.02 driver.
PiperOrigin-RevId: 720646566
2025-01-28 11:25:18 -08:00
Ayush RanjanandgVisor bot 0b5ee6d4df nvproxy: Add support for v565.57.01.
PiperOrigin-RevId: 720557549
2025-01-28 06:54:35 -08:00
2022tgoel 7399a32b4c Add GPU video codecs support to nvproxy (so that tools like ffmpeg work)
adding cap

tests work

fix merge

unit test

small fixes

additional ioctls for L4 gpu
2025-01-09 01:09:47 +00:00
Ayush RanjanandgVisor bot b11efeaecd nvproxy: Clean up struct field tags.
Before this change, there were 2 places in which the driver struct names were
defined for nvproxy structs:
1. As struct field tags. The first field of structs had a tag `nvproxy:*`. This
   was kind of awkward. Such metadata is usually a struct comment.
2. In version.go while registering the struct with a name. Not all structs are
   defined in nvproxy (for example simple structs). In such cases, the driver
   struct name is directly assigned while registering struct info.

This change gets rid of (1). Most of the struct tags were `nvproxy:"same"`. Now
driverStructs() always infers the driver struct name using the nvproxy struct
name itself. The few cases where the nvproxy tag was needed, because driver
struct name was lower cased, were handled by defining driverStructWithName()
which allows specifying a different name. Now all driver struct names
definitions are in one place.

Along the way, also made the following fixes:
- For some reason, many structs defined in pkg/abi/nvgpu/frontend.go had
  camel-cased naming, while all other structs in pkg/abi/nvgpu/ctrl.go and
  pkg/abi/nvgpu/classes.go were named the same as their driver structs. The
  convention in the abi/* packages is to follow the kernel source naming.
  This is against Go sytle guide, but is more readable for gVisor purposes and
  has been a long accepted convention. This also makes the task of removing (1)
  easier. So renamed all such structs as per their driver names.
- A lot of code in pkg/sentry/devices/nvproxy/version.go was still referring to
  driver struct info as "struct names", even though it was representing more
  than just struct names. It also contains the reflect.Type of the struct which
  is used to compare the nvproxy struct layout to the driver struct layout.

PiperOrigin-RevId: 710648105
2024-12-30 01:32:41 -08:00
Ayush RanjanandgVisor bot edda7b656d Update handler for NV_ESC_RM_UNMAP_MEMORY_DMA for 550.40.07+.
Fixes e6e1ecbdcc ("Add support for graphics in nvproxy.")

PiperOrigin-RevId: 710102132
2024-12-27 11:29:38 -08:00
Ayush RanjanandgVisor bot e6e1ecbdcc Add support for graphics in nvproxy.
PiperOrigin-RevId: 708100465
2024-12-19 17:41:18 -08:00
Ayush RanjanandgVisor bot 1ca2bd4a69 nvproxy: Improve debuggability by logging failures coming from the host driver.
Most ioctl contain a `Status` field (which in driver code is of type NvStatus)
which indicates if the ioctl command succeeded or not. Non NV_OK=0 values
indicate some kind of failure. In case of failure, the ioctl(2) syscall still
succeeds. So the failure is currently not visible in gVisor strace/debug logs.

This helps flag instances where the host invocation of ioctl(2) resulted in a
failure in the driver.

This also helps avoid the usage of frontendIoctlSimple() in some cases.
frontendIoctlSimple() heap allocates a byte buffer. It is better to copy into
the ioctl params on the stack when possible.

PiperOrigin-RevId: 707312482
2024-12-17 17:26:22 -08:00
Ayush RanjanandgVisor bot d1b164b8e5 nvproxy: Add back 550.54.15.
PiperOrigin-RevId: 704822825
2024-12-10 13:21:43 -08:00
Jamie LiuandgVisor bot 01e30ab09b nvproxy: don't depend on HVASpace for non-virtmem NVOS32_FUNCTION_ALLOC_SIZE
PiperOrigin-RevId: 704780681
2024-12-10 11:26:47 -08:00
Jamie LiuandgVisor bot a55b3b2d90 nvproxy: track objects created by NV_ESC_RM_DUP_OBJECT
PiperOrigin-RevId: 704502046
2024-12-09 18:59:36 -08:00
Ayush RanjanandgVisor bot dc24ae5c71 Add support for 550.127.05 in nvproxy.
Fixes #11111

PiperOrigin-RevId: 703584156
2024-12-06 12:44:18 -08:00
Etienne PerotandgVisor bot 1af6da4bdc Propagate NVIDIA driver capabilities to nvproxy and seccomp filters.
Updates #10856

PiperOrigin-RevId: 700440037
2024-11-26 13:21:46 -08:00
Etienne PerotandgVisor bot 004ed53163 nvproxy: Do capability-based segmentation for seccomp filters.
Updates #10856

PiperOrigin-RevId: 698599198
2024-11-20 18:54:57 -08:00
Etienne PerotandgVisor bot 6953ca0ca3 Add NVIDIA driver capability segmentation support to nvproxy.
This wraps `nvproxy`'s `ioctl` handlers with wrappers that are
driver-capability-aware, and initially populates the ABI tree
with all functions marked as being available for capabilities
`compute` and `utility`.

It is not yet possible for the user to specify which capability
they want to enable. This should not cause a regression for users
because the hardcoded effective capability set is the one that is
currently specified for all current handlers.

Updates #9452.
Updates #10856.

PiperOrigin-RevId: 697824737
2024-11-18 18:15:21 -08:00
Zach KoopmansandgVisor bot f37f2c37c8 Deprecate drivers
Our latest COS images in GKE have 535.183.01 and 550.90.07
as the available drivers. Deprecate older drivers.

PiperOrigin-RevId: 694654209
2024-11-08 15:06:22 -08:00