Fixed commpage for x86_64.

Since the commpage is at a kernel address, changed 64-bit paging code
to match x86's behaviour of allowing user-accessible mappings to be
created in the kernel portion of the address space. This is also
required by some drivers.
This commit is contained in:
Alex Smith
2012-07-21 16:18:10 +01:00
parent 195a0f350e
commit 59ae45c1ab
6 changed files with 16 additions and 13 deletions
@@ -9,7 +9,9 @@
# error Must not be included directly. Include <commpage_defs.h> instead!
#endif
// FIXME: correct address
#define ARCH_USER_COMMPAGE_ADDR (0xffff0000)
#define COMMPAGE_ENTRY_X86_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0)
#define COMMPAGE_ENTRY_X86_MEMSET (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 1)
#define ARCH_USER_COMMPAGE_ADDR (0xffffffffffff0000)
#endif /* _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H */
+1 -1
View File
@@ -27,7 +27,7 @@
#include "mmu.h"
static const uint64 kTableMappingFlags = 0x3;
static const uint64 kTableMappingFlags = 0x7;
static const uint64 kLargePageMappingFlags = 0x183;
static const uint64 kPageMappingFlags = 0x103;
// Global, R/W, Present
+1 -3
View File
@@ -922,8 +922,6 @@ arch_cpu_init_post_modules(kernel_args* args)
call_all_cpus(&init_mtrrs, NULL);
}
// TODO x86_64
#ifndef __x86_64__
// get optimized functions from the CPU module
if (sCpuModule != NULL && sCpuModule->get_optimized_functions != NULL) {
x86_optimized_functions functions;
@@ -960,7 +958,7 @@ arch_cpu_init_post_modules(kernel_args* args)
elf_add_memory_image_symbol(image, "commpage_memset",
((addr_t*)USER_COMMPAGE_ADDR)[COMMPAGE_ENTRY_X86_MEMSET], memsetLen,
B_SYMBOL_TYPE_TEXT);
#endif
return B_OK;
}
@@ -131,7 +131,8 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress,
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
| X86_64_PDPTE_PRESENT
| X86_64_PDPTE_WRITABLE);
| X86_64_PDPTE_WRITABLE
| X86_64_PDPTE_USER);
// Map it and zero it.
virtualPageDir = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
@@ -154,7 +155,8 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress,
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
| X86_64_PDE_PRESENT
| X86_64_PDE_WRITABLE);
| X86_64_PDE_WRITABLE
| X86_64_PDE_USER);
// Map it and zero it.
virtualPageTable = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
@@ -222,7 +224,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
SetTableEntry(pml4e, (physicalPDPT & X86_64_PML4E_ADDRESS_MASK)
| X86_64_PML4E_PRESENT
| X86_64_PML4E_WRITABLE
| (isKernel ? 0 : X86_64_PML4E_USER));
| X86_64_PML4E_USER);
mapCount++;
}
@@ -252,7 +254,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
| X86_64_PDPTE_PRESENT
| X86_64_PDPTE_WRITABLE
| (isKernel ? 0 : X86_64_PDPTE_USER));
| X86_64_PDPTE_USER);
mapCount++;
}
@@ -282,7 +284,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
| X86_64_PDE_PRESENT
| X86_64_PDE_WRITABLE
| (isKernel ? 0 : X86_64_PDE_USER));
| X86_64_PDE_USER);
mapCount++;
}
+2 -1
View File
@@ -32,7 +32,8 @@ allocate_commpage_entry(int entry, size_t size)
sFreeCommPageSpace = ALIGN_ENTRY((addr_t)sFreeCommPageSpace + size);
sCommPageAddress[entry] = (addr_t)sUserCommPageAddress
+ ((addr_t)space - (addr_t)sCommPageAddress);
dprintf("allocate_commpage_entry(%d, %lu) -> %p\n", entry, size, (void*)sCommPageAddress[entry]);
dprintf("allocate_commpage_entry(%d, %lu) -> %p\n", entry, size,
(void*)sCommPageAddress[entry]);
return space;
}
+1 -1
View File
@@ -463,7 +463,7 @@ dump_symbols(int argc, char **argv)
// dump symbols
kprintf("Symbols of image %" B_PRId32 "\"%s\":\n", image->id, image->name);
kprintf("Symbols of image %" B_PRId32 " \"%s\":\n", image->id, image->name);
kprintf("%-*s Type Size Name\n", B_PRINTF_POINTER_WIDTH, "Address");
if (image->num_debug_symbols > 0) {