mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Change syscall.POLL to syscall.PPOLL.
syscall.POLL is not supported on arm64, using syscall.PPOLL to support both the x86 and arm64. refs #63 Signed-off-by: Haibo Xu <haibo.xu@arm.com> Change-Id: I2c81a063d3ec4e7e6b38fe62f17a0924977f505e COPYBARA_INTEGRATE_REVIEW=https://github.com/google/gvisor/pull/543 from xiaobo55x:master ba598263fd3748d1addd48e4194080aa12085164 PiperOrigin-RevId: 260752049
This commit is contained in:
@@ -35,8 +35,14 @@ func NonBlockingPoll(fd int32, mask waiter.EventMask) waiter.EventMask {
|
||||
events: int16(mask.ToLinux()),
|
||||
}
|
||||
|
||||
ts := syscall.Timespec{
|
||||
Sec: 0,
|
||||
Nsec: 0,
|
||||
}
|
||||
|
||||
for {
|
||||
n, _, err := syscall.RawSyscall(syscall.SYS_POLL, uintptr(unsafe.Pointer(&e)), 1, 0)
|
||||
n, _, err := syscall.RawSyscall6(syscall.SYS_PPOLL, uintptr(unsafe.Pointer(&e)), 1,
|
||||
uintptr(unsafe.Pointer(&ts)), 0, 0, 0)
|
||||
// Interrupted by signal, try again.
|
||||
if err == syscall.EINTR {
|
||||
continue
|
||||
|
||||
@@ -70,7 +70,7 @@ func main() {
|
||||
syscall.SYS_NANOSLEEP: {},
|
||||
syscall.SYS_NEWFSTATAT: {},
|
||||
syscall.SYS_OPEN: {},
|
||||
syscall.SYS_POLL: {},
|
||||
syscall.SYS_PPOLL: {},
|
||||
syscall.SYS_PREAD64: {},
|
||||
syscall.SYS_PSELECT6: {},
|
||||
syscall.SYS_PWRITE64: {},
|
||||
|
||||
@@ -134,7 +134,7 @@ func (d *packetMMapDispatcher) readMMappedPacket() ([]byte, *tcpip.Error) {
|
||||
FD: int32(d.fd),
|
||||
Events: unix.POLLIN | unix.POLLERR,
|
||||
}
|
||||
if _, errno := rawfile.BlockingPoll(&event, 1, -1); errno != 0 {
|
||||
if _, errno := rawfile.BlockingPoll(&event, 1, nil); errno != 0 {
|
||||
if errno == syscall.EINTR {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -14,17 +14,18 @@
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// BlockingPoll makes the poll() syscall while calling the version of
|
||||
// BlockingPoll makes the ppoll() syscall while calling the version of
|
||||
// entersyscall that relinquishes the P so that other Gs can run. This is meant
|
||||
// to be called in cases when the syscall is expected to block.
|
||||
//
|
||||
// func BlockingPoll(fds *PollEvent, nfds int, timeout int64) (n int, err syscall.Errno)
|
||||
// func BlockingPoll(fds *PollEvent, nfds int, timeout *syscall.Timespec) (n int, err syscall.Errno)
|
||||
TEXT ·BlockingPoll(SB),NOSPLIT,$0-40
|
||||
CALL ·callEntersyscallblock(SB)
|
||||
MOVQ fds+0(FP), DI
|
||||
MOVQ nfds+8(FP), SI
|
||||
MOVQ timeout+16(FP), DX
|
||||
MOVQ $0x7, AX // SYS_POLL
|
||||
MOVQ $0x0, R10 // sigmask parameter which isn't used here
|
||||
MOVQ $0x10f, AX // SYS_PPOLL
|
||||
SYSCALL
|
||||
CMPQ AX, $0xfffffffffffff001
|
||||
JLS ok
|
||||
|
||||
@@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
//go:noescape
|
||||
func BlockingPoll(fds *PollEvent, nfds int, timeout int64) (int, syscall.Errno)
|
||||
func BlockingPoll(fds *PollEvent, nfds int, timeout *syscall.Timespec) (int, syscall.Errno)
|
||||
|
||||
// Use go:linkname to call into the runtime. As of Go 1.12 this has to
|
||||
// be done from Go code so that we make an ABIInternal call to an
|
||||
|
||||
@@ -21,9 +21,11 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// BlockingPoll is just a stub function that forwards to the poll() system call
|
||||
// BlockingPoll is just a stub function that forwards to the ppoll() system call
|
||||
// on non-amd64 platforms.
|
||||
func BlockingPoll(fds *PollEvent, nfds int, timeout int64) (int, syscall.Errno) {
|
||||
n, _, e := syscall.Syscall(syscall.SYS_POLL, uintptr(unsafe.Pointer(fds)), uintptr(nfds), uintptr(timeout))
|
||||
func BlockingPoll(fds *PollEvent, nfds int, timeout *syscall.Timespec) (int, syscall.Errno) {
|
||||
n, _, e := syscall.Syscall6(syscall.SYS_PPOLL, uintptr(unsafe.Pointer(fds)),
|
||||
uintptr(nfds), uintptr(unsafe.Pointer(timeout)), 0, 0, 0)
|
||||
|
||||
return int(n), e
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ func BlockingRead(fd int, b []byte) (int, *tcpip.Error) {
|
||||
Events: 1, // POLLIN
|
||||
}
|
||||
|
||||
_, e = BlockingPoll(&event, 1, -1)
|
||||
_, e = BlockingPoll(&event, 1, nil)
|
||||
if e != 0 && e != syscall.EINTR {
|
||||
return 0, TranslateErrno(e)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func BlockingReadv(fd int, iovecs []syscall.Iovec) (int, *tcpip.Error) {
|
||||
Events: 1, // POLLIN
|
||||
}
|
||||
|
||||
_, e = BlockingPoll(&event, 1, -1)
|
||||
_, e = BlockingPoll(&event, 1, nil)
|
||||
if e != 0 && e != syscall.EINTR {
|
||||
return 0, TranslateErrno(e)
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func BlockingRecvMMsg(fd int, msgHdrs []MMsgHdr) (int, *tcpip.Error) {
|
||||
Events: 1, // POLLIN
|
||||
}
|
||||
|
||||
if _, e := BlockingPoll(&event, 1, -1); e != 0 && e != syscall.EINTR {
|
||||
if _, e := BlockingPoll(&event, 1, nil); e != 0 && e != syscall.EINTR {
|
||||
return 0, TranslateErrno(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ package unet
|
||||
|
||||
import (
|
||||
"io"
|
||||
"math"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
@@ -53,7 +52,7 @@ func (s *Socket) wait(write bool) error {
|
||||
events[0].Events = unix.POLLOUT
|
||||
}
|
||||
|
||||
_, _, e := syscall.Syscall(syscall.SYS_POLL, uintptr(unsafe.Pointer(&events[0])), 2, uintptr(math.MaxUint64))
|
||||
_, _, e := syscall.Syscall6(syscall.SYS_PPOLL, uintptr(unsafe.Pointer(&events[0])), 2, 0, 0, 0, 0)
|
||||
if e == syscall.EINTR {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ var allowedSyscalls = seccomp.SyscallRules{
|
||||
syscall.SYS_MPROTECT: {},
|
||||
syscall.SYS_MUNMAP: {},
|
||||
syscall.SYS_NANOSLEEP: {},
|
||||
syscall.SYS_POLL: {},
|
||||
syscall.SYS_PPOLL: {},
|
||||
syscall.SYS_PREAD64: {},
|
||||
syscall.SYS_PWRITE64: {},
|
||||
syscall.SYS_READ: {},
|
||||
|
||||
@@ -138,7 +138,7 @@ var allowedSyscalls = seccomp.SyscallRules{
|
||||
syscall.SYS_NANOSLEEP: {},
|
||||
syscall.SYS_NEWFSTATAT: {},
|
||||
syscall.SYS_OPENAT: {},
|
||||
syscall.SYS_POLL: {},
|
||||
syscall.SYS_PPOLL: {},
|
||||
syscall.SYS_PREAD64: {},
|
||||
syscall.SYS_PWRITE64: {},
|
||||
syscall.SYS_READ: {},
|
||||
|
||||
Reference in New Issue
Block a user