mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 02:40:08 +00:00
sel4: convert frame pages back to untyped memory
to implement _revoke_ram_ds and to fix _unmap_local Issue #2044
This commit is contained in:
parent
b5ff552460
commit
2aaeb8db1b
@ -71,7 +71,10 @@ class Genode::Cnode_base
|
|||||||
*/
|
*/
|
||||||
void remove(Index idx)
|
void remove(Index idx)
|
||||||
{
|
{
|
||||||
seL4_CNode_Delete(sel().value(), idx.value(), size_log2());
|
int ret = seL4_CNode_Delete(sel().value(), idx.value(), size_log2());
|
||||||
|
if (ret != seL4_NoError)
|
||||||
|
error(__PRETTY_FUNCTION__, ": seL4_CNode_Delete (",
|
||||||
|
Hex(idx.value()), ") returned ", ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ struct Genode::Untyped_memory
|
|||||||
get_page_size_log2());
|
get_page_size_log2());
|
||||||
|
|
||||||
if (alloc_ret.error()) {
|
if (alloc_ret.error()) {
|
||||||
PERR("%s: allocation of untyped memory failed", __FUNCTION__);
|
error(__PRETTY_FUNCTION__, ": allocation of untyped memory failed");
|
||||||
throw Phys_alloc_failed();
|
throw Phys_alloc_failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,13 +110,47 @@ struct Genode::Untyped_memory
|
|||||||
node_offset,
|
node_offset,
|
||||||
num_objects);
|
num_objects);
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != seL4_NoError) {
|
||||||
PERR("%s: seL4_Untyped_RetypeAtOffset (IA32_4K) returned %d",
|
error(__FUNCTION__, ": seL4_Untyped_RetypeAtOffset (IA32_4K) "
|
||||||
__FUNCTION__, ret);
|
"returned ", ret);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free up page frames and turn it so into untyped memory
|
||||||
|
*/
|
||||||
|
static inline void convert_to_untyped_frames(addr_t const phys_addr,
|
||||||
|
addr_t const phys_size)
|
||||||
|
{
|
||||||
|
seL4_Untyped const service = Core_cspace::PHYS_CNODE_SEL;
|
||||||
|
int const space_size = Core_cspace::NUM_PHYS_SEL_LOG2;
|
||||||
|
|
||||||
|
for (addr_t phys = phys_addr; phys < phys_addr + phys_size;
|
||||||
|
phys += get_page_size()) {
|
||||||
|
|
||||||
|
int const index = phys >> get_page_size_log2();
|
||||||
|
/**
|
||||||
|
* Without the revoke, one gets sporadically
|
||||||
|
* Untyped Retype: Insufficient memory ( xx bytes needed, x bytes
|
||||||
|
* available)
|
||||||
|
* for the phys_addr when it gets reused.
|
||||||
|
*/
|
||||||
|
int ret = seL4_CNode_Revoke(service, index, space_size);
|
||||||
|
if (ret != seL4_NoError)
|
||||||
|
error(__FUNCTION__, ": seL4_CNode_Revoke returned ", ret);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Without the delete, one gets:
|
||||||
|
* Untyped Retype: Slot #xxxx in destination window non-empty
|
||||||
|
*/
|
||||||
|
ret = seL4_CNode_Delete(service, index, space_size);
|
||||||
|
if (ret != seL4_NoError)
|
||||||
|
error(__FUNCTION__, ": seL4_CNode_Delete returned ", ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _CORE__INCLUDE__UNTYPED_MEMORY_H_ */
|
#endif /* _CORE__INCLUDE__UNTYPED_MEMORY_H_ */
|
||||||
|
@ -75,7 +75,12 @@ bool Mapped_mem_allocator::_map_local(addr_t virt_addr, addr_t phys_addr,
|
|||||||
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
|
bool Mapped_mem_allocator::_unmap_local(addr_t virt_addr, addr_t phys_addr,
|
||||||
unsigned size)
|
unsigned size)
|
||||||
{
|
{
|
||||||
return unmap_local(virt_addr, size / get_page_size());
|
if (!unmap_local(virt_addr, size / get_page_size()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Untyped_memory::convert_to_untyped_frames(phys_addr, size);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ void Ram_session_component::_export_ram_ds(Dataspace_component *ds)
|
|||||||
|
|
||||||
void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds)
|
void Ram_session_component::_revoke_ram_ds(Dataspace_component *ds)
|
||||||
{
|
{
|
||||||
PDBG("not implemented");
|
Untyped_memory::convert_to_untyped_frames(ds->phys_addr(), ds->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user