mirror of
https://github.com/hanzoai/visor.git
synced 2026-09-24 17:04:14 +00:00
Mark all ABI structs with structs.HostLayout; verify this remains true.
This change marks all ABI-related structs with `structs.HostLayout`, which was introduced in Go 1.23: https://pkg.go.dev/[email protected]#HostLayout This is intended to force the Go compiler to preserve the layout of the struct, removing it from the liberty of reordering fields as it sees fit. Adds a check automatically generated by our `go_library` rule wrapper which verifies this recursively for all exported structs in a package. Fixes issue #10693. PiperOrigin-RevId: 860238103
This commit is contained in:
committed by
gVisor bot
parent
3926089572
commit
056a85f39d
@@ -12,5 +12,6 @@ go_library(
|
||||
"abi_linux.go",
|
||||
"flag.go",
|
||||
],
|
||||
hostlayout = True,
|
||||
visibility = ["//:sandbox"],
|
||||
)
|
||||
|
||||
@@ -8,5 +8,6 @@ package(
|
||||
go_library(
|
||||
name = "attestation",
|
||||
srcs = ["attestation.go"],
|
||||
hostlayout = True,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
// Package attestation includes definitions needed for gVisor attestation.
|
||||
package attestation
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Attestation ioctls.
|
||||
const (
|
||||
SIGN_ATTESTATION_REPORT = 0
|
||||
@@ -29,7 +33,8 @@ const SizeOfQuoteInputData = 64
|
||||
// size is an input that specifies the size of buf. When returned, it's updated
|
||||
// to the size of quote.
|
||||
type SignReport struct {
|
||||
_ structs.HostLayout
|
||||
data [64]byte
|
||||
size uint32
|
||||
buf []byte
|
||||
buf []byte `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ go_library(
|
||||
srcs = [
|
||||
"gasket.go",
|
||||
],
|
||||
hostlayout = True,
|
||||
marshal = True,
|
||||
visibility = ["//pkg/sentry:internal"],
|
||||
deps = ["//pkg/abi/linux"],
|
||||
|
||||
@@ -17,6 +17,7 @@ package gasket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi/linux"
|
||||
)
|
||||
@@ -80,6 +81,7 @@ func (i Ioctl) String() string {
|
||||
//
|
||||
// +marshal
|
||||
type GasketInterruptEventFd struct {
|
||||
_ structs.HostLayout
|
||||
Interrupt uint64
|
||||
EventFD uint64
|
||||
}
|
||||
@@ -89,6 +91,7 @@ type GasketInterruptEventFd struct {
|
||||
//
|
||||
// +marshal
|
||||
type GasketPageTableIoctl struct {
|
||||
_ structs.HostLayout
|
||||
PageTableIndex uint64
|
||||
Size uint64
|
||||
HostAddress uint64
|
||||
@@ -101,6 +104,7 @@ type GasketPageTableIoctl struct {
|
||||
//
|
||||
// +marshal
|
||||
type GasketInterruptMapping struct {
|
||||
_ structs.HostLayout
|
||||
Interrupt uint64
|
||||
EventFD uint64
|
||||
BarIndex uint64
|
||||
@@ -112,6 +116,7 @@ type GasketInterruptMapping struct {
|
||||
//
|
||||
// +marshal
|
||||
type GasketPageTableDmaBufIoctl struct {
|
||||
_ structs.HostLayout
|
||||
PageTableIndex uint64
|
||||
DeviceAddress uint64
|
||||
DMABufID int32 `marshal:"unaligned"` // Struct ends mid 64bit word.
|
||||
|
||||
@@ -88,6 +88,7 @@ go_library(
|
||||
"wait.go",
|
||||
"xattr.go",
|
||||
],
|
||||
hostlayout = True,
|
||||
marshal = True,
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
|
||||
@@ -14,11 +14,15 @@
|
||||
|
||||
package linux
|
||||
|
||||
import "encoding/binary"
|
||||
import (
|
||||
"encoding/binary"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// AIORing is struct aio_ring, from fs/aio.c, without the trailing
|
||||
// variable-length array.
|
||||
type AIORing struct {
|
||||
_ structs.HostLayout
|
||||
ID uint32
|
||||
Nr uint32
|
||||
Head uint32
|
||||
@@ -62,6 +66,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IOCallback struct {
|
||||
_ structs.HostLayout
|
||||
Data uint64
|
||||
Key uint32
|
||||
_ uint32
|
||||
@@ -86,6 +91,7 @@ type IOCallback struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type IOEvent struct {
|
||||
_ structs.HostLayout
|
||||
Data uint64
|
||||
Obj uint64
|
||||
Result int64
|
||||
|
||||
@@ -14,11 +14,16 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// BPFInstruction is a raw BPF virtual machine instruction.
|
||||
//
|
||||
// +marshal slice:BPFInstructionSlice
|
||||
// +stateify savable
|
||||
type BPFInstruction struct {
|
||||
_ structs.HostLayout
|
||||
// OpCode is the operation to execute.
|
||||
OpCode uint16
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package linux
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// A Capability represents the ability to perform a privileged operation.
|
||||
@@ -254,6 +255,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type VfsCapData struct {
|
||||
_ structs.HostLayout
|
||||
MagicEtc uint32
|
||||
PermittedLo uint32
|
||||
InheritableLo uint32
|
||||
@@ -287,6 +289,7 @@ func (c *VfsCapData) ToString() string {
|
||||
//
|
||||
// +marshal
|
||||
type VfsNsCapData struct {
|
||||
_ structs.HostLayout
|
||||
VfsCapData
|
||||
RootID uint32
|
||||
}
|
||||
@@ -323,6 +326,7 @@ func (c *VfsNsCapData) ToString() string {
|
||||
//
|
||||
// +marshal
|
||||
type CapUserHeader struct {
|
||||
_ structs.HostLayout
|
||||
Version uint32
|
||||
Pid int32
|
||||
}
|
||||
@@ -331,6 +335,7 @@ type CapUserHeader struct {
|
||||
//
|
||||
// +marshal slice:CapUserDataSlice
|
||||
type CapUserData struct {
|
||||
_ structs.HostLayout
|
||||
Effective uint32
|
||||
Permitted uint32
|
||||
Inheritable uint32
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Clone constants per clone(2).
|
||||
const (
|
||||
CSIGNAL = 0xff
|
||||
@@ -57,6 +61,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type CloneArgs struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint64
|
||||
Pidfd uint64
|
||||
ChildTID uint64
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Linux auxiliary vector entry types.
|
||||
const (
|
||||
// AT_NULL is the end of the auxiliary vector.
|
||||
@@ -111,6 +115,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type ElfHeader64 struct {
|
||||
_ structs.HostLayout
|
||||
Ident [16]byte // File identification.
|
||||
Type uint16 // File type.
|
||||
Machine uint16 // Machine architecture.
|
||||
@@ -131,6 +136,7 @@ type ElfHeader64 struct {
|
||||
//
|
||||
// +marshal
|
||||
type ElfSection64 struct {
|
||||
_ structs.HostLayout
|
||||
Name uint32 // Section name (index into the section header string table).
|
||||
Type uint32 // Section type.
|
||||
Flags uint64 // Section flags.
|
||||
@@ -147,6 +153,7 @@ type ElfSection64 struct {
|
||||
//
|
||||
// +marshal
|
||||
type ElfProg64 struct {
|
||||
_ structs.HostLayout
|
||||
Type uint32 // Entry type.
|
||||
Flags uint32 // Access permission flags.
|
||||
Off uint64 // File offset of contents.
|
||||
|
||||
@@ -17,10 +17,15 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// EpollEvent is equivalent to struct epoll_event from epoll(2).
|
||||
//
|
||||
// +marshal slice:EpollEventSlice
|
||||
type EpollEvent struct {
|
||||
_ structs.HostLayout
|
||||
Events uint32
|
||||
// Linux makes struct epoll_event::data a __u64. We represent it as
|
||||
// [2]int32 because, on amd64, Linux also makes struct epoll_event
|
||||
|
||||
@@ -17,10 +17,15 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// EpollEvent is equivalent to struct epoll_event from epoll(2).
|
||||
//
|
||||
// +marshal slice:EpollEventSlice
|
||||
type EpollEvent struct {
|
||||
_ structs.HostLayout
|
||||
Events uint32
|
||||
// Linux makes struct epoll_event a __u64, necessitating 4 bytes of padding
|
||||
// here.
|
||||
|
||||
@@ -8,5 +8,6 @@ package(
|
||||
go_library(
|
||||
name = "errno",
|
||||
srcs = ["errno.go"],
|
||||
hostlayout = True,
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
)
|
||||
|
||||
@@ -31,6 +33,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type SockExtendedErr struct {
|
||||
_ structs.HostLayout
|
||||
Errno uint32
|
||||
Origin uint8
|
||||
Type uint8
|
||||
@@ -54,6 +57,7 @@ type SockErrCMsg interface {
|
||||
//
|
||||
// +marshal
|
||||
type SockErrCMsgIPv4 struct {
|
||||
_ structs.HostLayout
|
||||
SockExtendedErr
|
||||
Offender SockAddrInet
|
||||
}
|
||||
@@ -76,6 +80,7 @@ func (*SockErrCMsgIPv4) CMsgType() uint32 {
|
||||
//
|
||||
// +marshal
|
||||
type SockErrCMsgIPv6 struct {
|
||||
_ structs.HostLayout
|
||||
SockExtendedErr
|
||||
Offender SockAddrInet6
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Commands from linux/fcntl.h.
|
||||
const (
|
||||
F_DUPFD = 0
|
||||
@@ -54,6 +58,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Flock struct {
|
||||
_ structs.HostLayout
|
||||
Type int16
|
||||
Whence int16
|
||||
_ [4]byte
|
||||
@@ -74,6 +79,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type FOwnerEx struct {
|
||||
_ structs.HostLayout
|
||||
Type int32
|
||||
PID int32
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package linux
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/abi"
|
||||
)
|
||||
@@ -284,6 +285,7 @@ const (
|
||||
//
|
||||
// +marshal boundCheck slice:StatxSlice
|
||||
type Statx struct {
|
||||
_ structs.HostLayout
|
||||
Mask uint32
|
||||
Blksize uint32
|
||||
Attributes uint64
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Constants for open(2).
|
||||
const (
|
||||
O_DIRECT = 000040000
|
||||
@@ -29,6 +33,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Stat struct {
|
||||
_ structs.HostLayout
|
||||
Dev uint64
|
||||
Ino uint64
|
||||
Nlink uint64
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Constants for open(2).
|
||||
const (
|
||||
O_DIRECTORY = 000040000
|
||||
@@ -29,6 +33,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Stat struct {
|
||||
_ structs.HostLayout
|
||||
Dev uint64
|
||||
Ino uint64
|
||||
Mode uint32
|
||||
|
||||
@@ -16,6 +16,7 @@ package linux
|
||||
|
||||
import (
|
||||
"math"
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
@@ -66,6 +67,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Statfs struct {
|
||||
_ structs.HostLayout
|
||||
// Type is one of the filesystem magic values, defined above.
|
||||
Type uint64
|
||||
|
||||
|
||||
+44
-4
@@ -15,6 +15,7 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
"time"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal/primitive"
|
||||
@@ -93,6 +94,7 @@ const (
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type FUSEHeaderIn struct {
|
||||
_ structs.HostLayout
|
||||
// Len specifies the total length of the data, including this header.
|
||||
Len uint32
|
||||
|
||||
@@ -127,6 +129,7 @@ var SizeOfFUSEHeaderIn = uint32((*FUSEHeaderIn)(nil).SizeBytes())
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type FUSEHeaderOut struct {
|
||||
_ structs.HostLayout
|
||||
// Len specifies the total length of the data, including this header.
|
||||
Len uint32
|
||||
|
||||
@@ -182,6 +185,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type FUSEInitIn struct {
|
||||
_ structs.HostLayout
|
||||
// Major version supported by kernel.
|
||||
Major uint32
|
||||
|
||||
@@ -201,6 +205,7 @@ type FUSEInitIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEInitOut struct {
|
||||
_ structs.HostLayout
|
||||
// Major version supported by daemon.
|
||||
Major uint32
|
||||
|
||||
@@ -249,6 +254,7 @@ type FUSEInitOut struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEStatfsOut struct {
|
||||
_ structs.HostLayout
|
||||
// Blocks is the maximum number of data blocks the filesystem may store, in
|
||||
// units of BlockSize.
|
||||
Blocks uint64
|
||||
@@ -290,6 +296,7 @@ const FUSE_GETATTR_FH = (1 << 0)
|
||||
//
|
||||
// +marshal
|
||||
type FUSEGetAttrIn struct {
|
||||
_ structs.HostLayout
|
||||
// GetAttrFlags specifies whether getattr request is sent with a nodeid or
|
||||
// with a file handle.
|
||||
GetAttrFlags uint32
|
||||
@@ -305,6 +312,7 @@ type FUSEGetAttrIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEAttr struct {
|
||||
_ structs.HostLayout
|
||||
// Ino is the inode number of this file.
|
||||
Ino uint64
|
||||
|
||||
@@ -376,6 +384,7 @@ func (a FUSEAttr) CTimeNsec() int64 {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEAttrOut struct {
|
||||
_ structs.HostLayout
|
||||
// AttrValid and AttrValidNsec describe the attribute cache duration
|
||||
AttrValid uint64
|
||||
|
||||
@@ -394,6 +403,7 @@ type FUSEAttrOut struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEEntryOut struct {
|
||||
_ structs.HostLayout
|
||||
// NodeID is the ID for current inode.
|
||||
NodeID uint64
|
||||
|
||||
@@ -445,6 +455,7 @@ func (s *CString) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSELookupIn struct {
|
||||
_ structs.HostLayout
|
||||
// Name is a file name to be looked up.
|
||||
Name CString
|
||||
}
|
||||
@@ -488,6 +499,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type FUSEOpenIn struct {
|
||||
_ structs.HostLayout
|
||||
// Flags of this open request.
|
||||
Flags uint32
|
||||
|
||||
@@ -499,6 +511,7 @@ type FUSEOpenIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEOpenOut struct {
|
||||
_ structs.HostLayout
|
||||
// Fh is the file handler for opened files.
|
||||
Fh uint64
|
||||
|
||||
@@ -513,6 +526,7 @@ type FUSEOpenOut struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSECreateOut struct {
|
||||
_ structs.HostLayout
|
||||
FUSEEntryOut
|
||||
FUSEOpenOut
|
||||
}
|
||||
@@ -527,6 +541,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type FUSEReadIn struct {
|
||||
_ structs.HostLayout
|
||||
// Fh is the file handle in userspace.
|
||||
Fh uint64
|
||||
|
||||
@@ -559,6 +574,7 @@ type FUSEReadIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEWriteIn struct {
|
||||
_ structs.HostLayout
|
||||
// Fh is the file handle in userspace.
|
||||
Fh uint64
|
||||
|
||||
@@ -589,8 +605,9 @@ var SizeOfFUSEWriteIn = uint32((*FUSEWriteIn)(nil).SizeBytes())
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEWritePayloadIn struct {
|
||||
_ structs.HostLayout
|
||||
Header FUSEWriteIn
|
||||
Payload primitive.ByteSlice
|
||||
Payload primitive.ByteSlice `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -618,6 +635,7 @@ func (r *FUSEWritePayloadIn) UnmarshalBytes(src []byte) []byte {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEWriteOut struct {
|
||||
_ structs.HostLayout
|
||||
// Size is the number of bytes written.
|
||||
Size uint32
|
||||
|
||||
@@ -629,6 +647,7 @@ type FUSEWriteOut struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEReleaseIn struct {
|
||||
_ structs.HostLayout
|
||||
// Fh is the file handler for the file to be released.
|
||||
Fh uint64
|
||||
|
||||
@@ -647,6 +666,7 @@ type FUSEReleaseIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSECreateMeta struct {
|
||||
_ structs.HostLayout
|
||||
// Flags of the creating file.
|
||||
Flags uint32
|
||||
|
||||
@@ -662,6 +682,7 @@ type FUSECreateMeta struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSERenameIn struct {
|
||||
_ structs.HostLayout
|
||||
Newdir primitive.Uint64
|
||||
Oldname CString
|
||||
Newname CString
|
||||
@@ -689,6 +710,7 @@ func (r *FUSERenameIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSECreateIn struct {
|
||||
_ structs.HostLayout
|
||||
// CreateMeta contains mode, rdev and umash fields for FUSE_MKNODS.
|
||||
CreateMeta FUSECreateMeta
|
||||
|
||||
@@ -717,6 +739,7 @@ func (r *FUSECreateIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEMknodMeta struct {
|
||||
_ structs.HostLayout
|
||||
// Mode of the inode to create.
|
||||
Mode uint32
|
||||
|
||||
@@ -734,6 +757,7 @@ type FUSEMknodMeta struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEMknodIn struct {
|
||||
_ structs.HostLayout
|
||||
// MknodMeta contains mode, rdev and umash fields for FUSE_MKNODS.
|
||||
MknodMeta FUSEMknodMeta
|
||||
// Name is the name of the node to create.
|
||||
@@ -761,6 +785,7 @@ func (r *FUSEMknodIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSESymlinkIn struct {
|
||||
_ structs.HostLayout
|
||||
// Name of symlink to create.
|
||||
Name CString
|
||||
|
||||
@@ -788,6 +813,7 @@ func (r *FUSESymlinkIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSELinkIn struct {
|
||||
_ structs.HostLayout
|
||||
// OldNodeID is the ID of the inode that is being linked to.
|
||||
OldNodeID primitive.Uint64
|
||||
// Name of the new hard link to create.
|
||||
@@ -813,7 +839,9 @@ func (r *FUSELinkIn) SizeBytes() int {
|
||||
// FUSEEmptyIn is used by operations without request body.
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEEmptyIn struct{}
|
||||
type FUSEEmptyIn struct {
|
||||
_ structs.HostLayout
|
||||
}
|
||||
|
||||
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
|
||||
func (r *FUSEEmptyIn) MarshalBytes(buf []byte) []byte {
|
||||
@@ -835,6 +863,7 @@ func (r *FUSEEmptyIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEMkdirMeta struct {
|
||||
_ structs.HostLayout
|
||||
// Mode of the directory of create.
|
||||
Mode uint32
|
||||
// Umask is the user file creation mask.
|
||||
@@ -846,6 +875,7 @@ type FUSEMkdirMeta struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEMkdirIn struct {
|
||||
_ structs.HostLayout
|
||||
// MkdirMeta contains Mode and Umask of the directory to create.
|
||||
MkdirMeta FUSEMkdirMeta
|
||||
// Name of the directory to create.
|
||||
@@ -873,6 +903,7 @@ func (r *FUSEMkdirIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSERmDirIn struct {
|
||||
_ structs.HostLayout
|
||||
// Name is a directory name to be removed.
|
||||
Name CString
|
||||
}
|
||||
@@ -897,7 +928,8 @@ func (r *FUSERmDirIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEDirents struct {
|
||||
Dirents []*FUSEDirent
|
||||
_ structs.HostLayout
|
||||
Dirents []*FUSEDirent `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// FUSEDirent is a Dirent received from the FUSE daemon server.
|
||||
@@ -905,10 +937,11 @@ type FUSEDirents struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEDirent struct {
|
||||
_ structs.HostLayout
|
||||
// Meta contains all the static fields of FUSEDirent.
|
||||
Meta FUSEDirentMeta
|
||||
// Name is the filename of the dirent.
|
||||
Name string
|
||||
Name string `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// FUSEDirentMeta contains all the static fields of FUSEDirent.
|
||||
@@ -916,6 +949,7 @@ type FUSEDirent struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEDirentMeta struct {
|
||||
_ structs.HostLayout
|
||||
// Inode of the dirent.
|
||||
Ino uint64
|
||||
// Offset of the dirent.
|
||||
@@ -1027,6 +1061,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type FUSESetAttrIn struct {
|
||||
_ structs.HostLayout
|
||||
// Valid indicates which attributes are modified by this request.
|
||||
Valid uint32
|
||||
|
||||
@@ -1078,6 +1113,7 @@ type FUSESetAttrIn struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type FUSEUnlinkIn struct {
|
||||
_ structs.HostLayout
|
||||
// Name of the node to unlink.
|
||||
Name CString
|
||||
}
|
||||
@@ -1102,6 +1138,7 @@ func (r *FUSEUnlinkIn) SizeBytes() int {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEFsyncIn struct {
|
||||
_ structs.HostLayout
|
||||
Fh uint64
|
||||
|
||||
FsyncFlags uint32
|
||||
@@ -1115,6 +1152,7 @@ type FUSEFsyncIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEAccessIn struct {
|
||||
_ structs.HostLayout
|
||||
Mask uint32
|
||||
// padding
|
||||
_ uint32
|
||||
@@ -1125,6 +1163,7 @@ type FUSEAccessIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEFallocateIn struct {
|
||||
_ structs.HostLayout
|
||||
Fh uint64
|
||||
Offset uint64
|
||||
Length uint64
|
||||
@@ -1138,6 +1177,7 @@ type FUSEFallocateIn struct {
|
||||
//
|
||||
// +marshal
|
||||
type FUSEFlushIn struct {
|
||||
_ structs.HostLayout
|
||||
Fh uint64
|
||||
_ uint32 // unused
|
||||
_ uint32 // padding
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// From <linux/futex.h> and <sys/time.h>.
|
||||
// Flags are used in syscall futex(2).
|
||||
const (
|
||||
@@ -71,6 +75,7 @@ const ROBUST_LIST_LIMIT = 2048
|
||||
//
|
||||
// +marshal
|
||||
type RobustListHead struct {
|
||||
_ structs.HostLayout
|
||||
List uint64
|
||||
FutexOffset uint64
|
||||
ListOpPending uint64
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Constants for io_uring_setup(2). See include/uapi/linux/io_uring.h.
|
||||
const (
|
||||
IORING_SETUP_IOPOLL = (1 << 0)
|
||||
@@ -75,6 +79,7 @@ type IORingIndex uint32
|
||||
//
|
||||
// +marshal
|
||||
type IOSqRingOffsets struct {
|
||||
_ structs.HostLayout
|
||||
Head uint32 // Offset to io_rings.sq.head
|
||||
Tail uint32 // Offset to io_rings.sq.tail
|
||||
RingMask uint32 // Offset to io_rings.sq_ring_mask
|
||||
@@ -92,6 +97,7 @@ type IOSqRingOffsets struct {
|
||||
//
|
||||
// +marshal
|
||||
type IOCqRingOffsets struct {
|
||||
_ structs.HostLayout
|
||||
Head uint32 // Offset to io_rings.cq.head
|
||||
Tail uint32 // Offset to io_rings.cq.tail
|
||||
RingMask uint32 // Offset to io_rings.cq_ring_mask
|
||||
@@ -108,6 +114,7 @@ type IOCqRingOffsets struct {
|
||||
//
|
||||
// +marshal
|
||||
type IOUringParams struct {
|
||||
_ structs.HostLayout
|
||||
SqEntries uint32
|
||||
CqEntries uint32
|
||||
Flags uint32
|
||||
@@ -128,6 +135,7 @@ type IOUringParams struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type IOUringCqe struct {
|
||||
_ structs.HostLayout
|
||||
UserData uint64
|
||||
Res int32
|
||||
Flags uint32
|
||||
@@ -139,6 +147,7 @@ type IOUringCqe struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type IOUring struct {
|
||||
_ structs.HostLayout
|
||||
// Both head and tail should be cacheline aligned. And we assume that
|
||||
// cacheline size is 64 bytes.
|
||||
Head uint32
|
||||
@@ -154,6 +163,7 @@ type IOUring struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type IORings struct {
|
||||
_ structs.HostLayout
|
||||
Sq IOUring
|
||||
Cq IOUring
|
||||
SqRingMask uint32
|
||||
@@ -177,6 +187,7 @@ type IORings struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type IOUringSqe struct {
|
||||
_ structs.HostLayout
|
||||
Opcode uint8
|
||||
Flags uint8
|
||||
IoPrio uint16
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Control commands used with semctl, shmctl, and msgctl.
|
||||
//
|
||||
// Source: include/uapi/linux/ipc.h.
|
||||
@@ -46,6 +50,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IPCPerm struct {
|
||||
_ structs.HostLayout
|
||||
Key uint32
|
||||
UID uint32
|
||||
GID uint32
|
||||
|
||||
+21
-16
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Resources for getrlimit(2)/setrlimit(2)/prlimit(2).
|
||||
const (
|
||||
RLIMIT_CPU = 0
|
||||
@@ -36,6 +40,7 @@ const (
|
||||
|
||||
// RLimit corresponds to Linux's struct rlimit.
|
||||
type RLimit struct {
|
||||
_ structs.HostLayout
|
||||
// Cur specifies the soft limit.
|
||||
Cur uint64
|
||||
// Max specifies the hard limit.
|
||||
@@ -69,20 +74,20 @@ const (
|
||||
// InitRLimits is a map of initial rlimits set by Linux in
|
||||
// include/asm-generic/resource.h.
|
||||
var InitRLimits = map[int]RLimit{
|
||||
RLIMIT_CPU: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_FSIZE: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_DATA: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_STACK: {DefaultStackSoftLimit, RLimInfinity},
|
||||
RLIMIT_CORE: {0, RLimInfinity},
|
||||
RLIMIT_RSS: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_NPROC: {DefaultNprocLimit, DefaultNprocLimit},
|
||||
RLIMIT_NOFILE: {DefaultNofileSoftLimit, DefaultNofileHardLimit},
|
||||
RLIMIT_MEMLOCK: {DefaultMemlockLimit, DefaultMemlockLimit},
|
||||
RLIMIT_AS: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_LOCKS: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_SIGPENDING: {0, 0},
|
||||
RLIMIT_MSGQUEUE: {DefaultMsgqueueLimit, DefaultMsgqueueLimit},
|
||||
RLIMIT_NICE: {0, 0},
|
||||
RLIMIT_RTPRIO: {0, 0},
|
||||
RLIMIT_RTTIME: {RLimInfinity, RLimInfinity},
|
||||
RLIMIT_CPU: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_FSIZE: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_DATA: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_STACK: {Cur: DefaultStackSoftLimit, Max: RLimInfinity},
|
||||
RLIMIT_CORE: {Cur: 0, Max: RLimInfinity},
|
||||
RLIMIT_RSS: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_NPROC: {Cur: DefaultNprocLimit, Max: DefaultNprocLimit},
|
||||
RLIMIT_NOFILE: {Cur: DefaultNofileSoftLimit, Max: DefaultNofileHardLimit},
|
||||
RLIMIT_MEMLOCK: {Cur: DefaultMemlockLimit, Max: DefaultMemlockLimit},
|
||||
RLIMIT_AS: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_LOCKS: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
RLIMIT_SIGPENDING: {Cur: 0, Max: 0},
|
||||
RLIMIT_MSGQUEUE: {Cur: DefaultMsgqueueLimit, Max: DefaultMsgqueueLimit},
|
||||
RLIMIT_NICE: {Cur: 0, Max: 0},
|
||||
RLIMIT_RTPRIO: {Cur: 0, Max: 0},
|
||||
RLIMIT_RTTIME: {Cur: RLimInfinity, Max: RLimInfinity},
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
// Linux kernel.
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// NumSoftIRQ is the number of software IRQs, exposed via /proc/stat.
|
||||
//
|
||||
// Defined in linux/interrupt.h.
|
||||
@@ -25,6 +29,7 @@ const NumSoftIRQ = 10
|
||||
//
|
||||
// +marshal
|
||||
type Sysinfo struct {
|
||||
_ structs.HostLayout
|
||||
Uptime int64
|
||||
Loads [3]uint64
|
||||
TotalRAM uint64
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Default values for POSIX message queues. Source:
|
||||
// include/linux/ipc_namespace.h
|
||||
const (
|
||||
@@ -47,6 +51,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type MqAttr struct {
|
||||
_ structs.HostLayout
|
||||
MqFlags int64 // Message queue flags.
|
||||
MqMaxmsg int64 // Maximum number of messages.
|
||||
MqMsgsize int64 // Maximum message size.
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal/primitive"
|
||||
)
|
||||
|
||||
@@ -55,6 +57,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type MsqidDS struct {
|
||||
_ structs.HostLayout
|
||||
MsgPerm IPCPerm // IPC permissions.
|
||||
MsgStime TimeT // Last msgsnd time.
|
||||
MsgRtime TimeT // Last msgrcv time.
|
||||
@@ -72,8 +75,9 @@ type MsqidDS struct {
|
||||
//
|
||||
// +marshal dynamic
|
||||
type MsgBuf struct {
|
||||
_ structs.HostLayout
|
||||
Type primitive.Int64
|
||||
Text primitive.ByteSlice
|
||||
Text primitive.ByteSlice `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -97,6 +101,7 @@ func (b *MsgBuf) UnmarshalBytes(src []byte) []byte {
|
||||
//
|
||||
// +marshal
|
||||
type MsgInfo struct {
|
||||
_ structs.HostLayout
|
||||
MsgPool int32
|
||||
MsgMap int32
|
||||
MsgMax int32
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
const (
|
||||
// IFNAMSIZ is the size of the name field for IFReq.
|
||||
IFNAMSIZ = 16
|
||||
@@ -23,6 +27,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IFReq struct {
|
||||
_ structs.HostLayout
|
||||
// IFName is an encoded name, normally null-terminated. This should be
|
||||
// accessed via the Name and SetName functions.
|
||||
IFName [IFNAMSIZ]byte
|
||||
@@ -66,6 +71,7 @@ var SizeOfIFReq = (*IFReq)(nil).SizeBytes()
|
||||
|
||||
// IFMap contains interface hardware parameters.
|
||||
type IFMap struct {
|
||||
_ structs.HostLayout
|
||||
MemStart uint64
|
||||
MemEnd uint64
|
||||
BaseAddr int16
|
||||
@@ -80,6 +86,7 @@ type IFMap struct {
|
||||
//
|
||||
// +marshal
|
||||
type IFConf struct {
|
||||
_ structs.HostLayout
|
||||
Len int32
|
||||
_ [4]byte // Pad to sizeof(struct ifconf).
|
||||
Ptr uint64
|
||||
@@ -106,6 +113,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type EthtoolGFeatures struct {
|
||||
_ structs.HostLayout
|
||||
Cmd uint32
|
||||
Size uint32
|
||||
}
|
||||
@@ -116,6 +124,7 @@ type EthtoolGFeatures struct {
|
||||
//
|
||||
// +marshal
|
||||
type EthtoolGetFeaturesBlock struct {
|
||||
_ structs.HostLayout
|
||||
Available uint32
|
||||
Requested uint32
|
||||
Active uint32
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
"gvisor.dev/gvisor/pkg/marshal/primitive"
|
||||
)
|
||||
@@ -109,6 +111,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IPTEntry struct {
|
||||
_ structs.HostLayout
|
||||
// IP is used to filter packets based on the IP header.
|
||||
IP IPTIP
|
||||
|
||||
@@ -148,13 +151,14 @@ const SizeOfIPTEntry = 112
|
||||
//
|
||||
// +marshal dynamic
|
||||
type KernelIPTEntry struct {
|
||||
_ structs.HostLayout
|
||||
Entry IPTEntry
|
||||
|
||||
// Elems holds the data for all this rule's matches followed by the
|
||||
// target. It is variable length -- users have to iterate over any
|
||||
// matches and use TargetOffset and NextOffset to make sense of the
|
||||
// data.
|
||||
Elems primitive.ByteSlice
|
||||
Elems primitive.ByteSlice `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -182,6 +186,7 @@ var _ marshal.Marshallable = (*KernelIPTEntry)(nil)
|
||||
//
|
||||
// +marshal
|
||||
type IPTIP struct {
|
||||
_ structs.HostLayout
|
||||
// Src is the source IP address.
|
||||
Src InetAddr
|
||||
|
||||
@@ -246,6 +251,7 @@ const SizeOfIPTIP = 84
|
||||
//
|
||||
// +marshal
|
||||
type XTCounters struct {
|
||||
_ structs.HostLayout
|
||||
// Pcnt is the packet count.
|
||||
Pcnt uint64
|
||||
|
||||
@@ -267,6 +273,7 @@ const SizeOfXTCounters = 16
|
||||
//
|
||||
// +marshal
|
||||
type XTEntryMatch struct {
|
||||
_ structs.HostLayout
|
||||
MatchSize uint16
|
||||
Name ExtensionName
|
||||
Revision uint8
|
||||
@@ -281,8 +288,9 @@ const SizeOfXTEntryMatch = 32
|
||||
// KernelXTEntryMatch is identical to XTEntryMatch, but contains
|
||||
// variable-length Data field.
|
||||
type KernelXTEntryMatch struct {
|
||||
_ structs.HostLayout
|
||||
XTEntryMatch
|
||||
Data []byte
|
||||
Data []byte `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// XTGetRevision corresponds to xt_get_revision in
|
||||
@@ -290,6 +298,7 @@ type KernelXTEntryMatch struct {
|
||||
//
|
||||
// +marshal
|
||||
type XTGetRevision struct {
|
||||
_ structs.HostLayout
|
||||
Name ExtensionName
|
||||
Revision uint8
|
||||
}
|
||||
@@ -308,6 +317,7 @@ const SizeOfXTGetRevision = 30
|
||||
//
|
||||
// +marshal
|
||||
type XTEntryTarget struct {
|
||||
_ structs.HostLayout
|
||||
TargetSize uint16
|
||||
Name ExtensionName
|
||||
Revision uint8
|
||||
@@ -322,8 +332,9 @@ const SizeOfXTEntryTarget = 32
|
||||
// KernelXTEntryTarget is identical to XTEntryTarget, but contains a
|
||||
// variable-length Data field.
|
||||
type KernelXTEntryTarget struct {
|
||||
_ structs.HostLayout
|
||||
XTEntryTarget
|
||||
Data []byte
|
||||
Data []byte `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// XTStandardTarget is a built-in target, one of ACCEPT, DROP, JUMP, QUEUE,
|
||||
@@ -332,6 +343,7 @@ type KernelXTEntryTarget struct {
|
||||
//
|
||||
// +marshal
|
||||
type XTStandardTarget struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
// A positive verdict indicates a jump, and is the offset from the
|
||||
// start of the table to jump to. A negative value means one of the
|
||||
@@ -350,6 +362,7 @@ const SizeOfXTStandardTarget = 40
|
||||
//
|
||||
// +marshal
|
||||
type XTErrorTarget struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
Name ErrorName
|
||||
_ [2]byte
|
||||
@@ -379,6 +392,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NfNATIPV4Range struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint32
|
||||
MinIP [4]byte
|
||||
MaxIP [4]byte
|
||||
@@ -391,6 +405,7 @@ type NfNATIPV4Range struct {
|
||||
//
|
||||
// +marshal
|
||||
type NfNATIPV4MultiRangeCompat struct {
|
||||
_ structs.HostLayout
|
||||
RangeSize uint32
|
||||
RangeIPV4 NfNATIPV4Range
|
||||
}
|
||||
@@ -400,6 +415,7 @@ type NfNATIPV4MultiRangeCompat struct {
|
||||
//
|
||||
// +marshal
|
||||
type XTRedirectTarget struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
NfRange NfNATIPV4MultiRangeCompat
|
||||
_ [4]byte
|
||||
@@ -413,6 +429,7 @@ const SizeOfXTRedirectTarget = 56
|
||||
//
|
||||
// +marshal
|
||||
type XTNATTargetV0 struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
NfRange NfNATIPV4MultiRangeCompat
|
||||
_ [4]byte
|
||||
@@ -425,6 +442,7 @@ const SizeOfXTNATTargetV0 = 56
|
||||
//
|
||||
// +marshal
|
||||
type XTNATTargetV1 struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
Range NFNATRange
|
||||
}
|
||||
@@ -436,6 +454,7 @@ const SizeOfXTNATTargetV1 = SizeOfXTEntryTarget + SizeOfNFNATRange
|
||||
//
|
||||
// +marshal
|
||||
type XTNATTargetV2 struct {
|
||||
_ structs.HostLayout
|
||||
Target XTEntryTarget
|
||||
Range NFNATRange2
|
||||
}
|
||||
@@ -448,6 +467,7 @@ const SizeOfXTNATTargetV2 = SizeOfXTEntryTarget + SizeOfNFNATRange2
|
||||
//
|
||||
// +marshal
|
||||
type IPTGetinfo struct {
|
||||
_ structs.HostLayout
|
||||
Name TableName
|
||||
ValidHooks uint32
|
||||
HookEntry [NF_INET_NUMHOOKS]uint32
|
||||
@@ -465,6 +485,7 @@ const SizeOfIPTGetinfo = 84
|
||||
//
|
||||
// +marshal
|
||||
type IPTGetEntries struct {
|
||||
_ structs.HostLayout
|
||||
Name TableName
|
||||
Size uint32
|
||||
_ [4]byte
|
||||
@@ -482,8 +503,9 @@ const SizeOfIPTGetEntries = 40
|
||||
//
|
||||
// +marshal dynamic
|
||||
type KernelIPTGetEntries struct {
|
||||
_ structs.HostLayout
|
||||
IPTGetEntries
|
||||
Entrytable []KernelIPTEntry
|
||||
Entrytable []KernelIPTEntry `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -521,6 +543,7 @@ var _ marshal.Marshallable = (*KernelIPTGetEntries)(nil)
|
||||
//
|
||||
// +marshal
|
||||
type IPTReplace struct {
|
||||
_ structs.HostLayout
|
||||
Name TableName
|
||||
ValidHooks uint32
|
||||
NumEntries uint32
|
||||
@@ -582,6 +605,7 @@ func goString(cstring []byte) string {
|
||||
//
|
||||
// +marshal
|
||||
type XTTCP struct {
|
||||
_ structs.HostLayout
|
||||
// SourcePortStart specifies the inclusive start of the range of source
|
||||
// ports to which the matcher applies.
|
||||
SourcePortStart uint16
|
||||
@@ -637,6 +661,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type XTUDP struct {
|
||||
_ structs.HostLayout
|
||||
// SourcePortStart is the inclusive start of the range of source ports
|
||||
// to which the matcher applies.
|
||||
SourcePortStart uint16
|
||||
@@ -679,6 +704,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IPTOwnerInfo struct {
|
||||
_ structs.HostLayout
|
||||
// UID is user id which created the packet.
|
||||
UID uint32
|
||||
|
||||
@@ -711,6 +737,7 @@ const SizeOfIPTOwnerInfo = 34
|
||||
//
|
||||
// +marshal
|
||||
type XTOwnerMatchInfo struct {
|
||||
_ structs.HostLayout
|
||||
UIDMin uint32
|
||||
UIDMax uint32
|
||||
GIDMin uint32
|
||||
@@ -753,6 +780,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type XTMultiport struct {
|
||||
_ structs.HostLayout
|
||||
// Flags indicates whether the match applies to
|
||||
// source ports, destination ports, or either, as
|
||||
// defined by "enum xt_multiport_flags".
|
||||
@@ -774,6 +802,7 @@ type XTMultiport struct {
|
||||
//
|
||||
// +marshal
|
||||
type XTMultiportV1 struct {
|
||||
_ structs.HostLayout
|
||||
// Fields same as "XTMultiport".
|
||||
Flags uint8
|
||||
Count uint8
|
||||
|
||||
@@ -16,6 +16,7 @@ package linux
|
||||
|
||||
import (
|
||||
"math"
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
"gvisor.dev/gvisor/pkg/marshal/primitive"
|
||||
@@ -69,6 +70,7 @@ const IP6T_ORIGINAL_DST = 80
|
||||
//
|
||||
// +marshal
|
||||
type IP6TReplace struct {
|
||||
_ structs.HostLayout
|
||||
Name TableName
|
||||
ValidHooks uint32
|
||||
NumEntries uint32
|
||||
@@ -90,8 +92,9 @@ const SizeOfIP6TReplace = 96
|
||||
//
|
||||
// +marshal dynamic
|
||||
type KernelIP6TGetEntries struct {
|
||||
_ structs.HostLayout
|
||||
IPTGetEntries
|
||||
Entrytable []KernelIP6TEntry
|
||||
Entrytable []KernelIP6TEntry `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -128,6 +131,7 @@ var _ marshal.Marshallable = (*KernelIP6TGetEntries)(nil)
|
||||
//
|
||||
// +marshal
|
||||
type IP6TEntry struct {
|
||||
_ structs.HostLayout
|
||||
// IPv6 is used to filter packets based on the IPv6 header.
|
||||
IPv6 IP6TIP
|
||||
|
||||
@@ -169,13 +173,14 @@ const SizeOfIP6TEntry = 168
|
||||
//
|
||||
// +marshal dynamic
|
||||
type KernelIP6TEntry struct {
|
||||
_ structs.HostLayout
|
||||
Entry IP6TEntry
|
||||
|
||||
// Elems holds the data for all this rule's matches followed by the
|
||||
// target. It is variable length -- users have to iterate over any
|
||||
// matches and use TargetOffset and NextOffset to make sense of the
|
||||
// data.
|
||||
Elems primitive.ByteSlice
|
||||
Elems primitive.ByteSlice `hostlayout:"ignore"`
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
@@ -203,6 +208,7 @@ var _ marshal.Marshallable = (*KernelIP6TEntry)(nil)
|
||||
//
|
||||
// +marshal
|
||||
type IP6TIP struct {
|
||||
_ structs.HostLayout
|
||||
// Src is the source IP address.
|
||||
Src Inet6Addr
|
||||
|
||||
@@ -286,6 +292,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NFNATRange struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint32
|
||||
MinAddr Inet6Addr
|
||||
MaxAddr Inet6Addr
|
||||
@@ -301,6 +308,7 @@ const SizeOfNFNATRange = 40
|
||||
//
|
||||
// +marshal
|
||||
type NFNATRange2 struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint32
|
||||
MinAddr Inet6Addr
|
||||
MaxAddr Inet6Addr
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Netlink protocols, from uapi/linux/netlink.h.
|
||||
const (
|
||||
NETLINK_ROUTE = 0
|
||||
@@ -43,6 +47,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type SockAddrNetlink struct {
|
||||
_ structs.HostLayout
|
||||
Family uint16
|
||||
_ uint16
|
||||
PortID uint32
|
||||
@@ -56,6 +61,7 @@ const SockAddrNetlinkSize = 12
|
||||
//
|
||||
// +marshal
|
||||
type NetlinkMessageHeader struct {
|
||||
_ structs.HostLayout
|
||||
Length uint32
|
||||
Type uint16
|
||||
Flags uint16
|
||||
@@ -118,6 +124,7 @@ const NLMSG_ALIGNTO = 4
|
||||
//
|
||||
// +marshal
|
||||
type NetlinkAttrHeader struct {
|
||||
_ structs.HostLayout
|
||||
Length uint16
|
||||
Type uint16
|
||||
}
|
||||
@@ -181,6 +188,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NetlinkErrorMessage struct {
|
||||
_ structs.HostLayout
|
||||
Error int32
|
||||
Header NetlinkMessageHeader
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Group describes Netlink Netfilter groups, from uapi/linux/netfilter/nfnetlink.h.
|
||||
// Users bind to specific groups to receive processing logs from those groups.
|
||||
type Group uint16
|
||||
@@ -38,6 +42,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NetFilterGenMsg struct {
|
||||
_ structs.HostLayout
|
||||
Family uint8
|
||||
Version uint8
|
||||
ResourceID uint16
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Netlink message types for NETLINK_ROUTE sockets, from uapi/linux/rtnetlink.h.
|
||||
const (
|
||||
RTM_NEWLINK = 16
|
||||
@@ -88,6 +92,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type InterfaceInfoMessage struct {
|
||||
_ structs.HostLayout
|
||||
Family uint8
|
||||
_ uint8
|
||||
Type uint16
|
||||
@@ -187,6 +192,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type InterfaceAddrMessage struct {
|
||||
_ structs.HostLayout
|
||||
Family uint8
|
||||
PrefixLen uint8
|
||||
Flags uint8
|
||||
@@ -221,6 +227,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type RouteMessage struct {
|
||||
_ structs.HostLayout
|
||||
Family uint8
|
||||
DstLen uint8
|
||||
SrcLen uint8
|
||||
@@ -369,6 +376,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type RtAttr struct {
|
||||
_ structs.HostLayout
|
||||
Len uint16
|
||||
Type uint16
|
||||
}
|
||||
|
||||
@@ -14,10 +14,15 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// PollFD is struct pollfd, used by poll(2)/ppoll(2), from uapi/asm-generic/poll.h.
|
||||
//
|
||||
// +marshal slice:PollFDSlice
|
||||
type PollFD struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
Events int16
|
||||
REvents int16
|
||||
|
||||
@@ -17,12 +17,17 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// PtraceRegs is the set of CPU registers exposed by ptrace. Source:
|
||||
// syscall.PtraceRegs.
|
||||
//
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type PtraceRegs struct {
|
||||
_ structs.HostLayout
|
||||
R15 uint64
|
||||
R14 uint64
|
||||
R13 uint64
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
const (
|
||||
//PSR bits
|
||||
PSR_MODE_EL0t = 0x00000000
|
||||
@@ -54,6 +58,7 @@ const (
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type PtraceRegs struct {
|
||||
_ structs.HostLayout
|
||||
Regs [31]uint64
|
||||
Sp uint64
|
||||
Pc uint64
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Flags passed to rseq(2).
|
||||
//
|
||||
// Defined in include/uapi/linux/rseq.h.
|
||||
@@ -45,6 +49,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type RSeqCriticalSection struct {
|
||||
_ structs.HostLayout
|
||||
// Version is the version of this structure. Version 0 is defined here.
|
||||
Version uint32
|
||||
|
||||
@@ -88,6 +93,7 @@ const (
|
||||
//
|
||||
// In userspace, this structure is always aligned to 32 bytes.
|
||||
type RSeq struct {
|
||||
_ structs.HostLayout
|
||||
// CPUIDStart contains the current CPU ID if rseq is initialized.
|
||||
//
|
||||
// This field should only be read by the thread which registered this
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Flags that may be used with wait4(2) and getrusage(2).
|
||||
const (
|
||||
// wait4(2) uses this to aggregate RUSAGE_SELF and RUSAGE_CHILDREN.
|
||||
@@ -29,6 +33,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Rusage struct {
|
||||
_ structs.HostLayout
|
||||
UTime Timeval
|
||||
STime Timeval
|
||||
MaxRSS int64
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Seccomp constants taken from <linux/seccomp.h>.
|
||||
const (
|
||||
@@ -103,6 +106,7 @@ func (a BPFAction) WithReturnCode(code uint16) BPFAction {
|
||||
|
||||
// SockFprog is sock_fprog taken from <linux/filter.h>.
|
||||
type SockFprog struct {
|
||||
_ structs.HostLayout
|
||||
Len uint16
|
||||
pad [6]byte
|
||||
Filter *BPFInstruction
|
||||
@@ -113,6 +117,7 @@ type SockFprog struct {
|
||||
//
|
||||
// +marshal
|
||||
type SeccompData struct {
|
||||
_ structs.HostLayout
|
||||
// Nr is the system call number.
|
||||
Nr int32
|
||||
|
||||
@@ -131,6 +136,7 @@ type SeccompData struct {
|
||||
//
|
||||
// +marshal
|
||||
type SeccompNotifResp struct {
|
||||
_ structs.HostLayout
|
||||
ID uint64
|
||||
Val int64
|
||||
Error int32
|
||||
@@ -141,6 +147,7 @@ type SeccompNotifResp struct {
|
||||
//
|
||||
// +marshal
|
||||
type SeccompNotifSizes struct {
|
||||
_ structs.HostLayout
|
||||
Notif uint16
|
||||
Notif_resp uint16
|
||||
Data uint16
|
||||
@@ -150,6 +157,7 @@ type SeccompNotifSizes struct {
|
||||
//
|
||||
// +marshal
|
||||
type SeccompNotif struct {
|
||||
_ structs.HostLayout
|
||||
ID uint64
|
||||
Pid int32
|
||||
Flags uint32
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// semctl Command Definitions. Source: include/uapi/linux/sem.h
|
||||
const (
|
||||
GETPID = 11
|
||||
@@ -58,6 +62,7 @@ const (
|
||||
//
|
||||
// +marshal slice:SembufSlice
|
||||
type Sembuf struct {
|
||||
_ structs.HostLayout
|
||||
SemNum uint16
|
||||
SemOp int16
|
||||
SemFlg int16
|
||||
@@ -69,6 +74,7 @@ type Sembuf struct {
|
||||
//
|
||||
// +marshal
|
||||
type SemInfo struct {
|
||||
_ structs.HostLayout
|
||||
SemMap uint32
|
||||
SemMni uint32
|
||||
SemMns uint32
|
||||
|
||||
@@ -17,12 +17,17 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// SemidDS is equivalent to struct semid64_ds.
|
||||
//
|
||||
// Source: arch/x86/include/uapi/asm/sembuf.h
|
||||
//
|
||||
// +marshal
|
||||
type SemidDS struct {
|
||||
_ structs.HostLayout
|
||||
SemPerm IPCPerm
|
||||
SemOTime TimeT
|
||||
unused1 uint64
|
||||
|
||||
@@ -17,12 +17,17 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// SemidDS is equivalent to struct semid64_ds.
|
||||
//
|
||||
// Source: include/uapi/asm-generic/sembuf.h
|
||||
//
|
||||
// +marshal
|
||||
type SemidDS struct {
|
||||
_ structs.HostLayout
|
||||
SemPerm IPCPerm
|
||||
SemOTime TimeT
|
||||
SemCTime TimeT
|
||||
|
||||
@@ -14,7 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import "math"
|
||||
import (
|
||||
"math"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// shmat(2) flags. Source: include/uapi/linux/shm.h
|
||||
const (
|
||||
@@ -54,6 +57,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type ShmidDS struct {
|
||||
_ structs.HostLayout
|
||||
ShmPerm IPCPerm
|
||||
ShmSegsz uint64
|
||||
ShmAtime TimeT
|
||||
@@ -71,6 +75,7 @@ type ShmidDS struct {
|
||||
//
|
||||
// +marshal
|
||||
type ShmParams struct {
|
||||
_ structs.HostLayout
|
||||
ShmMax uint64
|
||||
ShmMin uint64
|
||||
ShmMni uint64
|
||||
@@ -82,6 +87,7 @@ type ShmParams struct {
|
||||
//
|
||||
// +marshal
|
||||
type ShmInfo struct {
|
||||
_ structs.HostLayout
|
||||
UsedIDs int32 // Number of currently existing segments.
|
||||
_ [4]byte
|
||||
ShmTot uint64 // Total number of shared memory pages.
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/bits"
|
||||
"gvisor.dev/gvisor/pkg/hostarch"
|
||||
)
|
||||
@@ -291,6 +293,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Sigevent struct {
|
||||
_ structs.HostLayout
|
||||
Value uint64 // union sigval {int, void*}
|
||||
Signo int32
|
||||
Notify int32
|
||||
@@ -306,6 +309,7 @@ type Sigevent struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type SigAction struct {
|
||||
_ structs.HostLayout
|
||||
Handler uint64
|
||||
Flags uint64
|
||||
Restorer uint64
|
||||
@@ -318,6 +322,7 @@ type SigAction struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type SignalStack struct {
|
||||
_ structs.HostLayout
|
||||
Addr uint64
|
||||
Flags uint32
|
||||
_ uint32
|
||||
@@ -345,6 +350,7 @@ func (s *SignalStack) IsEnabled() bool {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type SignalInfo struct {
|
||||
_ structs.HostLayout
|
||||
Signo int32 // Signal number
|
||||
Errno int32 // Errno value
|
||||
Code int32 // Signal code
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
const (
|
||||
// SFD_NONBLOCK is a signalfd(2) flag.
|
||||
SFD_NONBLOCK = 00004000
|
||||
@@ -26,6 +30,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type SignalfdSiginfo struct {
|
||||
_ structs.HostLayout
|
||||
Signo uint32
|
||||
Errno int32
|
||||
Code int32
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
)
|
||||
|
||||
@@ -174,6 +176,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type TpacketReq struct {
|
||||
_ structs.HostLayout
|
||||
TpBlockSize uint32
|
||||
TpBlockNr uint32
|
||||
TpFrameSize uint32
|
||||
@@ -185,6 +188,7 @@ type TpacketReq struct {
|
||||
//
|
||||
// +marshal
|
||||
type TpacketHdr struct {
|
||||
_ structs.HostLayout
|
||||
TpStatus uint64
|
||||
TpLen uint32
|
||||
TpSnaplen uint32
|
||||
@@ -200,6 +204,7 @@ type TpacketHdr struct {
|
||||
//
|
||||
// +marshal
|
||||
type Tpacket2Hdr struct {
|
||||
_ structs.HostLayout
|
||||
TpStatus uint32
|
||||
TpLen uint32
|
||||
TpSnaplen uint32
|
||||
@@ -217,6 +222,7 @@ type Tpacket2Hdr struct {
|
||||
//
|
||||
// +marshal
|
||||
type TpacketStats struct {
|
||||
_ structs.HostLayout
|
||||
Packets uint32
|
||||
Dropped uint32
|
||||
}
|
||||
@@ -373,6 +379,7 @@ var SizeOfInetAddr = uint32((*InetAddr)(nil).SizeBytes())
|
||||
//
|
||||
// +marshal
|
||||
type SockAddrInet struct {
|
||||
_ structs.HostLayout
|
||||
Family uint16
|
||||
Port uint16
|
||||
Addr InetAddr
|
||||
@@ -383,6 +390,7 @@ type SockAddrInet struct {
|
||||
//
|
||||
// +marshal
|
||||
type Inet6MulticastRequest struct {
|
||||
_ structs.HostLayout
|
||||
MulticastAddr Inet6Addr
|
||||
InterfaceIndex int32
|
||||
}
|
||||
@@ -391,6 +399,7 @@ type Inet6MulticastRequest struct {
|
||||
//
|
||||
// +marshal
|
||||
type InetMulticastRequest struct {
|
||||
_ structs.HostLayout
|
||||
MulticastAddr InetAddr
|
||||
InterfaceAddr InetAddr
|
||||
}
|
||||
@@ -399,6 +408,7 @@ type InetMulticastRequest struct {
|
||||
//
|
||||
// +marshal
|
||||
type InetMulticastRequestWithNIC struct {
|
||||
_ structs.HostLayout
|
||||
InetMulticastRequest
|
||||
InterfaceIndex int32
|
||||
}
|
||||
@@ -412,6 +422,7 @@ type Inet6Addr [16]byte
|
||||
//
|
||||
// +marshal
|
||||
type SockAddrInet6 struct {
|
||||
_ structs.HostLayout
|
||||
Family uint16
|
||||
Port uint16
|
||||
Flowinfo uint32
|
||||
@@ -423,6 +434,7 @@ type SockAddrInet6 struct {
|
||||
//
|
||||
// +marshal
|
||||
type SockAddrLink struct {
|
||||
_ structs.HostLayout
|
||||
Family uint16
|
||||
Protocol uint16
|
||||
InterfaceIndex int32
|
||||
@@ -441,6 +453,7 @@ const UnixPathMax = 108
|
||||
//
|
||||
// +marshal
|
||||
type SockAddrUnix struct {
|
||||
_ structs.HostLayout
|
||||
Family uint16
|
||||
Path [UnixPathMax]int8
|
||||
}
|
||||
@@ -466,6 +479,7 @@ func (s *SockAddrNetlink) implementsSockAddr() {}
|
||||
//
|
||||
// +marshal
|
||||
type Linger struct {
|
||||
_ structs.HostLayout
|
||||
OnOff int32
|
||||
Linger int32
|
||||
}
|
||||
@@ -482,6 +496,7 @@ const SizeOfLinger = 8
|
||||
//
|
||||
// +marshal
|
||||
type TCPInfo struct {
|
||||
_ structs.HostLayout
|
||||
// State is the state of the connection.
|
||||
State uint8
|
||||
|
||||
@@ -640,6 +655,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type ControlMessageHeader struct {
|
||||
_ structs.HostLayout
|
||||
Length uint64
|
||||
Level int32
|
||||
Type int32
|
||||
@@ -655,6 +671,7 @@ var SizeOfControlMessageHeader = (*ControlMessageHeader)(nil).SizeBytes()
|
||||
//
|
||||
// +marshal
|
||||
type ControlMessageCredentials struct {
|
||||
_ structs.HostLayout
|
||||
PID int32
|
||||
UID uint32
|
||||
GID uint32
|
||||
@@ -667,6 +684,7 @@ type ControlMessageCredentials struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type ControlMessageIPPacketInfo struct {
|
||||
_ structs.HostLayout
|
||||
NIC int32
|
||||
LocalAddr InetAddr
|
||||
DestinationAddr InetAddr
|
||||
@@ -677,6 +695,7 @@ type ControlMessageIPPacketInfo struct {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type ControlMessageIPv6PacketInfo struct {
|
||||
_ structs.HostLayout
|
||||
Addr Inet6Addr
|
||||
NIC uint32
|
||||
}
|
||||
@@ -728,6 +747,7 @@ const SO_ACCEPTCON = 1 << 16
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type ICMP6Filter struct {
|
||||
_ structs.HostLayout
|
||||
Filter [8]uint32
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package linux
|
||||
|
||||
import (
|
||||
"math"
|
||||
"structs"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -106,6 +107,7 @@ func NsecToTimeT(nsec int64) TimeT {
|
||||
//
|
||||
// +marshal slice:TimespecSlice
|
||||
type Timespec struct {
|
||||
_ structs.HostLayout
|
||||
Sec int64
|
||||
Nsec int64
|
||||
}
|
||||
@@ -162,6 +164,7 @@ const SizeOfTimeval = 16
|
||||
//
|
||||
// +marshal slice:TimevalSlice
|
||||
type Timeval struct {
|
||||
_ structs.HostLayout
|
||||
Sec int64
|
||||
Usec int64
|
||||
}
|
||||
@@ -201,6 +204,7 @@ func DurationToTimeval(dur time.Duration) Timeval {
|
||||
//
|
||||
// +marshal
|
||||
type Itimerspec struct {
|
||||
_ structs.HostLayout
|
||||
Interval Timespec
|
||||
Value Timespec
|
||||
}
|
||||
@@ -214,6 +218,7 @@ type Itimerspec struct {
|
||||
//
|
||||
// +marshal
|
||||
type ItimerVal struct {
|
||||
_ structs.HostLayout
|
||||
Interval Timeval
|
||||
Value Timeval
|
||||
}
|
||||
@@ -232,6 +237,7 @@ func ClockTFromDuration(d time.Duration) ClockT {
|
||||
//
|
||||
// +marshal
|
||||
type Tms struct {
|
||||
_ structs.HostLayout
|
||||
UTime ClockT
|
||||
STime ClockT
|
||||
CUTime ClockT
|
||||
@@ -248,6 +254,7 @@ type TimerID int32
|
||||
//
|
||||
// +marshal
|
||||
type StatxTimestamp struct {
|
||||
_ structs.HostLayout
|
||||
Sec int64
|
||||
Nsec uint32
|
||||
_ int32
|
||||
@@ -283,6 +290,7 @@ func (sxts StatxTimestamp) ToTime() time.Time {
|
||||
//
|
||||
// +marshal
|
||||
type Utime struct {
|
||||
_ structs.HostLayout
|
||||
Actime int64
|
||||
Modtime int64
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
const (
|
||||
// NumControlCharacters is the number of control characters in Termios.
|
||||
NumControlCharacters = 19
|
||||
@@ -26,6 +30,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type Winsize struct {
|
||||
_ structs.HostLayout
|
||||
Row uint16
|
||||
Col uint16
|
||||
Xpixel uint16
|
||||
@@ -36,6 +41,7 @@ type Winsize struct {
|
||||
//
|
||||
// +marshal
|
||||
type Termios struct {
|
||||
_ structs.HostLayout
|
||||
InputFlags uint32
|
||||
OutputFlags uint32
|
||||
ControlFlags uint32
|
||||
@@ -49,6 +55,7 @@ type Termios struct {
|
||||
//
|
||||
// +stateify savable
|
||||
type KernelTermios struct {
|
||||
_ structs.HostLayout
|
||||
InputFlags uint32
|
||||
OutputFlags uint32
|
||||
ControlFlags uint32
|
||||
@@ -343,6 +350,7 @@ var DefaultReplicaTermios = KernelTermios{
|
||||
// +stateify savable
|
||||
// +marshal
|
||||
type WindowSize struct {
|
||||
_ structs.HostLayout
|
||||
Rows uint16
|
||||
Cols uint16
|
||||
_ [4]byte // Padding for 2 unused shorts.
|
||||
|
||||
@@ -17,6 +17,7 @@ package linux
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -29,6 +30,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type UtsName struct {
|
||||
_ structs.HostLayout
|
||||
Sysname [UTSLen + 1]byte
|
||||
Nodename [UTSLen + 1]byte
|
||||
Release [UTSLen + 1]byte
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
|
||||
package linux
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// For IOCTLs requests from include/uapi/linux/vfio.h.
|
||||
const (
|
||||
VFIO_TYPE = ';'
|
||||
@@ -131,6 +135,7 @@ var (
|
||||
//
|
||||
// +marshal
|
||||
type VFIODeviceInfo struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
// The total amount of regions.
|
||||
@@ -147,6 +152,7 @@ type VFIODeviceInfo struct {
|
||||
//
|
||||
// +marshal
|
||||
type VFIORegionInfo struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
Index uint32
|
||||
@@ -163,6 +169,7 @@ type VFIORegionInfo struct {
|
||||
//
|
||||
// +marshal
|
||||
type VFIOIrqInfo struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
Index uint32
|
||||
@@ -176,6 +183,7 @@ type VFIOIrqInfo struct {
|
||||
//
|
||||
// +marshal
|
||||
type VFIOIrqSet struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
Index uint32
|
||||
@@ -188,6 +196,7 @@ type VFIOIrqSet struct {
|
||||
//
|
||||
// +marshal
|
||||
type VFIOIommuType1DmaMap struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
// Process virtual address.
|
||||
@@ -203,6 +212,7 @@ type VFIOIommuType1DmaMap struct {
|
||||
//
|
||||
// +marshal
|
||||
type VFIOIommuType1DmaUnmap struct {
|
||||
_ structs.HostLayout
|
||||
Argsz uint32
|
||||
Flags uint32
|
||||
// IO virtual address.
|
||||
|
||||
@@ -15,6 +15,7 @@ go_library(
|
||||
"status.go",
|
||||
"uvm.go",
|
||||
],
|
||||
hostlayout = True,
|
||||
marshal = True,
|
||||
visibility = [
|
||||
"//pkg/sentry:internal",
|
||||
|
||||
@@ -16,6 +16,7 @@ package nvgpu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// ClassID is a client class ID, in the sense of
|
||||
@@ -132,6 +133,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV2081_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Reserved uint32
|
||||
}
|
||||
|
||||
@@ -140,6 +142,7 @@ type NV2081_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV0005_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HParentClient Handle
|
||||
HSrcResource Handle
|
||||
HClass ClassID
|
||||
@@ -162,6 +165,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_VIRTUAL_ALLOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Offset uint64
|
||||
Limit uint64
|
||||
HVASpace Handle
|
||||
@@ -178,6 +182,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV0080_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
DeviceID uint32
|
||||
HClientShare Handle
|
||||
HTargetClient Handle
|
||||
@@ -196,6 +201,7 @@ type NV0080_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_SEMAPHORE_SURFACE_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HSemaphoreMem Handle
|
||||
HMaxSubmittedMem Handle
|
||||
flags uint64
|
||||
@@ -206,6 +212,7 @@ type NV_SEMAPHORE_SURFACE_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV2080_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
SubDeviceID uint32
|
||||
}
|
||||
|
||||
@@ -214,6 +221,7 @@ type NV2080_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CONTEXT_DMA_ALLOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
HSubDevice Handle
|
||||
Flags uint32
|
||||
HMemory Handle
|
||||
@@ -227,6 +235,7 @@ type NV_CONTEXT_DMA_ALLOCATION_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_ALLOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Owner uint32
|
||||
Type uint32
|
||||
Flags uint32
|
||||
@@ -257,6 +266,7 @@ type NV_MEMORY_ALLOCATION_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_ALLOCATION_PARAMS_V545 struct {
|
||||
_ structs.HostLayout
|
||||
NV_MEMORY_ALLOCATION_PARAMS
|
||||
NumaNode int32
|
||||
_ uint32
|
||||
@@ -266,6 +276,7 @@ type NV_MEMORY_ALLOCATION_PARAMS_V545 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV503B_BAR1_P2P_DMA_INFO struct {
|
||||
_ structs.HostLayout
|
||||
DmaAddress uint64
|
||||
DmaSize uint64
|
||||
}
|
||||
@@ -275,6 +286,7 @@ type NV503B_BAR1_P2P_DMA_INFO struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV503B_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HSubDevice Handle
|
||||
HPeerSubDevice Handle
|
||||
SubDevicePeerIDMask uint32
|
||||
@@ -293,6 +305,7 @@ type NV503B_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV503C_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
@@ -301,6 +314,7 @@ type NV503C_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV83DE_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HDebuggerClient_Obsolete Handle
|
||||
HAppClient Handle
|
||||
HClass3DObject Handle
|
||||
@@ -311,6 +325,7 @@ type NV83DE_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CTXSHARE_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HVASpace Handle
|
||||
Flags uint32
|
||||
SubctxID uint32
|
||||
@@ -321,6 +336,7 @@ type NV_CTXSHARE_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_VASPACE_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Index uint32
|
||||
Flags uint32
|
||||
VASize uint64
|
||||
@@ -336,6 +352,7 @@ type NV_VASPACE_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_VASPACE_ALLOCATION_PARAMETERS_V580 struct {
|
||||
_ structs.HostLayout
|
||||
NV_VASPACE_ALLOCATION_PARAMETERS
|
||||
Pasid uint32
|
||||
Pad1 [4]byte
|
||||
@@ -346,6 +363,7 @@ type NV_VASPACE_ALLOCATION_PARAMETERS_V580 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HObjectError Handle
|
||||
HObjectECCError Handle
|
||||
HVASpace Handle
|
||||
@@ -359,6 +377,7 @@ type NV_CHANNEL_GROUP_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_DESC_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Size uint64
|
||||
AddressSpace uint32
|
||||
@@ -370,6 +389,7 @@ type NV_MEMORY_DESC_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_BSP_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Size uint32
|
||||
ProhibitMultipleInstances uint32
|
||||
EngineInstance uint32
|
||||
@@ -380,6 +400,7 @@ type NV_BSP_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MSENC_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Size uint32
|
||||
ProhibitMultipleInstances uint32
|
||||
EngineInstance uint32
|
||||
@@ -391,6 +412,7 @@ type NV_MSENC_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CHANNEL_ALLOC_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
HObjectError Handle
|
||||
HObjectBuffer Handle
|
||||
GPFIFOOffset uint64
|
||||
@@ -424,6 +446,7 @@ type NV_CHANNEL_ALLOC_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CHANNEL_ALLOC_PARAMS_V570 struct {
|
||||
_ structs.HostLayout
|
||||
NV_CHANNEL_ALLOC_PARAMS
|
||||
TPCConfigID uint32
|
||||
_ uint32
|
||||
@@ -435,6 +458,7 @@ type NV_CHANNEL_ALLOC_PARAMS_V570 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NVB0B5_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Version uint32
|
||||
EngineType uint32
|
||||
}
|
||||
@@ -444,6 +468,7 @@ type NVB0B5_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_GR_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Version uint32
|
||||
Flags uint32
|
||||
Size uint32
|
||||
@@ -455,6 +480,7 @@ type NV_GR_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_HOPPER_USERMODE_A_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Bar1Mapping uint8
|
||||
Priv uint8
|
||||
}
|
||||
@@ -464,6 +490,7 @@ type NV_HOPPER_USERMODE_A_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV9072_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
LogicalHeadID uint32
|
||||
DisplayMask uint32
|
||||
Caps uint32
|
||||
@@ -474,6 +501,7 @@ type NV9072_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00DE_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Reserved uint32
|
||||
}
|
||||
|
||||
@@ -482,11 +510,13 @@ type NV00DE_ALLOC_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00DE_ALLOC_PARAMETERS_V545 struct {
|
||||
_ structs.HostLayout
|
||||
PolledDataMask uint64
|
||||
}
|
||||
|
||||
// +marshal
|
||||
type nv00f8Map struct {
|
||||
_ structs.HostLayout
|
||||
offset uint64
|
||||
hVidMem Handle
|
||||
flags uint32
|
||||
@@ -503,6 +533,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV_EXPORT_MEM_PACKET struct {
|
||||
_ structs.HostLayout
|
||||
UUID [NV_MEM_EXPORT_UUID_LEN]uint8
|
||||
Opaque [16]uint8
|
||||
}
|
||||
@@ -512,6 +543,7 @@ type NV_EXPORT_MEM_PACKET struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00E0_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
IMEXChannel uint32
|
||||
Packet NV_EXPORT_MEM_PACKET
|
||||
NumMaxHandles uint16
|
||||
@@ -529,6 +561,7 @@ type NV00E0_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00F1_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
CapDescriptor uint64
|
||||
Flags uint32
|
||||
Pad0 [4]byte
|
||||
@@ -546,6 +579,7 @@ type NV00F1_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00F8_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Alignment uint64
|
||||
AllocSize uint64
|
||||
PageSize uint64
|
||||
@@ -560,6 +594,7 @@ type NV00F8_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00FB_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
ExportUUID [NV_MEM_EXPORT_UUID_LEN]uint8
|
||||
Index uint16
|
||||
Pad0 [2]byte
|
||||
@@ -572,6 +607,7 @@ type NV00FB_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00FD_ALLOCATION_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Alignment uint64
|
||||
AllocSize uint64
|
||||
PageSize uint32
|
||||
@@ -586,6 +622,7 @@ type NV00FD_ALLOCATION_PARAMETERS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV00FD_ALLOCATION_PARAMETERS_V545 struct {
|
||||
_ structs.HostLayout
|
||||
ExpPacket NV_EXPORT_MEM_PACKET
|
||||
Index uint16
|
||||
_ [6]byte
|
||||
@@ -597,6 +634,7 @@ type NV00FD_ALLOCATION_PARAMETERS_V545 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_MAPPER_ALLOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
unused uint8
|
||||
}
|
||||
|
||||
@@ -605,6 +643,7 @@ type NV_MEMORY_MAPPER_ALLOCATION_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
HSemaphoreSurface Handle
|
||||
MaxQueueSize uint32
|
||||
}
|
||||
@@ -614,6 +653,7 @@ type NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V555 struct {
|
||||
_ structs.HostLayout
|
||||
NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V550
|
||||
HNotificationMemory Handle
|
||||
_ uint32
|
||||
@@ -625,6 +665,7 @@ type NV_MEMORY_MAPPER_ALLOCATION_PARAMS_V555 struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV_CONFIDENTIAL_COMPUTE_ALLOC_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Handle Handle
|
||||
}
|
||||
|
||||
@@ -633,6 +674,7 @@ type NV_CONFIDENTIAL_COMPUTE_ALLOC_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NVA0BC_ALLOC_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
CodecType uint32
|
||||
HResolution uint32
|
||||
VResolution uint32
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package nvgpu
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// From src/nvidia/interface/deprecated/rmapi_deprecated.h:
|
||||
const (
|
||||
RM_GSS_LEGACY_MASK = 0x00008000
|
||||
@@ -38,6 +42,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NVXXXX_CTRL_XXX_INFO struct {
|
||||
_ structs.HostLayout
|
||||
Index uint32
|
||||
Data uint32
|
||||
}
|
||||
@@ -86,6 +91,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV0000_CTRL_GPU_GET_ID_INFO_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GpuID uint32
|
||||
GpuFlags uint32
|
||||
DeviceInstance uint32
|
||||
@@ -99,12 +105,14 @@ type NV0000_CTRL_GPU_GET_ID_INFO_PARAMS struct {
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_GPU_ATTACH_IDS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUIDs [NV0000_CTRL_GPU_MAX_PROBED_GPUS]uint32
|
||||
FailedID uint32
|
||||
}
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_GPU_GET_UUID_FROM_GPU_ID_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUID uint32
|
||||
Flags uint32
|
||||
GPUUUID [NV0000_GPU_MAX_GID_LENGTH]byte
|
||||
@@ -139,6 +147,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GpuIDs [NV0000_CTRL_SYSTEM_MAX_ATTACHED_GPUS]uint32
|
||||
GpuCount uint32
|
||||
P2PCaps uint32
|
||||
@@ -154,6 +163,7 @@ type NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
NV0000_CTRL_SYSTEM_GET_P2P_CAPS_PARAMS
|
||||
BusEgmPeerIDs P64
|
||||
}
|
||||
@@ -172,6 +182,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
DeviceInstance uint32
|
||||
MaxObjects uint16
|
||||
@@ -191,6 +202,7 @@ func (p *NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS) SetFrontendFD(fd int
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_V545 struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
DeviceInstance uint32
|
||||
GpuInstanceID uint32
|
||||
@@ -211,12 +223,14 @@ func (p *NV0000_CTRL_OS_UNIX_GET_EXPORT_OBJECT_INFO_PARAMS_V545) SetFrontendFD(f
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_EXPORT_OBJECT struct {
|
||||
_ structs.HostLayout
|
||||
Type uint32 // enum NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TYPE
|
||||
Data [12]byte // union
|
||||
}
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Object NV0000_CTRL_OS_UNIX_EXPORT_OBJECT
|
||||
FD int32
|
||||
Flags uint32
|
||||
@@ -234,6 +248,7 @@ func (p *NV0000_CTRL_OS_UNIX_EXPORT_OBJECT_TO_FD_PARAMS) SetFrontendFD(fd int32)
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
Object NV0000_CTRL_OS_UNIX_EXPORT_OBJECT
|
||||
}
|
||||
@@ -250,6 +265,7 @@ func (p *NV0000_CTRL_OS_UNIX_IMPORT_OBJECT_FROM_FD_PARAMS) SetFrontendFD(fd int3
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
HDevice Handle
|
||||
MaxObjects uint16
|
||||
@@ -272,6 +288,7 @@ func (p *NV0000_CTRL_OS_UNIX_EXPORT_OBJECTS_TO_FD_PARAMS) SetFrontendFD(fd int32
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
FD int32
|
||||
HParent Handle
|
||||
Objects [NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_TO_FD_MAX_OBJECTS]Handle
|
||||
@@ -292,6 +309,7 @@ func (p *NV0000_CTRL_OS_UNIX_IMPORT_OBJECTS_FROM_FD_PARAMS) SetFrontendFD(fd int
|
||||
|
||||
// +marshal
|
||||
type NV0000_CTRL_SYSTEM_GET_BUILD_VERSION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
SizeOfStrings uint32
|
||||
Pad [4]byte
|
||||
PDriverVersionBuffer P64
|
||||
@@ -328,6 +346,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV0080_CTRL_FIFO_GET_CHANNELLIST_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
NumChannels uint32
|
||||
Pad [4]byte
|
||||
PChannelHandleList P64
|
||||
@@ -349,6 +368,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type RmapiParamNvU32List struct {
|
||||
_ structs.HostLayout
|
||||
NumElems uint32
|
||||
Pad [4]byte
|
||||
List P64
|
||||
@@ -369,6 +389,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV0080_CTRL_GET_CAPS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
CapsTblSize uint32
|
||||
Pad [4]byte
|
||||
CapsTbl P64
|
||||
@@ -376,6 +397,7 @@ type NV0080_CTRL_GET_CAPS_PARAMS struct {
|
||||
|
||||
// +marshal
|
||||
type NV0080_CTRL_GR_ROUTE_INFO struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint32
|
||||
Pad [4]byte
|
||||
Route uint64
|
||||
@@ -391,6 +413,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NV208F_CTRL_GPU_VERIFY_INFOROM_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Result uint32
|
||||
Checksum uint32
|
||||
}
|
||||
@@ -404,6 +427,7 @@ type NV208F_CTRL_GPU_VERIFY_INFOROM_PARAMS struct {
|
||||
//
|
||||
// +marshal
|
||||
type NvxxxCtrlXxxGetInfoParams struct {
|
||||
_ structs.HostLayout
|
||||
InfoListSize uint32
|
||||
Pad [4]byte
|
||||
InfoList P64
|
||||
@@ -495,6 +519,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV00FD_CTRL_ATTACH_GPU_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
HSubDevice Handle
|
||||
Flags uint32
|
||||
DevDescriptor uint64
|
||||
@@ -554,6 +579,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV2080_CTRL_FIFO_DISABLE_CHANNELS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
BDisable uint8
|
||||
Pad1 [3]byte
|
||||
NumChannels uint32
|
||||
@@ -619,6 +645,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV2080_CTRL_GR_GET_INFO_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
NvxxxCtrlXxxGetInfoParams
|
||||
GRRouteInfo NV0080_CTRL_GR_ROUTE_INFO
|
||||
}
|
||||
@@ -690,6 +717,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type NV503C_CTRL_REGISTER_VA_SPACE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
HVASpace Handle
|
||||
Pad [4]byte
|
||||
VASpaceToken uint64
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
package nvgpu
|
||||
|
||||
import (
|
||||
"structs"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/marshal"
|
||||
)
|
||||
|
||||
@@ -64,6 +66,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IoctlCardInfo struct {
|
||||
_ structs.HostLayout
|
||||
Valid uint8
|
||||
Pad0 [3]byte
|
||||
PCIInfo PCIInfo
|
||||
@@ -83,6 +86,7 @@ type IoctlCardInfo struct {
|
||||
//
|
||||
// +marshal
|
||||
type PCIInfo struct {
|
||||
_ structs.HostLayout
|
||||
Domain uint32
|
||||
Bus uint8
|
||||
Slot uint8
|
||||
@@ -96,6 +100,7 @@ type PCIInfo struct {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlRegisterFD struct {
|
||||
_ structs.HostLayout
|
||||
CtlFD int32
|
||||
}
|
||||
|
||||
@@ -103,6 +108,7 @@ type IoctlRegisterFD struct {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlAllocOSEvent struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HDevice Handle
|
||||
FD uint32
|
||||
@@ -133,6 +139,7 @@ func (p *IoctlAllocOSEvent) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlFreeOSEvent struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HDevice Handle
|
||||
FD uint32
|
||||
@@ -163,6 +170,7 @@ func (p *IoctlFreeOSEvent) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type RMAPIVersion struct {
|
||||
_ structs.HostLayout
|
||||
Cmd uint32
|
||||
Reply uint32
|
||||
VersionString [64]byte
|
||||
@@ -172,6 +180,7 @@ type RMAPIVersion struct {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlSysParams struct {
|
||||
_ structs.HostLayout
|
||||
MemblockSize uint64
|
||||
}
|
||||
|
||||
@@ -179,6 +188,7 @@ type IoctlSysParams struct {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlWaitOpenComplete struct {
|
||||
_ structs.HostLayout
|
||||
Rc int32
|
||||
AdapterStatus uint32
|
||||
}
|
||||
@@ -197,6 +207,7 @@ func (p *IoctlWaitOpenComplete) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type IoctlNVOS02ParametersWithFD struct {
|
||||
_ structs.HostLayout
|
||||
Params NVOS02_PARAMETERS
|
||||
FD int32
|
||||
Pad0 [4]byte
|
||||
@@ -214,6 +225,7 @@ func (p *IoctlNVOS02ParametersWithFD) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type NVOS02_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HRoot Handle
|
||||
HObjectParent Handle
|
||||
HObjectNew Handle
|
||||
@@ -241,6 +253,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NVOS00_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HRoot Handle
|
||||
HObjectParent Handle
|
||||
HObjectOld Handle
|
||||
@@ -285,6 +298,7 @@ func GetRmAllocParamObj(isNVOS64 bool) RmAllocParamType {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS21_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HRoot Handle
|
||||
HObjectParent Handle
|
||||
HObjectNew Handle
|
||||
@@ -355,6 +369,7 @@ func (n *NVOS21_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS55_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HParent Handle
|
||||
HObject Handle
|
||||
@@ -378,6 +393,7 @@ func (n *NVOS55_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS57_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HObject Handle
|
||||
SharePolicy RS_SHARE_POLICY
|
||||
@@ -398,6 +414,7 @@ func (n *NVOS57_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS30_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Client Handle
|
||||
Device Handle
|
||||
Channel Handle
|
||||
@@ -427,6 +444,7 @@ func (n *NVOS30_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS32_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HRoot Handle
|
||||
HObjectParent Handle
|
||||
Function uint32
|
||||
@@ -457,6 +475,7 @@ const (
|
||||
// NVOS32AllocSize is the type of NVOS32Parameters.Data for
|
||||
// NVOS32_FUNCTION_ALLOC_SIZE.
|
||||
type NVOS32AllocSize struct {
|
||||
_ structs.HostLayout
|
||||
Owner uint32
|
||||
HMemory Handle
|
||||
Type uint32
|
||||
@@ -505,6 +524,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type IoctlNVOS33ParametersWithFD struct {
|
||||
_ structs.HostLayout
|
||||
Params NVOS33_PARAMETERS
|
||||
FD int32
|
||||
Pad0 [4]byte
|
||||
@@ -522,6 +542,7 @@ func (p *IoctlNVOS33ParametersWithFD) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type NVOS33_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HDevice Handle
|
||||
HMemory Handle
|
||||
@@ -549,6 +570,7 @@ const (
|
||||
//
|
||||
// +marshal
|
||||
type NVOS34_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HDevice Handle
|
||||
HMemory Handle
|
||||
@@ -572,6 +594,7 @@ func (n *NVOS34_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS39_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HObjectParent Handle
|
||||
HSubDevice Handle
|
||||
HObjectNew Handle
|
||||
@@ -600,6 +623,7 @@ func (n *NVOS39_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS46_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Client Handle
|
||||
Device Handle
|
||||
Dma Handle
|
||||
@@ -628,6 +652,7 @@ func (n *NVOS46_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS46_PARAMETERS_V580 struct {
|
||||
_ structs.HostLayout
|
||||
Client Handle
|
||||
Device Handle
|
||||
Dma Handle
|
||||
@@ -657,6 +682,7 @@ func (n *NVOS46_PARAMETERS_V580) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS47_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
Client Handle
|
||||
Device Handle
|
||||
Dma Handle
|
||||
@@ -683,6 +709,7 @@ func (n *NVOS47_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS47_PARAMETERS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
Client Handle
|
||||
Device Handle
|
||||
Dma Handle
|
||||
@@ -709,6 +736,7 @@ func (n *NVOS47_PARAMETERS_V550) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS54_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HObject Handle
|
||||
Cmd uint32
|
||||
@@ -732,6 +760,7 @@ func (n *NVOS54_PARAMETERS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type NVOS56_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HClient Handle
|
||||
HDevice Handle
|
||||
HMemory Handle
|
||||
@@ -757,6 +786,7 @@ func (n *NVOS56_PARAMETERS) SetStatus(status uint32) {
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type NVOS64_PARAMETERS struct {
|
||||
_ structs.HostLayout
|
||||
HRoot Handle
|
||||
HObjectParent Handle
|
||||
HObjectNew Handle
|
||||
|
||||
@@ -18,6 +18,7 @@ package nvgpu
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Device numbers.
|
||||
@@ -39,6 +40,7 @@ const (
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type Handle struct {
|
||||
_ structs.HostLayout
|
||||
Val uint32
|
||||
}
|
||||
|
||||
@@ -70,6 +72,7 @@ const (
|
||||
// +marshal
|
||||
// +stateify savable
|
||||
type RS_ACCESS_MASK struct {
|
||||
_ structs.HostLayout
|
||||
Limbs [SDK_RS_ACCESS_MAX_LIMBS]uint32 // RsAccessLimb
|
||||
}
|
||||
|
||||
@@ -80,6 +83,7 @@ const SDK_RS_ACCESS_MAX_LIMBS = 1
|
||||
//
|
||||
// +marshal
|
||||
type RS_SHARE_POLICY struct {
|
||||
_ structs.HostLayout
|
||||
Target uint32
|
||||
AccessMask RS_ACCESS_MASK
|
||||
Type uint16
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
|
||||
package nvgpu
|
||||
|
||||
import (
|
||||
"structs"
|
||||
)
|
||||
|
||||
// UVM ioctl commands.
|
||||
const (
|
||||
// From kernel-open/nvidia-uvm/uvm_linux_ioctl.h:
|
||||
@@ -56,6 +60,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type UVM_INITIALIZE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Flags uint64
|
||||
RMStatus uint32
|
||||
Pad0 [4]byte
|
||||
@@ -78,6 +83,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type UVM_CREATE_RANGE_GROUP_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RangeGroupID uint64
|
||||
RMStatus uint32
|
||||
Pad0 [4]byte
|
||||
@@ -95,6 +101,7 @@ func (p *UVM_CREATE_RANGE_GROUP_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_DESTROY_RANGE_GROUP_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RangeGroupID uint64
|
||||
RMStatus uint32
|
||||
Pad0 [4]byte
|
||||
@@ -112,6 +119,7 @@ func (p *UVM_DESTROY_RANGE_GROUP_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_REGISTER_GPU_VASPACE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
RMCtrlFD int32
|
||||
HClient Handle
|
||||
@@ -141,6 +149,7 @@ func (p *UVM_REGISTER_GPU_VASPACE_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNREGISTER_GPU_VASPACE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
RMStatus uint32
|
||||
}
|
||||
@@ -157,6 +166,7 @@ func (p *UVM_UNREGISTER_GPU_VASPACE_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_REGISTER_CHANNEL_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
RMCtrlFD int32
|
||||
HClient Handle
|
||||
@@ -190,6 +200,7 @@ func (p *UVM_REGISTER_CHANNEL_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNREGISTER_CHANNEL_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
HClient Handle
|
||||
HChannel Handle
|
||||
@@ -208,6 +219,7 @@ func (p *UVM_UNREGISTER_CHANNEL_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_ENABLE_PEER_ACCESS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUIDA NvUUID
|
||||
GPUUUIDB NvUUID
|
||||
RMStatus uint32
|
||||
@@ -225,6 +237,7 @@ func (p *UVM_ENABLE_PEER_ACCESS_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_DISABLE_PEER_ACCESS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUIDA NvUUID
|
||||
GPUUUIDB NvUUID
|
||||
RMStatus uint32
|
||||
@@ -242,6 +255,7 @@ func (p *UVM_DISABLE_PEER_ACCESS_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_SET_RANGE_GROUP_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RangeGroupID uint64
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
@@ -261,6 +275,7 @@ func (p *UVM_SET_RANGE_GROUP_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MAP_EXTERNAL_ALLOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
Offset uint64
|
||||
@@ -294,6 +309,7 @@ func (p *UVM_MAP_EXTERNAL_ALLOCATION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MAP_EXTERNAL_ALLOCATION_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
Offset uint64
|
||||
@@ -327,6 +343,7 @@ func (p *UVM_MAP_EXTERNAL_ALLOCATION_PARAMS_V550) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_FREE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -345,6 +362,7 @@ func (p *UVM_FREE_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_REGISTER_GPU_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
NumaEnabled uint8
|
||||
Pad [3]byte
|
||||
@@ -377,6 +395,7 @@ func (p *UVM_REGISTER_GPU_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNREGISTER_GPU_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
RMStatus uint32
|
||||
}
|
||||
@@ -393,6 +412,7 @@ func (p *UVM_UNREGISTER_GPU_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_PAGEABLE_MEM_ACCESS_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
PageableMemAccess uint8
|
||||
Pad [3]byte
|
||||
RMStatus uint32
|
||||
@@ -410,6 +430,7 @@ func (p *UVM_PAGEABLE_MEM_ACCESS_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_SET_PREFERRED_LOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
PreferredLocation NvUUID
|
||||
@@ -429,6 +450,7 @@ func (p *UVM_SET_PREFERRED_LOCATION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_SET_PREFERRED_LOCATION_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
PreferredLocation NvUUID
|
||||
@@ -448,6 +470,7 @@ func (p *UVM_SET_PREFERRED_LOCATION_PARAMS_V550) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNSET_PREFERRED_LOCATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -466,6 +489,7 @@ func (p *UVM_UNSET_PREFERRED_LOCATION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_ENABLE_READ_DUPLICATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -484,6 +508,7 @@ func (p *UVM_ENABLE_READ_DUPLICATION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_DISABLE_READ_DUPLICATION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -502,6 +527,7 @@ func (p *UVM_DISABLE_READ_DUPLICATION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_SET_ACCESSED_BY_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
AccessedByUUID NvUUID
|
||||
@@ -521,6 +547,7 @@ func (p *UVM_SET_ACCESSED_BY_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNSET_ACCESSED_BY_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RequestedBase uint64
|
||||
Length uint64
|
||||
AccessedByUUID NvUUID
|
||||
@@ -540,6 +567,7 @@ func (p *UVM_UNSET_ACCESSED_BY_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MIGRATE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
DestinationUUID NvUUID
|
||||
@@ -569,6 +597,7 @@ func (p *UVM_MIGRATE_PARAMS) SetStatus(status uint32) {
|
||||
//
|
||||
// +marshal
|
||||
type UVM_MIGRATE_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
DestinationUUID NvUUID
|
||||
@@ -595,6 +624,7 @@ func (p *UVM_MIGRATE_PARAMS_V550) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MIGRATE_RANGE_GROUP_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
RangeGroupID uint64
|
||||
DestinationUUID NvUUID
|
||||
RMStatus uint32
|
||||
@@ -613,6 +643,7 @@ func (p *UVM_MIGRATE_RANGE_GROUP_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_TOOLS_READ_PROCESS_MEMORY_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Buffer uint64
|
||||
Size uint64
|
||||
TargetVA uint64
|
||||
@@ -633,6 +664,7 @@ func (p *UVM_TOOLS_READ_PROCESS_MEMORY_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_TOOLS_WRITE_PROCESS_MEMORY_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Buffer uint64
|
||||
Size uint64
|
||||
TargetVA uint64
|
||||
@@ -653,6 +685,7 @@ func (p *UVM_TOOLS_WRITE_PROCESS_MEMORY_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MAP_DYNAMIC_PARALLELISM_REGION_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
GPUUUID NvUUID
|
||||
@@ -672,6 +705,7 @@ func (p *UVM_MAP_DYNAMIC_PARALLELISM_REGION_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_UNMAP_EXTERNAL_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
GPUUUID NvUUID
|
||||
@@ -691,6 +725,7 @@ func (p *UVM_UNMAP_EXTERNAL_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_ALLOC_SEMAPHORE_POOL_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
PerGPUAttributes [UVM_MAX_GPUS]UvmGpuMappingAttributes
|
||||
@@ -711,6 +746,7 @@ func (p *UVM_ALLOC_SEMAPHORE_POOL_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_ALLOC_SEMAPHORE_POOL_PARAMS_V550 struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
PerGPUAttributes [UVM_MAX_GPUS_V2]UvmGpuMappingAttributes
|
||||
@@ -731,6 +767,7 @@ func (p *UVM_ALLOC_SEMAPHORE_POOL_PARAMS_V550) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
PageableMemAccess uint8
|
||||
Pad [3]byte
|
||||
@@ -749,6 +786,7 @@ func (p *UVM_PAGEABLE_MEM_ACCESS_ON_GPU_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_VALIDATE_VA_RANGE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -767,6 +805,7 @@ func (p *UVM_VALIDATE_VA_RANGE_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_CREATE_EXTERNAL_RANGE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
Base uint64
|
||||
Length uint64
|
||||
RMStatus uint32
|
||||
@@ -785,6 +824,7 @@ func (p *UVM_CREATE_EXTERNAL_RANGE_PARAMS) SetStatus(status uint32) {
|
||||
|
||||
// +marshal
|
||||
type UVM_MM_INITIALIZE_PARAMS struct {
|
||||
_ structs.HostLayout
|
||||
UvmFD int32
|
||||
RMStatus uint32
|
||||
}
|
||||
@@ -808,6 +848,7 @@ const (
|
||||
|
||||
// +marshal
|
||||
type UvmGpuMappingAttributes struct {
|
||||
_ structs.HostLayout
|
||||
GPUUUID NvUUID
|
||||
GPUMappingType uint32
|
||||
GPUCachingType uint32
|
||||
|
||||
@@ -11,5 +11,6 @@ go_library(
|
||||
"sentry.go",
|
||||
"syscall.go",
|
||||
],
|
||||
hostlayout = True,
|
||||
visibility = ["//:sandbox"],
|
||||
)
|
||||
|
||||
@@ -7,5 +7,6 @@ licenses(["notice"])
|
||||
go_library(
|
||||
name = "tpu",
|
||||
srcs = ["tpu.go"],
|
||||
hostlayout = True,
|
||||
visibility = ["//pkg/sentry:internal"],
|
||||
)
|
||||
|
||||
@@ -132,6 +132,16 @@ func (ins *Instruction) String() string {
|
||||
return s
|
||||
}
|
||||
|
||||
// RawInstruction returns a linux.BPFInstruction with the given fields.
|
||||
func RawInstruction(opCode uint16, jumpIfTrue, jumpIfFalse uint8, k uint32) Instruction {
|
||||
return Instruction{
|
||||
OpCode: opCode,
|
||||
JumpIfTrue: jumpIfTrue,
|
||||
JumpIfFalse: jumpIfFalse,
|
||||
K: k,
|
||||
}
|
||||
}
|
||||
|
||||
// Stmt returns an Instruction representing a BPF non-jump instruction.
|
||||
func Stmt(code uint16, k uint32) Instruction {
|
||||
return Instruction{
|
||||
|
||||
+15
-15
@@ -898,21 +898,21 @@ func TestValidInstructions(t *testing.T) {
|
||||
// Documentation/networking/filter.txt, translated to bytecode using the
|
||||
// Linux kernel tree's tools/net/bpf_asm.
|
||||
var sampleFilter = []Instruction{
|
||||
{0x20, 0, 0, 0x00000004}, // ld [4] /* offsetof(struct seccomp_data, arch) */
|
||||
{0x15, 0, 11, 0xc000003e}, // jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */
|
||||
{0x20, 0, 0, 0000000000}, // ld [0] /* offsetof(struct seccomp_data, nr) */
|
||||
{0x15, 10, 0, 0x0000000f}, // jeq #15, good /* __NR_rt_sigreturn */
|
||||
{0x15, 9, 0, 0x000000e7}, // jeq #231, good /* __NR_exit_group */
|
||||
{0x15, 8, 0, 0x0000003c}, // jeq #60, good /* __NR_exit */
|
||||
{0x15, 7, 0, 0000000000}, // jeq #0, good /* __NR_read */
|
||||
{0x15, 6, 0, 0x00000001}, // jeq #1, good /* __NR_write */
|
||||
{0x15, 5, 0, 0x00000005}, // jeq #5, good /* __NR_fstat */
|
||||
{0x15, 4, 0, 0x00000009}, // jeq #9, good /* __NR_mmap */
|
||||
{0x15, 3, 0, 0x0000000e}, // jeq #14, good /* __NR_rt_sigprocmask */
|
||||
{0x15, 2, 0, 0x0000000d}, // jeq #13, good /* __NR_rt_sigaction */
|
||||
{0x15, 1, 0, 0x00000023}, // jeq #35, good /* __NR_nanosleep */
|
||||
{0x06, 0, 0, 0000000000}, // bad: ret #0 /* SECCOMP_RET_KILL */
|
||||
{0x06, 0, 0, 0x7fff0000}, // good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */
|
||||
RawInstruction(0x20, 0, 0, 0x00000004), // ld [4] /* offsetof(struct seccomp_data, arch) */
|
||||
RawInstruction(0x15, 0, 11, 0xc000003e), // jne #0xc000003e, bad /* AUDIT_ARCH_X86_64 */
|
||||
RawInstruction(0x20, 0, 0, 0000000000), // ld [0] /* offsetof(struct seccomp_data, nr) */
|
||||
RawInstruction(0x15, 10, 0, 0x0000000f), // jeq #15, good /* __NR_rt_sigreturn */
|
||||
RawInstruction(0x15, 9, 0, 0x000000e7), // jeq #231, good /* __NR_exit_group */
|
||||
RawInstruction(0x15, 8, 0, 0x0000003c), // jeq #60, good /* __NR_exit */
|
||||
RawInstruction(0x15, 7, 0, 0000000000), // jeq #0, good /* __NR_read */
|
||||
RawInstruction(0x15, 6, 0, 0x00000001), // jeq #1, good /* __NR_write */
|
||||
RawInstruction(0x15, 5, 0, 0x00000005), // jeq #5, good /* __NR_fstat */
|
||||
RawInstruction(0x15, 4, 0, 0x00000009), // jeq #9, good /* __NR_mmap */
|
||||
RawInstruction(0x15, 3, 0, 0x0000000e), // jeq #14, good /* __NR_rt_sigprocmask */
|
||||
RawInstruction(0x15, 2, 0, 0x0000000d), // jeq #13, good /* __NR_rt_sigaction */
|
||||
RawInstruction(0x15, 1, 0, 0x00000023), // jeq #35, good /* __NR_nanosleep */
|
||||
RawInstruction(0x06, 0, 0, 0000000000), // bad: ret #0 /* SECCOMP_RET_KILL */
|
||||
RawInstruction(0x06, 0, 0, 0x7fff0000), // good: ret #0x7fff0000 /* SECCOMP_RET_ALLOW */
|
||||
}
|
||||
|
||||
func TestSimpleFilter(t *testing.T) {
|
||||
|
||||
+10
-1
@@ -11,6 +11,7 @@ load("//tools/bazeldefs:go.bzl", _gazelle = "gazelle", _go_binary = "go_binary",
|
||||
load("//tools/bazeldefs:pkg.bzl", _pkg_deb = "pkg_deb", _pkg_tar = "pkg_tar")
|
||||
load("//tools/bazeldefs:platforms.bzl", _default_platform = "default_platform", _platform_capabilities = "platform_capabilities", _platforms = "platforms", _save_restore_platforms = "save_restore_platforms")
|
||||
load("//tools/bazeldefs:tags.bzl", _go_suffixes = "go_suffixes", _local_test_tags = "local_test_tags")
|
||||
load("//tools/go_hostlayout:defs.bzl", "go_host_layout_struct_test")
|
||||
load("//tools/go_marshal:defs.bzl", "go_marshal", "marshal_deps", "marshal_test_deps")
|
||||
load("//tools/go_stateify:defs.bzl", "go_stateify")
|
||||
load("//tools/nogo:defs.bzl", "nogo_test")
|
||||
@@ -134,7 +135,7 @@ def calculate_sets(srcs):
|
||||
result[target].append(file)
|
||||
return result
|
||||
|
||||
def go_library(name, srcs, deps = [], imports = [], stateify = True, force_add_state_pkg = False, marshal = False, marshal_debug = False, nogo = True, **kwargs):
|
||||
def go_library(name, srcs, deps = [], imports = [], stateify = True, force_add_state_pkg = False, marshal = False, marshal_debug = False, nogo = True, hostlayout = False, **kwargs):
|
||||
"""Wraps the standard go_library and does stateification and marshalling.
|
||||
|
||||
The recommended way is to use this rule with mostly identical configuration as the native
|
||||
@@ -235,6 +236,14 @@ def go_library(name, srcs, deps = [], imports = [], stateify = True, force_add_s
|
||||
tags = ["nogo"],
|
||||
)
|
||||
|
||||
if hostlayout:
|
||||
go_host_layout_struct_test(
|
||||
go_test_rule_func = _go_test,
|
||||
name = name + "_hostlayout_test",
|
||||
srcs = [src for src in srcs if src.endswith(".go")],
|
||||
library = ":" + name,
|
||||
)
|
||||
|
||||
if marshal:
|
||||
# Ignore importpath for go_test.
|
||||
kwargs.pop("importpath", None)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
load("//tools:defs.bzl", "go_binary")
|
||||
|
||||
package(
|
||||
default_applicable_licenses = ["//:license"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
go_binary(
|
||||
name = "hostlayoutgen",
|
||||
srcs = [
|
||||
"hostlayoutgen.go",
|
||||
"hostlayoutgen_template.go",
|
||||
],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,31 @@
|
||||
"""Defines go_host_layout_struct_test to generate host layout struct tests."""
|
||||
|
||||
def go_host_layout_struct_test(go_test_rule_func, name, srcs, library, **kwargs):
|
||||
"""Checks that all structs in the given source file have _ structs.HostLayout as their first field.
|
||||
|
||||
Args:
|
||||
go_test_rule_func: the go_test rule function to use.
|
||||
name: the name of the test.
|
||||
srcs: the source files to check.
|
||||
library: the library that the source files belong to.
|
||||
**kwargs: standard arguments.
|
||||
"""
|
||||
gen_file = name + "_generated.go"
|
||||
|
||||
native.genrule(
|
||||
name = name + "_gen",
|
||||
srcs = srcs + [library],
|
||||
outs = [gen_file],
|
||||
tools = ["//tools/go_hostlayout:hostlayoutgen"],
|
||||
cmd = "$(location //tools/go_hostlayout:hostlayoutgen) -package " + library.replace(":", "/") + " -out $@ " + " ".join(["$(location %s)" % src for src in srcs]) + " -- $(locations " + library + ")",
|
||||
)
|
||||
|
||||
go_test_rule_func(
|
||||
name = name,
|
||||
srcs = [gen_file],
|
||||
deps = [
|
||||
library,
|
||||
"//tools/go_hostlayout/hostlayoutcheck",
|
||||
],
|
||||
**kwargs
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
load("//tools:defs.bzl", "go_library")
|
||||
|
||||
package(
|
||||
default_applicable_licenses = ["//:license"],
|
||||
licenses = ["notice"],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "hostlayoutcheck",
|
||||
srcs = ["hostlayoutcheck.go"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,91 @@
|
||||
// Copyright 2026 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 hostlayoutcheck checks for `structs.HostLayout` usage.
|
||||
package hostlayoutcheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"structs"
|
||||
)
|
||||
|
||||
// Validate checks that t is a struct type and has _ structs.HostLayout as its first field.
|
||||
// It recursively checks all struct-typed fields.
|
||||
func Validate(t reflect.Type) error {
|
||||
if t.Kind() != reflect.Struct {
|
||||
return fmt.Errorf("type %v is not a struct", t)
|
||||
}
|
||||
|
||||
if t.NumField() == 0 {
|
||||
return fmt.Errorf("struct %v is empty, expected first field to be `_ structs.HostLayout`", t)
|
||||
}
|
||||
|
||||
f := t.Field(0)
|
||||
// We check if the type of the first field is structs.HostLayout.
|
||||
if f.Type != reflect.TypeOf(structs.HostLayout{}) {
|
||||
return fmt.Errorf("struct %v first field must be `structs.HostLayout`, got `%v`", t, f.Type)
|
||||
}
|
||||
|
||||
if f.Name != "_" {
|
||||
return fmt.Errorf("struct %v first field must be named `_`, got `%s`", t, f.Name)
|
||||
}
|
||||
|
||||
// Recursive check for all other fields.
|
||||
// We skip the first field as it is the marker itself.
|
||||
for i := 1; i < t.NumField(); i++ {
|
||||
field := t.Field(i)
|
||||
|
||||
// Skip fields tagged with `hostlayout:"ignore"`.
|
||||
if tag := field.Tag.Get("hostlayout"); tag == "ignore" {
|
||||
continue
|
||||
}
|
||||
|
||||
fieldType := field.Type
|
||||
switch fieldType.Kind() {
|
||||
case reflect.Struct:
|
||||
if err := Validate(fieldType); err != nil {
|
||||
return fmt.Errorf("field %s: %w", field.Name, err)
|
||||
}
|
||||
case reflect.Array:
|
||||
if fieldType.Elem().Kind() == reflect.Struct {
|
||||
if err := Validate(fieldType.Elem()); err != nil {
|
||||
return fmt.Errorf("field %s: %w", field.Name, err)
|
||||
}
|
||||
}
|
||||
case reflect.Ptr:
|
||||
if fieldType.Elem().Kind() == reflect.Struct {
|
||||
if err := Validate(fieldType.Elem()); err != nil {
|
||||
return fmt.Errorf("field %s: %w", field.Name, err)
|
||||
}
|
||||
}
|
||||
case reflect.Map:
|
||||
return fmt.Errorf("field %s: maps are not allowed in host-layout-controlled structs (use `hostlayout:\"ignore\"` to bypass)", field.Name)
|
||||
case reflect.Chan:
|
||||
return fmt.Errorf("field %s: channels are not allowed in host-layout-controlled structs (use `hostlayout:\"ignore\"` to bypass)", field.Name)
|
||||
case reflect.Func:
|
||||
return fmt.Errorf("field %s: functions are not allowed in host-layout-controlled structs (use `hostlayout:\"ignore\"` to bypass)", field.Name)
|
||||
case reflect.Interface:
|
||||
return fmt.Errorf("field %s: interfaces are not allowed in host-layout-controlled structs (use `hostlayout:\"ignore\"` to bypass)", field.Name)
|
||||
case reflect.Slice:
|
||||
return fmt.Errorf("field %s: slices are not allowed in host-layout-controlled structs (use `hostlayout:\"ignore\"` to bypass)", field.Name)
|
||||
case reflect.String:
|
||||
// Allow strings only if they are specifically named "CString".
|
||||
if fieldType.Name() != "CString" {
|
||||
return fmt.Errorf("field %s: strings are not allowed in host-layout-controlled structs; use the CString type or `hostlayout:\"ignore\"` if you know what you are doing", field.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Copyright 2026 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.
|
||||
|
||||
// Generate a Go unit test file that checks for `structs.HostLayout` usage.
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"text/template"
|
||||
)
|
||||
|
||||
var (
|
||||
pkg = flag.String("package", "", "Name of the Go library package")
|
||||
outPath = flag.String("out", "", "Output test file path")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
if *pkg == "" || *outPath == "" {
|
||||
fmt.Fprintln(os.Stderr, "Usage: hostlayout -package <package> -out <output_test.go> src1.go src2.go -- lib.a lib.x")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var structs []string
|
||||
afterDashDash := false
|
||||
libraryImportPath := ""
|
||||
for _, srcPath := range flag.Args() {
|
||||
if srcPath == "--" {
|
||||
afterDashDash = true
|
||||
continue
|
||||
}
|
||||
if !afterDashDash {
|
||||
fset := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fset, srcPath, nil, parser.ParseComments)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to parse %s: %v\n", srcPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
for _, decl := range f.Decls {
|
||||
genDecl, ok := decl.(*ast.GenDecl)
|
||||
if !ok || genDecl.Tok != token.TYPE {
|
||||
continue
|
||||
}
|
||||
for _, spec := range genDecl.Specs {
|
||||
typeSpec, ok := spec.(*ast.TypeSpec)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
// Only check exported structs
|
||||
if !typeSpec.Name.IsExported() {
|
||||
continue
|
||||
}
|
||||
if _, ok := typeSpec.Type.(*ast.StructType); ok && !slices.Contains(structs, typeSpec.Name.Name) {
|
||||
// We check for slices.Contains because duplicates can happen,
|
||||
// for example due to files with conditional compilation directives.
|
||||
structs = append(structs, typeSpec.Name.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !strings.HasSuffix(srcPath, ".a") && !strings.HasSuffix(srcPath, ".x") {
|
||||
continue
|
||||
}
|
||||
libraryImportPath = strings.TrimSuffix(strings.TrimSuffix(srcPath, ".a"), ".x")
|
||||
}
|
||||
if libraryImportPath == "" {
|
||||
fmt.Fprintf(os.Stderr, "Failed to find library import path\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if len(structs) == 0 {
|
||||
// No exported structs, create empty test file to satisfy build rules
|
||||
contents := `
|
||||
package ` + filepath.Base(*pkg) + `_hostlayout_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDummy(t *testing.T) {
|
||||
// Needed to avoid errors in case the package has no exported structs.
|
||||
}
|
||||
`
|
||||
if err := os.WriteFile(*outPath, []byte(contents), 0644); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write empty test file: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
tmplData, err := newTemplateData(filepath.Base(*pkg), libraryImportPath, structs)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to create template data: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create output file
|
||||
outF, err := os.Create(*outPath)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to create %s: %v\n", *outPath, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer outF.Close()
|
||||
t := template.Must(template.New("test").Parse(testTmpl))
|
||||
if err := t.Execute(outF, tmplData); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to execute template: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// Copyright 2026 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.
|
||||
|
||||
//go:build !false
|
||||
// +build !false
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const testTmpl = `// Autogenerated test for hostlayout check.
|
||||
package {{.Package}}_hostlayout_test
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"{{.ImportPath}}"
|
||||
"gvisor.dev/gvisor/tools/go_hostlayout/hostlayoutcheck"
|
||||
)
|
||||
|
||||
{{range .Structs}}
|
||||
func TestHostLayout_{{.}}(t *testing.T) {
|
||||
if err := hostlayoutcheck.Validate(reflect.TypeOf((*{{$.Package}}.{{.}})(nil)).Elem()); err != nil {
|
||||
t.Errorf("Struct {{.}} failed hostlayout check: %v", err)
|
||||
}
|
||||
}
|
||||
{{end}}
|
||||
`
|
||||
|
||||
type templateData struct {
|
||||
Package string
|
||||
ImportPath string
|
||||
Structs []string
|
||||
}
|
||||
|
||||
func newTemplateData(pkg string, importPath string, structs []string) (*templateData, error) {
|
||||
idx := strings.Index(importPath, "pkg/")
|
||||
if idx == -1 {
|
||||
return nil, fmt.Errorf("failed to find 'pkg/' in %q", importPath)
|
||||
}
|
||||
return &templateData{
|
||||
Package: pkg,
|
||||
ImportPath: filepath.Join("gvisor.dev", "gvisor", filepath.Dir(importPath[idx:])),
|
||||
Structs: structs,
|
||||
}, nil
|
||||
}
|
||||
@@ -65,6 +65,12 @@ func kindString(e ast.Expr) string {
|
||||
|
||||
func forEachStructField(st *ast.StructType, fn func(f *ast.Field)) {
|
||||
for _, field := range st.Fields.List {
|
||||
// Ignore structs.HostLayout field if present.
|
||||
if selExpr, ok := field.Type.(*ast.SelectorExpr); ok {
|
||||
if xIdent, ok := selExpr.X.(*ast.Ident); ok && xIdent.Name == "structs" && selExpr.Sel.Name == "HostLayout" {
|
||||
continue
|
||||
}
|
||||
}
|
||||
fn(field)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user