Skip to content

Commit 4da4ee8

Browse files
ycsinaescolar
authored andcommitted
tests: arch: riscv: test csf registers value
Test if callee-saved-registers values are as expected. Signed-off-by: David Reiss <[email protected]> Signed-off-by: Yong Cong Sin <[email protected]>
1 parent 4bbc2a7 commit 4da4ee8

File tree

4 files changed

+99
-0
lines changed

4 files changed

+99
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
5+
project(riscv_fatal)
6+
7+
FILE(GLOB app_sources src/*.c)
8+
target_sources(app PRIVATE ${app_sources})

tests/arch/riscv/fatal/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST=y
2+
CONFIG_LOG=y

tests/arch/riscv/fatal/src/main.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2024 Meta Platforms
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
int main(void)
8+
{
9+
__asm__(
10+
/**
11+
* Load up a bunch of known values into registers
12+
* and expect them to show up in the core dump.
13+
* Value is register ABI name kinda spelled out,
14+
* followed by zeros to pad to 32 bits,
15+
* followed by FF00, followed by hex number of the register,
16+
* follwed by the "hex-coded-decismal" number of the register.
17+
*/
18+
19+
/* "RA" -> "DA". Kind of a stretch, but okay. */
20+
"li x1, 0xDADA0000FF000101\n\t"
21+
22+
/* Skip stack pointer because it can mess stuff up. */
23+
/* "li x2, 0\n\t" */
24+
25+
/* T0 -> D0. Kinda close in pronunciation. */
26+
"li x5, 0xD0FF0000FF000505\n\t"
27+
"li x6, 0xD1FF0000FF000606\n\t"
28+
"li x7, 0xD2FF0000FF000707\n\t"
29+
/* S0 -> C0. Kinda close in pronunciation. */
30+
"li x8, 0xC0FF0000FF000808\n\t"
31+
"li x9, 0xC1FF0000FF000909\n\t"
32+
/* A0 -> A0. Actual match! */
33+
"li x10, 0xA0FF0000FF000A10\n\t"
34+
"li x11, 0xA1FF0000FF000B11\n\t"
35+
"li x12, 0xA2FF0000FF000C12\n\t"
36+
"li x13, 0xA3FF0000FF000D13\n\t"
37+
"li x14, 0xA4FF0000FF000E14\n\t"
38+
"li x15, 0xA5FF0000FF000F15\n\t"
39+
"li x16, 0xA6FF0000FF001016\n\t"
40+
"li x17, 0xA7FF0000FF001117\n\t"
41+
"li x18, 0xC2FF0000FF001218\n\t"
42+
"li x19, 0xC3FF0000FF001319\n\t"
43+
"li x20, 0xC4FF0000FF001420\n\t"
44+
"li x21, 0xC5FF0000FF001521\n\t"
45+
"li x22, 0xC6FF0000FF001622\n\t"
46+
"li x23, 0xC7FF0000FF001723\n\t"
47+
"li x24, 0xC8FF0000FF001824\n\t"
48+
"li x25, 0xC9FF0000FF001925\n\t"
49+
"li x26, 0xC10FF000FF001A26\n\t"
50+
"li x27, 0xC11FF000FF001B27\n\t"
51+
"li x28, 0xD3FF0000FF001C28\n\t"
52+
"li x29, 0xD4FF0000FF001D29\n\t"
53+
"li x30, 0xD5FF0000FF001E30\n\t"
54+
"li x31, 0xD6FF0000FF001F31\n\t"
55+
/* K_ERR_KERNEL_PANIC */
56+
"li a0, 4\n\t"
57+
/* RV_ECALL_RUNTIME_EXCEPT */
58+
"li t0, 0\n\t"
59+
"ecall\n");
60+
61+
return 0;
62+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
common:
2+
ignore_faults: true
3+
harness: console
4+
ignore_qemu_crash: true
5+
tags: kernel riscv
6+
platform_allow:
7+
- qemu_riscv64
8+
tests:
9+
arch.riscv64.fatal:
10+
harness_config:
11+
type: multi_line
12+
regex:
13+
- "E: a0: 0000000000000004 t0: 0000000000000000"
14+
- "E: a1: a1ff0000ff000b11 t1: d1ff0000ff000606"
15+
- "E: a2: a2ff0000ff000c12 t2: d2ff0000ff000707"
16+
- "E: a3: a3ff0000ff000d13 t3: d3ff0000ff001c28"
17+
- "E: a4: a4ff0000ff000e14 t4: d4ff0000ff001d29"
18+
- "E: a5: a5ff0000ff000f15 t5: d5ff0000ff001e30"
19+
- "E: a6: a6ff0000ff001016 t6: d6ff0000ff001f31"
20+
- "E: a7: a7ff0000ff001117"
21+
- "E: ra: dada0000ff000101"
22+
- "E: s0: c0ff0000ff000808 s6: c6ff0000ff001622"
23+
- "E: s1: c1ff0000ff000909 s7: c7ff0000ff001723"
24+
- "E: s2: c2ff0000ff001218 s8: c8ff0000ff001824"
25+
- "E: s3: c3ff0000ff001319 s9: c9ff0000ff001925"
26+
- "E: s4: c4ff0000ff001420 s10: c10ff000ff001a26"
27+
- "E: s5: c5ff0000ff001521 s11: c11ff000ff001b27"

0 commit comments

Comments
 (0)