-
Notifications
You must be signed in to change notification settings - Fork 202
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
[LibOS] When memory pages or access permissions in VMA bookkeeping are not changed, get rid of unnecessary calls to PAL memory ABI or EDMM operations #1708
Comments
@llly Good observation and good idea, thanks. @kailun-qin implemented a new LibOS upcall I think this new upcall will be enough to avoid OCALLs/EDMM calls. PALs will call this upcall, learn the current VMA info, compare with the requested info, and if the same, just exit the func. @kailun-qin @mkow What do you think? Sounds like we have another usage candidate for @llly Would this upcall be enough for your purposes? |
I recall that we might also have another candidate: #1527 (comment). |
@dimakuv It's different. @kailun-qin It's similar, but focus on EDMM. I'd like LibOS VMA bookkeeping to handle address, flag and prot of LibOS memory. Currently it only handles address and passthrough flag and prot to PAL. |
@llly Hm, I may be missing something. Now that I look at your example:
Why can't the LibOS consult itself during |
Yes. That's what I means. I don't need an |
Thank you @llly, then I misunderstood your initial request. Yes, now it totally makes sense to me. |
Description of the feature
In current Gramine LibOS VMA bookkeeping, address begin, address end, prot, flags and file with offset are recorded.
However, when VMAs are created or changed successfully, only address is returned to caller. Then a corresponding PAL memory function is always called even pages of host already meet the expected status. In SGX PAL, extra Ocalls are called, When EDMM enabled, extra EDMM functions are called to set EPCM permissions.
My proposal is adding a flag to indicate what kind of page flags and permissions changes (change page flags, change file mapping, initialize permissions, restrict permissions, extend permissions, maybe more), returned by VMA bookkeeping functions and passed to PAL memory functions.
When all page flags and permissions are unchanged, LibOS doesn't call PAL memory function.
When pages flags and/or permissions are changed. LibOS call PAL memory function with this flag. PAL memory function can call mmap/mprotect/EMODPE/EMODPR accordingly.
It requires that LibOS VMA bookkeeping records exact same memory pages and access permissions as host PAL.
Need to identify and fix all violations, for example,
gramine/libos/src/bookkeep/libos_thread.c
Line 100 in 1f72aaf
only change permissions for PAL.
Why Gramine should implement it?
Performance improved. We've seen a workload that calls
mmap(RW)
to allocate some pages then callsmprotect(RW)
on each page.And for SGX EDMM. PTE permissions and the EPCM permissions can sync.
The text was updated successfully, but these errors were encountered: