x86/acpi: Annotate indirect branch as safe
[linux-2.6-microblaze.git] / arch / x86 / kernel / acpi / wakeup_64.S
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 .text
3 #include <linux/linkage.h>
4 #include <asm/segment.h>
5 #include <asm/pgtable_types.h>
6 #include <asm/page_types.h>
7 #include <asm/msr.h>
8 #include <asm/asm-offsets.h>
9 #include <asm/frame.h>
10 #include <asm/nospec-branch.h>
11
12 # Copyright 2003 Pavel Machek <pavel@suse.cz
13
14 .code64
15         /*
16          * Hooray, we are in Long 64-bit mode (but still running in low memory)
17          */
18 SYM_FUNC_START(wakeup_long64)
19         movq    saved_magic, %rax
20         movq    $0x123456789abcdef0, %rdx
21         cmpq    %rdx, %rax
22         je      2f
23
24         /* stop here on a saved_magic mismatch */
25         movq $0xbad6d61676963, %rcx
26 1:
27         jmp 1b
28 2:
29         movw    $__KERNEL_DS, %ax
30         movw    %ax, %ss        
31         movw    %ax, %ds
32         movw    %ax, %es
33         movw    %ax, %fs
34         movw    %ax, %gs
35         movq    saved_rsp, %rsp
36
37         movq    saved_rbx, %rbx
38         movq    saved_rdi, %rdi
39         movq    saved_rsi, %rsi
40         movq    saved_rbp, %rbp
41
42         movq    saved_rip, %rax
43         ANNOTATE_RETPOLINE_SAFE
44         jmp     *%rax
45 SYM_FUNC_END(wakeup_long64)
46
47 SYM_FUNC_START(do_suspend_lowlevel)
48         FRAME_BEGIN
49         subq    $8, %rsp
50         xorl    %eax, %eax
51         call    save_processor_state
52
53         movq    $saved_context, %rax
54         movq    %rsp, pt_regs_sp(%rax)
55         movq    %rbp, pt_regs_bp(%rax)
56         movq    %rsi, pt_regs_si(%rax)
57         movq    %rdi, pt_regs_di(%rax)
58         movq    %rbx, pt_regs_bx(%rax)
59         movq    %rcx, pt_regs_cx(%rax)
60         movq    %rdx, pt_regs_dx(%rax)
61         movq    %r8, pt_regs_r8(%rax)
62         movq    %r9, pt_regs_r9(%rax)
63         movq    %r10, pt_regs_r10(%rax)
64         movq    %r11, pt_regs_r11(%rax)
65         movq    %r12, pt_regs_r12(%rax)
66         movq    %r13, pt_regs_r13(%rax)
67         movq    %r14, pt_regs_r14(%rax)
68         movq    %r15, pt_regs_r15(%rax)
69         pushfq
70         popq    pt_regs_flags(%rax)
71
72         movq    $.Lresume_point, saved_rip(%rip)
73
74         movq    %rsp, saved_rsp
75         movq    %rbp, saved_rbp
76         movq    %rbx, saved_rbx
77         movq    %rdi, saved_rdi
78         movq    %rsi, saved_rsi
79
80         addq    $8, %rsp
81         movl    $3, %edi
82         xorl    %eax, %eax
83         call    x86_acpi_enter_sleep_state
84         /* in case something went wrong, restore the machine status and go on */
85         jmp     .Lresume_point
86
87         .align 4
88 .Lresume_point:
89         /* We don't restore %rax, it must be 0 anyway */
90         movq    $saved_context, %rax
91         movq    saved_context_cr4(%rax), %rbx
92         movq    %rbx, %cr4
93         movq    saved_context_cr3(%rax), %rbx
94         movq    %rbx, %cr3
95         movq    saved_context_cr2(%rax), %rbx
96         movq    %rbx, %cr2
97         movq    saved_context_cr0(%rax), %rbx
98         movq    %rbx, %cr0
99         pushq   pt_regs_flags(%rax)
100         popfq
101         movq    pt_regs_sp(%rax), %rsp
102         movq    pt_regs_bp(%rax), %rbp
103         movq    pt_regs_si(%rax), %rsi
104         movq    pt_regs_di(%rax), %rdi
105         movq    pt_regs_bx(%rax), %rbx
106         movq    pt_regs_cx(%rax), %rcx
107         movq    pt_regs_dx(%rax), %rdx
108         movq    pt_regs_r8(%rax), %r8
109         movq    pt_regs_r9(%rax), %r9
110         movq    pt_regs_r10(%rax), %r10
111         movq    pt_regs_r11(%rax), %r11
112         movq    pt_regs_r12(%rax), %r12
113         movq    pt_regs_r13(%rax), %r13
114         movq    pt_regs_r14(%rax), %r14
115         movq    pt_regs_r15(%rax), %r15
116
117 #if defined(CONFIG_KASAN) && CONFIG_KASAN_STACK
118         /*
119          * The suspend path may have poisoned some areas deeper in the stack,
120          * which we now need to unpoison.
121          */
122         movq    %rsp, %rdi
123         call    kasan_unpoison_task_stack_below
124 #endif
125
126         xorl    %eax, %eax
127         addq    $8, %rsp
128         FRAME_END
129         jmp     restore_processor_state
130 SYM_FUNC_END(do_suspend_lowlevel)
131
132 .data
133 saved_rbp:              .quad   0
134 saved_rsi:              .quad   0
135 saved_rdi:              .quad   0
136 saved_rbx:              .quad   0
137
138 saved_rip:              .quad   0
139 saved_rsp:              .quad   0
140
141 SYM_DATA(saved_magic,   .quad   0)