From debc62dfb8fc05f4ad98dd349d553e58c8d38c57 Mon Sep 17 00:00:00 2001 From: Akilan Date: Thu, 19 Mar 2026 16:37:49 +0000 Subject: [PATCH] further testing needed --- Tests/isa/CPrograms/main.c | 42 ++++++++++++++++++++++++++++++----- Tests/isa/CPrograms/start.S | 3 ++- Tests/isa/build-assembler.sh | 10 +++++---- Tests/isa/testC | Bin 5048 -> 4808 bytes 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Tests/isa/CPrograms/main.c b/Tests/isa/CPrograms/main.c index 57bbe57..855296e 100644 --- a/Tests/isa/CPrograms/main.c +++ b/Tests/isa/CPrograms/main.c @@ -1,18 +1,50 @@ #include #include -int main(void) { - void *__capability csp; +void test() { + + void *__capability c1; // Set address - csp = (void *__capability)0x80001000; + c1 = (void *__capability)0x80001009; + + c1 = cheri_bounds_set(c1, 8); + +} + +// Add delta value for TLB translation +static inline void * __capability add_delta(void * __capability cap, int offset) { + void * __capability result; + + asm volatile ( + "cincoffset %0, %1, %2" + : "=C" (result) // Output: %0 (result) + : "C" (cap), // Input: %1 (original cap) + "r" (offset) // Input: %2 (offset register) + : // No clobbered registers + ); + + return result; +} + +int main(void) { + void *__capability csp1; + + // Set address + csp1 = (void *__capability)0x80001000; // Set bounds - csp = cheri_bounds_set(csp, 8); + csp1 = cheri_bounds_set(csp1, 1); // Increment offset // csp = cheri_offset_increment(csp, 10); + csp1 = add_delta(csp1, 10); - uint64_t val = *(uint64_t *__capability)csp; + // uint64_t val = *(uint64_t * __capability)csp1; + + + + // uint64_t val = *(uint64_t *__capability)csp1; + test(); return 0; } \ No newline at end of file diff --git a/Tests/isa/CPrograms/start.S b/Tests/isa/CPrograms/start.S index 4fd3e87..8e326a8 100644 --- a/Tests/isa/CPrograms/start.S +++ b/Tests/isa/CPrograms/start.S @@ -12,7 +12,7 @@ _start: # li t2, 8 # csetbounds csp, csp, t2 # li t5, 4 - # cincoffsetimm csp, csp, 10 + # cincoffsetimm csp, csp, 5 # Read bounds # cgetbase t3, csp @@ -25,6 +25,7 @@ _start: csetaddr csp, ca0, t0 # Set address li t1, -2048 # 2KB size csetbounds csp, csp, t1 # Restrict bounds so main can't wander + cincoffsetimm csp, csp, 12 # Call main # sw ra, 12(sp) diff --git a/Tests/isa/build-assembler.sh b/Tests/isa/build-assembler.sh index e671298..cd3890f 100644 --- a/Tests/isa/build-assembler.sh +++ b/Tests/isa/build-assembler.sh @@ -1,11 +1,13 @@ # Send assembler file to remote machine to run -scp Cprograms/start.S home:/home/akilan/cheri/output/sdk/bin/ -scp Cprograms/main.c home:/home/akilan/cheri/output/sdk/bin/ +# scp Cprograms/start.S home:/home/akilan/cheri/output/sdk/bin/ +# scp Cprograms/main.c home:/home/akilan/cheri/output/sdk/bin/ + +scp cheri.S home:/home/akilan/cheri/output/sdk/bin/ # Run compiled instruction remotely -# ssh home 'cd /home/akilan/cheri/output/sdk/bin/ && ./clang --target=riscv64-unknown-elf -march=rv64gcxcheri -mabi=l64pc128 -nostdlib -nostartfiles -Wl,-Ttext=0x80000000 -o testC start.S main.c' +ssh home 'cd /home/akilan/cheri/output/sdk/bin/ && ./clang --target=riscv64-unknown-elf -march=rv64gcxcheri -mabi=l64pc128 -nostdlib -nostartfiles -Wl,-Ttext=0x80000000 -o testC cheri.S' -ssh home 'cd /home/akilan/cheri/output/sdk/bin/ && ./clang --target=riscv64-unknown-elf -march=rv64gcxcheri -mabi=lp64d -nostdlib -nostartfiles -Wl,-Ttext=0x80000000 -o testC start.S main.c' +# ssh home 'cd /home/akilan/cheri/output/sdk/bin/ && ./clang --target=riscv64-unknown-elf -march=rv64gcxcheri -mabi=lp64d -nostdlib -nostartfiles -Wl,-Ttext=0x80000000 -o testC start.S main.c' # Disassembly ouput ssh home 'cd /home/akilan/cheri/output/sdk/bin/ && ./llvm-objdump -d testC' diff --git a/Tests/isa/testC b/Tests/isa/testC index 2a216ab2e4ab80a37539890baf8192988e03836d..3b0d5b613cdab87e84101aab7c39abee047965de 100755 GIT binary patch delta 270 zcmdm?enNGE1~-Qw0~jzeFi$j|%c%z8F{n+v>CdDlF!7@pXAo2&^em1P#{`xAwx8u;=iUOR%hi62@H;bK%GUI#mQw1jP5|@ zx~s<1Za0jP`(*nk{i N70y3U5e}%4JOI60Hthfa delta 507 zcmX@1x}sKBX2F|nz^F&JoQ zQD$*+83UsykjWyzT2waKQoz2RAvq^8FI}N5wWv5VKTpBXT+cwyKtUs;q@ zf(ndTlQRX)IkN;HhJ;LBDQM2U56Wu+Mp>=&WHuowQ4eS=CO|D?1JX>BO@*|XRtQc` P60+lb0#zUaG(jE!sKtBv