summaryrefslogtreecommitdiffhomepage
path: root/pkg/flipcall
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
committergVisor bot <gvisor-bot@google.com>2021-03-03 18:43:27 +0000
commitaae5455fe381c4cbc956f61c971284ee05c52dfc (patch)
tree2b1cb0233968680dcd0374f20ee826cf311bda95 /pkg/flipcall
parente2599d556573b05eb3714c1e791fa29431dc3d3f (diff)
parenta9441aea2780da8c93da1c73da860219f98438de (diff)
Merge release-20210301.0-5-ga9441aea2 (automated)
Diffstat (limited to 'pkg/flipcall')
-rw-r--r--pkg/flipcall/flipcall.go5
-rw-r--r--pkg/flipcall/futex_linux.go10
-rw-r--r--pkg/flipcall/packet_window_allocator.go10
-rw-r--r--pkg/flipcall/packet_window_mmap_amd64.go8
-rw-r--r--pkg/flipcall/packet_window_mmap_arm64.go8
5 files changed, 19 insertions, 22 deletions
diff --git a/pkg/flipcall/flipcall.go b/pkg/flipcall/flipcall.go
index c4a3366ce..8d8309a73 100644
--- a/pkg/flipcall/flipcall.go
+++ b/pkg/flipcall/flipcall.go
@@ -20,7 +20,8 @@ import (
"fmt"
"math"
"sync/atomic"
- "syscall"
+
+ "golang.org/x/sys/unix"
)
// An Endpoint provides the ability to synchronously transfer data and control
@@ -130,7 +131,7 @@ func (ep *Endpoint) Destroy() {
}
func (ep *Endpoint) unmapPacket() {
- syscall.RawSyscall(syscall.SYS_MUNMAP, ep.packet, uintptr(ep.dataCap)+PacketHeaderBytes, 0)
+ unix.RawSyscall(unix.SYS_MUNMAP, ep.packet, uintptr(ep.dataCap)+PacketHeaderBytes, 0)
ep.packet = 0
}
diff --git a/pkg/flipcall/futex_linux.go b/pkg/flipcall/futex_linux.go
index 0e559ee16..c212f05f1 100644
--- a/pkg/flipcall/futex_linux.go
+++ b/pkg/flipcall/futex_linux.go
@@ -20,8 +20,8 @@ import (
"fmt"
"runtime"
"sync/atomic"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/abi/linux"
)
@@ -66,22 +66,22 @@ func (ep *Endpoint) futexWaitUntilActive() error {
}
func (ep *Endpoint) futexWakeConnState(numThreads int32) error {
- if _, _, e := syscall.RawSyscall(syscall.SYS_FUTEX, ep.packet, linux.FUTEX_WAKE, uintptr(numThreads)); e != 0 {
+ if _, _, e := unix.RawSyscall(unix.SYS_FUTEX, ep.packet, linux.FUTEX_WAKE, uintptr(numThreads)); e != 0 {
return e
}
return nil
}
func (ep *Endpoint) futexWaitConnState(curState uint32) error {
- _, _, e := syscall.Syscall6(syscall.SYS_FUTEX, ep.packet, linux.FUTEX_WAIT, uintptr(curState), 0, 0, 0)
- if e != 0 && e != syscall.EAGAIN && e != syscall.EINTR {
+ _, _, e := unix.Syscall6(unix.SYS_FUTEX, ep.packet, linux.FUTEX_WAIT, uintptr(curState), 0, 0, 0)
+ if e != 0 && e != unix.EAGAIN && e != unix.EINTR {
return e
}
return nil
}
func yieldThread() {
- syscall.Syscall(syscall.SYS_SCHED_YIELD, 0, 0, 0)
+ unix.Syscall(unix.SYS_SCHED_YIELD, 0, 0, 0)
// The thread we're trying to yield to may be waiting for a Go runtime P.
// runtime.Gosched() will hand off ours if necessary.
runtime.Gosched()
diff --git a/pkg/flipcall/packet_window_allocator.go b/pkg/flipcall/packet_window_allocator.go
index af9cc3d21..9122c97b7 100644
--- a/pkg/flipcall/packet_window_allocator.go
+++ b/pkg/flipcall/packet_window_allocator.go
@@ -18,8 +18,8 @@ import (
"fmt"
"math/bits"
"os"
- "syscall"
+ "golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/abi/linux"
"gvisor.dev/gvisor/pkg/memutil"
)
@@ -85,8 +85,8 @@ func (pwa *PacketWindowAllocator) Init() error {
// Apply F_SEAL_SHRINK to prevent either party from causing SIGBUS in the
// other by truncating the file, and F_SEAL_SEAL to prevent either party
// from applying F_SEAL_GROW or F_SEAL_WRITE.
- if _, _, e := syscall.RawSyscall(syscall.SYS_FCNTL, uintptr(fd), linux.F_ADD_SEALS, linux.F_SEAL_SHRINK|linux.F_SEAL_SEAL); e != 0 {
- syscall.Close(fd)
+ if _, _, e := unix.RawSyscall(unix.SYS_FCNTL, uintptr(fd), linux.F_ADD_SEALS, linux.F_SEAL_SHRINK|linux.F_SEAL_SEAL); e != 0 {
+ unix.Close(fd)
return fmt.Errorf("failed to apply memfd seals: %v", e)
}
pwa.fd = fd
@@ -106,7 +106,7 @@ func NewPacketWindowAllocator() (*PacketWindowAllocator, error) {
// Destroy releases resources owned by pwa. This invalidates file descriptors
// previously returned by pwa.FD() and pwd.Allocate().
func (pwa *PacketWindowAllocator) Destroy() {
- syscall.Close(pwa.fd)
+ unix.Close(pwa.fd)
}
// FD represents the file descriptor of the shared memory file backing pwa.
@@ -158,7 +158,7 @@ func (pwa *PacketWindowAllocator) ensureFileSize(min int64) error {
}
newSize = newNewSize
}
- if err := syscall.Ftruncate(pwa.FD(), newSize); err != nil {
+ if err := unix.Ftruncate(pwa.FD(), newSize); err != nil {
return fmt.Errorf("ftruncate failed: %v", err)
}
pwa.fileSize = newSize
diff --git a/pkg/flipcall/packet_window_mmap_amd64.go b/pkg/flipcall/packet_window_mmap_amd64.go
index 869183b11..ced587a2a 100644
--- a/pkg/flipcall/packet_window_mmap_amd64.go
+++ b/pkg/flipcall/packet_window_mmap_amd64.go
@@ -14,12 +14,10 @@
package flipcall
-import (
- "syscall"
-)
+import "golang.org/x/sys/unix"
// Return a memory mapping of the pwd in memory that can be shared outside the sandbox.
-func packetWindowMmap(pwd PacketWindowDescriptor) (uintptr, syscall.Errno) {
- m, _, err := syscall.RawSyscall6(syscall.SYS_MMAP, 0, uintptr(pwd.Length), syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED, uintptr(pwd.FD), uintptr(pwd.Offset))
+func packetWindowMmap(pwd PacketWindowDescriptor) (uintptr, unix.Errno) {
+ m, _, err := unix.RawSyscall6(unix.SYS_MMAP, 0, uintptr(pwd.Length), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED, uintptr(pwd.FD), uintptr(pwd.Offset))
return m, err
}
diff --git a/pkg/flipcall/packet_window_mmap_arm64.go b/pkg/flipcall/packet_window_mmap_arm64.go
index b9c9c44f6..87ad1a4a1 100644
--- a/pkg/flipcall/packet_window_mmap_arm64.go
+++ b/pkg/flipcall/packet_window_mmap_arm64.go
@@ -16,12 +16,10 @@
package flipcall
-import (
- "syscall"
-)
+import "golang.org/x/sys/unix"
// Return a memory mapping of the pwd in memory that can be shared outside the sandbox.
-func packetWindowMmap(pwd PacketWindowDescriptor) (uintptr, syscall.Errno) {
- m, _, err := syscall.RawSyscall6(syscall.SYS_MMAP, 0, uintptr(pwd.Length), syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_SHARED, uintptr(pwd.FD), uintptr(pwd.Offset))
+func packetWindowMmap(pwd PacketWindowDescriptor) (uintptr, unix.Errno) {
+ m, _, err := unix.RawSyscall6(unix.SYS_MMAP, 0, uintptr(pwd.Length), unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED, uintptr(pwd.FD), uintptr(pwd.Offset))
return m, err
}