Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #include <linux/linkage.h>
0003 
0004 #define AX   0
0005 #define BX   1 * 8
0006 #define CX   2 * 8
0007 #define DX   3 * 8
0008 #define SI   4 * 8
0009 #define DI   5 * 8
0010 #define BP   6 * 8
0011 #define SP   7 * 8
0012 #define IP   8 * 8
0013 #define FLAGS    9 * 8
0014 #define CS  10 * 8
0015 #define SS  11 * 8
0016 #define DS  12 * 8
0017 #define ES  13 * 8
0018 #define FS  14 * 8
0019 #define GS  15 * 8
0020 #define R8  16 * 8
0021 #define R9  17 * 8
0022 #define R10 18 * 8
0023 #define R11 19 * 8
0024 #define R12 20 * 8
0025 #define R13 21 * 8
0026 #define R14 22 * 8
0027 #define R15 23 * 8
0028 
0029 .text
0030 #ifdef HAVE_ARCH_X86_64_SUPPORT
0031 SYM_FUNC_START(perf_regs_load)
0032     movq %rax, AX(%rdi)
0033     movq %rbx, BX(%rdi)
0034     movq %rcx, CX(%rdi)
0035     movq %rdx, DX(%rdi)
0036     movq %rsi, SI(%rdi)
0037     movq %rdi, DI(%rdi)
0038     movq %rbp, BP(%rdi)
0039 
0040     leaq 8(%rsp), %rax /* exclude this call.  */
0041     movq %rax, SP(%rdi)
0042 
0043     movq 0(%rsp), %rax
0044     movq %rax, IP(%rdi)
0045 
0046     movq $0, FLAGS(%rdi)
0047     movq $0, CS(%rdi)
0048     movq $0, SS(%rdi)
0049     movq $0, DS(%rdi)
0050     movq $0, ES(%rdi)
0051     movq $0, FS(%rdi)
0052     movq $0, GS(%rdi)
0053 
0054     movq %r8,  R8(%rdi)
0055     movq %r9,  R9(%rdi)
0056     movq %r10, R10(%rdi)
0057     movq %r11, R11(%rdi)
0058     movq %r12, R12(%rdi)
0059     movq %r13, R13(%rdi)
0060     movq %r14, R14(%rdi)
0061     movq %r15, R15(%rdi)
0062     ret
0063 SYM_FUNC_END(perf_regs_load)
0064 #else
0065 SYM_FUNC_START(perf_regs_load)
0066     push %edi
0067     movl 8(%esp), %edi
0068     movl %eax, AX(%edi)
0069     movl %ebx, BX(%edi)
0070     movl %ecx, CX(%edi)
0071     movl %edx, DX(%edi)
0072     movl %esi, SI(%edi)
0073     pop %eax
0074     movl %eax, DI(%edi)
0075     movl %ebp, BP(%edi)
0076 
0077     leal 4(%esp), %eax /* exclude this call.  */
0078     movl %eax, SP(%edi)
0079 
0080     movl 0(%esp), %eax
0081     movl %eax, IP(%edi)
0082 
0083     movl $0, FLAGS(%edi)
0084     movl $0, CS(%edi)
0085     movl $0, SS(%edi)
0086     movl $0, DS(%edi)
0087     movl $0, ES(%edi)
0088     movl $0, FS(%edi)
0089     movl $0, GS(%edi)
0090     ret
0091 SYM_FUNC_END(perf_regs_load)
0092 #endif
0093 
0094 /*
0095  * We need to provide note.GNU-stack section, saying that we want
0096  * NOT executable stack. Otherwise the final linking will assume that
0097  * the ELF stack should not be restricted at all and set it RWX.
0098  */
0099 .section .note.GNU-stack,"",@progbits