From 1bc47507b7a509caf80c233f5f7872f18de4829c Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 27 Sep 2019 16:59:49 +0100 Subject: [PATCH] arch: Move initial page table addresses to layout module These are part of RAM and are used as the initial page table entries for booting the OS and firmware (identity mapping.) Signed-off-by: Rob Bradford --- arch/src/x86_64/layout.rs | 5 +++++ arch/src/x86_64/regs.rs | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/src/x86_64/layout.rs b/arch/src/x86_64/layout.rs index ce1efce3d..021ac7dce 100644 --- a/arch/src/x86_64/layout.rs +++ b/arch/src/x86_64/layout.rs @@ -29,6 +29,11 @@ pub const ZERO_PAGE_START: GuestAddress = GuestAddress(0x7000); pub const BOOT_STACK_START: GuestAddress = GuestAddress(0x8000); pub const BOOT_STACK_POINTER: GuestAddress = GuestAddress(0x8ff0); +// Initial pagetables. +pub const PML4_START: GuestAddress = GuestAddress(0x9000); +pub const PDPTE_START: GuestAddress = GuestAddress(0xa000); +pub const PDE_START: GuestAddress = GuestAddress(0xb000); + /// Kernel command line start address. pub const CMDLINE_START: GuestAddress = GuestAddress(0x20000); /// Kernel command line start address maximum size. diff --git a/arch/src/x86_64/regs.rs b/arch/src/x86_64/regs.rs index 2782b0b36..34fa7696f 100644 --- a/arch/src/x86_64/regs.rs +++ b/arch/src/x86_64/regs.rs @@ -11,13 +11,9 @@ use super::gdt::{gdt_entry, kvm_segment_from_gdt}; use arch_gen::x86::msr_index; use kvm_bindings::{kvm_fpu, kvm_msr_entry, kvm_msrs, kvm_regs, kvm_sregs}; use kvm_ioctls::VcpuFd; +use layout::{PDE_START, PDPTE_START, PML4_START}; use vm_memory::{Address, Bytes, GuestAddress, GuestMemory, GuestMemoryMmap}; -// Initial pagetables. -const PML4_START: GuestAddress = GuestAddress(0x9000); -const PDPTE_START: GuestAddress = GuestAddress(0xa000); -const PDE_START: GuestAddress = GuestAddress(0xb000); - // MTRR constants const MTRR_ENABLE: u64 = 0x800; // IA32_MTRR_DEF_TYPE MSR: E (MTRRs enabled) flag, bit 11 const MTRR_MEM_TYPE_WB: u64 = 0x6;