Skip to content

Commit 56415c4

Browse files
committed
x86/xen: eliminate xen-asm_64.S
With 32-bit pv-guest support removed xen-asm_64.S can be merged with xen-asm.S Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent a13f2ef commit 56415c4

File tree

3 files changed

+180
-195
lines changed

3 files changed

+180
-195
lines changed

arch/x86/xen/Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
OBJECT_FILES_NON_STANDARD_xen-asm_$(BITS).o := y
2+
OBJECT_FILES_NON_STANDARD_xen-asm.o := y
33

44
ifdef CONFIG_FUNCTION_TRACER
55
# Do not profile debug and lowlevel utilities
@@ -34,7 +34,6 @@ obj-$(CONFIG_XEN_PV) += mmu_pv.o
3434
obj-$(CONFIG_XEN_PV) += irq.o
3535
obj-$(CONFIG_XEN_PV) += multicalls.o
3636
obj-$(CONFIG_XEN_PV) += xen-asm.o
37-
obj-$(CONFIG_XEN_PV) += xen-asm_$(BITS).o
3837

3938
obj-$(CONFIG_XEN_PVH) += enlighten_pvh.o
4039

arch/x86/xen/xen-asm.S

Lines changed: 179 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
* operations here; the indirect forms are better handled in C.
77
*/
88

9+
#include <asm/errno.h>
910
#include <asm/asm-offsets.h>
1011
#include <asm/percpu.h>
1112
#include <asm/processor-flags.h>
12-
#include <asm/frame.h>
13+
#include <asm/segment.h>
14+
#include <asm/thread_info.h>
1315
#include <asm/asm.h>
16+
#include <asm/frame.h>
17+
18+
#include <xen/interface/xen.h>
1419

20+
#include <linux/init.h>
1521
#include <linux/linkage.h>
1622

1723
/*
@@ -137,3 +143,175 @@ SYM_FUNC_START(xen_read_cr2_direct)
137143
FRAME_END
138144
ret
139145
SYM_FUNC_END(xen_read_cr2_direct);
146+
147+
.macro xen_pv_trap name
148+
SYM_CODE_START(xen_\name)
149+
pop %rcx
150+
pop %r11
151+
jmp \name
152+
SYM_CODE_END(xen_\name)
153+
_ASM_NOKPROBE(xen_\name)
154+
.endm
155+
156+
xen_pv_trap asm_exc_divide_error
157+
xen_pv_trap asm_xenpv_exc_debug
158+
xen_pv_trap asm_exc_int3
159+
xen_pv_trap asm_xenpv_exc_nmi
160+
xen_pv_trap asm_exc_overflow
161+
xen_pv_trap asm_exc_bounds
162+
xen_pv_trap asm_exc_invalid_op
163+
xen_pv_trap asm_exc_device_not_available
164+
xen_pv_trap asm_exc_double_fault
165+
xen_pv_trap asm_exc_coproc_segment_overrun
166+
xen_pv_trap asm_exc_invalid_tss
167+
xen_pv_trap asm_exc_segment_not_present
168+
xen_pv_trap asm_exc_stack_segment
169+
xen_pv_trap asm_exc_general_protection
170+
xen_pv_trap asm_exc_page_fault
171+
xen_pv_trap asm_exc_spurious_interrupt_bug
172+
xen_pv_trap asm_exc_coprocessor_error
173+
xen_pv_trap asm_exc_alignment_check
174+
#ifdef CONFIG_X86_MCE
175+
xen_pv_trap asm_exc_machine_check
176+
#endif /* CONFIG_X86_MCE */
177+
xen_pv_trap asm_exc_simd_coprocessor_error
178+
#ifdef CONFIG_IA32_EMULATION
179+
xen_pv_trap entry_INT80_compat
180+
#endif
181+
xen_pv_trap asm_exc_xen_hypervisor_callback
182+
183+
__INIT
184+
SYM_CODE_START(xen_early_idt_handler_array)
185+
i = 0
186+
.rept NUM_EXCEPTION_VECTORS
187+
pop %rcx
188+
pop %r11
189+
jmp early_idt_handler_array + i*EARLY_IDT_HANDLER_SIZE
190+
i = i + 1
191+
.fill xen_early_idt_handler_array + i*XEN_EARLY_IDT_HANDLER_SIZE - ., 1, 0xcc
192+
.endr
193+
SYM_CODE_END(xen_early_idt_handler_array)
194+
__FINIT
195+
196+
hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
197+
/*
198+
* Xen64 iret frame:
199+
*
200+
* ss
201+
* rsp
202+
* rflags
203+
* cs
204+
* rip <-- standard iret frame
205+
*
206+
* flags
207+
*
208+
* rcx }
209+
* r11 }<-- pushed by hypercall page
210+
* rsp->rax }
211+
*/
212+
SYM_CODE_START(xen_iret)
213+
pushq $0
214+
jmp hypercall_iret
215+
SYM_CODE_END(xen_iret)
216+
217+
SYM_CODE_START(xen_sysret64)
218+
/*
219+
* We're already on the usermode stack at this point, but
220+
* still with the kernel gs, so we can easily switch back.
221+
*
222+
* tss.sp2 is scratch space.
223+
*/
224+
movq %rsp, PER_CPU_VAR(cpu_tss_rw + TSS_sp2)
225+
movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
226+
227+
pushq $__USER_DS
228+
pushq PER_CPU_VAR(cpu_tss_rw + TSS_sp2)
229+
pushq %r11
230+
pushq $__USER_CS
231+
pushq %rcx
232+
233+
pushq $VGCF_in_syscall
234+
jmp hypercall_iret
235+
SYM_CODE_END(xen_sysret64)
236+
237+
/*
238+
* Xen handles syscall callbacks much like ordinary exceptions, which
239+
* means we have:
240+
* - kernel gs
241+
* - kernel rsp
242+
* - an iret-like stack frame on the stack (including rcx and r11):
243+
* ss
244+
* rsp
245+
* rflags
246+
* cs
247+
* rip
248+
* r11
249+
* rsp->rcx
250+
*/
251+
252+
/* Normal 64-bit system call target */
253+
SYM_FUNC_START(xen_syscall_target)
254+
popq %rcx
255+
popq %r11
256+
257+
/*
258+
* Neither Xen nor the kernel really knows what the old SS and
259+
* CS were. The kernel expects __USER_DS and __USER_CS, so
260+
* report those values even though Xen will guess its own values.
261+
*/
262+
movq $__USER_DS, 4*8(%rsp)
263+
movq $__USER_CS, 1*8(%rsp)
264+
265+
jmp entry_SYSCALL_64_after_hwframe
266+
SYM_FUNC_END(xen_syscall_target)
267+
268+
#ifdef CONFIG_IA32_EMULATION
269+
270+
/* 32-bit compat syscall target */
271+
SYM_FUNC_START(xen_syscall32_target)
272+
popq %rcx
273+
popq %r11
274+
275+
/*
276+
* Neither Xen nor the kernel really knows what the old SS and
277+
* CS were. The kernel expects __USER32_DS and __USER32_CS, so
278+
* report those values even though Xen will guess its own values.
279+
*/
280+
movq $__USER32_DS, 4*8(%rsp)
281+
movq $__USER32_CS, 1*8(%rsp)
282+
283+
jmp entry_SYSCALL_compat_after_hwframe
284+
SYM_FUNC_END(xen_syscall32_target)
285+
286+
/* 32-bit compat sysenter target */
287+
SYM_FUNC_START(xen_sysenter_target)
288+
/*
289+
* NB: Xen is polite and clears TF from EFLAGS for us. This means
290+
* that we don't need to guard against single step exceptions here.
291+
*/
292+
popq %rcx
293+
popq %r11
294+
295+
/*
296+
* Neither Xen nor the kernel really knows what the old SS and
297+
* CS were. The kernel expects __USER32_DS and __USER32_CS, so
298+
* report those values even though Xen will guess its own values.
299+
*/
300+
movq $__USER32_DS, 4*8(%rsp)
301+
movq $__USER32_CS, 1*8(%rsp)
302+
303+
jmp entry_SYSENTER_compat_after_hwframe
304+
SYM_FUNC_END(xen_sysenter_target)
305+
306+
#else /* !CONFIG_IA32_EMULATION */
307+
308+
SYM_FUNC_START_ALIAS(xen_syscall32_target)
309+
SYM_FUNC_START(xen_sysenter_target)
310+
lea 16(%rsp), %rsp /* strip %rcx, %r11 */
311+
mov $-ENOSYS, %rax
312+
pushq $0
313+
jmp hypercall_iret
314+
SYM_FUNC_END(xen_sysenter_target)
315+
SYM_FUNC_END_ALIAS(xen_syscall32_target)
316+
317+
#endif /* CONFIG_IA32_EMULATION */

0 commit comments

Comments
 (0)