From e476900dc0aa06e6b1273ba8372cd4d207aeff20 Mon Sep 17 00:00:00 2001 From: Mohanson Date: Fri, 26 Jan 2024 13:59:58 +0800 Subject: [PATCH] Let lr be initialized when the machine is initialized (#394) * Let lr be initialized when the machine is initialized * Fixed arm64v8/rust to v1.71 * Fixed arm64v8/rust to v1.71-bookworm * Fix yaml syntax * Remove duplicate assignments * Add --platform linux/arm64 for docker run * Remove unused comments --- .github/workflows/develop.yml | 2 +- definitions/src/asm.rs | 13 ++----------- tests/programs/_build_all_native.sh | 1 + tests/programs/sc_only | Bin 0 -> 9120 bytes tests/programs/sc_only.S | 16 ++++++++++++++++ tests/programs/sc_only.lds | 7 +++++++ tests/test_a_extension.rs | 16 ++++++++++++++++ 7 files changed, 43 insertions(+), 12 deletions(-) create mode 100755 tests/programs/sc_only create mode 100644 tests/programs/sc_only.S create mode 100644 tests/programs/sc_only.lds diff --git a/.github/workflows/develop.yml b/.github/workflows/develop.yml index 48e73cd3..d417bff1 100644 --- a/.github/workflows/develop.yml +++ b/.github/workflows/develop.yml @@ -149,7 +149,7 @@ jobs: cd ckb-vm-test-suite cd binary && cargo build --release --target=aarch64-unknown-linux-gnu && cd .. cd .. - docker run --rm -v `pwd`:/code -t arm64v8/rust bash -c "RISCV=/dummy /code/ckb-vm-test-suite/test.sh --prebuilt-prefix aarch64-unknown-linux-gnu" + docker run --rm -v `pwd`:/code -t --platform linux/arm64 arm64v8/rust bash -c "RISCV=/dummy /code/ckb-vm-test-suite/test.sh --prebuilt-prefix aarch64-unknown-linux-gnu" macos-x86-ci-asm: runs-on: macos-latest diff --git a/definitions/src/asm.rs b/definitions/src/asm.rs index bc3285e2..f1b43525 100644 --- a/definitions/src/asm.rs +++ b/definitions/src/asm.rs @@ -132,23 +132,14 @@ impl AsmCoreMachine { assert_eq!(memory_size % (1 << MEMORY_FRAME_SHIFTS), 0); let mut machine = unsafe { let layout = Layout::new::(); - let raw_allocation = alloc(layout) as *mut AsmCoreMachine; + let raw_allocation = alloc_zeroed(layout) as *mut AsmCoreMachine; Box::from_raw(raw_allocation) }; - machine.registers = [0; RISCV_GENERAL_REGISTER_NUMBER]; - machine.pc = 0; - machine.next_pc = 0; - machine.running = 0; - machine.cycles = 0; machine.max_cycles = max_cycles; if cfg!(feature = "enable-chaos-mode-by-default") { machine.chaos_mode = 1; - } else { - machine.chaos_mode = 0; } - machine.chaos_seed = 0; - machine.reset_signal = 0; - machine.error_arg0 = 0; + machine.load_reservation_address = u64::MAX; machine.version = version; machine.isa = isa; diff --git a/tests/programs/_build_all_native.sh b/tests/programs/_build_all_native.sh index 5e9a532e..d43ac623 100755 --- a/tests/programs/_build_all_native.sh +++ b/tests/programs/_build_all_native.sh @@ -53,6 +53,7 @@ riscv64-unknown-elf-as -o rorw_in_end_of_aot_block.o rorw_in_end_of_aot_block.S sh rvc_pageend.sh # TODO: sbinvi_aot_load_imm_bug riscv64-unknown-elf-as -o sc_after_sc.o sc_after_sc.S && riscv64-unknown-elf-ld -T sc_after_sc.lds -o sc_after_sc sc_after_sc.o && rm sc_after_sc.o +riscv64-unknown-elf-as -o sc_only.o sc_only.S && riscv64-unknown-elf-ld -T sc_only.lds -o sc_only sc_only.o && rm sc_only.o # SKIP: simple riscv64-unknown-elf-gcc -o simple64 simple.c riscv64-unknown-elf-as -o sp_alignment_test.o sp_alignment_test.S && riscv64-unknown-elf-ld -o sp_alignment_test sp_alignment_test.o && rm sp_alignment_test.o diff --git a/tests/programs/sc_only b/tests/programs/sc_only new file mode 100755 index 0000000000000000000000000000000000000000..96e107c79609fc52bd6951d3100220760743df6b GIT binary patch literal 9120 zcmeI2y-EW?5P;{BT#VR6L=4y@AZT^OAflZXilBv!U?Cir%LNbebKI>Vrm?m673|F; z*w|V42tI-$);e>$dxlH22?&81xS846o&EVXRd#L;P7X7M0a`Nf0n{4C8emU#yjG-> zL$e1vkVQQQd9)BvtWcKyX?>Ck=#|Kt_zjD4fL>4A4V9-YsBx5+r@k^Nl%kqZ*@BFM zwmMIR*)Rbnzyz286JP>NfC(@GCcp%k025#WGeBTv8DPmYKOeTAO73kQeSo{diy7hG zm&{_~&%jZ5i%ftCFaajO1egF5U;<2l2`~XBzy$t{0KMIl>>r~F{mAWsv5&49_O`eD zTCi!iYeCg^$ZOVun%y8Z@ZBh+_`q*^9oNHw=(pQft<9iH)BPz~tS!**{G$W2kokGf zAL+kF_Nj&Q(=ug`LX2>tq% z@aQj*sbv*sAl7ls1zLS?x^5$>&rmDr-;-)W1s%#yZcx{2l;wz|PD3_Rv;o#-ZlJmo zqw7t6t1r<5X>GjqF*z^G(3|R^T9kSG^nOYzPO)U~Dn{mr4u*0eO`>VNQCY;sr2Ko8 LzdJe@{dE2}hWKbd literal 0 HcmV?d00001 diff --git a/tests/programs/sc_only.S b/tests/programs/sc_only.S new file mode 100644 index 00000000..3a638bfe --- /dev/null +++ b/tests/programs/sc_only.S @@ -0,0 +1,16 @@ +.global _start +_start: + la a0, n0 # a0 holds address of memory location n0 + sc.d a3, a2, (a0) + beqz a3, fail # sc.d must fail +done: + li a0, 0 + li a7, 93 + ecall +fail: + li a0, 1 + li a7, 93 + ecall +.section .data +n0: + .dword 4 # Initialize to 4 diff --git a/tests/programs/sc_only.lds b/tests/programs/sc_only.lds new file mode 100644 index 00000000..fdfa58fb --- /dev/null +++ b/tests/programs/sc_only.lds @@ -0,0 +1,7 @@ +SECTIONS +{ +. = 0x100b0; +.text : { *(.text) } +. = 0x11000; +.data : { *(.data) } +} diff --git a/tests/test_a_extension.rs b/tests/test_a_extension.rs index a4b9c01b..6c3c0a34 100644 --- a/tests/test_a_extension.rs +++ b/tests/test_a_extension.rs @@ -35,6 +35,22 @@ pub fn test_sc_after_sc() { } } +#[test] +pub fn test_sc_only() { + let mut machine = machine_build::int_v2_imacb("tests/programs/sc_only"); + let ret = machine.run(); + assert!(ret.is_ok()); + assert_eq!(ret.unwrap(), 0); + + #[cfg(has_asm)] + { + let mut machine_asm = machine_build::asm_v2_imacb("tests/programs/sc_only"); + let ret_asm = machine_asm.run(); + assert!(ret_asm.is_ok()); + assert_eq!(ret_asm.unwrap(), 0); + } +} + #[test] pub fn test_amo_compare() { let mut machine = machine_build::int_v2_imacb("tests/programs/amo_compare");