diff --git a/pkg/abi/nvgpu/classes.go b/pkg/abi/nvgpu/classes.go index 8325f1b770..af9143f749 100644 --- a/pkg/abi/nvgpu/classes.go +++ b/pkg/abi/nvgpu/classes.go @@ -420,6 +420,9 @@ type NV_MEMORY_DESC_PARAMS struct { // NV_BSP_ALLOCATION_PARAMETERS is the alloc params type for // NV*VIDEO_DECODER, from src/common/sdk/nvidia/inc/nvos.h. // +// It is also used to represent the following driver structs: +// - NV_NVDEC_ALLOCATION_PARAMETERS +// // +marshal type NV_BSP_ALLOCATION_PARAMETERS struct { _ structs.HostLayout @@ -431,6 +434,9 @@ type NV_BSP_ALLOCATION_PARAMETERS struct { // NV_MSENC_ALLOCATION_PARAMETERS is the alloc params type for // NV*_VIDEO_ENCODER, from src/common/sdk/nvidia/inc/nvos.h. // +// It is also used to represent the following driver structs: +// - NV_NVENC_ALLOCATION_PARAMETERS +// // +marshal type NV_MSENC_ALLOCATION_PARAMETERS struct { _ structs.HostLayout @@ -485,6 +491,44 @@ type NV_CHANNEL_ALLOC_PARAMS_V570 struct { _ uint32 } +// NV_CHANNEL_ALLOC_PARAMS_V610 is the updated version of +// NV_CHANNEL_ALLOC_PARAMS since 610.43.02. +// +// +marshal +type NV_CHANNEL_ALLOC_PARAMS_V610 struct { + _ structs.HostLayout + HObjectError Handle + HObjectBuffer Handle + GPFIFOOffset uint64 + GPFIFOEntries uint32 + Flags uint32 + HContextShare Handle + HVASpace Handle + HHandleVASpace Handle + HUserdMemory [NV_MAX_SUBDEVICES]Handle + _ uint32 + UserdOffset [NV_MAX_SUBDEVICES]uint64 + EngineType uint32 + CID uint32 + SubDeviceID uint32 + HObjectECCError Handle + InstanceMem NV_MEMORY_DESC_PARAMS + UserdMem NV_MEMORY_DESC_PARAMS + RamfcMem NV_MEMORY_DESC_PARAMS + MthdbufMem NV_MEMORY_DESC_PARAMS + HPhysChannelGroup Handle + InternalFlags uint32 + ErrorNotifierMem NV_MEMORY_DESC_PARAMS + ECCErrorNotifierMem NV_MEMORY_DESC_PARAMS + ProcessID uint32 + SubProcessID uint32 + EncryptIv [CC_CHAN_ALLOC_IV_SIZE_DWORD]uint32 + DecryptIv [CC_CHAN_ALLOC_IV_SIZE_DWORD]uint32 + HmacNonce [CC_CHAN_ALLOC_NONCE_SIZE_DWORD]uint32 + TPCConfigID uint32 + _ uint32 +} + // NVB0B5_ALLOCATION_PARAMETERS is the alloc param type for TURING_DMA_COPY_A, // AMPERE_DMA_COPY_A, and AMPERE_DMA_COPY_B from // src/common/sdk/nvidia/inc/class/clb0b5sw.h. diff --git a/pkg/abi/nvgpu/ctrl.go b/pkg/abi/nvgpu/ctrl.go index 140f41392c..aa9a4b8de2 100644 --- a/pkg/abi/nvgpu/ctrl.go +++ b/pkg/abi/nvgpu/ctrl.go @@ -392,6 +392,7 @@ const ( // - NV0080_CTRL_GR_GET_CAPS_PARAMS // - NV0080_CTRL_FIFO_GET_CAPS_PARAMS // - NV0080_CTRL_MSENC_GET_CAPS_PARAMS +// - NV0080_CTRL_NVENC_GET_CAPS_PARAMS // // +marshal type NV0080_CTRL_GET_CAPS_PARAMS struct { diff --git a/pkg/sentry/devices/nvproxy/frontend.go b/pkg/sentry/devices/nvproxy/frontend.go index b9704a2d0b..3775000afc 100644 --- a/pkg/sentry/devices/nvproxy/frontend.go +++ b/pkg/sentry/devices/nvproxy/frontend.go @@ -1329,6 +1329,13 @@ func rmAllocChannelV570(fi *frontendIoctlState, ioctlParams *nvgpu.NVOS64_PARAME }) } +// rmAllocChannelV610 is the same as rmAllocChannel, but for 610.43.02. +func rmAllocChannelV610(fi *frontendIoctlState, ioctlParams *nvgpu.NVOS64_PARAMETERS, isNVOS64 bool) (uintptr, error) { + return rmAllocSimpleParams(fi, ioctlParams, isNVOS64, func(fi *frontendIoctlState, client *rootClient, ioctlParams *nvgpu.NVOS64_PARAMETERS, rightsRequested nvgpu.RS_ACCESS_MASK, allocParams *nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610) { + fi.fd.dev.nvp.objAdd(fi.ctx, client, ioctlParams.HObjectNew, ioctlParams.HClass, newRmAllocObject(fi.fd, ioctlParams, rightsRequested, allocParams), ioctlParams.HObjectParent, allocParams.HVASpace, allocParams.HContextShare) + }) +} + func rmAllocContextShare(fi *frontendIoctlState, ioctlParams *nvgpu.NVOS64_PARAMETERS, isNVOS64 bool) (uintptr, error) { return rmAllocSimpleParams(fi, ioctlParams, isNVOS64, func(fi *frontendIoctlState, client *rootClient, ioctlParams *nvgpu.NVOS64_PARAMETERS, rightsRequested nvgpu.RS_ACCESS_MASK, allocParams *nvgpu.NV_CTXSHARE_ALLOCATION_PARAMETERS) { // See diff --git a/pkg/sentry/devices/nvproxy/version.go b/pkg/sentry/devices/nvproxy/version.go index af04549118..dcf845672a 100644 --- a/pkg/sentry/devices/nvproxy/version.go +++ b/pkg/sentry/devices/nvproxy/version.go @@ -1105,7 +1105,59 @@ func Init() { } return abi } - _ = addDriverABI(590, 48, 01, "b9e2f80693781431cc87f4cd29109e133dcecb50a50d6b68d4b3bf2d696bd689", "14ecfb7faa56d4d18cd9fef891b3fa2db3628f12a3e59b59d3c6e6d1a0befd80", v590_44_01) + v590_48_01 := addDriverABI(590, 48, 01, "b9e2f80693781431cc87f4cd29109e133dcecb50a50d6b68d4b3bf2d696bd689", "14ecfb7faa56d4d18cd9fef891b3fa2db3628f12a3e59b59d3c6e6d1a0befd80", v590_44_01) + + _ = addDriverABI(610, 43, 02, ChecksumNoDriver, "8ac5939e891403f7735a870504b6a59e4e3e3b9812131563b37755a5d61353cf", func() *driverABI { + abi := v590_48_01() + // UVM range groups were removed in 610.43.02. + delete(abi.uvmIoctl, nvgpu.UVM_CREATE_RANGE_GROUP) + delete(abi.uvmIoctl, nvgpu.UVM_DESTROY_RANGE_GROUP) + delete(abi.uvmIoctl, nvgpu.UVM_SET_RANGE_GROUP) + delete(abi.uvmIoctl, nvgpu.UVM_MIGRATE_RANGE_GROUP) + + abi.allocationClass[nvgpu.TURING_CHANNEL_GPFIFO_A] = allocHandler(rmAllocChannelV610, compUtil) + abi.allocationClass[nvgpu.AMPERE_CHANNEL_GPFIFO_A] = allocHandler(rmAllocChannelV610, compUtil) + abi.allocationClass[nvgpu.HOPPER_CHANNEL_GPFIFO_A] = allocHandler(rmAllocChannelV610, compUtil) + abi.allocationClass[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = allocHandler(rmAllocChannelV610, compUtil) + abi.allocationClass[nvgpu.BLACKWELL_CHANNEL_GPFIFO_B] = allocHandler(rmAllocChannelV610, compUtil) + + prevGetInfo := abi.getInfo + abi.getInfo = func() *DriverABIInfo { + info := prevGetInfo() + delete(info.UvmInfos, nvgpu.UVM_CREATE_RANGE_GROUP) + delete(info.UvmInfos, nvgpu.UVM_DESTROY_RANGE_GROUP) + delete(info.UvmInfos, nvgpu.UVM_SET_RANGE_GROUP) + delete(info.UvmInfos, nvgpu.UVM_MIGRATE_RANGE_GROUP) + + info.AllocationInfos[nvgpu.TURING_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("TURING_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610{}, "NV_CHANNEL_ALLOC_PARAMS") + info.AllocationInfos[nvgpu.AMPERE_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("AMPERE_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610{}, "NV_CHANNEL_ALLOC_PARAMS") + info.AllocationInfos[nvgpu.HOPPER_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("HOPPER_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610{}, "NV_CHANNEL_ALLOC_PARAMS") + info.AllocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610{}, "NV_CHANNEL_ALLOC_PARAMS") + info.AllocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_B] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_B", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V610{}, "NV_CHANNEL_ALLOC_PARAMS") + + // BSP/MSENC structs were renamed to NVDEC/NVENC in 610.43.02. + + info.ControlInfos[nvgpu.NV0080_CTRL_CMD_BSP_GET_CAPS_V2] = simpleIoctlInfo("NV0080_CTRL_CMD_BSP_GET_CAPS_V2", "NV0080_CTRL_NVDEC_GET_CAPS_PARAMS_V2") + info.ControlInfos[nvgpu.NV0080_CTRL_CMD_MSENC_GET_CAPS] = ioctlInfoWithStructName("NV0080_CTRL_CMD_MSENC_GET_CAPS", nvgpu.NV0080_CTRL_GET_CAPS_PARAMS{}, "NV0080_CTRL_NVENC_GET_CAPS_PARAMS") + + info.AllocationInfos[nvgpu.NVC4B7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVC4B7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC7B7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVC7B7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC9B7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVC9B7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVCFB7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVCFB7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVCEB7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVCEB7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVD1B7_VIDEO_ENCODER] = ioctlInfoWithStructName("NVD1B7_VIDEO_ENCODER", nvgpu.NV_MSENC_ALLOCATION_PARAMETERS{}, "NV_NVENC_ALLOCATION_PARAMETERS") + + info.AllocationInfos[nvgpu.NVB8B0_VIDEO_DECODER] = ioctlInfoWithStructName("NVB8B0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC4B0_VIDEO_DECODER] = ioctlInfoWithStructName("NVC4B0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC6B0_VIDEO_DECODER] = ioctlInfoWithStructName("NVC6B0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC7B0_VIDEO_DECODER] = ioctlInfoWithStructName("NVC7B0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVC9B0_VIDEO_DECODER] = ioctlInfoWithStructName("NVC9B0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + info.AllocationInfos[nvgpu.NVCDB0_VIDEO_DECODER] = ioctlInfoWithStructName("NVCDB0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{}, "NV_NVDEC_ALLOCATION_PARAMETERS") + + return info + } + return abi + }) }) } diff --git a/tools/nvidia_driver_differ/parser/sources.go b/tools/nvidia_driver_differ/parser/sources.go index b27b79a8fb..39fb9069b5 100644 --- a/tools/nvidia_driver_differ/parser/sources.go +++ b/tools/nvidia_driver_differ/parser/sources.go @@ -54,6 +54,7 @@ func (d *DriverSourceDir) GetNonUVMSourcePaths() ([]string, error) { "src/common/sdk/nvidia/inc/class/*.h", "src/common/sdk/nvidia/inc/ctrl/*.h", "src/common/sdk/nvidia/inc/ctrl/*/*.h", + "src/common/sdk/nvidia/inc/alloc/*.h", "kernel-open/common/inc/nv-ioctl-numa.h", } @@ -110,7 +111,7 @@ func WriteIncludeFile(sources []string, w io.Writer, ioctls []nvproxy.IoctlName) // in the source file, we create constants with name "GVISOR_" // which are initialized with the ioctl macro. for _, ioctl := range ioctls { - if _, err := fmt.Fprintf(bufW, "const uint64_t GVISOR_%s = %s;\n", ioctl, ioctl); err != nil { + if _, err := fmt.Fprintf(bufW, "#ifdef %s\nconst uint64_t GVISOR_%s = %s;\n#endif\n", ioctl, ioctl, ioctl); err != nil { return fmt.Errorf("failed to write to include file: %w", err) } }