18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#include <linux/linkage.h>
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci#define AX	 0
58c2ecf20Sopenharmony_ci#define BX	 1 * 8
68c2ecf20Sopenharmony_ci#define CX	 2 * 8
78c2ecf20Sopenharmony_ci#define DX	 3 * 8
88c2ecf20Sopenharmony_ci#define SI	 4 * 8
98c2ecf20Sopenharmony_ci#define DI	 5 * 8
108c2ecf20Sopenharmony_ci#define BP	 6 * 8
118c2ecf20Sopenharmony_ci#define SP	 7 * 8
128c2ecf20Sopenharmony_ci#define IP	 8 * 8
138c2ecf20Sopenharmony_ci#define FLAGS	 9 * 8
148c2ecf20Sopenharmony_ci#define CS	10 * 8
158c2ecf20Sopenharmony_ci#define SS	11 * 8
168c2ecf20Sopenharmony_ci#define DS	12 * 8
178c2ecf20Sopenharmony_ci#define ES	13 * 8
188c2ecf20Sopenharmony_ci#define FS	14 * 8
198c2ecf20Sopenharmony_ci#define GS	15 * 8
208c2ecf20Sopenharmony_ci#define R8	16 * 8
218c2ecf20Sopenharmony_ci#define R9	17 * 8
228c2ecf20Sopenharmony_ci#define R10	18 * 8
238c2ecf20Sopenharmony_ci#define R11	19 * 8
248c2ecf20Sopenharmony_ci#define R12	20 * 8
258c2ecf20Sopenharmony_ci#define R13	21 * 8
268c2ecf20Sopenharmony_ci#define R14	22 * 8
278c2ecf20Sopenharmony_ci#define R15	23 * 8
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci.text
308c2ecf20Sopenharmony_ci#ifdef HAVE_ARCH_X86_64_SUPPORT
318c2ecf20Sopenharmony_ciSYM_FUNC_START(perf_regs_load)
328c2ecf20Sopenharmony_ci	movq %rax, AX(%rdi)
338c2ecf20Sopenharmony_ci	movq %rbx, BX(%rdi)
348c2ecf20Sopenharmony_ci	movq %rcx, CX(%rdi)
358c2ecf20Sopenharmony_ci	movq %rdx, DX(%rdi)
368c2ecf20Sopenharmony_ci	movq %rsi, SI(%rdi)
378c2ecf20Sopenharmony_ci	movq %rdi, DI(%rdi)
388c2ecf20Sopenharmony_ci	movq %rbp, BP(%rdi)
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	leaq 8(%rsp), %rax /* exclude this call.  */
418c2ecf20Sopenharmony_ci	movq %rax, SP(%rdi)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	movq 0(%rsp), %rax
448c2ecf20Sopenharmony_ci	movq %rax, IP(%rdi)
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	movq $0, FLAGS(%rdi)
478c2ecf20Sopenharmony_ci	movq $0, CS(%rdi)
488c2ecf20Sopenharmony_ci	movq $0, SS(%rdi)
498c2ecf20Sopenharmony_ci	movq $0, DS(%rdi)
508c2ecf20Sopenharmony_ci	movq $0, ES(%rdi)
518c2ecf20Sopenharmony_ci	movq $0, FS(%rdi)
528c2ecf20Sopenharmony_ci	movq $0, GS(%rdi)
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci	movq %r8,  R8(%rdi)
558c2ecf20Sopenharmony_ci	movq %r9,  R9(%rdi)
568c2ecf20Sopenharmony_ci	movq %r10, R10(%rdi)
578c2ecf20Sopenharmony_ci	movq %r11, R11(%rdi)
588c2ecf20Sopenharmony_ci	movq %r12, R12(%rdi)
598c2ecf20Sopenharmony_ci	movq %r13, R13(%rdi)
608c2ecf20Sopenharmony_ci	movq %r14, R14(%rdi)
618c2ecf20Sopenharmony_ci	movq %r15, R15(%rdi)
628c2ecf20Sopenharmony_ci	ret
638c2ecf20Sopenharmony_ciSYM_FUNC_END(perf_regs_load)
648c2ecf20Sopenharmony_ci#else
658c2ecf20Sopenharmony_ciSYM_FUNC_START(perf_regs_load)
668c2ecf20Sopenharmony_ci	push %edi
678c2ecf20Sopenharmony_ci	movl 8(%esp), %edi
688c2ecf20Sopenharmony_ci	movl %eax, AX(%edi)
698c2ecf20Sopenharmony_ci	movl %ebx, BX(%edi)
708c2ecf20Sopenharmony_ci	movl %ecx, CX(%edi)
718c2ecf20Sopenharmony_ci	movl %edx, DX(%edi)
728c2ecf20Sopenharmony_ci	movl %esi, SI(%edi)
738c2ecf20Sopenharmony_ci	pop %eax
748c2ecf20Sopenharmony_ci	movl %eax, DI(%edi)
758c2ecf20Sopenharmony_ci	movl %ebp, BP(%edi)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	leal 4(%esp), %eax /* exclude this call.  */
788c2ecf20Sopenharmony_ci	movl %eax, SP(%edi)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	movl 0(%esp), %eax
818c2ecf20Sopenharmony_ci	movl %eax, IP(%edi)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	movl $0, FLAGS(%edi)
848c2ecf20Sopenharmony_ci	movl $0, CS(%edi)
858c2ecf20Sopenharmony_ci	movl $0, SS(%edi)
868c2ecf20Sopenharmony_ci	movl $0, DS(%edi)
878c2ecf20Sopenharmony_ci	movl $0, ES(%edi)
888c2ecf20Sopenharmony_ci	movl $0, FS(%edi)
898c2ecf20Sopenharmony_ci	movl $0, GS(%edi)
908c2ecf20Sopenharmony_ci	ret
918c2ecf20Sopenharmony_ciSYM_FUNC_END(perf_regs_load)
928c2ecf20Sopenharmony_ci#endif
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/*
958c2ecf20Sopenharmony_ci * We need to provide note.GNU-stack section, saying that we want
968c2ecf20Sopenharmony_ci * NOT executable stack. Otherwise the final linking will assume that
978c2ecf20Sopenharmony_ci * the ELF stack should not be restricted at all and set it RWX.
988c2ecf20Sopenharmony_ci */
998c2ecf20Sopenharmony_ci.section .note.GNU-stack,"",@progbits
100