-
Notifications
You must be signed in to change notification settings - Fork 1
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
gnt: Avoid double unmapping on domain cleanup #5
gnt: Avoid double unmapping on domain cleanup #5
Conversation
This resolves the issue I was seeing with PVH unikernels, confirmed in manual testing. |
caml_failwith ("Failed to unmap grant"); | ||
} | ||
xengnttab_handle* xgt = _G(xgh); | ||
void* start_address = _M(array)->addr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the code clearer without the alias that we create here for M(array)->addr
? So not declaring start_address
and using the pointer instead in all places? Because then the NULL-ing becomes more obvious.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_M
accesses an OCaml object, so we need some kind of alias anyway to only access C objects inside the critical section
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you're here, perhaps do a similar refactor of stub_gnttab_map_fresh
?
Oxenstored itself, when cleaning up domains and connections, can call Gnt.unmap transitively several times. Under certain conditions, this can later result in a segfault bringing oxenstored down when it tries to use a freed grant. Set the mmap_interface pointer to NULL after the first attempt so that it can be detected on the subsequent ones. Since we are already at it, bring out accesses to OCaml fields out of the critical section. Signed-off-by: Andrii Sultanov <[email protected]>
stub_gnttab_map_fresh Signed-off-by: Andrii Sultanov <[email protected]>
013ea17
to
24b70bc
Compare
Addressed the suggestions, retested - looks good. |
Oxenstored itself, when cleaning up domains and connections, can call Gnt.unmap transitively several times. Under certain conditions, this can later result in a segfault bringing oxenstored down when it tries to use a freed grant.
Set the mmap_interface pointer to NULL after the first attempt so that it can be detected on the subsequent ones.
Since we are already at it, bring out accesses to OCaml fields out of the critical section.