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:
@@ -9,7 +9,9 @@
|
|||||||
# error Must not be included directly. Include <commpage_defs.h> instead!
|
# error Must not be included directly. Include <commpage_defs.h> instead!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FIXME: correct address
|
#define COMMPAGE_ENTRY_X86_MEMCPY (COMMPAGE_ENTRY_FIRST_ARCH_SPECIFIC + 0)
|
||||||
#define ARCH_USER_COMMPAGE_ADDR (0xffff0000)
|
#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 */
|
#endif /* _SYSTEM_ARCH_x86_64_COMMPAGE_DEFS_H */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
#include "mmu.h"
|
#include "mmu.h"
|
||||||
|
|
||||||
|
|
||||||
static const uint64 kTableMappingFlags = 0x3;
|
static const uint64 kTableMappingFlags = 0x7;
|
||||||
static const uint64 kLargePageMappingFlags = 0x183;
|
static const uint64 kLargePageMappingFlags = 0x183;
|
||||||
static const uint64 kPageMappingFlags = 0x103;
|
static const uint64 kPageMappingFlags = 0x103;
|
||||||
// Global, R/W, Present
|
// Global, R/W, Present
|
||||||
|
|||||||
@@ -922,8 +922,6 @@ arch_cpu_init_post_modules(kernel_args* args)
|
|||||||
call_all_cpus(&init_mtrrs, NULL);
|
call_all_cpus(&init_mtrrs, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO x86_64
|
|
||||||
#ifndef __x86_64__
|
|
||||||
// get optimized functions from the CPU module
|
// get optimized functions from the CPU module
|
||||||
if (sCpuModule != NULL && sCpuModule->get_optimized_functions != NULL) {
|
if (sCpuModule != NULL && sCpuModule->get_optimized_functions != NULL) {
|
||||||
x86_optimized_functions functions;
|
x86_optimized_functions functions;
|
||||||
@@ -960,7 +958,7 @@ arch_cpu_init_post_modules(kernel_args* args)
|
|||||||
elf_add_memory_image_symbol(image, "commpage_memset",
|
elf_add_memory_image_symbol(image, "commpage_memset",
|
||||||
((addr_t*)USER_COMMPAGE_ADDR)[COMMPAGE_ENTRY_X86_MEMSET], memsetLen,
|
((addr_t*)USER_COMMPAGE_ADDR)[COMMPAGE_ENTRY_X86_MEMSET], memsetLen,
|
||||||
B_SYMBOL_TYPE_TEXT);
|
B_SYMBOL_TYPE_TEXT);
|
||||||
#endif
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress,
|
|||||||
|
|
||||||
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
|
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
|
||||||
| X86_64_PDPTE_PRESENT
|
| X86_64_PDPTE_PRESENT
|
||||||
| X86_64_PDPTE_WRITABLE);
|
| X86_64_PDPTE_WRITABLE
|
||||||
|
| X86_64_PDPTE_USER);
|
||||||
|
|
||||||
// Map it and zero it.
|
// Map it and zero it.
|
||||||
virtualPageDir = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
|
virtualPageDir = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
|
||||||
@@ -154,7 +155,8 @@ X86PagingMethod64Bit::MapEarly(kernel_args* args, addr_t virtualAddress,
|
|||||||
|
|
||||||
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
|
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
|
||||||
| X86_64_PDE_PRESENT
|
| X86_64_PDE_PRESENT
|
||||||
| X86_64_PDE_WRITABLE);
|
| X86_64_PDE_WRITABLE
|
||||||
|
| X86_64_PDE_USER);
|
||||||
|
|
||||||
// Map it and zero it.
|
// Map it and zero it.
|
||||||
virtualPageTable = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
|
virtualPageTable = (uint64*)fKernelPhysicalPageMapper->GetPageTableAt(
|
||||||
@@ -222,7 +224,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
|
|||||||
SetTableEntry(pml4e, (physicalPDPT & X86_64_PML4E_ADDRESS_MASK)
|
SetTableEntry(pml4e, (physicalPDPT & X86_64_PML4E_ADDRESS_MASK)
|
||||||
| X86_64_PML4E_PRESENT
|
| X86_64_PML4E_PRESENT
|
||||||
| X86_64_PML4E_WRITABLE
|
| X86_64_PML4E_WRITABLE
|
||||||
| (isKernel ? 0 : X86_64_PML4E_USER));
|
| X86_64_PML4E_USER);
|
||||||
|
|
||||||
mapCount++;
|
mapCount++;
|
||||||
}
|
}
|
||||||
@@ -252,7 +254,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
|
|||||||
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
|
SetTableEntry(pdpte, (physicalPageDir & X86_64_PDPTE_ADDRESS_MASK)
|
||||||
| X86_64_PDPTE_PRESENT
|
| X86_64_PDPTE_PRESENT
|
||||||
| X86_64_PDPTE_WRITABLE
|
| X86_64_PDPTE_WRITABLE
|
||||||
| (isKernel ? 0 : X86_64_PDPTE_USER));
|
| X86_64_PDPTE_USER);
|
||||||
|
|
||||||
mapCount++;
|
mapCount++;
|
||||||
}
|
}
|
||||||
@@ -282,7 +284,7 @@ X86PagingMethod64Bit::PageTableForAddress(uint64* virtualPML4,
|
|||||||
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
|
SetTableEntry(pde, (physicalPageTable & X86_64_PDE_ADDRESS_MASK)
|
||||||
| X86_64_PDE_PRESENT
|
| X86_64_PDE_PRESENT
|
||||||
| X86_64_PDE_WRITABLE
|
| X86_64_PDE_WRITABLE
|
||||||
| (isKernel ? 0 : X86_64_PDE_USER));
|
| X86_64_PDE_USER);
|
||||||
|
|
||||||
mapCount++;
|
mapCount++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ allocate_commpage_entry(int entry, size_t size)
|
|||||||
sFreeCommPageSpace = ALIGN_ENTRY((addr_t)sFreeCommPageSpace + size);
|
sFreeCommPageSpace = ALIGN_ENTRY((addr_t)sFreeCommPageSpace + size);
|
||||||
sCommPageAddress[entry] = (addr_t)sUserCommPageAddress
|
sCommPageAddress[entry] = (addr_t)sUserCommPageAddress
|
||||||
+ ((addr_t)space - (addr_t)sCommPageAddress);
|
+ ((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;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ dump_symbols(int argc, char **argv)
|
|||||||
|
|
||||||
// dump symbols
|
// 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");
|
kprintf("%-*s Type Size Name\n", B_PRINTF_POINTER_WIDTH, "Address");
|
||||||
|
|
||||||
if (image->num_debug_symbols > 0) {
|
if (image->num_debug_symbols > 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user