Add support for restoring nvproxy.driverABI.

Fixes #9649

PiperOrigin-RevId: 580251470
This commit is contained in:
Ayush Ranjan
2023-11-07 11:47:59 -08:00
committed by gVisor bot
parent 47db4119a2
commit 999c708319
4 changed files with 34 additions and 1 deletions
+1
View File
@@ -21,6 +21,7 @@ go_library(
"nvproxy.go",
"nvproxy_unsafe.go",
"objs_mutex.go",
"save_restore.go",
"seccomp_filters.go",
"uvm.go",
"uvm_mmap.go",
+3 -1
View File
@@ -50,6 +50,7 @@ func Register(vfsObj *vfs.VirtualFilesystem, uvmDevMajor uint32) error {
nvp := &nvproxy{
objsLive: make(map[nvgpu.Handle]*object),
abi: abiCons.cons(),
version: version,
}
for minor := uint32(0); minor <= nvgpu.NV_CONTROL_DEVICE_MINOR; minor++ {
if err := vfsObj.RegisterDevice(vfs.CharDevice, nvgpu.NV_MAJOR_DEVICE_NUMBER, minor, &frontendDevice{
@@ -75,7 +76,8 @@ func Register(vfsObj *vfs.VirtualFilesystem, uvmDevMajor uint32) error {
type nvproxy struct {
objsMu objsMutex `state:"nosave"`
objsLive map[nvgpu.Handle]*object
abi *driverABI
abi *driverABI `state:"nosave"`
version DriverVersion
}
// object tracks an object allocated through the driver.
@@ -0,0 +1,28 @@
// Copyright 2023 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package nvproxy
import (
"fmt"
)
func (n *nvproxy) afterLoad() {
Init()
abiCons, ok := abis[n.version]
if !ok {
panic(fmt.Sprintf("driver version %q not found in abis map", n.version))
}
n.abi = abiCons.cons()
}
+2
View File
@@ -24,6 +24,8 @@ import (
)
// DriverVersion represents a NVIDIA driver version patch release.
//
// +stateify savable
type DriverVersion struct {
major int
minor int