| Crates.io | x86_vlapic |
| lib.rs | x86_vlapic |
| version | 0.1.0 |
| created_at | 2025-08-17 16:53:06.804863+00 |
| updated_at | 2025-08-17 16:53:06.804863+00 |
| description | x86 Virtual Local APIC |
| homepage | |
| repository | https://github.com/arceos-hypervisor/x86_vlapic |
| max_upload_size | |
| id | 1799574 |
| size | 215,779 |
A Rust library for virtualizing x86 Local Advanced Programmable Interrupt Controller (LAPIC) functionality. [Work in Progress].
This library provides a software implementation of the x86 Local APIC (Advanced Programmable Interrupt Controller) for hypervisor use cases. It virtualizes the LAPIC registers and functionality according to the Intel Software Developer's Manual (SDM) specifications.
⚠️ Important: This is an early-stage library focused solely on timer virtualization. Do not use for full LAPIC emulation yet.
The library is structured into several key modules:
src/vlapic.rs - Main virtual LAPIC implementationsrc/timer.rs - LAPIC timer virtualizationsrc/consts.rs - Constants and register offset definitionssrc/utils.rs - Utility functionssrc/regs/mod.rs - Main register structure definitionssrc/regs/lvt/ - Local Vector Table register implementations
timer.rs - LVT Timer Registerlint0.rs - LVT LINT0 Registerlint1.rs - LVT LINT1 Registererror.rs - LVT Error Registerthermal.rs - LVT Thermal Monitor Registerperfmon.rs - LVT Performance Counter Registercmci.rs - LVT CMCI Registersrc/regs/timer/ - Timer-related register definitions
dcr.rs - Divide Configuration Registeruse x86_vlapic::EmulatedLocalApic;
use axvisor_api::vmm::{VMId, VCpuId};
// Create a new emulated Local APIC for VM 1, VCPU 0
let vm_id = VMId::from(1 as usize);
let vcpu_id = VCpuId::from(0 as usize);
let apic = EmulatedLocalApic::new(vm_id, vcpu_id);
// Get the shared virtual APIC access page address (static for all instances)
let access_addr = EmulatedLocalApic::virtual_apic_access_addr();
assert!(access_addr.is_aligned(PAGE_SIZE_4K));
// Get the per-VCPU virtual APIC page address
let page_addr = apic.virtual_apic_page_addr();
assert!(page_addr.is_aligned(PAGE_SIZE_4K));
This library is designed for x86_64 architecture and targets x86_64-unknown-none for no-std environments, making it suitable for hypervisor and kernel development.
ArceOS - An experimental modular OS (or Unikernel) AxVisor - Hypervisor implementation
Note: This is a virtualization library and does not interact with actual hardware LAPIC. It's designed for use in hypervisors and virtual machine monitors.