whp-backend

Implements the native Windows Hypervisor Platform backend for a Rust virtual machine monitor.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/doctorspider42/entangled-destop --skill whp-backend-doctorspider42
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: whp-backend
Source: https://github.com/doctorspider42/entangled-destop/tree/main/.agents/skills/whp-backend
Command: npx skills add https://github.com/doctorspider42/entangled-destop --skill whp-backend-doctorspider42

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Porting a KVM-based Rust VMM to Windows requires reimplementing everything KVM provides in-kernel — partition and vCPU lifecycle, register mapping, run-loop exit translation, MMIO instruction emulation, CPUID policy, and the PIC/IOAPIC/PIT interrupt chips that WHP does not supply. This Skill encodes the hard-won design decisions, type mappings, and debugging traps for that work so changes to the Windows backend stay correct and keep Linux green. ## Core Features & Use Cases - WHP partition and vCPU lifecycle: Guides partition property ordering, WHvMapGpaRange guest memory mapping, register name/value tables, and the 16-byte alignment rules that otherwise crash WHP calls silently. - Run-loop exit translation: Covers HaltGate idle handling, port-I/O and MMIO emulation via WHvEmulatorTryMmioEmulation, CPUID exit policy as a diff over DefaultResult registers, and ACPI S5 shutdown instead of triple-fault detection. - Userspace irqchip: Documents the portable 8259/8254/IOAPIC implementation in machine-x86, InterruptDelivery into WHvRequestInterrupt, and PIT counter design driven by host elapsed time. - Use Case: When modifying crates/vmm-core/src/whp/ or machine-x86/src/irqchip/, load this Skill to avoid known traps — for example, why a memory-to-memory instruction with one MMIO operand must serve guest RAM through the emulator callback, or why concurrent WHP tests must serialize on one partition per process. ## Quick Start Load this skill before making any change to the windows crate, WHv* API calls, or machine_x86::irqchip in the Entangled Desktop repository.

Frequently Asked Questions about whp-backend

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a WHP backend for a Rust VMM?

Create a partition with WHvCreatePartition, set processor count and local APIC emulation mode before WHvSetupPartition, then map guest RAM with WHvMapGpaRange and create vCPUs. Run WHvRunVirtualProcessor in a loop translating exits for port I/O, MMIO, CPUID, and halt.

How do I handle MMIO emulation on Windows Hypervisor Platform?

Use WHvEmulatorCreateEmulator from winhvemulation.dll with memory, I/O port, register get/set, and GVA translation callbacks. The emulator routes every memory operand through the callback, so serve RAM-backed GPAs from guest memory first and fall through to the device bus.

Does WHP provide an in-kernel irqchip like KVM?

No. WHP provides only each vCPU's local APIC, so the 8259 PIC, 8254 PIT, and IOAPIC must be implemented in userspace. Decoded interrupt messages are delivered to the local APIC through WHvRequestInterrupt.

Why does WHvMapGpaRange fail with 0xC0370008?

WHP allows only one mapped partition per process; a second concurrent partition fails its first WHvMapGpaRange with 0xC0370008. Run one VM per process and serialize concurrent WHP tests with a guard.

Why does a WHP virtual machine hang instead of shutting down?

With local APIC emulation on, a triple fault does not produce an exit — the VP parks inside WHvRunVirtualProcessor, so reboot=k hangs. End WHP guests through ACPI S5 via the PM1a_CNT poweroff latch instead.

Why does WHP crash with STATUS_ACCESS_VIOLATION inside register calls?

WHV_REGISTER_VALUE requires 16-byte alignment but the generated binding drops it, so stack arrays land on 8-mod-16 addresses and WHP faults with no error. Always use an over-aligned buffer type and reject misaligned buffers with a typed error.