Add a panic for no sufficient virtual memory space.

When using KVM platform at arm64 machines, gVisor will attempts to retrieve the largest possible task size and compares the size with the expected user space size. If the user space size is larger than the task size, it will lead to mmap failures, gVisor should returns an error.

PiperOrigin-RevId: 581146644
This commit is contained in:
Jing Chen
2023-11-10 00:23:33 -08:00
committed by gVisor bot
parent 9a454b63f5
commit a1be003b6f
+7
View File
@@ -18,6 +18,9 @@
package kvm
import (
"fmt"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/ring0"
"gvisor.dev/gvisor/pkg/sentry/arch"
)
@@ -65,5 +68,9 @@ func updateGlobalOnce(fd int) error {
err := updateSystemValues(int(fd))
ring0.Init()
physicalInit()
// The linux.Task represents the possible largest task size, which the UserspaceSize shouldn't be larger than.
if linux.TaskSize < ring0.UserspaceSize {
return fmt.Errorf("gVisor doesn't support 3-level page tables on KVM platform. Try to recompile the kernel with CONFIG_ARM64_VA_BITS_48")
}
return err
}