Path: blob/master/tools/perf/arch/x86/tests/regs_load.S
26292 views
/* SPDX-License-Identifier: GPL-2.0 */1#include <linux/linkage.h>23#define AX 04#define BX 1 * 85#define CX 2 * 86#define DX 3 * 87#define SI 4 * 88#define DI 5 * 89#define BP 6 * 810#define SP 7 * 811#define IP 8 * 812#define FLAGS 9 * 813#define CS 10 * 814#define SS 11 * 815#define DS 12 * 816#define ES 13 * 817#define FS 14 * 818#define GS 15 * 819#define R8 16 * 820#define R9 17 * 821#define R10 18 * 822#define R11 19 * 823#define R12 20 * 824#define R13 21 * 825#define R14 22 * 826#define R15 23 * 82728.text29#ifdef HAVE_ARCH_X86_64_SUPPORT30SYM_FUNC_START(perf_regs_load)31movq %rax, AX(%rdi)32movq %rbx, BX(%rdi)33movq %rcx, CX(%rdi)34movq %rdx, DX(%rdi)35movq %rsi, SI(%rdi)36movq %rdi, DI(%rdi)37movq %rbp, BP(%rdi)3839leaq 8(%rsp), %rax /* exclude this call. */40movq %rax, SP(%rdi)4142movq 0(%rsp), %rax43movq %rax, IP(%rdi)4445movq $0, FLAGS(%rdi)46movq $0, CS(%rdi)47movq $0, SS(%rdi)48movq $0, DS(%rdi)49movq $0, ES(%rdi)50movq $0, FS(%rdi)51movq $0, GS(%rdi)5253movq %r8, R8(%rdi)54movq %r9, R9(%rdi)55movq %r10, R10(%rdi)56movq %r11, R11(%rdi)57movq %r12, R12(%rdi)58movq %r13, R13(%rdi)59movq %r14, R14(%rdi)60movq %r15, R15(%rdi)61ret62SYM_FUNC_END(perf_regs_load)63#else64SYM_FUNC_START(perf_regs_load)65push %edi66movl 8(%esp), %edi67movl %eax, AX(%edi)68movl %ebx, BX(%edi)69movl %ecx, CX(%edi)70movl %edx, DX(%edi)71movl %esi, SI(%edi)72pop %eax73movl %eax, DI(%edi)74movl %ebp, BP(%edi)7576leal 4(%esp), %eax /* exclude this call. */77movl %eax, SP(%edi)7879movl 0(%esp), %eax80movl %eax, IP(%edi)8182movl $0, FLAGS(%edi)83movl $0, CS(%edi)84movl $0, SS(%edi)85movl $0, DS(%edi)86movl $0, ES(%edi)87movl $0, FS(%edi)88movl $0, GS(%edi)89ret90SYM_FUNC_END(perf_regs_load)91#endif9293/*94* We need to provide note.GNU-stack section, saying that we want95* NOT executable stack. Otherwise the final linking will assume that96* the ELF stack should not be restricted at all and set it RWX.97*/98.section .note.GNU-stack,"",@progbits99100101