Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mpk: restore PKRU state when a fiber resumes execution (#7789)
* mpk: restore PKRU state when a fiber resumes execution Previously, when a fiber was suspended, other computation could change the PKRU state on the current CPU. This means that the fiber could be resumed with a different PKRU state. This could be bad, resulting in situations in which the fiber can access more memory slots than it should or cannot even access its own memory slots. This change saves the PKRU state prior to a fiber being suspended. When the fiber resumes execution, that PKRU state is restored. * mpk: check correct PKRU switching on async suspension This adds a test that alternately polls two Wasm instances in a loop. Since the instances are async, we can set up epochs to suspend each fiber as we iterate over a loop. Because we alternate between the two instances, it checks that `AsyncCx::block_on` has correctly restored the PKRU bits; otherwise we should see test failures. In the process of writing this test I discovered #7942, which can be solved separately (it has to do with the interaction between memory images, _not_ used here, and MPK). prtest:full * fix: condition the PKRU context switches Not all stores have protection keys and MPK is not always enabled. This change checks for these conditions before context-switching the PKRU bits.
- Loading branch information