joeywang4 / Flexo

A compiler for microarchitectural weird machines

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flexo

A compiler for microarchitectural weird machines.

For more details, please refer to our paper:

Ping-Lun Wang, Riccardo Paccagnella, Riad S. Wahby, Fraser Brown. "Bending microarchitectural weird machines towards practicality." USENIX Security, 2024.

Supported machines

The following list is the AWS EC2 instances that we used to run the weird machines generated by Flexo.

Microarchitecture Instance type Processor
Zen 1 t3a.xlarge AMD EPYC 7571
Zen 2 c5a.xlarge AMD EPYC 7R32
Zen 3 c6a.xlarge AMD EPYC 7R13
Zen 4 m7a.xlarge AMD EPYC 9R14
Skylake c5n.xlarge Intel Xeon 8124M
Cascade Lake m5n.xlarge Intel Xeon 8259CL
Icelake m6in.xlarge Intel Xeon 8375C
Sapphire Rapids m7i.xlarge Intel Xeon 8488C

Warning

When using a processor not included in this list, the weird machines may fail to generate correct results. While a processor with similar microarchitecture may be able to run our weird machines, we cannot guarantee the accuracy and performance when using other processors.

Reproduce our results

Follow the instructions in the README file under reproduce/ to run the experiments in our paper.

Install with Docker

docker build -t flexo .
docker run -i -t --rm \
  --mount type=bind,source="$(pwd)"/,target=/flexo \
  flexo \
  bash -c "cd /flexo && ./build.sh"

Compile a circuit

To compile a circuit, you need to first compile the circuits (a C/C++ program) into LLVM IR.

clang-17 -fno-discard-value-names -fno-inline-functions -O1 -S -emit-llvm [INPUT_CIRCUIT_SOURCE] -o [INPUT_LLVM_IR_FILE]

After that, run compile.sh to execute the Flexo compiler and compile the circuits into weird machines. The output will be another LLVM IR file.

docker run -i -t --rm \
  --mount type=bind,source="$(pwd)"/,target=/flexo \
  flexo \
  bash -c "cd /flexo && ./compile.sh [INPUT_LLVM_IR_FILE] [OUTPUT_LLVM_IR_FILE]"

Finally, you can generate an executable file using the output LLVM IR file:

clang-17 [OUTPUT_LLVM_IR_FILE] -o [OUTPUT_EXECUTABLE_FILE] -lm -lstdc++

About

A compiler for microarchitectural weird machines

License:MIT License


Languages

Language:Assembly 85.7%Language:C++ 10.6%Language:C 2.4%Language:Makefile 0.4%Language:Python 0.4%Language:Shell 0.3%Language:CMake 0.1%Language:Dockerfile 0.0%Language:Verilog 0.0%