diff --git a/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp b/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp index 992c132..2d16178 100644 --- a/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp +++ b/Architecture/amd64/cpu/SymmetricMultiprocessing.cpp @@ -115,6 +115,11 @@ namespace SMP { void Initialize(void *madt) { + if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_VIRTUALBOX) == 0) + { + KPrint("VirtualBox detected, disabling SMP"); + return; + } for (uint8_t i = 0; i < ((ACPI::MADT *)madt)->CPUCores; i++) if ((((APIC::APIC *)Interrupts::apic)->Read(APIC::APIC::APIC_ID) >> 24) != ((ACPI::MADT *)madt)->lapic[i]->ACPIProcessorId) { diff --git a/Kernel.cpp b/Kernel.cpp index ca38fd8..c1aebe4 100644 --- a/Kernel.cpp +++ b/Kernel.cpp @@ -81,26 +81,31 @@ EXTERNC void Entry(BootInfo *Info) cr0.NW = 0; cr0.CD = 0; - debug("Enabling UMIP, SMEP & SMAP support..."); - CPU::x64::cpuid(0x1, &rax, &rbx, &rcx, &rdx); - if (rdx & CPU::x64::CPUID_FEAT_RDX_UMIP) + if (strcmp(CPU::Hypervisor(), x86_CPUID_VENDOR_VIRTUALBOX) != 0) { - KPrint("UMIP is supported."); - fixme("Not going to enable UMIP."); - // cr4.UMIP = 1; - } - if (rdx & CPU::x64::CPUID_FEAT_RDX_SMEP) - { - KPrint("SMEP is supported."); - cr4.SMEP = 1; - } - if (rdx & CPU::x64::CPUID_FEAT_RDX_SMAP) - { - KPrint("SMAP is supported."); - cr4.SMAP = 1; + debug("Enabling UMIP, SMEP & SMAP support..."); + CPU::x64::cpuid(0x1, &rax, &rbx, &rcx, &rdx); + if (rdx & CPU::x64::CPUID_FEAT_RDX_UMIP) + { + KPrint("UMIP is supported."); + fixme("Not going to enable UMIP."); + // cr4.UMIP = 1; + } + if (rdx & CPU::x64::CPUID_FEAT_RDX_SMEP) + { + KPrint("SMEP is supported."); + cr4.SMEP = 1; + } + if (rdx & CPU::x64::CPUID_FEAT_RDX_SMAP) + { + KPrint("SMAP is supported."); + cr4.SMAP = 1; + } + CPU::x64::writecr4(cr4); } + else + KPrint("VirtualBox detected. Not using UMIP, SMEP & SMAP"); CPU::x64::writecr0(cr0); - CPU::x64::writecr4(cr4); debug("Enabling PAT support..."); CPU::x64::wrmsr(CPU::x64::MSR_CR_PAT, 0x6 | (0x0 << 8) | (0x1 << 16)); #elif defined(__i386__)