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

ISLE: upstream prototype ISLE verifier (Crocus) #9178

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

avanhatt
Copy link
Member

Draft PR to upstream the ongoing ISLE verification work, as described in our ASPLOS 2024 paper: Lightweight, Modular Verification for WebAssembly-to-Native Instruction Selection. The motivation for this work is described in detail in the paper.

Using the tool is described in detail at cranelift/isle/veri/README.md.

Alternatives considered

We could continue to develop this work in a fork, but that runs the risk of becoming quickly out-of-date. In discussions with @cfallin, @fitzgen, and @jameysharp, we have designed the specifications and verification to sit alongside the ISLE source.

However, we have also discussed delaying the upstreaming effort to instead upstream the newer version under development by @mmcloughlin. But, this version is much further from having the coverage of the original prototype.

@cfallin cfallin self-requested a review August 28, 2024 17:36
@alexcrichton
Copy link
Member

@avanhatt for the deny/vet CI errors I have two commits at https://github.com/alexcrichton/wasmtime/commits/verifier which should resolve the issues.

  • alexcrichton@9c54672 - this undoes what looks like a cargo update that may have been performed during development? If you need the updates though let me know and we can try to get that working. That fixes both cargo deny and cargo vet
  • alexcrichton@f8e5f3e - this flags the two new crates as publish = false to fix integration with the auto-publish workflow that we have. If you want these crates published though just let me know and I can help out with that too

No need to preserve authorship on those, feel free to include the commits here however's easiest to you!

alexcrichton and others added 4 commits September 7, 2024 20:32
Undoes a seeming `cargo update` that was performed previously and then
adds a vet for the new crate added.
This reverts commit df7b540.
@avanhatt
Copy link
Member Author

avanhatt commented Sep 8, 2024

@avanhatt for the deny/vet CI errors I have two commits at https://github.com/alexcrichton/wasmtime/commits/verifier which should resolve the issues.

@alexcrichton thanks so much for the help with these, passing all checks now!

@avanhatt avanhatt marked this pull request as ready for review September 8, 2024 17:11
@avanhatt avanhatt requested review from a team as code owners September 8, 2024 17:11
@avanhatt avanhatt changed the title (Draft) ISLE: upstream prototype ISLE verifier (Crocus) ISLE: upstream prototype ISLE verifier (Crocus) Sep 8, 2024
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.

This generally looks great -- thanks so much for the efforts (almost three years now?) to develop this and demonstrate its benefit with real-world verification results!

My comments are mostly around the integration points and diffs to existing ISLE compiler machinery, and that's also where I focused most of my energy here -- the core of the SMT lowering, type inference and related analysis was reviewed at a "looks plausible" level, as I've not been as deep into the code as you all have been. Nevertheless, that part is "self-checking" to some degree, and also not in Cranelift's critical path, so I'm not as worried about doing a fine-tooth-comb pass.

@@ -0,0 +1,287 @@
# Crocus: An SMT-based ISLE verification tool

This directory contains Crocus, a tool for verifying instruction lowering and transformation rules written in ISLE. Crocus uses an underlying SMT solver to model ISLE rules in as logical bitvectors; searching over all possible inputs to find potential soundness counterexamples.
Copy link
Member

Choose a reason for hiding this comment

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

We can cite the paper here too for folks who are curious about more details and how this has been applied, I suppose?

@@ -0,0 +1,3 @@
fn main() {
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/hope we can delete this stub binary -- we don't need cranelift/isle/veri to be a crate, just a directory that contains other crates, right?

Encodings Generation
====================

This directory contains some templatized SMT-LIBv2 code that encodes some operations we need in the verifier.
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any SMT-LIB code in this directory -- are there examples of input to convert.py? Or if no longer used, could we remove?

name = "veri_engine"
version = "0.1.0"
edition = "2021"
publish = false
Copy link
Member

Choose a reason for hiding this comment

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

we'll want at least a license key here (hopefully same as the rest of Cranelift, "Apache-2.0 WITH LLVM-exception"), and feel free to add authors as well if you'd like.

cranelift/isle/veri/veri_engine/Cargo.toml Show resolved Hide resolved
}
generate_isle(gen_dir.as_path()).expect("Can't generate ISLE");

let codegen_crate_dir = cur_dir.join("../../../codegen");
Copy link
Member

Choose a reason for hiding this comment

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

Rather than relying on the current directory to be a certain place in the tree, can we take an argument that points to the codegen crate, or the Wasmtime repo root, or something of the sort? Generally I find "must be run from this directory"-style tools to be brittle and a little annoying as the requirement isn't self-documenting, and doesn't interact well with various sorts of more complex build systems stuff or containerization or ... etc.

// Adapted from https://stackoverflow.com/questions/23856596/how-to-count-leading-zeros-in-a-32-bit-unsigned-integer

pub fn cls64(solver: &mut SolverCtx, x: SExpr, id: u32) -> SExpr {
// Generated code.
Copy link
Member

Choose a reason for hiding this comment

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

perfectly fine to upstream this for now, but idle question: are there any thoughts or potential plans to have a "prelude" in native SMT-LIB that we feed to the solver, or some other way to avoid having to open-code these inlined algorithms?

name = "veri_ir"
version = "0.1.0"
edition = "2021"
publish = false
Copy link
Member

Choose a reason for hiding this comment

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

likewise here re: license and authors keys

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. isle Related to the ISLE domain-specific language labels Sep 10, 2024
Copy link

Subscribe to Label Action

cc @cfallin, @fitzgen

This issue or pull request has been labeled: "cranelift", "cranelift:area:aarch64", "cranelift:area:x64", "cranelift:meta", "isle"

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

  • cfallin: isle
  • fitzgen: isle

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

Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift:area:aarch64 Issues related to AArch64 backend. cranelift:area:x64 Issues related to x64 codegen cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator isle Related to the ISLE domain-specific language
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants