base: support to attach RAM dataspaces readonly

Fixes #1633
This commit is contained in:
Alexander Boettcher
2018-05-08 11:21:10 +02:00
committed by Christian Helmuth
parent 487e8ea934
commit e6d20aba93
29 changed files with 122 additions and 78 deletions

View File

@@ -26,7 +26,7 @@ using namespace Genode;
Region_map::Local_addr
Core_region_map::attach(Dataspace_capability ds_cap, size_t size,
off_t offset, bool use_local_addr,
Region_map::Local_addr, bool)
Region_map::Local_addr, bool, bool writeable)
{
auto lambda = [&] (Dataspace_component *ds) -> Local_addr {
if (!ds)
@@ -61,8 +61,9 @@ Core_region_map::attach(Dataspace_capability ds_cap, size_t size,
/* map the dataspace's physical pages to corresponding virtual addresses */
unsigned num_pages = page_rounded_size >> get_page_size_log2();
Page_flags const flags { ds->writable() ? RW : RO, NO_EXEC, KERN,
GLOBAL, ds->io_mem() ? DEVICE : RAM,
Page_flags const flags { (writeable && ds->writable()) ? RW : RO,
NO_EXEC, KERN, GLOBAL,
ds->io_mem() ? DEVICE : RAM,
ds->cacheability() };
if (!map_local(ds->phys_addr(), (addr_t)virt_addr, num_pages, flags))
return nullptr;

View File

@@ -94,8 +94,8 @@ void Genode::Cpu::mmu_fault(Context & regs, Kernel::Thread_fault & fault)
};
auto fault_lambda = [] (addr_t err) {
if (!(err & ERR_P)) return Fault::PAGE_MISSING;
if (err & ERR_W) return Fault::WRITE;
if (!(err & ERR_P)) return Fault::PAGE_MISSING;
if (err & ERR_I) return Fault::EXEC;
else return Fault::UNKNOWN;
};