SimpleSvm is an educational Windows kernel-mode hypervisor project for AMD CPUs with SVM support. It is intended to help understand how a minimal hypervisor works on Windows, including VMCB setup, nested paging (NPT), #VMEXIT handling, and low-level host/guest transitions in ring 0.
This repository is based on the original educational code by Satoshi Tanda, and this version includes a stability-focused audit and hardening pass. The goal is not to produce a production runtime, but to provide a practical reference for kernel-mode virtualization, x64 internals, Windows driver development, and system-level experimentation in a controlled lab environment.
The project is useful for learning:
- how a hypervisor is initialized on Windows,
- how the AMD SVM interface is used,
- how
MSR,CPUID,GDTR,IDTR, and related hardware state are manipulated, - how a
VMCBis built and configured, - how nested paging (NPT) maps guest addresses to host memory,
- how
#VMEXITevents are intercepted and handled, - and how system calls and kernel shared data can be instrumented in a lab setting.
It is meant for technical study, reverse engineering research, and authorized experimentation. It is not intended as a general-purpose or production-ready hypervisor.
This code is distributed for research and educational purposes only.
It is not intended for:
- bypassing anti-cheat, DRM, or protection systems,
- tampering with third-party software,
- or performing activities outside an authorized and controlled environment.
The project should be used only on hardware and systems where you have explicit permission to test and study. Kernel-mode virtualization is dangerous, can cause system instability, and must be handled with extreme care.
The driver validates AMD hardware, enables EFER.SVME, initializes per-CPU virtualization state, creates a nested paging map, and then manipulates the guest and host transitions through #VMEXIT behavior. The code is intentionally small and readable so that the virtualization flow is understandable.
-
SimpleSvm/SimpleSvm.cpp- Main driver logic.
- Covers CPU validation, VMCB setup,
#VMEXITrouting, guest configuration, cleanup, and the stability-oriented fixes.
-
SimpleSvm/x64.asm- Assembly code for VM launch, stack setup, syscall interception, and transitions between host and guest execution contexts.
-
SimpleSvm/SimpleSvm.hpp- AMD-specific structures, VMCB definitions, paging layouts, segment descriptors, and other low-level support types.
-
SimpleSvm/SimpleSvm.vcxproj- Visual Studio project for the Windows driver build.
-
SimpleSvm.sln- Solution entry point for building the project.
-
LICENSE- MIT license for the repository.
This project is designed for a very specific environment:
- Windows x64
- AMD processor with SVM support
- Nested Page Tables (NPT) support
- Windows Driver Kit (WDK)
- Visual Studio with driver development tools
- BIOS/UEFI with SVM enabled
- A controlled lab or kernel-debug environment
- Advanced knowledge of Windows internals, x64, and virtualization
This is not a user-mode project. It is a kernel driver and requires careful handling of memory, IRQL, exceptions, and race conditions.
- Open
SimpleSvm.slnin Visual Studio. - Install and configure the relevant Windows WDK and driver development components.
- Select the
x64target configuration (DebugorRelease). - Build the solution.
- Only load or test the driver in a controlled and authorized environment.
The driver checks whether the CPU is AMD and verifies that SVM and NPT are available. The validation is done through CPUID and model-specific register reads, and the driver rejects unsupported configurations.
The project creates a VMCB per logical processor with guest state, segment selectors, control registers, RSP, RIP, RFLAGS, and the interception settings needed for the test environment.
NPT is configured to manage guest physical-to-host physical translation. This allows the hypervisor to control memory visibility and guest addressing in a controlled way.
When guest execution triggers a VM exit, the hypervisor examines the exit reason and decides whether to emulate behavior, modify VMCB state, inject an exception, or abort the VM.
Typical exit cases include CPUID, MSR access, GDTR/IDTR access, and faults or exceptions that require host intervention.
The code includes a syscall hook and KUSER spoofing logic used to redirect or observe certain system paths. This is a representative low-level technique that demonstrates how a hypervisor can intercept or reshape the execution environment, but it is only suitable for research and tightly controlled testing.
The driver installs power-state handling and uses explicit teardown paths to free resources and avoid stale state during unload or shutdown. Stability work in this repository makes these paths safer and more resilient.
This repository includes a practical hardening pass on the original educational base. The work focuses on real kernel-mode failures that turn a demo into a BSOD-prone system under realistic load.
The improvements are intentionally documented in the code and relate to the basic rule that in kernel mode, every allocation can fail, every pointer can be NULL, every reference count can leak, and every race can eventually happen.
The most serious issues fixed include:
- Use-after-free on
EPROCESSduring process exit and background setup. MmProbeAndLockPagesbeing called with a NULL MDL after failed allocation.- Exception escapes from
MmProbeAndLockPageswithout a kernel-mode SEH guard. KeWaitForSingleObjectbeing called with a NULL object on driver unload.- A
sysretqrace where the indirect target pointer could become NULL between validation and execution. - A
sysretqvalidation problem where a kernel-mode or invalid address could be used as the return target.
These are exactly the kind of problems that do not show up in a happy-path demo but become guaranteed crashes under real-world conditions.
The code also fixes several resource leaks, including:
- MDL and locked-page leaks when mapping a KUSER page fails,
- stale
EPROCESSreferences not released in cleanup paths, - thread exit paths that skipped cleanup after a failed setup routine.
These are especially important because kernel leaks are resilient and often survive until reboot.
Additional fixes include:
- correcting a bad copy of
BaselineInterruptTimeQpcfrom the wrong source, - eliminating a hardcoded
NtSystemRootstring in favor of the realKUSER_SHARED_DATAvalue, - cleaning up duplicated or dead code that was never reached in practice,
- adding explicit compiler barriers in critical points to avoid incorrect memory ordering assumptions.
A few hot-path optimizations were also considered:
- fast-fail checks for
g_Ready, - avoiding expensive operations when readiness is false,
- removing dead IRQL manipulation code from
VMEXIThandling.
The gains are modest, but when combined with the safety fixes they improve both correctness and maintainability without turning the project into a fragile demo.
This is the central logic file. It defines:
- driver entry and lifecycle,
- verification of SVM/NPT support,
- VMCB and memory setup,
#VMEXITdispatch,- process tracking and KUSER spoofing,
- cleanup paths and hardening checks.
This contains the low-level assembly needed to:
- launch the guest environment,
- install and maintain the syscall hook,
- switch execution context between host and guest,
- perform the required stack and register manipulations for virtualization.
This holds the foundational low-level definitions:
- paging structures,
- bit masks,
- AMD SVM details,
- segment descriptors,
- and other shared constants required by the driver.
- Only relevant on AMD systems with SVM and NPT support.
- Not a standard user-mode application.
- Requires deep knowledge of kernel programming, x64, Windows internals, and virtualization.
- Requires a highly controlled environment and explicit permissions.
- Not suitable for production systems or general-purpose use.
This project is released under the MIT license. See LICENSE for details.
SimpleSvm is a minimal but educational Windows hypervisor implementation for AMD SVM hardware. The original code shows the core mechanics of virtualization, while this hardened variant makes the project safer, more resilient, and easier to reason about in the real world.
In short:
- original purpose: learn how SVM works,
- updated purpose: learn how to make a low-level virtualization project survive realistic kernel failures,
- current status: research and lab code, not production software.
This repository is best treated as a technical study project for engineers and researchers working in authorized, controlled environments.