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

Add basic support for user land address space #269

Merged
merged 6 commits into from
Jul 11, 2022

Conversation

wipawel
Copy link
Contributor

@wipawel wipawel commented Jul 8, 2022

It is implementing part of the Issue #55.

Consists of the following commits:

    arch, pagetables: fix IS_ADDR_SPACE_VA() macro
    
    The IS_ADDR_SPACE_VA() macro was using incorrect comparison for an
    address belonging to an address space. Masking (&) could return
    incorrect result for a shifted user address space mappings.
    arch, pagetables: fix vmap()'s initial va alignment check
    
    It should check VA alignment based on requested order, not just
    PAGE_MASK (4K pages order).
    arch, pagetables: prepare vmap() to handle separate address spaces
    
    Make _vmap() accept CR3 as parameter, indicating which address space
    is being mapped into. And turn vmap() and vunmap() into helper functions
    with default address space of the kernel (vmap_kern(), vunmap_kern()).
    
    Remove mmap_*() helper functions as they are confusing and not used.
    mm/vmm: add put_page_top() helper function for stack pages
    arch, pagetables: add user address space
    
    Add separate CR3 variable holding top of the user space page tables.
    Add vmap_user*() helper functions, capable of mapping both kernel
    mappings (kernel privilege, for necessary kernel mappings in user
    address space) and user mappings (userland data and code).
    
    Map userland data and code to both kernel and user address spaces.
    
    Map IDT and TSS's RSP0 stack to user address space as kernel mappings.
    arch: add SET_CR3 assembly macro
    
    The macro preserves RAX register via stack, but does not clean the stack.

wipawel added 6 commits July 8, 2022 15:10
The IS_ADDR_SPACE_VA() macro was using incorrect comparison for an
address belonging to an address space. Masking (&) could return
incorrect result for a shifted user address space mappings.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
It should check VA alignment based on requested order, not just
PAGE_MASK (4K pages order).

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
Make _vmap() accept CR3 as parameter, indicating which address space
is being mapped into. And turn vmap() and vunmap() into helper functions
with default address space of the kernel (vmap_kern(), vunmap_kern()).

Remove mmap_*() helper functions as they are confusing and not used.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
Add separate CR3 variable holding top of the user space page tables.
Add vmap_user*() helper functions, capable of mapping both kernel
mappings (kernel privilege, for necessary kernel mappings in user
address space) and user mappings (userland data and code).

Map userland data and code to both kernel and user address spaces.

Map IDT and TSS's RSP0 stack to user address space as kernel mappings.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
The macro preserves RAX register via stack, but does not clean the stack.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
@wipawel wipawel added feature New feature or request improvement A small enhancement, that makes already implemented features better devel Development effort Priority: 3 Regular feature labels Jul 8, 2022
@wipawel wipawel requested a review from a team as a code owner July 8, 2022 13:24
@wipawel wipawel merged commit 9cf5fe5 into KernelTestFramework:mainline Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devel Development effort feature New feature or request improvement A small enhancement, that makes already implemented features better Priority: 3 Regular feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants