mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
Update nvidia_driver_differ to also check ioctl numbers.
Updated the tooling to fetch the ioctl number used in the driver source code
and compare it to the one used in nvproxy. It is possible that ioctl numbers
change across driver versions (under our foot). It is imperative that we mimic
these changes in nvproxy. For example, in 575.57.08 driver release,
NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT changed from
0x20801358 to 0x20801357.
To achieve this effect, the AST parser has been updated in the previous change
to be able to parse numerical constants. However, it is unable to parse macros
that evaluate to constants (trust me, I tried). So as a workaround, the
nvidia_driver_differ declares "const uint64_t" variables in the source file
which is created with all relevant includes (see parser.WriteIncludeFile()).
These variables are defined with name "GVISOR_{IOCTL_MACRO} = IOCTL_MACRO" so
they should not conflict with anything in the driver. Then we use the AST
parser to evaluate the value of the const variable and return that.
PiperOrigin-RevId: 793350829
This commit is contained in:
@@ -54,16 +54,16 @@ func createParserRunner(t *testing.T) *parser.Runner {
|
||||
return runner
|
||||
}
|
||||
|
||||
func getDriverDefs(t *testing.T, runner *parser.Runner, version nvconf.DriverVersion) ([]nvproxy.DriverStruct, *parser.OutputJSON) {
|
||||
func getDriverDefs(t *testing.T, runner *parser.Runner, version nvconf.DriverVersion) (*nvproxy.DriverABIInfo, *parser.OutputJSON) {
|
||||
t.Helper()
|
||||
|
||||
structs, ok := nvproxy.SupportedStructTypes(version)
|
||||
info, ok := nvproxy.SupportedIoctls(version)
|
||||
if !ok {
|
||||
t.Fatalf("failed to get struct names for driver %q", version.String())
|
||||
}
|
||||
|
||||
// Create structs file for parser
|
||||
if err := runner.CreateStructsFile(structs); err != nil {
|
||||
if err := runner.CreateInputFile(info); err != nil {
|
||||
t.Fatalf("failed to create temporary structs list: %v", err)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func getDriverDefs(t *testing.T, runner *parser.Runner, version nvconf.DriverVer
|
||||
t.Fatalf("failed to run driver_ast_parser: %v", err)
|
||||
}
|
||||
|
||||
return structs, defs
|
||||
return info, defs
|
||||
}
|
||||
|
||||
// TestStructDefinitionParity tests that the struct definitions in nvproxy are the same as the
|
||||
@@ -86,43 +86,68 @@ func TestStructDefinitionParity(t *testing.T) {
|
||||
t.Parallel()
|
||||
runner := createParserRunner(t)
|
||||
|
||||
nvproxyDefs, defs := getDriverDefs(t, runner, version)
|
||||
nvproxyIoctls, defs := getDriverDefs(t, runner, version)
|
||||
|
||||
for _, nvproxyDef := range nvproxyDefs {
|
||||
// Check if the nvproxy definition has disallowed types.
|
||||
if nvproxyDef.Type != nil {
|
||||
fields := flattenNvproxyStruct(t, nvproxyDef.Type)
|
||||
for _, field := range fields {
|
||||
if _, ok := typeAllowlist[field.Type.Kind()]; !ok {
|
||||
t.Errorf("struct %q has disallowed type %q in nvproxy", nvproxyDef.Name, field.Type.Name())
|
||||
checkIoctl := func(ioctlNum uint32, nvproxyIoctl nvproxy.IoctlInfo) {
|
||||
if nvproxyIoctl.Name == "" {
|
||||
return
|
||||
}
|
||||
// Check if the ioctl number has changed.
|
||||
if driverIoctlNum, ok := defs.Constants[nvproxyIoctl.Name]; !ok {
|
||||
t.Errorf("ioctl %q not found in driver source code", nvproxyIoctl.Name)
|
||||
} else if driverIoctlNum != uint64(ioctlNum) {
|
||||
t.Errorf("ioctl %q has changed numbers between nvproxy (%#x) and driver (%#x)",
|
||||
nvproxyIoctl.Name, ioctlNum, defs.Constants[nvproxyIoctl.Name])
|
||||
}
|
||||
|
||||
for _, nvproxyDef := range nvproxyIoctl.Structs {
|
||||
// Check if the nvproxy definition has disallowed types.
|
||||
if nvproxyDef.Type != nil {
|
||||
fields := flattenNvproxyStruct(t, nvproxyDef.Type)
|
||||
for _, field := range fields {
|
||||
if _, ok := typeAllowlist[field.Type.Kind()]; !ok {
|
||||
t.Errorf("struct %q has disallowed type %q in nvproxy", nvproxyDef.Name, field.Type.Name())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compare the nvproxy definition to the parser output.
|
||||
name := nvproxyDef.Name
|
||||
_, isRecord := defs.Records[name]
|
||||
aliasDef, isAlias := defs.Aliases[name]
|
||||
if !isRecord && !isAlias {
|
||||
t.Errorf("struct %q not found in parser output for version %q", name, version.String())
|
||||
continue
|
||||
}
|
||||
// Compare the nvproxy definition to the parser output.
|
||||
name := nvproxyDef.Name
|
||||
_, isRecord := defs.Records[name]
|
||||
aliasDef, isAlias := defs.Aliases[name]
|
||||
if !isRecord && !isAlias {
|
||||
t.Errorf("struct %q not found in parser output for version %q", name, version.String())
|
||||
continue
|
||||
}
|
||||
|
||||
switch {
|
||||
case isRecord && nvproxyDef.Type == nil:
|
||||
checkSimpleRecord(t, name, defs)
|
||||
case isRecord && nvproxyDef.Type != nil:
|
||||
if err := compareStructs(t, nvproxyDef.Type, name, defs); err != nil {
|
||||
t.Errorf("struct %q has different definitions between nvproxy and driver: %v", name, err)
|
||||
switch {
|
||||
case isRecord && nvproxyDef.Type == nil:
|
||||
checkSimpleRecord(t, name, defs)
|
||||
case isRecord && nvproxyDef.Type != nil:
|
||||
if err := compareStructs(t, nvproxyDef.Type, name, defs); err != nil {
|
||||
t.Errorf("struct %q has different definitions between nvproxy and driver: %v", name, err)
|
||||
}
|
||||
case isAlias && nvproxyDef.Type == nil:
|
||||
// For now, there is no good way to check if an alias is still simple.
|
||||
// Regardless, none of the current ioctls fall into this category.
|
||||
t.Errorf("struct %q is a simple alias, which is not supported yet", name)
|
||||
case isAlias && nvproxyDef.Type != nil:
|
||||
checkComplexAlias(t, nvproxyDef, aliasDef)
|
||||
}
|
||||
case isAlias && nvproxyDef.Type == nil:
|
||||
// For now, there is no good way to check if an alias is still simple.
|
||||
// Regardless, none of the current ioctls fall into this category.
|
||||
t.Errorf("struct %q is a simple alias, which is not supported yet", name)
|
||||
case isAlias && nvproxyDef.Type != nil:
|
||||
checkComplexAlias(t, nvproxyDef, aliasDef)
|
||||
}
|
||||
}
|
||||
for num, info := range nvproxyIoctls.FrontendInfos {
|
||||
checkIoctl(num, info)
|
||||
}
|
||||
for num, info := range nvproxyIoctls.ControlInfos {
|
||||
checkIoctl(num, info)
|
||||
}
|
||||
for num, info := range nvproxyIoctls.AllocationInfos {
|
||||
checkIoctl(uint32(num), info)
|
||||
}
|
||||
for num, info := range nvproxyIoctls.UvmInfos {
|
||||
checkIoctl(num, info)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,25 +54,37 @@ func TestABIStructNamesInSync(t *testing.T) {
|
||||
info := abi.getInfo()
|
||||
|
||||
for ioctl := range abi.frontendIoctl {
|
||||
if _, ok := info.frontendInfos[ioctl]; !ok {
|
||||
t.Errorf("Frontend ioctl %#x not found in struct names for version %v", ioctl, version.String())
|
||||
if _, ok := info.FrontendInfos[ioctl]; !ok {
|
||||
t.Errorf("Frontend ioctl %#x not found in struct names for version %s", ioctl, version)
|
||||
}
|
||||
}
|
||||
if len(abi.frontendIoctl) != len(info.FrontendInfos) {
|
||||
t.Errorf("Frontend ioctl count mismatch for version %s: %d != %d", version, len(abi.frontendIoctl), len(info.FrontendInfos))
|
||||
}
|
||||
for ioctl := range abi.uvmIoctl {
|
||||
if _, ok := info.uvmInfos[ioctl]; !ok {
|
||||
t.Errorf("UVM ioctl %#x not found in struct names for version %v", ioctl, version.String())
|
||||
if _, ok := info.UvmInfos[ioctl]; !ok {
|
||||
t.Errorf("UVM ioctl %#x not found in struct names for version %s", ioctl, version)
|
||||
}
|
||||
}
|
||||
if len(abi.uvmIoctl) != len(info.UvmInfos) {
|
||||
t.Errorf("UVM ioctl count mismatch for version %s: %d != %d", version, len(abi.uvmIoctl), len(info.UvmInfos))
|
||||
}
|
||||
for ioctl := range abi.controlCmd {
|
||||
if _, ok := info.controlInfos[ioctl]; !ok {
|
||||
t.Errorf("Control command %#x not found in struct names for version %v", ioctl, version.String())
|
||||
if _, ok := info.ControlInfos[ioctl]; !ok {
|
||||
t.Errorf("Control command %#x not found in struct names for version %s", ioctl, version)
|
||||
}
|
||||
}
|
||||
if len(abi.controlCmd) != len(info.ControlInfos) {
|
||||
t.Errorf("Control command count mismatch for version %s: %d != %d", version, len(abi.controlCmd), len(info.ControlInfos))
|
||||
}
|
||||
for ioctl := range abi.allocationClass {
|
||||
if _, ok := info.allocationInfos[ioctl]; !ok {
|
||||
t.Errorf("Alloc class %#x not found in struct names for version %v", ioctl, version.String())
|
||||
if _, ok := info.AllocationInfos[ioctl]; !ok {
|
||||
t.Errorf("Alloc class %#x not found in struct names for version %s", ioctl, version)
|
||||
}
|
||||
}
|
||||
if len(abi.allocationClass) != len(info.AllocationInfos) {
|
||||
t.Errorf("Alloc class count mismatch for version %s: %d != %d", version, len(abi.allocationClass), len(info.AllocationInfos))
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ type driverABIFunc func() *driverABI
|
||||
// driverABIInfoFunc returns the driverABIInfo for a given ABI version. This
|
||||
// indirection exists to avoid the memory usage in production when info about
|
||||
// the driver ABI is not needed.
|
||||
type driverABIInfoFunc func() *driverABIInfo
|
||||
type driverABIInfoFunc func() *DriverABIInfo
|
||||
|
||||
// Checksums is a struct containing the SHA256 checksum of the linux .run driver installer file from
|
||||
// NVIDIA.
|
||||
@@ -106,16 +106,16 @@ type driverABI struct {
|
||||
getInfo driverABIInfoFunc
|
||||
}
|
||||
|
||||
// driverABIInfo defines all the structs and ioctls used by a driverABI.
|
||||
// DriverABIInfo defines all the structs and ioctls used by a driverABI.
|
||||
// This is used to help with verifying and supporting new driver versions. This
|
||||
// helps keep track of all the driver structs and ioctls that we currently
|
||||
// support. We do so by mapping ioctl numbers to its name in the driver and a
|
||||
// list of DriverStructs used by that ioctl.
|
||||
type driverABIInfo struct {
|
||||
frontendInfos map[uint32]IoctlInfo
|
||||
uvmInfos map[uint32]IoctlInfo
|
||||
controlInfos map[uint32]IoctlInfo
|
||||
allocationInfos map[nvgpu.ClassID]IoctlInfo
|
||||
type DriverABIInfo struct {
|
||||
FrontendInfos map[uint32]IoctlInfo
|
||||
UvmInfos map[uint32]IoctlInfo
|
||||
ControlInfos map[uint32]IoctlInfo
|
||||
AllocationInfos map[nvgpu.ClassID]IoctlInfo
|
||||
}
|
||||
|
||||
// IoctlName is the name of the constant used by the Nvidia driver to define
|
||||
@@ -428,9 +428,9 @@ func Init() {
|
||||
nvgpu.NV20_SUBDEVICE_DIAG: allocHandler(rmAllocNoParams, compUtil),
|
||||
},
|
||||
|
||||
getInfo: func() *driverABIInfo {
|
||||
return &driverABIInfo{
|
||||
frontendInfos: map[uint32]IoctlInfo{
|
||||
getInfo: func() *DriverABIInfo {
|
||||
return &DriverABIInfo{
|
||||
FrontendInfos: map[uint32]IoctlInfo{
|
||||
nvgpu.NV_ESC_CARD_INFO: simpleIoctlInfo("NV_ESC_CARD_INFO", "nv_ioctl_card_info_t"),
|
||||
nvgpu.NV_ESC_CHECK_VERSION_STR: ioctlInfoWithStructName("NV_ESC_CHECK_VERSION_STR", nvgpu.RMAPIVersion{}, "nv_ioctl_rm_api_version_t"),
|
||||
nvgpu.NV_ESC_ATTACH_GPUS_TO_FD: simpleIoctlInfo("NV_ESC_ATTACH_GPUS_TO_FD"), // No params struct, params is a NvU32 array containing GPU IDs
|
||||
@@ -454,7 +454,7 @@ func Init() {
|
||||
nvgpu.NV_ESC_RM_VID_HEAP_CONTROL: ioctlInfo("NV_ESC_RM_VID_HEAP_CONTROL", nvgpu.NVOS32_PARAMETERS{}),
|
||||
nvgpu.NV_ESC_RM_MAP_MEMORY: ioctlInfoWithStructName("NV_ESC_RM_MAP_MEMORY", nvgpu.IoctlNVOS33ParametersWithFD{}, "nv_ioctl_nvos33_parameters_with_fd"),
|
||||
},
|
||||
uvmInfos: map[uint32]IoctlInfo{
|
||||
UvmInfos: map[uint32]IoctlInfo{
|
||||
nvgpu.UVM_INITIALIZE: ioctlInfo("UVM_INITIALIZE", nvgpu.UVM_INITIALIZE_PARAMS{}),
|
||||
nvgpu.UVM_DEINITIALIZE: simpleIoctlInfo("UVM_DEINITIALIZE"), // Doesn't have any params
|
||||
nvgpu.UVM_CREATE_RANGE_GROUP: ioctlInfo("UVM_CREATE_RANGE_GROUP", nvgpu.UVM_CREATE_RANGE_GROUP_PARAMS{}),
|
||||
@@ -485,7 +485,7 @@ func Init() {
|
||||
nvgpu.UVM_CREATE_EXTERNAL_RANGE: ioctlInfo("UVM_CREATE_EXTERNAL_RANGE", nvgpu.UVM_CREATE_EXTERNAL_RANGE_PARAMS{}),
|
||||
nvgpu.UVM_MM_INITIALIZE: ioctlInfo("UVM_MM_INITIALIZE", nvgpu.UVM_MM_INITIALIZE_PARAMS{}),
|
||||
},
|
||||
controlInfos: map[uint32]IoctlInfo{
|
||||
ControlInfos: map[uint32]IoctlInfo{
|
||||
nvgpu.NV0000_CTRL_CMD_CLIENT_GET_ADDR_SPACE_TYPE: simpleIoctlInfo("NV0000_CTRL_CMD_CLIENT_GET_ADDR_SPACE_TYPE", "NV0000_CTRL_CLIENT_GET_ADDR_SPACE_TYPE_PARAMS"),
|
||||
nvgpu.NV0000_CTRL_CMD_CLIENT_SET_INHERITED_SHARE_POLICY: simpleIoctlInfo("NV0000_CTRL_CMD_CLIENT_SET_INHERITED_SHARE_POLICY", "NV0000_CTRL_CLIENT_SET_INHERITED_SHARE_POLICY_PARAMS"),
|
||||
nvgpu.NV0000_CTRL_CMD_GPU_GET_ATTACHED_IDS: simpleIoctlInfo("NV0000_CTRL_CMD_GPU_GET_ATTACHED_IDS", "NV0000_CTRL_GPU_GET_ATTACHED_IDS_PARAMS"),
|
||||
@@ -630,7 +630,7 @@ func Init() {
|
||||
nvgpu.NV503C_CTRL_CMD_REGISTER_VA_SPACE: ioctlInfo("NV503C_CTRL_CMD_REGISTER_VA_SPACE", nvgpu.NV503C_CTRL_REGISTER_VA_SPACE_PARAMS{}),
|
||||
nvgpu.NV208F_CTRL_CMD_GPU_VERIFY_INFOROM: ioctlInfo("NV208F_CTRL_CMD_GPU_VERIFY_INFOROM", nvgpu.NV208F_CTRL_GPU_VERIFY_INFOROM_PARAMS{}),
|
||||
},
|
||||
allocationInfos: map[nvgpu.ClassID]IoctlInfo{
|
||||
AllocationInfos: map[nvgpu.ClassID]IoctlInfo{
|
||||
nvgpu.NV01_ROOT: ioctlInfoWithStructName("NV01_ROOT", nvgpu.Handle{}, "NvHandle"),
|
||||
nvgpu.NV01_ROOT_NON_PRIV: ioctlInfoWithStructName("NV01_ROOT_NON_PRIV", nvgpu.Handle{}, "NvHandle"),
|
||||
nvgpu.NV01_CONTEXT_DMA: ioctlInfo("NV01_CONTEXT_DMA", nvgpu.NV_CONTEXT_DMA_ALLOCATION_PARAMS{}),
|
||||
@@ -723,16 +723,16 @@ func Init() {
|
||||
abi.allocationClass[nvgpu.NV50_MEMORY_VIRTUAL] = allocHandler(rmAllocSimple[nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545], compUtil)
|
||||
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.controlInfos[nvgpu.NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO] = ioctlInfoWithStructName("NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO", nvgpu.NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_V545{}, "NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS")
|
||||
info.controlInfos[nvgpu.NV0000_CTRL_CMD_GPU_GET_ACTIVE_DEVICE_IDS] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_GET_ACTIVE_DEVICE_IDS", "NV0000_CTRL_GPU_GET_ACTIVE_DEVICE_IDS_PARAMS")
|
||||
info.controlInfos[nvgpu.NV00DE_CTRL_CMD_REQUEST_DATA_POLL] = simpleIoctlInfo("NV00DE_CTRL_CMD_REQUEST_DATA_POLL", "NV00DE_CTRL_REQUEST_DATA_POLL_PARAMS")
|
||||
info.allocationInfos[nvgpu.RM_USER_SHARED_DATA] = ioctlInfoWithStructName("RM_USER_SHARED_DATA", nvgpu.NV00DE_ALLOC_PARAMETERS_V545{}, "NV00DE_ALLOC_PARAMETERS")
|
||||
info.allocationInfos[nvgpu.NV_MEMORY_MULTICAST_FABRIC] = ioctlInfoWithStructName("NV_MEMORY_MULTICAST_FABRIC", nvgpu.NV00FD_ALLOCATION_PARAMETERS_V545{}, "NV00FD_ALLOCATION_PARAMETERS")
|
||||
info.allocationInfos[nvgpu.NV01_MEMORY_SYSTEM] = ioctlInfoWithStructName("NV01_MEMORY_SYSTEM", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
info.allocationInfos[nvgpu.NV01_MEMORY_LOCAL_USER] = ioctlInfoWithStructName("NV01_MEMORY_LOCAL_USER", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
info.allocationInfos[nvgpu.NV50_MEMORY_VIRTUAL] = ioctlInfoWithStructName("NV50_MEMORY_VIRTUAL", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO] = ioctlInfoWithStructName("NV0000_CTRL_CMD_OS_UNIX_GET_EXPORT_OBJECT_INFO", nvgpu.NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_V545{}, "NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV0000_CTRL_CMD_GPU_GET_ACTIVE_DEVICE_IDS] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_GET_ACTIVE_DEVICE_IDS", "NV0000_CTRL_GPU_GET_ACTIVE_DEVICE_IDS_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV00DE_CTRL_CMD_REQUEST_DATA_POLL] = simpleIoctlInfo("NV00DE_CTRL_CMD_REQUEST_DATA_POLL", "NV00DE_CTRL_REQUEST_DATA_POLL_PARAMS")
|
||||
info.AllocationInfos[nvgpu.RM_USER_SHARED_DATA] = ioctlInfoWithStructName("RM_USER_SHARED_DATA", nvgpu.NV00DE_ALLOC_PARAMETERS_V545{}, "NV00DE_ALLOC_PARAMETERS")
|
||||
info.AllocationInfos[nvgpu.NV_MEMORY_MULTICAST_FABRIC] = ioctlInfoWithStructName("NV_MEMORY_MULTICAST_FABRIC", nvgpu.NV00FD_ALLOCATION_PARAMETERS_V545{}, "NV00FD_ALLOCATION_PARAMETERS")
|
||||
info.AllocationInfos[nvgpu.NV01_MEMORY_SYSTEM] = ioctlInfoWithStructName("NV01_MEMORY_SYSTEM", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
info.AllocationInfos[nvgpu.NV01_MEMORY_LOCAL_USER] = ioctlInfoWithStructName("NV01_MEMORY_LOCAL_USER", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
info.AllocationInfos[nvgpu.NV50_MEMORY_VIRTUAL] = ioctlInfoWithStructName("NV50_MEMORY_VIRTUAL", nvgpu.NV_MEMORY_ALLOCATION_PARAMS_V545{}, "NV_MEMORY_ALLOCATION_PARAMS")
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -755,19 +755,19 @@ func Init() {
|
||||
abi.allocationClass[nvgpu.NV_MEMORY_MAPPER] = allocHandler(rmAllocSimple[nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550], nvconf.CapVideo)
|
||||
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.frontendInfos[nvgpu.NV_ESC_WAIT_OPEN_COMPLETE] = ioctlInfoWithStructName("NV_ESC_WAIT_OPEN_COMPLETE", nvgpu.IoctlWaitOpenComplete{}, "nv_ioctl_wait_open_complete_t")
|
||||
info.frontendInfos[nvgpu.NV_ESC_RM_UNMAP_MEMORY_DMA] = ioctlInfoWithStructName("NV_ESC_RM_UNMAP_MEMORY_DMA", nvgpu.NVOS47_PARAMETERS_V550{}, "NVOS47_PARAMETERS")
|
||||
info.controlInfos[nvgpu.NV0000_CTRL_CMD_GPU_ASYNC_ATTACH_ID] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_ASYNC_ATTACH_ID", "NV0000_CTRL_GPU_ASYNC_ATTACH_ID_PARAMS")
|
||||
info.controlInfos[nvgpu.NV0000_CTRL_CMD_GPU_WAIT_ATTACH_ID] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_WAIT_ATTACH_ID", "NV0000_CTRL_GPU_WAIT_ATTACH_ID_PARAMS")
|
||||
info.controlInfos[nvgpu.NV0080_CTRL_CMD_PERF_CUDA_LIMIT_SET_CONTROL] = simpleIoctlInfo("NV0080_CTRL_CMD_PERF_CUDA_LIMIT_SET_CONTROL", "NV0080_CTRL_PERF_CUDA_LIMIT_CONTROL_PARAMS")
|
||||
info.controlInfos[nvgpu.NV2080_CTRL_CMD_PERF_GET_CURRENT_PSTATE] = simpleIoctlInfo("NV2080_CTRL_CMD_PERF_GET_CURRENT_PSTATE", "NV2080_CTRL_PERF_GET_CURRENT_PSTATE_PARAMS")
|
||||
info.controlInfos[nvgpu.NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS] = ioctlInfoWithStructName("NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS", nvgpu.NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS_V550{}, "NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS")
|
||||
info.uvmInfos[nvgpu.UVM_SET_PREFERRED_LOCATION] = ioctlInfoWithStructName("UVM_SET_PREFERRED_LOCATION", nvgpu.UVM_SET_PREFERRED_LOCATION_PARAMS_V550{}, "UVM_SET_PREFERRED_LOCATION_PARAMS")
|
||||
info.uvmInfos[nvgpu.UVM_MIGRATE] = ioctlInfoWithStructName("UVM_MIGRATE", nvgpu.UVM_MIGRATE_PARAMS_V550{}, "UVM_MIGRATE_PARAMS")
|
||||
info.allocationInfos[nvgpu.NVENC_SW_SESSION] = ioctlInfo("NVENC_SW_SESSION", nvgpu.NVA0BC_ALLOC_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.NV_MEMORY_MAPPER] = ioctlInfoWithStructName("NV_MEMORY_MAPPER", nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550{}, "NV_MEMORY_MAPPER_ALLOCATION_PARAMS")
|
||||
info.FrontendInfos[nvgpu.NV_ESC_WAIT_OPEN_COMPLETE] = ioctlInfoWithStructName("NV_ESC_WAIT_OPEN_COMPLETE", nvgpu.IoctlWaitOpenComplete{}, "nv_ioctl_wait_open_complete_t")
|
||||
info.FrontendInfos[nvgpu.NV_ESC_RM_UNMAP_MEMORY_DMA] = ioctlInfoWithStructName("NV_ESC_RM_UNMAP_MEMORY_DMA", nvgpu.NVOS47_PARAMETERS_V550{}, "NVOS47_PARAMETERS")
|
||||
info.ControlInfos[nvgpu.NV0000_CTRL_CMD_GPU_ASYNC_ATTACH_ID] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_ASYNC_ATTACH_ID", "NV0000_CTRL_GPU_ASYNC_ATTACH_ID_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV0000_CTRL_CMD_GPU_WAIT_ATTACH_ID] = simpleIoctlInfo("NV0000_CTRL_CMD_GPU_WAIT_ATTACH_ID", "NV0000_CTRL_GPU_WAIT_ATTACH_ID_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV0080_CTRL_CMD_PERF_CUDA_LIMIT_SET_CONTROL] = simpleIoctlInfo("NV0080_CTRL_CMD_PERF_CUDA_LIMIT_SET_CONTROL", "NV0080_CTRL_PERF_CUDA_LIMIT_CONTROL_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV2080_CTRL_CMD_PERF_GET_CURRENT_PSTATE] = simpleIoctlInfo("NV2080_CTRL_CMD_PERF_GET_CURRENT_PSTATE", "NV2080_CTRL_PERF_GET_CURRENT_PSTATE_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS] = ioctlInfoWithStructName("NV0000_CTRL_CMD_SYSTEM_GET_P2P_CAPS", nvgpu.NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS_V550{}, "NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS")
|
||||
info.UvmInfos[nvgpu.UVM_SET_PREFERRED_LOCATION] = ioctlInfoWithStructName("UVM_SET_PREFERRED_LOCATION", nvgpu.UVM_SET_PREFERRED_LOCATION_PARAMS_V550{}, "UVM_SET_PREFERRED_LOCATION_PARAMS")
|
||||
info.UvmInfos[nvgpu.UVM_MIGRATE] = ioctlInfoWithStructName("UVM_MIGRATE", nvgpu.UVM_MIGRATE_PARAMS_V550{}, "UVM_MIGRATE_PARAMS")
|
||||
info.AllocationInfos[nvgpu.NVENC_SW_SESSION] = ioctlInfo("NVENC_SW_SESSION", nvgpu.NVA0BC_ALLOC_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.NV_MEMORY_MAPPER] = ioctlInfoWithStructName("NV_MEMORY_MAPPER", nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550{}, "NV_MEMORY_MAPPER_ALLOCATION_PARAMS")
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -780,10 +780,10 @@ func Init() {
|
||||
abi.uvmIoctl[nvgpu.UVM_MAP_EXTERNAL_ALLOCATION] = uvmHandler(uvmIoctlHasFrontendFD[nvgpu.UVM_MAP_EXTERNAL_ALLOCATION_PARAMS_V550], compUtil)
|
||||
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.uvmInfos[nvgpu.UVM_ALLOC_SEMAPHORE_POOL] = ioctlInfoWithStructName("UVM_ALLOC_SEMAPHORE_POOL", nvgpu.UVM_ALLOC_SEMAPHORE_POOL_PARAMS_V550{}, "UVM_ALLOC_SEMAPHORE_POOL_PARAMS")
|
||||
info.uvmInfos[nvgpu.UVM_MAP_EXTERNAL_ALLOCATION] = ioctlInfoWithStructName("UVM_MAP_EXTERNAL_ALLOCATION", nvgpu.UVM_MAP_EXTERNAL_ALLOCATION_PARAMS_V550{}, "UVM_MAP_EXTERNAL_ALLOCATION_PARAMS")
|
||||
info.UvmInfos[nvgpu.UVM_ALLOC_SEMAPHORE_POOL] = ioctlInfoWithStructName("UVM_ALLOC_SEMAPHORE_POOL", nvgpu.UVM_ALLOC_SEMAPHORE_POOL_PARAMS_V550{}, "UVM_ALLOC_SEMAPHORE_POOL_PARAMS")
|
||||
info.UvmInfos[nvgpu.UVM_MAP_EXTERNAL_ALLOCATION] = ioctlInfoWithStructName("UVM_MAP_EXTERNAL_ALLOCATION", nvgpu.UVM_MAP_EXTERNAL_ALLOCATION_PARAMS_V550{}, "UVM_MAP_EXTERNAL_ALLOCATION_PARAMS")
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -797,9 +797,9 @@ func Init() {
|
||||
abi.controlCmd[nvgpu.NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE] = ctrlHandler(rmControlSimple, compUtil)
|
||||
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.controlInfos[nvgpu.NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE] = simpleIoctlInfo("NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE", "NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE] = simpleIoctlInfo("NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE", "NV_CONF_COMPUTE_CTRL_CMD_GPU_GET_KEY_ROTATION_STATE_PARAMS")
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -820,13 +820,12 @@ func Init() {
|
||||
v555_42_02 := func() *driverABI {
|
||||
abi := v550_90_07()
|
||||
abi.allocationClass[nvgpu.NV_MEMORY_MAPPER] = allocHandler(rmAllocSimple[nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V555], nvconf.CapVideo)
|
||||
// NVC36F_CTRL_GET_CLASS_ENGINEID was deleted in 555.42.02.
|
||||
delete(abi.controlCmd, nvgpu.NVC36F_CTRL_GET_CLASS_ENGINEID)
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.allocationInfos[nvgpu.NV_MEMORY_MAPPER] = ioctlInfoWithStructName("NV_MEMORY_MAPPER", nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V555{}, "NV_MEMORY_MAPPER_ALLOCATION_PARAMS")
|
||||
delete(info.controlInfos, nvgpu.NVC36F_CTRL_GET_CLASS_ENGINEID)
|
||||
info.AllocationInfos[nvgpu.NV_MEMORY_MAPPER] = ioctlInfoWithStructName("NV_MEMORY_MAPPER", nvgpu.NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V555{}, "NV_MEMORY_MAPPER_ALLOCATION_PARAMS")
|
||||
delete(info.ControlInfos, nvgpu.NVC36F_CTRL_GET_CLASS_ENGINEID)
|
||||
return info
|
||||
}
|
||||
return abi
|
||||
@@ -843,15 +842,15 @@ func Init() {
|
||||
abi.allocationClass[nvgpu.BLACKWELL_INLINE_TO_MEMORY_A] = allocHandler(rmAllocSimple[nvgpu.NV_GR_ALLOCATION_PARAMETERS], nvconf.CapGraphics)
|
||||
abi.controlCmd[nvgpu.NV_SEMAPHORE_SURFACE_CTRL_CMD_UNBIND_CHANNEL] = ctrlHandler(rmControlSimple, nvconf.CapGraphics)
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.allocationInfos[nvgpu.NVCDB0_VIDEO_DECODER] = ioctlInfo("NVCDB0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = ioctlInfo("BLACKWELL_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_DMA_COPY_A] = ioctlInfo("BLACKWELL_DMA_COPY_A", nvgpu.NVB0B5_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_A] = ioctlInfo("BLACKWELL_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_COMPUTE_A] = ioctlInfo("BLACKWELL_COMPUTE_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_INLINE_TO_MEMORY_A] = ioctlInfo("BLACKWELL_INLINE_TO_MEMORY_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.controlInfos[nvgpu.NV_SEMAPHORE_SURFACE_CTRL_CMD_UNBIND_CHANNEL] = simpleIoctlInfo("NV_SEMAPHORE_SURFACE_CTRL_CMD_UNBIND_CHANNEL", "NV_SEMAPHORE_SURFACE_CTRL_UNBIND_CHANNEL_PARAMS")
|
||||
info.AllocationInfos[nvgpu.NVCDB0_VIDEO_DECODER] = ioctlInfo("NVCDB0_VIDEO_DECODER", nvgpu.NV_BSP_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = ioctlInfo("BLACKWELL_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_DMA_COPY_A] = ioctlInfo("BLACKWELL_DMA_COPY_A", nvgpu.NVB0B5_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_A] = ioctlInfo("BLACKWELL_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_COMPUTE_A] = ioctlInfo("BLACKWELL_COMPUTE_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_INLINE_TO_MEMORY_A] = ioctlInfo("BLACKWELL_INLINE_TO_MEMORY_A", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.ControlInfos[nvgpu.NV_SEMAPHORE_SURFACE_CTRL_CMD_UNBIND_CHANNEL] = simpleIoctlInfo("NV_SEMAPHORE_SURFACE_CTRL_CMD_UNBIND_CHANNEL", "NV_SEMAPHORE_SURFACE_CTRL_UNBIND_CHANNEL_PARAMS")
|
||||
return info
|
||||
}
|
||||
return abi
|
||||
@@ -873,18 +872,18 @@ func Init() {
|
||||
abi.allocationClass[nvgpu.BLACKWELL_COMPUTE_B] = allocHandler(rmAllocSimple[nvgpu.NV_GR_ALLOCATION_PARAMETERS], compUtil)
|
||||
abi.allocationClass[nvgpu.BLACKWELL_USERMODE_A] = allocHandler(rmAllocSimple[nvgpu.NV_HOPPER_USERMODE_A_PARAMS], compUtil)
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
info.controlInfos[nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT] = simpleIoctlInfo("NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT", "NV2080_CTRL_FB_DRAM_ENCRYPTION_INFOROM_SUPPORT_PARAMS")
|
||||
info.allocationInfos[nvgpu.TURING_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("TURING_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.allocationInfos[nvgpu.AMPERE_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("AMPERE_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.allocationInfos[nvgpu.HOPPER_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("HOPPER_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.allocationInfos[nvgpu.BLACKWELL_DMA_COPY_B] = ioctlInfo("BLACKWELL_DMA_COPY_B", nvgpu.NVB0B5_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.allocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_B] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_B", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.allocationInfos[nvgpu.BLACKWELL_B] = ioctlInfo("BLACKWELL_B", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_COMPUTE_B] = ioctlInfo("BLACKWELL_COMPUTE_B", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.allocationInfos[nvgpu.BLACKWELL_USERMODE_A] = ioctlInfo("BLACKWELL_USERMODE_A", nvgpu.NV_HOPPER_USERMODE_A_PARAMS{})
|
||||
info.ControlInfos[nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT] = simpleIoctlInfo("NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT", "NV2080_CTRL_FB_DRAM_ENCRYPTION_INFOROM_SUPPORT_PARAMS")
|
||||
info.AllocationInfos[nvgpu.TURING_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("TURING_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.AllocationInfos[nvgpu.AMPERE_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("AMPERE_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.AllocationInfos[nvgpu.HOPPER_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("HOPPER_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_DMA_COPY_B] = ioctlInfo("BLACKWELL_DMA_COPY_B", nvgpu.NVB0B5_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_A] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_A", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_CHANNEL_GPFIFO_B] = ioctlInfoWithStructName("BLACKWELL_CHANNEL_GPFIFO_B", nvgpu.NV_CHANNEL_ALLOC_PARAMS_V570{}, "NV_CHANNEL_ALLOC_PARAMS")
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_B] = ioctlInfo("BLACKWELL_B", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_COMPUTE_B] = ioctlInfo("BLACKWELL_COMPUTE_B", nvgpu.NV_GR_ALLOCATION_PARAMETERS{})
|
||||
info.AllocationInfos[nvgpu.BLACKWELL_USERMODE_A] = ioctlInfo("BLACKWELL_USERMODE_A", nvgpu.NV_HOPPER_USERMODE_A_PARAMS{})
|
||||
return info
|
||||
}
|
||||
return abi
|
||||
@@ -904,11 +903,11 @@ func Init() {
|
||||
abi.controlCmd[nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT_V575] = ctrlHandler(rmControlSimple, compUtil)
|
||||
abi.controlCmd[nvgpu.NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2] = ctrlHandler(rmControlSimple, compUtil)
|
||||
prevGetInfo := abi.getInfo
|
||||
abi.getInfo = func() *driverABIInfo {
|
||||
abi.getInfo = func() *DriverABIInfo {
|
||||
info := prevGetInfo()
|
||||
delete(info.controlInfos, nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT)
|
||||
info.controlInfos[nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT_V575] = simpleIoctlInfo("NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT", "NV2080_CTRL_FB_DRAM_ENCRYPTION_INFOROM_SUPPORT_PARAMS")
|
||||
info.controlInfos[nvgpu.NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2] = simpleIoctlInfo("NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2", "NV2080_CTRL_THERMAL_SYSTEM_EXECUTE_V2_PARAMS")
|
||||
delete(info.ControlInfos, nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT)
|
||||
info.ControlInfos[nvgpu.NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT_V575] = simpleIoctlInfo("NV2080_CTRL_CMD_FB_QUERY_DRAM_ENCRYPTION_INFOROM_SUPPORT", "NV2080_CTRL_FB_DRAM_ENCRYPTION_INFOROM_SUPPORT_PARAMS")
|
||||
info.ControlInfos[nvgpu.NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2] = simpleIoctlInfo("NV2080_CTRL_CMD_THERMAL_SYSTEM_EXECUTE_V2", "NV2080_CTRL_THERMAL_SYSTEM_EXECUTE_V2_PARAMS")
|
||||
return info
|
||||
}
|
||||
return abi
|
||||
@@ -1015,9 +1014,9 @@ func ExpectedDriverChecksum(version nvconf.DriverVersion) (Checksums, bool) {
|
||||
return abi.checksums, true
|
||||
}
|
||||
|
||||
// SupportedIoctls returns the ioctl numbers that are supported by nvproxy at
|
||||
// a given version.
|
||||
func SupportedIoctls(version nvconf.DriverVersion) (frontendIoctls map[uint32]struct{}, uvmIoctls map[uint32]struct{}, controlCmds map[uint32]struct{}, allocClasses map[uint32]struct{}, ok bool) {
|
||||
// SupportedIoctlsNumbers returns the ioctl numbers that are supported by
|
||||
// nvproxy at a given version.
|
||||
func SupportedIoctlsNumbers(version nvconf.DriverVersion) (frontendIoctls map[uint32]struct{}, uvmIoctls map[uint32]struct{}, controlCmds map[uint32]struct{}, allocClasses map[uint32]struct{}, ok bool) {
|
||||
abiCons, ok := abis[version]
|
||||
if !ok {
|
||||
return nil, nil, nil, nil, false
|
||||
@@ -1042,29 +1041,13 @@ func SupportedIoctls(version nvconf.DriverVersion) (frontendIoctls map[uint32]st
|
||||
return
|
||||
}
|
||||
|
||||
// SupportedStructTypes returns the list of struct types supported by the given driver version.
|
||||
// It merges the frontend, uvm, control, and allocation names into one slice.
|
||||
func SupportedStructTypes(version nvconf.DriverVersion) ([]DriverStruct, bool) {
|
||||
// SupportedIoctls returns the DriverABIInfo struct for the given version,
|
||||
// which describes the ioctls supported in nvproxy for the given version.
|
||||
func SupportedIoctls(version nvconf.DriverVersion) (*DriverABIInfo, bool) {
|
||||
abiCons, ok := abis[version]
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
abi := abiCons.cons()
|
||||
info := abi.getInfo()
|
||||
|
||||
var allStructs []DriverStruct
|
||||
for _, i := range info.frontendInfos {
|
||||
allStructs = append(allStructs, i.Structs...)
|
||||
}
|
||||
for _, i := range info.uvmInfos {
|
||||
allStructs = append(allStructs, i.Structs...)
|
||||
}
|
||||
for _, i := range info.controlInfos {
|
||||
allStructs = append(allStructs, i.Structs...)
|
||||
}
|
||||
for _, i := range info.allocationInfos {
|
||||
allStructs = append(allStructs, i.Structs...)
|
||||
}
|
||||
|
||||
return allStructs, true
|
||||
return abi.getInfo(), true
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ func Init() error {
|
||||
|
||||
log.Debugf("Host driver version: %v", driverVer)
|
||||
|
||||
suppFrontendIoctls, suppUvmIoctls, suppControlCmds, suppAllocClasses, ok := nvproxy.SupportedIoctls(driverVer)
|
||||
suppFrontendIoctls, suppUvmIoctls, suppControlCmds, suppAllocClasses, ok := nvproxy.SupportedIoctlsNumbers(driverVer)
|
||||
if !ok {
|
||||
return fmt.Errorf("host driver version %s is not supported", driverVer)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"os/exec"
|
||||
"path"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy"
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy/nvconf"
|
||||
)
|
||||
|
||||
@@ -50,7 +51,7 @@ func CloneDriverSource(dir string, version nvconf.DriverVersion) (*DriverSourceD
|
||||
|
||||
// CreateIncludeFiles creates the necessary include files for the given driver version, and returns
|
||||
// the config options for the files.
|
||||
func CreateIncludeFiles(dir string, driverSource DriverSourceDir) ([]ClangASTConfig, error) {
|
||||
func CreateIncludeFiles(dir string, driverSource DriverSourceDir, nonUVMIoctls, uvmIoctls []nvproxy.IoctlName) ([]ClangASTConfig, error) {
|
||||
// Create include file for non-uvm sources
|
||||
nonUVMFile, err := os.CreateTemp(dir, "include_non_uvm_*.cc")
|
||||
if err != nil {
|
||||
@@ -62,7 +63,7 @@ func CreateIncludeFiles(dir string, driverSource DriverSourceDir) ([]ClangASTCon
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get non-uvm include paths: %w", err)
|
||||
}
|
||||
if err := WriteIncludeFile(includeSources, nonUVMFile); err != nil {
|
||||
if err := WriteIncludeFile(includeSources, nonUVMFile, nonUVMIoctls); err != nil {
|
||||
return nil, fmt.Errorf("failed to write include file: %w", err)
|
||||
}
|
||||
configNonUVM := NewParserConfig(
|
||||
@@ -79,7 +80,7 @@ func CreateIncludeFiles(dir string, driverSource DriverSourceDir) ([]ClangASTCon
|
||||
defer UVMFile.Close()
|
||||
|
||||
includeSources = driverSource.GetUVMSourcePaths()
|
||||
if err := WriteIncludeFile(includeSources, UVMFile); err != nil {
|
||||
if err := WriteIncludeFile(includeSources, UVMFile, uvmIoctls); err != nil {
|
||||
return nil, fmt.Errorf("failed to write include file: %w", err)
|
||||
}
|
||||
configUVM := NewParserConfig(
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy"
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy/nvconf"
|
||||
@@ -30,6 +32,9 @@ type Runner struct {
|
||||
dir string
|
||||
parserPath string
|
||||
inputPath string
|
||||
|
||||
nonUVMIoctls []nvproxy.IoctlName
|
||||
uvmIoctls []nvproxy.IoctlName
|
||||
}
|
||||
|
||||
// NewRunner creates a new Runner around a given parser file and a temporary working directory.
|
||||
@@ -51,13 +56,43 @@ func (r *Runner) Cleanup() error {
|
||||
return os.RemoveAll(r.dir)
|
||||
}
|
||||
|
||||
// CreateStructsFile saves a list of structs for the runner to parse.
|
||||
func (r *Runner) CreateStructsFile(structs []nvproxy.DriverStruct) error {
|
||||
// CreateInputFile saves a list of structs for the runner to parse.
|
||||
func (r *Runner) CreateInputFile(info *nvproxy.DriverABIInfo) error {
|
||||
numNonUvm := len(info.FrontendInfos) + len(info.ControlInfos) + len(info.AllocationInfos)
|
||||
numUvm := len(info.UvmInfos)
|
||||
r.nonUVMIoctls = make([]nvproxy.IoctlName, 0, numNonUvm)
|
||||
r.uvmIoctls = make([]nvproxy.IoctlName, 0, numUvm)
|
||||
inputJSON := InputJSON{
|
||||
Structs: make([]string, 0, len(structs)),
|
||||
Structs: make([]nvproxy.DriverStructName, 0, numNonUvm+numUvm),
|
||||
Constants: make([]nvproxy.IoctlName, 0, numNonUvm+numUvm),
|
||||
}
|
||||
for _, structDef := range structs {
|
||||
inputJSON.Structs = append(inputJSON.Structs, structDef.Name)
|
||||
|
||||
handleIoctlInfo := func(info nvproxy.IoctlInfo, isUVM bool) {
|
||||
if info.Name == "" {
|
||||
return
|
||||
}
|
||||
if isUVM {
|
||||
r.uvmIoctls = append(r.uvmIoctls, info.Name)
|
||||
} else {
|
||||
r.nonUVMIoctls = append(r.nonUVMIoctls, info.Name)
|
||||
}
|
||||
// Add "GVISOR_" prefix to all constants; see WriteIncludeFile().
|
||||
inputJSON.Constants = append(inputJSON.Constants, "GVISOR_"+info.Name)
|
||||
for _, structDef := range info.Structs {
|
||||
inputJSON.Structs = append(inputJSON.Structs, structDef.Name)
|
||||
}
|
||||
}
|
||||
for _, info := range info.FrontendInfos {
|
||||
handleIoctlInfo(info, false)
|
||||
}
|
||||
for _, info := range info.ControlInfos {
|
||||
handleIoctlInfo(info, false)
|
||||
}
|
||||
for _, info := range info.AllocationInfos {
|
||||
handleIoctlInfo(info, false)
|
||||
}
|
||||
for _, info := range info.UvmInfos {
|
||||
handleIoctlInfo(info, true)
|
||||
}
|
||||
|
||||
f, err := os.CreateTemp(r.dir, "input_*.json")
|
||||
@@ -83,9 +118,11 @@ func (r *Runner) parseSourceFile(sourcePath string) (*OutputJSON, error) {
|
||||
|
||||
// Run driver_ast_parser on the source file.
|
||||
cmd := exec.Command(r.parserPath, "--input", r.inputPath, sourcePath)
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stderr = &stderr
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to run driver_ast_parser: %v", err)
|
||||
return nil, fmt.Errorf("failed to run driver_ast_parser: %v\n%s", err, stderr.String())
|
||||
}
|
||||
|
||||
// Unmarshal the output
|
||||
@@ -94,6 +131,13 @@ func (r *Runner) parseSourceFile(sourcePath string) (*OutputJSON, error) {
|
||||
return nil, fmt.Errorf("failed to unmarshal output file: %w", err)
|
||||
}
|
||||
|
||||
// Remove the "GVISOR_" prefix from all constants; see WriteIncludeFile().
|
||||
constants := make(map[string]uint64)
|
||||
for name, value := range defs.Constants {
|
||||
constants[strings.TrimPrefix(name, "GVISOR_")] = value
|
||||
}
|
||||
defs.Constants = constants
|
||||
|
||||
return &defs, nil
|
||||
}
|
||||
|
||||
@@ -132,7 +176,7 @@ func (r *Runner) ParseDriver(version nvconf.DriverVersion) (*OutputJSON, error)
|
||||
return nil, fmt.Errorf("failed to clone git repo: %w", err)
|
||||
}
|
||||
|
||||
config, err := CreateIncludeFiles(dir, *source)
|
||||
config, err := CreateIncludeFiles(dir, *source, r.nonUVMIoctls, r.uvmIoctls)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create include files: %w", err)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy"
|
||||
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy/nvconf"
|
||||
)
|
||||
|
||||
@@ -47,14 +48,16 @@ func (d *DriverSourceDir) GlobDriverFiles(pattern string) ([]string, error) {
|
||||
func (d *DriverSourceDir) GetNonUVMSourcePaths() ([]string, error) {
|
||||
patterns := []string{
|
||||
"src/common/sdk/nvidia/inc/nvos.h",
|
||||
"src/nvidia/arch/nvalloc/unix/include/nv_escape.h",
|
||||
"src/nvidia/arch/nvalloc/unix/include/nv-ioctl.h",
|
||||
"src/nvidia/arch/nvalloc/unix/include/nv-unix-nvos-params-wrappers.h",
|
||||
"src/common/sdk/nvidia/inc/class/*.h",
|
||||
"src/common/sdk/nvidia/inc/ctrl/*.h",
|
||||
"src/common/sdk/nvidia/inc/ctrl/*/*.h",
|
||||
"kernel-open/common/inc/nv-ioctl-numa.h",
|
||||
}
|
||||
|
||||
sources := []string{}
|
||||
var sources []string
|
||||
for _, pattern := range patterns {
|
||||
files, err := d.GlobDriverFiles(pattern)
|
||||
if err != nil {
|
||||
@@ -79,6 +82,7 @@ func (d *DriverSourceDir) GetNonUVMIncludePaths() []string {
|
||||
fmt.Sprintf("%s/src/common/sdk/nvidia/inc", d.Name()),
|
||||
fmt.Sprintf("%s/src/common/shared/inc", d.Name()),
|
||||
fmt.Sprintf("%s/src/nvidia/arch/nvalloc/unix/include", d.Name()),
|
||||
fmt.Sprintf("%s/kernel-open/common/inc", d.Name()),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,13 +94,26 @@ func (d *DriverSourceDir) GetUVMIncludePaths() []string {
|
||||
}
|
||||
|
||||
// WriteIncludeFile writes an cc file at file that includes all the given sources.
|
||||
func WriteIncludeFile(sources []string, w io.Writer) error {
|
||||
func WriteIncludeFile(sources []string, w io.Writer, ioctls []nvproxy.IoctlName) error {
|
||||
bufW := bufio.NewWriter(w)
|
||||
for _, source := range sources {
|
||||
if _, err := bufW.WriteString(fmt.Sprintf("#include \"%s\"\n", source)); err != nil {
|
||||
return fmt.Errorf("failed to write to include file: %w", err)
|
||||
}
|
||||
}
|
||||
// We need to include stdint.h for uint64_t.
|
||||
if _, err := bufW.WriteString("\n#include <stdint.h>\n\n"); err != nil {
|
||||
return fmt.Errorf("failed to write to include file: %w", err)
|
||||
}
|
||||
// The driver source code defines all ioctl numbers as macros. It is very
|
||||
// hard to evaluate the macro's numerical value in our Clang AST parser. So
|
||||
// in the source file, we create constants with name "GVISOR_<ioctl_name>"
|
||||
// which are initialized with the ioctl macro.
|
||||
for _, ioctl := range ioctls {
|
||||
if _, err := bufW.WriteString(fmt.Sprintf("const uint64_t GVISOR_%s = %s;\n", ioctl, ioctl)); err != nil {
|
||||
return fmt.Errorf("failed to write to include file: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return bufW.Flush()
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ func Main() error {
|
||||
|
||||
// Parse through nvproxy to find the list of structs used
|
||||
nvproxy.Init()
|
||||
structDefs, ok := nvproxy.SupportedStructTypes(baseVersion)
|
||||
nvproxyInfo, ok := nvproxy.SupportedIoctls(baseVersion)
|
||||
if !ok {
|
||||
return fmt.Errorf("failed to get struct names for version %v", baseVersion)
|
||||
}
|
||||
@@ -103,7 +103,7 @@ func Main() error {
|
||||
}()
|
||||
|
||||
// Write list of structs to file
|
||||
if err := runner.CreateStructsFile(structDefs); err != nil {
|
||||
if err := runner.CreateInputFile(nvproxyInfo); err != nil {
|
||||
return fmt.Errorf("failed to create temporary structs list: %w", err)
|
||||
}
|
||||
|
||||
@@ -176,18 +176,67 @@ func Main() error {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any structs from the list of struct names were missing.
|
||||
var missingStructs []nvproxy.DriverStructName
|
||||
for _, structDef := range structDefs {
|
||||
_, isRecord := recordsFound[structDef.Name]
|
||||
_, isAlias := aliasesFound[structDef.Name]
|
||||
if !isRecord && !isAlias {
|
||||
missingStructs = append(missingStructs, structDef.Name)
|
||||
log.Infof("Comparing constants between %s and %s", baseVersion, nextVersion)
|
||||
constantsFound := make(map[nvproxy.IoctlName]struct{})
|
||||
for name := range baseDefs.Constants {
|
||||
constantsFound[name] = struct{}{}
|
||||
}
|
||||
for name := range nextDefs.Constants {
|
||||
constantsFound[name] = struct{}{}
|
||||
}
|
||||
for name := range constantsFound {
|
||||
baseConstant, baseOk := baseDefs.Constants[name]
|
||||
if !baseOk {
|
||||
log.Infof("constant %s not found in first source file", name)
|
||||
}
|
||||
nextConstant, nextOk := nextDefs.Constants[name]
|
||||
if !nextOk {
|
||||
log.Infof("constant %s not found in second source file", name)
|
||||
}
|
||||
if !baseOk || !nextOk {
|
||||
continue
|
||||
}
|
||||
if baseConstant != nextConstant {
|
||||
log.Infof("constant %s changed from %d to %d", name, baseConstant, nextConstant)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if any constants or structs from the input list were missing.
|
||||
var missingStructs []nvproxy.DriverStructName
|
||||
var missingConstants []nvproxy.IoctlName
|
||||
checkMissing := func(ioctl nvproxy.IoctlInfo) {
|
||||
if ioctl.Name == "" {
|
||||
return
|
||||
}
|
||||
for _, structDef := range ioctl.Structs {
|
||||
_, isRecord := recordsFound[structDef.Name]
|
||||
_, isAlias := aliasesFound[structDef.Name]
|
||||
if !isRecord && !isAlias {
|
||||
missingStructs = append(missingStructs, structDef.Name)
|
||||
}
|
||||
}
|
||||
if _, ok := constantsFound[ioctl.Name]; !ok {
|
||||
missingConstants = append(missingConstants, ioctl.Name)
|
||||
}
|
||||
}
|
||||
for _, ioctl := range nvproxyInfo.FrontendInfos {
|
||||
checkMissing(ioctl)
|
||||
}
|
||||
for _, ioctl := range nvproxyInfo.ControlInfos {
|
||||
checkMissing(ioctl)
|
||||
}
|
||||
for _, ioctl := range nvproxyInfo.AllocationInfos {
|
||||
checkMissing(ioctl)
|
||||
}
|
||||
for _, ioctl := range nvproxyInfo.UvmInfos {
|
||||
checkMissing(ioctl)
|
||||
}
|
||||
if len(missingStructs) > 0 {
|
||||
return fmt.Errorf("expected structs not found: %v", missingStructs)
|
||||
}
|
||||
if len(missingConstants) > 0 {
|
||||
return fmt.Errorf("expected constants not found: %v", missingConstants)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user