skills/virtualization/hypervisor-internals/SKILL.md
Hardware virtualization internals skill for Intel VT-x and AMD-V. Use when studying VMCS/VMCB, EPT/NPT page tables, VMEXIT handling, APIC virtualization, or building minimal hypervisors. Activates on queries about VMX, SVM, VMCS, EPT, NPT, VMEXIT, or type-1 hypervisor.
npx skillsauth add mohitmishra786/low-level-dev-skills hypervisor-internalsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Explain hardware virtualization internals for agents: Intel VT-x (VMXON, VMCS, VMLAUNCH/VMRESUME, VMEXIT reasons), AMD SVM (VMCB, #VMEXIT), Extended/Nested Page Tables (EPT/NPT), APIC virtualization, MSR bitmaps, virtual interrupt injection, and references for building minimal type-1 hypervisors.
Type 1 (bare metal) Type 2 (hosted)
├── Hyper-V ├── KVM + QEMU
├── Xen ├── VirtualBox
├── VMware ESXi └── Parallels
└── Runs directly on HW Runs on host OS
VMX operation
├── VMXON — enter VMX root mode
├── VMCS setup — guest/host state fields
├── VMLAUNCH / VMRESUME — enter guest
├── Guest runs until VMEXIT
└── VMXOFF — exit VMX operation
Key structures:
// Simplified VMX enable check (kernel/driver context)
#include <linux/cpufeature.h>
if (boot_cpu_has(X86_FEATURE_VMX))
// VT-x supported
| Category | Examples | |----------|----------| | Guest state | GPRs, CR0/3/4, segment selectors, RIP, RSP | | Host state | Host RIP (VMEXIT handler), host CR3 | | Control | Pin-based, proc-based, VMEXIT/entry controls | | Exit info | Exit reason, qualification, guest-linear-address |
VMEXIT reasons (common):
Exit reason codes (Intel)
├── 10 — CPUID
├── 28 — CR access
├── 30 — I/O instruction
├── 48 — EPT violation
├── 0 — External interrupt
└── 1 — Triple fault
SVM operation
├── EFER.SVME = 1
├── VMCB setup — guest save area + control area
├── VMRUN — enter guest
├── #VMEXIT — exit to host handler
└── Guest state in VMCB
VMCB control area: intercept vectors (CPUID, MSR, IO), nested paging enable, ASID.
| Intel | AMD | |-------|-----| | VMCS | VMCB | | VMXON/VMXOFF | EFER.SVME | | VMLAUNCH/VMRESUME | VMRUN | | EPT | NPT (Nested Page Tables) |
Guest virtual (GVA) → Guest physical (GPA) [guest page tables]
GPA → Host physical (HPA) [EPT/NPT, managed by hypervisor]
EPT violation VMEXIT: guest accessed unmapped GPA or violated permissions.
# KVM EPT stats (if available)
# Nested virtualization adds second EPT walk — perf cost
Mitigations for side channels: flush L1D on VMEXIT (MDS), cache partitioning.
MSR bitmap (4KB)
├── Per-MSR read/write intercept control
└── Avoid VMEXIT on common MSRs for performance
I/O bitmap
├── Intercept specific port I/O
└── Pass-through unlisted ports
Hypervisors intercept MSR_IA32_FEATURE_CONTROL, MSR_IA32_EFER, etc.
APIC virtualization
├── Virtual interrupt delivery — reduce VMEXIT on EOI
├── Posted interrupts — hardware-assisted injection
└── TPR shadowing — avoid exit on priority changes
Reduces overhead for interrupt-heavy guests (network I/O).
Intel: inject via VM-entry interruption-information field. AMD: V_IRQ, V_INTR_PRIO in VMCB.
Device interrupt → host IRQ handler → hypervisor
→ inject virtual IRQ to guest IDT
→ guest ISR runs
| Project | Platform | Notes | |---------|----------|-------| | SimpleVisor | Windows | Educational, few thousand lines | | hvpp | Windows | C++ hypervisor library | | kvmm | Linux | Minimal KVM study | | barevisor | x86_64 | Rust/ASM educational |
Study path:
// Userspace KVM (how QEMU talks to KVM)
int kvm = open("/dev/kvm", O_RDWR);
int vm = ioctl(kvm, KVM_CREATE_VM, 0);
int vcpu = ioctl(vm, KVM_CREATE_VCPU, 0);
ioctl(vcpu, KVM_RUN, 0); // runs until VMEXIT
| Symptom | Cause | Fix | |---------|-------|-----| | VMEXIT storm on MSR | MSR bitmap intercepts all | Fine-tune bitmap; pass-through safe MSRs | | EPT misconfiguration | Mismatched GPA→HPA | Verify EPT PTE permissions | | Nested virt slow | Double page walk | Hardware assist; limit nesting depth | | VMXON fails | CR0/CR4 fixed bits | Set required CR bits per Intel SDM | | Guest triple fault | Bad IDT or unhandled exception | Check guest interrupt setup | | I/O intercept overhead | All ports trapped | Shrink I/O bitmap |
skills/virtualization/qemu-kvm — practical KVM/QEMU usageskills/virtualization/containers-internals — lighter isolation without full VMskills/kernel/kernel-internals — host kernel scheduler/memoryskills/kernel/os-dev-scratch — guest OS development contextskills/security/kernel-security — hypervisor CVE mitigationsskills/platform/riscv-privileged — RISC-V H-extension virtualizationdevelopment
QEMU/KVM skill for virtualization and kernel development. Use when running qemu-system-x86_64 with KVM, configuring virtio devices, VFIO passthrough, QMP monitor, libvirt, or booting custom kernels. Activates on queries about QEMU, KVM, virtio, VFIO, virsh, virt-install, or -kernel -append.
testing
Linux containers internals skill for namespaces, cgroups, and OCI. Use when understanding clone/unshare namespaces, cgroups v2 limits, overlayfs, runc, seccomp profiles, capabilities, or escape mitigations. Activates on queries about namespaces, cgroups, overlayfs, runc, seccomp-bpf, OCI spec, or container escape.
tools
Reverse engineering skill for binary analysis. Use when decompiling with Ghidra, analyzing with radare2, scripting RE tools, triaging with strings/file/xxd, or diffing binaries. Activates on queries about Ghidra, radare2, r2, decompiler, Binary Ninja, Diaphora, or stripped binary analysis.
testing
Linux kernel security skill for LSM, hardening, and exploit mitigations. Use when writing SELinux/AppArmor policies, seccomp-bpf filters, configuring KASLR/CET/PAC, or triaging kernel CVEs. Activates on queries about SELinux, AppArmor, seccomp, KASLR, CET, PAC, BTI, KASAN, or kernel CVE.