Skip to content

Commit 9f4ea59

Browse files
ayushr2gvisor-bot
authored andcommitted
nvproxy: Add support for driver version 580.65.06.
A lot of struct changes were reported by `bazel run tools/nvidia_driver_differ:run_differ -- --base 575.57.08 --next 580.65.06`: - NV_ESC_RM_MAP_MEMORY_DMA's parameter struct (NVOS46_PARAMETERS) was updated. Consequently, seccomp filters were updated to accommodate the new size. - NV_VASPACE_ALLOCATION_PARAMETERS was updated with a new field. - A lot of control command's param structs were changed. However, all of them remained "simple" and hence nvproxy doesn't need to define their exact struct definitions. Hence no changes regarding those were made. - With the 580 driver, TestCUDA/Samples/3_CUDA_Features/memMapIPCDrv started using 2 new control commands: NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD and NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD. Added support for those. PiperOrigin-RevId: 795528656
1 parent e52b1fc commit 9f4ea59

File tree

5 files changed

+111
-7
lines changed

5 files changed

+111
-7
lines changed

pkg/abi/nvgpu/classes.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ type NV_VASPACE_ALLOCATION_PARAMETERS struct {
328328
VABase uint64
329329
}
330330

331+
// NV_VASPACE_ALLOCATION_PARAMETERS_V580 is the updated version of
332+
// NV_VASPACE_ALLOCATION_PARAMETERS since 580.65.06.
333+
//
334+
// +marshal
335+
type NV_VASPACE_ALLOCATION_PARAMETERS_V580 struct {
336+
NV_VASPACE_ALLOCATION_PARAMETERS
337+
Pasid uint32
338+
Pad1 [4]byte
339+
}
340+
331341
// NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS is the alloc params type for
332342
// KEPLER_CHANNEL_GROUP_A, from src/common/sdk/nvidia/inc/nvos.h.
333343
//

pkg/abi/nvgpu/ctrl.go

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,14 @@ type NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS_V550 struct {
142142

143143
// From src/common/sdk/nvidia/inc/ctrl/ctrl0000/ctrl0000unix.h:
144144
const (
145-
NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD = 0x3d05
146-
NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD = 0x3d06
147-
NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO = 0x3d08
148-
NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE = 64
145+
NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD = 0x3d05
146+
NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD = 0x3d06
147+
NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO = 0x3d08
148+
NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD = 0x3d0b
149+
NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD = 0x3d0c
150+
NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE = 64
151+
NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_MAX_OBJECTS = 512
152+
NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS = 128
149153
)
150154

151155
// +marshal
@@ -226,6 +230,48 @@ func (p *NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS) SetFrontendFD(fd int3
226230
p.FD = fd
227231
}
228232

233+
// +marshal
234+
type NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS struct {
235+
FD int32
236+
HDevice Handle
237+
MaxObjects uint16
238+
Metadata [NV0000_OS_UNIX_EXPORT_OBJECT_FD_BUFFER_SIZE]uint8
239+
Pad [2]byte
240+
Objects [NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_MAX_OBJECTS]Handle
241+
NumObjects uint16
242+
Index uint16
243+
}
244+
245+
// GetFrontendFD implements HasFrontendFD.GetFrontendFD.
246+
func (p *NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS) GetFrontendFD() int32 {
247+
return p.FD
248+
}
249+
250+
// SetFrontendFD implements HasFrontendFD.SetFrontendFD.
251+
func (p *NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS) SetFrontendFD(fd int32) {
252+
p.FD = fd
253+
}
254+
255+
// +marshal
256+
type NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS struct {
257+
FD int32
258+
HParent Handle
259+
Objects [NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS]Handle
260+
ObjectTypes [NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS]uint8
261+
NumObjects uint16
262+
Index uint16
263+
}
264+
265+
// GetFrontendFD implements HasFrontendFD.GetFrontendFD.
266+
func (p *NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS) GetFrontendFD() int32 {
267+
return p.FD
268+
}
269+
270+
// SetFrontendFD implements HasFrontendFD.SetFrontendFD.
271+
func (p *NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS) SetFrontendFD(fd int32) {
272+
p.FD = fd
273+
}
274+
229275
// +marshal
230276
type NV0000_CTRL_SYSTEM_GET_BUILD_VERSION_PARAMS struct {
231277
SizeOfStrings uint32

pkg/abi/nvgpu/frontend.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,36 @@ func (n *NVOS46_PARAMETERS) SetStatus(status uint32) {
590590
n.Status = status
591591
}
592592

593+
// NVOS46_PARAMETERS_V580 is the updated version of NVOS46_PARAMETERS since
594+
// 580.65.06.
595+
//
596+
// +marshal
597+
type NVOS46_PARAMETERS_V580 struct {
598+
Client Handle
599+
Device Handle
600+
Dma Handle
601+
Memory Handle
602+
Offset uint64
603+
Length uint64
604+
Flags uint32
605+
Flags2 uint32
606+
KindOverride uint32
607+
Pad0 [4]byte
608+
DmaOffset uint64
609+
Status uint32
610+
Pad1 [4]byte
611+
}
612+
613+
// GetStatus implements HasStatus.GetStatus.
614+
func (n *NVOS46_PARAMETERS_V580) GetStatus() uint32 {
615+
return n.Status
616+
}
617+
618+
// SetStatus implements HasStatus.SetStatus.
619+
func (n *NVOS46_PARAMETERS_V580) SetStatus(status uint32) {
620+
n.Status = status
621+
}
622+
593623
// NVOS47_PARAMETERS is the parameter type for NV_ESC_RM_UNMAP_MEMORY_DMA.
594624
//
595625
// +marshal
@@ -767,7 +797,6 @@ var (
767797
SizeofNVOS32Parameters = uint32((*NVOS32_PARAMETERS)(nil).SizeBytes())
768798
SizeofNVOS34Parameters = uint32((*NVOS34_PARAMETERS)(nil).SizeBytes())
769799
SizeofNVOS39Parameters = uint32((*NVOS39_PARAMETERS)(nil).SizeBytes())
770-
SizeofNVOS46Parameters = uint32((*NVOS46_PARAMETERS)(nil).SizeBytes())
771800
SizeofNVOS54Parameters = uint32((*NVOS54_PARAMETERS)(nil).SizeBytes())
772801
SizeofNVOS55Parameters = uint32((*NVOS55_PARAMETERS)(nil).SizeBytes())
773802
SizeofNVOS56Parameters = uint32((*NVOS56_PARAMETERS)(nil).SizeBytes())

pkg/sentry/devices/nvproxy/seccomp_filters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func frontendIoctlFilters(enabledCaps nvconf.DriverCaps) []seccomp.SyscallRule {
6060
{seccomp.EqualTo(frontendIoctlCmd(nvgpu.NV_ESC_RM_MAP_MEMORY, nvgpu.SizeofIoctlNVOS33ParametersWithFD)), compUtil},
6161
{seccomp.EqualTo(frontendIoctlCmd(nvgpu.NV_ESC_RM_UNMAP_MEMORY, nvgpu.SizeofNVOS34Parameters)), compUtil},
6262
{seccomp.EqualTo(frontendIoctlCmd(nvgpu.NV_ESC_RM_ALLOC_CONTEXT_DMA2, nvgpu.SizeofNVOS39Parameters)), nvconf.CapGraphics},
63-
{seccomp.EqualTo(frontendIoctlCmd(nvgpu.NV_ESC_RM_MAP_MEMORY_DMA, nvgpu.SizeofNVOS46Parameters)), nvconf.CapGraphics | nvconf.CapVideo},
63+
{seccomp.MaskedEqual(notIocSizeMask, frontendIoctlCmd(nvgpu.NV_ESC_RM_MAP_MEMORY_DMA, 0)), nvconf.CapGraphics | nvconf.CapVideo},
6464
{seccomp.MaskedEqual(notIocSizeMask, frontendIoctlCmd(nvgpu.NV_ESC_RM_UNMAP_MEMORY_DMA, 0)), nvconf.CapGraphics | nvconf.CapVideo},
6565
{seccomp.EqualTo(frontendIoctlCmd(nvgpu.NV_ESC_RM_UPDATE_DEVICE_MAPPING_INFO, nvgpu.SizeofNVOS56Parameters)), compUtil},
6666
} {

pkg/sentry/devices/nvproxy/version.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ func Init() {
360360
nvgpu.NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD: ctrlHandler(ctrlHasFrontendFD[nvgpu.NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS], compUtil),
361361
nvgpu.NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD: ctrlHandler(ctrlHasFrontendFD[nvgpu.NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS], compUtil),
362362
nvgpu.NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO: ctrlHandler(ctrlHasFrontendFD[nvgpu.NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS], compUtil),
363+
nvgpu.NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD: ctrlHandler(ctrlHasFrontendFD[nvgpu.NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS], compUtil),
364+
nvgpu.NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD: ctrlHandler(ctrlHasFrontendFD[nvgpu.NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS], compUtil),
363365
nvgpu.NV0041_CTRL_CMD_GET_SURFACE_INFO: ctrlHandler(ctrlIoctlHasInfoList[nvgpu.NvxxxCtrlXxxGetInfoParams], compUtil),
364366
nvgpu.NV00FD_CTRL_CMD_ATTACH_GPU: ctrlHandler(ctrlMemoryMulticastFabricAttachGPU, compUtil),
365367
nvgpu.NV503C_CTRL_CMD_REGISTER_VA_SPACE: ctrlHandler(ctrlRegisterVASpace, compUtil),
@@ -625,6 +627,8 @@ func Init() {
625627
nvgpu.NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD: ioctlInfo("NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECT_TO_FD", nvgpu.NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS{}),
626628
nvgpu.NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD: ioctlInfo("NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECT_FROM_FD", nvgpu.NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS{}),
627629
nvgpu.NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO: ioctlInfo("NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO", nvgpu.NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS{}),
630+
nvgpu.NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD: ioctlInfo("NV0000_CTRL_CMD_OS_UNIX_EXPORT_OBJECTS_TO_FD", nvgpu.NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS{}),
631+
nvgpu.NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD: ioctlInfo("NV0000_CTRL_CMD_OS_UNIX_IMPORT_OBJECTS_FROM_FD", nvgpu.NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS{}),
628632
nvgpu.NV0041_CTRL_CMD_GET_SURFACE_INFO: ioctlInfoWithStructName("NV0041_CTRL_CMD_GET_SURFACE_INFO", nvgpu.NvxxxCtrlXxxGetInfoParams{}, "NV0041_CTRL_GET_SURFACE_INFO_PARAMS"),
629633
nvgpu.NV00FD_CTRL_CMD_ATTACH_GPU: ioctlInfo("NV00FD_CTRL_CMD_ATTACH_GPU", nvgpu.NV00FD_CTRL_ATTACH_GPU_PARAMS{}),
630634
nvgpu.NV503C_CTRL_CMD_REGISTER_VA_SPACE: ioctlInfo("NV503C_CTRL_CMD_REGISTER_VA_SPACE", nvgpu.NV503C_CTRL_REGISTER_VA_SPACE_PARAMS{}),
@@ -900,7 +904,22 @@ func Init() {
900904
return abi
901905
}
902906

903-
_ = addDriverABI(575, 57, 8, "2aa701dac180a7b20a6e578cccd901ded8d44e57d60580f08f9d28dd1fffc6f2", "549e73e4f7402f66275ee665b6e3a2ae5d7bf57296b743b824d713f205203bdf", v575_51_02)
907+
v575_57_08 := addDriverABI(575, 57, 8, "2aa701dac180a7b20a6e578cccd901ded8d44e57d60580f08f9d28dd1fffc6f2", "549e73e4f7402f66275ee665b6e3a2ae5d7bf57296b743b824d713f205203bdf", v575_51_02)
908+
909+
_ = addDriverABI(580, 65, 06, "04b10867af585e765cfbfdcf39ed5f4bd112375bebab0172eaa187c6aa5024ff", "e02acdc0d20d4a541aa5026bfddb1b9b4fc6bc64ae3b04ff9cb9c892700cf9c4", func() *driverABI {
910+
abi := v575_57_08()
911+
abi.frontendIoctl[nvgpu.NV_ESC_RM_MAP_MEMORY_DMA] = feHandler(frontendIoctlSimple[nvgpu.NVOS46_PARAMETERS_V580], nvconf.CapGraphics|nvconf.CapVideo)
912+
abi.allocationClass[nvgpu.FERMI_VASPACE_A] = allocHandler(rmAllocSimple[nvgpu.NV_VASPACE_ALLOCATION_PARAMETERS_V580], compUtil)
913+
914+
prevGetInfo := abi.getInfo
915+
abi.getInfo = func() *DriverABIInfo {
916+
info := prevGetInfo()
917+
info.FrontendInfos[nvgpu.NV_ESC_RM_MAP_MEMORY_DMA] = ioctlInfoWithStructName("NV_ESC_RM_MAP_MEMORY_DMA", nvgpu.NVOS46_PARAMETERS_V580{}, "NVOS46_PARAMETERS")
918+
info.AllocationInfos[nvgpu.FERMI_VASPACE_A] = ioctlInfoWithStructName("FERMI_VASPACE_A", nvgpu.NV_VASPACE_ALLOCATION_PARAMETERS_V580{}, "NV_VASPACE_ALLOCATION_PARAMETERS")
919+
return info
920+
}
921+
return abi
922+
})
904923
})
905924
}
906925

0 commit comments

Comments
 (0)