github.com/nicocha30/gvisor-ligolo@v0.0.0-20230726075806-989fa2c0a413/pkg/abi/gasket/gasket_abi_autogen_unsafe.go (about)

     1  // Automatically generated marshal implementation. See tools/go_marshal.
     2  
     3  package gasket
     4  
     5  import (
     6  	"github.com/nicocha30/gvisor-ligolo/pkg/gohacks"
     7  	"github.com/nicocha30/gvisor-ligolo/pkg/hostarch"
     8  	"github.com/nicocha30/gvisor-ligolo/pkg/marshal"
     9      "io"
    10      "reflect"
    11      "runtime"
    12      "unsafe"
    13  )
    14  
    15  // Marshallable types used by this file.
    16  var _ marshal.Marshallable = (*GasketInterruptEventFd)(nil)
    17  var _ marshal.Marshallable = (*GasketInterruptMapping)(nil)
    18  var _ marshal.Marshallable = (*GasketPageTableDmaBufIoctl)(nil)
    19  var _ marshal.Marshallable = (*GasketPageTableIoctl)(nil)
    20  
    21  // SizeBytes implements marshal.Marshallable.SizeBytes.
    22  func (g *GasketInterruptEventFd) SizeBytes() int {
    23      return 16
    24  }
    25  
    26  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
    27  func (g *GasketInterruptEventFd) MarshalBytes(dst []byte) []byte {
    28      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
    29      dst = dst[8:]
    30      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
    31      dst = dst[8:]
    32      return dst
    33  }
    34  
    35  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
    36  func (g *GasketInterruptEventFd) UnmarshalBytes(src []byte) []byte {
    37      g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
    38      src = src[8:]
    39      g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
    40      src = src[8:]
    41      return src
    42  }
    43  
    44  // Packed implements marshal.Marshallable.Packed.
    45  //go:nosplit
    46  func (g *GasketInterruptEventFd) Packed() bool {
    47      return true
    48  }
    49  
    50  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
    51  func (g *GasketInterruptEventFd) MarshalUnsafe(dst []byte) []byte {
    52      size := g.SizeBytes()
    53      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
    54      return dst[size:]
    55  }
    56  
    57  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
    58  func (g *GasketInterruptEventFd) UnmarshalUnsafe(src []byte) []byte {
    59      size := g.SizeBytes()
    60      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
    61      return src[size:]
    62  }
    63  
    64  // CopyOutN implements marshal.Marshallable.CopyOutN.
    65  func (g *GasketInterruptEventFd) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
    66      // Construct a slice backed by dst's underlying memory.
    67      var buf []byte
    68      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    69      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
    70      hdr.Len = g.SizeBytes()
    71      hdr.Cap = g.SizeBytes()
    72  
    73      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
    74      // Since we bypassed the compiler's escape analysis, indicate that g
    75      // must live until the use above.
    76      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
    77      return length, err
    78  }
    79  
    80  // CopyOut implements marshal.Marshallable.CopyOut.
    81  func (g *GasketInterruptEventFd) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    82      return g.CopyOutN(cc, addr, g.SizeBytes())
    83  }
    84  
    85  // CopyIn implements marshal.Marshallable.CopyIn.
    86  func (g *GasketInterruptEventFd) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
    87      // Construct a slice backed by dst's underlying memory.
    88      var buf []byte
    89      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
    90      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
    91      hdr.Len = g.SizeBytes()
    92      hdr.Cap = g.SizeBytes()
    93  
    94      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
    95      // Since we bypassed the compiler's escape analysis, indicate that g
    96      // must live until the use above.
    97      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
    98      return length, err
    99  }
   100  
   101  // WriteTo implements io.WriterTo.WriteTo.
   102  func (g *GasketInterruptEventFd) WriteTo(writer io.Writer) (int64, error) {
   103      // Construct a slice backed by dst's underlying memory.
   104      var buf []byte
   105      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   106      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   107      hdr.Len = g.SizeBytes()
   108      hdr.Cap = g.SizeBytes()
   109  
   110      length, err := writer.Write(buf)
   111      // Since we bypassed the compiler's escape analysis, indicate that g
   112      // must live until the use above.
   113      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   114      return int64(length), err
   115  }
   116  
   117  // SizeBytes implements marshal.Marshallable.SizeBytes.
   118  func (g *GasketInterruptMapping) SizeBytes() int {
   119      return 32
   120  }
   121  
   122  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   123  func (g *GasketInterruptMapping) MarshalBytes(dst []byte) []byte {
   124      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Interrupt))
   125      dst = dst[8:]
   126      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.EventFD))
   127      dst = dst[8:]
   128      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.BarIndex))
   129      dst = dst[8:]
   130      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.RegOffset))
   131      dst = dst[8:]
   132      return dst
   133  }
   134  
   135  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   136  func (g *GasketInterruptMapping) UnmarshalBytes(src []byte) []byte {
   137      g.Interrupt = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   138      src = src[8:]
   139      g.EventFD = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   140      src = src[8:]
   141      g.BarIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   142      src = src[8:]
   143      g.RegOffset = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   144      src = src[8:]
   145      return src
   146  }
   147  
   148  // Packed implements marshal.Marshallable.Packed.
   149  //go:nosplit
   150  func (g *GasketInterruptMapping) Packed() bool {
   151      return true
   152  }
   153  
   154  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   155  func (g *GasketInterruptMapping) MarshalUnsafe(dst []byte) []byte {
   156      size := g.SizeBytes()
   157      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
   158      return dst[size:]
   159  }
   160  
   161  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   162  func (g *GasketInterruptMapping) UnmarshalUnsafe(src []byte) []byte {
   163      size := g.SizeBytes()
   164      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
   165      return src[size:]
   166  }
   167  
   168  // CopyOutN implements marshal.Marshallable.CopyOutN.
   169  func (g *GasketInterruptMapping) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   170      // Construct a slice backed by dst's underlying memory.
   171      var buf []byte
   172      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   173      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   174      hdr.Len = g.SizeBytes()
   175      hdr.Cap = g.SizeBytes()
   176  
   177      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   178      // Since we bypassed the compiler's escape analysis, indicate that g
   179      // must live until the use above.
   180      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   181      return length, err
   182  }
   183  
   184  // CopyOut implements marshal.Marshallable.CopyOut.
   185  func (g *GasketInterruptMapping) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   186      return g.CopyOutN(cc, addr, g.SizeBytes())
   187  }
   188  
   189  // CopyIn implements marshal.Marshallable.CopyIn.
   190  func (g *GasketInterruptMapping) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   191      // Construct a slice backed by dst's underlying memory.
   192      var buf []byte
   193      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   194      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   195      hdr.Len = g.SizeBytes()
   196      hdr.Cap = g.SizeBytes()
   197  
   198      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   199      // Since we bypassed the compiler's escape analysis, indicate that g
   200      // must live until the use above.
   201      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   202      return length, err
   203  }
   204  
   205  // WriteTo implements io.WriterTo.WriteTo.
   206  func (g *GasketInterruptMapping) WriteTo(writer io.Writer) (int64, error) {
   207      // Construct a slice backed by dst's underlying memory.
   208      var buf []byte
   209      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   210      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   211      hdr.Len = g.SizeBytes()
   212      hdr.Cap = g.SizeBytes()
   213  
   214      length, err := writer.Write(buf)
   215      // Since we bypassed the compiler's escape analysis, indicate that g
   216      // must live until the use above.
   217      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   218      return int64(length), err
   219  }
   220  
   221  // SizeBytes implements marshal.Marshallable.SizeBytes.
   222  func (g *GasketPageTableDmaBufIoctl) SizeBytes() int {
   223      return 20
   224  }
   225  
   226  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   227  func (g *GasketPageTableDmaBufIoctl) MarshalBytes(dst []byte) []byte {
   228      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
   229      dst = dst[8:]
   230      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
   231      dst = dst[8:]
   232      hostarch.ByteOrder.PutUint32(dst[:4], uint32(g.DMABufID))
   233      dst = dst[4:]
   234      return dst
   235  }
   236  
   237  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   238  func (g *GasketPageTableDmaBufIoctl) UnmarshalBytes(src []byte) []byte {
   239      g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   240      src = src[8:]
   241      g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   242      src = src[8:]
   243      g.DMABufID = int32(hostarch.ByteOrder.Uint32(src[:4]))
   244      src = src[4:]
   245      return src
   246  }
   247  
   248  // Packed implements marshal.Marshallable.Packed.
   249  //go:nosplit
   250  func (g *GasketPageTableDmaBufIoctl) Packed() bool {
   251      return false
   252  }
   253  
   254  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   255  func (g *GasketPageTableDmaBufIoctl) MarshalUnsafe(dst []byte) []byte {
   256      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to MarshalBytes.
   257      return g.MarshalBytes(dst)
   258  }
   259  
   260  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   261  func (g *GasketPageTableDmaBufIoctl) UnmarshalUnsafe(src []byte) []byte {
   262      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fallback to UnmarshalBytes.
   263      return g.UnmarshalBytes(src)
   264  }
   265  
   266  // CopyOutN implements marshal.Marshallable.CopyOutN.
   267  func (g *GasketPageTableDmaBufIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   268      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
   269      buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
   270      g.MarshalBytes(buf) // escapes: fallback.
   271      return cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   272  }
   273  
   274  // CopyOut implements marshal.Marshallable.CopyOut.
   275  func (g *GasketPageTableDmaBufIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   276      return g.CopyOutN(cc, addr, g.SizeBytes())
   277  }
   278  
   279  // CopyIn implements marshal.Marshallable.CopyIn.
   280  func (g *GasketPageTableDmaBufIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   281      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to UnmarshalBytes.
   282      buf := cc.CopyScratchBuffer(g.SizeBytes()) // escapes: okay.
   283      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   284      // Unmarshal unconditionally. If we had a short copy-in, this results in a
   285      // partially unmarshalled struct.
   286      g.UnmarshalBytes(buf) // escapes: fallback.
   287      return length, err
   288  }
   289  
   290  // WriteTo implements io.WriterTo.WriteTo.
   291  func (g *GasketPageTableDmaBufIoctl) WriteTo(writer io.Writer) (int64, error) {
   292      // Type GasketPageTableDmaBufIoctl doesn't have a packed layout in memory, fall back to MarshalBytes.
   293      buf := make([]byte, g.SizeBytes())
   294      g.MarshalBytes(buf)
   295      length, err := writer.Write(buf)
   296      return int64(length), err
   297  }
   298  
   299  // SizeBytes implements marshal.Marshallable.SizeBytes.
   300  func (g *GasketPageTableIoctl) SizeBytes() int {
   301      return 32
   302  }
   303  
   304  // MarshalBytes implements marshal.Marshallable.MarshalBytes.
   305  func (g *GasketPageTableIoctl) MarshalBytes(dst []byte) []byte {
   306      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.PageTableIndex))
   307      dst = dst[8:]
   308      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.Size))
   309      dst = dst[8:]
   310      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.HostAddress))
   311      dst = dst[8:]
   312      hostarch.ByteOrder.PutUint64(dst[:8], uint64(g.DeviceAddress))
   313      dst = dst[8:]
   314      return dst
   315  }
   316  
   317  // UnmarshalBytes implements marshal.Marshallable.UnmarshalBytes.
   318  func (g *GasketPageTableIoctl) UnmarshalBytes(src []byte) []byte {
   319      g.PageTableIndex = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   320      src = src[8:]
   321      g.Size = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   322      src = src[8:]
   323      g.HostAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   324      src = src[8:]
   325      g.DeviceAddress = uint64(hostarch.ByteOrder.Uint64(src[:8]))
   326      src = src[8:]
   327      return src
   328  }
   329  
   330  // Packed implements marshal.Marshallable.Packed.
   331  //go:nosplit
   332  func (g *GasketPageTableIoctl) Packed() bool {
   333      return true
   334  }
   335  
   336  // MarshalUnsafe implements marshal.Marshallable.MarshalUnsafe.
   337  func (g *GasketPageTableIoctl) MarshalUnsafe(dst []byte) []byte {
   338      size := g.SizeBytes()
   339      gohacks.Memmove(unsafe.Pointer(&dst[0]), unsafe.Pointer(g), uintptr(size))
   340      return dst[size:]
   341  }
   342  
   343  // UnmarshalUnsafe implements marshal.Marshallable.UnmarshalUnsafe.
   344  func (g *GasketPageTableIoctl) UnmarshalUnsafe(src []byte) []byte {
   345      size := g.SizeBytes()
   346      gohacks.Memmove(unsafe.Pointer(g), unsafe.Pointer(&src[0]), uintptr(size))
   347      return src[size:]
   348  }
   349  
   350  // CopyOutN implements marshal.Marshallable.CopyOutN.
   351  func (g *GasketPageTableIoctl) CopyOutN(cc marshal.CopyContext, addr hostarch.Addr, limit int) (int, error) {
   352      // Construct a slice backed by dst's underlying memory.
   353      var buf []byte
   354      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   355      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   356      hdr.Len = g.SizeBytes()
   357      hdr.Cap = g.SizeBytes()
   358  
   359      length, err := cc.CopyOutBytes(addr, buf[:limit]) // escapes: okay.
   360      // Since we bypassed the compiler's escape analysis, indicate that g
   361      // must live until the use above.
   362      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   363      return length, err
   364  }
   365  
   366  // CopyOut implements marshal.Marshallable.CopyOut.
   367  func (g *GasketPageTableIoctl) CopyOut(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   368      return g.CopyOutN(cc, addr, g.SizeBytes())
   369  }
   370  
   371  // CopyIn implements marshal.Marshallable.CopyIn.
   372  func (g *GasketPageTableIoctl) CopyIn(cc marshal.CopyContext, addr hostarch.Addr) (int, error) {
   373      // Construct a slice backed by dst's underlying memory.
   374      var buf []byte
   375      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   376      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   377      hdr.Len = g.SizeBytes()
   378      hdr.Cap = g.SizeBytes()
   379  
   380      length, err := cc.CopyInBytes(addr, buf) // escapes: okay.
   381      // Since we bypassed the compiler's escape analysis, indicate that g
   382      // must live until the use above.
   383      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   384      return length, err
   385  }
   386  
   387  // WriteTo implements io.WriterTo.WriteTo.
   388  func (g *GasketPageTableIoctl) WriteTo(writer io.Writer) (int64, error) {
   389      // Construct a slice backed by dst's underlying memory.
   390      var buf []byte
   391      hdr := (*reflect.SliceHeader)(unsafe.Pointer(&buf))
   392      hdr.Data = uintptr(gohacks.Noescape(unsafe.Pointer(g)))
   393      hdr.Len = g.SizeBytes()
   394      hdr.Cap = g.SizeBytes()
   395  
   396      length, err := writer.Write(buf)
   397      // Since we bypassed the compiler's escape analysis, indicate that g
   398      // must live until the use above.
   399      runtime.KeepAlive(g) // escapes: replaced by intrinsic.
   400      return int64(length), err
   401  }
   402