mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Workaround for VirtualBox
This commit is contained in:
parent
e477618116
commit
6256ab5a4f
@ -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)
|
||||
{
|
||||
|
39
Kernel.cpp
39
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__)
|
||||
|
Loading…
x
Reference in New Issue
Block a user