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

arm64/kernel mode: Pull fixes for 48-bit VA from upstream #283

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

pussuw
Copy link

@pussuw pussuw commented Sep 13, 2024

Summary

Impact

Testing

@pussuw pussuw changed the title Arm64 kmode fixes2 [DO NOT MERGE]Arm64 kmode fixes2 Sep 13, 2024
@pussuw pussuw marked this pull request as draft September 13, 2024 13:07
The VMSAv8-64 translation system has 4 page table levels in total, ranging
from 0-3. The address environment code assumes only 3 levels, from 1-3 but
this is wrong; the amount of levels _utilized_ depends on the configured
VA size CONFIG_ARM64_VA_BITS. With <= 39 bits 3 levels is enough, while
if the va range is larger, the 4th translation table level is taken into
use dynamically by shifting the base translation table level.

From arm64_mmu.c, where va_bits is the amount of va bits used in address
translations:
(va_bits <= 21)       - base level 3
(22 <= va_bits <= 30) - base level 2
(31 <= va_bits <= 39) - base level 1
(40 <= va_bits <= 48) - base level 0

The base level is what is configured as the page directory root. This also
affects the performance of address translations i.e. if the VA range is
smaller, address translations are also faster as the page table walk is
shorter.
The original code made the incorrect assumption that the amount of
translation levels is 3, but this is incorrect. The amount of levels is 4
and the amount of levels that are utilized / in use is set dynamically
from the amount of VA bits in use.
The aforementioned functions can/will fail if the C compiler decides
to use the stack for the incoming entrypt/etc. parameters.

Fix this issue by converting the jump to user part into pure assembly,
ensuring the stack is NOT used for the parameters.
@pussuw pussuw changed the title [DO NOT MERGE]Arm64 kmode fixes2 arm64/kernel mode: Pull fixes for 48-bit VA from upstream Sep 23, 2024
@pussuw pussuw marked this pull request as ready for review September 23, 2024 13:03
@pussuw pussuw requested a review from jlaitine September 23, 2024 13:03
@pussuw pussuw merged commit a6a81be into master Sep 23, 2024
11 checks passed
@pussuw pussuw deleted the arm64_kmode_fixes2 branch September 23, 2024 17:28
Copy link

@jlaitine jlaitine left a comment

Choose a reason for hiding this comment

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

Sure, I was hoping to finish the nuttx rebase tomorrow though.... :)

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

Successfully merging this pull request may close these issues.

2 participants