diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_no_spectre.clif new file mode 100644 index 0000000000..5493880b42 --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_no_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=false + +function %do_store(i64 vmctx, i32, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32 + +block0(v0: i64, v1: i32, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i32, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32 + fn0 = %do_store(i64, i32, i32) + +block0(v0: i64, v1: i32, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_yes_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_yes_spectre.clif new file mode 100644 index 0000000000..045eb6a2e8 --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_no_guards_yes_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=true + +function %do_store(i64 vmctx, i32, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32 + +block0(v0: i64, v1: i32, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i32, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i32 + fn0 = %do_store(i64, i32, i32) + +block0(v0: i64, v1: i32, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_yes_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_yes_guards_no_spectre.clif index 52081f1933..56abdc7fdc 100644 --- a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_yes_guards_no_spectre.clif +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i32_yes_guards_no_spectre.clif @@ -7,7 +7,7 @@ test interpret ;; target aarch64 ;; target riscv64 -set enable_heap_access_spectre_mitigation=true +set enable_heap_access_spectre_mitigation=false function %do_store(i64 vmctx, i32, i32) { gv0 = vmctx diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_no_spectre.clif new file mode 100644 index 0000000000..869aff68fa --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_no_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=false + +function %do_store(i64 vmctx, i64, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64 + +block0(v0: i64, v1: i64, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i64, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64 + fn0 = %do_store(i64, i64, i32) + +block0(v0: i64, v1: i64, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_yes_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_yes_spectre.clif new file mode 100644 index 0000000000..6be2b401f5 --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_no_guards_yes_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=true + +function %do_store(i64 vmctx, i64, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64 + +block0(v0: i64, v1: i64, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i64, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + gv2 = load.i64 notrap aligned gv0+8 + heap0 = dynamic gv1, min 0x1000, bound gv2, offset_guard 0, index_type i64 + fn0 = %do_store(i64, i64, i32) + +block0(v0: i64, v1: i64, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: dynamic, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_yes_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_yes_guards_no_spectre.clif index db20c1168f..743256fd90 100644 --- a/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_yes_guards_no_spectre.clif +++ b/cranelift/filetests/filetests/runtests/heap_load_store_dynamic_i64_yes_guards_no_spectre.clif @@ -7,7 +7,7 @@ test interpret ;; target aarch64 ;; target riscv64 -set enable_heap_access_spectre_mitigation=true +set enable_heap_access_spectre_mitigation=false function %do_store(i64 vmctx, i64, i32) { gv0 = vmctx diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_no_spectre.clif new file mode 100644 index 0000000000..24159a1689 --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_no_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=false + +function %do_store(i64 vmctx, i32, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32 + +block0(v0: i64, v1: i32, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i32, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32 + fn0 = %do_store(i64, i32, i32) + +block0(v0: i64, v1: i32, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_yes_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_yes_spectre.clif new file mode 100644 index 0000000000..b8d96a55ea --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_no_guards_yes_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=true + +function %do_store(i64 vmctx, i32, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32 + +block0(v0: i64, v1: i32, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i32, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i32 + fn0 = %do_store(i64, i32, i32) + +block0(v0: i64, v1: i32, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_yes_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_yes_guards_no_spectre.clif index 42bd0eb49c..b9664bfc2f 100644 --- a/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_yes_guards_no_spectre.clif +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i32_yes_guards_no_spectre.clif @@ -7,7 +7,7 @@ test interpret ;; target aarch64 ;; target riscv64 -set enable_heap_access_spectre_mitigation=true +set enable_heap_access_spectre_mitigation=false function %do_store(i64 vmctx, i32, i32) { gv0 = vmctx diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_no_spectre.clif new file mode 100644 index 0000000000..3273ebc54a --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_no_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=false + +function %do_store(i64 vmctx, i64, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64 + +block0(v0: i64, v1: i64, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i64, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64 + fn0 = %do_store(i64, i64, i32) + +block0(v0: i64, v1: i64, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_yes_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_yes_spectre.clif new file mode 100644 index 0000000000..f93488aa79 --- /dev/null +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_no_guards_yes_spectre.clif @@ -0,0 +1,40 @@ +;; !!! GENERATED BY 'make-heap-load-store-tests.sh' DO NOT EDIT !!! + +test interpret +;; test run +;; target x86_64 +;; target s390x +;; target aarch64 +;; target riscv64 + +set enable_heap_access_spectre_mitigation=true + +function %do_store(i64 vmctx, i64, i32) { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64 + +block0(v0: i64, v1: i64, v2: i32): + heap_store.i32 heap0 little v1+4, v2 + return +} + +function %test(i64 vmctx, i64, i32) -> i32 { + gv0 = vmctx + gv1 = load.i64 notrap aligned gv0+0 + + heap0 = static gv1, min 0x1000, bound 0x1000, offset_guard 0, index_type i64 + fn0 = %do_store(i64, i64, i32) + +block0(v0: i64, v1: i64, v2: i32): + call fn0(v0, v1, v2) + v3 = heap_load.i32 heap0 little v1+4 + return v3 +} +; heap: static, size=0x1000, ptr=vmctx+0, bound=vmctx+8 +; run: %test(0, 0) == 0 +; run: %test(0, -1) == -1 +; run: %test(16, 1) == 1 +; run: %test(16, -1) == -1 +; run: %test(2049, 0xaabb_ccdd) == 0xaabb_ccdd diff --git a/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_yes_guards_no_spectre.clif b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_yes_guards_no_spectre.clif index dcb08f9c9b..4890b48b97 100644 --- a/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_yes_guards_no_spectre.clif +++ b/cranelift/filetests/filetests/runtests/heap_load_store_static_i64_yes_guards_no_spectre.clif @@ -7,7 +7,7 @@ test interpret ;; target aarch64 ;; target riscv64 -set enable_heap_access_spectre_mitigation=true +set enable_heap_access_spectre_mitigation=false function %do_store(i64 vmctx, i64, i32) { gv0 = vmctx diff --git a/cranelift/filetests/filetests/runtests/make-heap-load-store-tests.sh b/cranelift/filetests/filetests/runtests/make-heap-load-store-tests.sh index 694ee30ae1..4326d71b30 100755 --- a/cranelift/filetests/filetests/runtests/make-heap-load-store-tests.sh +++ b/cranelift/filetests/filetests/runtests/make-heap-load-store-tests.sh @@ -16,12 +16,12 @@ function generate_one_test() { local spectre=$4 local enable_spectre=true - if [[ spectre == "no" ]]; then + if [[ $spectre == "no" ]]; then enable_spectre=false fi local have_guards=yes - if [[ guard == "0" ]]; then + if [[ $guard == "0" ]]; then have_guards=no fi @@ -79,10 +79,10 @@ block0(v0: i64, v1: ${index_type}, v2: i32): EOF } -for spectre in yes no; do - for guard in 0 0xffff_ffff; do - for index_type in i32 i64; do - for kind in static dynamic; do +for spectre in "yes" "no"; do + for guard in "0" "0xffff_ffff"; do + for index_type in "i32" "i64"; do + for kind in "static" "dynamic"; do generate_one_test $kind $index_type $guard $spectre done done