From ae96aeda651e2e5e5257112af2e46852a440931d Mon Sep 17 00:00:00 2001 From: Samuel Ortiz Date: Fri, 13 Nov 2020 11:32:28 +0100 Subject: [PATCH] arch: Move the gdt module to the hypervisor crate We will need the GDT API for the hypervisor's x86 instruction emulator implementation, it's better if the arch crate depends on the hypervisor one rather than the other way around. Signed-off-by: Samuel Ortiz --- arch/src/x86_64/mod.rs | 1 - arch/src/x86_64/regs.rs | 2 +- {arch/src/x86_64 => hypervisor/src/arch/x86}/gdt.rs | 2 +- hypervisor/src/arch/x86/mod.rs | 2 ++ 4 files changed, 4 insertions(+), 3 deletions(-) rename {arch/src/x86_64 => hypervisor/src/arch/x86}/gdt.rs (99%) diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 8773f3b16..ba9c131bc 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -7,7 +7,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE-BSD-3-Clause file. use std::sync::Arc; -mod gdt; pub mod interrupts; pub mod layout; mod mptable; diff --git a/arch/src/x86_64/regs.rs b/arch/src/x86_64/regs.rs index aae9b445f..0d2543306 100644 --- a/arch/src/x86_64/regs.rs +++ b/arch/src/x86_64/regs.rs @@ -9,8 +9,8 @@ use std::sync::Arc; use std::{mem, result}; -use super::gdt::{gdt_entry, segment_from_gdt}; use super::BootProtocol; +use hypervisor::arch::x86::gdt::{gdt_entry, segment_from_gdt}; use hypervisor::x86_64::{FpuState, SpecialRegisters, StandardRegisters}; use layout::{ BOOT_GDT_START, BOOT_IDT_START, PDE_START, PDPTE_START, PML4_START, PML5_START, PVH_INFO_START, diff --git a/arch/src/x86_64/gdt.rs b/hypervisor/src/arch/x86/gdt.rs similarity index 99% rename from arch/src/x86_64/gdt.rs rename to hypervisor/src/arch/x86/gdt.rs index 4d36cea8e..8e85330d6 100644 --- a/arch/src/x86_64/gdt.rs +++ b/hypervisor/src/arch/x86/gdt.rs @@ -8,7 +8,7 @@ // found in the LICENSE-BSD-3-Clause file. // For GDT details see arch/x86/include/asm/segment.h -use hypervisor::x86_64::SegmentRegister; +use crate::x86_64::SegmentRegister; /// Constructor for a conventional segment GDT (or LDT) entry. Derived from the kernel's segment.h. pub fn gdt_entry(flags: u16, base: u32, limit: u32) -> u64 { diff --git a/hypervisor/src/arch/x86/mod.rs b/hypervisor/src/arch/x86/mod.rs index 1b1a04c35..6d445d886 100644 --- a/hypervisor/src/arch/x86/mod.rs +++ b/hypervisor/src/arch/x86/mod.rs @@ -11,6 +11,8 @@ // Copyright © 2020, Microsoft Corporation // +pub mod gdt; + #[allow(non_upper_case_globals)] #[allow(non_camel_case_types)] #[allow(non_snake_case)]