Skip to content

Adds device, ioctls, and new CapProfiling capability#12945

Open
luiscape wants to merge 1 commit intogoogle:masterfrom
luiscape:add-profiling-support
Open

Adds device, ioctls, and new CapProfiling capability#12945
luiscape wants to merge 1 commit intogoogle:masterfrom
luiscape:add-profiling-support

Conversation

@luiscape
Copy link
Copy Markdown
Contributor

@luiscape luiscape commented Apr 14, 2026

This makes changes to support Nsight, a suite of NVIDIA tools to profile GPU workloads, including:

  • adds missing classes and ioctls
  • adds new "unsafe" function ctrlGpuExecRegOps
  • adds new capability, CapProfiling

In order to mitigate side-channel attacks when exposing the same GPU to two different containers (see "Rendered Insecure: GPU Side Channel Attacks Adds nsight ioctls are Practical" [1]), I am adding a new capability: CapProfiling. This follows the implementation from CapFabricIMEXManagement and needs to explicitly added with --nvproxy-allowed-driver-capabilities=all,profiling.

This also adds the "unsafe" function ctrlGpuExecRegOps. This is the case because NV2080_CTRL_GPU_EXEC_REG_OPS_PARAMS contains an NvP64 pointer (RegOps) to an array of register operations in the application's address space. ctrlGpuExecRegOps copies this array into sentry memory and rewrites the pointer before forwarding to the host, then copies results back. This behavior follows existing nvproxy pattern for ioctls with embedded pointers (e.g. ctrlGetNvU32List).

(The parity test also explicitly checks that structs with NvP64 fields are not registered as simple ioctls. Hence the custom handler that copies the regOps array through sentry memory seems the correct approach.)

[1] https://www.cs.ucr.edu/~zhiyunq/pub/ccs18_gpu_side_channel.pdf

@luiscape
Copy link
Copy Markdown
Contributor Author

@ayushr2 took a bit of liberty here adding CapProfiling. Let me know if this is the right way to think about this.

@luiscape luiscape changed the title Adds devide, ioctl, and new CapProfiling capability Adds device, ioctls, and new CapProfiling capability Apr 14, 2026
@luiscape luiscape force-pushed the add-profiling-support branch from 125f5b2 to 321eddc Compare April 15, 2026 16:02
Comment thread pkg/sentry/devices/nvproxy/nvproxy.go Outdated
Comment thread pkg/sentry/devices/nvproxy/nvconf/caps.go Outdated
@luiscape luiscape force-pushed the add-profiling-support branch from 321eddc to 1083a59 Compare April 23, 2026 23:40
@luiscape
Copy link
Copy Markdown
Contributor Author

@ayushr2 thank you for your review. I removed /dev/nvidia-uvm-tools (not strictly required). Let me know what you think.

Copy link
Copy Markdown
Collaborator

@ayushr2 ayushr2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly LGTM!

Comment thread pkg/abi/nvgpu/nvgpu.go Outdated
Comment thread pkg/abi/nvgpu/classes.go Outdated
Comment thread pkg/sentry/devices/nvproxy/version.go Outdated
Comment thread pkg/sentry/devices/nvproxy/frontend_unsafe.go Outdated
Comment thread pkg/sentry/devices/nvproxy/version.go Outdated
This adds ioctls and classes to support Nsight, a suite of NVIDIA tools to profile
GPU workloads.

In order to mitigate side-channel attacks when exposing the same GPU to
two different containers (see Rendered Insecure: GPU Side Channel Attacks
Adds nsight ioctls are Practical [1]), I am adding a new capability
`CapProfiling`. This follows the implementation from
`CapFabricIMEXManagement` and needs to explicitly added with
`--nvproxy-allowed-driver-capabilities=all,profiling`.

[1] https://www.cs.ucr.edu/~zhiyunq/pub/ccs18_gpu_side_channel.pdf
@luiscape luiscape force-pushed the add-profiling-support branch from 1083a59 to ac83604 Compare April 24, 2026 20:12
@luiscape
Copy link
Copy Markdown
Contributor Author

@ayushr2 thank you so much. I applied all changes.

copybara-service Bot pushed a commit that referenced this pull request Apr 24, 2026
This makes changes to support [Nsight](https://developer.nvidia.com/tools-overview), a suite of NVIDIA tools to profile GPU workloads, including:

- adds missing classes and ioctls
- adds new "unsafe" function `ctrlGpuExecRegOps`
- adds new capability, `CapProfiling`

In order to mitigate side-channel attacks when exposing the same GPU to two different containers (see "Rendered Insecure: GPU Side Channel Attacks Adds nsight ioctls are Practical" [1]), I am adding a new capability: `CapProfiling`. This follows the implementation from `CapFabricIMEXManagement` and needs to explicitly added with `--nvproxy-allowed-driver-capabilities=all,profiling`.

This also adds the "unsafe" function `ctrlGpuExecRegOps`. This is the case because `NV2080_CTRL_GPU_EXEC_REG_OPS_PARAMS` contains an `NvP64` pointer (`RegOps`) to an array of register operations in the application's address space. `ctrlGpuExecRegOps` copies this array into sentry memory and rewrites the pointer before forwarding to the host, then copies results back. This behavior follows existing nvproxy pattern for ioctls with embedded pointers (e.g. `ctrlGetNvU32List`).

(The parity test also explicitly checks that structs with `NvP64` fields are not registered as simple ioctls. Hence the custom handler that copies the `regOps` array through sentry memory seems the correct approach.)

[1] https://www.cs.ucr.edu/~zhiyunq/pub/ccs18_gpu_side_channel.pdf

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12945 from luiscape:add-profiling-support ac83604
PiperOrigin-RevId: 905190979
copybara-service Bot pushed a commit that referenced this pull request Apr 24, 2026
This makes changes to support [Nsight](https://developer.nvidia.com/tools-overview), a suite of NVIDIA tools to profile GPU workloads, including:

- adds missing classes and ioctls
- adds new "unsafe" function `ctrlGpuExecRegOps`
- adds new capability, `CapProfiling`

In order to mitigate side-channel attacks when exposing the same GPU to two different containers (see "Rendered Insecure: GPU Side Channel Attacks Adds nsight ioctls are Practical" [1]), I am adding a new capability: `CapProfiling`. This follows the implementation from `CapFabricIMEXManagement` and needs to explicitly added with `--nvproxy-allowed-driver-capabilities=all,profiling`.

This also adds the "unsafe" function `ctrlGpuExecRegOps`. This is the case because `NV2080_CTRL_GPU_EXEC_REG_OPS_PARAMS` contains an `NvP64` pointer (`RegOps`) to an array of register operations in the application's address space. `ctrlGpuExecRegOps` copies this array into sentry memory and rewrites the pointer before forwarding to the host, then copies results back. This behavior follows existing nvproxy pattern for ioctls with embedded pointers (e.g. `ctrlGetNvU32List`).

(The parity test also explicitly checks that structs with `NvP64` fields are not registered as simple ioctls. Hence the custom handler that copies the `regOps` array through sentry memory seems the correct approach.)

[1] https://www.cs.ucr.edu/~zhiyunq/pub/ccs18_gpu_side_channel.pdf

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12945 from luiscape:add-profiling-support ac83604
PiperOrigin-RevId: 905190979
copybara-service Bot pushed a commit that referenced this pull request Apr 24, 2026
This makes changes to support [Nsight](https://developer.nvidia.com/tools-overview), a suite of NVIDIA tools to profile GPU workloads, including:

- adds missing classes and ioctls
- adds new "unsafe" function `ctrlGpuExecRegOps`
- adds new capability, `CapProfiling`

In order to mitigate side-channel attacks when exposing the same GPU to two different containers (see "Rendered Insecure: GPU Side Channel Attacks Adds nsight ioctls are Practical" [1]), I am adding a new capability: `CapProfiling`. This follows the implementation from `CapFabricIMEXManagement` and needs to explicitly added with `--nvproxy-allowed-driver-capabilities=all,profiling`.

This also adds the "unsafe" function `ctrlGpuExecRegOps`. This is the case because `NV2080_CTRL_GPU_EXEC_REG_OPS_PARAMS` contains an `NvP64` pointer (`RegOps`) to an array of register operations in the application's address space. `ctrlGpuExecRegOps` copies this array into sentry memory and rewrites the pointer before forwarding to the host, then copies results back. This behavior follows existing nvproxy pattern for ioctls with embedded pointers (e.g. `ctrlGetNvU32List`).

(The parity test also explicitly checks that structs with `NvP64` fields are not registered as simple ioctls. Hence the custom handler that copies the `regOps` array through sentry memory seems the correct approach.)

[1] https://www.cs.ucr.edu/~zhiyunq/pub/ccs18_gpu_side_channel.pdf

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12945 from luiscape:add-profiling-support ac83604
PiperOrigin-RevId: 905190979
nvgpu.NVB0CC_CTRL_CMD_UNBIND_PM_RESOURCES: simpleIoctlInfo("NVB0CC_CTRL_CMD_UNBIND_PM_RESOURCES"),
nvgpu.NVB0CC_CTRL_CMD_PMA_STREAM_UPDATE_GET_PUT: simpleIoctlInfo("NVB0CC_CTRL_CMD_PMA_STREAM_UPDATE_GET_PUT", "NVB0CC_CTRL_PMA_STREAM_UPDATE_GET_PUT_PARAMS"),
nvgpu.NVB0CC_CTRL_CMD_EXEC_REG_OPS: simpleIoctlInfo("NVB0CC_CTRL_CMD_EXEC_REG_OPS", "NVB0CC_CTRL_EXEC_REG_OPS_PARAMS"),
nvgpu.NVB0CC_CTRL_CMD_RESERVE_PM_AREA_PC_SAMPLER: simpleIoctlInfo("NVB0CC_CTRL_CMD_RESERVE_PM_AREA_PC_SAMPLER", "NVB0CC_CTRL_RESERVE_PM_AREA_PC_SAMPLER_PARAMS"),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submit is failing (https://buildkite.com/gvisor/pipeline/builds/41744) because NVB0CC_CTRL_RESERVE_PM_AREA_PC_SAMPLER_PARAMS does not exist in the driver. I think this control command does not have any params: https://github.com/NVIDIA/open-gpu-kernel-modules/blob/db0c4e65c8e34c678d745ddb1317f53f90d1072b/src/nvidia/generated/g_profiler_v2_nvoc.c#L290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants