forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/x86/platform/efi/efi_thunk_64.S
....@@ -22,18 +22,20 @@
2222 #include <linux/linkage.h>
2323 #include <asm/page_types.h>
2424 #include <asm/segment.h>
25
+#include <asm/nospec-branch.h>
2526
2627 .text
2728 .code64
28
-ENTRY(efi64_thunk)
29
+SYM_CODE_START(__efi64_thunk)
2930 push %rbp
3031 push %rbx
3132
3233 /*
3334 * Switch to 1:1 mapped 32-bit stack pointer.
3435 */
35
- movq %rsp, efi_saved_sp(%rip)
36
+ movq %rsp, %rax
3637 movq efi_scratch(%rip), %rsp
38
+ push %rax
3739
3840 /*
3941 * Calculate the physical address of the kernel text.
....@@ -41,113 +43,33 @@
4143 movq $__START_KERNEL_map, %rax
4244 subq phys_base(%rip), %rax
4345
44
- /*
45
- * Push some physical addresses onto the stack. This is easier
46
- * to do now in a code64 section while the assembler can address
47
- * 64-bit values. Note that all the addresses on the stack are
48
- * 32-bit.
49
- */
50
- subq $16, %rsp
51
- leaq efi_exit32(%rip), %rbx
46
+ leaq 1f(%rip), %rbp
47
+ leaq 2f(%rip), %rbx
48
+ subq %rax, %rbp
5249 subq %rax, %rbx
53
- movl %ebx, 8(%rsp)
5450
55
- leaq __efi64_thunk(%rip), %rbx
56
- subq %rax, %rbx
57
- call *%rbx
58
-
59
- movq efi_saved_sp(%rip), %rsp
60
- pop %rbx
61
- pop %rbp
62
- retq
63
-ENDPROC(efi64_thunk)
64
-
65
-/*
66
- * We run this function from the 1:1 mapping.
67
- *
68
- * This function must be invoked with a 1:1 mapped stack.
69
- */
70
-ENTRY(__efi64_thunk)
71
- movl %ds, %eax
72
- push %rax
73
- movl %es, %eax
74
- push %rax
75
- movl %ss, %eax
76
- push %rax
77
-
78
- subq $32, %rsp
79
- movl %esi, 0x0(%rsp)
80
- movl %edx, 0x4(%rsp)
81
- movl %ecx, 0x8(%rsp)
82
- movq %r8, %rsi
83
- movl %esi, 0xc(%rsp)
84
- movq %r9, %rsi
85
- movl %esi, 0x10(%rsp)
86
-
87
- leaq 1f(%rip), %rbx
88
- movq %rbx, func_rt_ptr(%rip)
51
+ subq $28, %rsp
52
+ movl %ebx, 0x0(%rsp) /* return address */
53
+ movl %esi, 0x4(%rsp)
54
+ movl %edx, 0x8(%rsp)
55
+ movl %ecx, 0xc(%rsp)
56
+ movl %r8d, 0x10(%rsp)
57
+ movl %r9d, 0x14(%rsp)
8958
9059 /* Switch to 32-bit descriptor */
9160 pushq $__KERNEL32_CS
92
- leaq efi_enter32(%rip), %rax
93
- pushq %rax
61
+ pushq %rdi /* EFI runtime service address */
9462 lretq
9563
96
-1: addq $32, %rsp
97
-
64
+1: movq 24(%rsp), %rsp
9865 pop %rbx
99
- movl %ebx, %ss
100
- pop %rbx
101
- movl %ebx, %es
102
- pop %rbx
103
- movl %ebx, %ds
104
-
105
- /*
106
- * Convert 32-bit status code into 64-bit.
107
- */
108
- test %rax, %rax
109
- jz 1f
110
- movl %eax, %ecx
111
- andl $0x0fffffff, %ecx
112
- andl $0xf0000000, %eax
113
- shl $32, %rax
114
- or %rcx, %rax
115
-1:
66
+ pop %rbp
67
+ ANNOTATE_UNRET_SAFE
11668 ret
117
-ENDPROC(__efi64_thunk)
118
-
119
-ENTRY(efi_exit32)
120
- movq func_rt_ptr(%rip), %rax
121
- push %rax
122
- mov %rdi, %rax
123
- ret
124
-ENDPROC(efi_exit32)
69
+ int3
12570
12671 .code32
127
-/*
128
- * EFI service pointer must be in %edi.
129
- *
130
- * The stack should represent the 32-bit calling convention.
131
- */
132
-ENTRY(efi_enter32)
133
- movl $__KERNEL_DS, %eax
134
- movl %eax, %ds
135
- movl %eax, %es
136
- movl %eax, %ss
137
-
138
- call *%edi
139
-
140
- /* We must preserve return value */
141
- movl %eax, %edi
142
-
143
- movl 72(%esp), %eax
144
- pushl $__KERNEL_CS
145
- pushl %eax
146
-
72
+2: pushl $__KERNEL_CS
73
+ pushl %ebp
14774 lret
148
-ENDPROC(efi_enter32)
149
-
150
- .data
151
- .balign 8
152
-func_rt_ptr: .quad 0
153
-efi_saved_sp: .quad 0
75
+SYM_CODE_END(__efi64_thunk)