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

@ -39,10 +39,10 @@ Region_map::Local_addr
Region_map_client::attach(Dataspace_capability ds, size_t size,
off_t offset, bool use_local_addr,
Region_map::Local_addr local_addr,
bool executable)
bool executable, bool writeable)
{
return _local(*this)->attach(ds, size, offset, use_local_addr,
local_addr, executable);
local_addr, executable, writeable);
}

View File

@ -123,10 +123,11 @@ void *Region_map_mmap::_map_local(Dataspace_capability ds,
bool use_local_addr,
addr_t local_addr,
bool executable,
bool overmap)
bool overmap,
bool writeable)
{
int const fd = _dataspace_fd(ds);
bool const writable = _dataspace_writable(ds);
bool const writable = _dataspace_writable(ds) && writeable;
int const flags = MAP_SHARED | (overmap ? MAP_FIXED : 0);
int const prot = PROT_READ
@ -172,7 +173,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
size_t size, off_t offset,
bool use_local_addr,
Region_map::Local_addr local_addr,
bool executable)
bool executable, bool writeable)
{
Lock::Guard lock_guard(lock());
@ -239,7 +240,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
* argument as the region was reserved by a PROT_NONE mapping.
*/
if (_is_attached())
_map_local(ds, region_size, offset, true, _base + (addr_t)local_addr, executable, true);
_map_local(ds, region_size, offset, true, _base + (addr_t)local_addr, executable, true, writeable);
return (void *)local_addr;
@ -290,7 +291,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
*/
_map_local(region.dataspace(), region.size(), region.offset(),
true, rm->_base + region.start() + region.offset(),
executable, true);
executable, true, writeable);
}
return rm->_base;
@ -304,7 +305,7 @@ Region_map::Local_addr Region_map_mmap::attach(Dataspace_capability ds,
* Note, we do not overmap.
*/
void *addr = _map_local(ds, region_size, offset, use_local_addr,
local_addr, executable);
local_addr, executable, false, writeable);
_add_to_rmap(Region((addr_t)addr, offset, ds, region_size));