base testing
This commit is contained in:
@@ -27,24 +27,84 @@ static inline void * __capability add_delta(void * __capability cap, int offset)
|
||||
return result;
|
||||
}
|
||||
|
||||
// void write_string_baremetal(void *__capability cap, const char* src) {
|
||||
// char *__capability ptr = (char *__capability)cap;
|
||||
|
||||
// while (*src != '\0') {
|
||||
// *ptr = *src; // This will FAULT if ptr goes outside cap's bounds
|
||||
// // ptr = add_delta(ptr, 1);
|
||||
// src++;
|
||||
// }
|
||||
// *ptr = '\0'; // Null terminate
|
||||
// }
|
||||
|
||||
// int main(void) {
|
||||
// void *__capability csp1;
|
||||
// void *__capability csp2;
|
||||
|
||||
// // Set address
|
||||
// // csp1 = (void *__capability)0x80001000;
|
||||
|
||||
// //void *csp1;
|
||||
|
||||
// // Set bounds
|
||||
// csp1 = cheri_bounds_set(csp1, 40);
|
||||
// // Increment offset
|
||||
// // csp = cheri_offset_increment(csp, 10);
|
||||
// csp1 = add_delta(csp1, 20);
|
||||
|
||||
// // csp2 = (void *__capability)0x80004000;
|
||||
|
||||
// // csp2 = cheri_bounds_set(csp2, 12);
|
||||
|
||||
// // csp2 = add_delta(csp2, 13);
|
||||
|
||||
// // uint64_t val = *(uint64_t * __capability)csp1;
|
||||
// // csp2 = 'A';
|
||||
|
||||
// //*char csp1 = 'A';
|
||||
// *(int * __capability)csp1 = 42;
|
||||
|
||||
|
||||
// // uint64_t val = *(uint64_t *__capability)csp1;
|
||||
// // test();
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int main(void) {
|
||||
void *__capability csp1;
|
||||
|
||||
// Start from a VALID capability
|
||||
void *__capability base = cheri_ddc_get();
|
||||
|
||||
// Set address
|
||||
csp1 = (void *__capability)0x80001000;
|
||||
// csp1 = cheri_address_set(base, 0x80001000);
|
||||
|
||||
// Set bounds
|
||||
csp1 = cheri_bounds_set(csp1, 1);
|
||||
// Increment offset
|
||||
// csp = cheri_offset_increment(csp, 10);
|
||||
// csp1 = add_delta(csp1, 10);
|
||||
// csp1 = cheri_bounds_set(csp1, 40);
|
||||
|
||||
// uint64_t val = *(uint64_t * __capability)csp1;
|
||||
// Add offset
|
||||
// csp1 = cheri_offset_increment(csp1, 20);
|
||||
|
||||
// ()csp1 = 12;
|
||||
// int j;
|
||||
// j = i;
|
||||
int a = 3;
|
||||
|
||||
char letters[] = {'A', 'B', 'C', 'D', 'E'};
|
||||
|
||||
csp1 = cheri_address_set(base, (uintptr_t)letters);
|
||||
|
||||
csp1 = __builtin_cheri_bounds_set(csp1, sizeof(letters));
|
||||
|
||||
*((char *__capability)csp1) = 'Z';
|
||||
|
||||
// csp1 = &letters;
|
||||
|
||||
// letters[1] = 'D';
|
||||
|
||||
|
||||
|
||||
// uint64_t val = *(uint64_t *__capability)csp1;
|
||||
test();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,8 +5,8 @@ _start:
|
||||
cspecialr c1, pcc
|
||||
|
||||
# Use csetaddr to build a stack capability
|
||||
# li t0, 0x80001000 # fixed top-of-stack address
|
||||
# csetaddr csp, ct0, t0
|
||||
li t0, 0x80001000 # fixed top-of-stack address
|
||||
csetaddr csp, ct0, t0
|
||||
|
||||
# bound it to 8 bytes (size of dword)
|
||||
# li t2, 8
|
||||
|
||||
@@ -1,13 +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/
|
||||
# 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 cheri.S'
|
||||
# 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'
|
||||
|
||||
@@ -16,7 +16,7 @@ _start:
|
||||
|
||||
# Read bounds
|
||||
# cgetbase t3, csp
|
||||
ld t0, 0(csp)
|
||||
cld t0, 0(csp)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
@@ -31,7 +31,7 @@ _start:
|
||||
|
||||
# Read bounds
|
||||
# cgetbase t3, csp
|
||||
ld t0, 0(ca1)
|
||||
cld t0, 0(ca1)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
@@ -46,7 +46,7 @@ _start:
|
||||
|
||||
# Read bounds
|
||||
# cgetbase t3, csp
|
||||
ld t0, 0(ca2)
|
||||
cld t0, 0(ca2)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
@@ -61,7 +61,7 @@ _start:
|
||||
|
||||
# Read bounds
|
||||
# cgetbase t3, csp
|
||||
ld t0, 0(ca3)
|
||||
cld t0, 0(ca3)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Use csetaddr to build a stack capability
|
||||
@@ -71,11 +71,11 @@ _start:
|
||||
# bound it to 8 bytes (size of dword)
|
||||
li t1, 8
|
||||
csetbounds ca4, ca4, t1
|
||||
cincoffsetimm ca4, ca4, 1
|
||||
# cincoffsetimm ca4, ca4, 6
|
||||
|
||||
# Read bounds
|
||||
# cgetbase t3, csp
|
||||
ld t0, 0(ca4)
|
||||
cld t0, 0(ca4)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
|
||||
BIN
Tests/isa/testC
BIN
Tests/isa/testC
Binary file not shown.
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
|
||||
|
||||
|
||||
@@ -658,6 +658,8 @@ module mkMemExePipeline#(MemExeInput inIfc)(MemExePipeline);
|
||||
// 33554431 is 2^25 - 1 (all ones)
|
||||
if (delta == 33554431) begin
|
||||
delta = 0;
|
||||
end else if (delta == 22369621) begin
|
||||
delta = 0;
|
||||
end else begin
|
||||
x.vaddr = encodeDelta(x.vaddr, 0);
|
||||
end
|
||||
|
||||
@@ -263,7 +263,6 @@ function Maybe#(MemInst) decodeExplicitBoundsMemInst(Instruction inst);
|
||||
endfunction
|
||||
|
||||
function CapChecks memCapChecks(Bool cap_mode);
|
||||
// TODO (Akilan): To extract offset for PPN
|
||||
CapChecks capChecks = unpack(0);
|
||||
capChecks.check_enable = True;
|
||||
capChecks.check_low_src = Vaddr;
|
||||
|
||||
Reference in New Issue
Block a user