mpk: maintain mapping of pkey ID to stripe ID #7353
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, we assumed that the Wasmtime engine would be able to
allocate keys 1-15 from the OS, in that order. (Recall that Linux
reserves key 0 for itself). While enabling various tests for MPK,
tests in
wasmtime_fuzzing::oracles
would fail because Wasmtime couldonly start allocating at key 2, e.g.; it turns out that the
diff_v8::smoke
test instantiates V8 which happens to allocate a keyfor itself.
The reason for the "allocate keys 1-15 in order" assumption was that the
logic for calculating the stripe each key owned was very simple:
key - 1
. We needed some way to map each key ID to the stripe ID it isassociated with.
With this change, we maintain a little bit more state in order to make
the mapping less brittle.
ProtectionKey
stores the "key ID to sliceID" mapping as an additional
u32
in the struct. This means that,regardless of what other code in the process allocates MPK keys,
Wasmtime should be able to work fine with the remaining keys it can
allocate.