Skip to content
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

mpk: restore PKRU state when a fiber resumes execution #7789

Merged
merged 3 commits into from
Feb 15, 2024

Commits on Feb 15, 2024

  1. 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.
    abrown committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    48ed67f View commit details
    Browse the repository at this point in the history
  2. 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 bytecodealliance#7942, which can be solved separately
    (it has to do with the interaction between memory images, _not_ used
    here, and MPK).
    
    prtest:full
    abrown committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    2e3ce73 View commit details
    Browse the repository at this point in the history
  3. 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.
    abrown committed Feb 15, 2024
    Configuration menu
    Copy the full SHA
    1fc08a8 View commit details
    Browse the repository at this point in the history