monitor

package
v0.0.0-...-4d68747 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: BSD-3-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package monitor provides supervisor support for TamaGo unikernels to allow scheduling of Secure user mode or NonSecure system mode (ARM) or Supervisor mode (RISC-V) executables.

This package is only meant to be used with `GOOS=tamago` as supported by the TamaGo framework for bare metal Go, see https://github.com/usbarmory/tamago.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal(a, b *ExecCtx) bool

Equal returns whether a and b holds the same register state.

func Exec

func Exec(ctx *ExecCtx)

Exec allows execution of an executable in Secure user mode or NonSecure system mode (ARM) or Supervisor mode (RISC-V).

The execution is isolated from the invoking Go runtime, yielding back to it is supported through exceptions (e.g. syscalls through SVC on ARM and ECALL on RISC-V).

The execution context pointer allows task initialization and it is updated with the program state at return, it can therefore be passed again to resume the task.

func NonSecureHandler

func NonSecureHandler(ctx *ExecCtx) (err error)

NonSecureHandler is the default handler for exceptions raised by a non-secure execution context to handle supported GoTEE secure monitor calls.

func SecureHandler

func SecureHandler(ctx *ExecCtx) (err error)

SecureHandler is the default handler for exceptions raised by a secure execution context to handle supported GoTEE system calls.

Types

type ExecCtx

type ExecCtx struct{}

ExecCtx represents a executable initialization or returning state.

func Load

func Load(entry uint, mem *dma.Region, secure bool) (ctx *ExecCtx, err error)

Load returns an execution context initialized for the argument entry point and memory region

ARM: the secure flag controls whether the context belongs to a secure partition (e.g. TrustZone Secure World) or a non-secure one (e.g. TrustZone Normal World). In case of a non-secure execution context, the memory is configured as NonSecure by means of MMU NS bit and memory controller region configuration. The caller is responsible for any other required MMU configuration (see arm.ConfigureMMU()) or additional peripheral restrictions (e.g. TrustZone).

RISC-V: any additional peripheral restrictions are up to the caller.

func (*ExecCtx) A0

func (ctx *ExecCtx) A0() uint

A0 returns the register treated as first argument for GoTEE secure monitor calls.

func (*ExecCtx) A1

func (ctx *ExecCtx) A1() uint

A1 returns the register treated as second argument for GoTEE secure monitor calls.

func (*ExecCtx) A2

func (ctx *ExecCtx) A2() uint

A2 returns the register treated as third argument for GoTEE secure monitor calls.

func (*ExecCtx) Cause

func (ctx *ExecCtx) Cause() (code uint64, irq bool)

Cause (RISC-V) returns the trap event.

func (*ExecCtx) Clone

func (ctx *ExecCtx) Clone() (shadow *ExecCtx)

Clone returns a duplicate execution context suitable for lockstep operation (see Shadow field), the original Handler field is not carried over in the shadow copy.

func (*ExecCtx) Close

func (ctx *ExecCtx) Close() error

Close has no effect.

func (*ExecCtx) Done

func (ctx *ExecCtx) Done() chan struct{}

Done returns a channel which will be closed once execution context has stopped.

func (*ExecCtx) Flush

func (ctx *ExecCtx) Flush(errno int) (n int, err error)

Flush handles syscall.Read() as received from the execution context, the buffered data (see Write()) is returned to the execution context memory.

A negative error number can passed as return value for syscall.Read() causing no data to be returned or flushed, zero or positive values are ignored as the number of bytes read is returned.

func (*ExecCtx) Mode

func (ctx *ExecCtx) Mode() (current int, saved int)

Mode (ARM) returns the processor mode.

func (*ExecCtx) NonSecure

func (ctx *ExecCtx) NonSecure() bool

NonSecure (ARM) returns whether the execution context is loaded as non-secure.

func (*ExecCtx) Poke

func (ctx *ExecCtx) Poke(off int, buf []byte)

Poke writes buffer contents to the execution context memory, including its Shadow if present, at a given offset.

func (*ExecCtx) Read

func (ctx *ExecCtx) Read(p []byte) (int, error)

Read reads up to len(p) bytes into p. The read data is received from the execution context memory, after it is being written with syscall.Write().

func (*ExecCtx) Recv

func (ctx *ExecCtx) Recv() (err error)

Recv handles syscall.Write() as received from the execution context memory, the written data is buffered (see Read()).

func (*ExecCtx) Ret

func (ctx *ExecCtx) Ret(val interface{})

Ret sets the return value for GoTEE secure monitor calls updating the relevant execution context registers, including its Shadow if present.

func (*ExecCtx) Run

func (ctx *ExecCtx) Run() (err error)

Run starts the execution context and handles system or monitor calls. The execution yields back to the invoking Go runtime only when exceptions are caught.

The function invokes the context Handler() and returns when an unhandled exception, or any other error, is raised.

func (*ExecCtx) Schedule

func (ctx *ExecCtx) Schedule() (err error)

Schedule runs the execution context until an exception is caught.

Unlike Run() the function does not invoke the context Handler(), there exceptions and system or monitor calls are not handled.

func (*ExecCtx) Secure

func (ctx *ExecCtx) Secure() bool

Secure (RISC-V) returns whether the execution context is loaded as trusted applet.

func (*ExecCtx) Stop

func (ctx *ExecCtx) Stop()

Stop stops the execution context.

func (*ExecCtx) String

func (ctx *ExecCtx) String()

String returns the string form of the execution context registers.

func (*ExecCtx) TransferRegion

func (ctx *ExecCtx) TransferRegion() (off int, n int, err error)

TransferRegion validates the registers used in memory transfer request for GoTEE secure monitor calls (syscall.Read(), syscall.Write()) and returns the computed memory offset and transfer size.

func (*ExecCtx) Write

func (ctx *ExecCtx) Write(p []byte) (int, error)

Write writes len(p) bytes from p to the underlying data stream, it never returns an error. The written data is buffered within the execution context, waiting for its read through syscall.Read().

Jump to

Keyboard shortcuts

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