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

riscv pmap: only need to re-read l3 when crossing the page boundary #1589

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

wy-chung
Copy link
Contributor

@wy-chung wy-chung commented Feb 2, 2025

No description provided.

l3 = pmap_l3(kernel_pmap, va);
while (true) {
KASSERT(l3 != NULL, ("%s: Invalid page table, va: 0x%lx",
__func__, va));
Copy link
Member

Choose a reason for hiding this comment

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

I think a better pattern is something like

for (l3 = NULL; size > 0; size -= PAGE_SIZE) {
    if (l3 == NULL || __is_aligned((uintptr_t)l3, PAGE_SIZE))
        l3 = pmap_l3(kernel_pmap, va);
    ...
    va += PAGE_SIZE;
    l3++;
}

This way, we don't need the extra size == 0 check, and there's only one use of pmap_l3().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will miss the KASSERT check for (l3 != NULL).

Copy link
Member

Choose a reason for hiding this comment

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

Well, it can be added after the pmap_l3() call of course. But I'm not sure such an assertion is very useful at all - we will crash regardless if l3 == NULL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The new code is uploaded.

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