Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pkg/sentry/devices/nvproxy/nvconf/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func NewDriverVersion(major, minor, patch int) DriverVersion {
// DriverVersionFrom returns a DriverVersion from a string.
func DriverVersionFrom(version string) (DriverVersion, error) {
parts := strings.Split(version, ".")
if len(parts) != 3 {
if len(parts) < 2 || len(parts) > 3 {
return DriverVersion{}, fmt.Errorf("invalid format of version string %q", version)
}
var (
Expand All @@ -52,9 +52,13 @@ func DriverVersionFrom(version string) (DriverVersion, error) {
if err != nil {
return DriverVersion{}, fmt.Errorf("invalid format for minor version %q: %v", version, err)
}
res.patch, err = strconv.Atoi(parts[2])
if err != nil {
return DriverVersion{}, fmt.Errorf("invalid format for patch version %q: %v", version, err)
if len(parts) == 3 {
res.patch, err = strconv.Atoi(parts[2])
if err != nil {
return DriverVersion{}, fmt.Errorf("invalid format for patch version %q: %v", version, err)
}
} else {
res.patch = 0
}
return res, nil
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/sentry/devices/nvproxy/nvproxy_driver_parity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package nvproxy_driver_parity_test

import (
"context"
"errors"
"fmt"
"reflect"
"regexp"
Expand Down Expand Up @@ -70,6 +71,9 @@ func getDriverDefs(t *testing.T, runner *parser.Runner, version nvconf.DriverVer
// Run parser
defs, err := runner.ParseDriver(version)
if err != nil {
if errors.Is(err, parser.ErrDriverSourceNotFound) {
t.Skipf("Skipping parity test for %s because driver source is not available: %v", version, err)
}
t.Fatalf("failed to run driver_ast_parser: %v", err)
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/sentry/devices/nvproxy/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ func Init() {

v595_71_05 := addUnsupportedDriverABI(595, 71, 05, v590_48_01)

_ = addUnsupportedDriverABI(610, 43, 02, func() *driverABI {
v610_43_02 := addUnsupportedDriverABI(610, 43, 02, func() *driverABI {
abi := v595_71_05()
// UVM range groups were removed in 610.43.02.
delete(abi.uvmIoctl, nvgpu.UVM_CREATE_RANGE_GROUP)
Expand Down Expand Up @@ -1161,6 +1161,8 @@ func Init() {
}
return abi
})

_ = addDriverABI(615, 15, 00, ChecksumNoDriver, "d5a40daa72e011395721f2a3de8598b77c3271eec057948de9b3d1755d8d02bc", v610_43_02)
})
}

Expand Down
27 changes: 26 additions & 1 deletion tools/gpu/drivers/install_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ type Installer struct {
installFunc func(string) error
}

func latestInstallableDriver() (nvconf.DriverVersion, error) {
var latest nvconf.DriverVersion
var found bool
nvproxy.ForEachSupportDriver(func(version nvconf.DriverVersion, checksums nvproxy.Checksums) {
checksum, err := checksums.Checksum()
if err != nil {
return
}
if checksum != nvproxy.ChecksumNoDriver && checksum != "" {
if version.IsGreaterThan(latest) {
latest = version
found = true
}
}
})
if !found {
return nvconf.DriverVersion{}, fmt.Errorf("no installable driver found for arch %q", runtime.GOARCH)
}
return latest, nil
}

// NewInstaller returns a driver installer instance.
func NewInstaller(requestedVersion string, latest bool) (*Installer, error) {

Expand All @@ -77,7 +98,11 @@ func NewInstaller(requestedVersion string, latest bool) (*Installer, error) {
}
switch {
case latest:
ret.requestedVersion = nvproxy.LatestDriver()
version, err := latestInstallableDriver()
if err != nil {
return nil, err
}
ret.requestedVersion = version
default:
d, err := nvconf.DriverVersionFrom(requestedVersion)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions tools/nvidia_driver_differ/parser/auxiliary_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@
package parser

import (
"errors"
"fmt"
"os"
"os/exec"
"path"
"strings"

"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy"
"gvisor.dev/gvisor/pkg/sentry/devices/nvproxy/nvconf"
)

// ErrDriverSourceNotFound is returned when the driver source code cannot be found.
var ErrDriverSourceNotFound = errors.New("driver source not found")

// GitRepoURL is the URL for the NVIDIA open-gpu-kernel-modules repo.
const GitRepoURL = "https://github.com/NVIDIA/open-gpu-kernel-modules.git"

Expand All @@ -41,6 +46,9 @@ func CloneDriverSource(dir string, version nvconf.DriverVersion) (*DriverSourceD
}
cmd := exec.Command("git", args...)
if out, err := cmd.CombinedOutput(); err != nil {
if strings.Contains(string(out), "not found in upstream origin") {
return nil, fmt.Errorf("%w: %s", ErrDriverSourceNotFound, string(out))
}
return nil, fmt.Errorf("failed to clone %s: %w\n%s", version, err, string(out))
}
return &DriverSourceDir{
Expand Down
Loading