Help us shape the future of Go! Take the 2026 Go Developer Survey

uffd

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

README

linux-uffd-go

linux-uffd-go is a Go package for working with Linux userfaultfd(2) without cgo at runtime.

  • Module path: github.com/niallnsec/linux-uffd-go
  • Package name: uffd
  • Target OS: Linux

The package is intended for applications that need to lazily populate memory from files, network-backed data sources, or other custom paging logic while staying in pure Go.

Features

  • Pure-Go runtime implementation
  • Linux kernel struct definitions generated with go tool cgo -godefs
  • Simple convenience API for common io.ReaderAt paging
  • Generic handler API for custom fault-resolution strategies
  • Unix socket helpers for passing userfaultfd file descriptors between processes
  • Default-safe UFFDIO_COPY population for caller-provided buffers
  • Explicit UFFDIO_MOVE opt-in for sacrificial mmap-backed buffers

Installation

go get github.com/niallnsec/linux-uffd-go@latest

Kernel support

  • Minimum supported kernel: Linux 4.3
  • CheckSupport() verifies that the running kernel supports the minimum feature set required by this package
  • The convenience helpers use UFFDIO_MOVE for their internal mmap scratch pages when the kernel advertises UFFD_FEATURE_MOVE
  • Caller-provided buffers use UFFDIO_COPY by default
  • PopulateMove allows callers to opt into UFFDIO_MOVE for buffers they know are safe to move

Package overview

The package exposes two levels of API.

1. Convenience helpers

For the common case where you want to register a memory region and populate it from an io.ReaderAt, use:

  • Register
  • Registration
  • Handle
  • HandleContext

Register returns a *Registration; call Close when you are done with the mapping and its userfaultfd.

2. Generic custom handler API

For custom paging strategies, use:

  • NewHandler
  • Handler.Serve
  • Fault
  • Resolver
  • Populate
  • PopulateMove
  • AllocateMoveBuffer

When you pass a userfaultfd between processes with the Unix socket helpers, the client and manager processes must have the same bit-ness. Mixed 32-bit and 64-bit setups are not supported.

This is the intended extension point when you want to:

  • populate pages from multiple sources
  • add tracing or metrics
  • prefetch or batch data
  • inject custom retry or cancellation behaviour

Examples

Runnable example programs live in examples/. That directory has its own go.mod, so example-only dependencies such as the AWS SDK for Go v2 do not affect the main module. See examples/README.md for file-backed, custom-handler, transferred-userfaultfd, S3-backed, and benchmark examples.

Basic example

package main

import (
	"bytes"
	"context"
	"log"

	uffd "github.com/niallnsec/linux-uffd-go"
)

func main() {
	if err := uffd.CheckSupport(); err != nil {
		log.Fatal(err)
	}

	payload := bytes.Repeat([]byte("hello"), 1024)
	reg, err := uffd.Register(len(payload))
	if err != nil {
		log.Fatal(err)
	}
	defer reg.Close()

	buf := reg.Bytes()

	go func() {
		if err := uffd.HandleContext(context.Background(), reg.UFFD(), reg.Start(), bytes.NewReader(payload)); err != nil {
			log.Fatal(err)
		}
	}()

	_ = buf
}

Custom handler example

The generic handler avoids exposing unsafe, raw fault messages, or ioctl details to ordinary callers:

handler := uffd.NewHandler(fd, nil)

err := handler.Serve(ctx, func(fault uffd.Fault, resolver uffd.Resolver) error {
	page := make([]byte, os.Getpagesize())
	pageAddress := fault.Address &^ uintptr(os.Getpagesize()-1)
	_, err := src.ReadAt(page, int64(pageAddress)-int64(start))
	if err != nil && !errors.Is(err, io.EOF) {
		return err
	}
	_, err = resolver.Populate(pageAddress, page)
	return err
})

If your handler wants to opt into UFFDIO_MOVE, allocate its scratch pages with AllocateMoveBuffer; it returns a private anonymous mmap that is safe to sacrifice to MOVE. Then call PopulateMove explicitly:

page, err := uffd.AllocateMoveBuffer(os.Getpagesize())
if err != nil {
	return err
}
defer page.Close()

err = handler.Serve(ctx, func(fault uffd.Fault, resolver uffd.Resolver) error {
	pageAddress := fault.Address &^ uintptr(os.Getpagesize()-1)
	clear(page.Bytes())
	_, err := src.ReadAt(page.Bytes(), int64(pageAddress)-int64(start))
	if err != nil && !errors.Is(err, io.EOF) {
		return err
	}
	_, err = resolver.PopulateMove(pageAddress, page.Bytes())
	return err
})

Why MOVE can be more efficient than COPY

UFFDIO_COPY resolves a fault by copying bytes from your source buffer into the faulting range. That is the safest default because the source buffer keeps its original mapping and contents.

UFFDIO_COPY

userspace scratch buffer           registered faulting address
+------------------------+         +------------------------+
| page bytes             | --copy->| new page with bytes    |
+------------------------+         +------------------------+

source buffer still points at the same backing page

UFFDIO_MOVE is different. Instead of copying page contents, the kernel can move the page itself by rewriting page-table entries (PTEs): the destination PTE is updated to point at the page that used to back the source buffer, and the source PTE is removed. Avoiding that extra page-sized memcpy can reduce memory bandwidth, cache churn, and latency on the fault path.

UFFDIO_MOVE (conceptually)

before:
  source VA -> source PTE -> physical page P
  dest   VA -> missing PTE

after:
  source VA -> no longer backed by page P
  dest   VA -> dest   PTE -> physical page P

That PTE remapping is exactly why the source must be a sacrificial anonymous mapping. After a successful MOVE, the old source virtual address should no longer be treated as owning the original bytes. Because that address still sits inside the same anonymous mapping, touching it again faults in zero-filled anonymous memory, which is what makes a single scratch buffer reusable.

This package therefore requires an anonymous private mmap for MOVE buffers. AllocateMoveBuffer creates a MAP_PRIVATE|MAP_ANONYMOUS region so the kernel can treat each page as an exclusive anonymous page, detach it from the temporary scratch address, and reattach it to the faulting address.

safe source for UFFDIO_MOVE in this package

temporary scratch VA -> private anonymous page
                                      |
                                      | PTE ownership is transferred
                                      v
registered fault VA  -> receives that same page

A normal Go slice is not a safe MOVE source:

  • it usually points into Go-managed heap pages that are not disposable scratch pages
  • MOVE changes virtual-to-physical page ownership rather than copying bytes
  • later reads from the original source address may observe a different page
  • file-backed or shared mappings do not fit the private-anonymous-page model

That is why:

  • the convenience helpers stage data in an internal anonymous mmap scratch page
  • Populate remains the default for caller-provided buffers
  • PopulateMove is the opt-in API for callers that already have a disposable anonymous mapping
  • when MOVE is unavailable or rejected for the requested span, the implementation falls back to UFFDIO_COPY

Open flags

To avoid requiring callers to import golang.org/x/sys/unix just to open a userfaultfd, the package exposes flag aliases for Open:

  • UFFD_O_CLOEXEC
  • UFFD_O_NONBLOCK
  • UFFD_OPEN_DEFAULT
  • UFFD_USER_MODE_ONLY

UFFD_OPEN_DEFAULT enables the package's normal close-on-exec and non-blocking behavior. Add UFFD_USER_MODE_ONLY explicitly when you need a descriptor that only handles user-mode faults.

Examples:

fd, err := uffd.Open(uffd.UFFD_OPEN_DEFAULT)

fd, err := uffd.Open(uffd.UFFD_OPEN_DEFAULT | uffd.UFFD_USER_MODE_ONLY)

reg, err := uffd.RegisterWithFlags(
	len(payload),
	uffd.UFFD_OPEN_DEFAULT|uffd.UFFD_USER_MODE_ONLY,
)

Generated Linux types

The Linux structs used by this package are generated using the same godefs-style workflow used by golang.org/x/sys/unix.

To regenerate them on Linux:

go generate ./...

Testing

Unit tests:

go test ./...

Linux integration tests:

LINUX_UFFD_GO_INTEGRATION=1 go test ./... -count=1

On non-Linux systems, use the included Docker harness:

make docker-test
make docker-test-integration

The Docker targets default to linux/arm64 on arm64/aarch64 hosts and to linux/amd64 otherwise. You can still override the platform explicitly:

make docker-test DOCKER_PLATFORM=linux/amd64

The integration target runs the container with:

  • --cap-add SYS_PTRACE
  • --security-opt seccomp=unconfined
Custom seccomp profile alternative

Instead of running the container with seccomp=unconfined, you can start from Docker's default seccomp profile and add an allow rule for the userfaultfd syscall.

The additional rule looks like this:

{
  "names": ["userfaultfd"],
  "action": "SCMP_ACT_ALLOW",
  "args": [],
  "comment": "Allow userfaultfd for linux-uffd-go",
  "includes": {},
  "excludes": {}
}

You would then run the container with that custom profile instead of seccomp=unconfined.

vm.unprivileged_userfaultfd

Linux exposes a sysctl that controls whether unprivileged processes may create userfaultfd file descriptors that can handle kernel page faults:

  • /proc/sys/vm/unprivileged_userfaultfd
  • sysctl vm.unprivileged_userfaultfd

Typical values:

  • 1: unprivileged processes may create userfaultfd file descriptors that can handle kernel page faults
  • 0: unprivileged processes must either:
    • have CAP_SYS_PTRACE, or
    • use UFFD_USER_MODE_ONLY to request a userspace-fault-only file descriptor

This matters in containers too. The default configuration for most linux hosts, vm.unprivileged_userfaultfd=0, is the reason why CAP_SYS_PTRACE is required for the integration tests. The convenience helpers in this package use UFFD_OPEN_DEFAULT by default, and if the userfaultfd(2) syscall returns EPERM they also try /dev/userfaultfd with USERFAULTFD_IOC_NEW. If your environment only permits userspace faults, opt into UFFD_USER_MODE_ONLY explicitly with Open, RegisterWithFlags, and CheckSupportWithFlags.

If you need a temporary override on a Linux host, the usual form is:

sudo sysctl -w vm.unprivileged_userfaultfd=1

To inspect the current value:

sysctl vm.unprivileged_userfaultfd

Attribution

This project was inspired by and partially based on:

The Linux type-generation workflow also follows the approach used by the Go authors in golang.org/x/sys/unix.

See NOTICE for detailed attribution.

License

Apache License, Version 2.0. See LICENSE.

Documentation

Overview

Package uffd provides Linux userfaultfd helpers without cgo at runtime.

Index

Constants

View Source
const (
	// UFFD_O_CLOEXEC requests that Open mark the returned descriptor
	// close-on-exec.
	UFFD_O_CLOEXEC = uintptr(unix.O_CLOEXEC)

	// UFFD_O_NONBLOCK requests that Open return a non-blocking descriptor.
	UFFD_O_NONBLOCK = uintptr(unix.O_NONBLOCK)

	// UFFD_OPEN_DEFAULT keeps the returned fd close-on-exec and non-blocking.
	//
	// Callers that specifically want a userspace-fault-only descriptor can add
	// UFFD_USER_MODE_ONLY explicitly.
	UFFD_OPEN_DEFAULT = uffdSharedOpenFlags

	// UFFD_API is the userfaultfd API version passed to UFFDIO_API during
	// descriptor initialisation.
	UFFD_API = uint64(0xAA)

	// UFFD_EVENT_PAGEFAULT identifies a missing-page event in UffdMsg.Event.
	UFFD_EVENT_PAGEFAULT = uint8(0x12)

	// UFFDIO_REGISTER_MODE_MISSING requests missing-page tracking when
	// registering a virtual address range.
	UFFDIO_REGISTER_MODE_MISSING = uint64(1)

	// UFFDIO_API is the ioctl number used to negotiate the userfaultfd API
	// version and feature bits.
	UFFDIO_API = uintptr(0xC018AA3F)

	// UFFDIO_REGISTER is the ioctl number used to register a virtual address
	// range for userfaultfd tracking.
	UFFDIO_REGISTER = uintptr(0xC020AA00)

	// UFFDIO_COPY is the ioctl number used to resolve a fault by copying bytes
	// into the registered range.
	UFFDIO_COPY = uintptr(0xC028AA03)

	// UFFDIO_MOVE is the ioctl number used to resolve a fault by moving page
	// contents into the registered range.
	UFFDIO_MOVE = uintptr(0xC028AA05)
)
View Source
const (
	// UFFD_FEATURE_MOVE is the feature bit negotiated through UFFDIO_API that
	// enables UFFDIO_MOVE support for a descriptor.
	UFFD_FEATURE_MOVE = uint64(1 << 16)

	// UFFD_USER_MODE_ONLY requests a descriptor that handles faults originating
	// in user mode and skips kernel-mode faults.
	UFFD_USER_MODE_ONLY = uintptr(1)
)

Variables

View Source
var (
	// ErrUnexpectedEventType indicates that a userfaultfd event other than a
	// missing-page fault was received by Handle.
	ErrUnexpectedEventType = errors.New("unexpected event type")

	// ErrInvalidFDsLength indicates that a Unix rights message contained an
	// unexpected number of file descriptors.
	ErrInvalidFDsLength = errors.New("invalid file descriptors length")

	// ErrUnsupportedPlatform indicates that the current GOOS/GOARCH does not
	// support the low-level userfaultfd implementation in this package.
	ErrUnsupportedPlatform = errors.New("userfaultfd is unsupported on this platform")

	// ErrInvalidPopulateRange indicates that Populate was asked to operate on a
	// destination or buffer length that is not page aligned.
	ErrInvalidPopulateRange = errors.New("populate range must be page aligned")
)

Functions

func CheckSupport

func CheckSupport() error

CheckSupport verifies that the running kernel supports at least the fallback UFFDIO_COPY mode used by this package and that the current process can open a userfaultfd with UFFD_OPEN_DEFAULT.

func CheckSupportWithFlags

func CheckSupportWithFlags(flags uintptr) error

CheckSupportWithFlags verifies that the running kernel supports at least the fallback UFFDIO_COPY mode used by this package and that the current process can open a userfaultfd with the supplied flags.

func GetCopyBytes

func GetCopyBytes(copy *UffdioCopy) int64

GetCopyBytes returns the completion count written back by UFFDIO_COPY.

func GetMoveBytes

func GetMoveBytes(move *UffdioMove) int64

GetMoveBytes returns the completion count written back by UFFDIO_MOVE.

func GetMsgArg

func GetMsgArg(msg *UffdMsg) [24]byte

GetMsgArg returns the raw 24-byte argument payload from a raw uffd_msg.

Callers can reinterpret the bytes according to the event type.

func GetMsgEvent

func GetMsgEvent(msg *UffdMsg) uint8

GetMsgEvent returns the event discriminator from a raw uffd_msg.

func GetPagefaultAddress

func GetPagefaultAddress(pagefault *UffdPagefault) uint64

GetPagefaultAddress returns the fault address encoded in a pagefault payload.

func Handle

func Handle(uffd UFFD, start uintptr, src io.ReaderAt) error

Handle is shorthand for HandleContext with context.Background().

func HandleContext

func HandleContext(ctx context.Context, uffd UFFD, start uintptr, src io.ReaderAt) error

HandleContext serves missing-page userfaultfd events until the context is cancelled or an error occurs.

It reads faulted pages from src using offsets relative to start, stages the bytes in an internal mmap-backed scratch page, and resolves faults with PopulateMove so MOVE is used when the descriptor supports it and COPY is used otherwise.

func Populate

func Populate(uffd UFFD, address uintptr, data []byte) (int64, error)

Populate resolves one missing-page range with UFFDIO_COPY.

address must be page aligned and len(data) must be a multiple of the system page size, otherwise it returns ErrInvalidPopulateRange.

func PopulateMove

func PopulateMove(uffd UFFD, address uintptr, data []byte) (int64, error)

PopulateMove resolves one missing-page range while allowing UFFDIO_MOVE when the descriptor advertises support for it and the target address falls within a registered range known to this package. Callers must ensure that the source buffer is safe to hand to MOVE, which clears the source PTE so later access faults in zero-filled memory again within the same anonymous mapping.

address must be page aligned and len(data) must be a multiple of the system page size, otherwise it returns ErrInvalidPopulateRange.

func ReceiveFDs

func ReceiveFDs(conn *net.UnixConn, num int) ([]uintptr, error)

ReceiveFDs receives num file descriptors via SCM_RIGHTS on conn.

If num is zero or negative it returns an empty slice and no error.

func SendFDs

func SendFDs(conn *net.UnixConn, fds []uintptr) error

SendFDs sends the supplied file descriptors over conn using SCM_RIGHTS.

If fds is empty it returns nil without writing to the socket.

func SendUFFD

func SendUFFD(conn *net.UnixConn, uffd UFFD, start uintptr) error

SendUFFD sends a userfaultfd and its associated start address over a Unix domain socket.

It also transmits cached feature and registered-range metadata so a receiver can continue using PopulateMove without re-probing the descriptor.

Types

type Fault

type Fault struct {
	// Address is the memory address at which the fault occured.
	Address uintptr
}

Fault describes a missing-page event delivered by userfaultfd.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler serves missing-page events and delegates page population to a callback.

func NewHandler

func NewHandler(uffd UFFD, opts *HandlerOptions) *Handler

NewHandler creates a reusable fault handler for the given userfaultfd.

When opts is nil it uses a 100ms poll timeout and keeps the serving goroutine locked to its OS thread, which is the safest default for low-level fault handling code.

func (*Handler) Serve

func (h *Handler) Serve(ctx context.Context, onFault func(Fault, Resolver) error) error

Serve processes userfaultfd missing-page events until the context is cancelled or an error occurs.

Each missing-page event is decoded into a Fault and passed to onFault along with a Resolver tied to the handler's descriptor. If onFault returns an error, Serve stops immediately and returns it.

type HandlerOptions

type HandlerOptions struct {
	PollTimeout         time.Duration
	DisableLockOSThread bool
}

HandlerOptions configures a generic fault handler.

By default, NewHandler polls every 100ms and locks the goroutine to its OS thread while serving faults. DisableLockOSThread turns that behaviour off.

type MoveBuffer

type MoveBuffer []byte

MoveBuffer is a mmap-backed buffer that is safe to use with PopulateMove. Call Close when the buffer is no longer needed.

func AllocateMoveBuffer

func AllocateMoveBuffer(length int) (MoveBuffer, error)

AllocateMoveBuffer returns a mmap-backed buffer with a length rounded up to the system page size so it can be used directly with PopulateMove.

func (MoveBuffer) Bytes

func (b MoveBuffer) Bytes() []byte

Bytes returns the underlying page-aligned buffer.

func (MoveBuffer) Close

func (b MoveBuffer) Close() error

Close releases the underlying mmap.

type Registration

type Registration struct {
	// contains filtered or unexported fields
}

Registration owns an mmap-backed region registered with a userfaultfd and the descriptor that tracks it. Call Close when the registration is no longer needed.

func Register

func Register(length int) (*Registration, error)

Register allocates an anonymous mapping of length bytes, opens and initialises a userfaultfd with UFFD_OPEN_DEFAULT, and registers the mapping for missing-page tracking.

The returned Registration owns both the descriptor and the full underlying mapping. Registration.Bytes() is clipped to the requested length, while the underlying mapping is rounded up to the system page size. Registration.Start() is the base address passed to fault handlers when converting fault offsets back into reader offsets.

func RegisterWithFlags

func RegisterWithFlags(length int, flags uintptr) (*Registration, error)

RegisterWithFlags is like Register, but opens the underlying userfaultfd with the supplied flags before initialising and registering it.

This is useful when callers want the convenience registration flow but still need to opt into descriptor flags such as UFFD_USER_MODE_ONLY explicitly.

func (*Registration) Bytes

func (r *Registration) Bytes() []byte

Bytes returns the registered region clipped to the originally requested length.

func (*Registration) Close

func (r *Registration) Close() error

Close releases both the userfaultfd and the underlying mapping. It is safe to call Close on a nil or already-closed Registration.

func (*Registration) Start

func (r *Registration) Start() uintptr

Start returns the base address used to translate fault offsets back into reader offsets.

func (*Registration) UFFD

func (r *Registration) UFFD() UFFD

UFFD returns the userfaultfd associated with the registration.

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

Resolver resolves faults by populating pages in the registered region.

func (Resolver) Populate

func (r Resolver) Populate(address uintptr, data []byte) (int64, error)

Populate resolves one missing-page range with UFFDIO_COPY.

This is the Resolver form of Populate and inherits the same alignment requirements and error semantics.

func (Resolver) PopulateMove

func (r Resolver) PopulateMove(address uintptr, data []byte) (int64, error)

PopulateMove resolves one missing-page range while allowing UFFDIO_MOVE when the descriptor advertises support for it and the target address falls within a registered range known to this package. Callers must ensure that the source buffer is safe to hand to MOVE.

This is the Resolver form of PopulateMove and inherits the same alignment requirements and fallback behaviour.

type UFFD

type UFFD uintptr

UFFD is a raw userfaultfd file descriptor.

The exported methods on UFFD wrap the kernel ioctls needed to initialise the descriptor, register memory ranges, and close the fd when it is no longer needed.

func Open

func Open(flags uintptr) (UFFD, error)

Open creates a userfaultfd descriptor using the supplied flags.

It prefers the userfaultfd syscall, retries without UFFD_USER_MODE_ONLY when an older kernel rejects that flag, and falls back to /dev/userfaultfd when the syscall path is blocked with EPERM.

func ReceiveUFFD

func ReceiveUFFD(conn *net.UnixConn) (UFFD, uintptr, error)

ReceiveUFFD receives a userfaultfd and its associated start address from a Unix domain socket.

In addition to the fd itself, it restores cached feature and registered-range metadata sent by SendUFFD so the receiving process can make the same PopulateMove decisions as the sender.

func (UFFD) Close

func (u UFFD) Close() error

Close closes the userfaultfd descriptor and discards any cached capability information associated with it.

func (UFFD) Init

func (u UFFD) Init(features uint64) error

Init negotiates the userfaultfd API version and the requested feature bits.

On success, Init caches the feature set accepted by the kernel so later calls to PopulateMove and the convenience handlers can decide whether MOVE is safe for this descriptor.

func (UFFD) Register

func (u UFFD) Register(start, length uintptr, mode uint64) error

Register registers the virtual address range [start, start+length] for the given userfaultfd mode.

The range must already be mapped and page aligned. On success the range ioctl mask returned by the kernel is cached for later MOVE/COPY decisions.

type UffdMsg

type UffdMsg struct {
	Event     uint8
	Reserved1 uint8
	Reserved2 uint16
	Reserved3 uint32
	Arg       [24]byte
}

UffdMsg mirrors Linux struct uffd_msg and carries events read from a userfaultfd descriptor.

type UffdPagefault

type UffdPagefault struct {
	Flags     uint64
	Address   uint64
	Feat      [4]byte
	Pad_cgo_0 [4]byte
}

UffdPagefault mirrors the pagefault payload stored in UffdMsg.Arg for UFFD_EVENT_PAGEFAULT events.

type UffdioAPI

type UffdioAPI struct {
	Api      uint64
	Features uint64
	Ioctls   uint64
}

UffdioAPI mirrors Linux struct uffdio_api, used with UFFDIO_API to negotiate feature bits and discover supported ioctls.

func NewUffdioAPI

func NewUffdioAPI(api, features uint64) UffdioAPI

NewUffdioAPI builds a UFFDIO_API request struct for callers using raw userfaultfd ioctls directly.

type UffdioCopy

type UffdioCopy struct {
	Dst  uint64
	Src  uint64
	Len  uint64
	Mode uint64
	Copy int64
}

UffdioCopy mirrors Linux struct uffdio_copy, used with UFFDIO_COPY to resolve missing pages from a source buffer.

func NewUffdioCopy

func NewUffdioCopy(b []byte, address uint64, length uint64, mode uint64, copied int64) UffdioCopy

NewUffdioCopy builds a UFFDIO_COPY request struct using b as the source buffer and address as the destination address in the registered range.

type UffdioMove

type UffdioMove struct {
	Dst  uint64
	Src  uint64
	Len  uint64
	Mode uint64
	Move int64
}

UffdioMove mirrors Linux struct uffdio_move, used with UFFDIO_MOVE to move page contents into a registered range.

func NewUffdioMove

func NewUffdioMove(b []byte, address uint64, length uint64, mode uint64, moved int64) UffdioMove

NewUffdioMove builds a UFFDIO_MOVE request struct using b as the source buffer and address as the destination address in the registered range.

type UffdioRange

type UffdioRange struct {
	Start uint64
	Len   uint64
}

UffdioRange mirrors Linux struct uffdio_range and identifies a virtual address range in a process.

type UffdioRegister

type UffdioRegister struct {
	Range  UffdioRange
	Mode   uint64
	Ioctls uint64
}

UffdioRegister mirrors Linux struct uffdio_register, used with UFFDIO_REGISTER to register ranges for fault tracking.

func NewUffdioRegister

func NewUffdioRegister(start, length, mode uint64) UffdioRegister

NewUffdioRegister builds a UFFDIO_REGISTER request struct covering the range [start, start+length] with the supplied mode bits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL