compiler/
kernel/
lib/
scripts/
seed/
sublime/
test/
acceptance/
boot/
bootstrap/
cycles/
dispatch/
loader/
mmio/
native/
packages/
pages/
runtime/
scheduling/
shared/
slots/
smp/
support/
sync/
termination/
tests/
trap/
machine.ras
6.2 KiB
reservations.ras
2.0 KiB
run
633 B
package-golden
1.6 KiB
run
3.1 KiB
runner.rad
10.5 KiB
vim/
.gitignore
336 B
.gitsigners
112 B
CONTRIBUTING
2.1 KiB
LICENSE
1.1 KiB
Makefile
9.2 KiB
README
2.5 KiB
STYLE
2.5 KiB
std.lib
1.5 KiB
std.lib.test
662 B
test/trap/reservations.ras
raw
| 1 | //! Reservation isolation at trap entry, frame resume, and user context switches. |
| 2 | .text; |
| 3 | li %s0 0x40010000; |
| 4 | slli %s0 %s0 1; |
| 5 | sd %sp 0(%s0); |
| 6 | li %t0 4096; |
| 7 | sub %t0 %sp %t0; |
| 8 | sd %t0 8(%s0); |
| 9 | sd %zero 16(%s0); |
| 10 | la %t0 @handler; |
| 11 | sd %t0 24(%s0); |
| 12 | mv %a0 %s0; |
| 13 | call @kernel::trap::install; |
| 14 | addi %s1 %s0 80; |
| 15 | |
| 16 | // Enter the vector with a live reservation and the machine trap CSR state. |
| 17 | la %t0 @resumed; |
| 18 | csrw mepc %t0; |
| 19 | li %t0 11; |
| 20 | csrw mcause %t0; |
| 21 | li %t0 0x1800; |
| 22 | csrw mstatus %t0; |
| 23 | lr.d %t0 (%s1); |
| 24 | j @kernel::trap::vector; |
| 25 | @resumed |
| 26 | sc.d %t0 %zero (%s1); |
| 27 | beqz %t0 @fail; |
| 28 | ld %t0 0(%s1); |
| 29 | bnez %t0 @fail; |
| 30 | li %t0 2; |
| 31 | sd %t0 88(%s0); |
| 32 | la %t0 @first; |
| 33 | csrw mepc %t0; |
| 34 | csrw mstatus %zero; |
| 35 | mret; |
| 36 | |
| 37 | // The first user context retains its loaded value across a peer's execution. |
| 38 | @first |
| 39 | lr.d %a2 (%s1); |
| 40 | ecall; |
| 41 | @firstResume |
| 42 | sc.d %a3 %a2 (%s1); |
| 43 | beqz %a3 @fail; |
| 44 | ld %t0 0(%s1); |
| 45 | li %t1 1; |
| 46 | bne %t0 %t1 @fail; |
| 47 | ecall; |
| 48 | j @fail; |
| 49 | |
| 50 | // The peer changes shared memory and reserves the same location before exit. |
| 51 | @peer |
| 52 | li %t0 1; |
| 53 | sd %t0 0(%s1); |
| 54 | lr.d %t0 (%s1); |
| 55 | ecall; |
| 56 | j @fail; |
| 57 | |
| 58 | // Inject a live return reservation after trap entry has completed. |
| 59 | @handler |
| 60 | ld %t0 88(%s0); |
| 61 | beqz %t0 @entryCheck; |
| 62 | ld %t1 272(%a0); |
| 63 | li %t2 8; |
| 64 | bne %t1 %t2 @fail; |
| 65 | li %t1 2; |
| 66 | beq %t0 %t1 @switchPeer; |
| 67 | li %t1 3; |
| 68 | beq %t0 %t1 @switchFirst; |
| 69 | li %t1 4; |
| 70 | bne %t0 %t1 @fail; |
| 71 | j @success; |
| 72 | @entryCheck |
| 73 | sc.d %t0 %zero (%s1); |
| 74 | beqz %t0 @fail; |
| 75 | li %t0 1; |
| 76 | sd %t0 88(%s0); |
| 77 | lr.d %t0 (%s1); |
| 78 | ret; |
| 79 | @switchPeer |
| 80 | li %t0 3; |
| 81 | sd %t0 88(%s0); |
| 82 | la %t0 @peer; |
| 83 | sd %t0 256(%a0); |
| 84 | ret; |
| 85 | @switchFirst |
| 86 | li %t0 4; |
| 87 | sd %t0 88(%s0); |
| 88 | la %t0 @firstResume; |
| 89 | sd %t0 256(%a0); |
| 90 | lr.d %t0 (%s1); |
| 91 | ret; |
| 92 | @success |
| 93 | li %t0 0x10001000; |
| 94 | li %t1 0x5555; |
| 95 | sw %t1 0(%t0); |
| 96 | @fail |
| 97 | li %t0 0x10001000; |
| 98 | li %t1 0x13333; |
| 99 | sw %t1 0(%t0); |
| 100 | ebreak; |