Skip to main content

Module kvt

Module kvt 

Source
Expand description

The extended trace format (.kvt): everything the tracer knows.

MacSim’s record has no room for CR3, the privilege level, physical addresses, instruction fetches, faults, interrupts or the global order across vCPUs. The .kvt file keeps all of it, one file per vCPU, so nothing the tracer learned is thrown away.

§Layout

header (uncompressed, 16 bytes):
  magic   "KVTRACE\0"         8 bytes
  version u32 = 1
  vcpu    u32
body: one zstd stream of items, each starting with a tag byte
  1 = instruction, 2 = event   (all integers little-endian)

instruction:
  seq.local u64, seq.global u64, seq.host_tsc u64,
  rip u64, linear_rip u64, physical_rip u64 (u64::MAX = none),
  cs u16, cpl u8, mode u8, cr3 u64, next_rip u64,
  outcome u8 (0 retired, 1 rep iteration, 2 faulted), vector u8,
  branch_taken u8, flags u16, len u8, bytes[len],
  access_count u16, access*
event:
  seq.local u64, seq.global u64, seq.host_tsc u64,
  vector u8, kind u8 (0 exception, 1 software, 2 interrupt),
  return_rip u64, handler_rip u64, cr3 u64,
  access_count u16, access*
access (32 bytes):
  linear u64, physical u64, physical_end u64 (u64::MAX = none),
  size u32, kind u8, class u8, outcome u8, conditional u8

KvtReader reads it back; kvmtrace dump prints it.

Structs§

KvtReader
Reads a .kvt file item by item.
KvtWriter
Writes one vCPU’s .kvt file.