hw: introduce kernel/user address space split

* introduces central memory map for core/kernel
* on 32-bit platforms the kernel/core starts at 0x80000000
* on 64-bit platforms the kernel/core starts at 0xffffffc000000000
* mark kernel/core mappings as global ones (tagged TLB)
* move the exception vector to begin of core's binary,
  thereby bootstrap knows from where to map it appropriately
* do not map boot modules into core anymore
* constrain core's virtual heap memory area
* differentiate in between user's and core's main thread's UTCB,
  which now resides inside the kernel segment

Ref #2091
This commit is contained in:
Stefan Kalkowski
2017-06-20 15:25:04 +02:00
committed by Christian Helmuth
parent 362337a9e8
commit 42db1e112b
41 changed files with 275 additions and 73 deletions

View File

@ -62,9 +62,10 @@ Platform::Pd::Pd(Platform::Ram_allocator & alloc)
array(*Genode::construct_at<Table_array>(array_base))
{
using namespace Genode;
map_insert(Mapping((addr_t)table_base, (addr_t)table_base,
addr_t const table_virt_base = Hw::Mm::core_page_tables().base;
map_insert(Mapping((addr_t)table_base, table_virt_base,
sizeof(Table), Hw::PAGE_FLAGS_KERN_DATA));
map_insert(Mapping((addr_t)array_base, (addr_t)array_base,
map_insert(Mapping((addr_t)array_base, table_virt_base + sizeof(Table),
sizeof(Table_array), Hw::PAGE_FLAGS_KERN_DATA));
}
@ -93,16 +94,14 @@ void Platform::Pd::map_insert(Mapping m)
** Platform **
**************/
addr_t Platform::_load_elf()
Mapping Platform::_load_elf()
{
using namespace Genode;
using namespace Hw;
addr_t start = ~0UL;
addr_t end = 0;
Mapping ret;
auto lambda = [&] (Genode::Elf_segment & segment) {
void * phys = (void*)(core_elf_addr + segment.file_offset());
start = min(start, (addr_t) phys);
size_t const size = round_page(segment.mem_size());
if (segment.flags().w) {
@ -123,13 +122,22 @@ addr_t Platform::_load_elf()
//FIXME: set read-only, privileged and global accordingly
Page_flags flags{RW, segment.flags().x ? EXEC : NO_EXEC,
USER, NO_GLOBAL, RAM, CACHED};
USER, GLOBAL, RAM, CACHED};
Mapping m((addr_t)phys, (addr_t)segment.start(), size, flags);
core_pd->map_insert(m);
end = max(end, (addr_t)segment.start() + size);
/*
* Do not map the read-only, non-executable segment containing
* the boot modules, although it is a loadable segment, which we
* define so that the modules are loaded as ELF image
* via the bootloader
*/
if (segment.flags().x || segment.flags().w)
core_pd->map_insert(m);
else
ret = m;
};
core_elf.for_each_segment(lambda);
return end;
return ret;
}
@ -173,17 +181,17 @@ Platform::Platform()
core_pd->map_insert(m); });
/* load ELF */
addr_t const elf_end = _load_elf();
Mapping boot_modules = _load_elf();
/* setup boot info page */
void * bi_base = ram_alloc.alloc(sizeof(Boot_info));
core_pd->map_insert(Mapping((addr_t)bi_base, elf_end, sizeof(Boot_info),
Hw::PAGE_FLAGS_KERN_TEXT));
core_pd->map_insert(Mapping((addr_t)bi_base, Hw::Mm::boot_info().base,
sizeof(Boot_info), Hw::PAGE_FLAGS_KERN_TEXT));
Boot_info & bootinfo =
*construct_at<Boot_info>(bi_base, (addr_t)&core_pd->table,
(addr_t)&core_pd->array,
core_pd->mappings, board.core_mmio,
board.acpi_rsdp);
core_pd->mappings, boot_modules,
board.core_mmio, board.acpi_rsdp);
/* add all left RAM to bootinfo */
ram_alloc.for_each_free_region([&] (Memory_region const & r) {

View File

@ -129,7 +129,7 @@ class Bootstrap::Platform
addr_t core_elf_addr;
Elf core_elf;
addr_t _load_elf();
Mapping _load_elf();
public:

View File

@ -82,11 +82,14 @@
movl %eax, %cr0
/* Set up GDT */
movl $_mt_gdt_ptr+2, %eax
movl $_mt_gdt_start, (%eax)
lgdt _mt_gdt_ptr
/* Indirect long jump to 64-bit code */
ljmp $8, $_start64
.code64
_start64:
@ -119,7 +122,6 @@
_define_gdt 0
/*********************************
** .bss (non-initialized data) **
*********************************/