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

pulley: Ungate memory64 feature #9780

Merged

Conversation

alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Dec 10, 2024

This commit is similar to #9779 in that it's removing a proposal from
the "known list of panicking features" for Pulley to allow more tests to
run on Pulley. This then fills out a few miscellaneous instructions to
get a full suite of tests passing in Pulley related to memory64 and
other instructions.

cc #9783

@alexcrichton alexcrichton requested review from a team as code owners December 10, 2024 19:53
@alexcrichton alexcrichton requested review from cfallin and fitzgen and removed request for a team December 10, 2024 19:53
@alexcrichton
Copy link
Member Author

alexcrichton commented Dec 10, 2024

note this is currently stacked on #9779

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator pulley Issues related to the Pulley interpreter wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime labels Dec 10, 2024
Copy link

Subscribe to Label Action

cc @fitzgen

This issue or pull request has been labeled: "cranelift", "pulley", "wasmtime:api", "wasmtime:config"

Thus the following users have been cc'd because of the following labels:

  • fitzgen: pulley

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

Copy link

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

  • If you added a new Config method, you wrote extensive documentation for
    it.

    Our documentation should be of the following form:

    Short, simple summary sentence.
    
    More details. These details can be multiple paragraphs. There should be
    information about not just the method, but its parameters and results as
    well.
    
    Is this method fallible? If so, when can it return an error?
    
    Can this method panic? If so, when does it panic?
    
    # Example
    
    Optional example here.
    
  • If you added a new Config method, or modified an existing one, you
    ensured that this configuration is exercised by the fuzz targets.

    For example, if you expose a new strategy for allocating the next instance
    slot inside the pooling allocator, you should ensure that at least one of our
    fuzz targets exercises that new strategy.

    Often, all that is required of you is to ensure that there is a knob for this
    configuration option in wasmtime_fuzzing::Config (or one
    of its nested structs).

    Rarely, this may require authoring a new fuzz target to specifically test this
    configuration. See our docs on fuzzing for more details.

  • If you are enabling a configuration option by default, make sure that it
    has been fuzzed for at least two weeks before turning it on by default.


To modify this label's message, edit the .github/label-messager/wasmtime-config.md file.

To add new label messages or remove existing label messages, edit the
.github/label-messager.json configuration file.

Learn more.

Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last commit LGTM, with note about Spectre below (happy to discuss further re: how much of an issue and/or how or if to document this).

let high_bits = pos.ins().ushr(index, c32);
let high_bits = pos.ins().ireduce(pointer_ty, high_bits);
pos.ins()
.trapnz(high_bits, ir::TrapCode::HEAP_OUT_OF_BOUNDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should make a note re: Spectre here -- trapnz internally uses a branch and so one might expect there to be some exposure here. I think we're actually safe because the worst that happens is that the guest accesses an OOB address like 0x1_0000_1000 where 0x1000 is in-bounds, and gets its own in-bounds data; in other words, this check is layered on top of the actual bounds-check on the lower 32 bits, so there is still not any visibility outside the sandbox in the misspeculated path. But it's... worth noting, if only because the guest might in turn rely on OOBs not to speculatively read valid data (niche but possible).

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo @cfallin's comment

Comment on lines -293 to -307
// Sanity-check what should already be true from wasm module validation.
// Note that for 32-bit targets the absolute maximum is `1<<32` during
// compilation, not one-page-less-than-u32::MAX, so need to handle that
// specially here.
let absolute_max64 = if cfg!(target_pointer_width = "32") {
1 << 32
} else {
u64::try_from(absolute_max).unwrap()
};
if let Ok(size) = ty.minimum_byte_size() {
assert!(size <= absolute_max64);
}
if let Ok(max) = ty.maximum_byte_size() {
assert!(max <= absolute_max64);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these asserts removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were basically a pain to maintain on 32-bit because I already had to modify the minimum check to use 1<<32 rather than absolute_max (due to absolute_max being a usize and not being able to represent 1<<32) and then this PR uncovered an assertion in the next one where a 64-bit linear memory's maximum size far exceeds 1<<32 as well. Given that these are just debug asserts that are already basically checked in many other places it seemed best to just remove them instead of trying to contort ourselves to keep them in all portable conditions.

This commit is similar to bytecodealliance#9779 in that it's removing a proposal from
the "known list of panicking features" for Pulley to allow more tests to
run on Pulley. This then fills out a few miscellaneous instructions to
get a full suite of tests passing in Pulley related to memory64 and
other instructions.

prtest:full
@alexcrichton alexcrichton force-pushed the pulley-ungate-memory64 branch from 47a9046 to 3d22b3d Compare December 11, 2024 15:25
@alexcrichton alexcrichton added this pull request to the merge queue Dec 11, 2024
Merged via the queue into bytecodealliance:main with commit bb68f41 Dec 11, 2024
132 checks passed
@alexcrichton alexcrichton deleted the pulley-ungate-memory64 branch December 11, 2024 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator pulley Issues related to the Pulley interpreter wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:config Issues related to the configuration of Wasmtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants