You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Test case:
When I give L4Linux 512Mb memory and more, user level apps execution can cause mystic errors, such as ‘Segmentation fault’ , glibc error, . For Pandaboard if memory has been extended to 1024Mb in Fiasco.OC bootstrap:
base-foc/contrib/l4/mk/platforms/pandaboard.conf :
PLATFORM_RAM_SIZE_MB = 1024
L4Linux allocates the main memory in function: long l4re_ma_alloc(unsigned long size, l4re_ds_t const mem, unsigned long flags)
calling ram_session()->alloc(size);
in it's turn called: Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, bool cached),
that function should find an optimal alignmemt for this memory chunk, starting from log2(size) (that is equal to 29 in case of 512MB chunk) and decrementing.
Note, that final alignment of memory chunk is 28 (alloc_aligned with align=29 fails)
L4Linux reserves memory in function: Region* Region_manager::reserve_range(Genode::size_t size, int align, Genode::addr_t start)
that calls:
env()->rm_session()->attach();
That calls Rm_session_component::attach in base/src/core/rm_session_component.cc. In this function one can see a similar approach to find an optimal alignment for memory chunk 512MB, starting from log2(size)=29 and decrementing. But final alignment at the end of the loop (align_log2) in this case is equal to 29 (that is greater then the allocated memory alignment !) and allocates the map:
_map.alloc_aligned(size, &r, align_log2);
with alignment 29.
Conclusion:
If we use 512Mb RAM, Genode’s Region Manager reserves region for ‘Main Memory’ from 0x20000000 to 0x3fffffff address (because of align=29), but allocated range starts from 0x10000000 (because of align=28). And ‘vmalloc’ region is reserved below ‘Main Memory’ region in this case. But this is not correct. According to function ‘sanity_check_meminfo’, the ‘Main Memory’ region must be located below ‘vmalloc’ region.
Possible solution:
When we force memory alignment in Rm_session_component::attach to be equal to allocated memory alignment (final) in
'''Ram_dataspace_capability Ram_session_component::alloc''
problems around L4Linux seems to be disappear.
I used a hardcoding such as
if (align_log2==29) align_log2=20;
in both Ram_session_component::alloc and Rm_session_component::attach but maybe you have a better idea?
The text was updated successfully, but these errors were encountered:
Ok, i'll test (it needs time). It is hard to understand all changes in L4Linux contrib code (maybe it will be reasonable to separate l4lx_genode.patch to a multiple patches?)
Test case:
When I give L4Linux 512Mb memory and more, user level apps execution can cause mystic errors, such as ‘Segmentation fault’ , glibc error, . For Pandaboard if memory has been extended to 1024Mb in Fiasco.OC bootstrap:
base-foc/contrib/l4/mk/platforms/pandaboard.conf :
PLATFORM_RAM_SIZE_MB = 1024
And L4Linux can use more than 512M memory:
<start name="vmlinux"> <binary name="l4linux"/> <resource name="RAM" quantum="796M"/> <config args="mem=512M l4x_rd=initrd.gz"> <block label="sda" /> </config> </start>
I did some investigation:
L4Linux allocates the main memory in function:
long l4re_ma_alloc(unsigned long size, l4re_ds_t const mem, unsigned long flags)
calling ram_session()->alloc(size);
in it's turn called:
Ram_dataspace_capability Ram_session_component::alloc(size_t ds_size, bool cached)
,that function should find an optimal alignmemt for this memory chunk, starting from log2(size) (that is equal to 29 in case of 512MB chunk) and decrementing.
Note, that final alignment of memory chunk is 28 (alloc_aligned with align=29 fails)
L4Linux reserves memory in function:
Region* Region_manager::reserve_range(Genode::size_t size, int align, Genode::addr_t start)
that calls:
env()->rm_session()->attach();
That calls Rm_session_component::attach in base/src/core/rm_session_component.cc. In this function one can see a similar approach to find an optimal alignment for memory chunk 512MB, starting from log2(size)=29 and decrementing. But final alignment at the end of the loop (align_log2) in this case is equal to 29 (that is greater then the allocated memory alignment !) and allocates the map:
_map.alloc_aligned(size, &r, align_log2);
with alignment 29.
Conclusion:
If we use 512Mb RAM, Genode’s Region Manager reserves region for ‘Main Memory’ from 0x20000000 to 0x3fffffff address (because of align=29), but allocated range starts from 0x10000000 (because of align=28). And ‘vmalloc’ region is reserved below ‘Main Memory’ region in this case. But this is not correct. According to function ‘sanity_check_meminfo’, the ‘Main Memory’ region must be located below ‘vmalloc’ region.
Possible solution:
When we force memory alignment in Rm_session_component::attach to be equal to allocated memory alignment (final) in
'''Ram_dataspace_capability Ram_session_component::alloc''
problems around L4Linux seems to be disappear.
I used a hardcoding such as
if (align_log2==29) align_log2=20;
in both Ram_session_component::alloc and Rm_session_component::attach but maybe you have a better idea?
The text was updated successfully, but these errors were encountered: