further testing needed
This commit is contained in:
@@ -1,18 +1,50 @@
|
||||
#include <cheriintrin.h>
|
||||
#include <stdint.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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'
|
||||
|
||||
BIN
Tests/isa/testC
BIN
Tests/isa/testC
Binary file not shown.
Reference in New Issue
Block a user