Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

L4Linux: Main memory alignment problem (fails if it has 512Mb and more) #687

Closed
yefe opened this issue Mar 13, 2013 · 3 comments
Closed

Comments

@yefe
Copy link

yefe commented Mar 13, 2013

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:

  1. 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)

  2. 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?

@skalk
Copy link
Member

skalk commented Mar 13, 2013

This is a duplicate of issue #414 that was recently fixed by a commit of cproc 07a460dfc8df147494812b7aeb9ef65a53269a71. Can you please give it a try?

@skalk skalk closed this as completed Mar 13, 2013
@yefe
Copy link
Author

yefe commented Mar 13, 2013

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?)

@skalk
Copy link
Member

skalk commented Mar 13, 2013

we're planning to throw away the patch approach, and host a fork of l4linux via github. then it's easy to put such changes into single commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants