1 /*
2 * Copyright (c) 2024 Meta Platforms
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
main(void)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 }
63