snapshot: sagernet/gvisor v0.0.0-20250811.0-sing-box-mod.1
Содержимое пина, зафиксированного в go.mod sing-box-lx, одним коммитом без истории. Полная история SagerNet/gvisor — 1.45 ГБ и клонируется в каждой CI-джобе; наша дельта — одна вставка в одну функцию, история для неё не нужна. Module path github.com/sagernet/gvisor сохранён намеренно: на него опирается replace-директива суперпроекта. Патч поверх — отдельным коммитом, чтобы дельта читалась одним git show и переносилась на новый пин копированием. SPECS/TASKS/048-GVISOR_HANDSHAKE_NIL_CRASH
This commit is contained in:
commit
2c4ae3b0a4
712 changed files with 185689 additions and 0 deletions
127
pkg/abi/gasket/gasket.go
Normal file
127
pkg/abi/gasket/gasket.go
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
// Copyright 2023 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 gasket describes the userspace interface for Gasket devices.
|
||||
package gasket
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sagernet/gvisor/pkg/abi/linux"
|
||||
)
|
||||
|
||||
// Ioctl represents a gasket ioctl command.
|
||||
type Ioctl uint32
|
||||
|
||||
// From https://github.com/tensorflow/tpu/blob/master/tools/driver/include/linux/google/gasket.h
|
||||
var (
|
||||
GASKET_IOCTL_BASE = uint32(0xDC)
|
||||
GASKET_IOCTL_RESET = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 0, SizeOfUnsignedLong))
|
||||
GASKET_IOCTL_SET_EVENTFD = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 1, SizeofGasketInterruptEventFd))
|
||||
GASKET_IOCTL_CLEAR_EVENTFD = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 2, SizeOfUnsignedLong))
|
||||
GASKET_IOCTL_NUMBER_PAGE_TABLES = Ioctl(linux.IOR(GASKET_IOCTL_BASE, 4, SizeOfUnsignedLong))
|
||||
GASKET_IOCTL_PAGE_TABLE_SIZE = Ioctl(linux.IOWR(GASKET_IOCTL_BASE, 5, SizeofGasketPageTableIoctl))
|
||||
GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE = Ioctl(linux.IOWR(GASKET_IOCTL_BASE, 6, SizeofGasketPageTableIoctl))
|
||||
GASKET_IOCTL_PARTITION_PAGE_TABLE = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 7, SizeofGasketPageTableIoctl))
|
||||
GASKET_IOCTL_MAP_BUFFER = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 8, SizeofGasketPageTableIoctl))
|
||||
GASKET_IOCTL_UNMAP_BUFFER = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 9, SizeofGasketPageTableIoctl))
|
||||
GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS = Ioctl(linux.IO(GASKET_IOCTL_BASE, 10))
|
||||
GASKET_IOCTL_REGISTER_INTERRUPT = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 11, SizeofGasketInterruptMapping))
|
||||
GASKET_IOCTL_UNREGISTER_INTERRUPT = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 12, SizeOfUnsignedLong))
|
||||
GASKET_IOCTL_MAP_DMA_BUF = Ioctl(linux.IOW(GASKET_IOCTL_BASE, 13, SizeofGasketPageTableDmaBufIoctl))
|
||||
)
|
||||
|
||||
func (i Ioctl) String() string {
|
||||
switch i {
|
||||
case GASKET_IOCTL_RESET:
|
||||
return "GASKET_IOCTL_RESET"
|
||||
case GASKET_IOCTL_SET_EVENTFD:
|
||||
return "GASKET_IOCTL_SET_EVENTFD"
|
||||
case GASKET_IOCTL_CLEAR_EVENTFD:
|
||||
return "GASKET_IOCTL_CLEAR_EVENTFD"
|
||||
case GASKET_IOCTL_NUMBER_PAGE_TABLES:
|
||||
return "GASKET_IOCTL_NUMBER_PAGE_TABLES"
|
||||
case GASKET_IOCTL_PAGE_TABLE_SIZE:
|
||||
return "GASKET_IOCTL_PAGE_TABLE_SIZE"
|
||||
case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
|
||||
return "GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE"
|
||||
case GASKET_IOCTL_PARTITION_PAGE_TABLE:
|
||||
return "GASKET_IOCTL_PARTITION_PAGE_TABLE"
|
||||
case GASKET_IOCTL_MAP_BUFFER:
|
||||
return "GASKET_IOCTL_MAP_BUFFER"
|
||||
case GASKET_IOCTL_UNMAP_BUFFER:
|
||||
return "GASKET_IOCTL_UNMAP_BUFFER"
|
||||
case GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS:
|
||||
return "GASKET_IOCTL_CLEAR_INTERRUPT_COUNTS"
|
||||
case GASKET_IOCTL_REGISTER_INTERRUPT:
|
||||
return "GASKET_IOCTL_REGISTER_INTERRUPT"
|
||||
case GASKET_IOCTL_UNREGISTER_INTERRUPT:
|
||||
return "GASKET_IOCTL_UNREGISTER_INTERRUPT"
|
||||
case GASKET_IOCTL_MAP_DMA_BUF:
|
||||
return "GASKET_IOCTL_MAP_DMA_BUF"
|
||||
default:
|
||||
return fmt.Sprintf("UNKNOWN GASKET COMMAND %d", uint32(i))
|
||||
}
|
||||
}
|
||||
|
||||
// GasketInterruptEventFd is the common structure for ioctls associating an
|
||||
// eventfd with a device interrupt, when using the Gasket interrupt module.
|
||||
//
|
||||
// +marshal
|
||||
type GasketInterruptEventFd struct {
|
||||
Interrupt uint64
|
||||
EventFD uint64
|
||||
}
|
||||
|
||||
// GasketPageTableIoctl is a common structure for ioctls mapping and unmapping
|
||||
// buffers when using the Gasket page_table module.
|
||||
//
|
||||
// +marshal
|
||||
type GasketPageTableIoctl struct {
|
||||
PageTableIndex uint64
|
||||
Size uint64
|
||||
HostAddress uint64
|
||||
DeviceAddress uint64
|
||||
}
|
||||
|
||||
// GasketInterruptMapping is a structure for ioctls associating an eventfd and
|
||||
// interrupt controlling bar register with a device interrupt, when using the
|
||||
// Gasket interrupt module.
|
||||
//
|
||||
// +marshal
|
||||
type GasketInterruptMapping struct {
|
||||
Interrupt uint64
|
||||
EventFD uint64
|
||||
BarIndex uint64
|
||||
RegOffset uint64
|
||||
}
|
||||
|
||||
// GasketPageTableDmaBufIoctl is a structure for dma_buf mapping ioctl
|
||||
// parameters.
|
||||
//
|
||||
// +marshal
|
||||
type GasketPageTableDmaBufIoctl struct {
|
||||
PageTableIndex uint64
|
||||
DeviceAddress uint64
|
||||
DMABufID int32 `marshal:"unaligned"` // Struct ends mid 64bit word.
|
||||
}
|
||||
|
||||
// Ioctl parameter struct sizes.
|
||||
var (
|
||||
SizeofGasketInterruptEventFd = uint32((*GasketInterruptEventFd)(nil).SizeBytes())
|
||||
SizeofGasketPageTableIoctl = uint32((*GasketPageTableIoctl)(nil).SizeBytes())
|
||||
SizeofGasketInterruptMapping = uint32((*GasketInterruptMapping)(nil).SizeBytes())
|
||||
SizeofGasketPageTableDmaBufIoctl = uint32((*GasketPageTableDmaBufIoctl)(nil).SizeBytes())
|
||||
SizeOfUnsignedLong = uint32(8)
|
||||
)
|
||||
428
pkg/abi/gasket/gasket_abi_autogen_unsafe.go
Normal file
428
pkg/abi/gasket/gasket_abi_autogen_unsafe.go
Normal file
|
|
@ -0,0 +1,428 @@
|
|||
// Automatically generated marshal implementation. See tools/go_marshal.
|
||||
|
||||
package gasket
|
||||
|
||||
import (
|
||||
"io"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"unsafe"
|
||||
|
||||
"github.com/sagernet/gvisor/pkg/gohacks"
|
||||
"github.com/sagernet/gvisor/pkg/hostarch"
|
||||
"github.com/sagernet/gvisor/pkg/marshal"
|
||||
)
|
||||
|
||||
// Marshallable types used by this file.
|
||||
var (
|
||||
_ marshal.Marshallable = (*GasketInterruptEventFd)(nil)
|
||||
_ marshal.Marshallable = (*GasketInterruptMapping)(nil)
|
||||
_ marshal.Marshallable = (*GasketPageTableDmaBufIoctl)(nil)
|
||||
_ marshal.Marshallable = (*GasketPageTableIoctl)(nil)
|
||||
)
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
func (g *GasketInterruptEventFd) SizeBytes() int {
|
||||
return 16
|
||||
}
|
||||
|
||||
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
|
||||
func (g *GasketInterruptEventFd) MarshalBytes(dst []byte) []byte {
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
|
||||
dst = dst[8:]
|
||||
return dst
|
||||
}
|
||||
|
||||
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
|
||||
func (g *GasketInterruptEventFd) UnmarshalBytes(src []byte) []byte {
|
||||
g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
return src
|
||||
}
|
||||
|
||||
// Packed implements marshal.Marshallable.Packed.
|
||||
//
|
||||
//go:nosplit
|
||||
func (g *GasketInterruptEventFd) Packed() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
|
||||
func (g *GasketInterruptEventFd) MarshalUnsafe(dst []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
|
||||
return dst[size:]
|
||||
}
|
||||
|
||||
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
|
||||
func (g *GasketInterruptEventFd) UnmarshalUnsafe(src []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
|
||||
return src[size:]
|
||||
}
|
||||
|
||||
// CopyOutN implements marshal.Marshallable.CopyOutN.
|
||||
func (g *GasketInterruptEventFd) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyOut implements marshal.Marshallable.CopyOut.
|
||||
func (g *GasketInterruptEventFd) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyOutN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// CopyInN implements marshal.Marshallable.CopyInN.
|
||||
func (g *GasketInterruptEventFd) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyIn implements marshal.Marshallable.CopyIn.
|
||||
func (g *GasketInterruptEventFd) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyInN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo.WriteTo.
|
||||
func (g *GasketInterruptEventFd) WriteTo(writer io.Writer) (int64, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := writer.Write(buf)
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return int64(length), err
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
func (g *GasketInterruptMapping) SizeBytes() int {
|
||||
return 32
|
||||
}
|
||||
|
||||
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
|
||||
func (g *GasketInterruptMapping) MarshalBytes(dst []byte) []byte {
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.BarIndex))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.RegOffset))
|
||||
dst = dst[8:]
|
||||
return dst
|
||||
}
|
||||
|
||||
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
|
||||
func (g *GasketInterruptMapping) UnmarshalBytes(src []byte) []byte {
|
||||
g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.BarIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.RegOffset = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
return src
|
||||
}
|
||||
|
||||
// Packed implements marshal.Marshallable.Packed.
|
||||
//
|
||||
//go:nosplit
|
||||
func (g *GasketInterruptMapping) Packed() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
|
||||
func (g *GasketInterruptMapping) MarshalUnsafe(dst []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
|
||||
return dst[size:]
|
||||
}
|
||||
|
||||
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
|
||||
func (g *GasketInterruptMapping) UnmarshalUnsafe(src []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
|
||||
return src[size:]
|
||||
}
|
||||
|
||||
// CopyOutN implements marshal.Marshallable.CopyOutN.
|
||||
func (g *GasketInterruptMapping) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyOut implements marshal.Marshallable.CopyOut.
|
||||
func (g *GasketInterruptMapping) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyOutN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// CopyInN implements marshal.Marshallable.CopyInN.
|
||||
func (g *GasketInterruptMapping) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyIn implements marshal.Marshallable.CopyIn.
|
||||
func (g *GasketInterruptMapping) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyInN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo.WriteTo.
|
||||
func (g *GasketInterruptMapping) WriteTo(writer io.Writer) (int64, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := writer.Write(buf)
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return int64(length), err
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
func (g *GasketPageTableDmaBufIoctl) SizeBytes() int {
|
||||
return 20
|
||||
}
|
||||
|
||||
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
|
||||
func (g *GasketPageTableDmaBufIoctl) MarshalBytes(dst []byte) []byte {
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint32(dst[:4], uint32(g.DMABufID))
|
||||
dst = dst[4:]
|
||||
return dst
|
||||
}
|
||||
|
||||
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
|
||||
func (g *GasketPageTableDmaBufIoctl) UnmarshalBytes(src []byte) []byte {
|
||||
g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.DMABufID = int32(hostarch.ByteOrder.Uint32(src[:4]))
|
||||
src = src[4:]
|
||||
return src
|
||||
}
|
||||
|
||||
// Packed implements marshal.Marshallable.Packed.
|
||||
//
|
||||
//go:nosplit
|
||||
func (g *GasketPageTableDmaBufIoctl) Packed() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
|
||||
func (g *GasketPageTableDmaBufIoctl) MarshalUnsafe(dst []byte) []byte {
|
||||
// Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to MarshalBytes.
|
||||
return g.MarshalBytes(dst)
|
||||
}
|
||||
|
||||
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
|
||||
func (g *GasketPageTableDmaBufIoctl) UnmarshalUnsafe(src []byte) []byte {
|
||||
// Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to UnmarshalBytes.
|
||||
return g.UnmarshalBytes(src)
|
||||
}
|
||||
|
||||
// CopyOutN implements marshal.Marshallable.CopyOutN.
|
||||
func (g *GasketPageTableDmaBufIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
|
||||
buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
|
||||
g.MarshalBytes(buf) // escapes: fallback.
|
||||
return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
|
||||
}
|
||||
|
||||
// CopyOut implements marshal.Marshallable.CopyOut.
|
||||
func (g *GasketPageTableDmaBufIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyOutN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// CopyInN implements marshal.Marshallable.CopyInN.
|
||||
func (g *GasketPageTableDmaBufIoctl) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to UnmarshalBytes.
|
||||
buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
|
||||
length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Unmarshal unconditionally. If we had a short copy-in, this results in a
|
||||
// partially unmarshalled struct.
|
||||
g.UnmarshalBytes(buf) // escapes: fallback.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyIn implements marshal.Marshallable.CopyIn.
|
||||
func (g *GasketPageTableDmaBufIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyInN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo.WriteTo.
|
||||
func (g *GasketPageTableDmaBufIoctl) WriteTo(writer io.Writer) (int64, error) {
|
||||
// Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
|
||||
buf := make([]byte, g.SizeBytes())
|
||||
g.MarshalBytes(buf)
|
||||
length, err := writer.Write(buf)
|
||||
return int64(length), err
|
||||
}
|
||||
|
||||
// SizeBytes implements marshal.Marshallable.SizeBytes.
|
||||
func (g *GasketPageTableIoctl) SizeBytes() int {
|
||||
return 32
|
||||
}
|
||||
|
||||
// MarshalBytes implements marshal.Marshallable.MarshalBytes.
|
||||
func (g *GasketPageTableIoctl) MarshalBytes(dst []byte) []byte {
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Size))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.HostAddress))
|
||||
dst = dst[8:]
|
||||
hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
|
||||
dst = dst[8:]
|
||||
return dst
|
||||
}
|
||||
|
||||
// UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
|
||||
func (g *GasketPageTableIoctl) UnmarshalBytes(src []byte) []byte {
|
||||
g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.Size = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.HostAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
|
||||
src = src[8:]
|
||||
return src
|
||||
}
|
||||
|
||||
// Packed implements marshal.Marshallable.Packed.
|
||||
//
|
||||
//go:nosplit
|
||||
func (g *GasketPageTableIoctl) Packed() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
|
||||
func (g *GasketPageTableIoctl) MarshalUnsafe(dst []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
|
||||
return dst[size:]
|
||||
}
|
||||
|
||||
// UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
|
||||
func (g *GasketPageTableIoctl) UnmarshalUnsafe(src []byte) []byte {
|
||||
size := g.SizeBytes()
|
||||
gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
|
||||
return src[size:]
|
||||
}
|
||||
|
||||
// CopyOutN implements marshal.Marshallable.CopyOutN.
|
||||
func (g *GasketPageTableIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyOut implements marshal.Marshallable.CopyOut.
|
||||
func (g *GasketPageTableIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyOutN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// CopyInN implements marshal.Marshallable.CopyInN.
|
||||
func (g *GasketPageTableIoctl) CopyInN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := cc.CopyInBytes(addr, buf[:limit]) // escapes: okay.
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return length, err
|
||||
}
|
||||
|
||||
// CopyIn implements marshal.Marshallable.CopyIn.
|
||||
func (g *GasketPageTableIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
|
||||
return g.CopyInN(cc, addr, g.SizeBytes())
|
||||
}
|
||||
|
||||
// WriteTo implements io.WriterTo.WriteTo.
|
||||
func (g *GasketPageTableIoctl) WriteTo(writer io.Writer) (int64, error) {
|
||||
// Construct a slice backed by dst's underlying memory.
|
||||
var buf []byte
|
||||
hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
|
||||
hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
|
||||
hdr.Len = g.SizeBytes()
|
||||
hdr.Cap = g.SizeBytes()
|
||||
|
||||
length, err := writer.Write(buf)
|
||||
// Since we bypassed the compiler's escape analysis, indicate that g
|
||||
// must live until the use above.
|
||||
runtime.KeepAlive(g) // escapes: replaced by intrinsic.
|
||||
return int64(length), err
|
||||
}
|
||||
3
pkg/abi/gasket/gasket_state_autogen.go
Normal file
3
pkg/abi/gasket/gasket_state_autogen.go
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
// automatically generated by stateify.
|
||||
|
||||
package gasket
|
||||
Loading…
Add table
Add a link
Reference in a new issue