Debian Codegraph @

third_party/rust/crash-context/src/linux/getcontext/aarch64.rs

raw
1 // GREGS_OFFSET = 184
2 // REGISTER_SIZE = 8
3 // SIMD_REGISTER_SIZE = 16
4
5 std::arch::global_asm! {
6 ".text",
7 ".global crash_context_getcontext",
8 ".hidden crash_context_getcontext",
9 ".type crash_context_getcontext, #function",
10 ".align 4",
11 ".cfi_startproc",
12 "crash_context_getcontext:",
13
14 // The saved context will return to the getcontext() call point
15 // with a return value of 0
16 "str xzr, [x0, 184]", // GREGS_OFFSET
17
18 "stp x18, x19, [x0, 328]", // GREGS_OFFSET + 18 * REGISTER_SIZE
19 "stp x20, x21, [x0, 344]", // GREGS_OFFSET + 20 * REGISTER_SIZE
20 "stp x22, x23, [x0, 360]", // GREGS_OFFSET + 22 * REGISTER_SIZE
21 "stp x24, x25, [x0, 376]", // GREGS_OFFSET + 24 * REGISTER_SIZE
22 "stp x26, x27, [x0, 392]", // GREGS_OFFSET + 26 * REGISTER_SIZE
23 "stp x28, x29, [x0, 408]", // GREGS_OFFSET + 28 * REGISTER_SIZE
24 "str x30, [x0, 424]", // GREGS_OFFSET + 30 * REGISTER_SIZE
25
26 // Place LR into the saved PC, this will ensure that when switching to this
27 // saved context with setcontext() control will pass back to the caller of
28 // getcontext(), we have already arranged to return the appropriate return
29 // value in x0 above.
30 "str x30, [x0, 440]",
31
32 // Save the current SP
33 "mov x2, sp",
34 "str x2, [x0, 432]",
35
36 // Initialize the pstate.
37 "str xzr, [x0, 448]",
38
39 // Figure out where to place the first context extension block.
40 "add x2, x0, #464",
41
42 // Write the context extension fpsimd header.
43 // FPSIMD_MAGIC = 0x46508001
44 "mov w3, #(0x46508001 & 0xffff)",
45 "movk w3, #(0x46508001 >> 16), lsl #16",
46 "str w3, [x2, #0]", // FPSIMD_CONTEXT_MAGIC_OFFSET
47 "mov w3, #528", // FPSIMD_CONTEXT_SIZE
48 "str w3, [x2, #4]", // FPSIMD_CONTEXT_SIZE_OFFSET
49
50 // Fill in the FP SIMD context.
51 "add x3, x2, #144", // VREGS_OFFSET + 8 * SIMD_REGISTER_SIZE
52 "stp d8, d9, [x3], #32",
53 "stp d10, d11, [x3], #32",
54 "stp d12, d13, [x3], #32",
55 "stp d14, d15, [x3], #32",
56
57 "add x3, x2, 8", // FPSR_OFFSET
58
59 "mrs x4, fpsr",
60 "str w4, [x3]",
61
62 "mrs x4, fpcr",
63 "str w4, [x3, 4]", // FPCR_OFFSET - FPSR_OFFSET
64
65 // Write the termination context extension header.
66 "add x2, x2, #528", // FPSIMD_CONTEXT_SIZE
67
68 "str xzr, [x2, #0]", // FPSIMD_CONTEXT_MAGIC_OFFSET
69 "str xzr, [x2, #4]", // FPSIMD_CONTEXT_SIZE_OFFSET
70
71 // Grab the signal mask
72 // rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8)
73 "add x2, x0, #40", // UCONTEXT_SIGMASK_OFFSET
74 "mov x0, #0", // SIG_BLOCK
75 "mov x1, #0", // NULL
76 "mov x3, #(64 / 8)", // _NSIG / 8
77 "mov x8, #135", // __NR_rt_sigprocmask
78 "svc 0",
79
80 // Return x0 for success
81 "mov x0, 0",
82 "ret",
83
84 ".cfi_endproc",
85 ".size crash_context_getcontext, . - crash_context_getcontext",
86 }