Crate x64

Crate x64 

Source
Expand description

§x64

x86_64 support with LA57 (5-level paging) for 57-bit virtual addresses.

This crate is a fork of the excellent rust-osdev/x86_64 crate, adding runtime support for 5-level paging (LA57) which enables 57-bit virtual addresses and up to 128 PB of addressable memory.

§The Problem

The upstream x86_64 crate (as of 0.15.x) has hardcoded 48-bit canonical address validation. When LA57 is enabled in CR4, addresses like 0x0000_8000_0000_0000 are perfectly valid (bit 56 is the sign bit, not bit 47), but the crate rejects them:

panicked at 'virtual address must be sign extended in bits 48 to 64'

§The Solution

This crate provides runtime detection of the paging mode:

use x64::{VirtAddr, addr::{enable_la57_mode, is_la57_mode}};

// During early boot, after enabling LA57 in CR4:
enable_la57_mode();

// Now addresses work correctly for 5-level paging:
let addr = VirtAddr::new(0x0000_8000_0000_0000);  // Works in LA57!

§Credits

This crate builds on the incredible work of Philipp Oppermann and all contributors to the rust-osdev/x86_64 project. We are deeply grateful for their foundational contributions to OS development in Rust.

Re-exports§

pub use crate::addr::align_down;
pub use crate::addr::align_up;
pub use crate::addr::enable_la57_mode;
pub use crate::addr::disable_la57_mode;
pub use crate::addr::is_la57_mode;
pub use crate::addr::LA57_ENABLED;
pub use crate::addr::PhysAddr;
pub use crate::addr::VirtAddr;

Modules§

addr
Physical and virtual addresses manipulation
instructionsinstructions and x86-64
Special x86_64 instructions.
registers
Access to various system and model specific registers.
structures
Representations of various x86 specific structures and descriptor tables.

Macros§

set_general_handlerinstructions and abi_x86_interrupt and x86-64
Set a general handler in an InterruptDescriptorTable.

Enums§

PrivilegeLevel
Represents a protection ring level.