~/bend-docscommunity

host/hvf.bend relies on unsafe/foreign

raw source on the hub · import 0x88887434395ee9936f9b6f658e234140/host/hvf.bend as Hvf

4 imports
import Base
import ../src/lib/u64.bend as U
import ../src/lib/bytes.bend as B
import ../src/vmm/abi.bend as V

Definitions

def Op.create source · line 400 · raw

U32

vCPU request codes (host/hvf.c).

def Op.run source · line 402 · raw

U32

def Op.set_reg source · line 404 · raw

U32

def Op.get_reg source · line 406 · raw

U32

def Op.set_vtimer_mask source · line 408 · raw

U32

def Op.advance_pc source · line 410 · raw

U32

def Reg.cpsr source · line 414 · raw

U32

Register numbers beyond V.Reg: 32 is CPSR.

def Host.vm_init source · line 417 · raw

@ram_mb:U32 -> @gicd:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @gicr:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @ram:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @cpus:U32 -> IO(U32)

def Host.load source · line 422 · raw

@path:String -> @gpa:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> IO(U32)

def Host.write source · line 427 · raw

@gpa:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @bytes:List<&2, U32> -> IO(U32)

def Host.read source · line 432 · raw

@gpa:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @len:U32 -> IO(List<&2, U32>)

def Host.first source · line 437 · raw

@ws:List<&2, U32> -> U32

def Host.vcpu_create source · line 440 · raw

@cpu:U32 -> IO(U32)

def Host.set_reg source · line 446 · raw

@cpu:U32 -> @reg:U32 -> @v:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> IO(U32)

Queued: applied by the vCPU thread before its next request.

def Host.advance_pc source · line 452 · raw

@cpu:U32 -> IO(U32)

Queued, like Host.set_reg: PC += 4.

def Host.get_reg source · line 455 · raw

@cpu:U32 -> @reg:U32 -> IO(0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64)

def Host.vtimer_mask source · line 460 · raw

@cpu:U32 -> @masked:U32 -> IO(U32)

def Host.exception source · line 468 · raw

@ws:List<&2, U32> -> 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.RawExit

An exit record: [kind, esr, far, ipa, x0, x1, x2, x3, xt], each 64-bit value as (hi, lo). One pattern match decodes it (walking the list per field was the hottest code on the exit path).

def Host.decode_exit.kind source · line 475 · raw

@is0:Bool -> @is1:Bool -> @is2:Bool -> @kind:U32 -> @rest:List<&2, U32> -> 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.RawExit

def Host.decode_exit source · line 487 · raw

@ws:List<&2, U32> -> 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.RawExit

Decodes Hvf.vcpu(.., Op.run(), ..) words into a RawExit.

def Host.run source · line 494 · raw

@cpu:U32 -> IO(0x88887434395ee9936f9b6f658e234140/src/vmm/abi.RawExit)

def Host.disk_read source · line 499 · raw

@disk:U32 -> @off:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @len:U32 -> IO(List<&2, U32>)

def Host.disk_write source · line 504 · raw

@disk:U32 -> @off:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @bytes:List<&2, U32> -> IO(U32)

def Host.iovs source · line 511 · raw

@xs:List<&2, 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.Iov> -> List<&2, U32>

Pieces of guest memory as the host takes them: each addr (8 bytes) then len (4), little-endian.

def Host.disk_copy source · line 520 · raw

@disk:U32 -> @dir:U32 -> @off:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @iovs:List<&2, 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.Iov> -> IO(U32)

Moves bytes between a disk and pieces of guest RAM on the host: dir 0 disk to RAM, 1 RAM to disk.

def Host.net_copy source · line 527 · raw

@conn:U32 -> @off:U32 -> @iovs:List<&2, 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.Iov> -> IO(U32)

Copies the bytes from offset off of what the host holds for TCP connection conn into pieces of guest RAM.

def Host.stage source · line 531 · raw

@iovs:List<&2, 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.Iov> -> IO(U32)

Copies pieces of guest RAM into a staged slot on the host.

def Host.disk_alloc source · line 534 · raw

@disk:U32 -> @len:U32 -> IO(0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64)

def Host.disk_xcopy source · line 539 · raw

@src:U32 -> @soff:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @dst:U32 -> @doff:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @len:U32 -> IO(U32)

def Host.inflate_ram source · line 544 · raw

@disk:U32 -> @off:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @clen:U32 -> @skip:U32 -> @iovs:List<&2, 0x88887434395ee9936f9b6f658e234140/src/vmm/abi.Iov> -> IO(U32)

def Host.inflate_disk source · line 549 · raw

@disk:U32 -> @off:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @clen:U32 -> @dst:U32 -> @doff:0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64 -> @skip:U32 -> @len:U32 -> IO(U32)

def Host.disk_size source · line 554 · raw

@disk:U32 -> IO(0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64)

def Host.now source · line 559 · raw

IO(0x88887434395ee9936f9b6f658e234140/src/lib/u64.U64)

Effects (foreign code)

effect Hvf.init source · line 9 · raw

@ram_mb:U32 -> @gicd_hi:U32 -> @gicd_lo:U32 -> @gicr_hi:U32 -> @gicr_lo:U32 -> @ram_hi:U32 -> @ram_lo:U32 -> @cpus:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.load source · line 13 · raw

@path:String -> @gpa_hi:U32 -> @gpa_lo:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.write source · line 17 · raw

@gpa_hi:U32 -> @gpa_lo:U32 -> @bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.read source · line 21 · raw

@gpa_hi:U32 -> @gpa_lo:U32 -> @len:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.vcpu source · line 25 · raw

@cpu:U32 -> @op:U32 -> @a_hi:U32 -> @a_lo:U32 -> @b_hi:U32 -> @b_lo:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.vcpu_queue source · line 29 · raw

@cpu:U32 -> @op:U32 -> @reg:U32 -> @hi:U32 -> @lo:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.irq source · line 33 · raw

@intid:U32 -> @level:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.kick source · line 37 · raw

@cpu:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.set_args source · line 41 · raw

@bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.reexec source · line 45 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.file_size source · line 49 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.out source · line 53 · raw

@bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.out_flush source · line 57 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.log_gate source · line 61 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.stdin source · line 65 · raw

@max:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.stdin_tty source · line 69 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.stdin_wait source · line 73 · raw

@max:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.random source · line 77 · raw

@len:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_open source · line 81 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_err source · line 85 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_open_ro source · line 89 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_open_backing source · line 93 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_status source · line 97 · raw

@disk:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.signal_wait source · line 101 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_size source · line 105 · raw

@disk:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_flush source · line 109 · raw

@disk:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.now source · line 113 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_read source · line 117 · raw

@disk:U32 -> @off_hi:U32 -> @off_lo:U32 -> @len:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_write source · line 121 · raw

@disk:U32 -> @off_hi:U32 -> @off_lo:U32 -> @bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_copy source · line 125 · raw

@disk:U32 -> @dir:U32 -> @off_hi:U32 -> @off_lo:U32 -> @iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.zero_ram source · line 129 · raw

@iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_alloc source · line 133 · raw

@disk:U32 -> @len:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.disk_xcopy source · line 137 · raw

@src:U32 -> @soff_hi:U32 -> @soff_lo:U32 -> @dst:U32 -> @doff_hi:U32 -> @doff_lo:U32 -> @len:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.inflate_ram source · line 141 · raw

@disk:U32 -> @off_hi:U32 -> @off_lo:U32 -> @clen:U32 -> @skip:U32 -> @iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.inflate_disk source · line 145 · raw

@disk:U32 -> @off_hi:U32 -> @off_lo:U32 -> @clen:U32 -> @dst:U32 -> @doff_hi:U32 -> @doff_lo:U32 -> @skip:U32 -> @len:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.set_dns source · line 150 · raw

@ip:U32 -> IO(U32)

Host sockets for the NAT (see host/hvf.c, "Network").

foreign: host/hvf.c, host/hvf.js

effect Hvf.dns source · line 154 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_connect source · line 158 · raw

@conn:U32 -> @ip:U32 -> @port:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_wait source · line 162 · raw

@conn:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_recv source · line 166 · raw

@conn:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_release source · line 170 · raw

@conn:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.net_holds source · line 174 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_fill source · line 178 · raw

@conn:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.net_copy source · line 182 · raw

@conn:U32 -> @off:U32 -> @iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.stage source · line 186 · raw

@iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.stage_drop source · line 190 · raw

@slot:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_send_staged source · line 194 · raw

@conn:U32 -> @slot:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.nat_send source · line 200 · raw

@conn:U32 -> @bytes:List<&2, U32> -> IO(U32)

Guest data on a NAT connection, never waiting: 1 when a flusher must start (Hvf.tcp_flush), else 0.

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_flush source · line 207 · raw

@conn:U32 -> IO(U32)

A NAT connection's flusher: sends its pending data as the socket takes it. 0: TcpUnblocked, then again; 3: TcpBlocked, then again; 2: TcpReset; 1: done.

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_shutdown source · line 211 · raw

@conn:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_close source · line 215 · raw

@conn:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.tcp_abort source · line 221 · raw

@conn:U32 -> IO(U32)

The guest reset a NAT connection: the host resets its socket at once and drops the data it has not sent.

foreign: host/hvf.c, host/hvf.js

effect Hvf.udp_send source · line 225 · raw

@sport:U32 -> @ip:U32 -> @port:U32 -> @bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.udp_recv source · line 229 · raw

@flow:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.share_open source · line 234 · raw

@path:String -> IO(U32)

Shared directories for virtio-9p (host/fs.bend wraps these).

foreign: host/hvf.c, host/hvf.js

effect Hvf.fs source · line 238 · raw

@share:U32 -> @op:U32 -> @path:String -> @path2:String -> @a_hi:U32 -> @a_lo:U32 -> @b:U32 -> @bytes:List<&2, U32> -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.pause source · line 243 · raw

IO(U32)

Pause, snapshots and restore (host/hvf.c).

foreign: host/hvf.c, host/hvf.js

effect Hvf.resume source · line 247 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.pause_state source · line 251 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_save source · line 255 · raw

@words:List<&2, U32> -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_commit source · line 259 · raw

@path:String -> @plan:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.lan_open source · line 263 · raw

@dir:String -> @mac:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.lan_send source · line 267 · raw

@dst:List<&2, U32> -> @iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.lan_recv source · line 271 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.lan_to_ram source · line 275 · raw

@iovs:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.lan_release source · line 279 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.set_prog source · line 283 · raw

@n:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.prog source · line 287 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.net_limits source · line 291 · raw

@words:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.rename source · line 295 · raw

@from:String -> @to:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_drop source · line 299 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_peek source · line 303 · raw

@off_hi:U32 -> @off_lo:U32 -> @len:U32 -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_load source · line 307 · raw

@layout:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_open source · line 311 · raw

@path:String -> IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_info source · line 315 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_args source · line 319 · raw

IO(List<&1, String>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_machine source · line 323 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.snap_gic source · line 327 · raw

IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.ctl_listen source · line 332 · raw

@path:String -> IO(U32)

The control socket (host/hvf.c).

foreign: host/hvf.c, host/hvf.js

effect Hvf.ctl_next source · line 336 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.ctl_reply source · line 340 · raw

@text:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.unix_connect source · line 346 · raw

@key:U32 -> @path:String -> IO(U32)

vsock over Unix sockets (host/hvf.c). Sockets share the tcp_* table under the key conn XOR 0x40000000.

foreign: host/hvf.c, host/hvf.js

effect Hvf.vsock_listen source · line 350 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.vsock_base source · line 354 · raw

IO(String)

foreign: host/hvf.c, host/hvf.js

effect Hvf.vsock_accept source · line 358 · raw

IO(List<&2, U32>)

foreign: host/hvf.c, host/hvf.js

effect Hvf.fwd_listen source · line 364 · raw

@idx:U32 -> @addr:String -> @port:U32 -> IO(U32)

Port forwarding (host/hvf.c): forward idx listens on addr:port; each accepted client is a NAT connection, its id fresh (0x20000000 up).

foreign: host/hvf.c, host/hvf.js

effect Hvf.fwd_accept source · line 368 · raw

@idx:U32 -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.err_text source · line 373 · raw

@code:U32 -> IO(String)

An errno's message (strerror).

foreign: host/hvf.c, host/hvf.js

effect Hvf.fw_load source · line 378 · raw

@code:String -> @vars:String -> IO(U32)

UEFI flash (host/hvf.c): the firmware and variable banks.

foreign: host/hvf.c, host/hvf.js

effect Hvf.flash source · line 382 · raw

@op:U32 -> @a:U32 -> @b:U32 -> @bytes:List<&2, U32> -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.fb_init source · line 387 · raw

@width:U32 -> @height:U32 -> IO(U32)

The framebuffer and its window (host/hvf.c).

foreign: host/hvf.c, host/hvf.js

effect Hvf.fb_dump source · line 391 · raw

@path:String -> IO(U32)

foreign: host/hvf.c, host/hvf.js

effect Hvf.fb_present source · line 395 · raw

@window:Window -> IO(Pair(Window, List<&1, Event>))

foreign: host/hvf.c, host/hvf.js