-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Need help with heap allocation from user program #1348
Comments
Can you share the code? Do you have separate address spaces? |
@tsatke, Thank you I was trying to set up a user mode program and test if it runs in ring 3. I set up the gdt. With a simple syscall was testing to print a value created in the user program. As of now i don't have a seperated addresss spaces was trying to figure out how to do it, I do have a Page that is mapped as user accessible. It works well with numbers that are stored on stack. Created a simple try_userprog function:
`/// Maps one page for the user program for testing usermode
}` Also created a stack for the user program and mapped it : `pub fn create_stack_mapping(
}` When initializing heap, made a change - In PageTableFlags::User_Accessible : `pub fn init_heap(
}` When I try to use Box::new() I get the Page Fault error: Thank you. |
Is the code of However, the compiled code of For a more sustainable solution, I'd build a separate executable that has all the code it needs ( As a reference, here's my implementation:
I have to add that I haven't made it into usermode yet, so you might adapt some things, like the trampoline (which makes the same mistake that I think you made). |
Hello,
When mapping the heap from the init_heap() I have added the PageTableFlags::User_Accessible. I also created a small user program which runs in ring 3. In that program when I try to use Box::new() I get a page fault error with error code User_Mode and Instruction Fetch. Also the virtual address which the Box::new() is trying to access is where the user program is mapped, instead of the heap address.
I am unable to figure out why Box::new() is not storing the value on heap when used in userspace, when it does correctly in kernel space.
Thank you.
The text was updated successfully, but these errors were encountered: