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

Let lr be initialized when the machine is initialized #394

Merged
merged 7 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ jobs:
RISCV=`pwd`/../riscv ./test.sh --build-only
cd ..
- name: Run test suite
# It is also possible to use arm64v8/rust@sha256:cd7c932094e80f2f2471af1c2c8dba4e87221bc55318ee846d003f2f4e26970a
mohanson marked this conversation as resolved.
Show resolved Hide resolved
run: |
sudo apt install -y qemu binfmt-support qemu-user-static
sudo apt install -y gcc-multilib
Expand All @@ -149,7 +150,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 arm64v8/rust:1.71.1-bookworm bash -c "RISCV=/dummy /code/ckb-vm-test-suite/test.sh --prebuilt-prefix aarch64-unknown-linux-gnu"
mohanson marked this conversation as resolved.
Show resolved Hide resolved

macos-x86-ci-asm:
runs-on: macos-latest
Expand Down
3 changes: 2 additions & 1 deletion definitions/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl AsmCoreMachine {
assert_eq!(memory_size % (1 << MEMORY_FRAME_SHIFTS), 0);
let mut machine = unsafe {
let layout = Layout::new::<AsmCoreMachine>();
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];
Expand All @@ -147,6 +147,7 @@ impl AsmCoreMachine {
machine.chaos_mode = 0;
}
machine.chaos_seed = 0;
mohanson marked this conversation as resolved.
Show resolved Hide resolved
machine.load_reservation_address = u64::MAX;
machine.reset_signal = 0;
machine.error_arg0 = 0;
machine.version = version;
Expand Down
1 change: 1 addition & 0 deletions tests/programs/_build_all_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added tests/programs/sc_only
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/programs/sc_only.S
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions tests/programs/sc_only.lds
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SECTIONS
{
. = 0x100b0;
.text : { *(.text) }
. = 0x11000;
.data : { *(.data) }
}
16 changes: 16 additions & 0 deletions tests/test_a_extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down