Skip to content

[CHERIoT] ELF/Writer: import entry permissions #180

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

Open
wants to merge 2 commits into
base: cheriot
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3192,17 +3192,26 @@ class CompartmentReportWriter {
static constexpr uint32_t ImportPermitsLoadStoreCapabilities =
(1UL << 29);
static constexpr uint32_t ImportPermitsLoadMutable = (1UL << 28);
static constexpr uint32_t ImportPermitsLoadGlobal = (1UL << 27);

imports.push_back(json::Object{
{"kind", "MMIO"},
{"start", entry.start},
{"length", entry.length & 0xfffffff},
/*
* Length and permissions are bit-stuffed into the same 32-bit
* word, with the top 8 bits reserved for permission flags and
* the bottom 24 for length. See CHERIoT-RTOS's
* sdk/core/loader/types.h ReservedPermissionsMask
*/
{"length", entry.length & 0x00ffffff},
{"permits_load", (entry.length & ImportPermitsLoad) != 0},
{"permits_store", (entry.length & ImportPermitsStore) != 0},
{"permits_load_store_capabilities",
(entry.length & ImportPermitsLoadStoreCapabilities) != 0},
{"permits_load_mutable",
(entry.length & ImportPermitsLoadMutable) != 0}});
(entry.length & ImportPermitsLoadMutable) != 0},
{"permits_load_global",
(entry.length & ImportPermitsLoadGlobal) != 0}});
}
continue;
}
Expand Down