2 * Asm versions of Xen pv-ops, suitable for either direct use or
3 * inlining. The inline versions are the same as the direct-use
4 * versions, with the pre- and post-amble chopped off.
6 * This code is encoded for size rather than absolute efficiency, with
7 * a view to being able to inline as much as possible.
9 * We only bother with direct forms (ie, vcpu in pda) of the
10 * operations here; the indirect forms are better handled in C, since
11 * they're generally too large to inline anyway.
14 #include <asm/errno.h>
15 #include <asm/percpu.h>
16 #include <asm/processor-flags.h>
17 #include <asm/segment.h>
18 #include <asm/asm-offsets.h>
19 #include <asm/thread_info.h>
21 #include <xen/interface/xen.h>
25 ENTRY(xen_adjust_exception_frame)
29 ENDPROC(xen_adjust_exception_frame)
31 hypercall_iret = hypercall_page + __HYPERVISOR_iret * 32
39 * rip <-- standard iret frame
44 * r11 }<-- pushed by hypercall page
55 * We're already on the usermode stack at this point, but
56 * still with the kernel gs, so we can easily switch back
58 movq %rsp, PER_CPU_VAR(rsp_scratch)
59 movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
62 pushq PER_CPU_VAR(rsp_scratch)
67 pushq $VGCF_in_syscall
69 ENDPATCH(xen_sysret64)
70 RELOC(xen_sysret64, 1b+1)
73 * Xen handles syscall callbacks much like ordinary exceptions, which
77 * - an iret-like stack frame on the stack (including rcx and r11):
86 * In all the entrypoints, we undo all that to make it look like a
87 * CPU-generated syscall/sysenter and jump to the normal entrypoint.
90 .macro undo_xen_syscall
96 /* Normal 64-bit system call target */
97 ENTRY(xen_syscall_target)
99 jmp entry_SYSCALL_64_after_swapgs
100 ENDPROC(xen_syscall_target)
102 #ifdef CONFIG_IA32_EMULATION
104 /* 32-bit compat syscall target */
105 ENTRY(xen_syscall32_target)
107 jmp entry_SYSCALL_compat
108 ENDPROC(xen_syscall32_target)
110 /* 32-bit compat sysenter target */
111 ENTRY(xen_sysenter_target)
113 jmp entry_SYSENTER_compat
114 ENDPROC(xen_sysenter_target)
116 #else /* !CONFIG_IA32_EMULATION */
118 ENTRY(xen_syscall32_target)
119 ENTRY(xen_sysenter_target)
120 lea 16(%rsp), %rsp /* strip %rcx, %r11 */
124 ENDPROC(xen_syscall32_target)
125 ENDPROC(xen_sysenter_target)
127 #endif /* CONFIG_IA32_EMULATION */