From a1be003b6f044227d17a4168925a34b6abc51520 Mon Sep 17 00:00:00 2001 From: Jing Chen Date: Fri, 10 Nov 2023 00:21:37 -0800 Subject: [PATCH] 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 --- pkg/sentry/platform/kvm/kvm_arm64.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/sentry/platform/kvm/kvm_arm64.go b/pkg/sentry/platform/kvm/kvm_arm64.go index 60714d781..0157f2731 100644 --- a/pkg/sentry/platform/kvm/kvm_arm64.go +++ b/pkg/sentry/platform/kvm/kvm_arm64.go @@ -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 }