# tzvisor/ltzvisor architecture

> Architecture diagram of the GitHub repository tzvisor/ltzvisor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tzvisor/ltzvisor
- Repository: https://github.com/tzvisor/ltzvisor

## Overview

LTZVisor is a TrustZone-assisted hypervisor for running secure and non-secure guests side by side. The documented workflow initializes platform hardware, starts the secure guest, and prepares non-secure guest context; the README describes bare-metal and OS guest options, though the sampled API shows scheduling and restart are incomplete. Board support, interrupt handling, timers, and the secure blink demo are represented as product branches. Source excerpts are limited, so unsampled relationships are omitted rather than inferred.

Main entry points: [`src/core/ltzvisor_api.c`](https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor_api.c) (Hypervisor API), [`src/s_guest/BareApp/blink.c`](https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/blink.c) (Secure guest), [`src/core/ltzvisor.c`](https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor.c) (Hypervisor core), [`src/drivers/gic.c`](https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/gic.c) (Interrupt controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_hypervisor["Hypervisor"]
  node_visor_core["Hypervisor core<br/>[ltzvisor.c]"]
  node_visor_api["Hypervisor API<br/>[ltzvisor_api.c]"]
  node_ns_config["Non-secure config"]
end

subgraph group_cpu["CPU and interrupts"]
  node_cpu_support["CPU support<br/>[cpu_helper.c]"]
  node_guest_context["Guest context<br/>[cpu_vcpu.h]"]
  node_exceptions["Monitor exceptions<br/>[cpu_handlers.c]"]
end

subgraph group_platform["Platform support"]
  node_gic["Interrupt controller<br/>[gic.c]"]
  node_gic_common["Common GIC<br/>[gic.c]"]
  node_board_init["Board initialization<br/>[board.c]"]
  node_zynq_hw["Zynq hardware<br/>[ltzvisor_hw.c]"]
  node_zynq_uart["UART driver<br/>[xilinx_uart.c]"]
  node_timer_zybo["ZYBO timer<br/>[zynq_ttc.c]"]
  node_timer_zed["ZedBoard timer<br/>[zynq_ttc.c]"]
  node_timer_zc702["ZC702 timer<br/>[zynq_ttc.c]"]
  node_timer_driver["Zynq timer driver<br/>[zynq_ttc.c]"]
  node_printk["Formatted output<br/>[printk.c]"]
end

subgraph group_guests["Guest software"]
  node_secure_guest["Secure guest<br/>[blink.c]"]
  node_secure_hw["Secure guest hardware<br/>[hw_zynq.c]"]
  node_secure_isr["Secure guest ISR<br/>[s_isr.c]"]
  node_nonsecure_guest["Non-secure guest"]
end

node_boot(("System boot"))
node_external_guests["Guest operating systems"]

node_boot -.->|"starts"| node_visor_core
node_visor_core -.->|"initializes"| node_visor_api
node_visor_api -->|"enters"| node_secure_guest
node_visor_api -->|"sets context"| node_guest_context
node_visor_api -.->|"uses config"| node_ns_config
node_visor_api -.->|"initializes hardware"| node_zynq_hw
node_visor_core -.->|"hosts"| node_nonsecure_guest
node_visor_core -.->|"hosts"| node_secure_guest
node_secure_guest -->|"initializes"| node_secure_hw
node_secure_guest -->|"prints"| node_printk
node_secure_guest -.->|"alternatives include"| node_external_guests
node_nonsecure_guest -.->|"supports"| node_external_guests
node_visor_api -->|"restores CP15"| node_cpu_support
node_gic -->|"dispatches timer IRQ"| node_timer_driver
node_board_init -.->|"configures platform"| node_zynq_hw
node_zynq_hw -.->|"initializes interrupts"| node_gic
node_secure_hw -.->|"uses timer"| node_timer_zybo
node_timer_zybo -.->|"raises interrupts"| node_gic

click node_visor_core "https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor.c"
click node_visor_api "https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor_api.c"
click node_ns_config "https://github.com/tzvisor/ltzvisor/blob/master/src/ns_guest/ltzvisor_nsguest_config.c"
click node_cpu_support "https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/cpu_helper.c"
click node_guest_context "https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/inc/cpu_vcpu.h"
click node_exceptions "https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/cpu_handlers.c"
click node_gic "https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/gic.c"
click node_gic_common "https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/common/gic.c"
click node_board_init "https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/board.c"
click node_zynq_hw "https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/ltzvisor_hw.c"
click node_zynq_uart "https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/zynq/xilinx_uart.c"
click node_timer_zybo "https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/zynq_ttc.c"
click node_timer_zed "https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zedboard/zynq_ttc.c"
click node_timer_zc702 "https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zc702/zynq_ttc.c"
click node_timer_driver "https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/zynq/zynq_ttc.c"
click node_secure_guest "https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/blink.c"
click node_secure_hw "https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/portable/hw_zynq.c"
click node_secure_isr "https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/portable/s_isr.c"
click node_nonsecure_guest "https://github.com/tzvisor/ltzvisor/tree/master/src/ns_guest"
click node_printk "https://github.com/tzvisor/ltzvisor/blob/master/src/lib/printk.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_visor_core,node_visor_api,node_ns_config toneBlue
class node_cpu_support,node_guest_context,node_exceptions toneAmber
class node_gic,node_gic_common,node_board_init,node_zynq_hw,node_zynq_uart,node_timer_zybo,node_timer_zed,node_timer_zc702,node_timer_driver,node_printk toneMint
class node_secure_guest,node_secure_hw,node_secure_isr,node_nonsecure_guest toneRose
class node_boot,node_external_guests toneIndigo
```

## Components

### Hypervisor

- [Hypervisor core](https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor.c): `src/core/ltzvisor.c`
- [Hypervisor API](https://github.com/tzvisor/ltzvisor/blob/master/src/core/ltzvisor_api.c): `src/core/ltzvisor_api.c`
- [Non-secure config](https://github.com/tzvisor/ltzvisor/blob/master/src/ns_guest/ltzvisor_nsguest_config.c): `src/ns_guest/ltzvisor_nsguest_config.c`

### CPU and interrupts

- [CPU support](https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/cpu_helper.c): `src/arch/armv7/cpu_helper.c`
- [Guest context](https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/inc/cpu_vcpu.h): `src/arch/armv7/inc/cpu_vcpu.h`
- [Monitor exceptions](https://github.com/tzvisor/ltzvisor/blob/master/src/arch/armv7/cpu_handlers.c): `src/arch/armv7/cpu_handlers.c`

### Platform support

- [Interrupt controller](https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/gic.c): `src/drivers/gic.c`
- [Common GIC](https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/common/gic.c): `src/drivers/common/gic.c`
- [Board initialization](https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/board.c): `src/boards/zybo/board.c`
- [Zynq hardware](https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/ltzvisor_hw.c): `src/boards/zybo/ltzvisor_hw.c`
- [UART driver](https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/zynq/xilinx_uart.c): `src/drivers/zynq/xilinx_uart.c`
- [ZYBO timer](https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zybo/zynq_ttc.c): `src/boards/zybo/zynq_ttc.c`
- [ZedBoard timer](https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zedboard/zynq_ttc.c): `src/boards/zedboard/zynq_ttc.c`
- [ZC702 timer](https://github.com/tzvisor/ltzvisor/blob/master/src/boards/zc702/zynq_ttc.c): `src/boards/zc702/zynq_ttc.c`
- [Zynq timer driver](https://github.com/tzvisor/ltzvisor/blob/master/src/drivers/zynq/zynq_ttc.c): `src/drivers/zynq/zynq_ttc.c`
- [Formatted output](https://github.com/tzvisor/ltzvisor/blob/master/src/lib/printk.c): `src/lib/printk.c`

### Guest software

- [Secure guest](https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/blink.c): `src/s_guest/BareApp/blink.c`
- [Secure guest hardware](https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/portable/hw_zynq.c): `src/s_guest/BareApp/portable/hw_zynq.c`
- [Secure guest ISR](https://github.com/tzvisor/ltzvisor/blob/master/src/s_guest/BareApp/portable/s_isr.c): `src/s_guest/BareApp/portable/s_isr.c`
- [Non-secure guest](https://github.com/tzvisor/ltzvisor/tree/master/src/ns_guest): `src/ns_guest`

### Other components

- **System boot**
- **Guest operating systems**

## Connections

- System boot → Hypervisor core: starts (evidence: `README.md`)
- Hypervisor core → Hypervisor API: initializes (evidence: `src/core/ltzvisor.c`)
- Hypervisor API → Secure guest: enters (evidence: `src/core/ltzvisor_api.c`)
- Hypervisor API → Guest context: sets context (evidence: `src/core/ltzvisor_api.c`)
- Hypervisor API → Non-secure config: uses config
- Hypervisor API → Zynq hardware: initializes hardware (evidence: `src/core/ltzvisor_api.c`)
- Hypervisor core → Non-secure guest: hosts (evidence: `README.md`)
- Hypervisor core → Secure guest: hosts (evidence: `README.md`)
- Secure guest → Secure guest hardware: initializes (evidence: `src/s_guest/BareApp/blink.c`)
- Secure guest → Formatted output: prints (evidence: `src/s_guest/BareApp/blink.c`)
- Secure guest → Guest operating systems: alternatives include (evidence: `README.md`)
- Non-secure guest → Guest operating systems: supports (evidence: `README.md`)
- Hypervisor API → CPU support: restores CP15 (evidence: `src/core/ltzvisor_api.c`)
- Interrupt controller → Zynq timer driver: dispatches timer IRQ (evidence: `src/drivers/gic.c`)
- Board initialization → Zynq hardware: configures platform
- Zynq hardware → Interrupt controller: initializes interrupts
- Secure guest hardware → ZYBO timer: uses timer
- ZYBO timer → Interrupt controller: raises interrupts
