diff --git a/Kernel/Arch/i386/APIC.cpp b/Kernel/Arch/i386/APIC.cpp index 0855f0ecf4..752bd9c56a 100644 --- a/Kernel/Arch/i386/APIC.cpp +++ b/Kernel/Arch/i386/APIC.cpp @@ -156,6 +156,8 @@ extern "C" u16 apic_ap_start_size; bool init() { + // FIXME: This code is broken and therefore isn't called. Please map everything correctly before calling this code. + ASSERT_NOT_REACHED(); if (!MSR::have()) return false; @@ -168,9 +170,8 @@ bool init() kprintf("Initializing APIC, base: P%x\n", apic_base); set_base(apic_base); - MM.map_for_kernel(VirtualAddress(apic_base.get()), apic_base, true); // Map memory, disable cache! g_apic_base = apic_base.as_ptr(); - + // copy ap init code to P8000 memcpy(reinterpret_cast(0x8000), reinterpret_cast(apic_ap_start), apic_ap_start_size); return true; diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 80dd6fedaf..36fe7113b4 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -55,7 +55,7 @@ MemoryManager::MemoryManager() asm volatile("movl %%eax, %%cr3" ::"a"(kernel_page_directory().cr3())); - setup_low_1mb(); + setup_low_identity_mapping(); protect_kernel_image(); } @@ -83,7 +83,7 @@ void MemoryManager::protect_kernel_image() } } -void MemoryManager::setup_low_1mb() +void MemoryManager::setup_low_identity_mapping() { m_low_page_table = allocate_user_physical_page(ShouldZeroFill::Yes); @@ -101,7 +101,7 @@ void MemoryManager::setup_low_1mb() if (g_cpu_supports_nx) pde_zero.set_execute_disabled(true); - for (uintptr_t offset = 0; offset < (2 * MB); offset += PAGE_SIZE) { + for (uintptr_t offset = (1 * MB); offset < (2 * MB); offset += PAGE_SIZE) { auto& page_table_page = m_low_page_table; auto& pte = quickmap_pt(page_table_page->paddr())[offset / PAGE_SIZE]; pte.set_physical_page_base(offset); @@ -532,17 +532,6 @@ PageTableEntry* MemoryManager::quickmap_pt(PhysicalAddress pt_paddr) return (PageTableEntry*)0xffe08000; } -void MemoryManager::map_for_kernel(VirtualAddress vaddr, PhysicalAddress paddr, bool cache_disabled) -{ - auto& pte = ensure_pte(kernel_page_directory(), vaddr); - pte.set_physical_page_base(paddr.get()); - pte.set_present(true); - pte.set_writable(true); - pte.set_user_allowed(false); - pte.set_cache_disabled(cache_disabled); - flush_tlb(vaddr); -} - u8* MemoryManager::quickmap_page(PhysicalPage& physical_page) { ASSERT_INTERRUPTS_DISABLED(); diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index 0cd372022d..abb4591401 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -108,8 +108,6 @@ public: void deallocate_user_physical_page(PhysicalPage&&); void deallocate_supervisor_physical_page(PhysicalPage&&); - void map_for_kernel(VirtualAddress, PhysicalAddress, bool cache_disabled = false); - OwnPtr allocate_kernel_region(size_t, const StringView& name, u8 access, bool user_accessible = false, bool should_commit = true, bool cacheable = true); OwnPtr allocate_kernel_region(PhysicalAddress, size_t, const StringView& name, u8 access, bool user_accessible = false, bool cacheable = false); OwnPtr allocate_kernel_region_with_vmobject(VMObject&, size_t, const StringView& name, u8 access, bool user_accessible = false, bool cacheable = false); @@ -149,7 +147,7 @@ private: void unregister_region(Region&); void detect_cpu_features(); - void setup_low_1mb(); + void setup_low_identity_mapping(); void protect_kernel_image(); void parse_memory_map(); void flush_entire_tlb(); diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 863c3fbbb3..2f69a6e576 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -142,9 +142,6 @@ extern "C" [[noreturn]] void init() PCI::Initializer::the().test_and_initialize(KParams::the().has("nopci_mmio")); PCI::Initializer::the().dismiss(); - if (APIC::init()) - APIC::enable(0); - PIT::initialize(); PCI::enumerate_all([](const PCI::Address& address, PCI::ID id) {