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

Implement better vunmap() functionality; Enable NULL address (0 MFN) handling #312

Merged
merged 5 commits into from
Nov 14, 2023

Conversation

wipawel
Copy link
Contributor

@wipawel wipawel commented Nov 2, 2023

No description provided.

@wipawel wipawel added the improvement A small enhancement, that makes already implemented features better label Nov 2, 2023
@wipawel wipawel requested a review from minipli-oss November 2, 2023 10:35
@wipawel wipawel requested a review from a team as a code owner November 2, 2023 10:35
Copy link
Contributor

@minipli-oss minipli-oss left a comment

Choose a reason for hiding this comment

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

The semantical change regarding vmap*(), get_free_page*() is unfortunate, as now all callers need to take care of (and be audited to actually do so!) to test for MAP_FAILED before trying to access the returned pointer. :/

The NULL pointer test was much more intuitive.... Can't we special case where we want to really map address zero? Like, by passing yet another flag MAP_NULL.

Or, to make users more aware, change the return value to int to represent an error code only and return va as an output parameter?

mm/vmm.c Show resolved Hide resolved
arch/x86/pagetables.c Outdated Show resolved Hide resolved
common/usermode.c Show resolved Hide resolved
@wipawel
Copy link
Contributor Author

wipawel commented Nov 13, 2023

The semantical change regarding vmap*(), get_free_page*() is unfortunate, as now all callers need to take care of (and be audited to actually do so!) to test for MAP_FAILED before trying to access the returned pointer. :/

The NULL pointer test was much more intuitive.... Can't we special case where we want to really map address zero? Like, by passing yet another flag MAP_NULL.

Or, to make users more aware, change the return value to int to represent an error code only and return va as an output parameter?

Ok, I went with a shortcut and a middle ground. Since the mapping of NULL va is not used as of now and should be very rare, hopefully it would suffice.

Copy link
Contributor

@minipli-oss minipli-oss left a comment

Choose a reason for hiding this comment

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

_vmap()'s handling of va == NULL is still tricky for the callers, but I guess this version is still better than the first.

So with the little nit addresses, lgtm!

mm/vmm.c Show resolved Hide resolved
common/usermode.c Show resolved Hide resolved
Previous naive implementation was creating new pagetable entries when
no such mapping had been created.
It wasn't also taking into account the order of the mapping, assuming
all mappings were 4K.

Also, return unmapped MFN and page order to let the caller handle
corresponding frame.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
Copy link
Contributor

@minipli-oss minipli-oss left a comment

Choose a reason for hiding this comment

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

LGTM!

@wipawel wipawel merged commit 5376e73 into KernelTestFramework:mainline Nov 14, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement A small enhancement, that makes already implemented features better
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants