Compare commits
2 Commits
34e84f2926
...
debc62dfb8
| Author | SHA1 | Date | |
|---|---|---|---|
| debc62dfb8 | |||
| 3fd9a03aa6 |
@@ -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.
File diff suppressed because it is too large
Load Diff
1621
builds/RV64ACDFIMSUxCHERI_Toooba_bluesim/test1.txt
Normal file
1621
builds/RV64ACDFIMSUxCHERI_Toooba_bluesim/test1.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -918,7 +918,7 @@ module mkCore#(CoreId coreId)(Core);
|
||||
// incr cycle count
|
||||
(* fire_when_enabled, no_implicit_conditions *)
|
||||
rule incCycleCnt(doStats);
|
||||
$display("calling cycle");
|
||||
// $display("calling cycle");
|
||||
cycleCnt.incr(1);
|
||||
endrule
|
||||
|
||||
@@ -963,7 +963,6 @@ module mkCore#(CoreId coreId)(Core);
|
||||
// broadcast whether we should collect data
|
||||
rule broadcastDoStats;
|
||||
let stats = csrf.doPerfStats;
|
||||
$display("[stats] enabled %0d", csrf.doPerfStats);
|
||||
doStats <= stats;
|
||||
iMem.perf.setStatus(stats);
|
||||
dMem.perf.setStatus(stats);
|
||||
|
||||
@@ -653,8 +653,15 @@ module mkMemExePipeline#(MemExeInput inIfc)(MemExePipeline);
|
||||
`endif
|
||||
// Test delta value read from the pointer
|
||||
Bit#(25) delta = decodeDelta(x.vaddr);
|
||||
$display("Decoded delta = %0d", delta);
|
||||
x.vaddr = encodeDelta(x.vaddr, 0);
|
||||
$display("Decoded delta from register = %0d", delta);
|
||||
|
||||
// 33554431 is 2^25 - 1 (all ones)
|
||||
if (delta == 33554431) begin
|
||||
delta = 0;
|
||||
end else begin
|
||||
x.vaddr = encodeDelta(x.vaddr, 0);
|
||||
end
|
||||
// x.vaddr = encodeDelta(x.vaddr, 0);
|
||||
// x.vaddr = (x.vaddr >> 25) << 25;
|
||||
// x.vaddr = (x.vaddr >> 25) << 25;
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ function CapPipe capModify(CapPipe a, CapPipe b, CapModifyFunc func);
|
||||
// TODO: Delta handler function
|
||||
CapPipe res = (case(func) matches
|
||||
tagged ModifyOffset .offsetOp :
|
||||
//modifyOffset(a_mut, getAddr(b), offsetOp == IncOffset).value;
|
||||
// modifyOffset(a_mut, getAddr(b), offsetOp == IncOffset).value;
|
||||
// To test this
|
||||
encodeDelta(a_mut, getAddr(b));
|
||||
tagged SetBounds .boundsOp :
|
||||
|
||||
Reference in New Issue
Block a user