summaryrefslogtreecommitdiffhomepage
path: root/pkg/abi
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-10-21 23:10:52 +0000
committergVisor bot <gvisor-bot@google.com>2021-10-21 23:10:52 +0000
commiteff88efe81e2a2dcc0ee541e90755d4d21374315 (patch)
tree967638a38d03d2c6e778cab057a6558d71e4ec2c /pkg/abi
parentac2e48668b599b3d3b0b4f5c4453b61773cae6fd (diff)
parent14f4113924c8b7b8c161be7335b147106d0c4a26 (diff)
Merge release-20211011.0-59-g14f411392 (automated)
Diffstat (limited to 'pkg/abi')
-rw-r--r--pkg/abi/linux/fs.go1
-rw-r--r--pkg/abi/linux/linux_abi_autogen_unsafe.go107
-rw-r--r--pkg/abi/linux/mqueue.go55
3 files changed, 163 insertions, 0 deletions
diff --git a/pkg/abi/linux/fs.go b/pkg/abi/linux/fs.go
index cad24fcc7..edc90e54c 100644
--- a/pkg/abi/linux/fs.go
+++ b/pkg/abi/linux/fs.go
@@ -23,6 +23,7 @@ const (
DEVPTS_SUPER_MAGIC = 0x00001cd1
EXT_SUPER_MAGIC = 0xef53
FUSE_SUPER_MAGIC = 0x65735546
+ MQUEUE_MAGIC = 0x19800202
OVERLAYFS_SUPER_MAGIC = 0x794c7630
PIPEFS_MAGIC = 0x50495045
PROC_SUPER_MAGIC = 0x9fa0
diff --git a/pkg/abi/linux/linux_abi_autogen_unsafe.go b/pkg/abi/linux/linux_abi_autogen_unsafe.go
index cd5786d12..b71bd1432 100644
--- a/pkg/abi/linux/linux_abi_autogen_unsafe.go
+++ b/pkg/abi/linux/linux_abi_autogen_unsafe.go
@@ -79,6 +79,7 @@ var _ marshal.Marshallable = (*KernelIP6TGetEntries)(nil)
var _ marshal.Marshallable = (*KernelIPTEntry)(nil)
var _ marshal.Marshallable = (*KernelIPTGetEntries)(nil)
var _ marshal.Marshallable = (*Linger)(nil)
+var _ marshal.Marshallable = (*MqAttr)(nil)
var _ marshal.Marshallable = (*MsgBuf)(nil)
var _ marshal.Marshallable = (*MsgInfo)(nil)
var _ marshal.Marshallable = (*MsqidDS)(nil)
@@ -5266,6 +5267,112 @@ func (n *NumaPolicy) WriteTo(w io.Writer) (int64, error) {
return int64(length), err
}
+// SizeBytes implements marshal.Marshallable.SizeBytes.
+func (m *MqAttr) SizeBytes() int {
+ return 32 +
+ 8*4
+}
+
+// MarshalBytes implements marshal.Marshallable.MarshalBytes.
+func (m *MqAttr) MarshalBytes(dst []byte) {
+ hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.MqFlags))
+ dst = dst[8:]
+ hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.MqMaxmsg))
+ dst = dst[8:]
+ hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.MqMsgsize))
+ dst = dst[8:]
+ hostarch.ByteOrder.PutUint64(dst[:8], uint64(m.MqCurmsgs))
+ dst = dst[8:]
+ // Padding: dst[:sizeof(int64)*4] ~= [4]int64{0}
+ dst = dst[8*(4):]
+}
+
+// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
+func (m *MqAttr) UnmarshalBytes(src []byte) {
+ m.MqFlags = int64(hostarch.ByteOrder.Uint64(src[:8]))
+ src = src[8:]
+ m.MqMaxmsg = int64(hostarch.ByteOrder.Uint64(src[:8]))
+ src = src[8:]
+ m.MqMsgsize = int64(hostarch.ByteOrder.Uint64(src[:8]))
+ src = src[8:]
+ m.MqCurmsgs = int64(hostarch.ByteOrder.Uint64(src[:8]))
+ src = src[8:]
+ // Padding: ~ copy([4]int64(m._), src[:sizeof(int64)*4])
+ src = src[8*(4):]
+}
+
+// Packed implements marshal.Marshallable.Packed.
+//go:nosplit
+func (m *MqAttr) Packed() bool {
+ return true
+}
+
+// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
+func (m *MqAttr) MarshalUnsafe(dst []byte) {
+ gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(m), uintptr(m.SizeBytes()))
+}
+
+// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
+func (m *MqAttr) UnmarshalUnsafe(src []byte) {
+ gohacks.Memmove(unsafe.Pointer(m), unsafe.Pointer(&src[0]), uintptr(m.SizeBytes()))
+}
+
+// CopyOutN implements marshal.Marshallable.CopyOutN.
+//go:nosplit
+func (m *MqAttr) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
+ // Construct a slice backed by dst's underlying memory.
+ var buf []byte
+ hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
+ hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m)))
+ hdr.Len = m.SizeBytes()
+ hdr.Cap = m.SizeBytes()
+
+ length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
+ // Since we bypassed the compiler's escape analysis, indicate that m
+ // must live until the use above.
+ runtime.KeepAlive(m) // escapes: replaced by intrinsic.
+ return length, err
+}
+
+// CopyOut implements marshal.Marshallable.CopyOut.
+//go:nosplit
+func (m *MqAttr) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
+ return m.CopyOutN(cc, addr, m.SizeBytes())
+}
+
+// CopyIn implements marshal.Marshallable.CopyIn.
+//go:nosplit
+func (m *MqAttr) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
+ // Construct a slice backed by dst's underlying memory.
+ var buf []byte
+ hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
+ hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m)))
+ hdr.Len = m.SizeBytes()
+ hdr.Cap = m.SizeBytes()
+
+ length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
+ // Since we bypassed the compiler's escape analysis, indicate that m
+ // must live until the use above.
+ runtime.KeepAlive(m) // escapes: replaced by intrinsic.
+ return length, err
+}
+
+// WriteTo implements io.WriterTo.WriteTo.
+func (m *MqAttr) WriteTo(writer io.Writer) (int64, error) {
+ // Construct a slice backed by dst's underlying memory.
+ var buf []byte
+ hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
+ hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(m)))
+ hdr.Len = m.SizeBytes()
+ hdr.Cap = m.SizeBytes()
+
+ length, err := writer.Write(buf)
+ // Since we bypassed the compiler's escape analysis, indicate that m
+ // must live until the use above.
+ runtime.KeepAlive(m) // escapes: replaced by intrinsic.
+ return int64(length), err
+}
+
// Packed implements marshal.Marshallable.Packed.
//go:nosplit
func (b *MsgBuf) Packed() bool {
diff --git a/pkg/abi/linux/mqueue.go b/pkg/abi/linux/mqueue.go
new file mode 100644
index 000000000..4988a2aa3
--- /dev/null
+++ b/pkg/abi/linux/mqueue.go
@@ -0,0 +1,55 @@
+// Copyright 2021 The gVisor Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package linux
+
+// Default values for POSIX message queues. Source:
+// include/linux/ipc_namespace.h
+const (
+ DFLT_QUEUESMAX = 256
+ MIN_MSGMAX = 1
+ DFLT_MSG uint = 10
+ DFLT_MSGMAX = 10
+ HARD_MSGMAX = 65536
+ MIN_MSGSIZEMAX = 128
+ DFLT_MSGSIZE uint = 8192
+ DFLT_MSGSIZEMAX = 8192
+ HARD_MSGSIZEMAX = (16 * 1024 * 1024)
+)
+
+// Maximum values for a message queue. Source: include/uapi/linux/mqueue.h
+const (
+ MQ_PRIO_MAX = 32768
+ MQ_BYTES_MAX = 819200
+)
+
+// Codes used by mq_notify. Source: include/uapi/linux/mqueue.h
+const (
+ NOTIFY_NONE = 0
+ NOTIFY_WOKENUP = 1
+ NOTIFY_REMOVED = 2
+
+ NOTIFY_COOKIE_LEN = 32
+)
+
+// MqAttr is equivelant to struct mq_attr. Source: include/uapi/linux/mqueue.h
+//
+// +marshal
+type MqAttr struct {
+ MqFlags int64 // Message queue flags.
+ MqMaxmsg int64 // Maximum number of messages.
+ MqMsgsize int64 // Maximum message size.
+ MqCurmsgs int64 // Number of messages currently queued.
+ _ [4]int64 // Ignored for input, zeroed for output.
+}