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

risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode user space #7060

Merged
merged 1 commit into from Sep 12, 2022

Conversation

pussuw
Copy link
Contributor

@pussuw pussuw commented Sep 9, 2022

Summary

The L3 mapping function was just way too simplistic. Depending on memory configuration it either works or not.

Noticed that with icicle:pnsh the software crashes due to instruction page fault, reason is the map_region() implementation that does not work for regions that are not aligned to 2MB (the L2 page size).

Implemented an extremely simplistic page table allocator for the L3 references, that should once and for all get rid of the L3 mapping issue.

NOTE: gran_alloc() cannot be used at this point, it is too early for it.

Impact

Fixes full system crash if the kernel memory regions (or user memory regions in protected mode) are selected so that they
are not aligned to 2MB boundary.

Testing

icicle:pnsh / icicle:knsh

@pussuw
Copy link
Contributor Author

pussuw commented Sep 9, 2022

@masayuki2009 I know you use the qemu-rv / rv-virt target, I cannot test / verify that because I don't have the environment set up. If it breaks can you please inform me and I'll fix it.

@masayuki2009
Copy link
Contributor

@pussuw
Let me try this PR later.

@pussuw
Copy link
Contributor Author

pussuw commented Sep 9, 2022

@pussuw Let me try this PR later.

Sounds good!

@masayuki2009
Copy link
Contributor

@pussuw
I confirmed that qv-virt:knsh64 works without a side effect.

@pussuw
Copy link
Contributor Author

pussuw commented Sep 10, 2022

@pussuw I confirmed that qv-virt:knsh64 works without a side effect.

Excellent, thank you!

Copy link
Contributor

@pkarashchenko pkarashchenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Just few minor comments

arch/risc-v/src/mpfs/mpfs_mm_init.c Outdated Show resolved Hide resolved
arch/risc-v/src/mpfs/mpfs_mm_init.c Outdated Show resolved Hide resolved
arch/risc-v/src/mpfs/mpfs_userspace.c Outdated Show resolved Hide resolved
arch/risc-v/src/qemu-rv/qemu_rv_mm_init.c Outdated Show resolved Hide resolved
…pace

The L3 mapping function was just way too simplistic. Depending on memory
configuration it either works or not.

Noticed that with icicle:pnsh the software crashes due to instruction
page fault, reason is the map_region() implementation that does not
work for regions that are not aligned to 2MB (the L2 page size).

Implemented an extremely simplistic page table allocator for the L3
references, that should once and for all get rid of the L3 mapping issue.

NOTE: gran_alloc() cannot be used at this point, it is too early for it.
@pkarashchenko pkarashchenko changed the title risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode users… risc-v/mmu: Fix L3 mappings for kernel, and mpfs protected mode user space Sep 12, 2022
@masayuki2009 masayuki2009 merged commit ff05cc5 into apache:master Sep 12, 2022
@pussuw pussuw deleted the rv_mmu_l3_fix branch September 12, 2022 09:20
@jerpelea jerpelea added this to To-Add in Release Notes - 12.0.0 Dec 29, 2022
@jerpelea jerpelea moved this from To-Add to Added in Release Notes - 12.0.0 Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants